> For the complete documentation index, see [llms.txt](https://docs.warpx.exchange/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.warpx.exchange/for-developers/warpx-v3/periphery/nft-position-manager.md).

# NFT Position Manager

#### Creating a New Position <a href="#user-content-creating-a-new-position" id="user-content-creating-a-new-position"></a>

```
struct MintParams {    address token0;    address token1;    uint24 fee;    int24 tickLower;    int24 tickUpper;    uint256 amount0Desired;    uint256 amount1Desired;    uint256 amount0Min;    uint256 amount1Min;    address recipient;    uint256 deadline;}function mint(MintParams calldata params) external payable returns (    uint256 tokenId,    uint128 liquidity,    uint256 amount0,    uint256 amount1)
```

Creates a new liquidity position as an NFT. The pool must already exist and be initialized.

**Parameters:**

| Field            | Description                          |
| ---------------- | ------------------------------------ |
| `token0`         | First token address                  |
| `token1`         | Second token address                 |
| `fee`            | Fee tier (100, 500, 3000, or 10000)  |
| `tickLower`      | Lower tick boundary                  |
| `tickUpper`      | Upper tick boundary                  |
| `amount0Desired` | Desired amount of token0 to add      |
| `amount1Desired` | Desired amount of token1 to add      |
| `amount0Min`     | Minimum token0 (slippage protection) |
| `amount1Min`     | Minimum token1 (slippage protection) |
| `recipient`      | NFT recipient address                |
| `deadline`       | Transaction expiry timestamp         |

**Returns:** `tokenId`, `liquidity`, actual `amount0` and `amount1` deposited

**Example:**

```
INonfungiblePositionManager.MintParams memory params = INonfungiblePositionManager.MintParams({    token0: USDC,    token1: WETH,    fee: 3000,    tickLower: -887220,    tickUpper: 887220,    amount0Desired: 1000e6,    // 1000 USDC    amount1Desired: 0.5e18,    // 0.5 WETH    amount0Min: 950e6,    amount1Min: 0.475e18,    recipient: msg.sender,    deadline: block.timestamp + 300});(uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1) = positionManager.mint(params);
```

***

#### Increasing Liquidity <a href="#user-content-increasing-liquidity" id="user-content-increasing-liquidity"></a>

```
struct IncreaseLiquidityParams {    uint256 tokenId;    uint256 amount0Desired;    uint256 amount1Desired;    uint256 amount0Min;    uint256 amount1Min;    uint256 deadline;}function increaseLiquidity(IncreaseLiquidityParams calldata params) external payable returns (    uint128 liquidity,    uint256 amount0,    uint256 amount1)
```

Adds more liquidity to an existing position. Only the position owner can call this.

**Example:**

```
INonfungiblePositionManager.IncreaseLiquidityParams memory params =     INonfungiblePositionManager.IncreaseLiquidityParams({        tokenId: 1234,        amount0Desired: 500e6,        amount1Desired: 0.25e18,        amount0Min: 475e6,        amount1Min: 0.2375e18,        deadline: block.timestamp + 300    });(uint128 liquidity, uint256 amount0, uint256 amount1) = positionManager.increaseLiquidity(params);
```

***

#### Decreasing Liquidity <a href="#user-content-decreasing-liquidity" id="user-content-decreasing-liquidity"></a>

```
struct DecreaseLiquidityParams {    uint256 tokenId;    uint128 liquidity;    uint256 amount0Min;    uint256 amount1Min;    uint256 deadline;}function decreaseLiquidity(DecreaseLiquidityParams calldata params) external payable returns (    uint256 amount0,    uint256 amount1)
```

Removes liquidity from a position. Withdrawn tokens are credited to the position and must be collected separately.

**Example:**

```
INonfungiblePositionManager.DecreaseLiquidityParams memory params =     INonfungiblePositionManager.DecreaseLiquidityParams({        tokenId: 1234,        liquidity: 50000,        amount0Min: 100e6,        amount1Min: 0.05e18,        deadline: block.timestamp + 300    });(uint256 amount0, uint256 amount1) = positionManager.decreaseLiquidity(params);
```

***

#### Collecting Fees & Tokens <a href="#user-content-collecting-fees--tokens" id="user-content-collecting-fees--tokens"></a>

```
struct CollectParams {    uint256 tokenId;    address recipient;    uint128 amount0Max;    uint128 amount1Max;}function collect(CollectParams calldata params) external payable returns (    uint256 amount0,    uint256 amount1)
```

Collects accumulated fees and tokens from decreased liquidity.

**Example:**

```
// Collect all available tokens and feesINonfungiblePositionManager.CollectParams memory params =     INonfungiblePositionManager.CollectParams({        tokenId: 1234,        recipient: msg.sender,        amount0Max: type(uint128).max,        amount1Max: type(uint128).max    });(uint256 amount0, uint256 amount1) = positionManager.collect(params);
```

***

#### Burning a Position <a href="#user-content-burning-a-position" id="user-content-burning-a-position"></a>

```
function burn(uint256 tokenId) external payable
```

Burns an NFT position. The position must have:

* Zero liquidity remaining
* All tokens and fees collected

**Example:**

```
// Must decrease liquidity to 0 and collect all tokens firstpositionManager.burn(1234);
```

***

#### Creating & Initializing Pools <a href="#user-content-creating--initializing-pools" id="user-content-creating--initializing-pools"></a>

```
function createAndInitializePoolIfNecessary(    address token0,    address token1,    uint24 fee,    uint160 sqrtPriceX96) external payable returns (address pool)
```

Creates a new pool if it doesn't exist, and initializes it if needed. Useful for bundling with `mint()`.

**Example:**

```
// Create and initialize USDC/WETH 0.3% pool at 1:2000 ratioaddress pool = positionManager.createAndInitializePoolIfNecessary(    USDC,    WETH,    3000,    1771845812700903892492222464  // sqrt(2000) * 2^96);
```

***

### Querying Positions <a href="#user-content-querying-positions" id="user-content-querying-positions"></a>

```
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 full details about a position NFT.

**Example:**

```
(    ,    ,    address token0,    address token1,    uint24 fee,    int24 tickLower,    int24 tickUpper,    uint128 liquidity,    ,    ,    uint128 tokensOwed0,    uint128 tokensOwed1) = positionManager.positions(1234);
```

***

### Events <a href="#user-content-events" id="user-content-events"></a>

#### IncreaseLiquidity <a href="#user-content-increaseliquidity" id="user-content-increaseliquidity"></a>

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

Emitted when liquidity is added to a position (including initial minting).

#### DecreaseLiquidity <a href="#user-content-decreaseliquidity" id="user-content-decreaseliquidity"></a>

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

Emitted when liquidity is removed from a position.

#### Collect <a href="#user-content-collect" id="user-content-collect"></a>

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

Emitted when fees or tokens are collected from a position.

***

### ERC721 Compatibility <a href="#user-content-erc721-compatibility" id="user-content-erc721-compatibility"></a>

The Position Manager is a full ERC721 NFT contract, supporting:

* `transferFrom()` - Transfer positions between addresses
* `approve()` / `setApprovalForAll()` - Authorize operators
* `ownerOf()` - Query position owner
* `tokenURI()` - Get on-chain SVG metadata

Position NFTs can be traded, used as collateral, or integrated with NFT marketplaces.<br>
