Struct Price

Source
#[repr(C)]
pub struct Price {
Show 22 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: Ema, pub ema_confidence: Ema, pub drv1: i64, pub drv2: i64, pub prod: AccKey, pub next: AccKey, pub prev_slot: u64, pub prev_price: i64, pub prev_conf: u64, pub drv3: i64, pub agg: PriceInfo, pub comp: [PriceComp; 32],
}
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.
Expand description

Price accounts represent a continuously-updating price feed for a product.

Fieldsยง

ยงmagic: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

pyth magic number

ยงver: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

program version

ยงatype: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

account type

ยงsize: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

price account size

ยงptype: PriceType
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

price or calculation type

ยงexpo: i32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

price exponent

ยงnum: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

number of component prices

ยงnum_qt: u32
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

number of quoters that make up aggregate

ยงlast_slot: u64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

slot of last valid (not unknown) aggregate price

ยงvalid_slot: u64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

valid slot-time of agg. price

ยงema_price: Ema
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

exponential moving average price

ยงema_confidence: Ema
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

exponential moving average confidence interval

ยงdrv1: i64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

space for future derived values

ยงdrv2: i64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

space for future derived values

ยงprod: AccKey
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

product account key

ยงnext: AccKey
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

next Price account in linked list

ยงprev_slot: u64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

valid slot of previous update

ยงprev_price: i64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

aggregate price of previous update

ยงprev_conf: u64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

confidence interval of previous update

ยงdrv3: i64
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

space for future derived values

ยงagg: PriceInfo
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

aggregate price info

ยงcomp: [PriceComp; 32]
๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

price components one per quoter

Implementationsยง

Sourceยง

impl Price

Source

pub fn get_current_price_status(&self) -> PriceStatus

๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

Get the current status of the aggregate price. If this lib is used on-chain it will mark price status as unknown if price has not been updated for a while.

Source

pub fn get_current_price(&self) -> Option<PriceConf>

๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

Get the current price and confidence interval as fixed-point numbers of the form a * 10^e. Returns a struct containing the current price, confidence interval, and the exponent for both numbers. Returns None if price information is currently unavailable for any reason.

Source

pub fn get_ema_price(&self) -> Option<PriceConf>

๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

Get the exponential moving average price (ema_price) and a confidence interval on the result. Returns None if the ema_price is currently unavailable.

At the moment, the confidence interval returned by this method is computed in a somewhat questionable way, so we do not recommend using it for high-value applications.

Source

pub fn get_price_in_quote( &self, quote: &Price, result_expo: i32, ) -> Option<PriceConf>

๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

Get the current price of this account in a different quote currency. If this account represents the price of the product X/Z, and quote represents the price of the product Y/Z, this method returns the price of X/Y. Use this method to get the price of e.g., mSOL/SOL from the mSOL/USD and SOL/USD accounts.

result_expo determines the exponent of the result, i.e., the number of digits below the decimal point. This method returns None if either the price or confidence are too large to be represented with the requested exponent.

Source

pub fn price_basket( amounts: &[(Price, i64, i32)], result_expo: i32, ) -> Option<PriceConf>

๐Ÿ‘ŽDeprecated: This crate has been deprecated. Please use pyth-sdk-solana instead.

Get the price of a basket of currencies. Each entry in amounts is of the form (price, qty, qty_expo), and the result is the sum of price * qty * 10^qty_expo. The result is returned with exponent result_expo.

An example use case for this function is to get the value of an LP token.

Trait Implementationsยง

Sourceยง

impl Clone for Price

Sourceยง

fn clone(&self) -> Price

Returns a copy 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 Debug for Price

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Default for Price

Sourceยง

fn default() -> Price

Returns the โ€œdefault valueโ€ for a type. Read more
Sourceยง

impl PartialEq for Price

Sourceยง

fn eq(&self, other: &Price) -> 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 Zeroable for Price

Sourceยง

impl Copy for Price

Sourceยง

impl Eq for Price

Sourceยง

impl Pod for Price

Sourceยง

impl StructuralPartialEq for Price

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<T> AbiExample for T

Sourceยง

default fn example() -> T

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
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<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Pointable for T

Sourceยง

const ALIGN: usize

The alignment of pointer.
Sourceยง

type Init = T

The type for initializers.
Sourceยง

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Sourceยง

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Sourceยง

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Sourceยง

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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,