MaverickV2LiquidityManager
Inherits: Checks, ExactOutputSlim, ArgPacker, IMaverickV2LiquidityManager
Maverick liquidity management contract that provides helper functions for minting either NFT liquidity positions or boosted positions which are fungible positions in a Maverick V2 pool. While this contract does have public payment callback functions, these are access controlled so that they can only be called by a factory pool; so it is safe to approve this contract to spend a caller's tokens. This contract inherits "Check" functions that can be multicalled with liquidity management functions to create slippage and deadline constraints on transactions.
This contract has a multicall interface and all public functions are payable which facilitates multicall combinations of both payable interactions and non-payable interactions.
addLiquidity parameters are specified as a lookup table of prices where the caller specifies packedSqrtPriceBreaks and packedArgs. During the add operation, this contract queries the pool for its current sqrtPrice and then looks up this price relative to the price breaks array (the array is packed as bytes using the conventions in the inherited ArgPacker contract to save calldata space). If the current pool sqrt price is in between the N and N+1 elements of the packedSqrtPriceBreaks array, then the add parameters from the Nth element of the packedArgs array are used in the add liquidity call.
This lookup table approach provides a flexible way for callers to manage price slippage between the time they submit their transaction and the time it is executed. The MaverickV2PoolLens contract provides a number of helper function to create this slippage lookup table.
State Variables
position
Maverick V2 NFT position contract that tracks NFT-based liquditiy positions.
boostedPositionFactory
Maverick V2 BP factory contract.
Functions
constructor
createPool
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.
createPool
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.
addLiquidity
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.
addPositionLiquidityToSenderByTokenIndex
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.
addPositionLiquidityToRecipientByTokenIndex
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.
mintPositionNft
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.
mintPositionNftToSender
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.
migrateBoostedPosition
Pass through function to the BP bin migration.
mintBoostedPosition
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.
addLiquidityAndMintBoostedPosition
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.
addLiquidityAndMintBoostedPositionToSender
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.
createBoostedPositionAndAddLiquidityToSender
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.
createBoostedPositionAndAddLiquidity
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.
donateLiquidity
Donates liquidity 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.
createPoolAtPriceAndAddLiquidityToSender
Creates a pool at a specified price and mints a Position NFT with liquidity to msg.sender.
createPoolAtPriceAndAddLiquidity
Creates a pool at a specified price and mints a Position NFT with liquidity to the recipient.
A Maverick V2 pool has no native way 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.
removeLiquidityFromPositionNftAndSweepToSender
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.
removeLiquidityFromBoostedPositionToSender
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.
maverickV2AddLiquidityCallback
Last updated