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};
/// Sets the delegated fee authority for an AdaptiveFeeTier.
/// The delegated fee authority can set the fee rate for individual pools
/// initialized with the adaptive fee-tier. Only the current fee authority in
/// WhirlpoolsConfig has permission to invoke this instruction. ### Authority
/// - "fee_authority" - Set authority in the WhirlpoolConfig
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct SetDelegatedFeeAuthority {}

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SetDelegatedFeeAuthorityInstructionAccounts {
    pub whirlpools_config: solana_pubkey::Pubkey,
    pub adaptive_fee_tier: solana_pubkey::Pubkey,
    pub fee_authority: solana_pubkey::Pubkey,
    pub new_delegated_fee_authority: solana_pubkey::Pubkey,
    pub remaining: Vec<solana_instruction::AccountMeta>,
}

impl SetDelegatedFeeAuthority {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [193, 234, 231, 147, 138, 57, 3, 122] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for SetDelegatedFeeAuthority {
    type ArrangedAccounts = SetDelegatedFeeAuthorityInstructionAccounts;

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

        let whirlpools_config = next_account(&mut iter)?;
        let adaptive_fee_tier = next_account(&mut iter)?;
        let fee_authority = next_account(&mut iter)?;
        let new_delegated_fee_authority = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(SetDelegatedFeeAuthorityInstructionAccounts {
            whirlpools_config,
            adaptive_fee_tier,
            fee_authority,
            new_delegated_fee_authority,
            remaining: remaining.to_vec(),
        })
    }
}