DEX essentials

Router contract vs DEX aggregator: two different jobs

Understand route search, transaction construction and onchain execution without confusing a router contract with an aggregation service.

A router contract executes a sequence of permitted operations. An aggregator decides which sequence to propose. A router can support sophisticated swaps without personally searching the market for the best one.

Follow the work through five layers

  1. Interface: collects the intended assets, amount and destination.
  2. Quote service: obtains usable market state or offers.
  3. Optimizer: compares feasible paths and allocations.
  4. Transaction builder: encodes the chosen operations and bounds.
  5. Execution contracts: perform transfers and check conditions onchain.

One organization can supply several layers, or an application can combine components from different providers. The distinction remains useful even when the user sees a single swap button.

Uniswap's smart-order-router repository contains route-search logic. Its multi-hop contract guide separately describes executing a specified path. This gives a concrete example of selection and execution being distinct functions.

Why the distinction matters

Suppose a router can execute A-to-C-to-B. That capability says nothing about whether C is the best intermediate asset today. The quote service might select C, another service might select D, and both can submit valid calls to the same router.

Likewise, a perfectly enforced minimum output cannot prove that the selected route was the best available. The execution contract checks the conditions encoded in the call; it does not necessarily compare every competing pool. Route quality and correct contract execution require different evidence.

When documentation says an application uses a particular router, read that as an execution detail. To understand aggregation, also identify its quote source, search coverage and optimization objective. Conversely, a named aggregation service may change its settlement architecture without changing the visible interface. A product name is therefore too coarse a unit for understanding the full trade.

For readers inspecting a transaction, the destination contract belongs primarily to the execution layer. It may not identify the company that produced the quote or the website that presented it.

Sources & verification (2)

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. Multi-hop Swapping

    Sequential token paths and reverse requirements for exact-output swaps.

    https://developers.uniswap.org/docs/protocols/v3/guides/swapping/multi-hop-swapping

Continue reading

Wallet swaps and aggregator websites: where execution comes from What liquidity aggregation means in practice Why the same token has liquidity in many places