#[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: u8Bump to identify PDA
token_0: PubkeyToken pair of the pool, where token_0 address < token_1 address
token_1: Pubkeyfee: u32Fee amount for swaps, denominated in hundredths of a bip (i.e. 1e-6)
tick_spacing: u16The minimum number of ticks between initialized ticks
liquidity: u64The currently in range liquidity available to the pool. This value has no relationship to the total liquidity across all ticks.
sqrt_price_x32: u64The current price of the pool as a sqrt(token_1/token_0) Q32.32 value
tick: i32The 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: u16the most-recently updated index of the observations array
observation_cardinality: u16the current maximum number of observations that are being stored
observation_cardinality_next: u16The next maximum number of observations to store, triggered on a swap or position update
fee_growth_global_0_x32: u64The 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: u64The 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: boolWhether the pool is currently locked to reentrancy
Implementations
sourceimpl PoolState
impl PoolState
sourcepub fn next_observation_index(self) -> u16
pub fn next_observation_index(self) -> u16
Returns the observation index after the currently active one in a liquidity pool
Arguments
self- A pool account
sourcepub fn validate_observation_address(
self,
key: &Pubkey,
bump: u8,
next: bool
) -> Result<()>
pub fn validate_observation_address(
self,
key: &Pubkey,
bump: u8,
next: bool
) -> Result<()>
Validates the public key of an observation account
Arguments
self- The pool to which the account belongskey- The address to validatedbump- The PDA bump for the addressnext- Whether to validate the current observation account or the next account
sourcepub fn validate_tick_address(
self,
key: &Pubkey,
bump: u8,
tick: i32
) -> Result<()>
pub fn validate_tick_address(
self,
key: &Pubkey,
bump: u8,
tick: i32
) -> Result<()>
Validates the public key of a tick account
Arguments
self- The pool to which the account belongskey- The address to validatedbump- The PDA bump for the addresstick- The tick from which the address should be derived
sourcepub fn validate_bitmap_address(
self,
key: &Pubkey,
bump: u8,
word_pos: i16
) -> Result<()>
pub fn validate_bitmap_address(
self,
key: &Pubkey,
bump: u8,
word_pos: i16
) -> Result<()>
Validates the public key of a bitmap account
Arguments
self- The pool to which the account belongskey- The address to validatedbump- The PDA bump for the addresstick- The tick from which the address should be derived
sourcepub fn validate_position_address(
self,
key: &Pubkey,
bump: u8,
position_owner: &Pubkey,
tick_lower: i32,
tick_upper: i32
) -> Result<()>
pub fn validate_position_address(
self,
key: &Pubkey,
bump: u8,
position_owner: &Pubkey,
tick_lower: i32,
tick_upper: i32
) -> Result<()>
Validates the public key of a bitmap account
Arguments
self- The pool to which the account belongskey- The address to validatedbump- The PDA bump for the addresstick- The tick from which the address should be derived
sourcepub fn snapshot_cumulatives_inside(
self,
lower: &TickState,
upper: &TickState,
latest_observation: &ObservationState
) -> SnapshotCumulative
pub fn snapshot_cumulatives_inside(
self,
lower: &TickState,
upper: &TickState,
latest_observation: &ObservationState
) -> SnapshotCumulative
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
sourceimpl AccountDeserialize for PoolState
impl AccountDeserialize for PoolState
sourcefn try_deserialize(buf: &mut &[u8]) -> Result<Self>
fn try_deserialize(buf: &mut &[u8]) -> Result<Self>
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
sourceimpl Discriminator for PoolState
impl Discriminator for PoolState
fn discriminator() -> [u8; 8]
impl Copy for PoolState
impl Pod for PoolState
impl ZeroCopy for PoolState
Auto Trait Implementations
impl RefUnwindSafe for PoolState
impl Send for PoolState
impl Sync for PoolState
impl Unpin for PoolState
impl UnwindSafe for PoolState
Blanket Implementations
impl<T> AbiExample for T
impl<T> AbiExample for T
default fn example() -> T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CheckedBitPattern for T where
T: AnyBitPattern,
impl<T> CheckedBitPattern for T where
T: AnyBitPattern,
type Bits = T
type Bits = T
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
fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret bits as &Self.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more