Links

Set Route Options

How to whitelist, blacklist, or prefer certain bridges and exchanges.
The RoutesRequest object takes optional RouteOptions. This allows configuring the route calculation further.
interface RouteOptions {
integrator?: string // Should contain the identifier of the integrator. Usually, it's dApp/company name.
fee?: number // 0.03 = take 3% integrator fee (requires verified integrator to be set)
insurance?: boolean // Whether the user wants to insure their tx
maxPriceImpact?: number // Hide routes with price impact greater than or equal to this value
order?: Order // (default: RECOMMENDED) 'RECOMMENDED' | 'FASTEST' | 'CHEAPEST' | 'SAFEST'
slippage?: number // (default: 0.03) Expressed as decimal proportion, 0.03 represents 3%
referrer?: string // Integrators can set a wallet address as a referrer to track them
infiniteApproval?: boolean // (default: false)
allowSwitchChain?: boolean // (default: false) Whether chain switches should be allowed in the routes
allowDestinationCall?: boolean // (default: true) destination calls are enabled by default
bridges?: AllowDenyPrefer
exchanges?: AllowDenyPrefer
}
interface AllowDenyPrefer {
allow?: string[];
deny?: string[];
prefer?: string[];
}

Route Order Options

The different order options are defined as follows:
  • RECOMMENDED: This sorting option balances cost and complexity, prioritizing affordable and less complex routes. It first sorts routes based on their cost and then focuses on the top 5% of the routes. These top routes are ranked by considering both their cheapness and ease of use.
  • FASTEST: This sorting option prioritizes routes with the shortest estimated execution time. Users who value speed and want their transactions to be completed as quickly as possible should choose the fastest routes.
  • CHEAPEST: This option focuses on minimizing the cost of the transaction, whether in token amount or USD amount (USD amount minus gas cost). Users looking for the most economical option should choose the cheapest routes.
  • SAFEST: Sorting with this option emphasizes the safety and reliability of the routes. Routes are ranked based on the safety level of the tools (bridges) used in their steps. Users who prioritize security and want to minimize risks associated with their transactions should choose the safest routes. If two routes have the same safety level, they are further ranked based on their speed.

Monetization

As an integrator, you can monetize your LI.FI Widget integration and collect fees. See our monetization guide for more information.

Enable/Disable of Assets/DEXs/Bridges

The inclusion and exclusion of specific bridges, exchanges, and services which should be preferred can be controlled via AllowDenyPrefer objects. By allowing/whitelisting (allow) tools, only those tools will be used to find the best routes. Tools specified in deny will be blacklisted. You can find all available keys in List: Chains, Bridges, DEXs, Solvers or by fetching the list of supported tools.
E.g., if you only want to use Connext as the bridge and don't want to support the 1inch exchange your options could look like this:
const routeOptions = {
bridges: {
allow: ['connext']
},
exchanges: {
deny: ['1inch'],
},
}
The allowSwitchChain property is part of an advanced set of functionalities. You can read more about them in the chapter Advanced Features
Last modified 3mo ago