carbon-okx-dex-decoder 2.0.0

OKX DEX 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 SwapWithFeesCpiEventEvent {
    pub order_id: u64,
    pub source_mint: Pubkey,
    pub destination_mint: Pubkey,
    pub source_token_account_owner: Pubkey,
    pub destination_token_account_owner: Pubkey,
    pub amount_in: u64,
    pub source_token_change: u64,
    pub destination_token_change: u64,
    pub commission_direction: bool,
    pub commission_rate: u32,
    pub commission_amount: u64,
    pub commission_account: Pubkey,
    pub platform_fee_rate: u16,
    pub platform_fee_amount: u64,
    pub platform_fee_account: Pubkey,
    pub trim_rate: u8,
    pub trim_amount: u64,
    pub trim_account: Pubkey,
}

impl SwapWithFeesCpiEventEvent {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [189, 97, 67, 12, 37, 209, 247, 29] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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