@chiefvulcan
The amount of gold
The defender loses isn't in proportion to the attackers stats, of the defenders or that matter. You lose gold as a percentage, that's why you lose a smaller amount during the second attack if there is one, then the first attack.
What the attacker gains depends on the defenders stats in proportion to the attackers.The smaller the attacker compared to the defender, the more you gain. Also, buildings that have a higher defence bonus then an attack (all tiers have a building that gives more attack than defence, more defence than attack and then a balanced, so 3 versions) will give you more plunder. Equipment and pots aren't involved in the math, at least not that I'm aware of.. I know that certain buildings give bad plunder to an attacker, hence why if you attack a guild Handel you'll be lucky to get more than 3 million per hit, whereas if they hit you they'll get up to 40 , so long as you aren't a guild Handel and are significantly bigger than them.