@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
- MIN_UNICODE_RUNE_VALUE
- Methods
- _modifyPosition()
- _updatePosition()
- burn()
- collect()
- collectProtocolFees()
- configureProtocolFee()
- getAmountForLiquidity()
- getCompositeKey()
- mint()
- serialize()
- swap()
- toPlainObject()
- validate()
- validateOrReject()
- deserialize()
- getCompositeKeyFromParts()
- 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: 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
Dev
Creates and initializes a new Pool with a given sqrtPrice.
Source
chain-api/src/types/DexV3Pool.ts:128
Properties
bitmap
bitmap:
Bitmap
Source
chain-api/src/types/DexV3Pool.ts:86
fee
readonly
fee:number
Source
chain-api/src/types/DexV3Pool.ts:70
feeGrowthGlobal0
feeGrowthGlobal0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:99
feeGrowthGlobal1
feeGrowthGlobal1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:102
liquidity
liquidity:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:96
maxLiquidityPerTick
maxLiquidityPerTick:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:105
positions
positions:
Positions
Source
chain-api/src/types/DexV3Pool.ts:82
protocolFees
protocolFees:
number
Source
chain-api/src/types/DexV3Pool.ts:111
protocolFeesToken0
protocolFeesToken0:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:114
protocolFeesToken1
protocolFeesToken1:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:117
sqrtPrice
sqrtPrice:
BigNumber
Source
chain-api/src/types/DexV3Pool.ts:93
tickData
tickData:
TickDataObj
Source
chain-api/src/types/DexV3Pool.ts:90
tickSpacing
tickSpacing:
number
Source
chain-api/src/types/DexV3Pool.ts:108
token0
readonly
token0:string
Source
chain-api/src/types/DexV3Pool.ts:62
token0ClassKey
readonly
token0ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:74
token1
readonly
token1:string
Source
chain-api/src/types/DexV3Pool.ts:66
token1ClassKey
readonly
token1ClassKey:TokenClassKey
Source
chain-api/src/types/DexV3Pool.ts:78
COMPOSITEKEY_NS
static
COMPOSITEKEY_NS:string
="\x00"
Inherited from
Source
chain-api/src/types/ChainObject.ts:45
ID_SPLIT_CHAR
static
ID_SPLIT_CHAR:string
="$"
Inherited from
Source
chain-api/src/types/ChainObject.ts:48
ID_SUB_SPLIT_CHAR
static
ID_SUB_SPLIT_CHAR:string
="|"
Inherited from
Source
chain-api/src/types/ChainObject.ts:50
INDEX_KEY
static
INDEX_KEY:string
="GCDVP"
Source
chain-api/src/types/DexV3Pool.ts:58
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:170
_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:216
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:458
collect()
collect(
recipient
,tickLower
,tickUpper
,amount0Requested
,amount1Requested
): [BigNumber
,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
Notice
It will Collect the fee accumulated on the user liquidity
Source
chain-api/src/types/DexV3Pool.ts:480
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:566
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:554
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:515
getCompositeKey()
getCompositeKey():
string
Inherited from
Source
chain-api/src/types/ChainObject.ts:79
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:282
serialize()
serialize():
string
Inherited from
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:299
toPlainObject()
toPlainObject():
Record
\<string
,unknown
>
Inherited from
Source
chain-api/src/types/ChainObject.ts:68
validate()
validate():
Promise
\<ValidationError
[]>
Inherited from
Source
chain-api/src/types/ChainObject.ts:56
validateOrReject()
validateOrReject():
Promise
\<void
>
Inherited from
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
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