Skip to main content
This quickstart deposits 1 USDC into a Morpho vault on Base in one same-chain transaction: request a quote, approve the token, send the transaction. For cross-chain deposits, see Cross-chain deposits.

Prerequisites

  • A wallet with USDC on Base (1 USDC is enough)
  • Node.js 18+ with axios and viem installed, or curl for the quote only

1

Get a Composer quote

Request a quote with toToken set to the vault token address:
curl
toToken is the position token address of the target protocol, such as a vault share token. Take it from Supported Protocols & Chains, which lists every token Composer can route to.The response includes transactionRequest, a ready-to-sign EVM transaction, and the estimated output. The route uses Composer when a step in includedSteps has tool: "composer":
TypeScript
If a DEX can buy the vault token more cheaply, the quote uses that DEX instead (for example tool: "nordstern"). The user still receives the vault token.
If the user reviews a quote for more than 30 seconds, re-fetch it before signing to get current pricing and simulation results.
2

Set token allowance

Approve the address in quote.estimate.approvalAddress to spend fromAmount of the input token. On Base this is the audited LI.FI Diamond at 0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE; always approve the address returned in the quote. Native tokens such as ETH need no approval. The full working example shows the allowance check, the approval and the send.
If an approval transaction was sent, re-fetch the quote before executing. The gas estimates in the original transactionRequest can be stale by the time the approval confirms.
3

Send the transaction

Send the transactionRequest from the quote. A same-chain route runs in one atomic transaction: either every step (swap and deposit) succeeds, or the transaction reverts and the USDC stays in the wallet. The deposit is complete once the transaction confirms. Cross-chain routes also need status polling and PARTIAL handling; see Cross-chain deposits.The quote was simulated against current chain state, but prices and state can change before the transaction lands. estimate.toAmountMin is the minimum output after slippage; the transaction reverts below it.

Full working example

This script runs the three steps. Set PRIVATE_KEY in the environment before running it.

Next steps

Cross-chain deposits

Bridge + deposit and swap + bridge + deposit across EVM chains

Withdrawals Guide

Add the other half of the user journey with withdraw flows

SDK Integration

Use the LI.FI SDK for managed execution with hooks and events

Vault Deposit Recipes

Copy-paste recipes for Morpho, Aave, Euler, and more