PoolLib

Functions

uniqueOrderedTicksCheck

Check to ensure that the ticks are in ascending order and amount array is same length as tick array.

function uniqueOrderedTicksCheck(int32[] memory ticks, uint256 amountsLength) internal pure;

Parameters

binReserves

Compute bin reserves assuming the bin is not merged; not accurate reflection of reserves for merged bins.

function binReserves(IMaverickV2Pool.BinState storage bin, IMaverickV2Pool.TickState memory tick)
    internal
    view
    returns (uint128 reserveA, uint128 reserveB);

Parameters

Returns

binReserves

Compute bin reserves assuming the bin is not merged; not accurate reflection of reserves for merged bins.

function binReserves(uint128 tickBalance, uint128 tickReserveA, uint128 tickReserveB, uint128 tickTotalSupply)
    internal
    pure
    returns (uint128 reserveA, uint128 reserveB);

Parameters

reserveValue

Reserves of a bin in a tick.

function reserveValue(uint128 tickReserve, uint128 tickBalance, uint128 tickTotalSupply)
    internal
    pure
    returns (uint128 reserve);

Parameters

deltaTickBalanceFromDeltaLpBalance

Calculate delta A, delta B, and delta Tick Balance based on delta LP balance and the Tick/Bin state.

function deltaTickBalanceFromDeltaLpBalance(
    uint256 binTickBalance,
    uint256 binTotalSupply,
    IMaverickV2Pool.TickState memory tickState,
    uint128 deltaLpBalance,
    AddLiquidityInfo memory addLiquidityInfo
) internal pure returns (uint256 deltaTickBalance);

_setRequiredDeltaReservesForEmptyTick

Calculates deltaA = liquidity * (sqrt(upper) - sqrt(lower))

Calculates deltaB = liquidity / sqrt(lower) - liquidity / sqrt(upper),

i.e., liquidity * (sqrt(upper) - sqrt(lower)) / (sqrt(upper) * sqrt(lower))

we set liquidity = deltaLpBalance / (1.0001^(tick * tickspacing) - 1)

which simplifies the A/B amounts to:

deltaA = deltaLpBalance * sqrt(lower)

deltaB = deltaLpBalance / sqrt(upper)

function _setRequiredDeltaReservesForEmptyTick(uint128 deltaLpBalance, AddLiquidityInfo memory addLiquidityInfo)
    internal
    pure;

Structs

AddLiquidityInfo

struct AddLiquidityInfo {
    uint256 deltaA;
    uint256 deltaB;
    bool tickLtActive;
    uint256 tickSpacing;
    int32 tick;
}

Last updated