carbon-drift-v2-decoder 1.0.0

Drift v2 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use {crate::types::OrderParams, solana_pubkey::Pubkey};

#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct SignedMsgOrderRecordEvent {
    pub user: Pubkey,
    pub hash: String,
    pub matching_order_params: OrderParams,
    pub user_order_id: u32,
    pub signed_msg_order_max_slot: u64,
    pub signed_msg_order_uuid: [u8; 8],
    pub ts: i64,
}

impl SignedMsgOrderRecordEvent {
    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, 211, 197, 25, 18, 142, 86, 113, 27,
            ]
        {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[16..];

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