carbon-sharky-decoder 2.0.0

Sharky 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 TokenLendingLoan {
    pub orderbook: Pubkey,
    pub borrower: Pubkey,
    pub pool: Pubkey,
    pub principal_usdc_amount: u64,
    pub collateral_required_amount: u64,
    pub start_ts: i64,
    pub end_ts: i64,
    pub apr: u32,
    pub version: u8,
    pub padding: [u8; 3],
}

impl TokenLendingLoan {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [48, 250, 133, 85, 42, 11, 45, 154] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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