Skip to main content
The LI.FI SDK handles the full Composer lifecycle (allowance checks, chain switching, transaction submission, and status tracking) so you can focus on your application logic. This guide shows how to use Composer through the SDK.
Prerequisites: You should have the LI.FI SDK installed and configured. If not, see Installing the SDK and Configure SDK.

Quick Example

Deposit USDC into a Morpho vault on Base using the SDK:
That’s it. The SDK internally manages:
  • Allowance checks and approvals
  • Transaction data retrieval (if using /advanced/routes)
  • Transaction submission
  • Status tracking and polling
  • Chain switching (for cross-chain flows)

Step-by-Step Guide

1. Configure the SDK

Set up the SDK once at application startup. You must configure EVM providers for the chains you want to use.
For full provider configuration, see Configure SDK Providers.

2. Request a Composer Quote

Use getQuote for a single best route (includes transaction data) or getRoutes for multiple options.

Using getQuote

Using getRoutes

The toToken / toTokenAddress is always the vault token address of the target protocol. This is what triggers Composer. Find vault token addresses on the protocol’s own app or documentation.

3. Execute the Route

The executeRoute function handles the entire execution lifecycle:

4. Monitor Execution

The updateRouteHook callback fires on every state change. Use it to update your UI:

Cross-Chain Composer via SDK

Cross-chain Composer works across EVM chains. The integration is identical to same-chain: just use different fromChain and toChain values. The SDK handles bridge routing, chain switching, and status tracking automatically.

ETH (Ethereum) → Morpho vault (Base)

USDC (Ethereum) → Morpho Vault (Base)

The SDK automatically handles:
  • Bridge selection and execution
  • Waiting for bridge completion
  • Chain switching to the destination chain
  • Executing the Composer deposit on the destination chain
  • Status tracking throughout

Execution Options

All execution options are optional but can be useful for advanced use cases: For the full execution options reference, see Execute Routes/Quotes.

Error Handling

The SDK throws errors that you can catch and handle:

Next Steps

Cross-Chain Patterns

Advanced cross-chain Composer flows

Widget Integration

Zero-code Composer via the drop-in Widget

SDK Configuration

Full SDK configuration reference

Vault Deposit Recipes

Copy-paste recipes for common protocols