#[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: u8

Bump to identify PDA

tick: i32

The price tick whose info is stored in the account

liquidity_net: i64

The total position liquidity that references this tick

liquidity_gross: u64

Amount of net liquidity added (subtracted) when tick is crossed from left to right (right to left)

fee_growth_outside_0_x32: u64

Fee 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: i64

The cumulative tick value on the other side of the tick

seconds_per_liquidity_outside_x32: u64

The 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: u32

The 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

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 updated
  • tick_current - The current tick
  • liquidity_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_0
  • fee_growth_global_1_x32 - The all-time global fee growth, per unit of liquidity, in token_1
  • seconds_per_liquidity_cumulative_x32 - The all-time seconds per max(1, liquidity) of the pool
  • tick_cumulative - The tick * time elapsed since the pool was first initialized
  • time - The current block timestamp cast to a u32
  • upper - true for updating a position’s upper tick, or false for updating a position’s lower tick
  • max_liquidity - The maximum liquidity allocation for a single tick

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 transition
  • fee_growth_global_0_x32 - The all-time global fee growth, per unit of liquidity, in token_0
  • fee_growth_global_1_x32 - The all-time global fee growth, per unit of liquidity, in token_1
  • seconds_per_liquidity_cumulative_x32 - The current seconds per liquidity
  • tick_cumulative - The tick * time elapsed since the pool was first initialized
  • time - The current block timestamp

Clears tick data. Variables other than bump and tick are cleared

Arguments
  • self - The tick account to be cleared

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

Formats the value using the given formatter. 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.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

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.