#[repr(packed)]
pub struct PoolState {
Show 16 fields pub bump: u8, pub token_0: Pubkey, pub token_1: Pubkey, pub fee: u32, pub tick_spacing: u16, pub liquidity: u64, pub sqrt_price_x32: u64, pub tick: i32, pub observation_index: u16, pub observation_cardinality: u16, pub observation_cardinality_next: u16, pub fee_growth_global_0_x32: u64, pub fee_growth_global_1_x32: u64, pub protocol_fees_token_0: u64, pub protocol_fees_token_1: u64, pub unlocked: bool,
}
Expand description

The pool state

PDA of [POOL_SEED, token_0, token_1, fee]

Fields

bump: u8

Bump to identify PDA

token_0: Pubkey

Token pair of the pool, where token_0 address < token_1 address

token_1: Pubkeyfee: u32

Fee amount for swaps, denominated in hundredths of a bip (i.e. 1e-6)

tick_spacing: u16

The minimum number of ticks between initialized ticks

liquidity: u64

The currently in range liquidity available to the pool. This value has no relationship to the total liquidity across all ticks.

sqrt_price_x32: u64

The current price of the pool as a sqrt(token_1/token_0) Q32.32 value

tick: i32

The current tick of the pool, i.e. according to the last tick transition that was run. This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick boundary. Not necessarily a multiple of tick_spacing.

observation_index: u16

the most-recently updated index of the observations array

observation_cardinality: u16

the current maximum number of observations that are being stored

observation_cardinality_next: u16

The next maximum number of observations to store, triggered on a swap or position update

fee_growth_global_0_x32: u64

The fee growth as a Q32.32 number, i.e. fees of token_0 and token_1 collected per unit of liquidity for the entire life of the pool. These values can overflow u64

fee_growth_global_1_x32: u64protocol_fees_token_0: u64

The amounts of token_0 and token_1 that are owed to the protocol. Protocol fees will never exceed u64::MAX in either token

protocol_fees_token_1: u64unlocked: bool

Whether the pool is currently locked to reentrancy

Implementations

Returns the observation index after the currently active one in a liquidity pool

Arguments
  • self - A pool account

Validates the public key of an observation account

Arguments
  • self- The pool to which the account belongs
  • key - The address to validated
  • bump - The PDA bump for the address
  • next - Whether to validate the current observation account or the next account

Validates the public key of a tick account

Arguments
  • self- The pool to which the account belongs
  • key - The address to validated
  • bump - The PDA bump for the address
  • tick - The tick from which the address should be derived

Validates the public key of a bitmap account

Arguments
  • self- The pool to which the account belongs
  • key - The address to validated
  • bump - The PDA bump for the address
  • tick - The tick from which the address should be derived

Validates the public key of a bitmap account

Arguments
  • self- The pool to which the account belongs
  • key - The address to validated
  • bump - The PDA bump for the address
  • tick - The tick from which the address should be derived

Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range

Snapshots must only be compared to other snapshots, taken over a period for which a position existed. I.e., snapshots cannot be compared if a position is not held for the entire period between when the first snapshot is taken and the second snapshot is taken.

Arguments
  • lower - The lower tick of the range.
  • upper - The upper tick of the range.
  • latest_observation - The latest oracle observation. The latest condition must be externally checked.

Trait Implementations

Deserializes previously initialized account data. Should fail for all uninitialized accounts, where the bytes are zeroed. Implementations should be unique to a particular account type so that one can never successfully deserialize the data of one account type into another. For example, if the SPL token program were to implement this trait, it should be impossible to deserialize a Mint account into a token Account. Read more

Deserializes account data without checking the account discriminator. This should only be used on account initialization, when the bytes of the account are zeroed. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern. Read more

If this function returns true, then it must be valid to reinterpret bits as &Self.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.