Skip to content
Finality

Crypto protocol and market news

Fermi swap: How the router chooses a trading route

Fermi swap routing can select one venue, pin execution to a chosen venue or split an order; each mode changes how quotes, fallback and output limits work.

The Finality Desk5 min read#d8abef

Fermi swap: How the router chooses a trading route

Fermi swap routing can select the best quoted venue, target a venue you specify, or split an order across venues. These are distinct execution paths in the PropAMMRouter, where FermiSwap is one of several proprietary automated market makers (AMMs) and Uniswap V3 provides a fallback. The mode determines how venues compete for the order and what happens if a selected venue cannot fill it.

That distinction matters because a quote describes an amount and pair at a point in time; it does not guarantee that a venue will complete the trade. The fermi swap route is therefore best understood alongside the router call that selects it and the minimum output the transaction enforces. For the same tokens and amount, one path can choose by quote, another can prioritize a named venue, and a third can distribute input across available capacity.

How does the best-quote Fermi swap route work?

The swapV1 function compares quotes from available proprietary AMMs and uses the venue with the best quoted output. It pulls the exact input amount from the caller, then attempts execution through that venue. If the chosen venue reverts or delivers too little, the router can execute the swap through Uniswap V3 instead.

The minimum output, amountOutMin, influences that decision as well as setting a floor for the completed trade. If the best proprietary quote is below the floor, the router routes to Uniswap V3. After execution, it checks the recipient’s measured balance increase against the minimum; if output falls short, the transaction reverts. This protects against receiving less than the caller’s threshold, though it does not promise a fill at the quoted rate.

This default path fits a trader who wants the router to compare eligible venues for the full order. Its result depends on which venues are whitelisted and can be priced. A venue that fails to quote may be skipped, so “best” means best among the quotes the router can use for that call, not every possible source of liquidity.

When should you pin a trade to one venue?

The swapViaVenueV1 function tries the venue named by the caller first. This suits a trade where execution policy favors a particular venue, even if another venue might quote more. When that named venue is a proprietary AMM such as FermiSwap, the Uniswap V3 fallback still applies if the AMM fails to fill.

There is a separate direct path: naming the router’s Uniswap V3 SwapRouter02 address sends the trade there, with no further fallback. The requested venue must be whitelisted or be that fallback address; otherwise the call reverts with UnknownVenue. Pinning thus expresses a routing preference, while amountOutMin continues to define the minimum acceptable output.

Use this mode when the venue itself matters to the caller or application. It does not make the venue’s quote more reliable, nor does it guarantee that the named proprietary AMM has capacity. If it cannot execute, the fallback can change where the trade completes, so inspect the transaction’s returned venue when the execution source matters.

What changes when a Fermi swap is split across venues?

The swapSplitV1 function plans a split of one exact-input order across proprietary AMMs, then executes that plan on-chain in the same transaction. It probes whitelisted venues for capacity, ranks the available portions against a Uniswap V3 reference quote, and sends any unallocated input to Uniswap V3 as one remainder leg.

This can suit a larger order when no single proprietary venue can take the full amount at its quoted terms. The router can use up to five proprietary-AMM legs, plus the Uniswap V3 remainder. It chooses the split on-chain; the caller does not supply a route or rely on an off-chain solver. In return, a split has more execution legs and more moving parts than a single-venue call.

  • Best-quote route: choose swapV1 when the router should select one venue for the full order and retain the fallback.
  • Named-venue route: choose swapViaVenueV1 when a particular venue should get first attempt or when the trade should go directly to Uniswap V3.
  • Split route: choose swapSplitV1 when the order may benefit from capacity across several proprietary AMMs.

Splitting has a specific execution risk: if one proprietary leg fails, its input joins the Uniswap remainder. The total received still has to meet amountOutMin, but the remainder does not get a separate output floor. If earlier legs already satisfy the aggregate minimum, that fallback portion may have no additional minimum-output protection. Set a tight aggregate floor that reflects the trade’s tolerance; a loose floor leaves more room for adverse execution, including sandwiching.

For most trades, the best-quote route is the straightforward starting point: one venue competes for the full order, and the fallback can handle a failed or under-delivering venue. Pin execution when venue choice is a deliberate requirement. Use splitting when comparing capacity across proprietary venues is useful, while accounting for its aggregate output floor and additional execution legs.