carbon-zeta-decoder 1.0.0

Zeta Program Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {crate::types::Asset, solana_pubkey::Pubkey};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct ApplyFundingEventEvent {
    pub margin_account: Pubkey,
    pub user: Pubkey,
    pub asset: Asset,
    pub balance_change: i64,
    pub remaining_balance: u64,
    pub funding_rate: i64,
    pub oracle_price: u64,
}

impl ApplyFundingEventEvent {
    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, 127, 202, 15, 183, 200, 192, 4, 12,
            ]
        {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[16..];

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