Trait mango_v4::health::AccountRetriever
source · [−]pub trait AccountRetriever {
fn bank_and_oracle(
&self,
group: &Pubkey,
active_token_position_index: usize,
token_index: TokenIndex
) -> Result<(&Bank, I80F48)>;
fn serum_oo(
&self,
active_serum_oo_index: usize,
key: &Pubkey
) -> Result<&OpenOrders>;
fn perp_market_and_oracle_price(
&self,
group: &Pubkey,
active_perp_position_index: usize,
perp_market_index: PerpMarketIndex
) -> Result<(&PerpMarket, I80F48)>;
}
Expand description
This trait abstracts how to find accounts needed for the health computation.
There are different ways they are retrieved from remainingAccounts, based on the instruction:
- FixedOrderAccountRetriever requires the remainingAccounts to be in a well defined order and is the fastest. It’s used where possible.
- ScanningAccountRetriever does a linear scan for each account it needs. It needs more compute, but works when a union of bank/oracle/market accounts are passed because health needs to be computed for different baskets in one instruction (such as for liquidation instructions).
Required Methods
sourcefn bank_and_oracle(
fn bank_and_oracle(
&self,
group: &Pubkey,
active_token_position_index: usize,
token_index: TokenIndex
) -> Result<(&Bank, I80F48)>
sourcefn perp_market_and_oracle_price(