Routing & execution

What does best mean to a swap router?

Distinguish maximum raw output, minimum input and cost-adjusted objectives when a router labels a path best.

A router's objective defines what it tries to improve. “Best” is incomplete unless the objective and constraints are known. Maximizing raw output, minimizing input and maximizing estimated net value are related but different problems.

Start with trade mode

For a fixed-input request, a raw-output objective selects the largest receipt. For a fixed-output request, a raw-input objective selects the smallest spend. A cost-adjusted objective also accounts for execution expenses under stated assumptions.

Uniswap's smart-order-router description explicitly includes gas costs. CFMM routing research expresses the broader problem through a user utility function and valid market trades.

An invented comparison

Assume Route One produces slightly more B but requires additional contract operations. Route Two produces slightly less B with less execution work. A raw-output optimizer can choose One while a net-value optimizer chooses Two, without either misapplying its own objective.

To turn costs paid in another asset into B terms, the model needs a valuation assumption. That assumption is part of the objective and can change the ranking when refreshed.

Constraints are not objectives

A minimum receipt is a boundary the route must satisfy. A maximum hop count limits the search space. A source exclusion removes alternatives. These conditions affect the winning route even if the objective itself stays unchanged.

Execution probability can also influence product choices, but do not assume a router optimizes a quantified success probability unless its documentation actually says so. A robust-sounding label is not evidence of a particular statistical model.

What a transparent result should reveal

The useful description names the trade mode, selected path, expected amounts, included costs and relevant restrictions. If two services disagree, first check whether they solve the same problem.

A route can be strongest under one valuation or source set and weaker under another. Evaluating the optimizer requires matching those assumptions, rather than treating every displayed “best” badge as a universal market claim.

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 Smart Order Router

    Routing searches consider split paths and gas costs.

    https://github.com/Uniswap/smart-order-router
  2. An Efficient Algorithm for Optimal Routing Through Constant Function Market Makers

    Network routing, utility objectives and optimization under CFMM constraints.

    https://arxiv.org/html/2302.04938v1
  3. Uniswap smart-order-router: alpha-router.ts

    Candidate-pool selection and configurable hop and split limits.

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

Continue reading

Why a router does not inspect every possible path Why split routes cannot treat a shared pool as independent How quote sampling estimates an AMM's output curve