carbon-jupiter-lend-decoder 2.0.0

Jupiter Lend Liquidity 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 TokenReserve {
    pub mint: Pubkey,
    pub vault: Pubkey,
    pub borrow_rate: u16,
    pub fee_on_interest: u16,
    pub last_utilization: u16,
    pub last_update_timestamp: u64,
    pub supply_exchange_price: u64,
    pub borrow_exchange_price: u64,
    pub max_utilization: u16,
    pub total_supply_with_interest: u64,
    pub total_supply_interest_free: u64,
    pub total_borrow_with_interest: u64,
    pub total_borrow_interest_free: u64,
    pub total_claim_amount: u64,
    pub interacting_protocol: Pubkey,
    pub interacting_timestamp: u64,
    pub interacting_balance: u64,
}

impl TokenReserve {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [21, 18, 59, 135, 120, 20, 31, 12] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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