carbon-moonshot-decoder 1.0.0

Moonshot Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct MigrateFunds {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MigrateFundsInstructionAccounts {
    pub backend_authority: solana_pubkey::Pubkey,
    pub migration_authority: solana_pubkey::Pubkey,
    pub curve_account: solana_pubkey::Pubkey,
    pub curve_token_account: solana_pubkey::Pubkey,
    pub migration_authority_token_account: solana_pubkey::Pubkey,
    pub mint: solana_pubkey::Pubkey,
    pub dex_fee_account: solana_pubkey::Pubkey,
    pub helio_fee_account: solana_pubkey::Pubkey,
    pub config_account: solana_pubkey::Pubkey,
    pub system_program: solana_pubkey::Pubkey,
    pub token_program: solana_pubkey::Pubkey,
    pub associated_token_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl MigrateFunds {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [42, 229, 10, 231, 189, 62, 193, 174] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

        borsh::BorshDeserialize::deserialize(&mut data_slice).ok()
    }
}

impl ArrangeAccounts for MigrateFunds {
    type ArrangedAccounts = MigrateFundsInstructionAccounts;

    fn arrange_accounts(
        accounts: &[solana_instruction::AccountMeta],
    ) -> Option<Self::ArrangedAccounts> {
        let mut iter = accounts.iter();

        let backend_authority = next_account(&mut iter)?;
        let migration_authority = next_account(&mut iter)?;
        let curve_account = next_account(&mut iter)?;
        let curve_token_account = next_account(&mut iter)?;
        let migration_authority_token_account = next_account(&mut iter)?;
        let mint = next_account(&mut iter)?;
        let dex_fee_account = next_account(&mut iter)?;
        let helio_fee_account = next_account(&mut iter)?;
        let config_account = next_account(&mut iter)?;
        let system_program = next_account(&mut iter)?;
        let token_program = next_account(&mut iter)?;
        let associated_token_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(MigrateFundsInstructionAccounts {
            backend_authority,
            migration_authority,
            curve_account,
            curve_token_account,
            migration_authority_token_account,
            mint,
            dex_fee_account,
            helio_fee_account,
            config_account,
            system_program,
            token_program,
            associated_token_program,
            remaining: remaining.to_vec(),
        })
    }
}