Skip to main content

carbon_pumpfun_decoder/instructions/
set_params.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/// Sets the global state parameters.
7#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
8#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
9pub struct SetParams {
10    pub initial_virtual_token_reserves: u64,
11    pub initial_virtual_sol_reserves: u64,
12    pub initial_real_token_reserves: u64,
13    pub token_total_supply: u64,
14    pub fee_basis_points: u64,
15    pub withdraw_authority: Pubkey,
16    pub enable_migrate: bool,
17    pub pool_migration_fee: u64,
18    pub creator_fee_basis_points: u64,
19    pub set_creator_authority: Pubkey,
20    pub admin_set_creator_authority: Pubkey,
21}
22
23#[derive(Debug, Clone, PartialEq)]
24#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
25pub struct SetParamsInstructionAccounts {
26    pub global: solana_pubkey::Pubkey,
27    pub authority: solana_pubkey::Pubkey,
28    pub event_authority: solana_pubkey::Pubkey,
29    pub program: solana_pubkey::Pubkey,
30    pub remaining: Vec<solana_instruction::AccountMeta>,
31}
32
33impl SetParams {
34    pub fn decode(data: &[u8]) -> Option<Self> {
35        if data.len() < 8 {
36            return None;
37        }
38        let discriminator = &data[0..8];
39        if discriminator != [27, 234, 178, 52, 147, 2, 187, 141] {
40            return None;
41        }
42
43        let mut data_slice = data;
44
45        data_slice = &data_slice[8..];
46
47        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
48    }
49}
50
51impl ArrangeAccounts for SetParams {
52    type ArrangedAccounts = SetParamsInstructionAccounts;
53
54    fn arrange_accounts(
55        accounts: &[solana_instruction::AccountMeta],
56    ) -> Option<Self::ArrangedAccounts> {
57        let mut iter = accounts.iter();
58
59        let global = next_account(&mut iter)?;
60        let authority = next_account(&mut iter)?;
61        let event_authority = next_account(&mut iter)?;
62        let program = next_account(&mut iter)?;
63
64        let remaining = iter.as_slice();
65
66        Some(SetParamsInstructionAccounts {
67            global,
68            authority,
69            event_authority,
70            program,
71            remaining: remaining.to_vec(),
72        })
73    }
74}