pub struct PercolatorClient {
pub client: RpcClient,
pub program_id: Pubkey,
pub engine_state: Pubkey,
}Expand description
A high-level client for interacting with the Percolator risk engine via RPC.
PercolatorClient simplifies the process of sending transactions and fetching
protocol state by encapsulating the RPC client and instruction building.
Fields§
§client: RpcClientThe underlying Solana RPC client.
program_id: PubkeyThe public key of the Percolator program (or its wrapper).
engine_state: PubkeyThe public key of the RiskEngine state account.
Implementations§
Source§impl PercolatorClient
impl PercolatorClient
Sourcepub fn new(rpc_url: &str, program_id: Pubkey, engine_state: Pubkey) -> Self
pub fn new(rpc_url: &str, program_id: Pubkey, engine_state: Pubkey) -> Self
Creates a new PercolatorClient.
Sourcepub fn get_engine_state(&self) -> Result<RiskEngine, Box<dyn Error>>
pub fn get_engine_state(&self) -> Result<RiskEngine, Box<dyn Error>>
Fetches the current RiskEngine state from the blockchain.
Sourcepub fn get_account(
&self,
index: usize,
) -> Result<Option<Account>, Box<dyn Error>>
pub fn get_account( &self, index: usize, ) -> Result<Option<Account>, Box<dyn Error>>
Fetches a specific Account from the engine by its index.
Sourcepub fn send_deposit(
&self,
payer: &Keypair,
account_index: u64,
amount: u128,
now_slot: u64,
) -> Result<String, Box<dyn Error>>
pub fn send_deposit( &self, payer: &Keypair, account_index: u64, amount: u128, now_slot: u64, ) -> Result<String, Box<dyn Error>>
Sends a Deposit transaction.
Sourcepub fn send_withdraw(
&self,
payer: &Keypair,
account_index: u64,
amount: u128,
now_slot: u64,
oracle_price: u64,
) -> Result<String, Box<dyn Error>>
pub fn send_withdraw( &self, payer: &Keypair, account_index: u64, amount: u128, now_slot: u64, oracle_price: u64, ) -> Result<String, Box<dyn Error>>
Sends a Withdraw transaction.
Auto Trait Implementations§
impl !Freeze for PercolatorClient
impl !RefUnwindSafe for PercolatorClient
impl Send for PercolatorClient
impl Sync for PercolatorClient
impl Unpin for PercolatorClient
impl !UnwindSafe for PercolatorClient
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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