
Architecture
Composer turns a partner’s request — “deposit USDC into Aave on Base” (via the LI.FI API) or a typed Flow document (via the Composer API) — into a single executable on-chain transaction. The system has three modular layers:1. Onchain VM
A smart contract deployed on every supported EVM chain holding the shared execution logic. Each user gets their own deterministic proxy that holds their tokens anddelegatecalls the VM, so a flow runs in the user’s own balance and storage context. Invoked this way, the VM can:
- Call any other on-chain protocol or sequence of protocols.
- Pass outputs from one step as inputs to the next.
- Handle token approvals, transfers, and balance checks between steps.
- Execute the entire sequence atomically within a single chain.
delegatecalls the VM with the compiled flow as calldata. See Account model for how the proxy is derived and access-controlled.
VM contract: 0xb57Ce43Be47DF611C98EB0943e5D36EBDb36cc6D — the shared logic the proxy delegatecalls, not the transaction to. Same address on every supported chain. See Addresses for the full deployment list.
2. eDSL and compiler
A typed embedded DSL (TypeScript) for expressing contract interactions. When Composer is invoked:- The routing engine identifies which protocols and actions are needed.
- The eDSL expresses those interactions as a typed program.
- The compiler transforms the program into bytecode the VM can execute.
3. Runtime value passing
Many DeFi operations need a value that isn’t known until a previous step runs — for example, depositing the exact amount of tokens received from a preceding swap. Rather than pre-computing intermediate amounts off-chain, Composer passes one step’s outputs into the next:- A Flow records how each call’s outputs feed later calls’ inputs (via refs).
- The VM encodes each call’s calldata at runtime, reading the concrete values produced by earlier steps and writing them into the arguments of later steps.
- This happens entirely on-chain, within the same transaction.
swap → deposit atomic without the integrator pre-computing intermediate amounts.
Transaction lifecycle
The Composer API (you author a Flow) and the LI.FI API integration (the backend builds one) share the same execution path:| Step | What happens | Where |
|---|---|---|
| 1. Request | Your app submits a Flow (via the Composer API) or /v1/quote with toToken set to a vault (via the LI.FI API). | Client → API |
| 2. Route optimisation | LI.FI’s routing engine finds the optimal path across DEXs and protocols. | API |
| 3. Compilation | The compiler produces VM bytecode from the resolved Flow. | API |
| 4. Pre-execution simulation | The compiled flow is simulated to verify execution; failures surface as structured errors before calldata is returned. | API |
| 5. Response | The API returns transactionRequest (calldata), producedResources (simulated outputs), and any approvals the signer must grant. | API → Client |
| 6. Submission | Your user signs once and broadcasts the transaction. | Client → Chain |
| 7. On-chain execution | The VM executes the bytecode atomically. All steps succeed or none do. | Chain |
| 8. Confirmation | The transaction confirms; the resulting position lands in the user’s wallet. | Chain → Client |
Pre-execution simulation
Every Compose request is simulated end-to-end against current chain state before calldata is returned to the client. The simulator runs with overridden balances and approvals (so missing user approvals don’t fail the simulation), which lets it focus on what actually goes wrong on-chain. This catches:- Token swaps that would slip past tolerance.
- Vault interactions that would revert (paused, capped, blacklisted).
- Insufficient pool liquidity to fill the swap size.
Same-chain vs. cross-chain
Composer behaves differently depending on whether the source and destination are on the same chain:- Same-chain. All steps execute atomically inside one transaction. Simulation guarantee: if the simulation passes, execution will succeed (barring extreme edge cases like aggressive mempool front-running). One signature, one gas payment, one block.
- Cross-chain (LI.FI API integration only today). The source-chain transaction triggers a bridge; the destination-chain actions then execute. Each phase is atomic within its chain, but the overall flow is eventually consistent. Total time depends on bridge latency. Cross-chain progress is tracked via the LI.FI
/statusendpoint.
chainId per Flow today; multi-chain Flows aren’t yet exposed via the Composer API. If you need cross-chain composition, see Integrate via LI.FI API.
Where to go next
Overview
Who Composer is for, what you can build, Composer API vs LI.FI API.
Composer API Quickstart
Author your first Flow in five minutes.
LI.FI API Quickstart
Add Composer to your existing LI.FI integration.


