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.

function addLiquidityByReserves(
    Bin.Instance storage self,
    IMaverickV2Pool.TickState storage tickState,
    uint128 deltaA,
    uint128 deltaB,
    uint128 deltaLpBalance
) internal;

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.

function addLiquidity(
    Bin.Instance storage self,
    IMaverickV2Pool.TickState storage tickState,
    address recipient,
    uint256 subaccount,
    uint128 deltaLpBalance,
    PoolLib.AddLiquidityInfo memory addLiquidityInfo
) internal;

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.

function migrateBinsUpStack(Instance storage self, mapping(uint32 => Instance) storage bins, uint32 maxRecursion)
    internal;

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.

function removeLiquidity(
    Instance storage self,
    mapping(int32 => IMaverickV2Pool.TickState) storage tickStates,
    mapping(uint32 => Instance) storage bins,
    address user,
    uint256 subaccount,
    uint256 deltaLpAmount
) internal returns (IMaverickV2Pool.BinDelta memory binDelta);

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.

function _updateBinState(
    Bin.Instance storage self,
    IMaverickV2Pool.TickState storage tickState,
    address user,
    uint256 subaccount,
    uint128 deltaA,
    uint128 deltaB,
    uint128 deltaLpBalance,
    uint128 deltaTickBalance
) private;

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

struct Instance {
    IMaverickV2Pool.BinState state;
    mapping(address => mapping(uint256 => uint128)) balances;
}

Last updated