carbon-sharky-decoder 2.0.0

Sharky 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 WithdrawLiquidityTokenPool {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct WithdrawLiquidityTokenPoolInstructionAccounts {
    pub orderbook: solana_pubkey::Pubkey,
    pub pool: solana_pubkey::Pubkey,
    pub usdc_vault: solana_pubkey::Pubkey,
    pub lender: solana_pubkey::Pubkey,
    pub lender_usdc: solana_pubkey::Pubkey,
    pub loan_mint: solana_pubkey::Pubkey,
    pub token_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl WithdrawLiquidityTokenPool {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [55, 103, 20, 35, 39, 183, 180, 64] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for WithdrawLiquidityTokenPool {
    type ArrangedAccounts = WithdrawLiquidityTokenPoolInstructionAccounts;

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

        let orderbook = next_account(&mut iter)?;
        let pool = next_account(&mut iter)?;
        let usdc_vault = next_account(&mut iter)?;
        let lender = next_account(&mut iter)?;
        let lender_usdc = next_account(&mut iter)?;
        let loan_mint = next_account(&mut iter)?;
        let token_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(WithdrawLiquidityTokenPoolInstructionAccounts {
            orderbook,
            pool,
            usdc_vault,
            lender,
            lender_usdc,
            loan_mint,
            token_program,
            remaining: remaining.to_vec(),
        })
    }
}