Bin

Functions

lpBalancesFromDeltaReserve

Calculate pro rata liquidity balances based on delta reserves.

function lpBalancesFromDeltaReserve(
    Bin.Instance storage self,
    IMaverickV2Pool.TickState storage tickState,
    uint256 deltaA,
    uint256 deltaB
) internal view returns (uint256 proRataLiquidity);

Parameters

Name
Type
Description

self

Bin.Instance

The Bin.Instance storage.

tickState

IMaverickV2Pool.TickState

The TickState storage.

deltaA

uint256

The change in A (token A) reserves.

deltaB

uint256

The change in B (token B) reserves.

Returns

Name
Type
Description

proRataLiquidity

uint256

The pro rata liquidity balance.

addLiquidityByReserves

Add liquidity to the bin based on delta reserves.

Parameters

Name
Type
Description

self

Bin.Instance

The Bin.Instance storage.

tickState

IMaverickV2Pool.TickState

The TickState storage.

deltaA

uint128

The change in A (token A) reserves.

deltaB

uint128

The change in B (token B) reserves.

deltaLpBalance

uint128

addLiquidity

Add liquidity to the bin. note: lp balance is not the same a "liquidity"; as fees accumulate in a bin, a unit of lp balance will diverge from a unit of liquidity.

Parameters

Name
Type
Description

self

Bin.Instance

The Bin.Instance storage.

tickState

IMaverickV2Pool.TickState

The TickState storage.

recipient

address

The recipient address.

subaccount

uint256

The subaccount.

deltaLpBalance

uint128

The change in LP balance.

addLiquidityInfo

PoolLib.AddLiquidityInfo

The AddLiquidityInfo structure.

Migrate bins up the stack.

Parameters

Name
Type
Description

self

Instance

The Instance storage.

bins

mapping(uint32 => Instance)

The bins mapping.

maxRecursion

uint32

The maximum recursion depth.

removeLiquidity

Remove liquidity from the bin.

Parameters

Name
Type
Description

self

Instance

The Instance storage.

tickStates

mapping(int32 => IMaverickV2Pool.TickState)

The TickState mapping.

bins

mapping(uint32 => Instance)

The bins mapping.

user

address

The user address.

subaccount

uint256

The subaccount.

deltaLpAmount

uint256

The change in LP balance.

Returns

Name
Type
Description

binDelta

IMaverickV2Pool.BinDelta

The BinDelta structure.

_updateBinState

Updates the state of a bin and tick in the MaverickV2Pool.

Parameters

Name
Type
Description

self

Bin.Instance

The bin instance to be updated.

tickState

IMaverickV2Pool.TickState

The tick state of the pool.

user

address

The address of the user performing the action.

subaccount

uint256

The subaccount identifier for the user.

deltaA

uint128

The change in reserveA.

deltaB

uint128

The change in reserveB.

deltaLpBalance

uint128

The change in LP token balance.

deltaTickBalance

uint128

The change in tick balance.

Structs

Instance

Last updated