carbon-okx-dex-decoder 2.0.0

OKX DEX Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct ClaimCashbackPumpfun {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ClaimCashbackPumpfunInstructionAccounts {
    pub signer: solana_pubkey::Pubkey,
    pub sa_authority: solana_pubkey::Pubkey,
    pub user_volume_accumulator: solana_pubkey::Pubkey,
    pub receiver: solana_pubkey::Pubkey,
    pub event_authority: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub pumpfun_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl ClaimCashbackPumpfun {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [83, 1, 245, 125, 201, 207, 209, 249] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for ClaimCashbackPumpfun {
    type ArrangedAccounts = ClaimCashbackPumpfunInstructionAccounts;

    fn arrange_accounts(
        accounts: &[solana_instruction::AccountMeta],
    ) -> Option<Self::ArrangedAccounts> {
        let mut iter = accounts.iter();

        let signer = next_account(&mut iter)?;
        let sa_authority = next_account(&mut iter)?;
        let user_volume_accumulator = next_account(&mut iter)?;
        let receiver = next_account(&mut iter)?;
        let event_authority = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let pumpfun_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(ClaimCashbackPumpfunInstructionAccounts {
            signer,
            sa_authority,
            user_volume_accumulator,
            receiver,
            event_authority,
            system_program,
            pumpfun_program,
            remaining: remaining.to_vec(),
        })
    }
}