AAVE flash loan documentation states

You do not need to transfer the owed amount back to the Pool. The funds will be automatically pulled at the conclusion of your operation.

But how does the ether get automatically transferred back to the loaning pool? I understand that your contract needs to implement an interface, but how does the interface force giving back the funds?

  • Ah there's transferFundsBackToPoolInternal, but not entirely sure how exactly it gets called.
    – Majiick
    Commented Jan 23, 2023 at 22:16

1 Answer 1


You cannot flash loan ETH, only ERC20 tokens, which are pulled by the pool using transferFrom() once control is given back to it, which is why it's required that you give approval to the pool contract.

  • Ah, so prior to loaning you need to be an approve() call from the borrower? I guess that's the missing step.
    – Majiick
    Commented Jan 24, 2023 at 18:36
  • 1
    So it goes like: Contract X calls Flashloan contract -> Flashloan gives a loan and calls executeOperation on contract X -> execute completes -> contract X approves for the loaned amount -> Flashloan contract calls transferFrom(), if transferFrom() fails then the whole TX is cancelled.
    – Majiick
    Commented Jan 24, 2023 at 18:37
  • ethereum.stackexchange.com/questions/125476/… has more info
    – Majiick
    Commented Jan 24, 2023 at 18:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.