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 {
order?: Order; // 'RECOMMENDED' | 'FASTEST' | 'CHEAPEST' | 'SAFEST'
slippage?: number; // expressed as decimal proportion: 0.03 represents 3%
infiniteApproval?: boolean;
allowSwitchChain?: boolean; // Whether chain switches should be allowed in the routes
integrator?: string; // string telling us who you are
referrer?: string; // string telling us who referred you to us
fee?: number; // expressed as decimal proportion: 0.03 represents 3%
bridges?: AllowDenyPrefer;
exchanges?: AllowDenyPrefer;
}
interface AllowDenyPrefer {
allow?: string[];
deny?: string[];
prefer?: string[];
}
The different
order
options are defined as follows:- RECOMMENDED: This sorting criteria aims to find a balance between 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 criteria 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 criteria 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 by this criteria 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.
The inclusion and exclusion of specific bridges and exchanges, as well as which services 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 or by fetching the list of supported tools.E.g. if you only want to use NXTP by Connext as the bridge and don't want to support the exchange 1inch 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 FeaturesLast modified 1mo ago