LayerHopDocsLaunch app (opens in a new tab)

Meta-aggregation

How one LayerHop quote request fans out to every eligible provider in parallel, survives partial failure, and returns an executable quote per route.

Meta-aggregation means LayerHop asks several routing engines (Jupiter, Relay, deBridge, 0x, KyberSwap, LI.FI) for the same trade at once and returns all their answers, ranked. LayerHop is an aggregator of aggregators: it owns no liquidity and adds no extra hop to the transaction.

What happens when I call GET /v1/quote?#

  1. Resolve the chains (id or slug, from the live registry of 71 chains) and tokens (a built-in symbol, the chain's native symbol, the symbol of a popular token on that chain in GET /v1/tokens, or a raw address / mint).
  2. Filter providers with supports(request). Jupiter only handles Solana → Solana; 0x and KyberSwap only same-chain EVM swaps; deBridge only cross-chain. See Which providers are asked?.
  3. Ask every eligible provider in parallel, each with its own timeout (8 seconds by default).
  4. Keep the successes and rank them best for the user first (see Providers & ranking).
  5. Store each quote under its own quoteId and return them.
JSON
{
  "best":   { "quoteId": "q_…", "provider": "relay", "dstAmount": "612345678", "...": "..." },
  "quotes": [ { "provider": "relay", "...": "..." }, { "provider": "debridge", "...": "..." } ],
  "errors": [ { "provider": "lifi", "code": "PROVIDER_TIMEOUT", "message": "Timed out: li.quest" } ]
}

What if a provider fails?#

A provider that errors or times out does not fail the request. It appears in errors with a stable error code. The API answers 404 NO_ROUTE only when no provider returns a quote.

You can therefore show a price while one provider is degraded, and explain why a provider is missing (for example UNSUPPORTED_TOKEN from one provider while another routes the token).

Can the user pick a quote other than the best one?#

Yes. quotes is not just a price comparison: every entry has its own quoteId. Let the user choose a cheaper or faster route and build that one with POST /v1/orders.

What interface does each provider implement?#

Every provider is an adapter implementing the same RouteProvider interface (packages/shared/src/types.ts):

Method Purpose
supports(req) Can this provider serve the chain/token pair at all?
quote(req, ctx) Price the trade, including LayerHop's fee (and a partner fee, if any).
buildTx(quote, ctx) Return the transaction to sign, or the one already returned with the quote.
status(id, ctx) Report pending / filled / refunded / failed / unknown.
submit?(quote, signedTx, ctx) Only for submitViaApi transactions.

New liquidity sources plug in as another adapter. Nothing changes for API clients.

How long is a quoteId valid?#

Until the quote's expiresAt (30 to 60 seconds, set per provider). The API keeps each quote (in memory and in its database, so a quote survives an API restart or deploy) and drops it a few minutes after it expires. Build the order promptly, and treat QUOTE_NOT_FOUND and QUOTE_EXPIRED as "get a fresh quote".

Last updated