Routing & execution

Why an aggregator splits a swap across pools

Work through why dividing one token swap across independent pools can improve output and when a split is unnecessary.

Split routing assigns portions of one trade to different execution paths. It can improve output when pushing the entire amount through one source produces weak incremental terms. The optimal division depends on size, liquidity curves and execution costs.

A simple independent-pool example

Assume two hypothetical fee-free constant-product pools each contain 1,000 A and 1,000 B. Selling 200 A entirely through one produces approximately 166.667 B, using 1000 × 200 / 1200.

Instead, send 100 A to each untouched pool. Each produces approximately 90.909 B, for a total of 181.818 B. The extra output arises because neither pool moves as far along its curve.

These are invented mathematical conditions, not live quotes. The example omits fees and execution charges to isolate the allocation mechanism. Uniswap's reserve-pricing explanation supplies the underlying constant-product model.

Equal splitting is not a general rule

The example uses identical pools. If one pool is deeper, begins at another price or applies a different fee, the best allocation may be unequal or may use only one source. A router evaluates what additional input yields at the point each branch would reach.

Activating an extra branch can also add execution work. A small gross-output improvement may disappear under a net objective. Uniswap's smart-order-router explicitly considers split routes and gas costs.

Parallel paths can contain several hops

A split could allocate one portion directly from A to B and another through A-to-C-to-B. The input percentages describe parallel allocation, while each branch's hop sequence describes serial conversion.

Independence is crucial. If two branches share a pool, adding separately calculated outputs can double-count its available state. The optimizer must account for the shared use or avoid combining those routes.

Finally, a route showing 100% through one source is not evidence that aggregation failed. The router may have searched many alternatives and found that splitting did not improve its objective for the current order.

Sources & verification (3)

Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.

  1. Uniswap v2 Pricing

    Reserve pricing, invariant enforcement and exact swap modes.

    https://developers.uniswap.org/docs/protocols/v2/concepts/pricing
  2. Uniswap Smart Order Router

    Routing searches consider split paths and gas costs.

    https://github.com/Uniswap/smart-order-router
  3. Uniswap smart-order-router: best-swap-route.ts

    Route allocation search, gas-adjusted objective and pool-overlap handling.

    https://github.com/Uniswap/smart-order-router/blob/main/src/routers/alpha-router/functions/best-swap-route.ts

Continue reading

Thinking about DEX liquidity as a routing graph Why the best route changes with trade size Why split routers compare marginal output