Skip to main content

carbon_raydium_launchpad_decoder/instructions/
create_config.rs

1//! This code was AUTOGENERATED using the Codama library.
2use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
3/// Creates a new configuration
4/// # Arguments
5/// * `ctx` - The accounts needed by instruction
6/// * `curve_type` - The type of bonding curve (0: ConstantProduct)
7/// * `index` - The index of config, there may be multiple config with the same
8///   curve type.
9/// * `trade_fee_rate` - Trade fee rate, must be less than
10///   RATE_DENOMINATOR_VALUE
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
13pub struct CreateConfig {
14    pub curve_type: u8,
15    pub index: u16,
16    pub migrate_fee: u64,
17    pub trade_fee_rate: u64,
18}
19
20#[derive(Debug, Clone, PartialEq)]
21#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
22pub struct CreateConfigInstructionAccounts {
23    pub owner: solana_pubkey::Pubkey,
24    pub global_config: solana_pubkey::Pubkey,
25    pub quote_token_mint: solana_pubkey::Pubkey,
26    pub protocol_fee_owner: solana_pubkey::Pubkey,
27    pub migrate_fee_owner: solana_pubkey::Pubkey,
28    pub migrate_to_amm_wallet: solana_pubkey::Pubkey,
29    pub migrate_to_cpswap_wallet: solana_pubkey::Pubkey,
30    pub system_program: solana_pubkey::Pubkey,
31    pub remaining: Vec<solana_instruction::AccountMeta>,
32}
33
34impl CreateConfig {
35    pub fn decode(data: &[u8]) -> Option<Self> {
36        if data.len() < 8 {
37            return None;
38        }
39        let discriminator = &data[0..8];
40        if discriminator != [201, 207, 243, 114, 75, 111, 47, 189] {
41            return None;
42        }
43
44        let mut data_slice = data;
45
46        data_slice = &data_slice[8..];
47
48        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
49    }
50}
51
52impl ArrangeAccounts for CreateConfig {
53    type ArrangedAccounts = CreateConfigInstructionAccounts;
54
55    fn arrange_accounts(
56        accounts: &[solana_instruction::AccountMeta],
57    ) -> Option<Self::ArrangedAccounts> {
58        let mut iter = accounts.iter();
59
60        let owner = next_account(&mut iter)?;
61        let global_config = next_account(&mut iter)?;
62        let quote_token_mint = next_account(&mut iter)?;
63        let protocol_fee_owner = next_account(&mut iter)?;
64        let migrate_fee_owner = next_account(&mut iter)?;
65        let migrate_to_amm_wallet = next_account(&mut iter)?;
66        let migrate_to_cpswap_wallet = next_account(&mut iter)?;
67        let system_program = next_account(&mut iter)?;
68
69        let remaining = iter.as_slice();
70
71        Some(CreateConfigInstructionAccounts {
72            owner,
73            global_config,
74            quote_token_mint,
75            protocol_fee_owner,
76            migrate_fee_owner,
77            migrate_to_amm_wallet,
78            migrate_to_cpswap_wallet,
79            system_program,
80            remaining: remaining.to_vec(),
81        })
82    }
83}