V3Estimator

This contract estimates v3 swap amounts

Code

Github Link: (Will be updated after official launch)

Address

Events, Read-Only Functions, and State-Changing Functions

Read-Only Functions

estimatePos

function estimatePos(
    struct IUniswapV3Pool pool, 
    address token, 
    uint256 amountIn
) external view returns (
    uint256 amountOut, 
    uint160 sqrtPriceX96After
)

Parameters:

NameTypeDescription

pool

contract IUniswapV3Pool

The address of the pool

token

address

The token being swapped in

amountIn

uint256

The desired input amount

Return Values:

NameTypeDescription

amountOut

uint256

The amount of the token that would be received

sqrtPriceX96After

uint160

The sqrt price after the swap

estimateNeg

function estimateNeg(
    contract IUniswapV3Pool pool, 
    address token, 
    uint256 amountOut
) external view returns (
    uint256 amountIn, 
    uint160 sqrtPriceX96After
)

Parameters:

NameTypeDescription

pool

contract IUniswapV3Pool

The address of the pool

token

address

The token being swapped out

amountOut

uint256

The desired output amount

Return Values:

NameTypeDescription

amountIn

uint256

The amount required as the input for the swap in order to receive amountOut

sqrtPriceX96After

uint160

The sqrt price after the swap

estimate

function estimate(
    contract IUniswapV3Pool pool,
    bool zeroForOne,
    int256 amountSpecified
) public view returns (int256 amount0, int256 amount1, uint160 sqrtPriceX96After) {

Parameters:

NameTypeDescription

pool

contract IUniswapV3Pool

The address of the pool

zeroForOne

bool

Is swap direction 0 -> 1?

amountSpecified

int256

The specified amount of token

Return Values:

NameTypeDescription

amount0

int256

The changed amount of token0

amount1

int256

The changed amount of token1

sqrtPriceX96After

uint160

The sqrt price after the swap

Last updated