use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum TunaError {
#[error("Type cast overflow")]
TypeCastOverflow = 0x1964,
#[error("Math overflow")]
MathOverflow = 0x1965,
#[error("Math underflow")]
MathUnderflow = 0x1966,
#[error("Lending vault is not initialized")]
VaultNotInitialized = 0x199F,
#[error("Withdraw request the exceeds user balance")]
WithdrawRequestExceedsUserBalance = 0x19A0,
#[error("Zero price range: the lower price is equal to upper price)")]
ZeroPriceRange = 0x19A1,
#[error("Amount slippage exceeded")]
AmountSlippageExceeded = 0x19C8,
#[error("Bad debt is not allowed for the executed instruction")]
BadDebt = 0x19C9,
#[error("Invalid number of remaining accounts")]
InvalidRemainingAccountsLength = 0x19CA,
#[error("Invalid instruction arguments")]
InvalidInstructionArguments = 0x19CB,
#[error("Invalid market maker")]
InvalidMarketMaker = 0x19CC,
#[error("Invalid account discriminator")]
InvalidAccountDiscriminator = 0x19CD,
#[error("Invalid account owner")]
InvalidAccountOwner = 0x19CE,
#[error("Invalid Fusion or Orca pool")]
InvalidPool = 0x19CF,
#[error("Vault address is invalid")]
InvalidVault = 0x19D0,
#[error("Insufficient liquidity")]
InsufficientLiquidity = 0x19D1,
#[error("Interest rate is out of range")]
InterestRateIsOutOfRange = 0x19D2,
#[error("Leverage is out or range")]
LeverageIsOutOfRange = 0x19D3,
#[error("Leftovers percentage exceeded the maximum allowed value")]
LeftoversExceeded = 0x19D4,
#[error("Liquidation fee is out of range")]
LiquidationFeeIsOutOfRange = 0x19D5,
#[error("Liquidation threshold is out of range")]
LiquidationThresholdIsOutOfRange = 0x19D6,
#[error("Market is disabled")]
MarketDisabled = 0x19D7,
#[error("Exceed the maximum allowed debt for the market")]
MarketDebtLimitExceeded = 0x19D8,
#[error("Unable to call transfer hook without extra accounts")]
NoExtraAccountsForTransferHook = 0x19D9,
#[error("Oracle price is stale")]
OracleStalePrice = 0x19DA,
#[error("Oracle price deviation threshold exceeded")]
OraclePriceDeviationThresholdExceeded = 0x19DB,
#[error("Oracle price deviation threshold out of range")]
OraclePriceDeviationThresholdOutOfRange = 0x19DC,
#[error("Invalid oracle price update account")]
InvalidPriceUpdateAccount = 0x19DD,
#[error("Position is healthy")]
PositionIsHealthy = 0x19DE,
#[error("Position is already liquidated")]
PositionIsLiquidated = 0x19DF,
#[error("Position is unhealthy")]
PositionIsUnhealthy = 0x19E0,
#[error("Position is not empty")]
PositionNotEmpty = 0x19E1,
#[error("Position is empty")]
PositionIsEmpty = 0x19E2,
#[error("Unable to claim yield for auto re-balanceable positions")]
PositionIsAutoRebalanceable = 0x19E3,
#[error("Position size exceeds the maximum allowed value")]
PositionSizeLimitExceeded = 0x19E4,
#[error("Protocol fee is out of range")]
ProtocolFeeIsOutOfRange = 0x19F0,
#[error("Rebalance conditions are not met")]
RebalanceConditionsNotMet = 0x19F1,
#[error("Same accounts type is provided more than once")]
RemainingAccountsDuplicatedAccountsType = 0x19F2,
#[error("Invalid remaining accounts")]
RemainingAccountsInvalidSlice = 0x19F3,
#[error("Invalid remaining accounts slice length")]
RemainingAccountsInvalidSliceLength = 0x19F4,
#[error("Insufficient remaining accounts")]
RemainingAccountsInsufficient = 0x19F5,
#[error("Required remaining account is not provided")]
RequiredRemainingAccountNotProvided = 0x19F6,
#[error("Swap equation solver failed to t find the root")]
SolverFailedToFindRoot = 0x19F7,
#[error("Lending vault supply limit exceeded")]
SupplyLimitExceeded = 0x19F8,
#[error("Instruction is suspended")]
Suspended = 0x19F9,
#[error("Maximum allowed swap slippage is exceeded")]
SwapSlippageExceeded = 0x19FA,
#[error("Provided swap slippage value is out of range")]
SwapSlippageIsOutOfRange = 0x19FB,
#[error("Swap to position ratio estimation failed")]
SwapToPositionRatioEstimationFailed = 0x19FC,
#[error("Swap quote amount is not equal to the actual swap amount")]
SwapQuoteNotEqualToActualSwapAmount = 0x19FD,
#[error("Transfer fee calculation failed")]
TransferFeeCalculationError = 0x19FE,
#[error("Unable to load the account data")]
UnableToLoadAccountData = 0x19FF,
#[error("Unable to deserialize the account data")]
UnableToDeserializeAccountData = 0x1A00,
#[error("Unexpected value")]
UnexpectedValue = 0x1A01,
#[error("Token mint has unsupported attributes")]
UnsupportedTokenMint = 0x1A02,
#[error("Collected yield is zero")]
ZeroYield = 0x1A06,
#[error("Position amount is zero")]
ZeroAmount = 0x1A07,
#[error("Incorrect position direction")]
IncorrectPositionDirection = 0x1A0E,
#[error("Optional recipient account is not set")]
RecipientAccountIsNotSet = 0x1A0F,
#[error("Moving Average price deviation threshold exceeded")]
MAPriceDeviationThresholdExceeded = 0x1A10,
#[error("Account is not initialized")]
AccountNotInitialized = 0x1A11,
#[error("Position is locked")]
PositionLocked = 0x1A12,
#[error("Leveraged locked position is not allowed")]
LeveragedLockedPositionNotAllowed = 0x1A13,
#[error("Invalid jupiter create token account instruction data")]
InvalidJupiterCreateTokenAccountInstructionData = 0x1A2C,
#[error("Invalid jupiter create token account instruction user account")]
InvalidJupiterCreateTokenAccountUserAccount = 0x1A2D,
#[error("Invalid jupiter route instruction data")]
InvalidJupiterRouteInstructionData = 0x1A2E,
#[error("Invalid jupiter route instruction user account")]
InvalidJupiterRouteUserAccount = 0x1A2F,
#[error("Insufficient swap output amount")]
InsufficientJupiterSwapOutputAmount = 0x1A30,
#[error("Incorrect swap input amount")]
IncorrectJupiterSwapInputAmount = 0x1A31,
}
impl From<TunaError> for solana_program_error::ProgramError {
fn from(e: TunaError) -> Self {
solana_program_error::ProgramError::Custom(e as u32)
}
}