# MaverickV2Position

**Inherits:** [Nft](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/positionbase/nft.md), [Checks](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/base/checks.md), [MigrateBins](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/base/migratebins.md), [PayableMulticall](/technical-reference/maverick-v2/v2-contracts/maverick-v2-common-contracts/base/payablemulticall.md), [IMaverickV2Position](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/interfaces/imaverickv2position.md)

ERC-721 contract that stores user NFTs that contain Maverick V2 pool liquidity.

The Maverick V2 pool has a concept of storing liquidity according to an address and a "subaccount". When liquidity is minted to an NFT, it is stored in the pool to the address of this Position contract to the subaccount that corresponds to the NFT tokenId. The mechanism of liquidity management is that the tokenId owner is the only user who can remove pool liquidity in the subaccount corresponding to their tokenId.

Additionally, this position NFT has data about the pools and binIds that a given tokenId has liquidity in. But these binId/pool values are essentially self reported and can be updated by the token owner by calling setTokenIdData.

### State Variables <a href="#state-variables" id="state-variables"></a>

#### positionImage <a href="#positionimage" id="positionimage"></a>

```solidity
IPositionImage public immutable positionImage;
```

#### dataByTokenId <a href="#databytokenid" id="databytokenid"></a>

```solidity
mapping(uint256 => PositionPoolBinIds[]) private dataByTokenId;
```

### Functions <a href="#functions" id="functions"></a>

#### constructor <a href="#constructor" id="constructor"></a>

```solidity
constructor(IPositionImage _positionImage) Nft("Maverick v2 Position", "MPv2");
```

#### mint <a href="#mint" id="mint"></a>

Mint NFT that holds liquidity in a Maverick V2 Pool. To mint liquidity to an NFT, add liquidity to bins in a pool where the add liquidity recipient is this contract and the subaccount is the tokenId. LiquidityManager can be used to simplify minting Position NFTs.

```solidity
function mint(address recipient, IMaverickV2Pool pool, uint32[] memory binIds) public returns (uint256 tokenId);
```

#### unSafeBurn <a href="#unsafeburn" id="unsafeburn"></a>

Burns the specified token without removing liquidity. Once tokenId is burned, it will no longer be possible to remove liquidity.

```solidity
function unSafeBurn(uint256 tokenId) external onlyTokenIdAuthorizedUser(tokenId);
```

#### removeLiquidity <a href="#removeliquidity" id="removeliquidity"></a>

Remove liquidity from tokenId for a given pool. User can specify arbitrary bins to remove from for their subaccount in the pool even if those bins are not in the tokenIdData set.

```solidity
function removeLiquidity(
    uint256 tokenId,
    address recipient,
    IMaverickV2Pool pool,
    IMaverickV2Pool.RemoveLiquidityParams memory params
) external onlyTokenIdAuthorizedUser(tokenId) returns (uint256 tokenAAmount, uint256 tokenBAmount);
```

#### removeLiquidityToSender <a href="#removeliquiditytosender" id="removeliquiditytosender"></a>

Remove liquidity from tokenId for a given pool to sender. User can specify arbitrary bins to remove from for their subaccount in the pool even if those bins are not in the tokenIdData set.

```solidity
function removeLiquidityToSender(
    uint256 tokenId,
    IMaverickV2Pool pool,
    IMaverickV2Pool.RemoveLiquidityParams memory params
) external onlyTokenIdAuthorizedUser(tokenId) returns (uint256 tokenAAmount, uint256 tokenBAmount);
```

#### setTokenIdData <a href="#settokeniddata" id="settokeniddata"></a>

Overwrites tokenId pool/binId information for a given data index.

```solidity
function setTokenIdData(uint256 tokenId, uint256 index, IMaverickV2Pool pool, uint32[] memory binIds)
    external
    onlyTokenIdAuthorizedUser(tokenId);
```

#### setTokenIdData <a href="#settokeniddata-1" id="settokeniddata-1"></a>

Overwrites tokenId pool/binId information for a given data index.

```solidity
function setTokenIdData(uint256 tokenId, PositionPoolBinIds[] memory data)
    external
    onlyTokenIdAuthorizedUser(tokenId);
```

#### appendTokenIdData <a href="#appendtokeniddata" id="appendtokeniddata"></a>

Append new pool/binIds data array to tokenId.

```solidity
function appendTokenIdData(uint256 tokenId, IMaverickV2Pool pool, uint32[] memory binIds)
    external
    onlyTokenIdAuthorizedUser(tokenId);
```

#### getTokenIdData <a href="#gettokeniddata" id="gettokeniddata"></a>

Get array pool/binIds data for a given tokenId.

```solidity
function getTokenIdData(uint256 tokenId) external view returns (PositionPoolBinIds[] memory);
```

#### getTokenIdData <a href="#gettokeniddata-1" id="gettokeniddata-1"></a>

Get array pool/binIds data for a given tokenId.

```solidity
function getTokenIdData(uint256 tokenId, uint256 index) external view returns (PositionPoolBinIds memory);
```

#### tokenIdDataLength <a href="#tokeniddatalength" id="tokeniddatalength"></a>

Length of array of pool/binIds data for a given tokenId.

```solidity
function tokenIdDataLength(uint256 tokenId) external view returns (uint256 length);
```

#### tokenIdPositionInformation <a href="#tokenidpositioninformation" id="tokenidpositioninformation"></a>

NFT asset information for a given range of pool/binIds indexes. This function only returns the liquidity in the pools/binIds stored as part of the tokenIdData, but it is possible that the NFT has additional liquidity in pools/binIds that have not been recorded.

```solidity
function tokenIdPositionInformation(uint256 tokenId, uint256 startIndex, uint256 stopIndex)
    public
    view
    returns (PositionFullInformation[] memory output);
```

#### tokenIdPositionInformation <a href="#tokenidpositioninformation-1" id="tokenidpositioninformation-1"></a>

NFT asset information for a given range of pool/binIds indexes. This function only returns the liquidity in the pools/binIds stored as part of the tokenIdData, but it is possible that the NFT has additional liquidity in pools/binIds that have not been recorded.

```solidity
function tokenIdPositionInformation(uint256 tokenId, uint256 index)
    public
    view
    returns (PositionFullInformation memory output);
```

#### getRemoveParams <a href="#getremoveparams" id="getremoveparams"></a>

Get remove paramters for removing a fractional part of the liquidity owned by a given tokenId. The fractional factor to remove is given by proporationD18 in 18-decimal scale.

```solidity
function getRemoveParams(uint256 tokenId, uint256 index, uint256 proportionD18)
    public
    view
    returns (IMaverickV2Pool.RemoveLiquidityParams memory params);
```

#### \_checkData <a href="#checkdata" id="checkdata"></a>

Checks that binIds are unique.

```solidity
function _checkData(PositionPoolBinIds memory data) internal view;
```

#### \_checkNoDuplicatePool <a href="#checknoduplicatepool" id="checknoduplicatepool"></a>

Checks that token data does not contain duplicate pool.

```solidity
function _checkNoDuplicatePool(uint256 tokenId) internal view;
```

#### tokenURI <a href="#tokenuri" id="tokenuri"></a>

```solidity
function tokenURI(uint256 tokenId) public view virtual override(Nft, INft) returns (string memory);
```

#### name <a href="#name" id="name"></a>

```solidity
function name() public view override(INft, Nft) returns (string memory);
```

#### symbol <a href="#symbol" id="symbol"></a>

```solidity
function symbol() public view override(INft, Nft) returns (string memory);
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mav.xyz/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/maverickv2position.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
