#[repr(packed)]pub struct TickState {
pub bump: u8,
pub tick: i32,
pub liquidity_net: i64,
pub liquidity_gross: u64,
pub fee_growth_outside_0_x32: u64,
pub fee_growth_outside_1_x32: u64,
pub tick_cumulative_outside: i64,
pub seconds_per_liquidity_outside_x32: u64,
pub seconds_outside: u32,
}Expand description
Account storing info for a price tick
PDA of [TICK_SEED, token_0, token_1, fee, tick]
Fields
bump: u8Bump to identify PDA
tick: i32The price tick whose info is stored in the account
liquidity_net: i64The total position liquidity that references this tick
liquidity_gross: u64Amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left)
fee_growth_outside_0_x32: u64Fee growth per unit of liquidity on the other side of this tick (relative to the current tick) only has relative meaning, not absolute — the value depends on when the tick is initialized
fee_growth_outside_1_x32: u64tick_cumulative_outside: i64The cumulative tick value on the other side of the tick
seconds_per_liquidity_outside_x32: u64The seconds per unit of liquidity on the other side of this tick (relative to the current tick) only has relative meaning, not absolute — the value depends on when the tick is initialized
seconds_outside: u32The seconds spent on the other side of the tick (relative to the current tick) only has relative meaning, not absolute — the value depends on when the tick is initialized
Implementations
sourceimpl TickState
impl TickState
sourcepub fn update(
&mut self,
tick_current: i32,
liquidity_delta: i64,
fee_growth_global_0_x32: u64,
fee_growth_global_1_x32: u64,
seconds_per_liquidity_cumulative_x32: u64,
tick_cumulative: i64,
time: u32,
upper: bool,
max_liquidity: u64
) -> Result<bool>
pub fn update(
&mut self,
tick_current: i32,
liquidity_delta: i64,
fee_growth_global_0_x32: u64,
fee_growth_global_1_x32: u64,
seconds_per_liquidity_cumulative_x32: u64,
tick_cumulative: i64,
time: u32,
upper: bool,
max_liquidity: u64
) -> Result<bool>
Updates a tick and returns true if the tick was flipped from initialized to uninitialized, or vice versa
Arguments
self- The tick state that will be updatedtick_current- The current tickliquidity_delta- A new amount of liquidity to be added (subtracted) when tick is crossed from left to right (right to left)fee_growth_global_0_x32- The all-time global fee growth, per unit of liquidity, in token_0fee_growth_global_1_x32- The all-time global fee growth, per unit of liquidity, in token_1seconds_per_liquidity_cumulative_x32- The all-time seconds per max(1, liquidity) of the pooltick_cumulative- The tick * time elapsed since the pool was first initializedtime- The current block timestamp cast to a u32upper- true for updating a position’s upper tick, or false for updating a position’s lower tickmax_liquidity- The maximum liquidity allocation for a single tick
sourcepub fn cross(
&mut self,
fee_growth_global_0_x32: u64,
fee_growth_global_1_x32: u64,
seconds_per_liquidity_cumulative_x32: u64,
tick_cumulative: i64,
time: u32
) -> i64
pub fn cross(
&mut self,
fee_growth_global_0_x32: u64,
fee_growth_global_1_x32: u64,
seconds_per_liquidity_cumulative_x32: u64,
tick_cumulative: i64,
time: u32
) -> i64
Transitions to the current tick as needed by price movement, returning the amount of liquidity added (subtracted) when tick is crossed from left to right (right to left)
Arguments
self- The destination tick of the transitionfee_growth_global_0_x32- The all-time global fee growth, per unit of liquidity, in token_0fee_growth_global_1_x32- The all-time global fee growth, per unit of liquidity, in token_1seconds_per_liquidity_cumulative_x32- The current seconds per liquiditytick_cumulative- The tick * time elapsed since the pool was first initializedtime- The current block timestamp
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clears tick data. Variables other than bump and tick are cleared
Arguments
self- The tick account to be cleared
pub fn is_clear(self) -> bool
Trait Implementations
sourceimpl AccountDeserialize for TickState
impl AccountDeserialize for TickState
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 TickState
impl Discriminator for TickState
fn discriminator() -> [u8; 8]
impl Copy for TickState
impl Pod for TickState
impl ZeroCopy for TickState
Auto Trait Implementations
impl RefUnwindSafe for TickState
impl Send for TickState
impl Sync for TickState
impl Unpin for TickState
impl UnwindSafe for TickState
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.
impl<T> Pointable for T
impl<T> Pointable for T
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