Skip to main content
Flashloans let you borrow tokens from a lending protocol without upfront collateral, execute a series of DeFi actions, and repay the debt — all within a single atomic transaction. If any step fails, the entire transaction reverts and no tokens are moved.
Flashloans are only available through the Bundle API. They are not available via the /route endpoint.

How Flashloans Work

  1. You choose the flashloan protocol by setting the action’s protocol field, for example morpho, aave-v3, or balancer-v3
  2. You submit a /bundle request containing a flashloan action with callback actions
  3. The API compiles the bundle into a single transaction
  4. When executed, the FlashloanAdapter requests a flash borrow from the selected lending protocol
  5. The lending protocol transfers the borrowed tokens to the wallet
  6. The callback actions execute sequentially (swaps, deposits, borrows, etc.)
  7. The borrowed amount plus any protocol fee is repaid to the lending protocol
  8. The transaction completes — or reverts entirely if repayment cannot be satisfied
Flashloans are atomic: if any callback action fails or the repayment cannot be satisfied, the entire transaction reverts and no tokens are moved.

Parameters

The callback actions must produce enough tokens to repay the flash-borrowed amount plus any protocol fee. If repayment cannot be satisfied, the entire transaction will revert.

Supported protocols

Select the flashloan integration through the action’s protocol field. The callback must be non-empty and must leave enough assets with the executing account to repay principal and protocol fees. Use Supported Actions to confirm current protocol availability before building.

Chain Availability

Not all flashloan protocols are deployed on every chain. The table below shows which protocols are available on each supported chain. Where a variant is noted (e.g. Hyperlend, Bend, Kodiak), the flashloan uses a fork or alternative deployment of the underlying protocol on that chain. For multi-token flashloans, token and amount arrays must have matching lengths. Output references inside callback are local to that callback sequence.

Routing Strategies

Flashloans are supported across three routing strategies. Each strategy uses a dedicated adapter contract: See the Routing Strategies reference for details on choosing a strategy.

Examples

Morpho WETH/USDC Leveraged Position (Open Loop)

Open a leveraged WETH long against a Morpho Markets V1 (Morpho Blue) market in a single atomic transaction. The user starts with 1 ETH and ends with a Morpho position holding ~1.45 WETH as collateral and 1,800 USDC of debt. The flashloan provides the temporary USDC to swap into extra collateral; the Morpho borrow at the end repays the flashloan from the freshly opened debt position.
morphoWethUsdcLoop.ts
Pick the flashloan asset to match the final borrow. Flashloaning USDC and ending the callback with a USDC borrow lets the borrowed USDC repay the flashloan directly — no extra swap needed at the end of the callback.

Alchemix AlchemistV3 alUSD Loop (Morpho Flashloan)

Open an AlchemistV3 alUSD position using a Morpho USDC flashloan. The user contributes 10 MIXUSD; the flashloan brings in 15 USDC of “synthetic” collateral that gets wrapped into 15 MIXUSD inside the callback. The combined 25 MIXUSD becomes AlchemistV3 collateral, against which 17 alUSD is minted and swapped back into the USDC needed to repay the flashloan.
alUsdLoopMorphoFlashloan.ts
tokenIn / amountIn on the flashloan action: these are user-contributed assets that flow into the callback alongside the flashloaned funds — tokenIn accepts a single address or an array, and amountIn accepts a single amount, an array, or a useOutputOfCallAt reference to an earlier action’s output.

Uniswap V3 Flashloan Opening an Aave V3 Leveraged Position (eMode)

Open a leveraged Aave V3 position inside a Uniswap V3 flashloan callback on MegaETH. The user contributes 1 USDm collateral and flashloans 1 USDe from a specific Uniswap V3 pool; inside the callback the flashloan is swapped to USDm, deposited as collateral, and Aave V3 mints 1.503 USDe debt (slightly more than 1 to cover the pool fee) to repay the flashloan.
uniswapV3FlashloanAaveLeverage.ts
Uniswap V3 flashloans require primaryAddress: unlike Morpho or Aave V3 (where the lender is global), Uniswap V3 flashloans borrow from a specific pool. Pass the pool address as primaryAddress and pay the pool’s fee tier (0.05% / 0.3% / 1%) when repaying — over-borrow slightly in the final borrow action to cover it.
Aave V3 eMode: when the borrow target sits in an eMode category, pass args.eModeCategoryId on the aave-v3.borrow action. Enso emits the matching setUserEMode approval automatically.

Updated