use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum AmmError {
#[error("Math operation overflow")]
MathOverflow = 0x1770,
#[error("Invalid fee setup")]
InvalidFee = 0x1771,
#[error("Invalid invariant d")]
InvalidInvariant = 0x1772,
#[error("Fee calculation failure")]
FeeCalculationFailure = 0x1773,
#[error("Exceeded slippage tolerance")]
ExceededSlippage = 0x1774,
#[error("Invalid curve calculation")]
InvalidCalculation = 0x1775,
#[error("Given pool token amount results in zero trading tokens")]
ZeroTradingTokens = 0x1776,
#[error("Math conversion overflow")]
ConversionError = 0x1777,
#[error("LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply")]
FaultyLpMint = 0x1778,
#[error("Token mint mismatched")]
MismatchedTokenMint = 0x1779,
#[error("LP mint mismatched")]
MismatchedLpMint = 0x177A,
#[error("Invalid lp token owner")]
MismatchedOwner = 0x177B,
#[error("Invalid vault account")]
InvalidVaultAccount = 0x177C,
#[error("Invalid vault lp account")]
InvalidVaultLpAccount = 0x177D,
#[error("Invalid pool lp mint account")]
InvalidPoolLpMintAccount = 0x177E,
#[error("Pool disabled")]
PoolDisabled = 0x177F,
#[error("Invalid admin account")]
InvalidAdminAccount = 0x1780,
#[error("Invalid protocol fee account")]
InvalidProtocolFeeAccount = 0x1781,
#[error("Same admin account")]
SameAdminAccount = 0x1782,
#[error("Identical user source and destination token account")]
IdenticalSourceDestination = 0x1783,
#[error("Apy calculation error")]
ApyCalculationError = 0x1784,
#[error("Insufficient virtual price snapshot")]
InsufficientSnapshot = 0x1785,
#[error("Current curve is non-updatable")]
NonUpdatableCurve = 0x1786,
#[error("New curve is mismatched with old curve")]
MisMatchedCurve = 0x1787,
#[error("Amplification is invalid")]
InvalidAmplification = 0x1788,
#[error("Operation is not supported")]
UnsupportedOperation = 0x1789,
#[error("Exceed max amplification changes")]
ExceedMaxAChanges = 0x178A,
#[error("Invalid remaining accounts length")]
InvalidRemainingAccountsLen = 0x178B,
#[error("Invalid remaining account")]
InvalidRemainingAccounts = 0x178C,
#[error("Token mint B doesn't matches depeg type token mint")]
MismatchedDepegMint = 0x178D,
#[error("Invalid APY account")]
InvalidApyAccount = 0x178E,
#[error("Invalid token multiplier")]
InvalidTokenMultiplier = 0x178F,
#[error("Invalid depeg information")]
InvalidDepegInformation = 0x1790,
#[error("Update time constraint violated")]
UpdateTimeConstraint = 0x1791,
#[error("Exceeded max fee bps")]
ExceedMaxFeeBps = 0x1792,
#[error("Invalid admin")]
InvalidAdmin = 0x1793,
#[error("Pool is not permissioned")]
PoolIsNotPermissioned = 0x1794,
#[error("Invalid deposit amount")]
InvalidDepositAmount = 0x1795,
#[error("Invalid fee owner")]
InvalidFeeOwner = 0x1796,
#[error("Pool is not depleted")]
NonDepletedPool = 0x1797,
#[error("Token amount is not 1:1")]
AmountNotPeg = 0x1798,
#[error("Amount is zero")]
AmountIsZero = 0x1799,
#[error("Type cast error")]
TypeCastFailed = 0x179A,
#[error("Amount is not enough")]
AmountIsNotEnough = 0x179B,
#[error("Invalid activation duration")]
InvalidActivationDuration = 0x179C,
#[error("Pool is not launch pool")]
PoolIsNotLaunchPool = 0x179D,
#[error("Unable to modify activation point")]
UnableToModifyActivationPoint = 0x179E,
#[error("Invalid authority to create the pool")]
InvalidAuthorityToCreateThePool = 0x179F,
#[error("Invalid activation type")]
InvalidActivationType = 0x17A0,
#[error("Invalid activation point")]
InvalidActivationPoint = 0x17A1,
#[error("Pre activation swap window started")]
PreActivationSwapStarted = 0x17A2,
#[error("Invalid pool type")]
InvalidPoolType = 0x17A3,
#[error("Quote token must be SOL,USDC")]
InvalidQuoteMint = 0x17A4,
}
impl solana_program::program_error::PrintProgramError for AmmError {
fn print<E>(&self) {
solana_program::msg!(&self.to_string());
}
}
impl<T> solana_program::decode_error::DecodeError<T> for AmmError {
fn type_of() -> &'static str {
"AmmError"
}
}