Skip to main content

MockPythOracleBuilder

Struct MockPythOracleBuilder 

Source
pub struct MockPythOracleBuilder<'a> { /* private fields */ }
Expand description

Builder for creating mock Pyth price feed accounts

§Example

let oracle = ctx.create_mock_pyth_oracle()
    .price(100_00000000)  // $100 with 8 decimals
    .exponent(-8)
    .confidence(100_000)
    .build()?;

Implementations§

Source§

impl<'a> MockPythOracleBuilder<'a>

Source

pub fn new(ctx: &'a mut TestContext) -> Self

Source

pub fn price(self, price: i64) -> Self

Set the price value (in smallest units based on exponent) For example, $100 with exponent -8 = 100_00000000

Source

pub fn exponent(self, exp: i32) -> Self

Set the price exponent (typically -8 for USD prices)

Source

pub fn confidence(self, conf: u64) -> Self

Set the confidence interval

Source

pub fn publish_time(self, time: i64) -> Self

Set the publish time (defaults to current system time)

Source

pub fn feed_id(self, id: [u8; 32]) -> Self

Set a custom feed ID (defaults to oracle pubkey bytes)

Source

pub fn program_id(self, id: Pubkey) -> Self

Override the Pyth program ID (defaults to Pyth Solana Receiver)

Source

pub fn build(self) -> Result<Pubkey>

Build and create the mock Pyth oracle account Returns the oracle’s public key

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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