@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
- liquidity
- maxLiquidityPerTick
- positions
- protocolFees
- protocolFeesToken0
- protocolFeesToken1
- sqrtPrice
- tickData
- tickSpacing
- token0
- token0ClassKey
- token1
- token1ClassKey
- COMPOSITEKEY_NS
- ID_SPLIT_CHAR
- ID_SUB_SPLIT_CHAR
- INDEX_KEY
- MAX_TICK
- MIN_TICK
- MIN_UNICODE_RUNE_VALUE
- Methods
- _modifyPosition()
- _updatePosition()
- burn()
- burnEstimate()
- collect()
- collectTradingFees()
- configureProtocolFee()
- getAmountForLiquidity()
- getCompositeKey()
- getFeeCollectedEstimation()
- getPoolAddrKey()
- 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:143
Properties
bitmap
bitmap:
Bitmap
Source
chain-api/src/types/DexV3Pool.ts:101
fee
readonly
fee:DexFeePercentageTypes
Source
chain-api/src/types/DexV3Pool.ts:85
feeGrowthGlobal0
feeGrowthGlobal0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:114
feeGrowthGlobal1
feeGrowthGlobal1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:117
liquidity
liquidity:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:111
maxLiquidityPerTick
maxLiquidityPerTick:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:120
positions
positions:
Positions
Source
chain-api/src/types/DexV3Pool.ts:97
protocolFees
protocolFees:
number
Source
chain-api/src/types/DexV3Pool.ts:126
protocolFeesToken0
protocolFeesToken0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:129
protocolFeesToken1
protocolFeesToken1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:132
sqrtPrice
sqrtPrice:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:108
tickData
tickData:
TickDataObj
Source
chain-api/src/types/DexV3Pool.ts:105
tickSpacing
tickSpacing:
number
Source
chain-api/src/types/DexV3Pool.ts:123
token0
readonly
token0:string
Source
chain-api/src/types/DexV3Pool.ts:77
token0ClassKey
readonly
token0ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:89
token1
readonly
token1:string
Source
chain-api/src/types/DexV3Pool.ts:81
token1ClassKey
readonly
token1ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:93
COMPOSITEKEY_NS
static
COMPOSITEKEY_NS:string
="\x00"
Inherited from
Source
chain-api/src/types/ChainObject.ts:46
ID_SPLIT_CHAR
static
ID_SPLIT_CHAR:string
="$"
Inherited from
Source
chain-api/src/types/ChainObject.ts:49
ID_SUB_SPLIT_CHAR
static
ID_SUB_SPLIT_CHAR:string
="|"
Inherited from
Source
chain-api/src/types/ChainObject.ts:51
INDEX_KEY
static
INDEX_KEY:string
="GCDVP"
Source
chain-api/src/types/DexV3Pool.ts:63
MAX_TICK
static
MAX_TICK:number
=887272
Source
chain-api/src/types/DexV3Pool.ts:73
MIN_TICK
static
MIN_TICK:number
=-887272
Source
chain-api/src/types/DexV3Pool.ts:68
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:44
Methods
_modifyPosition()
private
_modifyPosition(nftId
,tickLower
,tickUpper
,liquidityDelta
):BigNumber
[]
Parameters
▪ nftId: string
nftId that represents this 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:185
_updatePosition()
_updatePosition(
nftId
,tickLower
,tickUpper
,liquidityDelta
,tickCurrent
):void
Parameters
▪ nftId: string
nftId that represents this 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:231
burn()
burn(
nftId
,tickLower
,tickUpper
,amount
):BigNumber
[]
Parameters
▪ nftId: 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:475
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
The lower tick boundary of the burn range.
▪ tickUpper: number
The upper tick boundary of the burn range.
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:658
collect()
collect(
nftId
,tickLower
,tickUpper
,amount0Requested
,amount1Requested
):BigNumber
[]
Parameters
▪ nftId: string
▪ 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:563
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:547
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:535
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:496
getCompositeKey()
getCompositeKey():
string
Inherited from
Source
chain-api/src/types/ChainObject.ts:80
getFeeCollectedEstimation()
getFeeCollectedEstimation(
nftId
,tickLower
,tickUpper
):BigNumber
[]
Parameters
▪ nftId: string
▪ 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:603
getPoolAddrKey()
getPoolAddrKey():
string
Returns
poolAddrKey which uniquely identifies this pool
Dev
returns unique address key of this pool
Source
chain-api/src/types/DexV3Pool.ts:635
getPoolAlias()
getPoolAlias():
string
Returns
poolVirtualAddress
Dev
returns service address which holds the pool's liquidity
Source
chain-api/src/types/DexV3Pool.ts:643
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:297
serialize()
serialize():
string
Inherited from
Source
chain-api/src/types/ChainObject.ts:53
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:314
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()
static
decodeFromBase58(base58String
):string
Parameters
▪ base58String: string
Inherited from
Source
chain-api/src/types/ChainObject.ts:142
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
Source
chain-api/src/types/ChainObject.ts:73
encodeToBase58()
static
encodeToBase58(stringKey
):string
Parameters
▪ stringKey: string
Inherited from
Source
chain-api/src/types/ChainObject.ts:137
getCompositeKeyFromParts()
static
getCompositeKeyFromParts(indexKey
,parts
):string
Parameters
▪ indexKey: string
▪ parts: unknown
[]
Inherited from
ChainObject
.getCompositeKeyFromParts
Source
chain-api/src/types/ChainObject.ts:105
getEncodableStringKeyFromParts()
static
getEncodableStringKeyFromParts(parts
):string
Parameters
▪ parts: string
[]
Inherited from
ChainObject
.getEncodableStringKeyFromParts
Source
chain-api/src/types/ChainObject.ts:129
getPartsFromEncodableStringKey()
static
getPartsFromEncodableStringKey(stringKey
):string
[]
Parameters
▪ stringKey: string
Inherited from
ChainObject
.getPartsFromEncodableStringKey
Source
chain-api/src/types/ChainObject.ts:133
getStringKeyFromParts()
static
getStringKeyFromParts(parts
):string
Parameters
▪ parts: string
[]
Inherited from
ChainObject
.getStringKeyFromParts