Submitted by 0xAlix2, also found by pkqs90 (1, 2)
When users take a flash loan, an amount is sent to the receiver, and then some action takes place, after that action that sent amount is expected to be paid and some fee. Users can also call PositionAction::decreaseLever through a proxy, to Decrease the leverage of a position by taking out a credit flash loan to withdraw and sell collateral, after it is called, the flash loan lender sends the credit and calls onCreditFlashLoan, which handles all that logic.
This was reported in Issue 524, and a fix has been implemented. However, the fix is incomplete, and the onCreditFlashLoan will always revert when the fees are >0.
The fix added includes adding fees to the approval amounts:
That fix still misses a point; the amount coming from the flash lender is constant, and that amount will be used to repay a positions debt. The issue here is that all the amount is being used to repay without accounting for the extra fees that the flash lender will be requesting.
This causes PositionAction::onCreditFlashLoan to always revert.
Add the following test in src/test/integration/PositionAction20.lever.t.sol:
DoS
amarcu (LoopFi) confirmed
