Diagnose an Aave v3 simple flash loan that reverts after its callback
The receiver can return true from executeOperation and still fail settlement. The reference pool subsequently pulls the principal plus premium from the receiver.
Check the receiver at the end of its callback
For a controlled transaction, verify the actual pool caller, initiator and reserve asset. Read the premium passed to the callback. In the example the receiver must hold and authorize 1,000,500 raw units when the callback returns.
principal = 1000000 raw units
callback premium = 500
required post-callback balance and pool allowance = 1000500
Approving only the principal can leave the final transferFrom short by 500. Approve the pool that performs the pull and verify the underlying token allowance and balance independently. An approval to an aToken address does not authorize this pool call.
Use the simple-loan path’s rules
The simple flash-loan path requires repayment and has no interest-rate mode for opening debt. Do not import the multi-asset flash loan’s optional debt behavior into this test. A reverted settlement reverts the enclosing transaction, including intermediate token movements. github.com FlashLoanLogic.sol