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 WithdrawFees {
pub amount: u64,
}
#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WithdrawFeesInstructionAccounts {
pub admin: solana_pubkey::Pubkey,
pub mint: solana_pubkey::Pubkey,
pub fee_authority: solana_pubkey::Pubkey,
pub program_fee_ata: solana_pubkey::Pubkey,
pub admin_fee_ata: solana_pubkey::Pubkey,
pub system_program: solana_pubkey::Pubkey,
pub token_program: solana_pubkey::Pubkey,
pub associated_token_program: solana_pubkey::Pubkey,
pub remaining: Vec<solana_instruction::AccountMeta>,
}
impl WithdrawFees {
pub fn decode(data: &[u8]) -> Option<Self> {
if data.len() < 8 {
return None;
}
let discriminator = &data[0..8];
if discriminator != [198, 212, 171, 109, 144, 215, 174, 89] {
return None;
}
let mut data_slice = data;
data_slice = &data_slice[8..];
borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
}
}
impl ArrangeAccounts for WithdrawFees {
type ArrangedAccounts = WithdrawFeesInstructionAccounts;
fn arrange_accounts(
accounts: &[solana_instruction::AccountMeta],
) -> Option<Self::ArrangedAccounts> {
let mut iter = accounts.iter();
let admin = next_account(&mut iter)?;
let mint = next_account(&mut iter)?;
let fee_authority = next_account(&mut iter)?;
let program_fee_ata = next_account(&mut iter)?;
let admin_fee_ata = next_account(&mut iter)?;
let system_program = next_account(&mut iter)?;
let token_program = next_account(&mut iter)?;
let associated_token_program = next_account(&mut iter)?;
let remaining = iter.as_slice();
Some(WithdrawFeesInstructionAccounts {
admin,
mint,
fee_authority,
program_fee_ata,
admin_fee_ata,
system_program,
token_program,
associated_token_program,
remaining: remaining.to_vec(),
})
}
}