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

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

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

pub mod close_position;
pub mod collect_fund_fee;
pub mod collect_protocol_fee;
pub mod collect_remaining_rewards;
pub mod cpi_event;
pub mod create_amm_config;
pub mod create_operation_account;
pub mod create_permissionless_farm_switch;
pub mod create_pool;
pub mod create_support_mint_associated;
pub mod decrease_liquidity;
pub mod decrease_liquidity_v2;
pub mod increase_liquidity;
pub mod increase_liquidity_v2;
pub mod initialize_reward;
pub mod open_position;
pub mod open_position_v2;
pub mod open_position_with_token22_nft;
pub mod set_reward_params;
pub mod swap;
pub mod swap_router_base_in;
pub mod swap_v2;
pub mod toggle_permissionless_farm_switch;
pub mod transfer_reward_owner;
pub mod update_amm_config;
pub mod update_operation_account;
pub mod update_pool_status;
pub mod update_reward_infos;

pub use self::{
    close_position::*, collect_fund_fee::*, collect_protocol_fee::*, collect_remaining_rewards::*,
    cpi_event::*, create_amm_config::*, create_operation_account::*,
    create_permissionless_farm_switch::*, create_pool::*, create_support_mint_associated::*,
    decrease_liquidity::*, decrease_liquidity_v2::*, increase_liquidity::*,
    increase_liquidity_v2::*, initialize_reward::*, open_position::*, open_position_v2::*,
    open_position_with_token22_nft::*, set_reward_params::*, swap::*, swap_router_base_in::*,
    swap_v2::*, toggle_permissionless_farm_switch::*, transfer_reward_owner::*,
    update_amm_config::*, update_operation_account::*, update_pool_status::*,
    update_reward_infos::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum PancakeSwapInstruction {
    ClosePosition {
        program_id: solana_pubkey::Pubkey,
        data: ClosePosition,
        accounts: ClosePositionInstructionAccounts,
    },
    CollectFundFee {
        program_id: solana_pubkey::Pubkey,
        data: CollectFundFee,
        accounts: CollectFundFeeInstructionAccounts,
    },
    CollectProtocolFee {
        program_id: solana_pubkey::Pubkey,
        data: CollectProtocolFee,
        accounts: CollectProtocolFeeInstructionAccounts,
    },
    CollectRemainingRewards {
        program_id: solana_pubkey::Pubkey,
        data: CollectRemainingRewards,
        accounts: CollectRemainingRewardsInstructionAccounts,
    },
    CreateAmmConfig {
        program_id: solana_pubkey::Pubkey,
        data: CreateAmmConfig,
        accounts: CreateAmmConfigInstructionAccounts,
    },
    CreateOperationAccount {
        program_id: solana_pubkey::Pubkey,
        data: CreateOperationAccount,
        accounts: CreateOperationAccountInstructionAccounts,
    },
    CreatePermissionlessFarmSwitch {
        program_id: solana_pubkey::Pubkey,
        data: CreatePermissionlessFarmSwitch,
        accounts: CreatePermissionlessFarmSwitchInstructionAccounts,
    },
    CreatePool {
        program_id: solana_pubkey::Pubkey,
        data: CreatePool,
        accounts: CreatePoolInstructionAccounts,
    },
    CreateSupportMintAssociated {
        program_id: solana_pubkey::Pubkey,
        data: CreateSupportMintAssociated,
        accounts: CreateSupportMintAssociatedInstructionAccounts,
    },
    DecreaseLiquidity {
        program_id: solana_pubkey::Pubkey,
        data: DecreaseLiquidity,
        accounts: DecreaseLiquidityInstructionAccounts,
    },
    DecreaseLiquidityV2 {
        program_id: solana_pubkey::Pubkey,
        data: DecreaseLiquidityV2,
        accounts: DecreaseLiquidityV2InstructionAccounts,
    },
    IncreaseLiquidity {
        program_id: solana_pubkey::Pubkey,
        data: IncreaseLiquidity,
        accounts: IncreaseLiquidityInstructionAccounts,
    },
    IncreaseLiquidityV2 {
        program_id: solana_pubkey::Pubkey,
        data: IncreaseLiquidityV2,
        accounts: IncreaseLiquidityV2InstructionAccounts,
    },
    InitializeReward {
        program_id: solana_pubkey::Pubkey,
        data: InitializeReward,
        accounts: InitializeRewardInstructionAccounts,
    },
    OpenPosition {
        program_id: solana_pubkey::Pubkey,
        data: OpenPosition,
        accounts: OpenPositionInstructionAccounts,
    },
    OpenPositionV2 {
        program_id: solana_pubkey::Pubkey,
        data: OpenPositionV2,
        accounts: OpenPositionV2InstructionAccounts,
    },
    OpenPositionWithToken22Nft {
        program_id: solana_pubkey::Pubkey,
        data: OpenPositionWithToken22Nft,
        accounts: OpenPositionWithToken22NftInstructionAccounts,
    },
    SetRewardParams {
        program_id: solana_pubkey::Pubkey,
        data: SetRewardParams,
        accounts: SetRewardParamsInstructionAccounts,
    },
    Swap {
        program_id: solana_pubkey::Pubkey,
        data: Swap,
        accounts: SwapInstructionAccounts,
    },
    SwapRouterBaseIn {
        program_id: solana_pubkey::Pubkey,
        data: SwapRouterBaseIn,
        accounts: SwapRouterBaseInInstructionAccounts,
    },
    SwapV2 {
        program_id: solana_pubkey::Pubkey,
        data: SwapV2,
        accounts: SwapV2InstructionAccounts,
    },
    TogglePermissionlessFarmSwitch {
        program_id: solana_pubkey::Pubkey,
        data: TogglePermissionlessFarmSwitch,
        accounts: TogglePermissionlessFarmSwitchInstructionAccounts,
    },
    TransferRewardOwner {
        program_id: solana_pubkey::Pubkey,
        data: TransferRewardOwner,
        accounts: TransferRewardOwnerInstructionAccounts,
    },
    UpdateAmmConfig {
        program_id: solana_pubkey::Pubkey,
        data: UpdateAmmConfig,
        accounts: UpdateAmmConfigInstructionAccounts,
    },
    UpdateOperationAccount {
        program_id: solana_pubkey::Pubkey,
        data: UpdateOperationAccount,
        accounts: UpdateOperationAccountInstructionAccounts,
    },
    UpdatePoolStatus {
        program_id: solana_pubkey::Pubkey,
        data: UpdatePoolStatus,
        accounts: UpdatePoolStatusInstructionAccounts,
    },
    UpdateRewardInfos {
        program_id: solana_pubkey::Pubkey,
        data: UpdateRewardInfos,
        accounts: UpdateRewardInfosInstructionAccounts,
    },
    CpiEvent {
        program_id: solana_pubkey::Pubkey,
        data: CpiEvent,
        accounts: CpiEventInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for PancakeSwapDecoder {
    type InstructionType = PancakeSwapInstruction;

    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,
            PancakeSwapInstruction::ClosePosition => ClosePosition,
            PancakeSwapInstruction::CollectFundFee => CollectFundFee,
            PancakeSwapInstruction::CollectProtocolFee => CollectProtocolFee,
            PancakeSwapInstruction::CollectRemainingRewards => CollectRemainingRewards,
            PancakeSwapInstruction::CreateAmmConfig => CreateAmmConfig,
            PancakeSwapInstruction::CreateOperationAccount => CreateOperationAccount,
            PancakeSwapInstruction::CreatePermissionlessFarmSwitch => CreatePermissionlessFarmSwitch,
            PancakeSwapInstruction::CreatePool => CreatePool,
            PancakeSwapInstruction::CreateSupportMintAssociated => CreateSupportMintAssociated,
            PancakeSwapInstruction::DecreaseLiquidity => DecreaseLiquidity,
            PancakeSwapInstruction::DecreaseLiquidityV2 => DecreaseLiquidityV2,
            PancakeSwapInstruction::IncreaseLiquidity => IncreaseLiquidity,
            PancakeSwapInstruction::IncreaseLiquidityV2 => IncreaseLiquidityV2,
            PancakeSwapInstruction::InitializeReward => InitializeReward,
            PancakeSwapInstruction::OpenPosition => OpenPosition,
            PancakeSwapInstruction::OpenPositionV2 => OpenPositionV2,
            PancakeSwapInstruction::OpenPositionWithToken22Nft => OpenPositionWithToken22Nft,
            PancakeSwapInstruction::SetRewardParams => SetRewardParams,
            PancakeSwapInstruction::Swap => Swap,
            PancakeSwapInstruction::SwapRouterBaseIn => SwapRouterBaseIn,
            PancakeSwapInstruction::SwapV2 => SwapV2,
            PancakeSwapInstruction::TogglePermissionlessFarmSwitch => TogglePermissionlessFarmSwitch,
            PancakeSwapInstruction::TransferRewardOwner => TransferRewardOwner,
            PancakeSwapInstruction::UpdateAmmConfig => UpdateAmmConfig,
            PancakeSwapInstruction::UpdateOperationAccount => UpdateOperationAccount,
            PancakeSwapInstruction::UpdatePoolStatus => UpdatePoolStatus,
            PancakeSwapInstruction::UpdateRewardInfos => UpdateRewardInfos,
            PancakeSwapInstruction::CpiEvent => CpiEvent,
        )
    }
}
