lifi.swap swaps one token for another on the flow’s chain through the LI.FI aggregator. It consumes a resource on amountIn and produces a resource of the resourceOut token on amountOut. At compile time the op fetches a LI.FI quote; the transaction calls the LI.FI router with that quote’s calldata.
lifi.swap is same-chain only. For a cross-chain move, use lifi.bridge. To deposit the output into a position, chain a lifi.zap onto amountOut.
The router enforces the quote’s minimum output on chain, so amountOut already has a floor (providesMinimum). Set slippage in the config instead of attaching a slippage guard. amountOut is the amount the swap produced; tokens the execution proxy already held don’t count.
Ports
Config
Understanding unspentIn
lifi.swap pins the quoted input amount at compile time and spends exactly that amount. If less reaches amountIn at execution, the transaction reverts. When amountIn comes from an upstream op, the quote uses that op’s guaranteed minimum, so more usually arrives.
unspentIn is the input handed to this op minus the pinned amount, in the input token. Tokens the proxy already held are excluded. It is omitted from outputs when zero. Bind it downstream like any resource, or leave it unbound so sweepTo returns it.
Example
Swap 1 WETH to USDC on Ethereum mainnet:Errors
Related
lifi.zap: deposit the swap’s output into a position.lifi.bridge: move tokens to another chain.- Swap and deposit: a full recipe.

