IMaverickV2Pool
Functions
kinds
1-15 number to represent the active kinds. 0b0001 = static; 0b0010 = right; 0b0100 = left; 0b1000 = both; E.g. a pool with all 4 modes will have kinds = b1111 = 15
fee
Pool swap fee for the given direction (A-in or B-in swap) in 18-decimal format. E.g. 0.01e18 is a 1% swap fee.
tickSpacing
TickSpacing of pool where 1.0001^tickSpacing is the bin width.
lookback
Lookback period of pool in seconds.
accessor
Address of Pool accessor. This is Zero address for permissionless pools.
tokenA
Pool tokenA. Address of tokenA is such that tokenA < tokenB.
tokenB
Pool tokenB.
factory
Deploying factory of the pool and also contract that has ability to set and collect protocol fees for the pool.
tokenAScale
Most significant bit of scale value is a flag to indicate whether tokenA has more or less than 18 decimals. Scale is used in conjuction with Math.toScale/Math.fromScale functions to convert from token amounts to D18 scale internal pool accounting.
tokenBScale
Most significant bit of scale value is a flag to indicate whether tokenA has more or less than 18 decimals. Scale is used in conjuction with Math.toScale/Math.fromScale functions to convert from token amounts to D18 scale internal pool accounting.
binIdByTickKind
ID of bin at input tick position and kind.
protocolFeeA
Accumulated tokenA protocol fee.
protocolFeeB
Accumulated tokenB protocol fee.
lendingFeeRateD18
Lending fee rate on flash loans.
getCurrentTwa
External function to get the current time-weighted average price.
getState
External function to get the state of the pool.
getBin
Return state of Bin at input binId.
getTick
Return state of Tick at input tick position.
balanceOf
Retrieves the balance of a user within a bin.
Parameters
addLiquidity
Add liquidity to a pool. This function allows users to deposit tokens into a liquidity pool.
This function will call maverickV2AddLiquidityCallback
on the calling contract to collect the tokenA/tokenB payment.
Parameters
Returns
removeLiquidity
Removes liquidity from the pool.
Liquidity can only be removed from a bin that is either unmerged or has a mergeId of an unmerged bin. If a bin is merged more than one level deep, it must be migrated up the merge stack to the root bin before liquidity removal.
Parameters
Returns
migrateBinUpStack
Migrate bins up the linked list of merged bins so that its mergeId is the currrent active bin.
Liquidity can only be removed from a bin that is either unmerged or has a mergeId of an unmerged bin. If a bin is merged more than one level deep, it must be migrated up the merge stack to the root bin before liquidity removal.
Parameters
swap
Swap tokenA/tokenB assets in the pool. The swap user has two options for funding their swap.
The user can push the input token amount to the pool before calling the swap function. In order to avoid having the pool call the callback, the user should pass a zero-length
data
bytes object with the swap call.The user can send the input token amount to the pool when the pool calls the
maverickV2SwapCallback
function on the calling contract. That callback has input parameters that specify the token address of the input token, the input and output amounts, and the bytes data sent to the swap function.
If the users elects to do a callback-based swap, the output assets will be sent before the callback is called, allowing the user to execute flash swaps. However, the pool does have reentrancy protection, so a swapper will not be able to interact with the same pool again while they are in the callback function.
Parameters
flashLoan
Loan tokenA/tokenB assets from the pool to recipient. The fee rate of a loan is determined by lendingFeeRateD18
, which is set at the protocol level by the factory. This function calls maverickV2FlashLoanCallback
on the calling contract. At the end of the callback, the caller must pay back the loan with fee (if there is a fee).
Parameters
setFee
Sets fee for permissioned pools. May only be called by the accessor.
Events
PoolSwap
PoolAddLiquidity
PoolMigrateBinsUpStack
PoolRemoveLiquidity
PoolSetVariableFee
Errors
PoolZeroLiquidityAdded
PoolMinimumLiquidityNotMet
PoolLocked
PoolInvalidInput
PoolInsufficientBalance
PoolReservesExceedMaximum
PoolValueExceedsBits
PoolTickMaxExceeded
PoolMigrateBinFirst
PoolCurrentTickBeyondSwapLimit
PoolSenderNotAccessor
PoolSenderNotFactory
PoolFunctionNotImplemented
PoolTokenNotSolvent
Structs
TickState
Tick state parameters.
TickData
Tick data parameters.
Properties
BinState
Bin state parameters.
Properties
SwapParams
Parameters for swap.
Properties
AddLiquidityParams
Parameters associated with adding liquidity.
Properties
RemoveLiquidityParams
Parameters for each bin that will have liquidity removed.
Properties
State
State of the pool.
Properties
BinDelta
Internal data used for data passing between Pool and Bin code.
Last updated