LayerHopDocsLaunch app (opens in a new tab)

Providers & ranking

How LayerHop orders quotes by time-adjusted output for the user, how near-identical quotes (within 0.1%) are settled, and which providers are asked for each route.

LayerHop ranks quotes by time-adjusted output: what the user receives, minus 1 basis point for every minute of estimated delivery time beyond the first (capped at 50 bps). What a route pays LayerHop only settles near-identical quotes: within 0.1% of the best, the one that supports LayerHop goes first (see What happens when two quotes are nearly equal?).

How is the best route chosen?#

Quotes are ranked best for the user first. LayerHop compares dstAmount, which is already net of provider fees and LayerHop's own fee, and adjusts it for waiting time. The code is rankQuotes in packages/shared/src/rank.ts.

What is time-adjusted output?#

Raw output alone would let a route that is 0.08% better but takes 18 minutes beat one that lands in seconds. So LayerHop compares an effective output:

  • Every quote has estimatedSeconds.
  • The first minute is free. Each started minute beyond it costs 1 bp of output.
  • The penalty is capped at 50 bps.
Text
slowMinutes   = max(0, ceil((estimatedSeconds - 60) / 60))
penaltyBps    = min(50, slowMinutes × 1)
effectiveOut  = dstAmount × (10000 − penaltyBps) / 10000

Quotes are sorted by effectiveOut, highest first; ties go to the faster route.

Route dstAmount ETA Penalty Effective output
A 1 000 000 5 s 0 bps 1 000 000
B 1 000 800 18 min 17 bps 999 098

Route A wins: B's extra 0.08% does not pay for 18 minutes of waiting.

Note

The penalty only affects ordering. The dstAmount and dstAmountMin you receive are the provider's real numbers.

What happens when two quotes are nearly equal?#

Quotes whose time-adjusted output is within 0.1% (10 bps) of the best one count as a tie. A tie goes to the quote that earns LayerHop more (its fee, or the spread of a LayerHop-run source), or to a LayerHop-run source that pays at least as much as the best partner quote. Otherwise the best quote stays first.

  • A quote more than 0.1% below the best is never moved ahead of it.
  • Only the first quote can change; the rest keep their payout order.
  • On a 1,000 USDC swap the most a tie can cost is 1 USDC; most ties are far closer.
  • Every quote is still in quotes, so your UI can show the highest output or let the user pick.

How are exact-output quotes ranked?#

With dstAmount (receive an exact amount) every quote delivers the same output, so the lowest srcAmount (what the sender pays) ranks first, after a waiting penalty of 0.1% of srcAmount per minute beyond the first, capped at 1.5% (stronger than the swap penalty, because exact-amount payers are usually waiting on a checkout page). Only providers that quote a fixed output are asked.

What does the ranking not do?#

  • It does not hide quotes. Every success is in quotes, so your UI can offer alternatives.
  • It does not prefer providers that carry LayerHop's fee outside a tie. A quote that carries less or none reports a lower fees.ourFeeBps and is ranked on output like any other; the fee only settles quotes within 0.1% of each other.
  • It does not price gas paid separately in the native coin beyond what providers fold into dstAmount. Where providers report them, fees.gasUsd and fees.providerFeeUsd let you show those costs.

Which providers are asked?#

Only providers whose supports() accepts the route are queried. Chain coverage per provider comes from each provider's own chain list, refreshed every hour (the providers field of GET /v1/chains).

Route Providers asked
Solana → Solana Jupiter, LI.FI
EVM → same EVM chain 0x, KyberSwap, Relay, LI.FI
EVM → other EVM chain Relay, deBridge, LI.FI
EVM → Solana Relay, deBridge, LI.FI
Solana → EVM deBridge, LI.FI

Mayan (cross-chain, Solana ↔ EVM and EVM ↔ EVM) is built but not enabled in production; it is available on request. Details, limits and fee mechanics per provider: Providers.

Last updated