In this 3-way currency exchange, who loses, and by how much? Let's say, hypothetically, we have the following imbalanced exchange rates:

1USD = 1.2EUR

1.2EUR = 1000 JPY

1000 JPY = 1.5 USD

Let's say person A starts off with 1 USD, buys 1.2 EUR from B, then buys 1000 JPY from C with the 1.2 EUR, then finally buys 1.5 USD from D with the 1000 JPY.

Person A now has .5 more USD than they started with. Where did the .5 USD come from? Who lost that equivalent amount? Does it depend on the exchange rates before and after this imbalance happens?
If the starting balances were

A = 1USD
B = 1.2EUR
C = 1000JPY
D = 1.5USD


then the ending balances are

A = 1.5USD
B = 1USD
C = 1.2EUR
D = 1000JPY


so the simple answer to where the 0.5USD came from is D.

A more complicated answer would be some combination of B, C and D depending on how the exchange rates rebalanced to iron out this arbitrage opportunity.

For example if 1000JPY dropped back to 1USD, then D could do some exchanges with B and C leaving them where they started and D with 1USD, i.e. D lost the 0.5USD

But if the EUR/JPY changed so that 1.8EUR = 1000JPY, then C ends up with -0.5USD, if you do exchanges to restore the JPY and EUR to where they started.

If USD/EUR changed so that 1.5USD = 1.2EUR, B ends up with -0.5USD.