carbon_wavebreak_decoder/instructions/
token_refund.rs1use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
5pub struct TokenRefund {}
6
7#[derive(Debug, Clone, PartialEq)]
8#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
9pub struct TokenRefundInstructionAccounts {
10 pub signer: solana_pubkey::Pubkey,
11 pub bonding_curve: solana_pubkey::Pubkey,
12 pub quote_mint: solana_pubkey::Pubkey,
13 pub quote_vault: solana_pubkey::Pubkey,
14 pub signer_quote_ata: solana_pubkey::Pubkey,
15 pub base_mint: solana_pubkey::Pubkey,
16 pub signer_base_ata: solana_pubkey::Pubkey,
17 pub system_program: solana_pubkey::Pubkey,
18 pub base_token_program: solana_pubkey::Pubkey,
19 pub quote_token_program: solana_pubkey::Pubkey,
20 pub ata_program: solana_pubkey::Pubkey,
21 pub remaining: Vec<solana_instruction::AccountMeta>,
22}
23
24impl TokenRefund {
25 pub fn decode(data: &[u8]) -> Option<Self> {
26 if data.is_empty() {
27 return None;
28 }
29 let discriminator = &data[0..1];
30 if discriminator != [12] {
31 return None;
32 }
33
34 let mut data_slice = data;
35
36 data_slice = &data_slice[1..];
37
38 borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
39 }
40}
41
42impl ArrangeAccounts for TokenRefund {
43 type ArrangedAccounts = TokenRefundInstructionAccounts;
44
45 fn arrange_accounts(
46 accounts: &[solana_instruction::AccountMeta],
47 ) -> Option<Self::ArrangedAccounts> {
48 let mut iter = accounts.iter();
49
50 let signer = next_account(&mut iter)?;
51 let bonding_curve = next_account(&mut iter)?;
52 let quote_mint = next_account(&mut iter)?;
53 let quote_vault = next_account(&mut iter)?;
54 let signer_quote_ata = next_account(&mut iter)?;
55 let base_mint = next_account(&mut iter)?;
56 let signer_base_ata = next_account(&mut iter)?;
57 let system_program = next_account(&mut iter)?;
58 let base_token_program = next_account(&mut iter)?;
59 let quote_token_program = next_account(&mut iter)?;
60 let ata_program = next_account(&mut iter)?;
61
62 let remaining = iter.as_slice();
63
64 Some(TokenRefundInstructionAccounts {
65 signer,
66 bonding_curve,
67 quote_mint,
68 quote_vault,
69 signer_quote_ata,
70 base_mint,
71 signer_base_ata,
72 system_program,
73 base_token_program,
74 quote_token_program,
75 ata_program,
76 remaining: remaining.to_vec(),
77 })
78 }
79}