有关费用如何运作、不同链上的费用收取以及设置费用钱包的更多详细信息,请参阅 货币化集成 指南。
全局费用配置
推荐的方法是在使用createClient 创建 SDK 客户端时全局配置费用。这可确保所有请求自动使用相同的费用配置:
按请求费用配置
或者,您可以按请求配置费用。当您需要为不同类型的交易或用户设置不同的费率时,这很有用。在请求路由或报价时,可以将fee 参数添加到 options 对象中。
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
了解如何配置费用并货币化您的 LI.FI SDK 集成。
createClient 创建 SDK 客户端时全局配置费用。这可确保所有请求自动使用相同的费用配置:
import { createClient } from '@lifi/sdk';
const client = createClient({
integrator: 'Your dApp/company name',
routeOptions: {
fee: 0.01, // 1% fee applied to all requests
},
// other options...
});
fee 参数添加到 options 对象中。
import { getRoutes } from '@lifi/sdk';
const routesRequest = {
fromChainId: 42161, // Arbitrum
toChainId: 10, // Optimism
fromTokenAddress: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
toTokenAddress: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', // DAI on Optimism
fromAmount: '10000000', // 10 USDC
options: {
integrator: 'Your dApp/company name',
fee: 0.01, // 1% fee
},
};
const result = await getRoutes(client, routesRequest);
const routes = result.routes;
import { getQuote } from '@lifi/sdk';
const quoteRequest = {
fromChain: 42161, // Arbitrum
toChain: 10, // Optimism
fromToken: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // USDC on Arbitrum
toToken: '0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1', // DAI on Optimism
fromAmount: '10000000', // 10 USDC
fromAddress: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
integrator: 'Your dApp/company name',
fee: 0.01, // 1% fee
};
const quote = await getQuote(client, quoteRequest);
