The registerTradeAndBorrow is called with the results of a trade (inAmount, outAmount). It first tries to pay back any debt with the outAmount. However, the full outAmount is credited to the user again as a deposit in the adjustAmounts(account, tokenFrom, tokenTo, sellAmount, outAmount); call. As the user pays back their debt and is credited the same amount again, they are essentially credited twice the outAmount, making a profit of one outAmount. This can be withdrawn and the process can be repeated until the funds are empty.
In the adjustAmounts call, it should only credit outAmount - extinguishableDebt as a deposit like in registerDeposit.
The registerDeposit function correctly handles this case.
