carbon_tcomp_decoder/instructions/
withdraw_fees.rs1use carbon_core::CarbonDeserialize;
3use carbon_core::account_utils::next_account;
4use carbon_core::borsh;
5use carbon_core::deserialize::ArrangeAccounts;
6use carbon_core::deserialize::CarbonDeserialize;
7
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9#[derive(Debug, Clone, borsh::BorshSerialize, CarbonDeserialize, PartialEq, Eq, Hash)]
10pub struct WithdrawFees {
11 pub amount: u64,
12}
13
14#[derive(Debug, Clone, PartialEq)]
15#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
16pub struct WithdrawFeesInstructionAccounts {
17 pub tswap: solana_pubkey::Pubkey,
18 pub tcomp: solana_pubkey::Pubkey,
19 pub cosigner: solana_pubkey::Pubkey,
20 pub owner: solana_pubkey::Pubkey,
21 pub destination: solana_pubkey::Pubkey,
22 pub system_program: solana_pubkey::Pubkey,
23 pub remaining: Vec<solana_instruction::AccountMeta>,
24}
25
26impl WithdrawFees {
27 pub fn decode(data: &[u8]) -> Option<Self> {
28 if data.len() < 8 {
29 return None;
30 }
31 let discriminator = &data[0..8];
32 if discriminator != &[198, 212, 171, 109, 144, 215, 174, 89] {
33 return None;
34 }
35
36 let data_slice = data;
37
38 let data_slice = &data_slice[8..];
39
40 Self::deserialize(data_slice)
41 }
42}
43
44impl ArrangeAccounts for WithdrawFees {
45 type ArrangedAccounts = WithdrawFeesInstructionAccounts;
46
47 fn arrange_accounts(
48 accounts: &[solana_instruction::AccountMeta],
49 ) -> Option<Self::ArrangedAccounts> {
50 let mut iter = accounts.iter();
51
52 let tswap = next_account(&mut iter)?;
53 let tcomp = next_account(&mut iter)?;
54 let cosigner = next_account(&mut iter)?;
55 let owner = next_account(&mut iter)?;
56 let destination = next_account(&mut iter)?;
57 let system_program = next_account(&mut iter)?;
58
59 let remaining = iter.as_slice();
60
61 Some(WithdrawFeesInstructionAccounts {
62 tswap,
63 tcomp,
64 cosigner,
65 owner,
66 destination,
67 system_program,
68 remaining: remaining.to_vec(),
69 })
70 }
71}