Skip to main content

Pool

Structure of Pool

Each pool has following structure:

pub struct Pool {
pub token_x: Pubkey,
pub token_y: Pubkey,
pub token_x_reserve: Pubkey,
pub token_y_reserve: Pubkey,
pub position_iterator: u128,
pub tick_spacing: u16,
pub fee: FixedPoint,
pub protocol_fee: FixedPoint,
pub liquidity: Liquidity,
pub sqrt_price: Price,
pub current_tick_index: i32,
pub tickmap: Pubkey,
pub fee_growth_global_x: FeeGrowth,
pub fee_growth_global_y: FeeGrowth,
pub fee_protocol_token_x: u64,
pub fee_protocol_token_y: u64,
pub seconds_per_liquidity_global: FixedPoint,
pub start_timestamp: u64,
pub last_timestamp: u64,
pub fee_receiver: Pubkey,
pub oracle_address: Pubkey,
pub oracle_initialized: bool,
pub bump: u8,
}
NameTypeDescription
token_xPubkeyAddress of token_x.
token_yPubkeyAddress of token_y.
token_x_reservePubkeyAccount on token_x controlled by Authority.
token_y_reservePubkeyAccount on token_y controlled by Authority.
position_iteratoru128Unique ID of each position in current pool.
tick_spacingu16The spacing between usable ticks.
feeFixedPointPercentage of the fee collected upon every swap in the pool.
protocol_feeFixedPointPercentage of the protocol fee collected upon every swap in the pool.
liquidityLiquidityAmount of virtual liquidity that the position represented the last time this position was touched. The difference between virtual and actual liquidity reflect the increased capital efficiency in Invariant.
sqrt_pricePriceSquare root of current price.
current_tick_indexi32The nearest tick below the current price.
tickmapPubkeyAddress of the tick map.
fee_growth_global_xFeeGrowthAmount of fees accumulated in token_x in per one integer unit of Liquidity.
fee_growth_global_yFeeGrowthAmount of fees accumulated in token_y in per one integer unit of Liquidity.
fee_protocol_token_xu64Amount of protocol fees accumulated in token_x in per one integer unit of Liquidity.
fee_protocol_token_yu64Amount of protocol fees accumulated in token_y in per one integer unit of Liquidity.
seconds_per_liquidity_globalFixedPointCumulative seconds per liquidity-in-range value.
start_timestampu64Time of initialization.
last_timestampu64Last update.
fee_receiverPubkeyAddress of entity enabling to claim protocol fee. By default it's admin but can be change for specific pool.
oracle_addressPubkeyAddress of oracle records.
oracle_initializedboolIs oracle set for Pool.
bumpu8Seed used to ensure the generated address doesn't collide with any other existing one.

Using above props there could be created Pool with different method mentioned in introduction:

  createPoolTx(props:createPoolVars)

createPool(props: createPoolVars)
  initPoolAndPositionTx(props, signer: PublicKey)

initPoolAndPosition(props: InitPoolAndPosition, signer: PublicKey)