//! 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 TunaError {
    /// 6500 - Type cast overflow
    #[error("Type cast overflow")]
    TypeCastOverflow = 0x1964,
    /// 6501 - Math overflow
    #[error("Math overflow")]
    MathOverflow = 0x1965,
    /// 6502 - Math underflow
    #[error("Math underflow")]
    MathUnderflow = 0x1966,
    /// 6559 - Lending vault is not initialized
    #[error("Lending vault is not initialized")]
    VaultNotInitialized = 0x199F,
    /// 6560 - Withdraw request the exceeds user balance
    #[error("Withdraw request the exceeds user balance")]
    WithdrawRequestExceedsUserBalance = 0x19A0,
    /// 6561 - Zero price range: the lower price is equal to upper price)
    #[error("Zero price range: the lower price is equal to upper price)")]
    ZeroPriceRange = 0x19A1,
    /// 6600 - Amount slippage exceeded
    #[error("Amount slippage exceeded")]
    AmountSlippageExceeded = 0x19C8,
    /// 6601 - Bad debt is not allowed for the executed instruction
    #[error("Bad debt is not allowed for the executed instruction")]
    BadDebt = 0x19C9,
    /// 6602 - Invalid number of remaining accounts
    #[error("Invalid number of remaining accounts")]
    InvalidRemainingAccountsLength = 0x19CA,
    /// 6603 - Invalid instruction arguments
    #[error("Invalid instruction arguments")]
    InvalidInstructionArguments = 0x19CB,
    /// 6604 - Invalid market maker
    #[error("Invalid market maker")]
    InvalidMarketMaker = 0x19CC,
    /// 6605 - Invalid account discriminator
    #[error("Invalid account discriminator")]
    InvalidAccountDiscriminator = 0x19CD,
    /// 6606 - Invalid account owner
    #[error("Invalid account owner")]
    InvalidAccountOwner = 0x19CE,
    /// 6607 - Invalid Fusion or Orca pool
    #[error("Invalid Fusion or Orca pool")]
    InvalidPool = 0x19CF,
    /// 6608 - Vault address is invalid
    #[error("Vault address is invalid")]
    InvalidVault = 0x19D0,
    /// 6609 - Insufficient liquidity
    #[error("Insufficient liquidity")]
    InsufficientLiquidity = 0x19D1,
    /// 6610 - Interest rate is out of range
    #[error("Interest rate is out of range")]
    InterestRateIsOutOfRange = 0x19D2,
    /// 6611 - Leverage is out or range
    #[error("Leverage is out or range")]
    LeverageIsOutOfRange = 0x19D3,
    /// 6612 - Leftovers percentage exceeded the maximum allowed value
    #[error("Leftovers percentage exceeded the maximum allowed value")]
    LeftoversExceeded = 0x19D4,
    /// 6613 - Liquidation fee is out of range
    #[error("Liquidation fee is out of range")]
    LiquidationFeeIsOutOfRange = 0x19D5,
    /// 6614 - Liquidation threshold is out of range
    #[error("Liquidation threshold is out of range")]
    LiquidationThresholdIsOutOfRange = 0x19D6,
    /// 6615 - Market is disabled
    #[error("Market is disabled")]
    MarketDisabled = 0x19D7,
    /// 6616 - Exceed the maximum allowed debt for the market
    #[error("Exceed the maximum allowed debt for the market")]
    MarketDebtLimitExceeded = 0x19D8,
    /// 6617 - Unable to call transfer hook without extra accounts
    #[error("Unable to call transfer hook without extra accounts")]
    NoExtraAccountsForTransferHook = 0x19D9,
    /// 6618 - Oracle price is stale
    #[error("Oracle price is stale")]
    OracleStalePrice = 0x19DA,
    /// 6619 - Oracle price deviation threshold exceeded
    #[error("Oracle price deviation threshold exceeded")]
    OraclePriceDeviationThresholdExceeded = 0x19DB,
    /// 6620 - Oracle price deviation threshold out of range
    #[error("Oracle price deviation threshold out of range")]
    OraclePriceDeviationThresholdOutOfRange = 0x19DC,
    /// 6621 - Invalid oracle price update account
    #[error("Invalid oracle price update account")]
    InvalidPriceUpdateAccount = 0x19DD,
    /// 6622 - Position is healthy
    #[error("Position is healthy")]
    PositionIsHealthy = 0x19DE,
    /// 6623 - Position is already liquidated
    #[error("Position is already liquidated")]
    PositionIsLiquidated = 0x19DF,
    /// 6624 - Position is unhealthy
    #[error("Position is unhealthy")]
    PositionIsUnhealthy = 0x19E0,
    /// 6625 - Position is not empty
    #[error("Position is not empty")]
    PositionNotEmpty = 0x19E1,
    /// 6626 - Position is empty
    #[error("Position is empty")]
    PositionIsEmpty = 0x19E2,
    /// 6627 - Unable to claim yield for auto re-balanceable positions
    #[error("Unable to claim yield for auto re-balanceable positions")]
    PositionIsAutoRebalanceable = 0x19E3,
    /// 6628 - Position size exceeds the maximum allowed value
    #[error("Position size exceeds the maximum allowed value")]
    PositionSizeLimitExceeded = 0x19E4,
    /// 6640 - Protocol fee is out of range
    #[error("Protocol fee is out of range")]
    ProtocolFeeIsOutOfRange = 0x19F0,
    /// 6641 - Rebalance conditions are not met
    #[error("Rebalance conditions are not met")]
    RebalanceConditionsNotMet = 0x19F1,
    /// 6642 - Same accounts type is provided more than once
    #[error("Same accounts type is provided more than once")]
    RemainingAccountsDuplicatedAccountsType = 0x19F2,
    /// 6643 - Invalid remaining accounts
    #[error("Invalid remaining accounts")]
    RemainingAccountsInvalidSlice = 0x19F3,
    /// 6644 - Invalid remaining accounts slice length
    #[error("Invalid remaining accounts slice length")]
    RemainingAccountsInvalidSliceLength = 0x19F4,
    /// 6645 - Insufficient remaining accounts
    #[error("Insufficient remaining accounts")]
    RemainingAccountsInsufficient = 0x19F5,
    /// 6646 - Required remaining account is not provided
    #[error("Required remaining account is not provided")]
    RequiredRemainingAccountNotProvided = 0x19F6,
    /// 6647 - Swap equation solver failed to t find the root
    #[error("Swap equation solver failed to t find the root")]
    SolverFailedToFindRoot = 0x19F7,
    /// 6648 - Lending vault supply limit exceeded
    #[error("Lending vault supply limit exceeded")]
    SupplyLimitExceeded = 0x19F8,
    /// 6649 - Instruction is suspended
    #[error("Instruction is suspended")]
    Suspended = 0x19F9,
    /// 6650 - Maximum allowed swap slippage is exceeded
    #[error("Maximum allowed swap slippage is exceeded")]
    SwapSlippageExceeded = 0x19FA,
    /// 6651 - Provided swap slippage value is out of range
    #[error("Provided swap slippage value is out of range")]
    SwapSlippageIsOutOfRange = 0x19FB,
    /// 6652 - Swap to position ratio estimation failed
    #[error("Swap to position ratio estimation failed")]
    SwapToPositionRatioEstimationFailed = 0x19FC,
    /// 6653 - Swap quote amount is not equal to the actual swap amount
    #[error("Swap quote amount is not equal to the actual swap amount")]
    SwapQuoteNotEqualToActualSwapAmount = 0x19FD,
    /// 6654 - Transfer fee calculation failed
    #[error("Transfer fee calculation failed")]
    TransferFeeCalculationError = 0x19FE,
    /// 6655 - Unable to load the account data
    #[error("Unable to load the account data")]
    UnableToLoadAccountData = 0x19FF,
    /// 6656 - Unable to deserialize the account data
    #[error("Unable to deserialize the account data")]
    UnableToDeserializeAccountData = 0x1A00,
    /// 6657 - Unexpected value
    #[error("Unexpected value")]
    UnexpectedValue = 0x1A01,
    /// 6658 - Token mint has unsupported attributes
    #[error("Token mint has unsupported attributes")]
    UnsupportedTokenMint = 0x1A02,
    /// 6662 - Collected yield is zero
    #[error("Collected yield is zero")]
    ZeroYield = 0x1A06,
    /// 6663 - Position amount is zero
    #[error("Position amount is zero")]
    ZeroAmount = 0x1A07,
    /// 6670 - Incorrect position direction
    #[error("Incorrect position direction")]
    IncorrectPositionDirection = 0x1A0E,
    /// 6671 - Optional recipient account is not set
    #[error("Optional recipient account is not set")]
    RecipientAccountIsNotSet = 0x1A0F,
    /// 6672 - Moving Average price deviation threshold exceeded
    #[error("Moving Average price deviation threshold exceeded")]
    MAPriceDeviationThresholdExceeded = 0x1A10,
    /// 6673 - Invalid jupiter route data
    #[error("Invalid jupiter route data")]
    InvalidJupiterRoute = 0x1A11,
    /// 6674 - Insufficient swap output amount
    #[error("Insufficient swap output amount")]
    InsufficientSwapOutputAmount = 0x1A12,
    /// 6675 - Incorrect swap input amount
    #[error("Incorrect swap input amount")]
    IncorrectSwapInputAmount = 0x1A13,
    /// 6676 - Incorrect swap output amount
    #[error("Incorrect swap output amount")]
    IncorrectSwapOutputAmount = 0x1A14,
    /// 6677 - Account is not initialized
    #[error("Account is not initialized")]
    AccountNotInitialized = 0x1A15,
}

impl From<TunaError> for solana_program_error::ProgramError {
    fn from(e: TunaError) -> Self {
        solana_program_error::ProgramError::Custom(e as u32)
    }
}

