Skip to main content
LI.FI Composer is an onchain execution engine for multi-step DeFi flows. A flow chains swaps, deposits, validations and protocol calls, and Composer turns it into one transaction that runs atomically on one EVM chain. A deposit into a yield strategy that would otherwise take several user signatures takes one.
LI.FI Composer turns a multi-step flow (swap then deposit, normally 2 signatures) into a single signed transaction. The Composer layer compiles, resolves runtime values, simulates, and executes via the onchain VM.LI.FI Composer turns a multi-step flow (swap then deposit, normally 2 signatures) into a single signed transaction. The Composer layer compiles, resolves runtime values, simulates, and executes via the onchain VM.

How a flow runs

Each signer has their own execution proxy: a contract at a deterministic address that holds the tokens while the flow runs. The user’s transaction goes to that proxy, and only the signer can drive it. See Account model. Each step passes its output to the next step onchain. A swap → deposit flow deposits exactly what the swap produced, so you never compute intermediate amounts yourself. You describe a flow in one of two ways:
  • Composer API. You author a Flow with @lifi/composer-sdk and choose every step.
  • LI.FI API. You request a /v1/quote whose toToken is a vault token, and LI.FI builds the flow for you.

The lifecycle you observe

  1. Request. Your backend sends a Flow to POST /compose, or your app sends a quote request to the LI.FI API.
  2. Validation, quoting and simulation. Composer checks the request, quotes every swap, zap and bridge, and simulates the transaction against current chain state. A flow that would revert comes back as a structured error instead of a transaction. Any guards you attach become checks inside the transaction.
  3. Response. You receive the transactions to submit, in order, and the expected and minimum amount of each output.
  4. Submission. The user signs and sends those transactions.
  5. Execution. The flow runs atomically: every step succeeds, or the whole transaction reverts.
  6. Delivery. Each output lands with its owner: the signer, a recipient, or the execution proxy if the flow does not move it. Cross-chain outputs land later.
For the Composer API’s checks, response fields and errors, see Execution Model.

Pre-execution simulation

Before Composer returns a transaction, it simulates the flow against the current state of its chain. The simulation overrides the signer’s balances and approvals, so a user who has not approved a token yet does not fail it. It catches the failures that would make the transaction revert onchain:
  • A swap that would slip past its tolerance.
  • A vault that would revert, for example because it is paused, full or blocks the user.
  • A pool without enough liquidity for the swap size.
A failed simulation comes back as a structured error, not as a transaction. So the user does not sign, or pay gas for, a transaction that already reverts against current state. Composer skips the simulation only when the response needs no measured value; see When the simulation runs.

Same-chain and cross-chain flows

The user always signs once. What changes is where the steps run: a flow executes on one chain, where its inputs live and the user’s transaction runs, and what it delivers can land on another chain.
Two rows. Same-chain flow, one signature, atomic: the user signs once on Base, a swap then a deposit runs, and the user receives aUSDC on Base. Cross-chain flow, one signature, no gas on Base: the user signs once on Arbitrum, where the source flow swaps and then bridges; after seconds, the funds land in an escrow on Base, where LI.FI runs the destination flow's deposit and the user receives aUSDC. If the destination flow doesn't run, the funds go to your refund address on Base.Two rows. Same-chain flow, one signature, atomic: the user signs once on Base, a swap then a deposit runs, and the user receives aUSDC on Base. Cross-chain flow, one signature, no gas on Base: the user signs once on Arbitrum, where the source flow swaps and then bridges; after seconds, the funds land in an escrow on Base, where LI.FI runs the destination flow's deposit and the user receives aUSDC. If the destination flow doesn't run, the funds go to your refund address on Base.

How a flow delivers

  • Same-chain. Every step runs atomically in the user’s transaction.
  • Cross-chain, deliver only. The flow ends in a bridge (lifi.bridge) or a LI.FI Intents order (lifiIntents.order) to an address on another chain, so there is no destination flow. It’s still one transaction; the output arrives on the destination chain after it confirms.
  • Cross-chain, then act. The bridge delivers into an escrow. Once the funds land, LI.FI’s settlement service runs the destination flow and pays its gas, so the user needs no second signature and no gas on the destination chain. See Cross-chain flows.
  • Same-chain, then act later. A continuation can also keep its escrow on the flow’s own chain. The user’s transaction or a plain transfer from any wallet funds it, and the destination flow runs later on that chain. See Same-chain continuations.
Each part is atomic on its own chain; a cross-chain flow as a whole is eventually consistent. Total time depends on the bridge and on when the destination flow runs.

Where to go next

Composer API Quickstart

Author and compile your first flow.

Build a cross-chain flow

Sign on one chain, end up in a position on another.

LI.FI API Quickstart

Add Composer to your existing LI.FI integration.