use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum ReflectMainError {
#[error("Number of recipients wrong")]
MissingRecipient = 0x1770,
#[error("Number of recipients can't be zero")]
NoRecipients = 0x1771,
#[error("Recipients can't exceed limit")]
TooManyRecipients = 0x1772,
#[error("Provided wrong recipient or in incorrect order")]
IncorrectRecipient = 0x1773,
#[error("Component does not exist in this account")]
ComponentNotFound = 0x1774,
#[error("Invalid component type")]
InvalidComponentType = 0x1775,
#[error("Component registry is full")]
ComponentRegistryFull = 0x1776,
#[error("Component size exceeds maximum allowed")]
ComponentTooLarge = 0x1777,
#[error("No more space for component data")]
ComponentDataExhausted = 0x1778,
#[error("Component exists already")]
ComponentAlreadyExists = 0x1779,
#[error("Cap can't be lower than what has been minted")]
TooLowCap = 0x177A,
#[error("No more stable can be minted under this cap settings")]
CapExceeded = 0x177B,
#[error("Out of bounds access")]
OutOfBounds = 0x177C,
#[error("Invalid data length")]
BadLen = 0x177D,
#[error("This strategy already supports this SPL")]
StrategyAlreadySupportsSpl = 0x177E,
#[error("Protocol already supports this SPL")]
ProtocolAlreadySupportsSpl = 0x177F,
#[error("Not enough funds for this transaction")]
NotEnoughSplInput = 0x1780,
#[error("SPL not found")]
SplNotFound = 0x1781,
#[error("Provided SPL mint is not supported at the strategy")]
StrategyDoesNotSupportSpl = 0x1782,
#[error("Provided wrong mint account")]
IncorrectMint = 0x1783,
#[error("Need the correct number of the accounts in the remaining")]
IncorrectNumberOfAccounts = 0x1784,
#[error("Incorrect mint address for this strategy")]
IncorrectReflectStrategyMint = 0x1785,
#[error("Incorrect token address for reflect token account")]
IncorrectReflectTokenAccount = 0x1786,
#[error("Slippage protection triggered for SPL redeem")]
OutputAmountTooLow = 0x1787,
#[error("Cannot mint stable using this SPL at this strategy")]
SplMintFrozen = 0x1788,
#[error("Token account of a different accoutn is needed for withdraw")]
IncorrectWithdrawMint = 0x1789,
#[error("Provided wrong token account")]
InvalidTokenAccount = 0x178A,
#[error("Provided permissions account does not match the caller")]
IncorrectAdminAccount = 0x178B,
#[error("Caller does not have the privilege for this action")]
MissingAdminPrivallages = 0x178C,
#[error("Can't remove the last admin")]
LastAdmin = 0x178D,
#[error("Special call for supremo removal")]
SupremoOnly = 0x178E,
#[error("You've provided same admin account")]
SameAdmin = 0x178F,
#[error("User does not have such role")]
UserLacksRole = 0x1790,
#[error("User already has requested role")]
UserAlreadyHasRole = 0x1791,
#[error("This action lacks specified role")]
RoleNotUnderAction = 0x1792,
#[error("Action not found")]
ActionNotFound = 0x1793,
#[error("This action can already be performed by this role")]
ActionHasAssignedRole = 0x1794,
#[error("This action can only be performed by a supreme authority")]
SupremoOnlyAction = 0x1795,
#[error("Only supreme authorities can assign supreme authority roles")]
CannotAssignSupremo = 0x1796,
#[error("Desired state is already on")]
AlreadyThere = 0x1797,
#[error("Action already frozen")]
AlreadyFrozen = 0x1798,
#[error("Action already unfrozen")]
AlreadyUnfrozen = 0x1799,
#[error("Program already registered")]
ProgramAlreadyExists = 0x179A,
#[error("Supplied program can not be used")]
InvalidProgram = 0x179B,
#[error("Supplied program account can not be used")]
InvalidProgramAccount = 0x179C,
#[error("Neceessary account not provided")]
MissingAccount = 0x179D,
#[error("Math error")]
MathError = 0x179E,
#[error("Can't transmute")]
ConversionFailed = 0x179F,
#[error("Mathematical operation overflow")]
MathOverflow = 0x17A0,
#[error("Can't divide by zero")]
DivisionByZero = 0x17A1,
#[error("Invalid data provided")]
InvalidData = 0x17A2,
#[error("Invalid state")]
InvalidState = 0x17A3,
#[error("Invalid input")]
InvalidInput = 0x17A4,
#[error("Could not load the price account")]
PythError = 0x17A5,
#[error("Failed unwrap")]
FailedUnwrap = 0x17A6,
#[error("Difference is too small to capture")]
SpreadTooSmall = 0x17A7,
#[error("Serialisation failed")]
SerialisationFailed = 0x17A8,
#[error("Deserialisation failed")]
DeserialisationFailed = 0x17A9,
#[error("Item could not be added")]
NoEntriesLeft = 0x17AA,
#[error("Provided wrong controller")]
InvalidController = 0x17AB,
#[error("This action is suspended")]
ActionFrozen = 0x17AC,
#[error("This configuration leads to an impossibility")]
AttenuationExceedsMaximum = 0x17AD,
#[error("At least one parameter must be provided")]
InvalidAttenuationParameters = 0x17AE,
#[error("Capture failed")]
CaptureProblem = 0x17AF,
#[error("All payout parties must add up to 100.0%")]
InvalidRatios = 0x17B0,
#[error("PerpMarketNotFound")]
PerpMarketNotFound = 0x17B1,
#[error("UnableToLoadMarketAccount")]
UnableToLoadPerpMarketAccount = 0x17B2,
#[error("InvalidMarketAccount")]
InvalidMarketAccount = 0x17B3,
#[error("CouldNotLoadMarketData")]
CouldNotLoadMarketData = 0x17B4,
#[error("MarketWrongMutability")]
MarketWrongMutability = 0x17B5,
#[error("SpotMarketWrongMutability")]
SpotMarketWrongMutability = 0x17B6,
#[error("UnableToLoadSpotMarketAccount")]
UnableToLoadSpotMarketAccount = 0x17B7,
#[error("InvalidSpotMarketAccount")]
InvalidSpotMarketAccount = 0x17B8,
#[error("CouldNotLoadSpotMarketData")]
CouldNotLoadSpotMarketData = 0x17B9,
#[error("Position has unsettled PnL and must be settled first")]
UnsettledPnl = 0x17BA,
#[error("Unable To Load Oracles")]
UnableToLoadOracle = 0x17BB,
#[error("OracleNotFound")]
OracleNotFound = 0x17BC,
#[error("InvalidOracle")]
InvalidOracle = 0x17BD,
#[error("SpotMarketNotFound")]
SpotMarketNotFound = 0x17BE,
#[error("InvalidOracle")]
InvalidOracleSource = 0x17BF,
#[error("Position does not exist.")]
MissingPositon = 0x17C0,
#[error("SPL input is less than the minimum position change.")]
BelowMinPositionChange = 0x17C1,
#[error("SPL input is less than the minimum position.")]
BelowMinPosition = 0x17C2,
#[error("Drift only supports 8 spot accounts")]
DriftMaxSpots = 0x17C3,
#[error("My main man is to suffer no sneaky haircuts")]
DriftWithdrawlFee = 0x17C4,
#[error("SPL not supported")]
SplNotSupported = 0x17C5,
#[error("Provided spot account does not match the expected spot account")]
IncorrectSpot = 0x17C6,
#[error("Market index not supported")]
DriftMarketIndexNotSupported = 0x17C7,
#[error("Provided drift state account is incorrect")]
IncorrectReflectState = 0x17C8,
#[error("Drift post CPI state of orders and/or base asset amount didn't show decrease")]
IncorrectReduction = 0x17C9,
#[error("Drift post CPI state of orders and/or base asset amount didn't show increase")]
IncorrectIncrease = 0x17CA,
#[error("Can't create a new subaccount")]
SubAccountNotFull = 0x17CB,
#[error("Not enough USDC for this deposit")]
UsdcSplTooLow = 0x17CC,
#[error("Specified perp position not found")]
PerpPositionNotFound = 0x17CD,
#[error("InvalidJlpOracle")]
InvalidJlpOracle = 0x17CE,
#[error("Mint of this custody is not hedged")]
CustodyNotHedged = 0x17CF,
#[error("Incorrect JLP account supplied")]
IncorrectJlpAccount = 0x17D0,
#[error("TODO")]
ToDo = 0x17D1,
}
impl From<ReflectMainError> for solana_program_error::ProgramError {
fn from(e: ReflectMainError) -> Self {
solana_program_error::ProgramError::Custom(e as u32)
}
}