//! 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 {
    /// 6000 - Amount slippage exceeded
    #[error("Amount slippage exceeded")]
    AmountSlippageExceeded = 0x1770,
    /// 6001 - Bad debt is not allowed for the executed instruction
    #[error("Bad debt is not allowed for the executed instruction")]
    BadDebt = 0x1771,
    /// 6002 - Invalid number of remaining accounts
    #[error("Invalid number of remaining accounts")]
    InvalidRemainingAccountsLength = 0x1772,
    /// 6003 - Invalid account owner
    #[error("Invalid account owner")]
    InvalidAccountOwner = 0x1773,
    /// 6004 - Invalid instruction arguments
    #[error("Invalid instruction arguments")]
    InvalidInstructionArguments = 0x1774,
    /// 6005 - Invalid market maker
    #[error("Invalid market maker")]
    InvalidMarketMaker = 0x1775,
    /// 6006 - Provided SqrtPriceLimit not in the same direction as the swap.
    #[error("Provided SqrtPriceLimit not in the same direction as the swap.")]
    InvalidSqrtPriceLimitDirection = 0x1776,
    /// 6007 - Invalid tick array sequence provided for instruction
    #[error("Invalid tick array sequence provided for instruction")]
    InvalidTickArraySequence = 0x1777,
    /// 6008 - Insufficient liquidity
    #[error("Insufficient liquidity")]
    InsufficientLiquidity = 0x1778,
    /// 6009 - Interest rate is out of range
    #[error("Interest rate is out of range")]
    InterestRateIsOutOfRange = 0x1779,
    /// 6010 - Leverage is out or range
    #[error("Leverage is out or range")]
    LeverageIsOutOfRange = 0x177A,
    /// 6011 - Leftovers percentage exceeded the maximum allowed value
    #[error("Leftovers percentage exceeded the maximum allowed value")]
    LeftoversExceeded = 0x177B,
    /// 6012 - Unused error
    #[error("Unused error")]
    Unused = 0x177C,
    /// 6013 - Liquidation fee is out of range
    #[error("Liquidation fee is out of range")]
    LiquidationFeeIsOutOfRange = 0x177D,
    /// 6014 - Liquidation threshold is out of range
    #[error("Liquidation threshold is out of range")]
    LiquidationThresholdIsOutOfRange = 0x177E,
    /// 6015 - Liquidity amount must be greater than zero.
    #[error("Liquidity amount must be greater than zero.")]
    LiquidityZero = 0x177F,
    /// 6016 - Market is disabled
    #[error("Market is disabled")]
    MarketDisabled = 0x1780,
    /// 6017 - Exceed the maximum allowed debt for the market
    #[error("Exceed the maximum allowed debt for the market")]
    MarketDebtLimitExceeded = 0x1781,
    /// 6018 - Math overflow
    #[error("Math overflow")]
    MathOverflow = 0x1782,
    /// 6019 - Math underflow
    #[error("Math underflow")]
    MathUnderflow = 0x1783,
    /// 6020 - Unable to call transfer hook without extra accounts
    #[error("Unable to call transfer hook without extra accounts")]
    NoExtraAccountsForTransferHook = 0x1784,
    /// 6021 - Oracle price is stale
    #[error("Oracle price is stale")]
    OracleStalePrice = 0x1785,
    /// 6022 - Oracle price deviation threshold exceeded
    #[error("Oracle price deviation threshold exceeded")]
    OraclePriceDeviationThresholdExceeded = 0x1786,
    /// 6023 - Oracle price deviation threshold out of range
    #[error("Oracle price deviation threshold out of range")]
    OraclePriceDeviationThresholdOutOfRange = 0x1787,
    /// 6024 - Trade resulted in partial fill
    #[error("Trade resulted in partial fill")]
    PartialFillError = 0x1788,
    /// 6025 - Position is healthy
    #[error("Position is healthy")]
    PositionIsHealthy = 0x1789,
    /// 6026 - Position is already liquidated
    #[error("Position is already liquidated")]
    PositionIsLiquidated = 0x178A,
    /// 6027 - Position is unhealthy
    #[error("Position is unhealthy")]
    PositionIsUnhealthy = 0x178B,
    /// 6028 - Position is not empty
    #[error("Position is not empty")]
    PositionNotEmpty = 0x178C,
    /// 6029 - Protocol fee is out of range
    #[error("Protocol fee is out of range")]
    ProtocolFeeIsOutOfRange = 0x178D,
    /// 6030 - Rebalance conditions are not met
    #[error("Rebalance conditions are not met")]
    RebalanceConditionsNotMet = 0x178E,
    /// 6031 - Same accounts type is provided more than once
    #[error("Same accounts type is provided more than once")]
    RemainingAccountsDuplicatedAccountsType = 0x178F,
    /// 6032 - Invalid remaining accounts
    #[error("Invalid remaining accounts")]
    RemainingAccountsInvalidSlice = 0x1790,
    /// 6033 - Invalid remaining accounts slice length
    #[error("Invalid remaining accounts slice length")]
    RemainingAccountsInvalidSliceLength = 0x1791,
    /// 6034 - Insufficient remaining accounts
    #[error("Insufficient remaining accounts")]
    RemainingAccountsInsufficient = 0x1792,
    /// 6035 - Required remaining account is not provided
    #[error("Required remaining account is not provided")]
    RequiredRemainingAccountNotProvided = 0x1793,
    /// 6036 - Swap equation solver failed to t find the root
    #[error("Swap equation solver failed to t find the root")]
    SolverFailedToFindRoot = 0x1794,
    /// 6037 - Provided sqrt price out of bounds
    #[error("Provided sqrt price out of bounds")]
    SqrtPriceOutOfBounds = 0x1795,
    /// 6038 - Lending vault supply limit exceeded
    #[error("Lending vault supply limit exceeded")]
    SupplyLimitExceeded = 0x1796,
    /// 6039 - Instruction is suspended
    #[error("Instruction is suspended")]
    Suspended = 0x1797,
    /// 6040 - Maximum allowed swap slippage is exceeded
    #[error("Maximum allowed swap slippage is exceeded")]
    SwapSlippageExceeded = 0x1798,
    /// 6041 - Provided swap slippage value is out of range
    #[error("Provided swap slippage value is out of range")]
    SwapSlippageIsOutOfRange = 0x1799,
    /// 6042 - Swap to position ratio estimation failed
    #[error("Swap to position ratio estimation failed")]
    SwapToPositionRatioEstimationFailed = 0x179A,
    /// 6043 - Swap quote amount is not equal to the actual swap amount
    #[error("Swap quote amount is not equal to the actual swap amount")]
    SwapQuoteNotEqualToActualSwapAmount = 0x179B,
    /// 6044 - Tick index is out of bounds
    #[error("Tick index is out of bounds")]
    TickIndexOfBounds = 0x179C,
    /// 6045 - Transfer fee calculation failed
    #[error("Transfer fee calculation failed")]
    TransferFeeCalculationError = 0x179D,
    /// 6046 - Type cast overflow
    #[error("Type cast overflow")]
    TypeCastOverflow = 0x179E,
    /// 6047 - Unable to load the account data
    #[error("Unable to load the account data")]
    UnableToLoadAccountData = 0x179F,
    /// 6048 - Unable to deserialize the account data
    #[error("Unable to deserialize the account data")]
    UnableToDeserializeAccountData = 0x17A0,
    /// 6049 - Unexpected value
    #[error("Unexpected value")]
    UnexpectedValue = 0x17A1,
    /// 6050 - Token mint has unsupported attributes
    #[error("Token mint has unsupported attributes")]
    UnsupportedTokenMint = 0x17A2,
    /// 6051 - Lending vault is not initialized
    #[error("Lending vault is not initialized")]
    VaultNotInitialized = 0x17A3,
    /// 6052 - Withdraw request the exceeds user balance
    #[error("Withdraw request the exceeds user balance")]
    WithdrawRequestExceedsUserBalance = 0x17A4,
    /// 6053 - Zero price range: the lower price is equal to upper price)
    #[error("Zero price range: the lower price is equal to upper price)")]
    ZeroPriceRange = 0x17A5,
    /// 6054 - There are no tradable amount to swap.
    #[error("There are no tradable amount to swap.")]
    ZeroTradableAmount = 0x17A6,
    /// 6055 - Collected yield is zero
    #[error("Collected yield is zero")]
    ZeroYield = 0x17A7,
    /// 6056 - Position amount is zero
    #[error("Position amount is zero")]
    ZeroAmount = 0x17A8,
    /// 6057 - Unable to claim yield for auto re-balanceable positions
    #[error("Unable to claim yield for auto re-balanceable positions")]
    PositionIsAutoRebalanceable = 0x17A9,
    /// 6058 - Incorrect position direction
    #[error("Incorrect position direction")]
    IncorrectPositionDirection = 0x17AA,
    /// 6059 - Optional recipient account is not set
    #[error("Optional recipient account is not set")]
    RecipientAccountIsNotSet = 0x17AB,
    /// 6060 - Moving Average price deviation threshold exceeded
    #[error("Moving Average price deviation threshold exceeded")]
    MAPriceDeviationThresholdExceeded = 0x17AC,
    /// 6061 - Position size exceeds the maximum allowed value
    #[error("Position size exceeds the maximum allowed value")]
    PositionSizeLimitExceeded = 0x17AD,
    /// 6062 - Invalid jupiter route data
    #[error("Invalid jupiter route data")]
    InvalidJupiterRoute = 0x17AE,
    /// 6063 - Insufficient swap output amount
    #[error("Insufficient swap output amount")]
    InsufficientSwapOutputAmount = 0x17AF,
    /// 6064 - Incorrect swap input amount
    #[error("Incorrect swap input amount")]
    IncorrectSwapInputAmount = 0x17B0,
    /// 6065 - Incorrect swap output amount
    #[error("Incorrect swap output amount")]
    IncorrectSwapOutputAmount = 0x17B1,
    /// 6066 - Account is not initialized
    #[error("Account is not initialized")]
    AccountNotInitialized = 0x17B2,
    /// 6067 - Invalid account discriminator
    #[error("Invalid account discriminator")]
    InvalidAccountDiscriminator = 0x17B3,
    /// 6068 - Invalid Fusion or Orca pool
    #[error("Invalid Fusion or Orca pool")]
    InvalidPool = 0x17B4,
    /// 6069 - Position is empty
    #[error("Position is empty")]
    PositionIsEmpty = 0x17B5,
    /// 6070 - Vault address is invalid
    #[error("Vault address is invalid")]
    InvalidVault = 0x17B6,
}

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

