//! This code was AUTOGENERATED using the Codama library.
use crate::{FluxbeamDecoder, PROGRAM_ID};

#[cfg(feature = "postgres")]
pub mod postgres;

#[cfg(feature = "graphql")]
pub mod graphql;

pub mod deposit_all_token_types;
pub mod deposit_single_token_type_exact_amount_in;
pub mod initialize;
pub mod swap;
pub mod withdraw_all_token_types;
pub mod withdraw_single_token_type_exact_amount_out;

pub use self::{
    deposit_all_token_types::*, deposit_single_token_type_exact_amount_in::*, initialize::*,
    swap::*, withdraw_all_token_types::*, withdraw_single_token_type_exact_amount_out::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum FluxbeamInstruction {
    DepositAllTokenTypes {
        program_id: solana_pubkey::Pubkey,
        data: DepositAllTokenTypes,
        accounts: DepositAllTokenTypesInstructionAccounts,
    },
    DepositSingleTokenTypeExactAmountIn {
        program_id: solana_pubkey::Pubkey,
        data: DepositSingleTokenTypeExactAmountIn,
        accounts: DepositSingleTokenTypeExactAmountInInstructionAccounts,
    },
    Initialize {
        program_id: solana_pubkey::Pubkey,
        data: Initialize,
        accounts: InitializeInstructionAccounts,
    },
    Swap {
        program_id: solana_pubkey::Pubkey,
        data: Swap,
        accounts: SwapInstructionAccounts,
    },
    WithdrawAllTokenTypes {
        program_id: solana_pubkey::Pubkey,
        data: WithdrawAllTokenTypes,
        accounts: WithdrawAllTokenTypesInstructionAccounts,
    },
    WithdrawSingleTokenTypeExactAmountOut {
        program_id: solana_pubkey::Pubkey,
        data: WithdrawSingleTokenTypeExactAmountOut,
        accounts: WithdrawSingleTokenTypeExactAmountOutInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for FluxbeamDecoder {
    type InstructionType = FluxbeamInstruction;

    fn decode_instruction(
        &self,
        instruction: &solana_instruction::Instruction,
    ) -> Option<Self::InstructionType> {
        if instruction.program_id != PROGRAM_ID {
            return None;
        }

        carbon_core::try_decode_instructions!(
            instruction,
            PROGRAM_ID,
            FluxbeamInstruction::DepositAllTokenTypes => DepositAllTokenTypes,
            FluxbeamInstruction::DepositSingleTokenTypeExactAmountIn => DepositSingleTokenTypeExactAmountIn,
            FluxbeamInstruction::Initialize => Initialize,
            FluxbeamInstruction::Swap => Swap,
            FluxbeamInstruction::WithdrawAllTokenTypes => WithdrawAllTokenTypes,
            FluxbeamInstruction::WithdrawSingleTokenTypeExactAmountOut => WithdrawSingleTokenTypeExactAmountOut,
        )
    }
}
