Skip to main content

V3 QuoterV2

The QuoterV2 contract allows getting the expected amount out or amount in for a given V3 swap without executing the swap. It simulates the swap logic on-chain to return accurate quotes.
These functions are not gas efficient and should not be called on-chain. Instead, use them via eth_call (static call) from off-chain code. For on-chain swap execution, use the V3 Router or Universal Router.

Key Functions

quoteExactInputSingle

Returns the expected output amount for a single-pool exact input swap.
function quoteExactInputSingle(
    QuoteExactInputSingleParams memory params
) public override returns (
    uint256 amountOut,
    uint160 sqrtPriceX96After,
    uint32 initializedTicksCrossed,
    uint256 gasEstimate
);
Parameters (struct QuoteExactInputSingleParams):
ParameterTypeDescription
tokenInaddressInput token address
tokenOutaddressOutput token address
amountInuint256The desired input amount
feeuint24Pool fee tier (100, 500, 3000, or 10000)
sqrtPriceLimitX96uint160Price limit (0 for no limit)
Returns:
ReturnTypeDescription
amountOutuint256The expected output amount
sqrtPriceX96Afteruint160The pool price after the swap
initializedTicksCrosseduint32Number of initialized ticks crossed
gasEstimateuint256Estimated gas cost of the swap

quoteExactInput

Returns the expected output amount for a multi-hop exact input swap.
function quoteExactInput(
    bytes memory path,
    uint256 amountIn
) public override returns (
    uint256 amountOut,
    uint160[] memory sqrtPriceX96AfterList,
    uint32[] memory initializedTicksCrossedList,
    uint256 gasEstimate
);
ParameterTypeDescription
pathbytesEncoded swap path (token addresses and fees)
amountInuint256The desired input amount
Returns:
ReturnTypeDescription
amountOutuint256The expected output amount
sqrtPriceX96AfterListuint160[]Pool prices after each hop
initializedTicksCrossedListuint32[]Ticks crossed per hop
gasEstimateuint256Total estimated gas cost

quoteExactOutputSingle

Returns the required input amount for a single-pool exact output swap.
function quoteExactOutputSingle(
    QuoteExactOutputSingleParams memory params
) public override returns (
    uint256 amountIn,
    uint160 sqrtPriceX96After,
    uint32 initializedTicksCrossed,
    uint256 gasEstimate
);
Parameters (struct QuoteExactOutputSingleParams):
ParameterTypeDescription
tokenInaddressInput token address
tokenOutaddressOutput token address
amountuint256The desired output amount
feeuint24Pool fee tier
sqrtPriceLimitX96uint160Price limit (0 for no limit)

quoteExactOutput

Returns the required input amount for a multi-hop exact output swap.
function quoteExactOutput(
    bytes memory path,
    uint256 amountOut
) public override returns (
    uint256 amountIn,
    uint160[] memory sqrtPriceX96AfterList,
    uint32[] memory initializedTicksCrossedList,
    uint256 gasEstimate
);
ParameterTypeDescription
pathbytesEncoded swap path (reversed for exact output)
amountOutuint256The desired output amount

Callback

uniswapV3SwapCallback

function uniswapV3SwapCallback(
    int256 amount0Delta,
    int256 amount1Delta,
    bytes data
) external view override;
Called by the pool during quote simulation. This is an internal mechanism — you do not need to call this directly.
ParameterTypeDescription
amount0Deltaint256Amount of token0 sent (negative) or received (positive) by the pool
amount1Deltaint256Amount of token1 sent (negative) or received (positive) by the pool
databytesCallback data passed through from the swap call

ABI

[
  "function quoteExactInputSingle((address tokenIn, address tokenOut, uint256 amountIn, uint24 fee, uint160 sqrtPriceLimitX96)) returns (uint256 amountOut, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)",
  "function quoteExactInput(bytes path, uint256 amountIn) returns (uint256 amountOut, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)",
  "function quoteExactOutputSingle((address tokenIn, address tokenOut, uint256 amount, uint24 fee, uint160 sqrtPriceLimitX96)) returns (uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate)",
  "function quoteExactOutput(bytes path, uint256 amountOut) returns (uint256 amountIn, uint160[] sqrtPriceX96AfterList, uint32[] initializedTicksCrossedList, uint256 gasEstimate)"
]

Example: Get a Quote

const QUOTER_ABI = [
  'function quoteExactInputSingle((address,address,uint256,uint24,uint160)) returns (uint256,uint160,uint32,uint256)',
];

const quoter = new ethers.Contract(QUOTER_V2_ADDRESS, QUOTER_ABI, provider);

// Quote: how much tokenOut for 1 tokenIn via the 0.3% pool?
const [amountOut, sqrtPriceAfter, ticksCrossed, gasEstimate] =
  await quoter.quoteExactInputSingle.staticCall({
    tokenIn: '0xTokenA',
    tokenOut: '0xTokenB',
    amountIn: ethers.parseEther('1'),
    fee: 3000,
    sqrtPriceLimitX96: 0,
  });

console.log(`Expected output: ${ethers.formatEther(amountOut)}`);
console.log(`Gas estimate: ${gasEstimate}`);
Always use staticCall (ethers v6) or callStatic (ethers v5) — these functions revert if called as regular transactions.