# NonfungiblePositionManager

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

## Table of Contents

<details>

<summary>Variables</summary>

[#lockeduntil](#lockeduntil "mention")\
[#timelock](#timelock "mention")\
[#timelockexcluded](#timelockexcluded "mention")

</details>

<details>

<summary>Events</summary>

[#increaseliquidity](#increaseliquidity "mention")\
[#decreaseliquidity](#decreaseliquidity "mention")\
[#collect](#collect "mention")

</details>

<details>

<summary>Public Write Functions</summary>

[#increaseliquidity-1](#increaseliquidity-1 "mention")\
[#decreaseliquidity-1](#decreaseliquidity-1 "mention")\
[#collect-1](#collect-1 "mention")\
[#burn](#burn "mention")

</details>

<details>

<summary>Owner Write Functions</summary>

[#settimelockexcluded](#settimelockexcluded "mention")

</details>

<details>

<summary>Read Functions</summary>

[#positions](#positions "mention")\
[#tokenuri](#tokenuri "mention")\
[#getapproved](#getapproved "mention")

</details>

## Variables

#### lockedUntil

```solidity
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

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

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

#### timelockExcluded

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

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

## Events

#### IncreaseLiquidity

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

Emitted by `mint()` and `increaseLiquidity()`.

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position being increased.</td></tr><tr><td>liquidity</td><td><code>uint128</code></td><td>Amount of liquidity added.</td></tr><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 deposited.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 deposited.</td></tr></tbody></table>

#### DecreaseLiquidity

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

Emitted by `decreaseLiquidity()`.

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position being decreased.</td></tr><tr><td>liquidity</td><td><code>uint128</code></td><td>Amount of liquidity removed.</td></tr><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 removed.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 removed.</td></tr></tbody></table>

#### Collect

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

Emitted by `collect()`.

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position. </td></tr><tr><td>recipient</td><td><code>address</code></td><td>Address that collected tokens.</td></tr><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 sent.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 sent.</td></tr></tbody></table>

## Write Functions

#### increaseLiquidity

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

Increases liquidity of a position.&#x20;

<table><thead><tr><th width="160.5">Parameters</th><th width="266">Type</th><th>Description</th></tr></thead><tbody><tr><td>params</td><td><code>IncreaseLiquidityParams</code></td><td>See table below.</td></tr><tr><td><code>msg.value</code></td><td><code>uint256</code></td><td>Amount of ETH sent.</td></tr></tbody></table>

<table><thead><tr><th width="248.5">IncreaseLiquidityParams</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position.</td></tr><tr><td>amount0Desired</td><td><code>uint256</code></td><td>Desired token0 deposit amount.</td></tr><tr><td>amount1Desired</td><td><code>uint256</code></td><td>Desired token1 deposit amount.</td></tr><tr><td>amount0Min</td><td><code>uint256</code></td><td>Minimum required token0 deposit amount.</td></tr><tr><td>amount1Min</td><td><code>uint256</code></td><td>Minimum required token0 deposit amount.</td></tr></tbody></table>

<table><thead><tr><th width="249.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>liquidity</td><td><code>uint128</code></td><td>Amount of liquidity added.</td></tr><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 added.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 added. </td></tr></tbody></table>

#### decreaseLiquidity

```solidity
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()`.&#x20;

<table><thead><tr><th width="249.5">DecreaseLiquidityParams</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position.</td></tr><tr><td>liquidity</td><td><code>uint256</code></td><td>Amount of liquidity to remove. </td></tr><tr><td>amount0Min</td><td><code>uint256</code></td><td>Minimum required token0 removal.</td></tr><tr><td>amount1Min</td><td><code>uint256</code></td><td>Minimum required token1 removal.</td></tr><tr><td>deadline</td><td><code>uint256</code></td><td>Unix timestamp in seconds after which the transaction will not succeed.</td></tr></tbody></table>

<table><thead><tr><th width="249.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 removed.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 removed.</td></tr></tbody></table>

#### collect

```solidity
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).&#x20;

<table><thead><tr><th width="196.5">CollectParams</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position.</td></tr><tr><td>recipient</td><td><code>address</code></td><td>Address to receive tokens.</td></tr><tr><td>amount0Max</td><td><code>uint256</code></td><td>Maximum token0 amount to withdraw.</td></tr><tr><td>amount1Max</td><td><code>uint256</code></td><td>Maximum token1 amount to withdraw.</td></tr></tbody></table>

<table><thead><tr><th width="197.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>amount0</td><td><code>uint256</code></td><td>Amount of token0 sent.</td></tr><tr><td>amount1</td><td><code>uint256</code></td><td>Amount of token1 sent.</td></tr></tbody></table>

#### burn

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

Burns a liquidity position. The position must have zero liquidity and zero tokens owed.&#x20;

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position to burn.</td></tr></tbody></table>

## Owner Functions

#### setTimelockExcluded

```solidity
function setTimelockExcluded(
    address addr,
    bool isExcluded
) external
```

Sets whether an address is excluded from having timelocks imposed on new positions.&#x20;

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>addr</td><td><code>address</code></td><td>Address to be excluded (or un-excluded).</td></tr><tr><td>isExcluded</td><td><code>bool</code></td><td>True to exclude, false to un-exclude.</td></tr></tbody></table>

## Read Functions

#### positions

```solidity
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.&#x20;

<table><thead><tr><th width="257.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position. </td></tr></tbody></table>

<table><thead><tr><th width="256.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>nonce</td><td><code>uint96</code></td><td>The nonce for permits.</td></tr><tr><td>operator</td><td><code>address</code></td><td>Address that is approved for spending. </td></tr><tr><td>token0</td><td><code>address</code></td><td>Address of token0.</td></tr><tr><td>token1</td><td><code>address</code></td><td>Address of token1.</td></tr><tr><td>fee</td><td><code>uint24</code></td><td>Swap fee tier of the pool.</td></tr><tr><td>tickLower</td><td><code>int24</code></td><td>Lower bound tick of price range.</td></tr><tr><td>tickUpper</td><td><code>int24</code></td><td>Upper bound tick of price range.</td></tr><tr><td>liquidity</td><td><code>uint128</code></td><td>Liquidity of position.</td></tr><tr><td>feeGrowthInside0LastX128</td><td><code>uint256</code></td><td>Fee growth of token0 since the last action on the position.</td></tr><tr><td>feeGrowthInside1LastX128</td><td><code>uint256</code></td><td>Fee growth of token1 since the last action on the position.</td></tr><tr><td>tokensOwed0</td><td><code>uint128</code></td><td>Uncollected amount of token0 owed to the position.</td></tr><tr><td>tokensOwed1</td><td><code>uint128</code></td><td>Uncollected amount of token1 owed to the position.</td></tr></tbody></table>

#### tokenURI

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

Returns a liquidity position's NFT tokenURI.

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>ID of liquidity position. </td></tr></tbody></table>

<table><thead><tr><th width="192.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td><em>unnamed</em></td><td><code>string</code></td><td>TokenURI string. </td></tr></tbody></table>

#### getApproved

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

Returns the `operator` of a liquidity position.&#x20;

<table><thead><tr><th width="192.5">Parameters</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td>tokenId</td><td><code>uint256</code></td><td>Liquidity position ID.</td></tr></tbody></table>

<table><thead><tr><th width="192.5">Return values</th><th width="128">Type</th><th>Description</th></tr></thead><tbody><tr><td><em>unnamed</em></td><td><code>address</code></td><td>Operator of position.</td></tr></tbody></table>
