//! 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>
//!

use num_derive::FromPrimitive;
use thiserror::Error;

#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum RaydiumAmmError {
    /// 0 - AlreadyInUse
    #[error("AlreadyInUse")]
    AlreadyInUse = 0x0,
    /// 1 - InvalidProgramAddress
    #[error("InvalidProgramAddress")]
    InvalidProgramAddress = 0x1,
    /// 2 - ExpectedMint
    #[error("ExpectedMint")]
    ExpectedMint = 0x2,
    /// 3 - ExpectedAccount
    #[error("ExpectedAccount")]
    ExpectedAccount = 0x3,
    /// 4 - InvalidCoinVault
    #[error("InvalidCoinVault")]
    InvalidCoinVault = 0x4,
    /// 5 - InvalidPCVault
    #[error("InvalidPCVault")]
    InvalidPCVault = 0x5,
    /// 6 - InvalidTokenLP
    #[error("InvalidTokenLP")]
    InvalidTokenLP = 0x6,
    /// 7 - InvalidDestTokenCoin
    #[error("InvalidDestTokenCoin")]
    InvalidDestTokenCoin = 0x7,
    /// 8 - InvalidDestTokenPC
    #[error("InvalidDestTokenPC")]
    InvalidDestTokenPC = 0x8,
    /// 9 - InvalidPoolMint
    #[error("InvalidPoolMint")]
    InvalidPoolMint = 0x9,
    /// 10 - InvalidOpenOrders
    #[error("InvalidOpenOrders")]
    InvalidOpenOrders = 0xA,
    /// 11 - InvalidSerumMarket
    #[error("InvalidSerumMarket")]
    InvalidSerumMarket = 0xB,
    /// 12 - InvalidSerumProgram
    #[error("InvalidSerumProgram")]
    InvalidSerumProgram = 0xC,
    /// 13 - InvalidTargetOrders
    #[error("InvalidTargetOrders")]
    InvalidTargetOrders = 0xD,
    /// 14 - InvalidWithdrawQueue
    #[error("InvalidWithdrawQueue")]
    InvalidWithdrawQueue = 0xE,
    /// 15 - InvalidTempLp
    #[error("InvalidTempLp")]
    InvalidTempLp = 0xF,
    /// 16 - InvalidCoinMint
    #[error("InvalidCoinMint")]
    InvalidCoinMint = 0x10,
    /// 17 - InvalidPCMint
    #[error("InvalidPCMint")]
    InvalidPCMint = 0x11,
    /// 18 - InvalidOwner
    #[error("InvalidOwner")]
    InvalidOwner = 0x12,
    /// 19 - InvalidSupply
    #[error("InvalidSupply")]
    InvalidSupply = 0x13,
    /// 20 - InvalidDelegate
    #[error("InvalidDelegate")]
    InvalidDelegate = 0x14,
    /// 21 - Invalid Sign Account
    #[error("Invalid Sign Account")]
    InvalidSignAccount = 0x15,
    /// 22 - InvalidStatus
    #[error("InvalidStatus")]
    InvalidStatus = 0x16,
    /// 23 - Invalid instruction
    #[error("Invalid instruction")]
    InvalidInstruction = 0x17,
    /// 24 - Wrong accounts number
    #[error("Wrong accounts number")]
    WrongAccountsNumber = 0x18,
    /// 25 - Withdraw_transfer is busy
    #[error("Withdraw_transfer is busy")]
    WithdrawTransferBusy = 0x19,
    /// 26 - WithdrawQueue is full
    #[error("WithdrawQueue is full")]
    WithdrawQueueFull = 0x1A,
    /// 27 - WithdrawQueue is empty
    #[error("WithdrawQueue is empty")]
    WithdrawQueueEmpty = 0x1B,
    /// 28 - Params Set is invalid
    #[error("Params Set is invalid")]
    InvalidParamsSet = 0x1C,
    /// 29 - InvalidInput
    #[error("InvalidInput")]
    InvalidInput = 0x1D,
    /// 30 - instruction exceeds desired slippage limit
    #[error("instruction exceeds desired slippage limit")]
    ExceededSlippage = 0x1E,
    /// 31 - CalculationExRateFailure
    #[error("CalculationExRateFailure")]
    CalculationExRateFailure = 0x1F,
    /// 32 - Checked_Sub Overflow
    #[error("Checked_Sub Overflow")]
    CheckedSubOverflow = 0x20,
    /// 33 - Checked_Add Overflow
    #[error("Checked_Add Overflow")]
    CheckedAddOverflow = 0x21,
    /// 34 - Checked_Mul Overflow
    #[error("Checked_Mul Overflow")]
    CheckedMulOverflow = 0x22,
    /// 35 - Checked_Div Overflow
    #[error("Checked_Div Overflow")]
    CheckedDivOverflow = 0x23,
    /// 36 - Empty Funds
    #[error("Empty Funds")]
    CheckedEmptyFunds = 0x24,
    /// 37 - Calc pnl error
    #[error("Calc pnl error")]
    CalcPnlError = 0x25,
    /// 38 - InvalidSplTokenProgram
    #[error("InvalidSplTokenProgram")]
    InvalidSplTokenProgram = 0x26,
    /// 39 - Take Pnl error
    #[error("Take Pnl error")]
    TakePnlError = 0x27,
    /// 40 - Insufficient funds
    #[error("Insufficient funds")]
    InsufficientFunds = 0x28,
    /// 41 - Conversion to u64 failed with an overflow or underflow
    #[error("Conversion to u64 failed with an overflow or underflow")]
    ConversionFailure = 0x29,
    /// 42 - user token input does not match amm
    #[error("user token input does not match amm")]
    InvalidUserToken = 0x2A,
    /// 43 - InvalidSrmMint
    #[error("InvalidSrmMint")]
    InvalidSrmMint = 0x2B,
    /// 44 - InvalidSrmToken
    #[error("InvalidSrmToken")]
    InvalidSrmToken = 0x2C,
    /// 45 - TooManyOpenOrders
    #[error("TooManyOpenOrders")]
    TooManyOpenOrders = 0x2D,
    /// 46 - OrderAtSlotIsPlaced
    #[error("OrderAtSlotIsPlaced")]
    OrderAtSlotIsPlaced = 0x2E,
    /// 47 - InvalidSysProgramAddress
    #[error("InvalidSysProgramAddress")]
    InvalidSysProgramAddress = 0x2F,
    /// 48 - The provided fee does not match the program owner's constraints
    #[error("The provided fee does not match the program owner's constraints")]
    InvalidFee = 0x30,
    /// 49 - Repeat create amm about market
    #[error("Repeat create amm about market")]
    RepeatCreateAmm = 0x31,
    /// 50 - Not allow Zero LP
    #[error("Not allow Zero LP")]
    NotAllowZeroLP = 0x32,
    /// 51 - Token account has a close authority
    #[error("Token account has a close authority")]
    InvalidCloseAuthority = 0x33,
    /// 52 - Pool token mint has a freeze authority
    #[error("Pool token mint has a freeze authority")]
    InvalidFreezeAuthority = 0x34,
    /// 53 - InvalidReferPCMint
    #[error("InvalidReferPCMint")]
    InvalidReferPCMint = 0x35,
    /// 54 - InvalidConfigAccount
    #[error("InvalidConfigAccount")]
    InvalidConfigAccount = 0x36,
    /// 55 - Repeat create staking config account
    #[error("Repeat create staking config account")]
    RepeatCreateConfigAccount = 0x37,
    /// 56 - Unknown Amm Error
    #[error("Unknown Amm Error")]
    UnknownAmmError = 0x38,
}

impl solana_program_error::PrintProgramError for RaydiumAmmError {
    fn print<E>(&self) {
        solana_msg::msg!(&self.to_string());
    }
}

impl<T> solana_decode_error::DecodeError<T> for RaydiumAmmError {
    fn type_of() -> &'static str {
        "RaydiumAmmError"
    }
}
