@gala-chain/api ∙ API
API > Pool
Class: Pool
Contents
- Extends
- Constructors
- new Pool(token0, token1, token0ClassKey, token1ClassKey, fee, initialSqrtPrice, protocolFees)
- Properties
- bitmap
- fee
- feeGrowthGlobal0
- feeGrowthGlobal1
- grossPoolLiquidity
- liquidity
- maxLiquidityPerTick
- protocolFees
- protocolFeesToken0
- protocolFeesToken1
- sqrtPrice
- tickSpacing
- token0
- token0ClassKey
- token1
- token1ClassKey
- COMPOSITEKEY_NS
- ID_SPLIT_CHAR
- ID_SUB_SPLIT_CHAR
- INDEX_KEY
- MIN_UNICODE_RUNE_VALUE
- Methods
- _modifyPosition()
- _updatePosition()
- burn()
- burnEstimate()
- collect()
- collectProtocolFees()
- configureProtocolFee()
- genPoolHash()
- getAmountForLiquidity()
- getCompositeKey()
- getFeeCollectedEstimation()
- getPoolAlias()
- mint()
- serialize()
- swap()
- toPlainObject()
- validate()
- validateOrReject()
- decodeFromBase58()
- deserialize()
- encodeToBase58()
- getCompositeKeyFromParts()
- getEncodableStringKeyFromParts()
- getPartsFromEncodableStringKey()
- getStringKeyFromParts()
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: DexFeePercentageTypes
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
Dev
Creates and initializes a new Pool with a given sqrtPrice.
Source
chain-api/src/types/DexV3Pool.ts:120
Properties
bitmap
bitmap:
Record\<string,string>
Source
chain-api/src/types/DexV3Pool.ts:78
fee
readonlyfee:DexFeePercentageTypes
Source
chain-api/src/types/DexV3Pool.ts:63
feeGrowthGlobal0
feeGrowthGlobal0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:91
feeGrowthGlobal1
feeGrowthGlobal1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:94
grossPoolLiquidity
grossPoolLiquidity:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:88
liquidity
liquidity:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:84
maxLiquidityPerTick
maxLiquidityPerTick:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:97
protocolFees
protocolFees:
number
Source
chain-api/src/types/DexV3Pool.ts:103
protocolFeesToken0
protocolFeesToken0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:106
protocolFeesToken1
protocolFeesToken1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:109
sqrtPrice
sqrtPrice:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:81
tickSpacing
tickSpacing:
number
Source
chain-api/src/types/DexV3Pool.ts:100
token0
readonlytoken0:string
Source
chain-api/src/types/DexV3Pool.ts:55
token0ClassKey
readonlytoken0ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:67
token1
readonlytoken1:string
Source
chain-api/src/types/DexV3Pool.ts:59
token1ClassKey
readonlytoken1ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:71
COMPOSITEKEY_NS
staticCOMPOSITEKEY_NS:string="\x00"
Inherited from
Source
chain-api/src/types/ChainObject.ts:46
ID_SPLIT_CHAR
staticID_SPLIT_CHAR:string="$"
Inherited from
Source
chain-api/src/types/ChainObject.ts:49
ID_SUB_SPLIT_CHAR
staticID_SUB_SPLIT_CHAR:string="|"
Inherited from
Source
chain-api/src/types/ChainObject.ts:51
INDEX_KEY
staticINDEX_KEY:string="GCDEXCHP"
Source
chain-api/src/types/DexV3Pool.ts:51
MIN_UNICODE_RUNE_VALUE
staticMIN_UNICODE_RUNE_VALUE:string="\u0000"
Inherited from
ChainObject.MIN_UNICODE_RUNE_VALUE
Source
chain-api/src/types/ChainObject.ts:44
Methods
_modifyPosition()
private_modifyPosition(position,tickLowerData,tickUpperData,liquidityDelta):BigNumber[]
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
The tick data of the lower tick of the position's tick range
▪ tickUpperData: TickData
The tick data of the 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:162
_updatePosition()
_updatePosition(
position,tickLowerData,tickUpperData,liquidityDelta,tickCurrent):void
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
the tick data of the lower tick of the position's tick range
▪ tickUpperData: TickData
the tick data of 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:214
burn()
burn(
position,tickLowerData,tickUpperData,amount):BigNumber[]
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
The tick data of the lower tick of the position for which to burn liquidity
▪ tickUpperData: TickData
The tick data of 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:293
burnEstimate()
burnEstimate(
liquidityDelta,tickLower,tickUpper): [BigNumber,BigNumber]
Estimates the amount of token0 and token1 required to burn a given liquidity amount within a specified tick range.
Parameters
▪ liquidityDelta: BigNumber
The amount of liquidity to be removed (burned).
▪ tickLower: number
▪ tickUpper: number
Returns
A tuple containing: - amount0Req: The estimated amount of token0 to be burned. - amount1Req: The estimated amount of token1 to be burned.
Source
chain-api/src/types/DexV3Pool.ts:487
collect()
collect(
position,tickLowerData,tickUpperData,amount0Requested,amount1Requested):BigNumber[]
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
The tick data of the lower tick of the position for which to collect fee accumulated
▪ tickUpperData: TickData
The tick data of 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:389
collectProtocolFees()
collectProtocolFees():
BigNumber[]
Returns
[protocolFeeToken0,protocolFeesToken1]
Dev
this will bring the state of protocolFeesTokens and reset them to 0
Source
chain-api/src/types/DexV3Pool.ts:373
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:361
genPoolHash()
genPoolHash():
string
Returns
poolHash
Dev
returns a hash that is unique to this pool
Source
chain-api/src/types/DexV3Pool.ts:463
getAmountForLiquidity()
getAmountForLiquidity(
amount,tickLower,tickUpper,isToken0):BigNumber[]
Parameters
▪ amount: BigNumber
Amount for which one wants estimation
▪ tickLower: number
▪ tickUpper: number
▪ 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:322
getCompositeKey()
getCompositeKey():
string
Inherited from
Source
chain-api/src/types/ChainObject.ts:80
getFeeCollectedEstimation()
getFeeCollectedEstimation(
position,tickLowerData,tickUpperData):BigNumber[]
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
The tick data of the lower tick of the position for which to collect fee accumulated
▪ tickUpperData: TickData
The tick data of the upper tick of the position for which to collect fee accumulated
Returns
the amount of tokens that this position have accumulated as its fees
Dev
it will give Estimation for the tokens collected due swaps
Source
chain-api/src/types/DexV3Pool.ts:429
getPoolAlias()
getPoolAlias():
string
Returns
poolAlias
Dev
returns service address which holds the pool's liquidity
Source
chain-api/src/types/DexV3Pool.ts:472
mint()
mint(
position,tickLowerData,tickUpperData,liquidity):BigNumber[]
Parameters
▪ position: DexPositionData
The Dex position that is being updated here
▪ tickLowerData: TickData
The tick data of the lower tick of the position in which to add liquidity
▪ tickUpperData: TickData
The tick data of 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:269
serialize()
serialize():
string
Inherited from
Source
chain-api/src/types/ChainObject.ts:53
swap()
swap(
zeroForOne,state,amountSpecified): [BigNumber,BigNumber]
Performs a swap based on the specified amount and direction, updating global state.
Parameters
▪ zeroForOne: boolean
Boolean indicating the swap direction (true for token0 -> token1, false for token1 -> token0).
▪ state: SwapState
The current state of the swap, including price, liquidity, fee growth, and protocol fees.
▪ amountSpecified: BigNumber
The amount specified for the swap.
Returns
A tuple of [amount0, amount1] representing the swap amounts for token0 and token1.
Source
chain-api/src/types/DexV3Pool.ts:521
toPlainObject()
toPlainObject():
Record\<string,unknown>
Inherited from
Source
chain-api/src/types/ChainObject.ts:69
validate()
validate():
Promise\<ValidationError[]>
Inherited from
Source
chain-api/src/types/ChainObject.ts:57
validateOrReject()
validateOrReject():
Promise\<void>
Inherited from
Source
chain-api/src/types/ChainObject.ts:61
decodeFromBase58()
staticdecodeFromBase58(base58String):string
Parameters
▪ base58String: string
Inherited from
Source
chain-api/src/types/ChainObject.ts:142
deserialize()
staticdeserialize\<T>(constructor,object):T
Type parameters
▪ T
Parameters
▪ constructor: ClassConstructor\<Inferred\<T, ChainObject>>
▪ object: string | Record\<string, unknown> | Record\<string, unknown>[]
Inherited from
Source
chain-api/src/types/ChainObject.ts:73
encodeToBase58()
staticencodeToBase58(stringKey):string
Parameters
▪ stringKey: string
Inherited from
Source
chain-api/src/types/ChainObject.ts:137
getCompositeKeyFromParts()
staticgetCompositeKeyFromParts(indexKey,parts):string
Parameters
▪ indexKey: string
▪ parts: unknown[]
Inherited from
ChainObject.getCompositeKeyFromParts
Source
chain-api/src/types/ChainObject.ts:105
getEncodableStringKeyFromParts()
staticgetEncodableStringKeyFromParts(parts):string
Parameters
▪ parts: string[]
Inherited from
ChainObject.getEncodableStringKeyFromParts
Source
chain-api/src/types/ChainObject.ts:129
getPartsFromEncodableStringKey()
staticgetPartsFromEncodableStringKey(stringKey):string[]
Parameters
▪ stringKey: string
Inherited from
ChainObject.getPartsFromEncodableStringKey
Source
chain-api/src/types/ChainObject.ts:133
getStringKeyFromParts()
staticgetStringKeyFromParts(parts):string
Parameters
▪ parts: string[]
Inherited from
ChainObject.getStringKeyFromParts