Struct GenericPriceAccount

Source
#[repr(C)]
pub struct GenericPriceAccount<const N: usize, T>
where T: Default + Copy,
{
Show 26 fields pub magic: u32, pub ver: u32, pub atype: u32, pub size: u32, pub ptype: PriceType, pub expo: i32, pub num: u32, pub num_qt: u32, pub last_slot: u64, pub valid_slot: u64, pub ema_price: Rational, pub ema_conf: Rational, pub timestamp: i64, pub min_pub: u8, pub drv2: u8, pub drv3: u16, pub drv4: u32, pub prod: Pubkey, pub next: Pubkey, pub prev_slot: u64, pub prev_price: i64, pub prev_conf: u64, pub prev_timestamp: i64, pub agg: PriceInfo, pub comp: [PriceComp; N], pub extended: T,
}

Fields§

§magic: u32

pyth magic number

§ver: u32

program version

§atype: u32

account type

§size: u32

price account size

§ptype: PriceType

price or calculation type

§expo: i32

price exponent

§num: u32

number of component prices

§num_qt: u32

number of quoters that make up aggregate

§last_slot: u64

slot of last valid (not unknown) aggregate price

§valid_slot: u64

valid slot-time of agg. price

§ema_price: Rational

exponentially moving average price

§ema_conf: Rational

exponentially moving average confidence interval

§timestamp: i64

unix timestamp of aggregate price

§min_pub: u8

min publishers for valid price

§drv2: u8

space for future derived values

§drv3: u16

space for future derived values

§drv4: u32

space for future derived values

§prod: Pubkey

product account key

§next: Pubkey

next Price account in linked list

§prev_slot: u64

valid slot of previous update

§prev_price: i64

aggregate price of previous update with TRADING status

§prev_conf: u64

confidence interval of previous update with TRADING status

§prev_timestamp: i64

unix timestamp of previous aggregate with TRADING status

§agg: PriceInfo

aggregate price info

§comp: [PriceComp; N]

price components one per quoter

§extended: T

additional extended account data

Implementations§

Source§

impl<const N: usize, T> GenericPriceAccount<N, T>
where T: Default + Copy,

Source

pub fn get_publish_time(&self) -> UnixTimestamp

Source

pub fn get_price_no_older_than( &self, clock: &Clock, slot_threshold: u64, ) -> Option<Price>

Get the last valid price as long as it was updated within slot_threshold slots of the current slot.

Source

pub fn to_price_feed(&self, price_key: &Pubkey) -> PriceFeed

Source§

impl<const N: usize, T> GenericPriceAccount<N, T>
where T: Default + Copy + 'static,

Source

pub fn account_info_to_feed( price_account_info: &AccountInfo<'_>, ) -> Result<PriceFeed, PythError>

Source

pub fn account_to_feed( price_key: &Pubkey, price_account: &mut impl Account, ) -> Result<PriceFeed, PythError>

Trait Implementations§

Source§

impl<const N: usize, T> Clone for GenericPriceAccount<N, T>
where T: Default + Copy + Clone,

Source§

fn clone(&self) -> GenericPriceAccount<N, T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const N: usize, T> Debug for GenericPriceAccount<N, T>
where T: Default + Copy + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<const N: usize, T> Default for GenericPriceAccount<N, T>
where T: Default + Copy,

Source§

fn default() -> Self

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

impl<const N: usize, T> Deref for GenericPriceAccount<N, T>
where T: Default + Copy,

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<const N: usize, T> PartialEq for GenericPriceAccount<N, T>
where T: Default + Copy + PartialEq,

Source§

fn eq(&self, other: &GenericPriceAccount<N, T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<const N: usize, T: Default + Copy> Zeroable for GenericPriceAccount<N, T>

Source§

fn zeroed() -> Self

Source§

impl<const N: usize, T> Copy for GenericPriceAccount<N, T>
where T: Default + Copy + Copy,

Source§

impl<const N: usize, T> Eq for GenericPriceAccount<N, T>
where T: Default + Copy + Eq,

Source§

impl<const N: usize, T: Default + Copy + 'static> Pod for GenericPriceAccount<N, T>

Source§

impl<const N: usize, T> StructuralPartialEq for GenericPriceAccount<N, T>
where T: Default + Copy,

Auto Trait Implementations§

§

impl<const N: usize, T> Freeze for GenericPriceAccount<N, T>
where T: Freeze,

§

impl<const N: usize, T> RefUnwindSafe for GenericPriceAccount<N, T>
where T: RefUnwindSafe,

§

impl<const N: usize, T> Send for GenericPriceAccount<N, T>
where T: Send,

§

impl<const N: usize, T> Sync for GenericPriceAccount<N, T>
where T: Sync,

§

impl<const N: usize, T> Unpin for GenericPriceAccount<N, T>
where T: Unpin,

§

impl<const N: usize, T> UnwindSafe for GenericPriceAccount<N, T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

Source§

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.
Source§

fn is_valid_bit_pattern(_bits: &T) -> bool

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

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> AnyBitPattern for T
where T: Pod,

Source§

impl<T> NoUninit for T
where T: Pod,