Documentation Index
Fetch the complete documentation index at: https://docs.li.fi/llms.txt
Use this file to discover all available pages before exploring further.
For more details about how fees work, fee collection on different chains, and
setting up fee wallets, see the Monetizing the
integration guide.
When using the LI.FI SDK, you can monetize your integration by collecting fees from the transactions processed through your application. The SDK supports fee configuration in two ways: globally when creating the SDK config, or per-request through route options.
Global fee configuration
The recommended approach is to configure fees globally when creating your SDK config using createConfig. This ensures all requests use the same fee configuration automatically:
import { createConfig } from "@lifi/sdk";
const config = createConfig({
integrator: "Your dApp/company name",
routeOptions: {
fee: 0.01, // 1% fee applied to all requests
},
// other options...
});
With this configuration, all route requests, quotes, and contract calls will automatically include the specified fee without needing to add it to each individual request.
Per-request fee configuration
Alternatively, you can configure fees on a per-request basis. This is useful when you need different fee rates for different types of transactions or users. The fee parameter can be added to the options object when requesting routes or quotes.
Basic route request with fees
import { getRoutes } from "@lifi/sdk";
const routesRequest: 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(routesRequest);
const routes = result.routes;
Quote request with fees
import { getQuote } from "@lifi/sdk";
const quoteRequest: 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(quoteRequest);