Skip to content

@gala-chain/apiAPI


API > Pool

Class: Pool

Contents

Extends

Constructors

new Pool(token0, token1, token0ClassKey, token1ClassKey, fee, initialSqrtPrice, protocolFees)

new Pool(token0, token1, token0ClassKey, token1ClassKey, fee, initialSqrtPrice, protocolFees): Pool

Parameters

token0: string

TokenKey0 used to create a composite key for the pool.

token1: string

TokenKey1 used to create a composite key for the pool.

token0ClassKey: TokenClassKey

Token class key to identify token0.

token1ClassKey: TokenClassKey

Token class key to identify token1.

fee: number

Fee parameter that determines the pool's fee structure and tick spacing.

initialSqrtPrice: BigNumber

Initial square root price for the V3 pool.

protocolFees: number= 0

Returns

Overrides

ChainObject.constructor

Dev

Creates and initializes a new Pool with a given sqrtPrice.

Source

chain-api/src/types/DexV3Pool.ts:140

Properties

bitmap

bitmap: Bitmap

Source

chain-api/src/types/DexV3Pool.ts:98


fee

readonly fee: number

Source

chain-api/src/types/DexV3Pool.ts:82


feeGrowthGlobal0

feeGrowthGlobal0: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:111


feeGrowthGlobal1

feeGrowthGlobal1: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:114


liquidity

liquidity: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:108


maxLiquidityPerTick

maxLiquidityPerTick: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:117


positions

positions: Positions

Source

chain-api/src/types/DexV3Pool.ts:94


protocolFees

protocolFees: number

Source

chain-api/src/types/DexV3Pool.ts:123


protocolFeesToken0

protocolFeesToken0: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:126


protocolFeesToken1

protocolFeesToken1: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:129


sqrtPrice

sqrtPrice: BigNumber

Source

chain-api/src/types/DexV3Pool.ts:105


tickData

tickData: TickDataObj

Source

chain-api/src/types/DexV3Pool.ts:102


tickSpacing

tickSpacing: number

Source

chain-api/src/types/DexV3Pool.ts:120


token0

readonly token0: string

Source

chain-api/src/types/DexV3Pool.ts:74


token0ClassKey

readonly token0ClassKey: TokenClassKey

Source

chain-api/src/types/DexV3Pool.ts:86


token1

readonly token1: string

Source

chain-api/src/types/DexV3Pool.ts:78


token1ClassKey

readonly token1ClassKey: TokenClassKey

Source

chain-api/src/types/DexV3Pool.ts:90


COMPOSITEKEY_NS

static COMPOSITEKEY_NS: string = "\x00"

Inherited from

ChainObject.COMPOSITEKEY_NS

Source

chain-api/src/types/ChainObject.ts:45


ID_SPLIT_CHAR

static ID_SPLIT_CHAR: string = "$"

Inherited from

ChainObject.ID_SPLIT_CHAR

Source

chain-api/src/types/ChainObject.ts:48


ID_SUB_SPLIT_CHAR

static ID_SUB_SPLIT_CHAR: string = "|"

Inherited from

ChainObject.ID_SUB_SPLIT_CHAR

Source

chain-api/src/types/ChainObject.ts:50


INDEX_KEY

static INDEX_KEY: string = "GCDVP"

Source

chain-api/src/types/DexV3Pool.ts:60


MAX_TICK

static MAX_TICK: number = 887272

Source

chain-api/src/types/DexV3Pool.ts:70


MIN_TICK

static MIN_TICK: number = -887272

Source

chain-api/src/types/DexV3Pool.ts:65


MIN_UNICODE_RUNE_VALUE

static MIN_UNICODE_RUNE_VALUE: string = "\u0000"

Inherited from

ChainObject.MIN_UNICODE_RUNE_VALUE

Source

chain-api/src/types/ChainObject.ts:43

Methods

_modifyPosition()

private _modifyPosition(owner, tickLower, tickUpper, liquidityDelta): BigNumber[]

Parameters

owner: string

owner of the position

tickLower: number

lower tick of the position's tick range

tickUpper: number

upper tick of the position's tick range

liquidityDelta: BigNumber

Returns

amount0 the amount of token0 owed to the pool, negative if the pool should pay the recipient

amount1 the amount of token1 owed to the pool, negative if the pool should pay the recipient

Dev

Effect some changes to a position

Source

chain-api/src/types/DexV3Pool.ts:182


_updatePosition()

_updatePosition(owner, tickLower, tickUpper, liquidityDelta, tickCurrent): void

Parameters

owner: string

the owner of the position

tickLower: number

the lower tick of the position's tick range

tickUpper: number

the upper tick of the position's tick range

liquidityDelta: BigNumber

tickCurrent: number

the current tick

Returns

Dev

Gets and updates a position with the given liquidity delta

Source

chain-api/src/types/DexV3Pool.ts:228


burn()

burn(owner, tickLower, tickUpper, amount): BigNumber[]

Parameters

owner: string

tickLower: number

The lower tick of the position for which to burn liquidity

tickUpper: number

The upper tick of the position for which to burn liquidity

amount: BigNumber

How much liquidity to burn

Returns

amount0 The amount of token0 sent to the recipient

amount1 The amount of token1 sent to the recipient

Notice

Burn liquidity from the sender and account tokens owed for the liquidity to the position

Dev

Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0

Dev

Fees must be collected separately via a call to #collect

Source

chain-api/src/types/DexV3Pool.ts:472


collect()

collect(recipient, tickLower, tickUpper, amount0Requested, amount1Requested): BigNumber[]

Parameters

recipient: string

this person will get whose accumulated tokens are to be collected

tickLower: number

The lower tick of the position for which to collect fee accumulated

tickUpper: number

The upper tick of the position for which to collect fee accumulated

amount0Requested: BigNumber

amount0 The amount of token0 sent to be collected by the recipient

amount1Requested: BigNumber

amount1 The amount of token1 sent to be collected by the recipient

Returns

Source

chain-api/src/types/DexV3Pool.ts:562


collectTradingFees()

collectTradingFees(): BigNumber[]

Returns

[protocolFeeToken0,protocolFeesToken1]

Dev

this will bring the state of protocolFeesTokens and reset them to 0

Source

chain-api/src/types/DexV3Pool.ts:546


configureProtocolFee()

configureProtocolFee(protocolFees): number

Parameters

protocolFees: number

Percentage of protocol fees that needs to be deducted

Returns

Dev

this will change the Protocol fee of the pool

Source

chain-api/src/types/DexV3Pool.ts:534


getAmountForLiquidity()

getAmountForLiquidity(amount, tickLower, tickUpper, isToken0): BigNumber[]

Parameters

amount: BigNumber

Amount for which one wants estimation

tickLower: number

The lower tick of the position for which to add liquidity

tickUpper: number

The upper tick of the position for which to add liquidity

isToken0: boolean

Is the amount for token0

Returns

amount0 The amount of token0 are required to add liquidity

amount1 The amount of token1 are required to add liquidity

liquidity The amount of liquidity that it consist of

Dev

It will estimate the tokens required to add liquidity

Source

chain-api/src/types/DexV3Pool.ts:495


getCompositeKey()

getCompositeKey(): string

Inherited from

ChainObject.getCompositeKey

Source

chain-api/src/types/ChainObject.ts:79


getFeeCollectedEstimation()

getFeeCollectedEstimation(recipient, tickLower, tickUpper): BigNumber[]

Parameters

recipient: string

this person will get whose accumulated tokens are to be collected

tickLower: number

The lower tick of the position for which to collect fee accumulated

tickUpper: number

The upper tick of the position for which to collect fee accumulated

Returns

Dev

it will give Estimation for the tokens collected due swaps

Source

chain-api/src/types/DexV3Pool.ts:604


mint()

mint(recipient, tickLower, tickUpper, liquidity): BigNumber[]

Parameters

recipient: string

The address for which the liquidity will be created

tickLower: number

The lower tick of the position in which to add liquidity

tickUpper: number

The upper tick of the position in which to add liquidity

liquidity: BigNumber

The amount of liquidity to mint

Returns

amount0 The amount of token0 that was paid to mint the given amount of liquidity

amount1 The amount of token1 that was paid to mint the given amount of liquidity

Notice

Adds liquidity for the given recipient/tickLower/tickUpper position

Source

chain-api/src/types/DexV3Pool.ts:294


serialize()

serialize(): string

Inherited from

ChainObject.serialize

Source

chain-api/src/types/ChainObject.ts:52


swap()

swap(zeroForOne, amountSpecified, sqrtPriceLimit): [BigNumber, BigNumber]

Parameters

zeroForOne: boolean

The direction of the swap, true for token0 to token1, false for token1 to token0

amountSpecified: BigNumber

The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)

sqrtPriceLimit: BigNumber

sqrt price limit. If zero for one, the price cannot be less than this value after the swap. If one for zero, the price cannot be greater than this value after the swap

Returns

amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive

amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive

Notice

Swap token0 for token1, or token1 for token0

Source

chain-api/src/types/DexV3Pool.ts:311


toPlainObject()

toPlainObject(): Record\<string, unknown>

Inherited from

ChainObject.toPlainObject

Source

chain-api/src/types/ChainObject.ts:68


validate()

validate(): Promise\<ValidationError[]>

Inherited from

ChainObject.validate

Source

chain-api/src/types/ChainObject.ts:56


validateOrReject()

validateOrReject(): Promise\<void>

Inherited from

ChainObject.validateOrReject

Source

chain-api/src/types/ChainObject.ts:60


deserialize()

static deserialize\<T>(constructor, object): T

Type parameters

T

Parameters

constructor: ClassConstructor\<Inferred\<T, ChainObject>>

object: string | Record\<string, unknown> | Record\<string, unknown>[]

Inherited from

ChainObject.deserialize

Source

chain-api/src/types/ChainObject.ts:72


getCompositeKeyFromParts()

static getCompositeKeyFromParts(indexKey, parts): string

Parameters

indexKey: string

parts: unknown[]

Inherited from

ChainObject.getCompositeKeyFromParts

Source

chain-api/src/types/ChainObject.ts:104


getStringKeyFromParts()

static getStringKeyFromParts(parts): string

Parameters

parts: string[]

Inherited from

ChainObject.getStringKeyFromParts

Source

chain-api/src/types/ChainObject.ts:124