### Install and Run Widget Examples Source: https://docs.li.fi/widget/widget-light-api-reference Instructions to install dependencies and run the widget examples locally using pnpm. Choose between the minimal EVM-only integration or the full multi-ecosystem setup. ```bash pnpm install pnpm --filter vite-iframe-wagmi dev # or pnpm --filter vite-iframe dev ``` -------------------------------- ### Install and List Chains with LI.FI CLI Source: https://docs.li.fi/llms.txt Quickstart guide to install the LI.FI CLI globally via NPM and list supported chains. Alternatively, run commands without installation using npx. ```bash npm install -g @lifi/cli lifi chains ``` ```bash npx @lifi/cli chains ``` -------------------------------- ### Run Node.js SDK Example Source: https://docs.li.fi/agents/quick-start/code-samples Execute the Node.js SDK example after installing dependencies. ```bash node lifi-sdk-agent.js ``` -------------------------------- ### Install Node.js SDK Dependencies Source: https://docs.li.fi/agents/quick-start/code-samples Install the necessary packages for the Node.js SDK example using npm. ```bash npm install @lifi/sdk viem ``` -------------------------------- ### Install LiFi SDK Provider Packages Source: https://docs.li.fi/sdk/migrate-v3-to-v4 Install the necessary provider packages for the ecosystems you need to support. For example, install `@lifi/sdk-provider-ethereum` if you only support EVM chains. ```typescript yarn add @lifi/sdk-provider-ethereum @lifi/sdk-provider-solana @lifi/sdk-provider-bitcoin @lifi/sdk-provider-sui @lifi/sdk-provider-tron ``` ```typescript pnpm add @lifi/sdk-provider-ethereum @lifi/sdk-provider-solana @lifi/sdk-provider-bitcoin @lifi/sdk-provider-sui @lifi/sdk-provider-tron ``` ```typescript npm install @lifi/sdk-provider-ethereum @lifi/sdk-provider-solana @lifi/sdk-provider-bitcoin @lifi/sdk-provider-sui @lifi/sdk-provider-tron ``` ```typescript bun add @lifi/sdk-provider-ethereum @lifi/sdk-provider-solana @lifi/sdk-provider-bitcoin @lifi/sdk-provider-sui @lifi/sdk-provider-tron ``` -------------------------------- ### Basic LiFi Widget Installation Source: https://docs.li.fi/widget/install-widget This snippet shows the basic setup for integrating the LiFi Widget. Ensure you have the necessary imports and provide your dApp's name. ```typescript import { LiFiWidget, WidgetConfig } from '@lifi/widget'; const widgetConfig: WidgetConfig = { theme: { container: { border: '1px solid rgb(234, 234, 234)', borderRadius: '16px', }, }, }; export const WidgetPage = () => { return ; }; ``` -------------------------------- ### TypeScript: Full Composer Transaction Example Source: https://docs.li.fi/composer/lifi-api/quickstart This example shows how to perform a complete cross-chain transaction using the LiFi API and Composer. It includes setting up the wallet, getting a quote, ensuring token allowance, and sending the transaction. Ensure you replace 'YOUR_PRIVATE_KEY' with your actual private key. ```typescript import { ethers } from 'ethers'; import axios from 'axios'; const API_URL = 'https://li.quest/v1'; // --- Configuration --- const PRIVATE_KEY = 'YOUR_PRIVATE_KEY'; const RPC_URL = 'https://mainnet.base.org'; const FROM_CHAIN = 8453; // Base const FROM_TOKEN = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'; // USDC on Base const TO_TOKEN = '0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A'; // Morpho vault token const FROM_AMOUNT = '1000000'; // 1 USDC // --- Setup --- const provider = new ethers.JsonRpcProvider(RPC_URL); const signer = new ethers.Wallet(PRIVATE_KEY, provider); // --- Helpers --- const getQuote = async (fromAddress: string) => { const result = await axios.get(`${API_URL}/quote`, { params: { fromChain: FROM_CHAIN, toChain: FROM_CHAIN, fromToken: FROM_TOKEN, toToken: TO_TOKEN, fromAmount: FROM_AMOUNT, fromAddress, toAddress: fromAddress, }, }); return result.data; }; const ERC20_ABI = [ 'function approve(address spender, uint256 amount) returns (bool)', 'function allowance(address owner, address spender) view returns (uint256)', ]; const ensureAllowance = async ( tokenAddress: string, approvalAddress: string, amount: string ) => { const erc20 = new ethers.Contract(tokenAddress, ERC20_ABI, signer); const address = await signer.getAddress(); const allowance = await erc20.allowance(address, approvalAddress); if (allowance < BigInt(amount)) { console.log('Setting allowance...'); const tx = await erc20.approve(approvalAddress, amount); await tx.wait(); console.log('Allowance set.'); } }; // --- Main --- const run = async () => { const address = await signer.getAddress(); console.log('Wallet:', address); // 1. Get quote console.log('Requesting Composer quote...'); const quote = await getQuote(address); console.log('Quote received. Tool:', quote.tool); console.log('Estimated output:', quote.estimate.toAmount); // 2. Approve await ensureAllowance( quote.action.fromToken.address, quote.estimate.approvalAddress, quote.action.fromAmount ); // 3. Execute console.log('Sending transaction...'); const tx = await signer.sendTransaction(quote.transactionRequest); console.log('Tx hash:', tx.hash); const receipt = await tx.wait(); console.log('Confirmed in block:', receipt.blockNumber); console.log('Done! USDC deposited into Morpho vault.'); }; run().catch(console.error); ``` -------------------------------- ### LI.FI SDK: Get Quote and Execute Route Source: https://docs.li.fi/llms.txt This TypeScript example demonstrates how to configure the LI.FI SDK, get a quote for a token transfer between chains, and then execute the route. Ensure you have the `@lifi/sdk` package installed. ```typescript import { createConfig, getQuote, executeRoute } from "@lifi/sdk"; createConfig({ integrator: "YourAppName" }); const quote = await getQuote({ fromChain: 1, toChain: 42161, fromToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC on Ethereum toToken: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831", // USDC on Arbitrum fromAmount: "100000000", fromAddress: "0x...", }); await executeRoute(quote, { updateRouteHook: (route) => console.log(route) }); ``` -------------------------------- ### Get Quote and Execute Transfer with LI.FI SDK Source: https://docs.li.fi/agents/quick-start/code-samples This example demonstrates using the LI.FI SDK to get a quote for a token transfer and then executing that transfer. It includes setup for the SDK, wallet client, and handling quote and execution details. ```javascript // lifi-sdk-agent.js // Install: npm install @lifi/sdk viem // Run with: node lifi-sdk-agent.js import { createConfig, getQuote, executeRoute, convertQuoteToRoute } from '@lifi/sdk'; import { createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { mainnet, arbitrum } from 'viem/chains'; // Configuration const PRIVATE_KEY = process.env.PRIVATE_KEY; // Never hardcode! const INTEGRATOR_NAME = 'your-agent-name'; // Initialize SDK createConfig({ integrator: INTEGRATOR_NAME, // Optional: API key for higher rate limits // apiKey: process.env.LIFI_API_KEY, }); // Create wallet client const account = privateKeyToAccount(PRIVATE_KEY); const walletClient = createWalletClient({ account, chain: mainnet, transport: http(), }); // Get a quote async function fetchQuote(params) { const quote = await getQuote({ fromChain: params.fromChain, toChain: params.toChain, fromToken: params.fromToken, toToken: params.toToken, fromAmount: params.fromAmount, fromAddress: account.address, }); return quote; } // Execute the transfer async function executeTransfer(quote) { console.log('Executing transfer...'); // Convert quote to route format for execution const route = convertQuoteToRoute(quote); const result = await executeRoute(route, { // Update hook called on each status change updateRouteHook: (updatedRoute) => { console.log('Route updated:', updatedRoute.id); const step = updatedRoute.steps[0]; if (step?.execution) { console.log(`Execution status: ${step.execution.status}`); } }, }); return result; } // Main flow async function main() { try { console.log(`Wallet address: ${account.address}`); // Get quote const quote = await fetchQuote({ fromChain: 1, // Ethereum toChain: 42161, // Arbitrum fromToken: 'USDC', toToken: 'USDC', fromAmount: '10000000', // 10 USDC }); console.log('Quote received:'); console.log(`- Tool: ${quote.tool}`); console.log(`- Expected: ${quote.estimate.toAmount}`); console.log(`- Minimum: ${quote.estimate.toAmountMin}`); // Execute (uncomment to run actual transfer) // const result = await executeTransfer(quote); // console.log('Transfer complete:', result); } catch (error) { console.error('Error:', error.message); } } main(); ``` -------------------------------- ### Configure LiFi SDK Client Source: https://docs.li.fi/composer/lifi-api/guides/sdk-integration Set up the SDK client once at application startup. Ensure EVM providers are configured for the desired chains. Requires wallet client for provider setup. ```typescript import { createClient } from "@lifi/sdk"; import { EthereumProvider } from "@lifi/sdk-provider-ethereum"; const client = createClient({ integrator: "YourAppName", }); client.setProviders([ EthereumProvider({ getWalletClient: () => Promise.resolve(walletClient), }), ]); ``` -------------------------------- ### Install Python Agent Dependencies Source: https://docs.li.fi/agents/quick-start/code-samples Install the 'requests' library for the Python agent example using pip. ```bash pip install requests ``` -------------------------------- ### Configure EVM Provider with Local Accounts Source: https://docs.li.fi/sdk/configure-sdk-providers Set up the Ethereum provider for the LI.FI SDK using Viem and local accounts. This example demonstrates how to define chains, create a wallet client, and configure the provider to handle chain switching. ```typescript import { createClient } from '@lifi/sdk'; import { EthereumProvider } from '@lifi/sdk-provider-ethereum'; import type { Chain } from 'viem'; import { createWalletClient, http } from 'viem'; import { privateKeyToAccount } from 'viem/accounts'; import { arbitrum, mainnet, optimism, polygon, scroll } from 'viem/chains'; const account = privateKeyToAccount('PRIVATE_KEY'); const chains = [arbitrum, mainnet, optimism, polygon, scroll]; const walletClient = createWalletClient({ account, chain: mainnet, transport: http(), }); const client = createClient({ integrator: 'Your dApp/company name', }); client.setProviders([ EthereumProvider({ getWalletClient: async () => walletClient, switchChain: async (chainId) => // Switch chain by creating a new wallet client createWalletClient({ account, chain: chains.find((chain) => chain.id == chainId) as Chain, transport: http(), }), }), ]); ``` -------------------------------- ### Full Swap and Zap Example with Composer SDK Source: https://docs.li.fi/composer/composer-api/quickstart This example demonstrates a complete DeFi flow using the Composer SDK, involving a token swap followed by a zap into a lending protocol position. It includes input binding, output configuration, and the use of guards for execution safety. ```typescript import { createComposeSdk, guards, materialisers, resources, } from '@lifi/composer-sdk'; const WETH = '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'; const USDC = '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48'; const A_ETH_USDC = '0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c'; const run = async () => { const sdk = createComposeSdk({ baseUrl: 'https://composer.li.quest', apiKey: process.env.LIFI_API_KEY, }); const builder = sdk.flow(1, { name: 'swap-and-zap-quickstart', inputs: { amountIn: resources.erc20(WETH, 1), }, }); // Swap WETH → USDC via LI.FI. const swapOutputs = builder.lifi.swap('swap', { bind: { amountIn: builder.inputs.amountIn }, config: { resourceOut: resources.erc20(USDC, 1), slippage: 0.03, }, }); // Zap the swapped USDC into Aave's aEthUSDC position. builder.lifi.zap('zap', { bind: { amountIn: swapOutputs.amountOut }, config: { resourceOut: resources.erc20(A_ETH_USDC, 1), }, guards: [guards.slippage({ port: 'amountOut', bps: 100 })], }); const result = await builder.compile({ signer: '0xYourSignerAddress', inputs: { amountIn: materialisers.directDeposit({ amount: '1000000000000000000', // 1 WETH (18 decimals) }), }, sweepTo: builder.context.sender, }); console.log(JSON.stringify(result.transactionRequest, null, 2)); }; run().catch((err) => { console.error(err); process.exit(1); }); ``` -------------------------------- ### Example URL with Search Parameters Source: https://docs.li.fi/widget/configure-widget This is an example of a URL that can be used to initialize the widget with specific form values. Ensure `buildUrl` is true in the widget config for this to work. ```url https://playground.li.fi/?fromAmount=20&fromChain=42161&fromToken=0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9&toAddress=0x29DaCdF7cCaDf4eE67c923b4C22255A4B2494eD7&toChain=42161&toToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831 ``` -------------------------------- ### Install Ecosystem Provider Packages Source: https://docs.li.fi/integrate-li.fi-js-sdk/install-li.fi-sdk Install provider packages for specific ecosystems if you need to execute transactions through the SDK. For example, install the Ethereum provider for EVM chains. ```bash yarn add @lifi/sdk-provider-ethereum # For EVM chains (uses viem) yarn add @lifi/sdk-provider-solana # For Solana (uses @solana/kit) yarn add @lifi/sdk-provider-bitcoin # For Bitcoin (uses @bigmi/core) yarn add @lifi/sdk-provider-sui # For Sui (uses @mysten/sui v2) yarn add @lifi/sdk-provider-tron # For Tron (uses tronweb) ``` -------------------------------- ### Example Request Body for Getting Routes Source: https://docs.li.fi/api-reference/advanced/get-a-set-of-routes-for-a-request-that-describes-a-transfer-of-tokens This is an example of the request body used to get a set of routes for a token transfer. It includes essential details like token addresses, chain IDs, and amounts, along with optional configurations for bridges, exchanges, and slippage. ```json { "fromAddress": "0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0", "fromChainId": 100, "fromAmount": "1000000000000000000", "fromTokenAddress": "0x63e62989d9eb2d37dfdb1f93a22f063635b07d51", "toChainId": 137, "toTokenAddress": "0xc0b2983a17573660053beeed6fdb1053107cf387", "options": { "integrator": "fee-demo", "slippage": 0.003, "fee": 0.02, "bridges": { "allow": [ "relay" ] }, "exchanges": { "allow": [ "1inch", "openocean" ] } } } ``` -------------------------------- ### Install All Ecosystem Dependencies Source: https://docs.li.fi/widget/widget-light-installation Install all available ecosystem dependencies for Widget Light at once. This includes packages for EVM, Solana, Bitcoin, Sui, and Tron. ```bash pnpm add @lifi/widget-light wagmi viem @wagmi/core @tanstack/react-query @wallet-standard/base @bigmi/client @bigmi/react @mysten/dapp-kit-react @tronweb3/tronwallet-adapter-react-hooks ``` ```bash yarn add @lifi/widget-light wagmi viem @wagmi/core @tanstack/react-query @wallet-standard/base @bigmi/client @bigmi/react @mysten/dapp-kit-react @tronweb3/tronwallet-adapter-react-hooks ``` ```bash npm install @lifi/widget-light wagmi viem @wagmi/core @tanstack/react-query @wallet-standard/base @bigmi/client @bigmi/react @mysten/dapp-kit-react @tronweb3/tronwallet-adapter-react-hooks ``` ```bash bun add @lifi/widget-light wagmi viem @wagmi/core @tanstack/react-query @wallet-standard/base @bigmi/client @bigmi/react @mysten/dapp-kit-react @tronweb3/tronwallet-adapter-react-hooks ``` -------------------------------- ### Get Quote for Same-Chain Deposit Source: https://docs.li.fi/llms.txt This example demonstrates how to get a quote for depositing USDC into a Morpho vault on the Base chain using the Composer. ```APIDOC ## GET /v1/quote ### Description Retrieves a quote for a transaction, which can include bundled protocol interactions via Composer. ### Method GET ### Endpoint https://li.quest/v1/quote ### Parameters #### Query Parameters - **fromChain** (number) - Required - The chain ID of the source chain. - **toChain** (number) - Required - The chain ID of the destination chain. - **fromToken** (string) - Required - The token address to send from. - **toToken** (string) - Required - The token address to send to. For Composer, this should be a supported protocol's vault, staking, or deposit token address. - **fromAddress** (string) - Required - The user's wallet address. - **fromAmount** (string) - Required - The amount of the `fromToken` to send. ### Request Example ``` GET https://li.quest/v1/quote?fromChain=8453&toChain=8453&fromToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&toToken=0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A&fromAddress=0x...&fromAmount=1000000 ``` ``` -------------------------------- ### Run Node.js API Example Source: https://docs.li.fi/agents/quick-start/code-samples Execute the Node.js API example using the native fetch implementation. No external dependencies are required. ```bash # No dependencies required (uses native fetch) node lifi-agent.js ``` -------------------------------- ### Get Quote for Cross-Chain Deposit Source: https://docs.li.fi/llms.txt This example shows how to get a quote for a cross-chain transaction, sending ETH on Ethereum and depositing it into a Morpho vault on Base using the Composer. ```APIDOC ## GET /v1/quote ### Description Retrieves a quote for a cross-chain transaction, which can include bundled protocol interactions via Composer. ### Method GET ### Endpoint https://li.quest/v1/quote ### Parameters #### Query Parameters - **fromChain** (number) - Required - The chain ID of the source chain (e.g., Ethereum). - **toChain** (number) - Required - The chain ID of the destination chain (e.g., Base). - **fromToken** (string) - Required - The token address to send from (e.g., ETH address). - **toToken** (string) - Required - The token address to send to. For Composer, this should be a supported protocol's vault, staking, or deposit token address. - **fromAddress** (string) - Required - The user's wallet address. - **fromAmount** (string) - Required - The amount of the `fromToken` to send. ### Request Example ``` GET https://li.quest/v1/quote?fromChain=1&toChain=8453&fromToken=0x0000000000000000000000000000000000000000&toToken=0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A&fromAddress=0x...&fromAmount=100000000000000000 ``` ``` -------------------------------- ### Swap and Zap Flow Example Source: https://docs.li.fi/composer/composer-api/reference/flow-wire-format A complete Flow wire format example demonstrating a swap operation followed by a zap operation, including input and output resource definitions, node configurations, and guards. ```json { "version": 1, "id": "swap-and-zap-weth-to-aave", "chainId": 1, "inputs": [ { "name": "amountIn", "resource": { "kind": "erc20", "token": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", "chainId": 1 } } ], "nodes": [ { "id": "swap", "op": "lifi.swap", "bind": { "amountIn": { "$ref": "input.amountIn" } }, "config": { "resourceOut": { "kind": "erc20", "token": "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", "chainId": 1 }, "slippage": 0.03 } }, { "id": "zap", "op": "lifi.zap", "bind": { "amountIn": { "$ref": "swap.amountOut" } }, "config": { "resourceOut": { "kind": "erc20", "token": "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c", "chainId": 1 } }, "guards": [ { "kind": "slippage", "port": "amountOut", "bps": 100 } ] } ] } ``` -------------------------------- ### Example Cross-Chain Swap Workflow Source: https://docs.li.fi/cli/overview Demonstrates a typical workflow for performing a cross-chain swap using the LI.FI CLI, including finding chains, tokens, getting quotes, and tracking status. Note that transaction signing is an external step. ```bash # 1. Find chain IDs lifi chains --type EVM # 2. Look up token addresses lifi token 1 USDC # 3. Get best quote lifi quote \ --from 1 --to 8453 \ --from-token USDC --to-token USDC \ --amount 1000000000 \ --from-address 0xYOUR_ADDRESS # 4. (External) Approve tokens and sign transactionRequest with your wallet # 5. Track progress lifi status 0xTX_HASH --watch ``` -------------------------------- ### Get Quote for EVM to Solana Transfer Source: https://docs.li.fi/introduction/user-flows-and-examples/solana-tx-execution Request a quote for a token transfer from an EVM chain to Solana. This example uses query parameters for a simple GET request. ```curl curl --request GET \ --url 'https://li.quest/v1/quote?fromChain=ARB&toChain=SOL&fromToken=0xaf88d065e77c8cC2239327C5EDb3A432268e5831&toToken=7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs&fromAddress=YOUR_EVM_WALLET&toAddress=YOUR_SOL_WALLET&fromAmount=1000000000' \ --header 'accept: application/json' ``` -------------------------------- ### Get Tokens Source: https://docs.li.fi/introduction/user-flows-and-examples/bitcoin-tx-example Fetches a list of tokens available on a specific blockchain. This example retrieves Bitcoin-related tokens. ```APIDOC ## GET /v1/tokens ### Description Retrieves a list of tokens supported on a specified blockchain. This example focuses on tokens available on the Bitcoin chain. ### Method GET ### Endpoint /v1/tokens?chains=BTC ### Parameters #### Query Parameters - **chains** (string) - Required - The chain identifier for which to list tokens. 'BTC' is used to specify the Bitcoin chain. ``` -------------------------------- ### Install LI.FI SDK with Bun Source: https://docs.li.fi/sdk/installing-the-sdk Install the core LI.FI SDK package using Bun. ```typescript bun add @lifi/sdk ``` -------------------------------- ### OpenAPI Specification for Get Vault Source: https://docs.li.fi/api-reference/earn-vaults/get-vault-by-chain-and-address This OpenAPI specification defines the GET /v1/vaults/{chainId}/{address} endpoint, which returns detailed information about a specific vault. It includes parameter descriptions, response schemas, and example data. ```yaml openapi: 3.0.0 info: title: LI.FI Earn API description: Enterprise DeFi yield discovery and tracking API version: 0.1.0 contact: {} servers: - url: https://earn.li.fi description: Production security: - x-lifi-api-key: [] tags: [] paths: /v1/vaults/{chainId}/{address}: get: tags: - Earn Vaults summary: Get vault by chain and address description: Returns the full details for a single vault. operationId: VaultsController_getVault_v1 parameters: - name: address required: true in: path description: Vault contract address (0x-prefixed, 40 hex characters). example: '0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' schema: type: string pattern: ^0x[0-9a-fA-F]{40}$ - name: chainId required: true in: path description: EVM chain ID of the network the vault is deployed on. example: 8453 schema: type: integer minimum: 1 maximum: 2147483647 responses: '200': description: Vault found content: application/json: schema: $ref: '#/components/schemas/Vault' example: address: '0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' network: base chainId: 8453 slug: morpho-base-usdc-0x7bfa name: Morpho USDC Vault description: Optimized USDC lending vault on Morpho protocol: name: Morpho logoUri: https://example.com/morpho-logo.png url: https://morpho.org underlyingTokens: - address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913' symbol: USDC decimals: 6 weight: 1 lpTokens: - address: '0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' symbol: mUSDC decimals: 18 priceUsd: '1.02' rewardTokens: [] tags: - stablecoin - lending analytics: apy: base: 0.0534 reward: null total: 0.0534 apy1d: 0.0521 apy7d: 0.0538 apy30d: 0.0545 tvl: usd: '12500000.00' native: '12500000000000' updatedAt: '2026-03-31T14:30:00.000Z' caps: totalCap: '50000000000000' maxCap: '100000000000000' timeLock: 0 kyc: false syncedAt: '2026-03-31T14:30:00.000Z' isTransactional: true isRedeemable: true depositPacks: - name: morpho-deposit stepsType: instant redeemPacks: - name: morpho-redeem stepsType: instant '400': description: Invalid chain ID or address format content: application/json: schema: $ref: '#/components/schemas/ValidationError' '404': description: Vault not found content: application/json: schema: $ref: '#/components/schemas/NotFoundError' components: schemas: Vault: type: object additionalProperties: false required: - address - network - chainId - slug - name - protocol - underlyingTokens - lpTokens - tags - analytics - syncedAt - isTransactional - isRedeemable - depositPacks - redeemPacks properties: address: type: string description: Vault contract address (0x-prefixed, 40 hex characters). example: '0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' network: type: string description: Network name as a lowercase string (e.g., `base`, `ethereum`). example: base chainId: type: integer description: EVM chain ID of the network the vault is deployed on. example: 8453 minimum: -9007199254740991 maximum: 9007199254740991 slug: type: string description: >- URL-safe unique identifier for the vault, combining protocol, ``` -------------------------------- ### Initialize and Use Client in LiFi SDK v4 Source: https://docs.li.fi/sdk/migrate-v3-to-v4 Demonstrates initializing the LiFi SDK v4 client with integrator name and accessing configuration, setting providers, and fetching chains or specific chains and RPC URLs. ```typescript // SDK v4 import { createClient } from '@lifi/sdk'; const client = createClient({ integrator: 'Your dApp/company name', }); // Access configuration (read-only) console.log(client.config.integrator); // Set providers client.setProviders([...]); // Get chains const chains = await client.getChains(); // Get specific chain const chain = await client.getChainById(1); // Get RPC URLs const rpcUrls = await client.getRpcUrls(); ``` -------------------------------- ### Get Quote for USDe to sUSDe Deposit (TypeScript) Source: https://docs.li.fi/composer/lifi-api/recipes/vault-deposits Use this TypeScript code snippet to get a quote for swapping USDe to sUSDe on the same chain (Ethereum) using the LiFi API. Ensure you have axios installed and a signer object available. ```typescript const { data: quote } = await axios.get(`${API_URL}/quote`, { params: { fromChain: 1, toChain: 1, fromToken: "0x4c9EDD5852cd905f086C759E8383e09bff1E68B3", // USDe toToken: "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497", // sUSDe (Ethena) fromAddress: await signer.getAddress(), toAddress: await signer.getAddress(), fromAmount: "1000000000000000000000", // 1000 USDe (18 decimals) slippage: 0.005, }, }); // Approve + send (same pattern as the Morpho example above) ``` -------------------------------- ### MCP Server Example Workflow Source: https://docs.li.fi/lifi-intents/mcp-server/overview Outlines the sequence of tool calls for a typical cross-chain swap using the MCP server. ```text 1. get-supported-routes # Discover available chain + token pairs 2. request-quote # Get pricing (chain names, symbols, or IDs all work) 3. prepare-order # Build order structure (unsigned) 4. (external) Sign the order using EIP-712 typed data signing 5. submit-order # Submit signed order to the order server 6. track-order # Monitor: Submitted -> Open -> Signed -> Delivered -> Settled ``` -------------------------------- ### Get Transfer Quote API Example Source: https://docs.li.fi/llms.txt Use this endpoint to get a quote for a token transfer. It returns a transaction request ready for signing. Ensure you provide the correct chain IDs, token symbols, amounts, and sender address. ```HTTP GET /v1/quote?fromChain=1&toChain=42161&fromToken=USDC&toToken=USDC&fromAmount=1000000&fromAddress=0x... ``` -------------------------------- ### Widget v3 Configuration Example Source: https://docs.li.fi/widget/migrate-from-v3-to-v4 Example of how the LiFiWidget was configured in v3, relying on automatic provider detection. ```typescript import { LiFiWidget } from '@lifi/widget'; import { WagmiProvider } from 'wagmi'; export const WidgetPage = () => { return ( ); }; ``` -------------------------------- ### Get Advanced Possibilities Request Example Source: https://docs.li.fi/openapi.yaml Define preferences for chains, exchanges, and bridges to retrieve available services. This endpoint is deprecated. ```OpenAPI post: requestBody: description: >- Object defining preferences regarding chain, exchanges and bridges. Retrieve the up-to-date lists of supported exchanges and bridges from the `/v1/tools` endpoint. content: application/json: schema: $ref: '#/components/schemas/PossibilitiesRequest' examples: PossibilitiesRequestExample: value: chains: - 100 - 137 bridges: allow: - relay - hop deny: - cbridge prefer: - relay exchanges: allow: - 1inch - paraswap - openocean deny: - 0x prefer: - 1inch tags: - advanced parameters: - name: x-lifi-api-key description: >- Authentication header, register in the LI.FI Partner Portal (https://portal.li.fi/ ) to get your API Key. schema: type: string in: header required: false responses: '200': $ref: '#/components/responses/PossibilitiesResponse' deprecated: true summary: Get information about available services, chains and tokens description: >- Get a set of current possibilities based on a request that specifies which chains, exchanges and bridges are preferred or unwanted. ``` -------------------------------- ### Get Tools Source: https://docs.li.fi/introduction/user-flows-and-examples/bitcoin-tx-example Retrieves a list of available tools for a specific chain, identified by its chain ID. This example targets a UTXO chain. ```APIDOC ## GET /v1/tools ### Description Fetches a list of tools available for a given blockchain. This example queries for tools on a specific UTXO chain. ### Method GET ### Endpoint /v1/tools?chains=20000000000001 ### Parameters #### Query Parameters - **chains** (string) - Required - The chain ID for which to retrieve tools. '20000000000001' is used as an example for a UTXO chain. ``` -------------------------------- ### Custom Iframe Setup with useWidgetLightHost Source: https://docs.li.fi/widget/widget-light-api-reference Demonstrates how to set up a custom iframe using the useWidgetLightHost hook, including configuration, handlers, and iframe origin. ```tsx import { useWidgetLightHost } from '@lifi/widget-light' import { useEthereumIframeHandler } from '@lifi/widget-light/ethereum' import { useMemo } from 'react' function CustomIframeSetup() { const ethHandler = useEthereumIframeHandler() const handlers = useMemo(() => [ethHandler], [ethHandler]) const { iframeRef } = useWidgetLightHost({ config: { integrator: 'my-app', fromChain: 1, toChain: 137 }, handlers, iframeOrigin: 'https://widget.li.fi', autoResize: true, }) return (