LiquidityUtilities

State Variables

MIN_DELTA_RESERVES

uint256 internal constant MIN_DELTA_RESERVES = 100;

Functions

priceIndexFromPriceBreaks

Return index into the price breaks array that corresponds to the current pool price.

Price break array is N elements [e_0, e_1, ..., e_{n-1}].

If price is less than e_0, then 0 is returned, if price is betweeen e_0 and e_1, then 1 is returned, etc. If the price is between e_{n-2} and e_{n-1}, then n-2 is returned. If price is larger than e_{n-1}, then n-1 is returned.

function priceIndexFromPriceBreaks(uint256 sqrtPrice, bytes memory packedSqrtPriceBreaks)
    internal
    pure
    returns (uint256 index);

tokenScales

function tokenScales(IMaverickV2Pool pool) internal view returns (uint256 tokenAScale, uint256 tokenBScale);

deltaReservesFromDeltaLpBalanceAtNewPrice

function deltaReservesFromDeltaLpBalanceAtNewPrice(
    IMaverickV2Pool pool,
    int32 tick,
    uint128 deltaLpBalance,
    uint8 kind,
    uint256 newSqrtPrice
) internal view returns (uint256 deltaA, uint256 deltaB);

deltaReservesFromDeltaLpBalancesAtNewPrice

scaleAddParams

getScaledAddParams

getAddLiquidityParamsFromRelativeBinLpBalance

getAddLiquidityParams

Compute add params for N price breaks around price with max right slippage of p * (1 + f) and max left slippage of p / (1 + f). The user specifies the max A and B they are willing to spend. If the price of the pool does not move, the user will spend exactly this amount. If the price moves left, then the user would like to spend the specified B amount, but will end up spending less A. Conversely, if the price moves right, the user will spend their max A amount, but less B. By having more break points, we make it so that the user gets as much liquidity as possible at the new price. With too few break points, the user will not have bought as much liquidity as they could have.

deltaReservesFromDeltaLiquidity

deltasFromBinLiquidityAmounts

_deltasFromRelativeBinLiquidityAmountsAndTargetAmount

lpBalanceForArrayOfTargetAmountsEmptyPool

lpBalanceForArrayOfTargetAmounts

donateAndSwapData

getCreatePoolParams

emulateExactOut

reservesInTickForGivenPrice

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))

lpBalanceRequiredForTargetReserveAmountsMultiBinTick

lpBalanceRequiredForTargetReserveAmountsOneBinTick

emptyTickLpBalanceRequirement

getBoostedPositionSpec

Errors

LiquidityUtilitiesTargetPriceOutOfBounds

LiquidityUtilitiesTooLittleLiquidity

LiquidityUtilitiesTargetingTokenWithNoDelta

LiquidityUtilitiesNoSwapLiquidity

LiquidityUtilitiesFailedToFindDeltaAmounts

LiquidityUtilitiesInitialTargetBTooSmall

Structs

StateInfo

RelativeLiquidityInput

Last updated