use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum AmmV3Error {
#[error("LOK")]
LOK = 0x1770,
#[error("Not approved")]
NotApproved = 0x1771,
#[error("invalid update amm config flag")]
InvalidUpdateConfigFlag = 0x1772,
#[error("Account lack")]
AccountLack = 0x1773,
#[error("Remove liquitity, collect fees owed and reward then you can close position account")]
ClosePositionErr = 0x1774,
#[error("Minting amount should be greater than 0")]
ZeroMintAmount = 0x1775,
#[error("Tick out of range")]
InvalidTickIndex = 0x1776,
#[error("The lower tick must be below the upper tick")]
TickInvalidOrder = 0x1777,
#[error("The tick must be greater, or equal to the minimum tick(-443636)")]
TickLowerOverflow = 0x1778,
#[error("The tick must be lesser than, or equal to the maximum tick(443636)")]
TickUpperOverflow = 0x1779,
#[error("tick % tick_spacing must be zero")]
TickAndSpacingNotMatch = 0x177A,
#[error("Invalid tick array account")]
InvalidTickArray = 0x177B,
#[error("Invalid tick array boundary")]
InvalidTickArrayBoundary = 0x177C,
#[error("Square root price limit overflow")]
SqrtPriceLimitOverflow = 0x177D,
#[error("sqrt_price_x64 out of range")]
SqrtPriceX64 = 0x177E,
#[error("Liquidity sub delta L must be smaller than before")]
LiquiditySubValueErr = 0x177F,
#[error("Liquidity add delta L must be greater, or equal to before")]
LiquidityAddValueErr = 0x1780,
#[error("Invalid liquidity when update position")]
InvalidLiquidity = 0x1781,
#[error("Both token amount must not be zero while supply liquidity")]
ForbidBothZeroForSupplyLiquidity = 0x1782,
#[error("Liquidity insufficient")]
LiquidityInsufficient = 0x1783,
#[error("Transaction too old")]
TransactionTooOld = 0x1784,
#[error("Price slippage check")]
PriceSlippageCheck = 0x1785,
#[error("Too little output received")]
TooLittleOutputReceived = 0x1786,
#[error("Too much input paid")]
TooMuchInputPaid = 0x1787,
#[error("Swap special amount can not be zero")]
ZeroAmountSpecified = 0x1788,
#[error("Input pool vault is invalid")]
InvalidInputPoolVault = 0x1789,
#[error("Swap input or output amount is too small")]
TooSmallInputOrOutputAmount = 0x178A,
#[error("Not enought tick array account")]
NotEnoughTickArrayAccount = 0x178B,
#[error("Invalid first tick array account")]
InvalidFirstTickArrayAccount = 0x178C,
#[error("Invalid reward index")]
InvalidRewardIndex = 0x178D,
#[error("The init reward token reach to the max")]
FullRewardInfo = 0x178E,
#[error("The init reward token already in use")]
RewardTokenAlreadyInUse = 0x178F,
#[error("The reward tokens must contain one of pool vault mint except the last reward")]
ExceptRewardMint = 0x1790,
#[error("Invalid reward init param")]
InvalidRewardInitParam = 0x1791,
#[error("Invalid collect reward desired amount")]
InvalidRewardDesiredAmount = 0x1792,
#[error("Invalid collect reward input account number")]
InvalidRewardInputAccountNumber = 0x1793,
#[error("Invalid reward period")]
InvalidRewardPeriod = 0x1794,
#[error(
"Modification of emissiones is allowed within 72 hours from the end of the previous cycle"
)]
NotApproveUpdateRewardEmissiones = 0x1795,
#[error("uninitialized reward info")]
UnInitializedRewardInfo = 0x1796,
#[error("Not support token_2022 mint extension")]
NotSupportMint = 0x1797,
#[error("Missing tickarray bitmap extension account")]
MissingTickArrayBitmapExtensionAccount = 0x1798,
#[error("Insufficient liquidity for this direction")]
InsufficientLiquidityForDirection = 0x1799,
#[error("Max token overflow")]
MaxTokenOverflow = 0x179A,
#[error("Calculate overflow")]
CalculateOverflow = 0x179B,
#[error("TransferFee calculate not match")]
TransferFeeCalculateNotMatch = 0x179C,
}
impl solana_program_error::PrintProgramError for AmmV3Error {
fn print<E>(&self) {
solana_msg::msg!(&self.to_string());
}
}
impl<T> solana_decode_error::DecodeError<T> for AmmV3Error {
fn type_of() -> &'static str {
"AmmV3Error"
}
}