Routing & execution

Why reversing a swap can select a different route

Explain why reversing a token pair is a fresh routing problem and why finite-size buy and sell routes need not mirror each other.

A B-to-A trade does not have to retrace the route chosen for A-to-B. Reversing the direction changes which inventory is supplied, which inventory is requested and how the proposed size moves each source's state.

The amount is not automatically comparable

If you ask to sell 100 A, the quoted B receipt is an output estimate. Asking to sell 100 B is a different economic size unless the assets happen to have matching value under the relevant terms. Comparing their route diagrams directly can therefore be misleading.

Even when you use the first trade's B output as the reverse input, the market may already have changed. The forward trade itself can be one reason.

Uniswap's pricing reference calculates amounts from the input and output reserve roles. Signed maker orders similarly express a particular offered direction rather than an unconditional reciprocal offer.

Availability can be directional

A dealer willing to sell B for A is not necessarily offering to sell A for B at inverse terms. In pools, asymmetric balances and concentrated ranges can make the finite-size execution conditions differ in the two directions.

A hypothetical A-to-C-to-B route may therefore beat the direct pool for one request, while B-to-A directly wins for the reverse request. There is no requirement that route selection be symmetric.

What is reciprocal?

The reciprocal of an average rate is a valid alternative way to express that same completed exchange. If 10 A purchased 20 B, its average can be written as 2 B per A or 0.5 A per B. Those statements describe one trade, not a promise to execute the reverse trade.

For a reverse comparison, submit the actual desired input or output amount and obtain a new route. That respects the current state, directional offers and mode-specific constraints instead of treating a historical route as a two-way contract.

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. Orders — 0x Protocol 4.1 documentation

    Version-specific order fields: token identity, amounts, maker/taker, expiry and RFQ.

    https://docs.0xprotocol.org/en/latest/basics/orders.html
  3. Uniswap Smart Order Router

    Routing searches consider split paths and gas costs.

    https://github.com/Uniswap/smart-order-router

Continue reading

Why swapping back does not restore the original amount Reading a DEX trading pair without reversing the price Pool spot price vs the price of an actual swap