Learn how to compose cross-chain DeFi operations: bridge + swap + deposit in a single user flow using LI.FI Composer.
Cross-chain Composer lets users deposit into protocols on a different chain from where their assets live, all in a single flow. This guide covers the patterns, examples, and considerations for cross-chain Composer operations.
When fromChain and toChain differ, LI.FI’s routing engine automatically combines:
Source chain actions — swap tokens if needed
Bridge — transfer assets to the destination chain
Destination chain actions — swap to the required token and deposit into the target protocol via Composer
From the developer’s perspective, the API call is identical to same-chain Composer. You just use different chain IDs. LI.FI handles bridge selection, intermediate swaps, and the final Composer deposit.
The patterns below illustrate possible execution paths. You do not control which pattern the routing engine selects. It optimises for cost, speed, and liquidity automatically. You will only know the exact execution path when you receive the route response.
These patterns describe typical ways the routing engine may fulfil a cross-chain Composer request. The actual path is determined at quote time based on available liquidity, bridge options, and gas costs.
User has the right token on the wrong chain.Example: USDC on Arbitrum → Morpho vault on Base
curl -X GET 'https://li.quest/v1/quote?\fromChain=42161&\toChain=8453&\fromToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&\toToken=0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A&\fromAddress=0xYOUR_WALLET_ADDRESS&\toAddress=0xYOUR_WALLET_ADDRESS&\fromAmount=10000000'
What may happen under the hood:
Bridge USDC from Arbitrum to Base
Deposit USDC into Morpho vault on Base
User receives vault tokens
The exact steps depend on the route returned by the API. The routing engine may choose a different bridge or insert intermediate swaps if that produces a better outcome.
User has a different token on a different chain.Example: ETH on Ethereum → Aave USDC lending on Optimism
curl -X GET 'https://li.quest/v1/quote?\fromChain=1&\toChain=10&\fromToken=0x0000000000000000000000000000000000000000&\toToken=AAVE_AUSDC_TOKEN_ADDRESS_ON_OPTIMISM&\fromAddress=0xYOUR_WALLET_ADDRESS&\toAddress=0xYOUR_WALLET_ADDRESS&\fromAmount=100000000000000000'
What may happen under the hood:
Swap ETH → USDC on Ethereum, then bridge USDC to Optimism, or bridge ETH directly and swap on the destination chain
Deposit USDC into Aave on Optimism
User receives aUSDC tokens
The routing engine decides the optimal sequence. You will see the chosen path in the route response.
Cross-chain Composer transactions take longer than same-chain because they include a bridge transfer. Actual duration depends on the bridge selected, network congestion, and the number of steps in the route. There are no fixed values.You can influence bridge selection with the order parameter:
const quote = await getQuote({ // ... other params options: { order: 'FASTEST', // Prioritise speed over cost },});
The route response includes an estimate.executionDuration field (in seconds) that reflects the expected end-to-end time for the chosen path. Use this to set user expectations in your UI.For controlling how quickly the API returns quotes, see API Latency & Optimization.
if (status.status === 'DONE' && status.substatus === 'PARTIAL') { console.log('Bridge succeeded but destination action may have partially completed.'); console.log('Check destination chain for received tokens.');}if (status.substatus === 'REFUND_IN_PROGRESS') { console.log('Refund is being processed on the source chain.');}