Prerequisites
- Node.js 24 or later, and a LI.FI API key on your server. See Before you start.
- A signer address. The quickstart compiles the flow but does not send it. Signing and submission are in Build a same-chain flow.
Steps
1
Install the SDK
Install
@lifi/composer-sdk and its peer dependency @lifi/compose-spec. Both packages must be on the same version; these docs target 0.14.0.2
Set your API key
3
Write the flow
Save this as
quickstart.ts and replace 0xYourSignerAddress with the signer’s address. It is adapted from swapAndZap.ts in the composer-sdk-examples repo.4
Run it
approval action for WETH and the execute action, then the aEthUSDC output zap.amountOut with its estimate and its minimum.What the code does
- Input.
amountInis a resource: a token balance the flow tracks from step to step. You choose input names and node ids (swap,zap); the response keys its outputs by them. - Ops.
lifi.swapturns WETH into USDC with a 3% slippage bound.lifi.zaptakes the swap’s output and deposits it into Aave. See the op catalog. - Guard.
guards.slippage({ port: 'amountOut', bps: 100 })makes the transaction revert if the zap delivers more than 1% below the simulated amount. The swap needs no guard: itsslippageconfig already sets a floor. See Guards. - Materialiser.
directDeposittells Composer how to fund the input: pull exactly 1 WETH from the signer into the execution proxy. sweepTo. Sends whatever the flow leaves on the proxy, here the aEthUSDC, to the signer. SeesweepTo.- Result. The default simulation policy throws a
ComposeErrorwhen the simulation reverts, so thestatuscheck only narrows the type. Submit the transactions inresult.actionsorder; see the compile response for every field.
builder.build(). Flow Schema: Complete request shows this flow on the wire.
Next steps
Build a same-chain flow
Signing and submission, runtime values, preconditions and errors, step by step.
Go cross-chain
Run a deposit on another chain, from one signature.

