Non-fungible Position Manager
The Non-fungible Position Manager (NFPM) is an ERC-721 contract that represents liquidity positions as NFTs. It provides a user-friendly interface for creating, managing, and interacting with concentrated liquidity positions.Overview
Each liquidity position is represented as a unique NFT with metadata including token pair, fee tier, tick range, and liquidity amount.
Core Functions
mint
address
required
First token in the pair
address
required
Second token in the pair
uint24
required
Fee tier for the pool
int24
required
Lower tick boundary of the position
int24
required
Upper tick boundary of the position
uint256
required
Desired amount of token0
uint256
required
Desired amount of token1
uint256
required
Minimum amount of token0 to accept
uint256
required
Minimum amount of token1 to accept
address
required
Address to receive the NFT
uint256
required
Unix timestamp deadline
uint256
required
Unique identifier for the position NFT
uint128
required
Amount of liquidity created
uint256
required
Amount of token0 used
uint256
required
Amount of token1 used
increaseLiquidity
uint256
required
ID of the position to increase liquidity for
uint256
required
Desired amount of token0 to add
uint256
required
Desired amount of token1 to add
uint256
required
Minimum amount of token0 to accept
uint256
required
Minimum amount of token1 to accept
uint256
required
Unix timestamp deadline
decreaseLiquidity
uint256
required
ID of the position to decrease liquidity for
uint128
required
Amount of liquidity to remove
uint256
required
Minimum amount of token0 to receive
uint256
required
Minimum amount of token1 to receive
uint256
required
Unix timestamp deadline
collect
uint256
required
ID of the position to collect fees from
address
required
Address to receive the collected fees
uint128
required
Maximum amount of token0 to collect
uint128
required
Maximum amount of token1 to collect
burn
uint256
required
ID of the position to burn
Position Information
positions
uint256
required
ID of the position to query
uint96
required
Position nonce for replay protection
address
required
Address authorized to manage the position
address
required
First token in the pair
address
required
Second token in the pair
uint24
required
Fee tier of the pool
int24
required
Lower tick boundary
int24
required
Upper tick boundary
uint128
required
Current liquidity amount
uint256
required
Last fee growth for token0
uint256
required
Last fee growth for token1
uint128
required
Unclaimed token0 fees
uint128
required
Unclaimed token1 fees
Router Contract
The Router contract provides simplified interfaces for common operations like swaps and liquidity management.Swap Functions
exactInputSingle
address
required
Input token address
address
required
Output token address
uint24
required
Fee tier of the pool
address
required
Address to receive output tokens
uint256
required
Unix timestamp deadline
uint256
required
Exact input amount
uint256
required
Minimum output amount
uint160
required
Price limit for the swap
exactInput
bytes
required
Encoded path for the swap
address
required
Address to receive output tokens
uint256
required
Unix timestamp deadline
uint256
required
Exact input amount
uint256
required
Minimum output amount
exactOutputSingle
address
required
Input token address
address
required
Output token address
uint24
required
Fee tier of the pool
address
required
Address to receive output tokens
uint256
required
Unix timestamp deadline
uint256
required
Exact output amount
uint256
required
Maximum input amount
uint160
required
Price limit for the swap
exactOutput
bytes
required
Encoded path for the swap (in reverse order)
address
required
Address to receive output tokens
uint256
required
Unix timestamp deadline
uint256
required
Exact output amount
uint256
required
Maximum input amount
Liquidity Management Functions
mint
increaseLiquidity
decreaseLiquidity
collect
Interfaces
INonfungiblePositionManager
ISwapRouter
Usage Examples
Creating a Position
Executing a Swap
Managing Positions
Best Practices
1
Always check position ownership
Verify you own the position before performing operations.
Use
positions(tokenId).operator to check ownership.2
Set appropriate deadlines
Use reasonable deadlines to prevent transaction failures.
3
Handle slippage properly
Set minimum amounts to protect against price movements.
Use the SDK to calculate expected amounts and set appropriate minimums.
4
Collect fees regularly
Collect accumulated fees to maximize returns.
Error Handling
Position Errors
Position Errors
NOT_AUTHORIZED: Caller is not authorized to manage the positionPOSITION_NOT_FOUND: Position does not existINSUFFICIENT_LIQUIDITY: Not enough liquidity to removeINVALID_TICK_RANGE: Tick range is invalid
Swap Errors
Swap Errors
EXCESSIVE_INPUT_AMOUNT: Input amount exceeds maximumINSUFFICIENT_OUTPUT_AMOUNT: Output amount below minimumEXPIRED: Transaction deadline has passedPRICE_LIMIT_EXCEEDED: Price limit exceeded during swap
Approval Errors
Approval Errors
INSUFFICIENT_ALLOWANCE: Token approval insufficientTRANSFER_FAILED: Token transfer failedINSUFFICIENT_BALANCE: Insufficient token balance