I was going through some basic stuff and I found something that I couldn't really make sense of. Lets say that two entities A and B engage in a currency swap. A pays 3% on USD, while B pays 2% on JPY. While I understand that the discrepancy in the interest rate stem from the fact that A and B might have different credit ratings from the US and Japan, it seems to me that this would lead to an arbitrage opportunity. If we cut out the middleman, wouldn't this mean that B will be earning a free percentage on the principle? Or, is my understanding of currency swaps and comparative advantage just bogus?
Criticism is welcome as long as they are constructive. I would appreciate any input.