carbon-dflow-aggregator-v4-decoder 2.0.0

Dflow Aggregator V4 Decoder
Documentation
//! This code was AUTOGENERATED using the Codama library.
use crate::{DflowAggregatorV4Decoder, PROGRAM_ID};

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

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

pub mod close_empty_token_account;
pub mod close_order;
pub mod cpi_event;
pub mod create_referral_token_account_idempotent;
pub mod fill_order;
pub mod init_market_ledger_idempotent;
pub mod open_order;
pub mod swap;
pub mod swap2;
pub mod swap2_with_destination;
pub mod swap2_with_destination_native;
pub mod swap_with_destination;
pub mod swap_with_destination_native;
pub mod transfer_fee;
pub mod transfer_sol;
pub mod transfer_to_sponsor;
pub mod unwrap_sol;
pub mod wrap_sol;

pub use self::{
    close_empty_token_account::*, close_order::*, cpi_event::*,
    create_referral_token_account_idempotent::*, fill_order::*, init_market_ledger_idempotent::*,
    open_order::*, swap::*, swap2::*, swap2_with_destination::*, swap2_with_destination_native::*,
    swap_with_destination::*, swap_with_destination_native::*, transfer_fee::*, transfer_sol::*,
    transfer_to_sponsor::*, unwrap_sol::*, wrap_sol::*,
};

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum DflowAggregatorV4Instruction {
    CloseEmptyTokenAccount {
        program_id: solana_pubkey::Pubkey,
        data: CloseEmptyTokenAccount,
        accounts: CloseEmptyTokenAccountInstructionAccounts,
    },
    CloseOrder {
        program_id: solana_pubkey::Pubkey,
        data: CloseOrder,
        accounts: CloseOrderInstructionAccounts,
    },
    CreateReferralTokenAccountIdempotent {
        program_id: solana_pubkey::Pubkey,
        data: CreateReferralTokenAccountIdempotent,
        accounts: CreateReferralTokenAccountIdempotentInstructionAccounts,
    },
    FillOrder {
        program_id: solana_pubkey::Pubkey,
        data: FillOrder,
        accounts: FillOrderInstructionAccounts,
    },
    InitMarketLedgerIdempotent {
        program_id: solana_pubkey::Pubkey,
        data: InitMarketLedgerIdempotent,
        accounts: InitMarketLedgerIdempotentInstructionAccounts,
    },
    OpenOrder {
        program_id: solana_pubkey::Pubkey,
        data: OpenOrder,
        accounts: OpenOrderInstructionAccounts,
    },
    Swap {
        program_id: solana_pubkey::Pubkey,
        data: Swap,
        accounts: SwapInstructionAccounts,
    },
    Swap2 {
        program_id: solana_pubkey::Pubkey,
        data: Swap2,
        accounts: Swap2InstructionAccounts,
    },
    Swap2WithDestination {
        program_id: solana_pubkey::Pubkey,
        data: Swap2WithDestination,
        accounts: Swap2WithDestinationInstructionAccounts,
    },
    Swap2WithDestinationNative {
        program_id: solana_pubkey::Pubkey,
        data: Swap2WithDestinationNative,
        accounts: Swap2WithDestinationNativeInstructionAccounts,
    },
    SwapWithDestination {
        program_id: solana_pubkey::Pubkey,
        data: SwapWithDestination,
        accounts: SwapWithDestinationInstructionAccounts,
    },
    SwapWithDestinationNative {
        program_id: solana_pubkey::Pubkey,
        data: SwapWithDestinationNative,
        accounts: SwapWithDestinationNativeInstructionAccounts,
    },
    TransferFee {
        program_id: solana_pubkey::Pubkey,
        data: TransferFee,
        accounts: TransferFeeInstructionAccounts,
    },
    TransferSol {
        program_id: solana_pubkey::Pubkey,
        data: TransferSol,
        accounts: TransferSolInstructionAccounts,
    },
    TransferToSponsor {
        program_id: solana_pubkey::Pubkey,
        data: TransferToSponsor,
        accounts: TransferToSponsorInstructionAccounts,
    },
    UnwrapSol {
        program_id: solana_pubkey::Pubkey,
        data: UnwrapSol,
        accounts: UnwrapSolInstructionAccounts,
    },
    WrapSol {
        program_id: solana_pubkey::Pubkey,
        data: WrapSol,
        accounts: WrapSolInstructionAccounts,
    },
    CpiEvent {
        program_id: solana_pubkey::Pubkey,
        data: CpiEvent,
        accounts: CpiEventInstructionAccounts,
    },
}

impl carbon_core::instruction::InstructionDecoder<'_> for DflowAggregatorV4Decoder {
    type InstructionType = DflowAggregatorV4Instruction;

    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,
            DflowAggregatorV4Instruction::CloseEmptyTokenAccount => CloseEmptyTokenAccount,
            DflowAggregatorV4Instruction::CloseOrder => CloseOrder,
            DflowAggregatorV4Instruction::CreateReferralTokenAccountIdempotent => CreateReferralTokenAccountIdempotent,
            DflowAggregatorV4Instruction::FillOrder => FillOrder,
            DflowAggregatorV4Instruction::InitMarketLedgerIdempotent => InitMarketLedgerIdempotent,
            DflowAggregatorV4Instruction::OpenOrder => OpenOrder,
            DflowAggregatorV4Instruction::Swap => Swap,
            DflowAggregatorV4Instruction::Swap2 => Swap2,
            DflowAggregatorV4Instruction::Swap2WithDestination => Swap2WithDestination,
            DflowAggregatorV4Instruction::Swap2WithDestinationNative => Swap2WithDestinationNative,
            DflowAggregatorV4Instruction::SwapWithDestination => SwapWithDestination,
            DflowAggregatorV4Instruction::SwapWithDestinationNative => SwapWithDestinationNative,
            DflowAggregatorV4Instruction::TransferFee => TransferFee,
            DflowAggregatorV4Instruction::TransferSol => TransferSol,
            DflowAggregatorV4Instruction::TransferToSponsor => TransferToSponsor,
            DflowAggregatorV4Instruction::UnwrapSol => UnwrapSol,
            DflowAggregatorV4Instruction::WrapSol => WrapSol,
            DflowAggregatorV4Instruction::CpiEvent => CpiEvent,
        )
    }
}