Skip to main content

How do I use a flashloan in an Enso bundle?

Declare a flashloan action with a non-empty callback inside one Bundle request. The callback must be able to repay the borrowed amount plus any protocol fee.

J
Written by Javier Diaz

Declare a flashloan action with a non-empty callback inside one Bundle request. The callback must produce enough tokens to repay the borrowed amount plus any protocol fee, or the whole transaction reverts.

Definition

A flashloan is temporary liquidity for the length of one atomic transaction. In Enso it is a Bundle action, not a Route request.

How it works

  • Set the action’s protocol to the flashloan integration you want to use, and include flashloanToken, flashloanAmount, and a callback array.

  • Put the actions that use and repay the borrowed tokens in that callback — swaps, deposits, borrows, or other supported steps.

  • Chain amounts with useOutputOfCallAt instead of hardcoding intermediate sizes.

  • If repayment cannot be satisfied, the entire bundle reverts and no tokens are moved.

How Enso does this

Send POST https://api.enso.build/api/v1/shortcuts/bundle with the flashloan action in the body. See Flashloans for the current field list and integration notes. This article does not name lending venues; use the live docs for the protocol slugs you can set. Flashloans are not available on /route.

FAQ

Can I split borrow and repay across two transactions?

No. Repayment must happen in the same transaction as the flash borrow.

Do I use Route for this?

No. The flashloan docs state that flashloans are only available through the Bundle API.

Related articles

  • What is a flashloan in a bundled transaction?

  • How do I build a leverage or looping position in one transaction?

  • How do I chain bundle actions together?

  • How do I add checks or slippage guards inside a bundle?

  • How do I bundle multiple DeFi actions into one transaction?

Sources

Did this answer your question?