I try to understand how to get a flashloan from euqlizer finance and make something with it. There is a documentation where they say I have to call the onFlashLoan(...) function to borrow the flashloan (Equalizer Docs).

But then I found a github repository where it is a full code example (Equalizer Github), here I think the flashBorrow(...) funtion is borrowing the flashloan.

So my question is: Which function do I have to call to borrow a flashloan (flashBorrow or onFlashLoan), or do I have to call both? If I only have to call one function, where is the connection between the two functions because there is no function calling the other one?

PS: If needed I can post the functions here, but it makes the question very long.

Thank you!

Best regards

1 Answer 1


The FlashBorrowerMock example you've linked is the correct implementation.

It works like this:

  1. You call FlashBorrowerMock.flashBorrow(...).
  2. FlashBorrowerMock calls lender.flashLoan(...) at the end.
  3. lender calls FlashBorrowerMock.onFlashLoan(...) (it's a callback, see link).
  4. Now you put your logic inside the onFlashLoan function.

Hope it's more clear!

  • Amazing, I was hoping for a answer like this. Thank you. But now I do have one more question. In FlashBorrowerMock.flashBorrow(...) the fee data is not used. Does the function have to make the repayment or where does it happen?
    – Dani S
    Commented Sep 26, 2022 at 19:06
  • The repayment is automatically pulled. That's why in flashBorrow there's token.approve
    – 0xSanson
    Commented Sep 26, 2022 at 19:19
  • Ok perfect thank you. Do you have a good page where I can read what a callback function is? I searched for it a long time and do not understand. Is it like a fallback function (Which is called if contract is called and no other function matches)?
    – Dani S
    Commented Sep 26, 2022 at 20:28
  • @DaniS Callback function is just a fancy word for re-entering the previous contract. So if A calls B, and B calls A in the same function, then B is doing a callback.
    – 0xSanson
    Commented Sep 26, 2022 at 22:36
  • Well, I got it now. Thank you very much!
    – Dani S
    Commented Sep 29, 2022 at 19:51

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.