3. Search for routes

searchBridgeRoutes in @gibs/quotes/search does the whole search in one call. It loads the provider lists, the omnibridge pairs, prices, gas prices and balances. Then it runs the route engine and decides which routes it may serve. loadBridgeablePairs in the same subpath lists the pairs the omnibridge carries.

It takes:

  • origin and destination: the chain, the token, the amount, the sending account and the recipient;
  • clientForChain: your viem client for each chain, or null for a chain you have no endpoint for. The search skips what it cannot read;
  • fetch, an AbortSignal, and timeouts;
  • your keys and your attribution. See Fees and attribution;
  • delivery, either 'requested' or 'declined' (the default). Pass 'requested' when the user buys delivery on a crossing that leaves PulseChain;
  • deliveryFeeTermsFor, a function that returns the QuotedDeliveryFee for one omnibridge crossing, or null.

With delivery: 'requested' and fee terms, the search quotes a delivered crossing net of the delivery fee. Put the fee terms in your cache key, because they move with gas and price. With 'declined', the search offers no route that only a delivery can make.

Native landing. On a crossing that leaves PulseChain, only the delivery router unwraps. A crossing can then land on the native coin of the destination chain, for example ether, in one signature. The search offers that route only with delivery: 'requested'. The execution planner refuses an unwrap without bought delivery, with the refusal unwrap-needs-delivery. The section's plan decides the unwrap: it unwraps exactly when the hop lands on the native coin.

A cancelled search rejects with RouteSearchCancelledError.

PulseChain never reaches an aggregator. PulseChain is chain 369, and its testnet is chain 943. No request that names either chain goes to LI.FI, Relay or NEAR Intents. Three layers refuse it, the last one at the wire.

Your LI.FI key. Pass lifiApiKey. It travels only as the x-lifi-api-key header, on every LI.FI request the search makes: the chain list, the token lists, the prices and every quote. It never enters a URL, a body or a log, and no other provider receives it. The search refuses any request that would carry it in a URL or a body.

LI.FI advises against shipping a key in client code. If you keep the key on a server, point lifiApiOrigin at your own proxy, and let the proxy add the header. You can combine the two. Without either, LI.FI answers at its lower keyless rate limit.