carbon-openbook-v2-decoder 2.0.0

Openbook 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 FillLogEvent {
    pub market: Pubkey,
    pub taker_side: u8,
    pub maker_slot: u8,
    pub maker_out: bool,
    pub timestamp: u64,
    pub seq_num: u64,
    pub maker: Pubkey,
    pub maker_client_order_id: u64,
    pub maker_fee: u64,
    pub maker_timestamp: u64,
    pub taker: Pubkey,
    pub taker_client_order_id: u64,
    pub taker_fee_ceil: u64,
    pub price: i64,
    pub quantity: i64,
}

impl FillLogEvent {
    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, 150, 23, 41, 148, 152, 162, 215, 64,
            ]
        {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[16..];

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