Skip to main content

gmsol_sdk/client/pyth/pull_oracle/
mod.rs

1/// Wormhole Ops.
2pub mod wormhole;
3
4/// Pyth Reciever Ops.
5pub mod receiver;
6
7/// Hermes.
8pub mod hermes;
9
10/// Utils.
11pub mod utils;
12
13mod pull_oracle_impl;
14
15use std::ops::Deref;
16
17use gmsol_solana_utils::program::Program;
18use solana_sdk::signer::Signer;
19
20use self::wormhole::WORMHOLE_PROGRAM_ID;
21
22pub use self::{
23    pull_oracle_impl::{PriceUpdates, PythPullOracleWithHermes},
24    receiver::PythReceiverOps,
25    wormhole::WormholeOps,
26};
27
28const VAA_SPLIT_INDEX: usize = 755;
29
30/// Pyth Pull Oracle.
31pub struct PythPullOracle<C> {
32    wormhole: Program<C>,
33    pyth: Program<C>,
34}
35
36impl<S, C> PythPullOracle<C>
37where
38    C: Deref<Target = S> + Clone,
39    S: Signer,
40{
41    /// Create a new [`PythPullOracle`] client from [`Client`](crate::Client).
42    pub fn try_new(client: &crate::Client<C>) -> crate::Result<Self> {
43        Ok(Self {
44            wormhole: client.program(WORMHOLE_PROGRAM_ID),
45            pyth: client.program(pyth_solana_receiver_sdk::ID),
46        })
47    }
48}