I didn't see this posted anywhere, so I did a statistical regression analysis (R^2=0.989) on a large number of attacks done against people higher and lower cups. I found that the cups you win seems to based off nothing besides the difference in trophies between you and them, not town hall level, not storages or anything else. I found:
# cups won for 3-star = 30 - [cup difference] / 12
You get one-third, or two-thirds, rounded down, for 1-star or 2-star wins.
Simple.

