Uniswap

Uniswap routing prepares a Universal Router swap you can review in your wallet before signing

Last updated -

For a Universal Router swap, Uniswap routing selects a direct, multi-hop, or split path through available pools, then encodes the chosen swap for the router to execute. For a first swap, confirm the network and token contracts, inspect the quoted limits, and stop at the wallet prompt until the recipient, amount, and call match the intended trade.

What must be ready before requesting the route?

Before routing begins, select the network in your wallet and confirm the input token contract, output token contract, amount, and recipient. Token symbols aren't unique identifiers, so the contract addresses and chain matter more than the names displayed by an interface. The wallet also needs enough of the network's native currency to pay for approval and swap transactions.

Next, confirm a Universal Router deployment and the required pool protocols are available on the selected network. Native currency and ERC-20 inputs follow different funding paths: a native input can travel as transaction value or be wrapped when the plan requires it, while an ERC-20 input may need spending authorization. The route is ready for review when the route builder returns a quote and compatible call data without a simulation or token-support error.

The quote fixes the proposed path and limits

A quote is a snapshot of the route under a particular pool state. It identifies the input, output, path, expected result, estimated network cost, and transaction constraints. A direct pool may be shortest, while a multi-hop or split route may produce a better effective result when deeper liquidity offsets its added fees and execution cost.

For an exact-input swap, the swap instruction fixes the input amount and sets a minimum acceptable output that the execution must satisfy. An exact-output route reverses that relationship by fixing the desired output and capping the input. A deadline can stop stale call data from executing later, but it doesn't reserve the quoted price. Pool state can change between quote creation and block inclusion.


Universal Router turns the route into ordered commands

Path discovery happens before execution. Universal Router receives an encoded plan rather than searching pools during the transaction. The Universal Router executes a byte sequence of commands, with each command matched by position to its ABI-encoded input. Those commands can cover token transfers, Permit2 authorization, wrapping, swaps through supported protocol versions, unwrapping, and returning residual funds.

Order matters because one command can prepare the balance consumed by the next. The swap input must also identify whether funds come from the caller or already sit in the router, while the recipient determines where the output goes. An incompatible command, router deployment, or encoded path can make the entire call revert before any intended swap result survives.

Some command bytes may carry an allow-revert flag. That feature supports plans where a failed branch can be skipped, but it also creates a cleanup requirement. Any plan using it must account for funds left inside the router. A simple first swap usually benefits from requiring its central swap command to succeed or reverting the transaction.


Approval state determines the first onchain action

An ERC-20 route can't spend tokens without the required authorization. In a Permit2 flow, the token may first need an onchain allowance for Permit2. A signed Permit2 message can then authorize the router as spender within the message's token, amount, expiration, nonce, and chain context. If the ERC-20 allowance to Permit2 already exists, the route may not need a separate approval transaction, but you should still inspect the new router authorization.

The approval and swap remain different actions even when the interface presents them together. An approval receipt proves an allowance changed; it doesn't prove a swap occurred. Likewise, signing permit data doesn't execute Universal Router by itself. Universal Router still needs an execution transaction containing the relevant permit and swap commands. Native currency inputs don't use an ERC-20 allowance, although the route may still include wrapping.

The wallet prompt lets you stop before submitting the swap

A prepared quote can be discarded before signing without changing pool balances. At the wallet prompt, compare the selected chain, router address, transaction value, recipient, input limit, output protection, and deadline with the quote. If the wallet decodes the call, its displayed actions should follow the same order as the proposed route.

Simulation adds a useful compatibility check, but it isn't an execution guarantee. Another transaction can alter the relevant pools before inclusion, and the network fee can move independently of the quoted token result. Rejecting the prompt leaves the swap unsubmitted. Any earlier token approval may remain active, however, because it was a separate state change.


A hypothetical route check from quote to receipt

Every amount, gas estimate, path, pool state, and result in this example is hypothetical. A reader requests an exact-input quote for 1,258 smallest units of an unnamed ERC-20 input token. Both candidates use the same network, output token, recipient, and compatible Universal Router deployment.

Option A uses one pool. It expects 612 output units, protects a minimum of 604, and estimates 119,400 gas units. Option B uses two pools through an intermediate token. It expects 625 output units, protects a minimum of 616, and estimates 158,600 gas units. The routing model ranks Option B higher after applying its network-cost model.

The reader selects Option B only after the wallet call matches its two-hop path, recipient, input, minimum output, and deadline. The transaction receipt later reports successful execution, and the recipient's balance rises by 621 output units. That balance change exceeds the encoded minimum, so the quote, call, receipt, and delivered tokens reconcile.

A hypothetical route check from quote to receipt: The reader selects Option B only after the wallet call matches its two-hop path, recipient, input, minimum output, and deadline.; The transaction receipt later reports successful execution, and the recipient's balance rises by 621 output units.; That balance change exceeds the encoded minimum, so the quote, call, receipt, and delivered tokens reconcile.

Open full-size image

If Option B fails simulation because its command set isn't supported by the selected deployment, its higher quote isn't actionable. The fallback is to request a fresh route restricted to compatible commands, then reassess Option A under the new pool state. Reusing the incompatible call would leave the original failure unchanged.


Direct, multi-hop, and split paths change execution

A direct path crosses one pool. It usually needs less calldata and applies one pool's fee, although limited depth can worsen the output. A multi-hop path crosses intermediate pools and applies each hop's fee. The intermediate token is part of execution, not an extra asset the recipient should receive.

A split route allocates portions of one input across separate paths, then combines the output for the designated recipient. This can use liquidity more efficiently, but it also adds commands and execution work. Smart order routing considers estimated gas costs when comparing candidate paths. More hops or branches therefore don't automatically indicate a better route.

Pool balances, active liquidity, fee settings, and network-cost estimates can all change the winning path. Refreshing an otherwise identical quote may produce a different route without changing the requested tokens. The relevant comparison is the protected and expected result under the new quote, not whether its path looks simpler.


What confirms the first swap actually completed?

A successful onchain receipt on the selected network is the first confirmation that the Universal Router call didn't revert. A transaction hash alone doesn't prove inclusion or successful execution. Match the receipt's sender and router target to the signed call, then inspect the executed token transfers and the recipient's final output-token balance.

For an ERC-20 output, transfer logs can show the token contract, sender, recipient, and amount moved during execution. The recipient's balance provides a second practical check, provided the wallet is reading the same network and token contract. A hidden token in a wallet interface doesn't by itself mean routing failed.

The delivered amount should satisfy the encoded minimum for exact input, or the amount spent should remain within the maximum for exact output. Network finality develops according to the selected chain's rules, so a newly included receipt and a deeply confirmed receipt aren't identical states.


Route failures point to different repairs

A missing quote indicates a routing problem before calldata exists. Common causes include an unsupported network, incorrect token address, unavailable liquidity, or route restrictions that exclude every viable path. Changing slippage can't create a missing pool or make an incompatible protocol available. Correct the input or compatibility issue before requesting another quote.

A build or simulation error means the proposed route couldn't become an executable call under the supplied state. Check the router deployment, command support, allowance, balance, recipient, and gas funding. If pool conditions or the deadline changed, request new call data. Editing encoded amounts without rebuilding the dependent limits can break the relationship the quote established.

A wallet rejection leaves the swap unsubmitted, while an onchain revert records a failed transaction and can still consume the network fee. A pending transaction is neither outcome. Submitting another swap before resolving the first transaction's nonce and status can replace it at the same nonce or queue a second swap at a later nonce; neither outcome repairs the original call.

Plans that allow a command to revert need an additional check for unused balances and cleanup commands. If the receipt succeeds but the intended output doesn't reach the recipient, inspect the executed command path and transfers before attempting another trade. The next action changes according to whether the failure happened during quoting, authorization, submission, or execution.

Uniswap routing: reader questions

Does a Permit2 signature execute the Universal Router swap?

No. A Permit2 signature authorizes a specified spender under the signed token, amount, expiration, nonce, and chain conditions. Universal Router still needs an execution transaction containing the relevant permit and swap commands. Treat the signature as spending authority, even though signing it alone doesn't move tokens or create a swap receipt.

Could refreshing a quote replace a direct route with a multi-hop path?

Yes. Routing compares candidate paths against the latest pool state and estimated network cost. A change in liquidity, price, fees, or gas estimates can alter which path ranks highest. The refreshed route should be reviewed as a new proposal because its pools, intermediate token, limits, and encoded commands may differ.

Is the FASTEST routing preference the path with the fewest hops?

No. In the Uniswap API, FASTEST concerns how quickly the service returns a quote, not the number of pools, commands, or transactions in the proposed route. A fast response can still contain a multi-hop path. Use the returned route details and execution limits to understand what the wallet will authorize.

Can an exact-output route spend less than its maximum input?

Yes. The maximum input is a ceiling, and execution can consume less when the requested output is available within that limit. If a plan prefunds Universal Router or wraps native currency, its encoded cleanup actions must return any remainder. The caller shouldn't assume unused value is refunded outside the command plan.

Are token symbols enough to verify the assets in a route?

No. Different contracts can use the same symbol, and the same asset can have different representations across networks. Review the chain, input contract, output contract, token decimals, and recipient. Those identifiers must match the quote and wallet call before the displayed amount can be interpreted correctly.