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

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

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

pub mod claim;
pub mod claim_cashback_pumpfun;
pub mod claim_cashback_pumpswap;
pub mod cpi_event;
pub mod create_token_account;
pub mod create_token_account_with_seed;
pub mod proxy_swap;
pub mod swap;
pub mod swap_tob_v3;
pub mod swap_tob_v3_enhanced;
pub mod swap_tob_v3_with_receiver;
pub mod swap_v3;
pub mod swap_v3_with_cpi_event;
pub mod wrap_unwrap_v3;
pub mod wrap_unwrap_v3_with_receiver;

pub use self::{
    claim::*, claim_cashback_pumpfun::*, claim_cashback_pumpswap::*, cpi_event::*,
    create_token_account::*, create_token_account_with_seed::*, proxy_swap::*, swap::*,
    swap_tob_v3::*, swap_tob_v3_enhanced::*, swap_tob_v3_with_receiver::*, swap_v3::*,
    swap_v3_with_cpi_event::*, wrap_unwrap_v3::*, wrap_unwrap_v3_with_receiver::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum OkxDexInstruction {
    Claim {
        program_id: solana_pubkey::Pubkey,
        data: Claim,
        accounts: ClaimInstructionAccounts,
    },
    ClaimCashbackPumpfun {
        program_id: solana_pubkey::Pubkey,
        data: ClaimCashbackPumpfun,
        accounts: ClaimCashbackPumpfunInstructionAccounts,
    },
    ClaimCashbackPumpswap {
        program_id: solana_pubkey::Pubkey,
        data: ClaimCashbackPumpswap,
        accounts: ClaimCashbackPumpswapInstructionAccounts,
    },
    CreateTokenAccount {
        program_id: solana_pubkey::Pubkey,
        data: CreateTokenAccount,
        accounts: CreateTokenAccountInstructionAccounts,
    },
    CreateTokenAccountWithSeed {
        program_id: solana_pubkey::Pubkey,
        data: CreateTokenAccountWithSeed,
        accounts: CreateTokenAccountWithSeedInstructionAccounts,
    },
    ProxySwap {
        program_id: solana_pubkey::Pubkey,
        data: ProxySwap,
        accounts: ProxySwapInstructionAccounts,
    },
    Swap {
        program_id: solana_pubkey::Pubkey,
        data: Swap,
        accounts: SwapInstructionAccounts,
    },
    SwapTobV3 {
        program_id: solana_pubkey::Pubkey,
        data: SwapTobV3,
        accounts: SwapTobV3InstructionAccounts,
    },
    SwapTobV3Enhanced {
        program_id: solana_pubkey::Pubkey,
        data: SwapTobV3Enhanced,
        accounts: SwapTobV3EnhancedInstructionAccounts,
    },
    SwapTobV3WithReceiver {
        program_id: solana_pubkey::Pubkey,
        data: SwapTobV3WithReceiver,
        accounts: SwapTobV3WithReceiverInstructionAccounts,
    },
    SwapV3 {
        program_id: solana_pubkey::Pubkey,
        data: SwapV3,
        accounts: SwapV3InstructionAccounts,
    },
    SwapV3WithCpiEvent {
        program_id: solana_pubkey::Pubkey,
        data: SwapV3WithCpiEvent,
        accounts: SwapV3WithCpiEventInstructionAccounts,
    },
    WrapUnwrapV3 {
        program_id: solana_pubkey::Pubkey,
        data: WrapUnwrapV3,
        accounts: WrapUnwrapV3InstructionAccounts,
    },
    WrapUnwrapV3WithReceiver {
        program_id: solana_pubkey::Pubkey,
        data: WrapUnwrapV3WithReceiver,
        accounts: WrapUnwrapV3WithReceiverInstructionAccounts,
    },
    CpiEvent {
        program_id: solana_pubkey::Pubkey,
        data: CpiEvent,
        accounts: CpiEventInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for OkxDexDecoder {
    type InstructionType = OkxDexInstruction;

    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,
            OkxDexInstruction::Claim => Claim,
            OkxDexInstruction::ClaimCashbackPumpfun => ClaimCashbackPumpfun,
            OkxDexInstruction::ClaimCashbackPumpswap => ClaimCashbackPumpswap,
            OkxDexInstruction::CreateTokenAccount => CreateTokenAccount,
            OkxDexInstruction::CreateTokenAccountWithSeed => CreateTokenAccountWithSeed,
            OkxDexInstruction::ProxySwap => ProxySwap,
            OkxDexInstruction::Swap => Swap,
            OkxDexInstruction::SwapTobV3 => SwapTobV3,
            OkxDexInstruction::SwapTobV3Enhanced => SwapTobV3Enhanced,
            OkxDexInstruction::SwapTobV3WithReceiver => SwapTobV3WithReceiver,
            OkxDexInstruction::SwapV3 => SwapV3,
            OkxDexInstruction::SwapV3WithCpiEvent => SwapV3WithCpiEvent,
            OkxDexInstruction::WrapUnwrapV3 => WrapUnwrapV3,
            OkxDexInstruction::WrapUnwrapV3WithReceiver => WrapUnwrapV3WithReceiver,
            OkxDexInstruction::CpiEvent => CpiEvent,
        )
    }
}
