Skip to main content

raydium_amm_swap/libraries/
error.rs

1use anchor_lang::prelude::*;
2
3#[error_code]
4pub enum ErrorCode {
5    #[msg("LOK")]
6    LOK,
7    #[msg("Not approved")]
8    NotApproved,
9    #[msg("invalid update amm config flag")]
10    InvalidUpdateConfigFlag,
11    #[msg("Account lack")]
12    AccountLack,
13    #[msg("Remove liquitity, collect fees owed and reward then you can close position account")]
14    ClosePositionErr,
15
16    #[msg("Minting amount should be greater than 0")]
17    ZeroMintAmount,
18
19    #[msg("Tick out of range")]
20    InvaildTickIndex,
21    #[msg("The lower tick must be below the upper tick")]
22    TickInvaildOrder,
23    #[msg("The tick must be greater, or equal to the minimum tick(-443636)")]
24    TickLowerOverflow,
25    #[msg("The tick must be lesser than, or equal to the maximum tick(443636)")]
26    TickUpperOverflow,
27    #[msg("tick % tick_spacing must be zero")]
28    TickAndSpacingNotMatch,
29    #[msg("Invaild tick array account")]
30    InvalidTickArray,
31    #[msg("Invaild tick array boundary")]
32    InvalidTickArrayBoundary,
33
34    #[msg("Square root price limit overflow")]
35    SqrtPriceLimitOverflow,
36    // second inequality must be < because the price can never reach the price at the max tick
37    #[msg("sqrt_price_x64 out of range")]
38    SqrtPriceX64,
39
40    // Liquidity Sub
41    #[msg("Liquidity sub delta L must be smaller than before")]
42    LiquiditySubValueErr,
43    // Liquidity Add
44    #[msg("Liquidity add delta L must be greater, or equal to before")]
45    LiquidityAddValueErr,
46    #[msg("Invaild liquidity when update position")]
47    InvaildLiquidity,
48    #[msg("Both token amount must not be zero while supply liquidity")]
49    ForbidBothZeroForSupplyLiquidity,
50    #[msg("Liquidity insufficient")]
51    LiquidityInsufficient,
52
53    /// swap errors
54    // Non fungible position manager
55    #[msg("Transaction too old")]
56    TransactionTooOld,
57    #[msg("Price slippage check")]
58    PriceSlippageCheck,
59    #[msg("Too little output received")]
60    TooLittleOutputReceived,
61    #[msg("Too much input paid")]
62    TooMuchInputPaid,
63    #[msg("Swap special amount can not be zero")]
64    ZeroAmountSpecified,
65    #[msg("Input pool vault is invalid")]
66    InvalidInputPoolVault,
67    #[msg("Swap input or output amount is too small")]
68    TooSmallInputOrOutputAmount,
69    #[msg("Not enought tick array account")]
70    NotEnoughTickArrayAccount,
71    #[msg("Invaild first tick array account")]
72    InvalidFirstTickArrayAccount,
73
74    /// reward errors
75    #[msg("Invalid reward index")]
76    InvalidRewardIndex,
77    #[msg("The init reward token reach to the max")]
78    FullRewardInfo,
79    #[msg("The init reward token already in use")]
80    RewardTokenAlreadyInUse,
81    #[msg("The reward tokens must contain one of pool vault mint except the last reward")]
82    ExceptPoolVaultMint,
83    #[msg("Invalid reward init param")]
84    InvalidRewardInitParam,
85    #[msg("Invalid collect reward desired amount")]
86    InvalidRewardDesiredAmount,
87    #[msg("Invalid collect reward input account number")]
88    InvalidRewardInputAccountNumber,
89    #[msg("Invalid reward period")]
90    InvalidRewardPeriod,
91    #[msg(
92        "Modification of emissiones is allowed within 72 hours from the end of the previous cycle"
93    )]
94    NotApproveUpdateRewardEmissiones,
95    #[msg("uninitialized reward info")]
96    UnInitializedRewardInfo,
97
98    #[msg("Not support token_2022 mint extension")]
99    NotSupportMint,
100    #[msg("Missing tickarray bitmap extension account")]
101    MissingTickArrayBitmapExtensionAccount,
102    #[msg("Insufficient liquidity for this direction")]
103    InsufficientLiquidityForDirection,
104    #[msg("Max token overflow")]
105    MaxTokenOverflow,
106    #[msg("calculate overflow")]
107    CalculateOverflow,
108}