The actual numbers behind how payouts are determined are pretty complex, but I’ll try to break it down for you.
When Player A invades Player B, there is a base percentage of Player B’s total gold income that Player A will be able to take. That percentage can increase or decrease based on each player’s attributes, and the total gold taken will increase the longer Player B goes without collecting their daily rewards. Because there are so many variables (and the game never tells you exactly how much gold the other player has coming), the exact amount Player B could lose from their next payout can vary wildly, especially if Player A is of an especially high level.
But this is where Revenge comes in. If Player B is attacked and loses X amount of gold, they can immediately turn around and attack Player A. If successful, not only will Player B regain all of the gold they lost, but they’ll also pick up some extra gold for their trouble.
Hope that helps!