// SPDX-License-Identifier: GPL-2.0-or-later pragma solidity >=0.7.5; pragma abicoder v2; /// @title QuoterV2 Interface /// @notice Supports quoting the calculated amounts from exact input or exact output swaps. /// @notice For each pool also tells you the number of initialized ticks crossed and the sqrt price of the pool after the swap. /// @dev These functions are not marked view because they rely on calling non-view functions and reverting /// to compute the result. They are also not gas efficient and should not be called on-chain. /// Credit to Uniswap Labs under GPL-2.0-or-later license: /// https://github.com/Uniswap/v3-periphery interface IQuoterV2 { /// @notice Returns the amount out received for a given exact input swap without executing the swap /// @param path The path of the swap, i.e. each token pair /// @param pluginsData The swap plugin data /// @param amountInRequired The desired amount of the first token to swap /// @return amountOutList The amount of the last token that would be received /// @return amountInList The amount of the last token that should be paid /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path /// @return gasEstimate The estimate of the gas that the swap consumes /// @return feeList List of the fee values used for swaps in the path function quoteExactInput( bytes memory path, bytes[] memory pluginsData, uint256 amountInRequired ) external returns ( uint256[] memory amountOutList, uint256[] memory amountInList, uint160[] memory sqrtPriceX96AfterList, uint32[] memory initializedTicksCrossedList, uint256 gasEstimate, uint16[] memory feeList ); struct QuoteExactInputSingleParams { bytes pluginData; address tokenIn; address tokenOut; address deployer; uint256 amountIn; uint160 limitSqrtPrice; } /// @notice Returns the amount out received for a given exact input but for a swap of a single pool /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams` /// tokenIn The token being swapped in /// tokenOut The token being swapped out /// amountIn The desired input amount /// limitSqrtPrice The price limit of the pool that cannot be exceeded by the swap /// @return amountOut The amount of `tokenOut` that would be received /// @return amountIn The amount of the `tokenIn` that should be paid /// @return sqrtPriceX96After The sqrt price of the pool after the swap /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed /// @return gasEstimate The estimate of the gas that the swap consumes /// @return fee The fee value used for swap in the pool function quoteExactInputSingle( QuoteExactInputSingleParams memory params ) external returns ( uint256 amountOut, uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate, uint16 fee ); /// @notice Returns the amount in required for a given exact output swap without executing the swap /// @param path The path of the swap, i.e. each token pair. Path must be provided in reverse order /// @param pluginsData The swap plugin data /// @param amountOutRequired The amount of the last token to receive /// @return amountOutList The amount of the last token that would be received /// @return amountInList The amount of first token required to be paid /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path /// @return gasEstimate The estimate of the gas that the swap consumes /// @return feeList List of the fee values used for swaps in the path function quoteExactOutput( bytes memory path, bytes[] memory pluginsData, uint256 amountOutRequired ) external returns ( uint256[] memory amountOutList, uint256[] memory amountInList, uint160[] memory sqrtPriceX96AfterList, uint32[] memory initializedTicksCrossedList, uint256 gasEstimate, uint16[] memory feeList ); struct QuoteExactOutputSingleParams { bytes pluginData; address tokenIn; address tokenOut; address deployer; uint256 amount; uint160 limitSqrtPrice; } /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool /// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams` /// tokenIn The token being swapped in /// tokenOut The token being swapped out /// amountOut The desired output amount /// limitSqrtPrice The price limit of the pool that cannot be exceeded by the swap /// @return amountOut The amount of the last token that would be received /// @return amountIn The amount required as the input for the swap in order to receive `amountOut` /// @return sqrtPriceX96After The sqrt price of the pool after the swap /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed /// @return gasEstimate The estimate of the gas that the swap consumes /// @return fee The fee value used for swap in the pool function quoteExactOutputSingle( QuoteExactOutputSingleParams memory params ) external returns ( uint256 amountOut, uint256 amountIn, uint160 sqrtPriceX96After, uint32 initializedTicksCrossed, uint256 gasEstimate, uint16 fee ); }