1use anchor_lang::prelude::error_code;
2use fix::prelude::ExponentMismatch;
3
4impl std::error::Error for CoreError {}
5
6impl From<ExponentMismatch> for CoreError {
7 fn from(_: ExponentMismatch) -> CoreError {
8 CoreError::FixValueConversion
9 }
10}
11
12#[error_code]
13#[derive(PartialEq, Eq)]
14pub enum CoreError {
15 #[msg("Cannot decrement TotalSolCache due to outdated epoch.")]
17 TotalSolCacheDecrement = 7000,
18 #[msg("Cannot increment TotalSolCache due to outdated epoch.")]
19 TotalSolCacheIncrement,
20 #[msg("Increment overflow in TotalSolCache.")]
21 TotalSolCacheOverflow,
22 #[msg("Decrement underflow in TotalSolCache.")]
23 TotalSolCacheUnderflow,
24 #[msg("TotalSolCache is not valid for the current epoch.")]
25 TotalSolCacheOutdated,
26 #[msg("Underflow in delta between current and previous LST prices.")]
28 LstSolPriceDelta,
29 #[msg("LstSolPrice delta failed due to non-adjacent epochs.")]
30 LstSolPriceEpochOrder,
31 #[msg("Cached LstSolPrice is not from current epoch.")]
32 LstSolPriceOutdated,
33 #[msg("Overflow while computing LstSolPrice conversion.")]
34 LstSolPriceConversion,
35 #[msg("Overflow while computing SolLstPrice conversion.")]
36 SolLstPriceConversion,
37 #[msg("Arithmetic error during LST to LST conversion.")]
38 LstLstPriceConversion,
39 #[msg("Oracle confidence interval is too wide.")]
41 PythOracleConfidence,
42 #[msg("Oracle exponent is out of range.")]
43 PythOracleExponent,
44 #[msg("Oracle yielded a negative price which can't be unsigned.")]
45 PythOracleNegativePrice,
46 #[msg("Oracle time is negative.")]
47 PythOracleNegativeTime,
48 #[msg("Oracle did not yield a price within the configured age window.")]
49 PythOracleOutdated,
50 #[msg("Oracle price is out of range.")]
51 PythOraclePriceRange,
52 #[msg("Oracle publish slot greater than current slot.")]
53 PythOracleSlotInvalid,
54 #[msg("Oracle price update is not fully verified.")]
55 PythOracleVerificationLevel,
56 #[msg("Overflow while computing collateral ratio.")]
58 CollateralRatioOverflow,
59 #[msg("Arithmetic error while computing max mintable stablecoin.")]
60 MaxMintable,
61 #[msg("Arithmetic error while computing max swappable stablecoin.")]
62 MaxSwappable,
63 #[msg("Arithmetic error while computing depegged stablecoin NAV.")]
64 StablecoinNav,
65 #[msg("Unable to compute max mintable stablecoin with target CR < 1.")]
66 TargetCollateralRatioTooLow,
67 #[msg("Overflow while computing total value locked in USD.")]
68 TotalValueLocked,
69 #[msg("Over/underflow while computing acceptable token amount.")]
71 SlippageArithmetic,
72 #[msg("Token output amount exceeds provided slippage configuration.")]
73 SlippageExceeded,
74 #[msg("Arithmetic error in conversion from levercoin to stablecoin.")]
76 LeverToStable,
77 #[msg("Arithmetic error in conversion from stablecoin to levercoin.")]
78 StableToLever,
79 #[msg("Arithmetic error in conversion from LST to protocol token.")]
80 LstToToken,
81 #[msg("Arithmetic error in conversion from protocol token to LST.")]
82 TokenToLst,
83 #[msg("Arithmetic error in conversion from LST to USD.")]
84 LstToUsd,
85 #[msg("Over/underflow while computing fee extraction for transaction.")]
87 FeeExtraction,
88 #[msg("No valid mint fee for levercoin. Projected rebalance mode is Depeg.")]
89 NoValidLevercoinMintFee,
90 #[msg("No valid redeem fee for levercoin due to Depeg.")]
91 NoValidLevercoinRedeemFee,
92 #[msg("No valid mint fee: projected CR below mint fee curve domain.")]
93 NoValidStablecoinMintFee,
94 #[msg("No valid redeem fee: projected CR above redeem fee curve domain.")]
95 NoValidStablecoinRedeemFee,
96 #[msg("No valid fee for swap due to SellZone2 or Depeg.")]
97 NoValidSwapFee,
98 #[msg("Fees cannot exceed configured maximum.")]
99 InvalidFees,
100 #[msg("Arithmetic error while computing levercoin NAV.")]
102 LevercoinNav,
103 #[msg("Levercoin supply not set on exchange context.")]
104 LevercoinSupplyNotSet,
105 #[msg("Over/underflow projecting total collateral.")]
106 DestinationCollateral,
107 #[msg("Over/underflow projecting total stablecoin.")]
108 DestinationStablecoin,
109 #[msg("Requested amount of stablecoin over max mintable limit.")]
110 RequestedStablecoinOverMaxMintable,
111 #[msg("Arithmetic error while computing virtual stablecoin overhang.")]
112 VirtualStablecoinOverhang,
113 #[msg("Arithmetic error while computing virtual stablecoin surplus.")]
114 VirtualStablecoinSurplus,
115 #[msg("Virtual stablecoin burn exceeds given burn limit.")]
116 VirtualStablecoinBurnLimit,
117 #[msg("Arithmetic error while computing LP token NAV.")]
119 LpTokenNav,
120 #[msg("Arithmetic error while computing LP token amount to give to user.")]
121 LpTokenOut,
122 #[msg("Arithmetic error while computing amount of token to withdraw.")]
123 TokenWithdraw,
124 #[msg("Yield harvest configuration percentages failed validation.")]
126 YieldHarvestConfigValidation,
127 #[msg("Arithmetic error while applying yield harvest multiplier.")]
128 YieldHarvestMultiplier,
129 #[msg("Overflow while minting virtual stablecoin.")]
131 MintOverflow,
132 #[msg("Overflow while burning virtual stablecoin.")]
133 BurnUnderflow,
134 #[msg("Interpolation requires at least two points.")]
136 InterpInsufficientPoints,
137 #[msg("Interpolation points must have strictly increasing x-coordinates.")]
138 InterpPointsNotMonotonic,
139 #[msg("Interpolation input is outside the valid domain.")]
140 InterpOutOfDomain,
141 #[msg("Arithmetic overflow during interpolation calculation.")]
142 InterpArithmetic,
143 #[msg("Marginal rate is non-finite or non-positive.")]
145 MarginalRateInvalid,
146 #[msg("Failed to convert collateral ratio from u64 to i64.")]
148 CollateralRatioConversion,
149 #[msg("Failed to convert interpolated fee from i64 to u64.")]
150 InterpFeeConversion,
151 #[msg("Borrow rate configuration failed validation.")]
153 BorrowRateValidation,
154 #[msg("Arithmetic error while applying borrow rate.")]
155 BorrowRateApply,
156 #[msg("Arithmetic error converting exo collateral to protocol token.")]
158 ExoToToken,
159 #[msg("Arithmetic error converting protocol token to exo collateral.")]
160 ExoFromToken,
161 #[msg("Arithmetic error converting exo collateral to USD.")]
162 ExoToUsd,
163 #[msg("Precision conversion failed while normalizing exo amount to N9.")]
165 ExoAmountNormalization,
166 #[msg("Arithmetic error converting exo collateral to USDC.")]
167 ExoCollateralToUsdc,
168 #[msg("Arithmetic error converting USDC to exo collateral.")]
169 ExoUsdcToCollateral,
170 #[msg("Arithmetic error converting LST to USDC via SOL.")]
171 LstToUsdc,
172 #[msg("Arithmetic error converting USDC to LST via SOL.")]
173 UsdcToLst,
174 #[msg("Rebalance curve config value is zero or has incorrect precision.")]
176 RebalanceCurveConfigValidation,
177 #[msg("Arithmetic error constructing rebalance price curve from oracle.")]
178 RebalancePriceConstruction,
179 #[msg("CR or price conversion failed in rebalance price curve.")]
180 RebalancePriceConversion,
181 #[msg("CR is outside the rebalance pricing curve domain.")]
182 RebalanceOutOfDomain,
183 #[msg("Rebalance amount projects CR outside the pricing curve domain.")]
184 RebalanceAmountExceeded,
185 #[msg("Arithmetic error while converting percentage for rebalance curve.")]
186 RebalancePercentArithmetic,
187 #[msg("Arithmetic error while computing sell side liquidity.")]
189 RebalanceSellSideLiquidity,
190 #[msg("Arithmetic error while computing buy side target.")]
191 RebalanceBuySideTarget,
192 #[msg("Arithmetic error while computing rebalance swap PnL.")]
194 RebalanceSwapPnl,
195 #[msg("Division by zero computing SPL stake pool price.")]
197 StakePoolDivByZero,
198 #[msg("Oracle interval not in valid range.")]
200 OracleIntervalSecsInvalid,
201 #[msg("Oracle confidence tolerance not in valid range.")]
202 OracleConfToleranceInvalid,
203 #[msg("Range boundary did not match the expected bound variant.")]
205 RangeUnexpectedBound,
206 #[msg("Stablecoin mint threshold not in Neutral rebalance range.")]
207 StablecoinMintThresholdInvalid,
208 #[msg("Rebalance reserve configuration is invalid.")]
209 ReserveGateInvalid,
210 #[msg("Levercoin market cap limit not in valid configuration range.")]
212 LevercoinMarketCapLimitInvalid,
213 #[msg("Cannot mint new levercoin as market cap limit has been reached.")]
214 LevercoinMarketCapLimitReached,
215 #[msg("Arithmetic error while computing levercoin market cap limit.")]
216 LevercoinMarketCapArithmetic,
217 #[msg("Arithmetic error while computing total deposit.")]
219 DepositLimitArithmetic,
220 #[msg("Deposit exceeds configured limit.")]
221 DepositLimitExceeded,
222 #[msg("Deposit limit cannot be lower than pool amount.")]
223 DepositLimitValidation,
224 #[msg("Arithmetic error while computing total withdrawal.")]
226 WithdrawalLimitArithmetic,
227 #[msg("Withdrawal exceeds configured limit for epoch.")]
228 WithdrawalLimitExceededForEpoch,
229 #[msg("Withdrawal limiter logged epoch greater than current epoch.")]
230 WithdrawalLimitInvalidEpoch,
231 #[msg("Withdrawal limit is zero or exceeds pool amount.")]
232 WithdrawalLimitValidation,
233 #[msg("Fixed-point value has unexpected exponent.")]
234 FixValueConversion,
235 #[msg("SPL stake pool account data failed to deserialize.")]
236 StakePoolAccountData,
237 #[msg("Operation disabled in current protocol state.")]
239 OperationDisabled,
240 #[msg("Failed while converting precision for a token amount.")]
241 TokenAmountPrecision,
242 #[msg("No LST header or stake pool found for mint.")]
243 UnknownLstMint,
244 #[msg("Insufficient vault liquidity for requested output.")]
246 InsufficientLiquidity,
247 #[msg("Protocol is paused.")]
248 ProtocolPaused,
249 #[msg("Trading pair is paused.")]
250 PairPaused,
251 #[msg("Yield harvest has not run this epoch.")]
252 YieldHarvestNotRun,
253 #[msg("Borrow rate harvest has not run this epoch.")]
254 BorrowRateHarvestNotRun,
255 #[msg("Drawdown loss has not been repaid.")]
256 DrawdownNotRepaid,
257 #[msg("Levercoin market cap exceeded.")]
258 LevercoinMarketCapExceeded,
259 #[msg("Amount must be greater than zero.")]
260 ZeroAmount,
261 #[msg("Protocol account missing from RPC response.")]
262 ProtocolAccountNotFound,
263 #[msg("Rebalance swap input exceeds buy-side target.")]
264 RebalanceBuyTargetExceeded,
265 #[msg("Earn pool cannot absorb rebalance swap loss.")]
266 InsufficientEarnPoolLiquidity,
267 #[msg("Overflow while computing minimum input.")]
268 MinInputOverflow,
269 #[msg("No exo pair found for mint.")]
270 UnknownExoMint,
271 #[msg("Par tolerance not in valid range.")]
273 InvalidParTolerance,
274 #[msg("Spot price deviates from par beyond configured tolerance.")]
275 ParToleranceExceeded,
276 #[msg("Arithmetic error while computing max redeemable stablecoin.")]
278 MaxRedeemable,
279 #[msg("Minimum input exceeds maximum input for this route.")]
280 MinInputExceedsMax,
281 #[msg("No redemption lane can price the reference amount.")]
283 NoRedemptionLane,
284 #[msg("Overflow while computing redemption rate.")]
285 RedemptionRateOverflow,
286 #[msg("USDC vault balance below required reserve.")]
288 UsdcReserveBelowMinimum,
289 #[msg("No route between the mint pair.")]
291 UnroutablePair,
292}