Pick a route and avoid bridges
Show users every route a quote found and build the one they pick. Keep providers, bridges and exchanges they never want out of every route with three quote parameters.
A quote asks every provider that serves the route at once. best is the route with the highest time-adjusted output (or, within 0.1% of it, the one that supports LayerHop; see Providers & ranking), but every entry of quotes is a complete quote: it has its own quoteId, carries the same LayerHop fee, and can be built with POST /v1/orders. So your app can show all of them and let the user choose.
Show every route#
Each quote has what a route list needs:
| Field | Show it as |
|---|---|
provider |
Who runs the route (relay, debridge, lifi, …). |
estimatedSeconds |
Arrival time. |
fees |
LayerHop's fee (ourFeeBps), the provider's fee (providerFeeUsd) and network gas (gasUsd) when known. |
dstAmount / dstAmountMin |
Amount received, and the least it can be after slippage. |
const res = await lh.quote({
srcChain: "base", srcToken: "USDC", amount: "20000000", // 20 USDC
dstChain: "arbitrum", dstToken: "USDC",
sender: "0xYou", recipient: "0xYou",
});
for (const q of res.quotes) console.log(q.provider, q.estimatedSeconds, q.dstAmount, q.fees);
const picked = res.quotes.find((q) => q.provider === "debridge") ?? res.best;
const { tx } = await lh.buildTx(picked.quoteId);Quotes expire (expiresAt), so quote again before building an old one. When you re-quote, keep the user's choice by provider: if that provider answered again, select its new quote; if not, fall back to best and tell the user.
Avoid providers, bridges and exchanges#
Three optional parameters on GET /v1/quote (comma-separated) and POST /v1/quote (an array or a comma-separated string):
| Parameter | Ids |
|---|---|
excludeProviders |
across, blast-native, debridge, jupiter, kyberswap, lifi, mayan, relay, zerox |
excludeBridges |
across, allbridge, arbitrum-bridge, blast-bridge, celer-cctp, debridge, eco, garden, gaszip, glacis, layerswap, mayan, near-intents, polymer, relay, squid, stargate, symbiosis |
excludeExchanges |
0x, 1inch, dodo, enso, jupiter, kyberswap, okx, sushiswap, velora |
curl "https://api.layerhop.com/v1/quote?srcChain=base&srcToken=USDC&amount=20000000\
&dstChain=arbitrum&dstToken=USDC&sender=0xYou&recipient=0xYou\
&excludeBridges=stargate,relay&excludeExchanges=1inch"await lh.quote({ ...params, excludeBridges: ["stargate", "relay"], excludeExchanges: ["1inch"] });How each list is applied:
- A bridge or exchange that is itself a LayerHop provider (Across, Blast Bridge, deBridge, Mayan and Relay as bridges; 0x, Jupiter and KyberSwap as exchanges) excludes that provider: it is not asked.
- The other bridges and exchanges are ones LI.FI can route through. LayerHop passes them to LI.FI as its deny list, and drops a LI.FI route that still names one (it appears in
errorswithROUTE_EXCLUDED). - Unknown ids, or an id in the wrong list, are
INVALID_PARAMS, with the valid ids in the message. - When the lists rule out every route for the pair, the answer is
ROUTE_EXCLUDED.
Avoiding a route never changes the fee: every route still offered carries the same LayerHop fee as without the lists.
Last updated