How Flashloans Work
- You submit a
/bundlerequest containing aflashloanaction with callback actions - The API compiles the bundle into a single transaction
- When executed, the FlashloanAdapter requests a flash borrow from the lending protocol
- The lending protocol transfers the borrowed tokens to the wallet
- The callback actions execute sequentially (swaps, deposits, borrows, etc.)
- The borrowed amount plus any protocol fee is repaid to the lending protocol
- 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
| Parameter | Type | Description | Required |
|---|---|---|---|
flashloanToken | string | Address of the token to flash borrow | Yes |
flashloanAmount | string | Amount to flash borrow in wei (with full decimals) | Yes |
tokenIn | string[] | Addresses of additional tokens provided by the user as input | No |
amountIn | string | Amount of tokenIn provided by the user in wei | No |
tokenOut | string[] | Addresses of tokens expected as output after callback execution | No |
callback | Action[] | Array of actions to execute after receiving the flash-borrowed tokens | Yes |
receiver | string | Address to receive output tokens if not the caller | No |
Supported Protocols
Enso automatically selects the optimal flashloan source based on chain, token, and fee. The following lending protocols are supported:| Protocol | Slug | Fee |
|---|---|---|
| Morpho | morpho | 0% |
| Bend (Morpho fork) | bend | 0% |
| Dolomite | dolomite | 0% |
| Aave V3 | aave-v3 | Dynamic (pool-specific, basis points from FLASHLOAN_PREMIUM_TOTAL) |
| Hyperlend (Aave V3 fork) | hyperlend | Dynamic (pool-specific) |
| Balancer V3 | balancer-v3 | Pool-specific fee |
| Uniswap V3 | uniswap-v3 | Pool-specific fee (0.05%, 0.3%, or 1% depending on pool tier) |
| Kodiak (Uniswap V3 fork) | kodiak | Pool-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.| Chain | Aave V3 | Morpho | Balancer V3 | Dolomite | Uniswap V3 |
|---|---|---|---|---|---|
| Ethereum | ✅ | ✅ | ✅ | ✅ | ✅ |
| Arbitrum | ✅ | ✅ | ✅ | ✅ | ✅ |
| Base | ✅ | ✅ | ✅ | ✅ | ✅ |
| HyperEVM | ✅ (Hyperlend) | ✅ | ✅ | ❌ | ❌ |
| Optimism | ✅ | ✅ | ❌ | ❌ | ✅ |
| Polygon | ✅ | ✅ | ❌ | ❌ | ✅ |
| Berachain | ❌ | ✅ (Bend) | ❌ | ✅ | ✅ (Kodiak) |
| Sonic | ✅ | ✅ | ❌ | ❌ | ❌ |
| Binance | ✅ | ❌ | ❌ | ❌ | ✅ |
| Avalanche | ✅ | ❌ | ❌ | ❌ | ❌ |
| Plasma | ✅ | ❌ | ❌ | ❌ | ❌ |
| Ink | ❌ | ❌ | ❌ | ✅ | ❌ |
| Unichain | ❌ | ✅ | ❌ | ❌ | ❌ |
| World | ❌ | ✅ | ❌ | ❌ | ✅ |
| Soneium | ❌ | ✅ | ❌ | ❌ | ❌ |
| Plume | ❌ | ✅ | ❌ | ❌ | ❌ |
| Katana | ❌ | ✅ | ❌ | ❌ | ❌ |
| Monad | ❌ | ✅ | ❌ | ❌ | ❌ |
Routing Strategies
Flashloans are supported across three routing strategies. Each strategy uses a dedicated adapter contract:| Strategy | Description | Adapter Contract |
|---|---|---|
ensowallet-v2 | Smart contract wallet — tokens stay in the user’s wallet | EnsoWalletFlashloanAdapter |
router | EOA via EnsoRouter — intermediate tokens held by the router | EnsoRouterFlashloanAdapter |
safe | Gnosis Safe multisig wallet | EnsoSafeFlashloanAdapter |
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.- Flash borrow — Borrow HONEY from Bend with zero fee (Morpho-based protocol)
- Route — Swap the borrowed HONEY to iBGT via Enso’s optimal routing with 0.5% slippage
- Balance — Check the iBGT balance in the wallet (needed for dynamic amount referencing)
- Deposit — Deposit all iBGT as collateral into Bend’s lending pool, using
useOutputOfCallAt: 1to reference the balance from step 3 - Borrow — Borrow HONEY against the deposited iBGT collateral to repay the flashloan
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
