//! This code was AUTOGENERATED using the Codama library.
//! Please DO NOT EDIT THIS FILE, instead use visitors
//! to add features, then rerun Codama to update it.
//!
//! <https://github.com/codama-idl/codama>
//!

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

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

use crate::{BonkswapDecoder, PROGRAM_ID};

pub mod add_supply;
pub mod add_tokens;
pub mod close_pool;
pub mod create_dual_farm;
pub mod create_farm;
pub mod create_pool;
pub mod create_provider;
pub mod create_state;
pub mod create_triple_farm;
pub mod reset_farm;
pub mod swap;
pub mod update_fees;
pub mod update_reward_tokens;
pub mod withdraw_buyback;
pub mod withdraw_lp_fee;
pub mod withdraw_mercanti_fee;
pub mod withdraw_project_fee;
pub mod withdraw_rewards;
pub mod withdraw_shares;

pub use self::add_supply::*;
pub use self::add_tokens::*;
pub use self::close_pool::*;
pub use self::create_dual_farm::*;
pub use self::create_farm::*;
pub use self::create_pool::*;
pub use self::create_provider::*;
pub use self::create_state::*;
pub use self::create_triple_farm::*;
pub use self::reset_farm::*;
pub use self::swap::*;
pub use self::update_fees::*;
pub use self::update_reward_tokens::*;
pub use self::withdraw_buyback::*;
pub use self::withdraw_lp_fee::*;
pub use self::withdraw_mercanti_fee::*;
pub use self::withdraw_project_fee::*;
pub use self::withdraw_rewards::*;
pub use self::withdraw_shares::*;

#[derive(Debug, Clone, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(tag = "type", content = "data"))]
pub enum BonkswapInstruction {
    AddSupply(AddSupply),
    AddTokens(AddTokens),
    ClosePool(ClosePool),
    CreateDualFarm(CreateDualFarm),
    CreateFarm(CreateFarm),
    CreatePool(CreatePool),
    CreateProvider(CreateProvider),
    CreateState(CreateState),
    CreateTripleFarm(CreateTripleFarm),
    ResetFarm(ResetFarm),
    Swap(Swap),
    UpdateFees(UpdateFees),
    UpdateRewardTokens(UpdateRewardTokens),
    WithdrawBuyback(WithdrawBuyback),
    WithdrawLpFee(WithdrawLpFee),
    WithdrawMercantiFee(WithdrawMercantiFee),
    WithdrawProjectFee(WithdrawProjectFee),
    WithdrawRewards(WithdrawRewards),
    WithdrawShares(WithdrawShares),
}

impl carbon_core::instruction::InstructionDecoder<'_> for BonkswapDecoder {
    type InstructionType = BonkswapInstruction;

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

        let data = instruction.data.as_slice();

        // Try to decode CreatePool
        {
            if let Some(decoded) = create_pool::CreatePool::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreatePool(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode CreateProvider
        {
            if let Some(decoded) = create_provider::CreateProvider::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreateProvider(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode CreateState
        {
            if let Some(decoded) = create_state::CreateState::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreateState(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode AddTokens
        {
            if let Some(decoded) = add_tokens::AddTokens::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::AddTokens(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawBuyback
        {
            if let Some(decoded) = withdraw_buyback::WithdrawBuyback::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawBuyback(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode Swap
        {
            if let Some(decoded) = swap::Swap::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::Swap(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawShares
        {
            if let Some(decoded) = withdraw_shares::WithdrawShares::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawShares(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawLpFee
        {
            if let Some(decoded) = withdraw_lp_fee::WithdrawLpFee::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawLpFee(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawProjectFee
        {
            if let Some(decoded) = withdraw_project_fee::WithdrawProjectFee::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawProjectFee(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode CreateFarm
        {
            if let Some(decoded) = create_farm::CreateFarm::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreateFarm(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode CreateDualFarm
        {
            if let Some(decoded) = create_dual_farm::CreateDualFarm::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreateDualFarm(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode CreateTripleFarm
        {
            if let Some(decoded) = create_triple_farm::CreateTripleFarm::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::CreateTripleFarm(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawRewards
        {
            if let Some(decoded) = withdraw_rewards::WithdrawRewards::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawRewards(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode ClosePool
        {
            if let Some(decoded) = close_pool::ClosePool::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::ClosePool(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode WithdrawMercantiFee
        {
            if let Some(decoded) = withdraw_mercanti_fee::WithdrawMercantiFee::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::WithdrawMercantiFee(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode AddSupply
        {
            if let Some(decoded) = add_supply::AddSupply::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::AddSupply(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode UpdateFees
        {
            if let Some(decoded) = update_fees::UpdateFees::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::UpdateFees(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode ResetFarm
        {
            if let Some(decoded) = reset_farm::ResetFarm::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::ResetFarm(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }
        // Try to decode UpdateRewardTokens
        {
            if let Some(decoded) = update_reward_tokens::UpdateRewardTokens::decode(data) {
                return Some(carbon_core::instruction::DecodedInstruction {
                    program_id: instruction.program_id,
                    data: BonkswapInstruction::UpdateRewardTokens(decoded),
                    accounts: instruction.accounts.clone(),
                });
            }
        }

        None
    }
}
