use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum JupiterError {
#[error("Empty route")]
EmptyRoute = 0x1770,
#[error("Slippage tolerance exceeded")]
SlippageToleranceExceeded = 0x1771,
#[error("Invalid calculation")]
InvalidCalculation = 0x1772,
#[error("Missing platform fee account")]
MissingPlatformFeeAccount = 0x1773,
#[error("Invalid slippage")]
InvalidSlippage = 0x1774,
#[error("Not enough percent to 100")]
NotEnoughPercent = 0x1775,
#[error("Token input index is invalid")]
InvalidInputIndex = 0x1776,
#[error("Token output index is invalid")]
InvalidOutputIndex = 0x1777,
#[error("Not Enough Account keys")]
NotEnoughAccountKeys = 0x1778,
#[error("Non zero minimum out amount not supported")]
NonZeroMinimumOutAmountNotSupported = 0x1779,
#[error("Invalid route plan")]
InvalidRoutePlan = 0x177A,
#[error("Invalid referral authority")]
InvalidReferralAuthority = 0x177B,
#[error("Token account doesn't match the ledger")]
LedgerTokenAccountDoesNotMatch = 0x177C,
#[error("Invalid token ledger")]
InvalidTokenLedger = 0x177D,
#[error("Token program ID is invalid")]
IncorrectTokenProgramID = 0x177E,
#[error("Token program not provided")]
TokenProgramNotProvided = 0x177F,
#[error("Swap not supported")]
SwapNotSupported = 0x1780,
#[error("Exact out amount doesn't match")]
ExactOutAmountNotMatched = 0x1781,
#[error("Source mint and destination mint cannot the same")]
SourceAndDestinationMintCannotBeTheSame = 0x1782,
#[error("Invalid mint")]
InvalidMint = 0x1783,
#[error("Invalid program authority")]
InvalidProgramAuthority = 0x1784,
#[error("Invalid output token account")]
InvalidOutputTokenAccount = 0x1785,
#[error("Invalid fee wallet")]
InvalidFeeWallet = 0x1786,
#[error("Invalid authority")]
InvalidAuthority = 0x1787,
#[error("Insufficient funds")]
InsufficientFunds = 0x1788,
#[error("Invalid token account")]
InvalidTokenAccount = 0x1789,
#[error("Bonding curve already completed")]
BondingCurveAlreadyCompleted = 0x178A,
}
impl From<JupiterError> for solana_program_error::ProgramError {
fn from(e: JupiterError) -> Self {
solana_program_error::ProgramError::Custom(e as u32)
}
}