Skip to main content

UniswapV3Positions

Git Source

Title: UniswapV3Positions

Author: 0xJem

Helper functions for Uniswap V3 positions

Functions

getPositionAmounts

Gets the amount of token0 and token1 that would be received if the position was closed

function getPositionAmounts(IUniswapV3Pool pool_, int24 tickLower_, int24 tickUpper_, address owner_)
public
view
returns (uint256, uint256);

Parameters

NameTypeDescription
pool_IUniswapV3PoolThe address of the Uniswap V3 pool
tickLower_int24The lower tick of the position
tickUpper_int24The upper tick of the position
owner_addressThe owner of the position

Returns

NameTypeDescription
<none>uint256uint256 The amount of token0
<none>uint256uint256 The amount of token1

getPositionTokensOwed

Gets the tokens owed (collected but unwithdrawn) for the position

function getPositionTokensOwed(IUniswapV3Pool pool_, int24 tickLower_, int24 tickUpper_, address owner_)
public
view
returns (uint128, uint128);

Parameters

NameTypeDescription
pool_IUniswapV3PoolThe address of the Uniswap V3 pool
tickLower_int24The lower tick of the position
tickUpper_int24The upper tick of the position
owner_addressThe owner of the position

Returns

NameTypeDescription
<none>uint128uint128 The amount of token0 tokens owed
<none>uint128uint128 The amount of token1 tokens owed

getPositionLiquidity

Gets the amount of liquidity in the position

function getPositionLiquidity(IUniswapV3Pool pool_, int24 tickLower_, int24 tickUpper_, address owner_)
public
view
returns (uint128);

Parameters

NameTypeDescription
pool_IUniswapV3PoolThe address of the Uniswap V3 pool
tickLower_int24The lower tick of the position
tickUpper_int24The upper tick of the position
owner_addressThe owner of the position

Returns

NameTypeDescription
<none>uint128uint128 The amount of liquidity

positionHasLiquidity

Checks if the position has liquidity

function positionHasLiquidity(IUniswapV3Pool pool_, int24 tickLower_, int24 tickUpper_, address owner_)
public
view
returns (bool);

Parameters

NameTypeDescription
pool_IUniswapV3PoolThe address of the Uniswap V3 pool
tickLower_int24The lower tick of the position
tickUpper_int24The upper tick of the position
owner_addressThe owner of the position

Returns

NameTypeDescription
<none>boolbool True if the position has liquidity