NonfungiblePositionManager

The NonfungiblePositionManager wraps VinuSwap liquidity positions as ERC721 NFTs for easier management.

Source: contracts/periphery/NonfungiblePositionManager.sol

Overview

The position manager:

  • Mints ERC721 tokens representing liquidity positions

  • Tracks position ownership, fees, and liquidity

  • Provides functions to modify positions

  • Supports position locking (VinuSwap extension)

Inheritance

NonfungiblePositionManager
├── INonfungiblePositionManager
├── Multicall
├── ERC721Permit
├── PeripheryImmutableState
├── LiquidityManagement
├── PeripheryValidation
└── SelfPermit

Position Struct

Functions

mint

Creates a new position and mints an NFT.

Parameters:

Field
Description

token0

First token address (must be < token1)

token1

Second token address

fee

Pool fee tier

tickLower

Lower tick boundary

tickUpper

Upper tick boundary

amount0Desired

Desired token0 amount

amount1Desired

Desired token1 amount

amount0Min

Minimum token0 (slippage protection)

amount1Min

Minimum token1 (slippage protection)

recipient

NFT recipient

deadline

Transaction deadline

Returns:

Name
Type
Description

tokenId

uint256

ID of minted NFT

liquidity

uint128

Liquidity added

amount0

uint256

Token0 used

amount1

uint256

Token1 used

Example:


increaseLiquidity

Adds liquidity to an existing position.

Parameters:

Note: Can be called even on locked positions.


decreaseLiquidity

Removes liquidity from a position.

Parameters:

Requirements:

  • Caller must be owner or approved

  • Position must NOT be locked (block.timestamp >= lockedUntil)

Returns:

Name
Type
Description

amount0

uint256

Token0 amount withdrawn

amount1

uint256

Token1 amount withdrawn

Note: Tokens are not transferred automatically. Call collect() to receive tokens.


collect

Collects tokens owed from a position (from decreaseLiquidity and accumulated fees).

Parameters:

Field
Description

tokenId

Position NFT ID

recipient

Token recipient

amount0Max

Maximum token0 to collect

amount1Max

Maximum token1 to collect

Note: Can be called on locked positions (fee collection is always allowed).

Example:


burn

Burns a position NFT.

Requirements:

  • Caller must be owner or approved

  • Position liquidity must be 0

  • Position must NOT be locked

  • All tokens must be collected (tokensOwed0 = tokensOwed1 = 0)


lock

VinuSwap Extension

Locks a position until a specified timestamp.

Parameters:

Name
Type
Description

tokenId

uint256

Position NFT ID

lockedUntil

uint256

Unix timestamp until which position is locked

deadline

uint256

Transaction deadline

Requirements:

  • Caller must be owner or approved

  • lockedUntil must be in the future or extend current lock

Effects:

  • Position cannot call decreaseLiquidity() until lock expires

  • Position cannot call burn() until lock expires

  • Position CAN still call collect() and increaseLiquidity()

Events Emitted:

  • Lock(tokenId, lockedUntil)

Example:


positions

Returns position data for a given NFT ID.

Note: Returns lockedUntil instead of tokensOwed. Use tokensOwed(tokenId) to get uncollected token amounts.


tokensOwed

Returns uncollected tokens for a position.

Parameters:

Name
Type
Description

tokenId

uint256

Position NFT ID

Returns:

Name
Type
Description

tokensOwed0

uint128

Uncollected token0

tokensOwed1

uint128

Uncollected token1

Events

IncreaseLiquidity

DecreaseLiquidity

Collect

Lock

VinuSwap Extension

Error Messages

Error
Meaning

Invalid token ID

NFT does not exist

Not approved

Caller lacks permission

Locked

Position is locked

Not cleared

Position has uncollected tokens

Price slippage check

Slippage bounds exceeded

Common Patterns

Create Position with VC

Remove All Liquidity

Lock and Provide Liquidity

Interface

Last updated