NonfungiblePositionManager

NonfungiblePositionManager.sol

Wraps AMM positions in the ERC721 non-fungible token interface.

Table of Contents

Variables
Events
Public Write Functions
Owner Write Functions
Read Functions

Variables

lockedUntil

function lockedUntil(uint256 tokenId) external view returns (uint256)

Unix timestamps, in seconds, for each position describing when they can be unlocked (without paying an early withdrawal fee).

timelock

function timelock(uint256 tokenId) external view returns (uint256)

The full duration of the most recent timelock applied to a position.

timelockExcluded

function timelockExcluded(address addr) external view returns (bool)

Whether an address is excluded from having timelocks applied. Useful for some integrations.

Events

IncreaseLiquidity

event IncreaseLiquidity(
    uint256 indexed tokenId,
    uint128 liquidity,
    uint256 amount0,
    uint256 amount1
)

Emitted by mint() and increaseLiquidity().

ParametersTypeDescription

tokenId

uint256

ID of liquidity position being increased.

liquidity

uint128

Amount of liquidity added.

amount0

uint256

Amount of token0 deposited.

amount1

uint256

Amount of token1 deposited.

DecreaseLiquidity

event DecreaseLiquidity(
    uint256 indexed tokenId,
    uint128 liquidity,
    uint256 amount0,
    uint256 amount1
)

Emitted by decreaseLiquidity().

ParametersTypeDescription

tokenId

uint256

ID of liquidity position being decreased.

liquidity

uint128

Amount of liquidity removed.

amount0

uint256

Amount of token0 removed.

amount1

uint256

Amount of token1 removed.

Collect

event Collect(
    uint256 indexed tokenId,
    address recipient,
    uint256 amount0,
    uint256 amount1
)

Emitted by collect().

ParametersTypeDescription

tokenId

uint256

ID of liquidity position.

recipient

address

Address that collected tokens.

amount0

uint256

Amount of token0 sent.

amount1

uint256

Amount of token1 sent.

Write Functions

increaseLiquidity

function increaseLiquidity(
    IncreaseLiquidityParams calldata params
)
    external
    payable
    returns (uint128 liquidity, uint256 amount0, uint256 amount1)

Increases liquidity of a position.

ParametersTypeDescription

params

IncreaseLiquidityParams

See table below.

msg.value

uint256

Amount of ETH sent.

IncreaseLiquidityParamsTypeDescription

tokenId

uint256

ID of liquidity position.

amount0Desired

uint256

Desired token0 deposit amount.

amount1Desired

uint256

Desired token1 deposit amount.

amount0Min

uint256

Minimum required token0 deposit amount.

amount1Min

uint256

Minimum required token0 deposit amount.

Return valuesTypeDescription

liquidity

uint128

Amount of liquidity added.

amount0

uint256

Amount of token0 added.

amount1

uint256

Amount of token1 added.

decreaseLiquidity

function decreaseLiquidity(
    DecreaseLiquidityParams calldata params
)
    external
    payable
    returns (uint256 amount0, uint256 amount1)

Decreases the liquidity of a position. Tokens removed from liquidity are not actually transferred; they are simply accounted for as tokens owed to the position's owner, should they decide to call collect().

DecreaseLiquidityParamsTypeDescription

tokenId

uint256

ID of liquidity position.

liquidity

uint256

Amount of liquidity to remove.

amount0Min

uint256

Minimum required token0 removal.

amount1Min

uint256

Minimum required token1 removal.

deadline

uint256

Unix timestamp in seconds after which the transaction will not succeed.

Return valuesTypeDescription

amount0

uint256

Amount of token0 removed.

amount1

uint256

Amount of token1 removed.

collect

function collect(
    CollectParams calldata params
)
    external
    payable
    returns (uint256 amount0, uint256 amount1)

Retrieves tokens from a liquidity position (from fees earned and any liquidity removed).

CollectParamsTypeDescription

tokenId

uint256

ID of liquidity position.

recipient

address

Address to receive tokens.

amount0Max

uint256

Maximum token0 amount to withdraw.

amount1Max

uint256

Maximum token1 amount to withdraw.

Return valuesTypeDescription

amount0

uint256

Amount of token0 sent.

amount1

uint256

Amount of token1 sent.

burn

function burn(
    uint256 tokenId
) external payable

Burns a liquidity position. The position must have zero liquidity and zero tokens owed.

ParametersTypeDescription

tokenId

uint256

ID of liquidity position to burn.

Owner Functions

setTimelockExcluded

function setTimelockExcluded(
    address addr,
    bool isExcluded
) external

Sets whether an address is excluded from having timelocks imposed on new positions.

ParametersTypeDescription

addr

address

Address to be excluded (or un-excluded).

isExcluded

bool

True to exclude, false to un-exclude.

Read Functions

positions

function positions(
    uint256 tokenId
)
    external
    view
    returns (
        uint96 nonce,
        address operator,
        address token0,
        address token1,
        uint24 fee,
        int24 tickLower,
        int24 tickUpper,
        uint128 liquidity,
        uint256 feeGrowthInside0LastX128,
        uint256 feeGrowthInside1LastX128,
        uint128 tokensOwed0,
        uint128 tokensOwed1
    )

Returns the position data of a liquidity position ID.

ParametersTypeDescription

tokenId

uint256

ID of liquidity position.

Return valuesTypeDescription

nonce

uint96

The nonce for permits.

operator

address

Address that is approved for spending.

token0

address

Address of token0.

token1

address

Address of token1.

fee

uint24

Swap fee tier of the pool.

tickLower

int24

Lower bound tick of price range.

tickUpper

int24

Upper bound tick of price range.

liquidity

uint128

Liquidity of position.

feeGrowthInside0LastX128

uint256

Fee growth of token0 since the last action on the position.

feeGrowthInside1LastX128

uint256

Fee growth of token1 since the last action on the position.

tokensOwed0

uint128

Uncollected amount of token0 owed to the position.

tokensOwed1

uint128

Uncollected amount of token1 owed to the position.

tokenURI

function tokenURI(
    uint256 tokenId
) external view returns (string memory)

Returns a liquidity position's NFT tokenURI.

ParametersTypeDescription

tokenId

uint256

ID of liquidity position.

Return valuesTypeDescription

unnamed

string

TokenURI string.

getApproved

function getApproved(
    uint256 tokenId
) external view returns (address)

Returns the operator of a liquidity position.

ParametersTypeDescription

tokenId

uint256

Liquidity position ID.

Return valuesTypeDescription

unnamed

address

Operator of position.

Last updated