Skip to main content

carbon_bonkswap_decoder/instructions/
create_pool.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {
3    crate::types::{FixedPoint, Token},
4    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
5};
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
8pub struct CreatePool {
9    pub lp_fee: FixedPoint,
10    pub buyback_fee: FixedPoint,
11    pub project_fee: FixedPoint,
12    pub mercanti_fee: FixedPoint,
13    pub initial_token_x: Token,
14    pub initial_token_y: Token,
15    pub bump: u8,
16}
17
18#[derive(Debug, Clone, PartialEq)]
19#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
20pub struct CreatePoolInstructionAccounts {
21    pub state: solana_pubkey::Pubkey,
22    pub pool: solana_pubkey::Pubkey,
23    pub token_x: solana_pubkey::Pubkey,
24    pub token_y: solana_pubkey::Pubkey,
25    pub pool_x_account: solana_pubkey::Pubkey,
26    pub pool_y_account: solana_pubkey::Pubkey,
27    pub admin_x_account: solana_pubkey::Pubkey,
28    pub admin_y_account: solana_pubkey::Pubkey,
29    pub admin: solana_pubkey::Pubkey,
30    pub project_owner: solana_pubkey::Pubkey,
31    pub program_authority: solana_pubkey::Pubkey,
32    pub system_program: solana_pubkey::Pubkey,
33    pub token_program: solana_pubkey::Pubkey,
34    pub rent: solana_pubkey::Pubkey,
35    pub remaining: Vec<solana_instruction::AccountMeta>,
36}
37
38impl CreatePool {
39    pub fn decode(data: &[u8]) -> Option<Self> {
40        if data.len() < 8 {
41            return None;
42        }
43        let discriminator = &data[0..8];
44        if discriminator != [233, 146, 209, 142, 207, 104, 64, 188] {
45            return None;
46        }
47
48        let mut data_slice = data;
49
50        data_slice = &data_slice[8..];
51
52        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
53    }
54}
55
56impl ArrangeAccounts for CreatePool {
57    type ArrangedAccounts = CreatePoolInstructionAccounts;
58
59    fn arrange_accounts(
60        accounts: &[solana_instruction::AccountMeta],
61    ) -> Option<Self::ArrangedAccounts> {
62        let mut iter = accounts.iter();
63
64        let state = next_account(&mut iter)?;
65        let pool = next_account(&mut iter)?;
66        let token_x = next_account(&mut iter)?;
67        let token_y = next_account(&mut iter)?;
68        let pool_x_account = next_account(&mut iter)?;
69        let pool_y_account = next_account(&mut iter)?;
70        let admin_x_account = next_account(&mut iter)?;
71        let admin_y_account = next_account(&mut iter)?;
72        let admin = next_account(&mut iter)?;
73        let project_owner = next_account(&mut iter)?;
74        let program_authority = next_account(&mut iter)?;
75        let system_program = next_account(&mut iter)?;
76        let token_program = next_account(&mut iter)?;
77        let rent = next_account(&mut iter)?;
78
79        let remaining = iter.as_slice();
80
81        Some(CreatePoolInstructionAccounts {
82            state,
83            pool,
84            token_x,
85            token_y,
86            pool_x_account,
87            pool_y_account,
88            admin_x_account,
89            admin_y_account,
90            admin,
91            project_owner,
92            program_authority,
93            system_program,
94            token_program,
95            rent,
96            remaining: remaining.to_vec(),
97        })
98    }
99}