Skip to main content

carbon_heaven_decoder/instructions/
admin_repay_sol.rs

1//! This code was AUTOGENERATED using the Codama library.
2use 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 AdminRepaySol {
6    pub version: u16,
7    pub amount: u64,
8}
9
10#[derive(Debug, Clone, PartialEq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub struct AdminRepaySolInstructionAccounts {
13    pub token_program: solana_pubkey::Pubkey,
14    pub associated_token_program: solana_pubkey::Pubkey,
15    pub payer: solana_pubkey::Pubkey,
16    pub admin: solana_pubkey::Pubkey,
17    pub protocol_config_state: solana_pubkey::Pubkey,
18    pub system_program: solana_pubkey::Pubkey,
19    pub protocol_staking_admin_state: solana_pubkey::Pubkey,
20    pub address_lookup_program: solana_pubkey::Pubkey,
21    pub instruction_sysvar_account_info: solana_pubkey::Pubkey,
22    pub temp_sol_holder: solana_pubkey::Pubkey,
23    pub remaining: Vec<solana_instruction::AccountMeta>,
24}
25
26impl AdminRepaySol {
27    pub fn decode(data: &[u8]) -> Option<Self> {
28        if data.len() < 8 {
29            return None;
30        }
31        let discriminator = &data[0..8];
32        if discriminator != [136, 61, 48, 232, 166, 26, 207, 46] {
33            return None;
34        }
35
36        let mut data_slice = data;
37
38        data_slice = &data_slice[8..];
39
40        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
41    }
42}
43
44impl ArrangeAccounts for AdminRepaySol {
45    type ArrangedAccounts = AdminRepaySolInstructionAccounts;
46
47    fn arrange_accounts(
48        accounts: &[solana_instruction::AccountMeta],
49    ) -> Option<Self::ArrangedAccounts> {
50        let mut iter = accounts.iter();
51
52        let token_program = next_account(&mut iter)?;
53        let associated_token_program = next_account(&mut iter)?;
54        let payer = next_account(&mut iter)?;
55        let admin = next_account(&mut iter)?;
56        let protocol_config_state = next_account(&mut iter)?;
57        let system_program = next_account(&mut iter)?;
58        let protocol_staking_admin_state = next_account(&mut iter)?;
59        let address_lookup_program = next_account(&mut iter)?;
60        let instruction_sysvar_account_info = next_account(&mut iter)?;
61        let temp_sol_holder = next_account(&mut iter)?;
62
63        let remaining = iter.as_slice();
64
65        Some(AdminRepaySolInstructionAccounts {
66            token_program,
67            associated_token_program,
68            payer,
69            admin,
70            protocol_config_state,
71            system_program,
72            protocol_staking_admin_state,
73            address_lookup_program,
74            instruction_sysvar_account_info,
75            temp_sol_holder,
76            remaining: remaining.to_vec(),
77        })
78    }
79}