> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enso.build/llms.txt
> Use this file to discover all available pages before exploring further.

# Flashloans

> Borrow tokens without upfront collateral using the Bundle API.

export const date_0 = "2026-02-16"

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.

<Tip>
  Flashloans are only available through the [Bundle
  API](/pages/build/get-started/bundling-actions). They are not available via
  the `/route` endpoint.
</Tip>

## How Flashloans Work

```mermaid theme={null}
sequenceDiagram
    participant User
    participant Enso API
    participant FlashloanAdapter
    participant Lending Protocol
    participant Wallet

    User->>Enso API: POST /bundle with flashloan action
    Enso API-->>User: Transaction data
    User->>Wallet: Submit transaction
    Wallet->>FlashloanAdapter: Execute flashloan
    FlashloanAdapter->>Lending Protocol: Request flash borrow
    Lending Protocol->>Wallet: Transfer borrowed tokens
    Wallet->>Wallet: Execute callback actions
    Wallet->>Lending Protocol: Repay borrowed amount + fee
```

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

<Note>
  Flashloans are atomic: if any callback action fails or the repayment cannot be
  satisfied, the entire transaction reverts and no tokens are moved.
</Note>

## 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       |

<Warning>
  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.
</Warning>

## Supported Protocols

The user must select the flashloan protocol by using one of these slugs as the action's `protocol` value.

```json theme={null}
{
  "protocol": "morpho",
  "action": "flashloan",
  "args": {
    "flashloanToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "flashloanAmount": "1000000000",
    "tokenOut": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"],
    "callback": []
  }
}
```

| 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     | ❌             | ✅        | ❌           | ❌        | ❌          |

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:

| 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   |

See the [Routing Strategies](/pages/build/reference/routing-strategies) reference for details on choosing a strategy.

## Bundle Example

This example shows a `/bundle` request with a Morpho flashloan. The flashloan protocol is selected by setting `protocol` to `morpho` on the `flashloan` action.

```bash cURL theme={null}
curl -X POST "https://api.enso.build/api/v1/shortcuts/bundle" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "chainId": 1,
    "fromAddress": "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8",
    "routingStrategy": "router",
    "receiver": "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8",
    "spender": "0x0125fAd1eBaF67Fb529BdEd12a7e68213994A2b8",
    "bundle": [
      {
        "protocol": "morpho",
        "action": "flashloan",
        "args": {
          "flashloanToken": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
          "flashloanAmount": "1000000000",
          "tokenOut": ["0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"],
          "callback": [...]
        }
      }
    ]
  }'
```

<div className="text-right text-xs gray-200 font-semibold w-full" style={{marginTop: '0'}}>
  <p style={{
        color: "#b2b2b2"  
    }}>Updated {date_0}</p>
</div>
