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};
/// Set the whirlpool reward super authority for a WhirlpoolConfig
/// Only the current reward super authority has permission to invoke this
/// instruction. This instruction will not change the authority on any
/// `WhirlpoolRewardInfo` whirlpool rewards. ### Authority
/// - "reward_emissions_super_authority" - Set authority that can control reward
///   authorities for all pools in this config space.
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[derive(Debug, Clone, borsh::BorshSerialize, borsh::BorshDeserialize, PartialEq)]
pub struct SetRewardEmissionsSuperAuthority {}

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

impl SetRewardEmissionsSuperAuthority {
    pub fn decode(data: &[u8]) -> Option<Self> {
        if data.len() < 8 {
            return None;
        }
        let discriminator = &data[0..8];
        if discriminator != [207, 5, 200, 209, 122, 56, 82, 183] {
            return None;
        }

        let mut data_slice = data;

        data_slice = &data_slice[8..];

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

impl ArrangeAccounts for SetRewardEmissionsSuperAuthority {
    type ArrangedAccounts = SetRewardEmissionsSuperAuthorityInstructionAccounts;

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

        let whirlpools_config = next_account(&mut iter)?;
        let reward_emissions_super_authority = next_account(&mut iter)?;
        let new_reward_emissions_super_authority = next_account(&mut iter)?;

        let remaining = iter.as_slice();

        Some(SetRewardEmissionsSuperAuthorityInstructionAccounts {
            whirlpools_config,
            reward_emissions_super_authority,
            new_reward_emissions_super_authority,
            remaining: remaining.to_vec(),
        })
    }
}