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 submit a /bundle request containing a flashloan action with callback actions
  2. The API compiles the bundle into a single transaction
  3. When executed, the FlashloanAdapter requests a flash borrow from the lending protocol
  4. The lending protocol transfers the borrowed tokens to the wallet
  5. The callback actions execute sequentially (swaps, deposits, borrows, etc.)
  6. The borrowed amount plus any protocol fee is repaid to the lending protocol
  7. 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

ParameterTypeDescriptionRequired
flashloanTokenstringAddress of the token to flash borrowYes
flashloanAmountstringAmount to flash borrow in wei (with full decimals)Yes
tokenInstring[]Addresses of additional tokens provided by the user as inputNo
amountInstringAmount of tokenIn provided by the user in weiNo
tokenOutstring[]Addresses of tokens expected as output after callback executionNo
callbackAction[]Array of actions to execute after receiving the flash-borrowed tokensYes
receiverstringAddress to receive output tokens if not the callerNo
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

Enso automatically selects the optimal flashloan source based on chain, token, and fee. The following lending protocols are supported:
ProtocolSlugFee
Morphomorpho0%
Bend (Morpho fork)bend0%
Dolomitedolomite0%
Aave V3aave-v3Dynamic (pool-specific, basis points from FLASHLOAN_PREMIUM_TOTAL)
Hyperlend (Aave V3 fork)hyperlendDynamic (pool-specific)
Balancer V3balancer-v3Pool-specific fee
Uniswap V3uniswap-v3Pool-specific fee (0.05%, 0.3%, or 1% depending on pool tier)
Kodiak (Uniswap V3 fork)kodiakPool-specific fee

Chain Availability

Not all flashloan protocols are deployed on every chain. The table below shows which protocols are available on each supported chain.
ChainAave V3MorphoBalancer V3DolomiteUniswap V3
Ethereum
Arbitrum
Base
HyperEVM✅ (Hyperlend)
Optimism
Polygon
Berachain✅ (Bend)✅ (Kodiak)
Sonic
Binance
Avalanche
Plasma
Ink
Unichain
World
Soneium
Plume
Katana
Monad
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.

Routing Strategies

Flashloans are supported across three routing strategies. Each strategy uses a dedicated adapter contract:
StrategyDescriptionAdapter Contract
ensowallet-v2Smart contract wallet — tokens stay in the user’s walletEnsoWalletFlashloanAdapter
routerEOA via EnsoRouter — intermediate tokens held by the routerEnsoRouterFlashloanAdapter
safeGnosis Safe multisig walletEnsoSafeFlashloanAdapter
See the Routing Strategies reference for details on choosing a strategy.

Example: Leveraged Position on Bend

This example flash borrows HONEY on Berachain, swaps it to iBGT, deposits iBGT as collateral on Bend, and borrows HONEY against it to repay the flashloan — creating a leveraged iBGT position in a single transaction.
const fromAddress = "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8";

const bundle = await client.getBundleData(
  {
    chainId: 80094,
    fromAddress: fromAddress,
    routingStrategy: "ensowallet-v2",
    receiver: fromAddress,
    spender: fromAddress,
  },
  [
    {
      protocol: "bend",
      action: "flashloan",
      args: {
        flashloanToken: "0xFCBD14DC51f0A4d49d5E53C2E0950e0bC26d0Dce", // HONEY
        flashloanAmount: "26939472318660971",
        tokenIn: ["0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590"], // iBGT
        amountIn: "104715952583368",
        tokenOut: ["0xfcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce"], // HONEY
        callback: [
          {
            protocol: "enso",
            action: "route",
            args: {
              tokenIn: ["0xfcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce"], // HONEY
              tokenOut: ["0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590"], // iBGT
              amountIn: "26939472318660971",
              slippage: 50,
            },
          },
          {
            protocol: "enso",
            action: "balance",
            args: {
              token: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590", // iBGT
            },
          },
          {
            protocol: "bend",
            action: "deposit",
            args: {
              primaryAddress: "0x24147243f9c08d835C218Cda1e135f8dFD0517D0",
              positionId:
                "0x1f05d324f604bd1654ec040311d2ac4f5820ecfd1801a3d19d2c6f09d4f7a614",
              tokenIn: ["0x2f6f07cdcf3588944bf4c42ac74ff24bf56e7590"], // iBGT
              amountIn: { useOutputOfCallAt: 1 }, // iBGT balance from step 2
              onBehalfOf: "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8",
            },
          },
          {
            protocol: "bend",
            action: "borrow",
            args: {
              primaryAddress: "0x24147243f9c08d835C218Cda1e135f8dFD0517D0",
              positionId:
                "0x1f05d324f604bd1654ec040311d2ac4f5820ecfd1801a3d19d2c6f09d4f7a614",
              collateral: "0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590", // iBGT
              tokenOut: ["0xfcbd14dc51f0a4d49d5e53c2e0950e0bc26d0dce"], // HONEY
              amountOut: "26939472318660971", // Repay flashloan amount
              onBehalfOf: "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8",
            },
          },
        ],
      },
    },
  ]
);
What’s happening step by step:
  1. Flash borrow — Borrow HONEY from Bend with zero fee (Morpho-based protocol)
  2. Route — Swap the borrowed HONEY to iBGT via Enso’s optimal routing with 0.5% slippage
  3. Balance — Check the iBGT balance in the wallet (needed for dynamic amount referencing)
  4. Deposit — Deposit all iBGT as collateral into Bend’s lending pool, using useOutputOfCallAt: 1 to reference the balance from step 3
  5. Borrow — Borrow HONEY against the deposited iBGT collateral to repay the flashloan
Use useOutputOfCallAt within callbacks to dynamically chain action outputs. This is essential when exact amounts are unknown at request time (e.g., swap output amounts). See Chaining Actions for details.

More Examples

Additional flashloan examples are coming soon:
  • Collateral swap — Replace one collateral type with another without closing the position
  • Debt refinancing — Move a lending position from one protocol to another

Updated