Skip to main content
UniswapV3Adapter implements ISwapRouter on top of Uniswap V3 SwapRouter02. Its quote reads a pool TWAP (or spot when the pool lacks history) and is the slippage reference for Zap, PositionRouter, FeeCollector, and CreatorFeeRouter. It is never a collateral price. An owner sets the default fee tier, a per-pair fee, and the TWAP window, with two-step ownership transfer. UniswapV3Adapter lets you:
  • Quote a multi-hop swap against pool TWAPs
  • Execute an exact-input multi-hop swap
  • Read the fee tier used for any pair
  • Let the owner tune fee tiers and the TWAP window
This contract is not deployed on a listed network yet. Watch Addresses. The source code is src/periphery/UniswapV3Adapter.sol on GitHub. The ABI is /abis/UniswapV3Adapter.json.

Write methods

setOwner

Proposes a new owner. The new owner must call acceptOwner. Owner only. Reverts with ZeroAddress for the zero address.
Owner only.
Input parameters

acceptOwner

Completes the ownership transfer. Only the pending owner can call it (NotOwner otherwise).

setDefaultFee

Sets the fee tier used when a pair has no specific fee. Owner only. Reverts with InvalidFee for 0.
Owner only.
Input parameters

setTwapWindow

Sets the TWAP lookback used by quote. A window of 0 makes quote use spot. Owner only.
Owner only. A 0 window makes quotes easy to manipulate within a block.
Input parameters

setPairFee

Sets the fee tier for one pair. Owner only. Reverts with InvalidPath for zero or identical tokens and InvalidFee for 0.
Owner only.
Input parameters

swapExactTokensForTokens

Pulls amountIn of the first path token from the caller and swaps it through SwapRouter02 to to. Reverts with the same path errors as quote, ZeroAddress for a zero recipient, and ZeroAmount if the output is 0. SwapRouter02 reverts if the output is below amountOutMin.
The caller must approve the adapter for amountIn of the input token.
Input parameters Return values

Read methods

quote

Returns the expected output of swapping amountIn along path using each hop’s TWAP over twapWindow, or spot if the window is 0 or the pool cannot observe that far back. Reverts with InvalidPath for fewer than two hops or repeated tokens, ZeroAddress for a zero hop, ZeroAmount for a zero input or output, and NoPool if a hop has no pool at the configured fee. Input parameters Return values

feeOf

Returns the fee tier for a pair: the configured pair fee if set, else defaultFee. Order of the two tokens does not matter. Input parameters Return values

Events

OwnerPending

Fires when a new owner is proposed.

OwnerSet

Fires when the pending owner accepts.

DefaultFeeSet

Fires when the default fee tier changes.

TwapWindowSet

Fires when the TWAP window changes.

PairFeeSet

Fires when a pair fee is set.

Errors

ZeroAddress

A constructor address, path hop, or recipient was zero.

NotOwner

The caller is not the owner (or not the pending owner for acceptOwner).

ZeroAmount

The input or output amount was zero.

InvalidPath

The path has fewer than two hops, repeats a token, or a pair uses zero or identical tokens.

InvalidFee

A fee tier was 0.

NoPool

No Uniswap V3 pool exists for the pair at the configured fee.