How does routing work?

When you swap tokens on Uniswap, the app automatically searches for a favorable price for your trade. This is handled by Uniroute, an algorithm that works behind the scenes every time you swap.
 

What is routing?

Every swap on Uniswap moves your tokens through one or more liquidity pools. A route is the path your swap takes to get from token A to token B.

The simplest route is a direct swap, such as ETH → USDC through a single pool. But sometimes a better price is available by going through intermediate tokens, such as ETH → WBTC → USDC. The router evaluates these possibilities and picks a route based on how many output tokens you'd receive after accounting for fees and network costs.

When default trade options are turned on, the Auto Router uses two routing methods. The primary method is described first below. If the primary method finds no route or its selected route fails validation, the Auto Router uses the fallback method described second. Each method applies its parameters uniformly to every swap.

 

Primary routing method

The Auto Router selects the route estimated to deliver the largest amount of the output token after network costs.

The routing algorithm includes:

  • Pool eligibility rules that determine which pools and tokens the router may use
  • Intermediate tokens that allow multi-step routes through other tokens
  • Splitting that routes larger swaps in increments across multiple pools or paths
  • Network cost awareness that charges each candidate route its estimated gas cost
  • Simulation that validates the selected route before it is returned

Pool eligibility

Only pools created by the Uniswap Protocol contracts or the recognized external protocols listed in the published configuration are considered, with usable liquidity and trading activity within the past 60 days. Hooked pools are eligible according to the hook’s on-chain permissions, with custom-accounting and dynamic-fee hooks used only if on the allowed lists in the published configuration. Pools on the published blocked-pool list are never used.

Intermediate tokens

Routes may pass through the published common tokens, or through other connected tokens only where a trial quote shows an improvement over the most efficient candidate route already found. Tokens flagged as fee-on-transfer, spam, or blocked for compliance are never used as intermediate steps.

Splitting

Larger swaps are routed in increments and may be divided across multiple pools or paths where that produces a better result after network costs.

Network costs

Each candidate route is charged its estimated gas cost at the current gas rate before the winner is selected, which may deprioritize routes with higher network fees.

Simulation and your transaction settings

The selected route is then simulated to confirm it behaves as expected. Your slippage tolerance and swap deadline are encoded into the transaction, which will revert if execution would be worse than your tolerance or occur after your deadline.

Fallback routing method

Where the primary method returns no route, the Auto Router will select the most efficient trade route considering price, liquidity, and network costs.

The routing algorithm includes:

  • Split and multi-hop routes that execute swaps across multiple pools at once
  • Network cost awareness that ensures every added step is net positive for the trade
  • Simulation that validates the route and confirms it is effective

Split and multi-hop routes

Rather than sending your entire trade through one pool, Uniroute can split it across multiple paths simultaneously. This is useful when no single pool has enough liquidity to absorb a large trade without moving the price against you.

Searching more deeply

Uniroute examines a large set of pools and token paths. This matters especially on large trades, where routing through one or two pools can cause significant price impact. By exploring more of the available liquidity, the router can find execution paths that reduce that impact. The router doesn’t explore pools with fees greater than 11%. This protects swappers from unexpected price impact due to unusually high LP fees.

Network cost awareness

Adding more hops to a route increases the network cost. The router factors this in by only adding an extra step if the price improvement outweighs the additional cost you'd pay. For smaller trades, this often means taking a simpler, shorter route that costs less to execute.


Liquidity across versions

The router considers liquidity across Uniswap v2, v3, and v4. If one offers a more favorable effective price after accounting for network costs, the router will use it automatically. You don't need to think about which version to use — the router handles this for you.


Viewing your route

After entering a swap in the Uniswap app, you can hover over the route icon to see exactly how your trade will be executed, which pools it will pass through, and how the trade is split (if applicable).


Changing default trade options

If you would like to adjust your trade options, see our article here: How to change default trade options.