carbon-marginfi-v2-decoder 1.0.0

MarginfiV2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::types::WrappedI80F48;
/// A read-only cache of the bank's key metrics, e.g. spot interest/fee rates.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct BankCache {
    /// Actual (spot) interest/fee rates of the bank, based on utilization
    /// * APR (annual percentage rate) values
    /// * From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc
    pub base_rate: u32,
    /// Equivalent to `base_rate` * utilization
    /// * From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc
    pub lending_rate: u32,
    /// Equivalent to `base_rate` * (1 + ir_fees) + fixed_fees
    /// * From 0-1000%, as u32, e.g. u32::MAX = 1000%, u32::MAX/2 = 500%, etc
    pub borrowing_rate: u32,
    /// * in seconds
    pub interest_accumulated_for: u32,
    /// equivalent to (share value increase in the last
    /// `interest_accumulated_for` seconds * shares), i.e. the delta in
    /// `asset_share_value`, in token.
    /// * Note: if the tx that triggered this cache update increased or
    ///   decreased the net shares,
    ///
    /// this value still reports using the PRE-CHANGE share amount, since
    /// interest is always earned on that amount.
    /// * in token, in native decimals, as I80F48
    pub accumulated_since_last_update: WrappedI80F48,
    /// Oracle price used in the last instruction that consumed an oracle price
    /// * Only updated when instruction uses an oracle price, not updated for
    ///   operations that don't
    ///
    /// require prices (e.g., deposit, repay)
    /// * Price in USD, with no price bias
    /// * Zero if never updated
    pub last_oracle_price: WrappedI80F48,
    /// Unix timestamp (seconds) when last_oracle_price was last updated
    /// * Used to determine staleness of cached price
    /// * Zero if never updated
    pub last_oracle_price_timestamp: i64,
    /// Confidence interval reported by the oracle when last_oracle_price was
    /// fetched
    /// * Always non-negative
    /// * Zero if never updated
    /// * Note: this value is the confidence reported by oracles, multiplied by
    ///   `STD_DEV_MULTIPLE`
    pub last_oracle_price_confidence: WrappedI80F48,
    /// Liquidation cache flags, set during receivership flow.
    /// * 1 (LIQ_CACHE_LOCKED_FLAG) - We "lock" the liquidation cache when
    ///   writing to it in Start
    ///
    /// Liquidate as an additional safeguard, if the liquidation prices stored
    /// here were to be edited between start and end, it would completely
    /// break the risk engine. End validates that the lock is set, panics if
    /// not, and removes it - which prevents footguns if the cache was
    /// e.g. accidently set to default. The lock is also removed when a Balance
    /// is closed via withdraw_all, repay_all, or close_balance, but only
    /// when the account has ACCOUNT_IN_RECEIVERSHIP set, so that operations
    /// on unrelated accounts sharing the same bank do not interfere with an
    /// in-progress liquidation.
    pub liq_cache_flags: u8,
    pub padding: [u8; 23],
    /// Cached real-time price for receivership liquidation.
    pub liquidation_price_rt: WrappedI80F48,
    /// Cached real-time price confidence for receivership liquidation.
    pub liquidation_price_rt_confidence: WrappedI80F48,
    /// Cached TWAP price for receivership liquidation.
    pub liquidation_price_twap: WrappedI80F48,
    /// Cached TWAP price confidence for receivership liquidation.
    pub liquidation_price_twap_confidence: WrappedI80F48,
}