Struct cyclos_core::states::oracle::ObservationState
source · [−]#[repr(packed)]pub struct ObservationState {
pub bump: u8,
pub index: u16,
pub block_timestamp: u32,
pub tick_cumulative: i64,
pub seconds_per_liquidity_cumulative_x32: u64,
pub initialized: bool,
}Expand description
Returns data about a specific observation index
PDA of [OBSERVATION_SEED, token_0, token_1, fee, index]
Fields
bump: u8Bump to identify PDA
index: u16The element of the observations array stored in this account
block_timestamp: u32The block timestamp of the observation
tick_cumulative: i64The tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp
seconds_per_liquidity_cumulative_x32: u64The seconds per in range liquidity for the life of the pool as of the observation timestamp
initialized: boolWhether the observation has been initialized and the values are safe to use
Implementations
sourceimpl ObservationState
impl ObservationState
sourcepub fn transform(
self,
block_timestamp: u32,
tick: i32,
liquidity: u64
) -> ObservationState
pub fn transform(
self,
block_timestamp: u32,
tick: i32,
liquidity: u64
) -> ObservationState
Transforms a previous observation into a new observation, given the passage of time and the current tick and liquidity values
Arguments
last- Must be chronologically equal to or greater than last.blockTimestamp, safe for 0 or 1 overflows.block_timestamp- The timestamp of the new observationtick- The active tick at the time of the new observationliquidity- The total in-range liquidity at the time of the new observation
sourcepub fn update(
&mut self,
block_timestamp: u32,
tick: i32,
liquidity: u64,
cardinality: u16,
cardinality_next: u16
) -> u16
pub fn update(
&mut self,
block_timestamp: u32,
tick: i32,
liquidity: u64,
cardinality: u16,
cardinality_next: u16
) -> u16
Writes an oracle observation to the account, returning the updated cardinality. Writable at most once per second. Index represents the most recently written element. cardinality and index must be tracked externally. If the index is at the end of the allowable array length (according to cardinality), and the next cardinality is greater than the current one, cardinality may be increased. This restriction is created to preserve ordering.
Arguments
self- The observation account to write inblock_timestamp- The timestamp of the new observationtick- The active tick at the time of the new observationliquidity- The total in-range liquidity at the time of the new observationcardinality- The number of populated elements in the oracle arraycardinality_next- The new length of the oracle array, independent of population
Trait Implementations
sourceimpl AccountDeserialize for ObservationState
impl AccountDeserialize for ObservationState
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 Clone for ObservationState
impl Clone for ObservationState
sourcefn clone(&self) -> ObservationState
fn clone(&self) -> ObservationState
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Default for ObservationState
impl Default for ObservationState
sourcefn default() -> ObservationState
fn default() -> ObservationState
Returns the “default value” for a type. Read more
sourceimpl Discriminator for ObservationState
impl Discriminator for ObservationState
fn discriminator() -> [u8; 8]
sourceimpl Owner for ObservationState
impl Owner for ObservationState
sourceimpl Zeroable for ObservationState
impl Zeroable for ObservationState
impl Copy for ObservationState
impl Pod for ObservationState
impl ZeroCopy for ObservationState
Auto Trait Implementations
impl RefUnwindSafe for ObservationState
impl Send for ObservationState
impl Sync for ObservationState
impl Unpin for ObservationState
impl UnwindSafe for ObservationState
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