carbon-marginfi-v2-decoder 1.0.0

MarginfiV2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use solana_pubkey::Pubkey;

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct RateLimitFlowEventEvent {
    pub group: Pubkey,
    pub bank: Pubkey,
    pub mint: Pubkey,
    /// 0 = outflow (withdraw/borrow), 1 = inflow (deposit/repay)
    pub flow_direction: u8,
    /// Amount in native tokens
    pub native_amount: u64,
    pub mint_decimals: u8,
    /// Unix timestamp when the flow was recorded
    pub current_timestamp: i64,
}

impl RateLimitFlowEventEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [229, 5, 73, 200, 0, 107, 105, 109] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}