Cross-chain token swaps and bridges via the LI.FI protocol. Get quotes, execute transfers, track progress, and compose DeFi operations across 35+ blockchains.
LI.FI is a cross-chain bridge and DEX aggregation protocol. It finds optimal routes across 35+ blockchains, comparing dozens of bridges (Stargate, Hop, Across, etc.) and DEXes (Uniswap, SushiSwap, 1inch, etc.) to execute token swaps and cross-chain transfers.
$ARGUMENTSParse the arguments:
swap, bridge, track, routes, zap, or a natural language requestIf no arguments are provided, ask the user what they want to do.
https://li.quest/v1transactionRequest objects (to, data, value, gasLimit, gasPrice) ready to sign — provide these to the agent's wallet0x0000000000000000000000000000000000000000 (for ETH, MATIC, BNB, etc.)1000000000000000000 (18 decimals), 1 USDC = 1000000 (6 decimals)x-lifi-api-key header for higher rate limits (not required)curl -s "https://li.quest/v1/chains"
# Optional: ?chainTypes=EVM or ?chainTypes=SVM
curl -s "https://li.quest/v1/tokens?chains=1,137"
# Optional: chainTypes, minPriceUSD
curl -s "https://li.quest/v1/token?chain=1&token=USDC"
# chain (required): chain ID or name. token (required): address or symbol
curl -s "https://li.quest/v1/connections?fromChain=1&toChain=137&fromToken=0x0000000000000000000000000000000000000000"
# Optional: toToken, chainTypes, allowBridges
curl -s "https://li.quest/v1/tools"
# Returns {bridges: [{key, name}], exchanges: [{key, name}]}
The primary endpoint for initiating any swap or bridge.
curl -s "https://li.quest/v1/quote?\
fromChain=1&toChain=137\
&fromToken=0x0000000000000000000000000000000000000000\
&toToken=0x0000000000000000000000000000000000000000\
&fromAddress=0xYOUR_WALLET\
&fromAmount=1000000000000000000\
&slippage=0.03"
Required: fromChain, toChain, fromToken, toToken, fromAddress, fromAmount Optional: toAddress, slippage (decimal, e.g. 0.03 = 3%), integrator, order (RECOMMENDED|FASTEST|CHEAPEST|SAFEST), allowBridges, allowExchanges
Returns: action, estimate (toAmount, fees, executionDuration), and transactionRequest (to, data, value, gasLimit).
curl -s "https://li.quest/v1/status?txHash=0xTX_HASH"
# Optional: bridge, fromChain, toChain
Returns: status (NOT_FOUND, PENDING, DONE, FAILED), substatus (COMPLETED, PARTIAL, REFUNDED), source/destination tx details.
curl -s -X POST "https://li.quest/v1/advanced/routes" \
-H "Content-Type: application/json" \
-d '{
"fromChainId": "1",
"toChainId": "137",
"fromTokenAddress": "0x0000000000000000000000000000000000000000",
"toTokenAddress": "0x0000000000000000000000000000000000000000",
"fromAddress": "0xYOUR_WALLET",
"fromAmount": "1000000000000000000",
"options": {"order": "RECOMMENDED"}
}'
Required: fromChainId, toChainId, fromTokenAddress, toTokenAddress, fromAddress, fromAmount Optional: toAddress, slippage, options.order
Returns: routes[] array — each route has steps, estimated output, fees, and execution time.
curl -s -X POST "https://li.quest/v1/advanced/stepTransaction" \
-H "Content-Type: application/json" \
-d '{ ...step object from routes response... }'
Pass the entire step object from a route. Returns transactionRequest ready to sign.
curl -s -X POST "https://li.quest/v1/quote/contractCalls" \
-H "Content-Type: application/json" \
-d '{
"fromChain": "1",
"toChain": "137",
"fromToken": "0x0000000000000000000000000000000000000000",
"toToken": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"fromAddress": "0xYOUR_WALLET",
"fromAmount": "1000000000000000000",
"contractCalls": [
{
"toContractAddress": "0xTARGET_CONTRACT",
"toContractCallData": "0xENCODED_FUNCTION_CALL",
"toContractGasLimit": "200000"
}
]
}'
Required: fromChain, toChain, fromToken, toToken, fromAddress, fromAmount, contractCalls[] Optional: slippage
curl -s "https://li.quest/v1/gas/prices"
curl -s "https://li.quest/v1/gas/suggestion/1"
Use this for any "swap X for Y" or "bridge tokens to chain" request.
Identify parameters from the user's request:
Look up token addresses if the user gave symbols:
curl -s "https://li.quest/v1/token?chain=1&token=USDC"
Extract address and decimals from the response.
Convert amount to smallest unit:
1500000000000000000100000000Get a quote:
curl -s "https://li.quest/v1/quote?fromChain=1&toChain=137&fromToken=0x0000000000000000000000000000000000000000&toToken=0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359&fromAddress=0xWALLET&fromAmount=1500000000000000000&slippage=0.03"
Present summary to user (REQUIRED before returning tx data):
Swap: 1.5 ETH (Ethereum) → ~2,850 USDC (Polygon)
Route: Stargate bridge → Uniswap V3
Fees: ~$2.50 (gas) + $0.50 (bridge)
Estimated time: ~2 minutes
Slippage: 3%
If ERC20 token: Check if the LiFi contract has sufficient allowance. The spender address is transactionRequest.to from the quote response. If allowance < fromAmount, guide the user to approve the token first.
Return transactionRequest for signing by the agent's wallet.
If cross-chain: Explain that bridging is asynchronous — the source chain tx will confirm first, then the bridge delivers tokens to the destination. Offer to track with Workflow 3.
Use when the user wants to see options or find the best deal.
Gather parameters (same as Workflow 1, steps 1-3).
Request multiple routes:
curl -s -X POST "https://li.quest/v1/advanced/routes" \
-H "Content-Type: application/json" \
-d '{
"fromChainId": "1",
"toChainId": "137",
"fromTokenAddress": "0x0000000000000000000000000000000000000000",
"toTokenAddress": "0x0000000000000000000000000000000000000000",
"fromAddress": "0xWALLET",
"fromAmount": "1000000000000000000",
"options": {"order": "RECOMMENDED"}
}'
Present comparison table:
# Route Output Fees Time Bridge
1 Stargate → Uniswap V3 2,850 USDC $3.00 2 min Stargate
2 Hop → SushiSwap 2,845 USDC $2.80 5 min Hop
3 Across → 1inch 2,848 USDC $3.20 3 min Across
User picks a route. Extract the chosen route's steps.
Get transaction data for each step:
curl -s -X POST "https://li.quest/v1/advanced/stepTransaction" \
-H "Content-Type: application/json" \
-d '{ ...step object... }'
Return transactionRequest for signing.
Use when the user wants to check status of a cross-chain transfer.
Get details from user: transaction hash, source chain, destination chain.
Check status:
curl -s "https://li.quest/v1/status?txHash=0xTX_HASH&fromChain=1&toChain=137"
Interpret and report status:
NOT_FOUND — Transaction not yet indexed. Wait a minute and retry.PENDING — Transfer in progress. Suggest polling every 30 seconds.DONE with substatus COMPLETED — Transfer complete. Report destination tx hash.DONE with substatus PARTIAL — User received the bridged token on the destination chain but NOT the final target token (e.g., got USDC.e instead of native USDC). The user may need to swap manually.DONE with substatus REFUNDED — Transfer failed and funds were returned to the source address.FAILED — Transfer failed. Report error details and advise the user to check the source chain tx on a block explorer.If PENDING: Offer to poll periodically. Wait 30 seconds between checks.
Use for multi-step DeFi operations like "bridge ETH to Polygon and deposit into Aave" or "swap to USDC and stake in a vault."
Understand the multi-step operation — identify:
Gather contract call data:
toContractAddress: The destination contract (e.g., Aave lending pool)toContractCallData: ABI-encoded function call (e.g., deposit(address,uint256,address,uint16))toContractGasLimit: Gas limit for the contract call (e.g., "200000")Request zap quote:
curl -s -X POST "https://li.quest/v1/quote/contractCalls" \
-H "Content-Type: application/json" \
-d '{
"fromChain": "1",
"toChain": "137",
"fromToken": "0x0000000000000000000000000000000000000000",
"toToken": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"fromAddress": "0xWALLET",
"fromAmount": "1000000000000000000",
"contractCalls": [{
"toContractAddress": "0xTARGET",
"toContractCallData": "0xENCODED_CALL",
"toContractGasLimit": "200000"
}]
}'
Present summary showing all operations in the zap (bridge + swap + deposit/stake/etc.).
Return transactionRequest for signing.
Use when the user asks "what chains are supported?", "what tokens can I swap?", "what bridges are available?", etc.
Determine what the user wants to know:
GET /v1/chainsGET /v1/tokens?chains={chainId}GET /v1/token?chain={chainId}&token={symbol}GET /v1/connections?fromChain={id}&toChain={id}GET /v1/toolsGET /v1/gas/prices or GET /v1/gas/suggestion/{chainId}Call the appropriate endpoint.
Present results in a readable table format. For large responses (e.g., all tokens), summarize the most relevant results and offer to filter further.
These rules are mandatory — never skip them.
fromAddress is a valid hex address: starts with 0x, 42 characters total, valid hex characters0x0000000000000000000000000000000000000000) as toAddress — this burns funds permanently. The zero address is ONLY valid as a fromToken/toToken to represent native tokens.decimals field (ETH=18, USDC=6, WBTC=8, DAI=18)amount_wei = human_amount × 10^decimals1000000000000000000, NOT 10.03 (3%) if the user doesn't specify0.5) — this is almost certainly an error0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) unless the user explicitly requests it — approve only the needed amounttransactionRequest.to from the quote responsetransactionRequest dataPARTIAL status, explain the user received bridged tokens but not the final target tokenGET /v1/connections to verify the route is supported before retrying| Error | Cause | Action |
|---|---|---|
| HTTP 429 | Rate limited | Wait 30s, retry with exponential backoff (30s → 60s → 120s). Suggest user set LIFI_API_KEY for higher limits. |
| No route found | Route unsupported or amount too small/large | Check /v1/connections for valid pairs. Suggest different tokens, smaller amount, or alternative chains. |
| Slippage error | Price moved beyond tolerance | Increase slippage (e.g., 0.03 → 0.05) and retry. Warn user about the trade-off. |
| Insufficient balance | Wallet lacks funds | Report the shortfall amount. Check balance with the agent's wallet tools. |
| Transaction reverted | Price moved, liquidity drained, or gas too low | Explain possible causes. Suggest retrying with higher slippage or gas. |
| PARTIAL completion | Bridge delivered token but not final swap | User has the bridged asset on the destination chain. They can swap it manually or retry. |
| REFUNDED | Bridge failed, funds returned | Confirm refund on source chain. Suggest trying a different bridge via allowBridges. |
| Invalid address | Malformed hex address | Verify address format: 0x prefix, 42 characters, valid hex. |
| Chain | ID | Native Token |
|---|---|---|
| Ethereum | 1 | ETH |
| Polygon | 137 | MATIC |
| Arbitrum One | 42161 | ETH |
| Optimism | 10 | ETH |
| BSC | 56 | BNB |
| Base | 8453 | ETH |
| Avalanche | 43114 | AVAX |
| Fantom | 250 | FTM |
| zkSync Era | 324 | ETH |
| Gnosis | 100 | xDAI |
| Scroll | 534352 | ETH |
| Linea | 59144 | ETH |
| Blast | 81457 | ETH |
| Mode | 34443 | ETH |
| Solana | 1151111081099710 | SOL |
For the full list of supported chains, call GET /v1/chains.
Native token address on all EVM chains: 0x0000000000000000000000000000000000000000