LayerHopdocs

Concepts

Providers & ranking

How LayerHop orders quotes — by time-adjusted output for the user, never by what a route pays LayerHop.

Open in ClaudeOpen in ChatGPT

The rule#

Quotes are ranked best for the user first. LayerHop compares what the user receives — dstAmount, which is already net of the provider's fees and LayerHop's own fee — and never looks at how much a route pays LayerHop. The ranking code lives in packages/shared/src/rank.ts.

ETA-adjusted output#

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

  • Every quote has estimatedSeconds.
  • The first minute is free. Each started minute beyond it costs 1 basis point 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 get back are the provider's real numbers.

What the ranking does not do#

  • It does not hide quotes. Everything that succeeded is in quotes, so your UI can offer the alternatives.
  • It does not prefer providers that share fees with LayerHop. If a provider cannot carry LayerHop's fee (for example Jupiter below 50 bps), that quote simply reports fees.ourFeeBps: 0 and is ranked on output like any other.
  • It does not take gas paid separately in the native coin into account beyond what providers fold into dstAmount. Where providers report it, fees.gasUsd and fees.providerFeeUsd let you show it.

Which providers are asked#

Only providers whose supports() accepts the route are queried. The current matrix:

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

Details, limits and fee mechanics per provider: Providers.