Skip to main content
This recipe walks through a complete LI.FI Earn integration: use the Earn Data API to find the highest-yielding vaults for a specific token, display them to a user, and then execute a deposit via Composer.
Two layers, one flow. This recipe uses the Earn Data API for discovery and Composer for execution. The Earn Data API tells you where to deposit. Composer handles how.

Step 1: Find the Best USDC Vaults on Base

Query the Earn Data API for USDC vaults on Base, sorted by APY:

Step 2: Filter for Depositable Vaults

Not all vaults support deposits via Composer. Filter using the isTransactional flag:
TypeScript
Use apy30d alongside apy.total to give users a sense of yield stability. A vault with a high current APY but low 30-day average may be experiencing a temporary spike.

Step 3: Get a Composer Quote

When the user selects a vault, use its contract address as the toToken in a Composer quote request. This is the handoff from Earn to Composer.
The Composer quote endpoint is https://li.quest/v1/quote. This is the Composer layer of LI.FI Earn, not the Earn Data API. See the Composer API Integration Guide for full details on parameters, token approvals, and transaction submission.

Step 4: Execute the Transaction

Submit the transaction from the quote response. See the Composer API Integration Guide for the full execution flow including token approvals and status tracking.
TypeScript

Step 5: Verify the Position

After the deposit confirms, use the Earn portfolio endpoint to verify the user’s new position:

Cross-Chain Deposits

Vaults are chain-specific, but Composer handles cross-chain deposits seamlessly. To deposit from a different chain, change fromChain and fromToken in the quote request:
TypeScript
Composer’s routing engine automatically determines the optimal bridge and swap path. See Cross-Chain Compose for details.

Full Example

Here is the complete flow in a single function:
TypeScript

Earn API Reference

Full endpoint reference with all parameters

Composer Vault Deposits

More vault deposit recipes with protocol-specific examples

Composer API Guide

Full Composer integration guide including approvals and status tracking

Cross-Chain Compose

Cross-chain deposit patterns and bridge selection