carbon-orca-whirlpool-decoder 1.0.0

Orca Whirlpool Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use carbon_core::{account_utils::next_account, deserialize::ArrangeAccounts};
/// Delete a PositionBundle account. Burns the position bundle token in the
/// owner's wallet. ### Authority
/// - `position_bundle_owner` - The owner that owns the position bundle token.
///
/// ### Special Errors
/// - `PositionBundleNotDeletable` - The provided position bundle has open
///   positions.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct DeletePositionBundle {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct DeletePositionBundleInstructionAccounts {
    pub position_bundle: solana_pubkey::Pubkey,
    pub position_bundle_mint: solana_pubkey::Pubkey,
    pub position_bundle_token_account: solana_pubkey::Pubkey,
    pub position_bundle_owner: solana_pubkey::Pubkey,
    pub receiver: solana_pubkey::Pubkey,
    pub token_program: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl DeletePositionBundle {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [100, 25, 99, 2, 217, 239, 124, 173] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for DeletePositionBundle {
    type ArrangedAccounts = DeletePositionBundleInstructionAccounts;

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

        let position_bundle = next_account(&mut iter)?;
        let position_bundle_mint = next_account(&mut iter)?;
        let position_bundle_token_account = next_account(&mut iter)?;
        let position_bundle_owner = next_account(&mut iter)?;
        let receiver = next_account(&mut iter)?;
        let token_program = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(DeletePositionBundleInstructionAccounts {
            position_bundle,
            position_bundle_mint,
            position_bundle_token_account,
            position_bundle_owner,
            receiver,
            token_program,
            remaining: remaining.to_vec(),
        })
    }
}