carbon-drift-v2-decoder 2.0.0

Drift v2 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 LPMintRedeemRecordEvent {
    pub ts: i64,
    pub slot: u64,
    pub authority: Pubkey,
    pub description: u8,
    pub amount: u128,
    pub fee: i128,
    pub spot_market_index: u16,
    pub constituent_index: u16,
    pub oracle_price: i64,
    pub mint: Pubkey,
    pub lp_amount: u64,
    pub lp_fee: i64,
    pub lp_price: u128,
    pub mint_redeem_id: u64,
    pub last_aum: u128,
    pub last_aum_slot: u64,
    pub in_market_current_weight: i64,
    pub in_market_target_weight: i64,
    pub lp_pool: Pubkey,
}

impl LPMintRedeemRecordEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 16 {
            return None;
        }
        let discriminator = &data[0..16];
        if discriminator
            != [
                228, 69, 165, 46, 81, 203, 154, 29, 53, 178, 142, 73, 78, 91, 91, 8,
            ]
        {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[16..];

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