Skip to main content

carbon_pump_swap_decoder/instructions/
create_config.rs

1//! This code was AUTOGENERATED using the Codama library.
2use {
3    carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts},
4    solana_pubkey::Pubkey,
5};
6#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
7#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
8pub struct CreateConfig {
9    pub lp_fee_basis_points: u64,
10    pub protocol_fee_basis_points: u64,
11    pub protocol_fee_recipients: [Pubkey; 8],
12    pub coin_creator_fee_basis_points: u64,
13    pub admin_set_coin_creator_authority: Pubkey,
14}
15
16#[derive(Debug, Clone, PartialEq)]
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18pub struct CreateConfigInstructionAccounts {
19    pub admin: solana_pubkey::Pubkey,
20    pub global_config: solana_pubkey::Pubkey,
21    pub system_program: solana_pubkey::Pubkey,
22    pub event_authority: solana_pubkey::Pubkey,
23    pub program: solana_pubkey::Pubkey,
24    pub remaining: Vec<solana_instruction::AccountMeta>,
25}
26
27impl CreateConfig {
28    pub fn decode(data: &[u8]) -> Option<Self> {
29        if data.len() < 8 {
30            return None;
31        }
32        let discriminator = &data[0..8];
33        if discriminator != [201, 207, 243, 114, 75, 111, 47, 189] {
34            return None;
35        }
36
37        let mut data_slice = data;
38
39        data_slice = &data_slice[8..];
40
41        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
42    }
43}
44
45impl ArrangeAccounts for CreateConfig {
46    type ArrangedAccounts = CreateConfigInstructionAccounts;
47
48    fn arrange_accounts(
49        accounts: &[solana_instruction::AccountMeta],
50    ) -> Option<Self::ArrangedAccounts> {
51        let mut iter = accounts.iter();
52
53        let admin = next_account(&mut iter)?;
54        let global_config = next_account(&mut iter)?;
55        let system_program = next_account(&mut iter)?;
56        let event_authority = next_account(&mut iter)?;
57        let program = next_account(&mut iter)?;
58
59        let remaining = iter.as_slice();
60
61        Some(CreateConfigInstructionAccounts {
62            admin,
63            global_config,
64            system_program,
65            event_authority,
66            program,
67            remaining: remaining.to_vec(),
68        })
69    }
70}