Learn · Execution

How order routing finds the best price

When you request a swap on an aggregator, a lot happens in the moment before a quote appears. The router is searching across many liquidity sources, comparing direct and multi-hop paths, sometimes splitting your order, and accounting for fees and gas to find the route that leaves you with the most tokens. Understanding how that routing works demystifies the quote you see and explains why an aggregator usually beats trading on a single pool. This article walks through the routing process step by step.

The problem routing solves

Liquidity for any pair is scattered across many pools and protocols, each with different depth, fees, and prices at any moment. Trading on a single pool means accepting whatever that one venue offers, including its price impact. A router's job is to survey the whole landscape and assemble the path — or combination of paths — that delivers the best net result for your specific trade size, which a human comparing manually could never do in real time.

Direct, multi-hop, and split routes

The router considers several path shapes. A direct route trades your two tokens in one pool. A multi-hop route goes through intermediates — say, your token to a stablecoin to the target — when that yields more than any direct pool. A split route divides your order across several pools simultaneously to reduce the price impact of being a large participant in any one of them. The best route is often a combination, chosen for your exact size.

Net output, not headline price

A longer or split route is not automatically worse, and a shorter one is not automatically better. Each hop adds a pool fee and some price impact, and the whole transaction costs gas. The router optimizes for net output — the tokens you actually receive after every fee and impact along the path. That is why a three-hop split route can beat a simple direct swap, and why you should judge routes by the minimum received rather than the quoted rate on any single leg.

Why quotes expire

Routing is computed against the current state of every pool it considers, and that state changes constantly as others trade. The route that is optimal now may not be optimal in ten seconds, and the prices certainly shift. This is why quotes refresh and why your slippage tolerance exists — to bound the difference between the routed quote and the price at the moment your transaction confirms. Re-quoting before signing gives the router fresh data to work with.

Legal

Risk disclosure

XAUConnect is a non-custodial swap aggregator. Digital assets are volatile and may lose value rapidly. Content on this page is educational and not investment advice. Verify every contract address on the official block explorer before approving a transaction.

Frequently asked questions

Why does an aggregator beat a single pool?

It surveys many pools and protocols and assembles the best path — direct, multi-hop, or split — for your exact trade size, instead of accepting one venue's price and impact.

Is a multi-hop or split route worse?

Not necessarily. Extra hops add fees and impact but can still yield more net output. The router optimizes for tokens actually received, so judge by the minimum received.

What does the router actually optimize?

Net output after all pool fees, price impact, and gas — not the headline price of any single leg.

Why do quotes expire?

Routing reflects the current state of pools, which changes as others trade. Quotes refresh so the route and price stay accurate; re-quote before signing for fresh data.

Live execution

Trade on XAUConnect

Open the swap page to compare live routes, set slippage, and sign from your own wallet — fully non-custodial.

Continue exploring

Related markets, guides & networks

Curated next steps based on this topic — deepen your research before you trade.

Build programmatically

Swap via API for bots and AI agents — quotes, builds, and cross-chain routes.

Developer quickstart