API latency and optimization
API latency and optimization guide
Where Latency Comes From and How LI.FI Routing Works
LI.FI’s routing engine aggregates quotes from multiple bridges and decentralized exchanges (DEXes). This process involves real-time requests to external protocols and tools, including:
- Bridge and DEX aggregators
- On-chain simulations for security and execution checks
- Off-chain services that may introduce their own delays
Latency can vary depending on the number of providers queried, the responsiveness of those providers, and whether on-chain simulations are enabled.
The LI.FI routing flow includes two main components:
- Swap Step Resolution – Fetches quotes from DEXes.
- Route Composition – Combines swaps and bridges to construct optimal cross-chain paths.
Both steps involve third-party systems and introduce potential delays. By default, LI.FI waits a short time for responses before returning the best available result. However, integrators can configure timing strategies to better control this behavior.
Optimizing Response Timing
You can optimize how quickly you receive quotes by customizing:
Choosing Between /quote
and /routes
- Use
/quote
for faster responses. It returns a single best route. It combines route finding and transaction generation into a single call which cuts down on client to server latency. - Use
/routes
to retrieve multiple route options. Those calls are quite fast to show results to the user quickly. In order to execute one of the routes a call to/stepTransaction
is needed to generate the transaction data.
Disabling Simulation
-
By default, responses with transaction data include on-chain simulation checks.
-
To improve speed, set the simulation option to
false
. You pass theskipSimulation
flag as a query parameter to the/quote
or/stepTransaction
endpoint: -
Note: Disabling simulation reduces verification but improves response time. It is especially recommended when you simulate/gasEstimate the transaction either way in your system.
Selecting Timing Strategies
LI.FI allows you to control how long it waits for results using timing strategies. Instead of only specifiy a timeout they are allow more advanced configuration to ensure that results of multiple tools get considered.
Timeing strategies are applied in two ways when generating routes:
swapStepTimingStrategies
: applied when requesting same chain exchangesrouteTimingStrategies
: applied on the full route that can consist of multiple tools (e.g. swap+bridge)
Timing Strategy Format
A timing stratgies consists of the following properties:
- strategy: Currently only
minWaitTime
exists - minWaitTimeMs: Minimum time to wait for responses (e.g. 600ms)
- startingExpectedResults: Number of expected quotes (e.g. 4)
- reduceEveryMs: Frequency of reducing expectations (e.g. every 300ms)
When this strategy is applied, we give all tool 600ms (minWaitTimeMs) to return a result. If we received 4 or more (startingExpectedResults) results during this time we return those and don’t wait for other tools.
If less than 4 results are present we wait another 300ms and check if now at least 3 results are present.
Passing Strategies in API calls
In POST /v1/advanced/routes
requests:
In GET /v1/quote
requests:
The passed strategies in those examples are the default strategies we apply.
Timing Strategy Examples
Maximise Results
Returns the best routes even if it takes longer:
Balanced Approach
Waits a moderate amount of time to return a mix of speed and completeness:
Fastest Possible Response
Returns first available result with no delay:
Time-Limited Return (timeout)
Returns any result received within a fixed time limit:
The timing strategies are only used for how long LI.FI will wait for third party providers to respond, the total response time from LI.FI API will be the sum of roundTripTime+parsing+strategies+simulation.