Ivermectin based dewormer. These larvae hook in to the lining of the pony's stomach and damage it... often causing ulcers and even ruptures.

Something to be aware of if their condition doesn't show significant improvement now they're being properly cared for.