use anchor_lang::prelude::error_code;
use fix::prelude::ExponentMismatch;
impl std::error::Error for CoreError {}
impl From<ExponentMismatch> for CoreError {
fn from(_: ExponentMismatch) -> CoreError {
CoreError::FixValueConversion
}
}
#[error_code]
#[derive(PartialEq, Eq)]
pub enum CoreError {
#[msg("Cannot decrement TotalSolCache due to outdated epoch.")]
TotalSolCacheDecrement = 7000,
#[msg("Cannot increment TotalSolCache due to outdated epoch.")]
TotalSolCacheIncrement,
#[msg("Increment overflow in TotalSolCache.")]
TotalSolCacheOverflow,
#[msg("Decrement underflow in TotalSolCache.")]
TotalSolCacheUnderflow,
#[msg("TotalSolCache is not valid for the current epoch.")]
TotalSolCacheOutdated,
#[msg("Underflow in delta between current and previous LST prices.")]
LstSolPriceDelta,
#[msg("LstSolPrice delta failed due to non-adjacent epochs.")]
LstSolPriceEpochOrder,
#[msg("Cached LstSolPrice is not from current epoch.")]
LstSolPriceOutdated,
#[msg("Overflow while computing LstSolPrice conversion.")]
LstSolPriceConversion,
#[msg("Overflow while computing SolLstPrice conversion.")]
SolLstPriceConversion,
#[msg("Arithmetic error during LST to LST conversion.")]
LstLstPriceConversion,
#[msg("Oracle confidence interval is too wide.")]
PythOracleConfidence,
#[msg("Oracle exponent is out of range.")]
PythOracleExponent,
#[msg("Oracle yielded a negative price which can't be unsigned.")]
PythOracleNegativePrice,
#[msg("Oracle time is negative.")]
PythOracleNegativeTime,
#[msg("Oracle did not yield a price within the configured age window.")]
PythOracleOutdated,
#[msg("Oracle price is out of range.")]
PythOraclePriceRange,
#[msg("Oracle publish slot greater than current slot.")]
PythOracleSlotInvalid,
#[msg("Oracle price update is not fully verified.")]
PythOracleVerificationLevel,
#[msg("Overflow while computing collateral ratio.")]
CollateralRatio,
#[msg("Arithmetic error while computing max mintable stablecoin.")]
MaxMintable,
#[msg("Arithmetic error while computing max swappable stablecoin.")]
MaxSwappable,
#[msg("Arithmetic error while computing depegged stablecoin NAV.")]
StablecoinNav,
#[msg("Unable to compute max mintable stablecoin with target CR < 1.")]
TargetCollateralRatioTooLow,
#[msg("Overflow while computing total value locked in USD.")]
TotalValueLocked,
#[msg("Over/underflow while computing acceptable token amount.")]
SlippageArithmetic,
#[msg("Token output amount exceeds provided slippage configuration.")]
SlippageExceeded,
#[msg("Arithmetic error in conversion from levercoin to stablecoin.")]
LeverToStable,
#[msg("Arithmetic error in conversion from stablecoin to levercoin.")]
StableToLever,
#[msg("Arithmetic error in conversion from LST to protocol token.")]
LstToToken,
#[msg("Arithmetic error in conversion from protocol token to LST.")]
TokenToLst,
#[msg("Over/underflow while computing fee extraction for transaction.")]
FeeExtraction,
#[msg("No valid mint fee for levercoin. Projected rebalance mode is Depeg.")]
NoValidLevercoinMintFee,
#[msg("No valid redeem fee for levercoin due to Depeg.")]
NoValidLevercoinRedeemFee,
#[msg("No valid mint fee: projected CR below mint fee curve domain.")]
NoValidStablecoinMintFee,
#[msg("No valid fee for swap due to SellZone2 or Depeg.")]
NoValidSwapFee,
#[msg("Fees cannot exceed configured maximum.")]
InvalidFees,
#[msg("Arithmetic error while computing levercoin NAV.")]
LevercoinNav,
#[msg("Levercoin supply not set on exchange context.")]
LevercoinSupplyNotSet,
#[msg("Over/underflow projecting total collateral.")]
DestinationCollateral,
#[msg("Over/underflow projecting total stablecoin.")]
DestinationStablecoin,
#[msg("Requested amount of stablecoin over max mintable limit.")]
RequestedStablecoinOverMaxMintable,
#[msg("Arithmetic error while computing virtual stablecoin overhang.")]
VirtualStablecoinOverhang,
#[msg("Arithmetic error while computing virtual stablecoin surplus.")]
VirtualStablecoinSurplus,
#[msg("Virtual stablecoin burn exceeds given burn limit.")]
VirtualStablecoinBurnLimit,
#[msg("Arithmetic error while computing LP token NAV.")]
LpTokenNav,
#[msg("Arithmetic error while computing LP token amount to give to user.")]
LpTokenOut,
#[msg("Arithmetic error while computing amount of token to withdraw.")]
TokenWithdraw,
#[msg("Yield harvest configuration percentages failed validation.")]
YieldHarvestConfigValidation,
#[msg("Arithmetic error while computing yield harvest allocation.")]
YieldHarvestAllocation,
#[msg("Overflow while minting virtual stablecoin.")]
MintOverflow,
#[msg("Overflow while burning virtual stablecoin.")]
BurnUnderflow,
#[msg("Interpolation requires at least two points.")]
InterpInsufficientPoints,
#[msg("Interpolation points must have strictly increasing x-coordinates.")]
InterpPointsNotMonotonic,
#[msg("Interpolation input is outside the valid domain.")]
InterpOutOfDomain,
#[msg("Arithmetic overflow during interpolation calculation.")]
InterpArithmetic,
#[msg("Failed to convert collateral ratio from u64 to i64.")]
CollateralRatioConversion,
#[msg("Failed to convert interpolated fee from i64 to u64.")]
InterpFeeConversion,
#[msg("Borrow rate configuration failed validation.")]
BorrowRateValidation,
#[msg("Arithmetic error while applying borrow rate.")]
BorrowRateApply,
#[msg("Arithmetic error converting exo collateral to protocol token.")]
ExoToToken,
#[msg("Arithmetic error converting protocol token to exo collateral.")]
ExoFromToken,
#[msg("Precision conversion failed while normalizing exo amount to N9.")]
ExoAmountNormalization,
#[msg("Arithmetic error converting exo collateral to USDC.")]
ExoCollateralToUsdc,
#[msg("Arithmetic error converting USDC to exo collateral.")]
ExoUsdcToCollateral,
#[msg("Arithmetic error converting LST to USDC via SOL.")]
LstToUsdc,
#[msg("Arithmetic error converting USDC to LST via SOL.")]
UsdcToLst,
#[msg("Rebalance curve config value is zero or has incorrect precision.")]
RebalanceCurveConfigValidation,
#[msg("Arithmetic error constructing rebalance price curve from oracle.")]
RebalancePriceConstruction,
#[msg("CR or price conversion failed in rebalance price curve.")]
RebalancePriceConversion,
#[msg("CR is outside the rebalance pricing curve domain.")]
RebalanceOutOfDomain,
#[msg("Rebalance amount projects CR outside the pricing curve domain.")]
RebalanceAmountExceeded,
#[msg("Arithmetic error while converting percentage for rebalance curve.")]
RebalancePercentArithmetic,
#[msg("Arithmetic error while computing sell side liquidity.")]
RebalanceSellSideLiquidity,
#[msg("Arithmetic error while computing buy side target.")]
RebalanceBuySideTarget,
#[msg("Arithmetic error while computing rebalance swap PnL.")]
RebalanceSwapPnl,
#[msg("Division by zero computing SPL stake pool price.")]
StakePoolDivByZero,
#[msg("Oracle interval not in valid range.")]
OracleIntervalSecsInvalid,
#[msg("Oracle confidence tolerance not in valid range.")]
OracleConfToleranceInvalid,
#[msg("Range boundary did not match the expected bound variant.")]
RangeUnexpectedBound,
#[msg("Stablecoin mint threshold not in Neutral rebalance range.")]
StablecoinMintThresholdInvalid,
#[msg("Levercoin market cap limit not in valid configuration range.")]
LevercoinMarketCapLimitInvalid,
#[msg("Cannot mint new levercoin as market cap limit has been reached.")]
LevercoinMarketCapLimitReached,
#[msg("Arithmetic error while computing levercoin market cap limit.")]
LevercoinMarketCapArithmetic,
#[msg("Arithmetic error while computing total deposit.")]
DepositLimitArithmetic,
#[msg("Deposit exceeds configured limit.")]
DepositLimitExceeded,
#[msg("Deposit limit cannot be lower than pool amount.")]
DepositLimitValidation,
#[msg("Arithmetic error while computing total withdrawal.")]
WithdrawalLimitArithmetic,
#[msg("Withdrawal exceeds configured limit for epoch.")]
WithdrawalLimitExceededForEpoch,
#[msg("Withdrawal limiter logged epoch greater than current epoch.")]
WithdrawalLimitInvalidEpoch,
#[msg("Withdrawal limit is zero or exceeds pool amount.")]
WithdrawalLimitValidation,
#[msg("Fixed-point value has unexpected exponent.")]
FixValueConversion,
#[msg("SPL stake pool account data failed to deserialize.")]
StakePoolAccountData,
#[msg("Operation disabled in current protocol state.")]
OperationDisabled,
#[msg("Failed while converting precision for a token amount.")]
TokenAmountPrecision,
#[msg("No LST header or stake pool found for mint.")]
UnknownLstMint,
}