# IMaverickV2LiquidityManager

**Inherits:** [IPayment](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/paymentbase/ipayment.md), [IChecks](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/base/ichecks.md), [IExactOutputSlim](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/routerbase/iexactoutputslim.md), [IArgPacker](/technical-reference/maverick-v2/v2-contracts/maverick-v2-supplemental-contracts/liquiditybase/iargpacker.md)

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

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

Maverick V2 NFT position contract that tracks NFT-based liquditiy positions.

```solidity
function position() external view returns (IMaverickV2Position);
```

#### boostedPositionFactory <a href="#boostedpositionfactory" id="boostedpositionfactory"></a>

Maverick V2 BP factory contract.

```solidity
function boostedPositionFactory() external view returns (IMaverickV2BoostedPositionFactory);
```

#### createPool <a href="#createpool" id="createpool"></a>

Create Maverick V2 pool. Function is a pass through to the pool factory and is provided here so that is can be assembled as part of a multicall transaction.

```solidity
function createPool(
    uint64 fee,
    uint16 tickSpacing,
    uint32 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    int32 activeTick,
    uint8 kinds
) external payable returns (IMaverickV2Pool pool);
```

#### createPool <a href="#createpool-1" id="createpool-1"></a>

Create Maverick V2 pool with two-way fees. Function is a pass through to the pool factory and is provided here so that is can be assembled as part of a multicall transaction.

```solidity
function createPool(
    uint64 feeAIn,
    uint64 feeBIn,
    uint16 tickSpacing,
    uint32 lookback,
    IERC20 tokenA,
    IERC20 tokenB,
    int32 activeTick,
    uint8 kinds
) external payable returns (IMaverickV2Pool pool);
```

#### addLiquidity <a href="#addliquidity" id="addliquidity"></a>

Add Liquidity to a Maverick V2 pool. Function is a pass through to the pool and is provided here so that is can be assembled as part of a multicall transaction. Users can add liquidity to the Position NFT contract or a BP as part of a multicall in order to mint NFT/BP positions.

Liquidity is specified as bytes that represent a lookup table of add parameters. This allows an adder to specify what liquidity amounts they wish to add conditional on the price of the pool when their transaction is executed. With this, users have fine-grain control of how price slippage affects the amount of liquidity they add. The MaverickV2PoolLens contract has helper view functions that can be used to easily create a combination of price breaks and packed arguments.

```solidity
function addLiquidity(
    IMaverickV2Pool pool,
    address recipient,
    uint256 subaccount,
    bytes calldata packedSqrtPriceBreaks,
    bytes[] calldata packedArgs
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds);
```

#### addPositionLiquidityToSenderByTokenIndex <a href="#addpositionliquiditytosenderbytokenindex" id="addpositionliquiditytosenderbytokenindex"></a>

Add Liquidity position NFT for msg.sender by specifying msg.sender's token index.

Token index is different from tokenId. On the Position NFT contract a user can own multiple NFT tokenIds and these are indexes by an enumeration index which is the `index` input here. See addLiquidity for a description of the add params.

```solidity
function addPositionLiquidityToSenderByTokenIndex(
    IMaverickV2Pool pool,
    uint256 index,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds);
```

#### addPositionLiquidityToRecipientByTokenIndex <a href="#addpositionliquiditytorecipientbytokenindex" id="addpositionliquiditytorecipientbytokenindex"></a>

Add Liquidity position NFT for msg.sender by specifying recipient's token index.

Token index is different from tokenId. On the Position NFT contract a user can own multiple NFT tokenIds and these are indexes by an enumeration index which is the `index` input here. See addLiquidity for a description of the add params.

```solidity
function addPositionLiquidityToRecipientByTokenIndex(
    IMaverickV2Pool pool,
    address recipient,
    uint256 index,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds);
```

#### migrateBoostedPosition <a href="#migrateboostedposition" id="migrateboostedposition"></a>

Pass through function to the BP bin migration.

```solidity
function migrateBoostedPosition(IMaverickV2BoostedPosition boostedPosition) external payable;
```

#### mintPositionNft <a href="#mintpositionnft" id="mintpositionnft"></a>

Mint new tokenId in the Position NFT contract. Both mints an NFT and adds liquidity to the pool that is held by the NFT.

Caller must approve this LiquidityManager contract to spend the caller's token A/B in order to fund the liquidity position. See addLiquidity for a description of the add params.

```solidity
function mintPositionNft(
    IMaverickV2Pool pool,
    address recipient,
    bytes calldata packedSqrtPriceBreaks,
    bytes[] calldata packedArgs
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds, uint256 tokenId);
```

#### mintPositionNftToSender <a href="#mintpositionnfttosender" id="mintpositionnfttosender"></a>

Mint new tokenId in the Position NFt contract to msg.sender. Both mints an NFT and adds liquidity to the pool that is held by the NFT.

```solidity
function mintPositionNftToSender(
    IMaverickV2Pool pool,
    bytes calldata packedSqrtPriceBreaks,
    bytes[] calldata packedArgs
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds, uint256 tokenId);
```

#### mintBoostedPosition <a href="#mintboostedposition" id="mintboostedposition"></a>

Mint BP LP tokens to recipient. This function does not add liquidity to the BP and is only useful in conjuction with addLiquidity as part of a multcall.

```solidity
function mintBoostedPosition(IMaverickV2BoostedPosition boostedPosition, address recipient)
    external
    payable
    returns (uint256 mintedLpAmount);
```

#### donateLiquidity <a href="#donateliquidity" id="donateliquidity"></a>

Donates liqudity to a pool that is held by the position contract and will never be retrievable. Can be used to start a pool and ensure there will always be a base level of liquditiy in the pool.

```solidity
function donateLiquidity(IMaverickV2Pool pool, IMaverickV2Pool.AddLiquidityParams memory args) external payable;
```

#### createPoolAtPriceAndAddLiquidity <a href="#createpoolatpriceandaddliquidity" id="createpoolatpriceandaddliquidity"></a>

Creates a pool at a specified price and mints a Position NFT with liquidity to the recipient.

A Maverick V2 pool has no native was to specify a starting price, only a starting `activeTick`. The initial pool price will be the left edge of the initial activeTick. In order to create a pool at a fixed price, this function dontes a small amount of liquidity to the pool, does a swap to the specified price, and then adds liquidity for the user.

```solidity
function createPoolAtPriceAndAddLiquidity(address recipient, IMaverickV2PoolLens.CreateAndAddParamsInputs memory params)
    external
    payable
    returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds, uint256 tokenId);
```

#### createPoolAtPriceAndAddLiquidityToSender <a href="#createpoolatpriceandaddliquiditytosender" id="createpoolatpriceandaddliquiditytosender"></a>

Creates a pool at a specified price and mints a Position NFT with liquidity to msg.sender.

```solidity
function createPoolAtPriceAndAddLiquidityToSender(IMaverickV2PoolLens.CreateAndAddParamsInputs memory params)
    external
    payable
    returns (uint256 tokenAAmount, uint256 tokenBAmount, uint32[] memory binIds, uint256 tokenId);
```

#### addLiquidityAndMintBoostedPosition <a href="#addliquidityandmintboostedposition" id="addliquidityandmintboostedposition"></a>

Executes the multi-step process of minting BP LP positions by adding liqudiity to a pool in the BP liquidity distribution and then minting the BP to recipient.

Caller will need to approve this LiquidityManager contract to spend their token A/B in order to execute this function.

```solidity
function addLiquidityAndMintBoostedPosition(
    address recipient,
    IMaverickV2BoostedPosition boostedPosition,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs
) external payable returns (uint256 mintedLpAmount, uint256 tokenAAmount, uint256 tokenBAmount);
```

#### addLiquidityAndMintBoostedPositionToSender <a href="#addliquidityandmintboostedpositiontosender" id="addliquidityandmintboostedpositiontosender"></a>

Executes the multi-step process of minting BP LP positions by adding liquidity to a pool in the BP liquidity distribution and then minting the BP to msg.sender.

Caller will need to approve this LiquidityManager contract to spend their token A/B in order to execute this function.

```solidity
function addLiquidityAndMintBoostedPositionToSender(
    IMaverickV2BoostedPosition boostedPosition,
    bytes memory packedSqrtPriceBreaks,
    bytes[] memory packedArgs
) external payable returns (uint256 mintedLpAmount, uint256 tokenAAmount, uint256 tokenBAmount);
```

#### createBoostedPositionAndAddLiquidity <a href="#createboostedpositionandaddliquidity" id="createboostedpositionandaddliquidity"></a>

Deploy new BP contract from the BP factory and mint BP LP tokens to the recipient.

Caller will need to approve this LiquidityManager contract to spend their token A/B in order to execute this function.

```solidity
function createBoostedPositionAndAddLiquidity(
    address recipient,
    IMaverickV2PoolLens.CreateBoostedPositionInputs memory params
)
    external
    payable
    returns (
        IMaverickV2BoostedPosition boostedPosition,
        uint256 mintedLpAmount,
        uint256 tokenAAmount,
        uint256 tokenBAmount
    );
```

#### createBoostedPositionAndAddLiquidityToSender <a href="#createboostedpositionandaddliquiditytosender" id="createboostedpositionandaddliquiditytosender"></a>

Deploy new BP contract from the BP factory and mint BP LP tokens to msg.sender.

Caller will need to approve this LiquidityManager contract to spend their token A/B in order to execute this function.

```solidity
function createBoostedPositionAndAddLiquidityToSender(IMaverickV2PoolLens.CreateBoostedPositionInputs memory params)
    external
    payable
    returns (
        IMaverickV2BoostedPosition boostedPosition,
        uint256 mintedLpAmount,
        uint256 tokenAAmount,
        uint256 tokenBAmount
    );
```

#### removeLiquidityFromPositionNftAndSweepToSender <a href="#removeliquidityfrompositionnftandsweeptosender" id="removeliquidityfrompositionnftandsweeptosender"></a>

Remove liquidity from a Position NFT and send proceeds to msg.sender. This function will unwrap WETH to ETH before sending to user. A user can also remove liquidity using the Position contract if they do not need to unwrap WETH.

Caller will need to approve this LiquidityManager contract to access the caller's tokenId NFT.

```solidity
function removeLiquidityFromPositionNftAndSweepToSender(
    uint256 tokenId,
    IMaverickV2Pool pool,
    IMaverickV2Pool.RemoveLiquidityParams memory params,
    uint256 tokenAAmountMin,
    uint256 tokenBAmountMin
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount);
```

#### removeLiquidityFromBoostedPositionToSender <a href="#removeliquidityfromboostedpositiontosender" id="removeliquidityfromboostedpositiontosender"></a>

Burn a BP and send proceeds to msg.sender. This function will unwrap WETH to ETH before sending to user. A user can also burn their LP tokens using the BP contract if they do not need to unwrap WETH.

Caller will need to approve this LiquidityManager contract to access the caller's BP balance.

```solidity
function removeLiquidityFromBoostedPositionToSender(
    IMaverickV2BoostedPosition boostedPosition,
    uint256 amount,
    uint256 tokenAAmountMin,
    uint256 tokenBAmountMin
) external payable returns (uint256 tokenAAmount, uint256 tokenBAmount);
```

### Errors <a href="#errors" id="errors"></a>

#### LiquidityManagerNotFactoryPool <a href="#liquiditymanagernotfactorypool" id="liquiditymanagernotfactorypool"></a>

```solidity
error LiquidityManagerNotFactoryPool();
```

#### LiquidityManagerNotTokenIdOwner <a href="#liquiditymanagernottokenidowner" id="liquiditymanagernottokenidowner"></a>

```solidity
error LiquidityManagerNotTokenIdOwner();
```

<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/interfaces/imaverickv2liquiditymanager.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.
