amm/
error.rs

1//! Error module includes error messages and codes of the program
2use anchor_lang::prelude::*;
3
4/// Error messages and codes of the program
5#[error_code]
6pub enum PoolError {
7    /// Mathematic operation results in overflow.
8    #[msg("Math operation overflow")]
9    MathOverflow,
10
11    /// Invalid fee configuration
12    #[msg("Invalid fee setup")]
13    InvalidFee,
14
15    /// Invalid invariant d amount
16    #[msg("Invalid invariant d")]
17    InvalidInvariant,
18
19    /// Failed to calculate fees.
20    #[msg("Fee calculation failure")]
21    FeeCalculationFailure,
22
23    /// The operation exceeds slippage defined by the user.
24    #[msg("Exceeded slippage tolerance")]
25    ExceededSlippage,
26
27    /// Swap curve calculation results in error.
28    #[msg("Invalid curve calculation")]
29    InvalidCalculation,
30
31    /// Swap curve calculation results in zero token A/B.
32    #[msg("Given pool token amount results in zero trading tokens")]
33    ZeroTradingTokens,
34
35    /// Type conversion results in error.
36    #[msg("Math conversion overflow")]
37    ConversionError,
38
39    /// Invalid LP mint account.
40    #[msg("LP mint authority must be 'A' vault lp, without freeze authority, and 0 supply")]
41    FaultyLpMint,
42
43    /// Invalid token mint account.
44    #[msg("Token mint mismatched")]
45    MismatchedTokenMint,
46
47    /// Invalid LP mint account.
48    #[msg("LP mint mismatched")]
49    MismatchedLpMint,
50
51    /// Invalid owner account.
52    #[msg("Invalid lp token owner")]
53    MismatchedOwner,
54
55    /// Invalid vault account.
56    #[msg("Invalid vault account")]
57    InvalidVaultAccount,
58
59    /// Invalud vault LP account.
60    #[msg("Invalid vault lp account")]
61    InvalidVaultLpAccount,
62
63    /// Invalid pool LP mint account.
64    #[msg("Invalid pool lp mint account")]
65    InvalidPoolLpMintAccount,
66
67    /// The pool was disabled.
68    #[msg("Pool disabled")]
69    PoolDisabled,
70
71    /// Invalid admin account.
72    #[msg("Invalid admin account")]
73    InvalidAdminAccount,
74
75    /// Invalid admin fee token account.
76
77    #[msg("Invalid admin fee account")]
78    InvalidAdminFeeAccount,
79
80    /// Old and new admin are the same account.
81    #[msg("Same admin account")]
82    SameAdminAccount,
83
84    /// Source and destination token mint are the same.
85    #[msg("Identical user source and destination token account")]
86    IdenticalSourceDestination,
87
88    /// APY calculation results in error.
89    #[msg("Apy calculation error")]
90    ApyCalculationError,
91
92    /// Insufficient virtual price snapshot.
93    #[msg("Insufficient virtual price snapshot")]
94    InsufficientSnapshot,
95
96    /// Curve is not updatable.
97    #[msg("Current curve is non-updatable")]
98    NonUpdatableCurve,
99
100    /// The new curve is not the same type as the old curve.
101    #[msg("New curve is mismatched with old curve")]
102    MisMatchedCurve,
103
104    /// Invalid amplification coefficient value.
105    #[msg("Amplification is invalid")]
106    InvalidAmplification,
107
108    /// The operation is not supported.
109    #[msg("Operation is not supported")]
110    UnsupportedOperation,
111
112    /// The ramping of amplification coefficient over the allowed value.
113    #[msg("Exceed max amplification changes")]
114    ExceedMaxAChanges,
115
116    /// Invalid number of remaining accounts
117    #[msg("Invalid remaining accounts length")]
118    InvalidRemainingAccountsLen,
119
120    /// Invalid remaining accounts
121    #[msg("Invalid remaining account")]
122    InvalidRemainingAccounts,
123
124    /// Pool token B mint doesn't match with depeg token mint address
125    #[msg("Token mint B doesn't matches depeg type token mint")]
126    MismatchedDepegMint,
127
128    /// Invalid APY account
129    #[msg("Invalid APY account")]
130    InvalidApyAccount,
131
132    /// Invalid token multiplier for stable swap curve
133    #[msg("Invalid token multiplier")]
134    InvalidTokenMultiplier,
135
136    /// Invalid depeg information
137    #[msg("Invalid depeg information")]
138    InvalidDepegInformation,
139
140    /// Update time violated the cooldown interval
141    #[msg("Update time constraint violated")]
142    UpdateTimeConstraint,
143
144    /// Pool fee exceed allowed max fee bps
145    #[msg("Exceeded max fee bps")]
146    ExceedMaxFeeBps,
147
148    /// Owner fee exceed half of trade fee
149    #[msg("Owner fee exceed half of trade fee")]
150    OwnerFeeOverHalfOfTradeFee,
151
152    /// Invalid admin
153    #[msg("Invalid admin")]
154    InvalidAdmin,
155
156    /// Pool is not permissioned
157    #[msg("Pool is not permissioned")]
158    PoolIsNotPermissioned,
159
160    /// Invalid deposit amount
161    #[msg("Invalid deposit amount")]
162    InvalidDepositAmount,
163
164    /// Invalid fee owner
165    #[msg("Invalid fee owner")]
166    InvalidFeeOwner,
167
168    /// Pool is not depleted
169    #[msg("Pool is not depleted")]
170    NonDepletedPool,
171
172    /// Amount is not peg
173    #[msg("Token amount is not 1:1")]
174    AmountNotPeg,
175}