Skip to main content

LiquidityChunkLibrary

Git Source

Author: Axicon Labs Limited

A liquidity chunk is an amount of liquidity deployed between two ticks: tickLower and tickUpper into a concentrated liquidity AMM.

State Variables

CLEAR_TL_MASK

AND mask to strip the tickLower value from a packed LiquidityChunk.

uint256 internal constant CLEAR_TL_MASK = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

CLEAR_TU_MASK

AND mask to strip the tickUpper value from a packed LiquidityChunk.

uint256 internal constant CLEAR_TU_MASK = 0xFFFFFF000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;

Functions

createChunk

Create a new LiquidityChunk given by its bounding ticks and its liquidity.

function createChunk(int24 _tickLower, int24 _tickUpper, uint128 amount) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
_tickLowerint24The lower tick of the chunk
_tickUpperint24The upper tick of the chunk
amountuint128The amount of liquidity to add to the chunk

Returns

NameTypeDescription
<none>LiquidityChunkThe new chunk with the given liquidity and tick range

addLiquidity

Add liquidity to self.

function addLiquidity(LiquidityChunk self, uint128 amount) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to add liquidity to
amountuint128The amount of liquidity to add to self

Returns

NameTypeDescription
<none>LiquidityChunkself with added liquidity amount

addTickLower

Add the lower tick to self.

function addTickLower(LiquidityChunk self, int24 _tickLower) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to add the lower tick to
_tickLowerint24The lower tick to add to self

Returns

NameTypeDescription
<none>LiquidityChunkself with added lower tick _tickLower

addTickUpper

Add the upper tick to self.

function addTickUpper(LiquidityChunk self, int24 _tickUpper) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to add the upper tick to
_tickUpperint24The upper tick to add to self

Returns

NameTypeDescription
<none>LiquidityChunkself with added upper tick _tickUpper

updateTickLower

Overwrites the lower tick on self.

function updateTickLower(LiquidityChunk self, int24 _tickLower) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to overwrite the lower tick on
_tickLowerint24The lower tick to overwrite self with

Returns

NameTypeDescription
<none>LiquidityChunkself with _tickLower as the new lower tick

updateTickUpper

Overwrites the upper tick on self.

function updateTickUpper(LiquidityChunk self, int24 _tickUpper) internal pure returns (LiquidityChunk);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to overwrite the upper tick on
_tickUpperint24The upper tick to overwrite self with

Returns

NameTypeDescription
<none>LiquidityChunkself with _tickUpper as the new upper tick

tickLower

Get the lower tick of self.

function tickLower(LiquidityChunk self) internal pure returns (int24);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to get the lower tick from

Returns

NameTypeDescription
<none>int24The lower tick of self

tickUpper

Get the upper tick of self.

function tickUpper(LiquidityChunk self) internal pure returns (int24);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to get the upper tick from

Returns

NameTypeDescription
<none>int24The upper tick of self

liquidity

Get the amount of liquidity/size of self.

function liquidity(LiquidityChunk self) internal pure returns (uint128);

Parameters

NameTypeDescription
selfLiquidityChunkThe LiquidityChunk to get the liquidity from

Returns

NameTypeDescription
<none>uint128The liquidity of self