//! 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 ClaimCashbackPumpswap {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct ClaimCashbackPumpswapInstructionAccounts {
    pub signer: solana_pubkey::Pubkey,
    pub sa_authority: solana_pubkey::Pubkey,
    pub user_volume_accumulator: solana_pubkey::Pubkey,
    pub wsol_mint: solana_pubkey::Pubkey,
    pub spl_token_program: solana_pubkey::Pubkey,
    pub uva_wsol_ata: solana_pubkey::Pubkey,
    pub sa_wsol_ata: solana_pubkey::Pubkey,
    pub receiver_wsol_ata: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub event_authority: solana_pubkey::Pubkey,
    pub pumpswap_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl ClaimCashbackPumpswap {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [253, 242, 176, 173, 217, 78, 100, 25] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for ClaimCashbackPumpswap {
    type ArrangedAccounts = ClaimCashbackPumpswapInstructionAccounts;

    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 wsol_mint = next_account(&mut iter)?;
        let spl_token_program = next_account(&mut iter)?;
        let uva_wsol_ata = next_account(&mut iter)?;
        let sa_wsol_ata = next_account(&mut iter)?;
        let receiver_wsol_ata = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let event_authority = next_account(&mut iter)?;
        let pumpswap_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(ClaimCashbackPumpswapInstructionAccounts {
            signer,
            sa_authority,
            user_volume_accumulator,
            wsol_mint,
            spl_token_program,
            uva_wsol_ata,
            sa_wsol_ata,
            receiver_wsol_ata,
            system_program,
            event_authority,
            pumpswap_program,
            remaining: remaining.to_vec(),
        })
    }
}
