use num_derive::FromPrimitive;
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
pub enum SatrushError {
#[error("Signer is not authorized to execute this instruction")]
Unauthorized = 0x1770,
#[error("Ongoing round is not yet finished")]
RoundInProgress = 0x1771,
#[error("Invalid round id supplied to create round")]
InvalidRoundId = 0x1772,
#[error("Round duration must be greater than zero")]
InvalidRoundDuration = 0x1773,
#[error("Entropy value is invalid")]
InvalidEntropy = 0x1774,
#[error("Round is not accepting deploys")]
RoundNotActive = 0x1775,
#[error("Deployment amount must be greater than zero")]
InvalidDeploymentAmount = 0x1776,
#[error("Selection mask must pick between 1 and 21 tiles within the 21-bit range")]
InvalidSelectionMask = 0x1777,
#[error("Arithmetic overflow")]
MathOverflow = 0x1778,
#[error("Arithmetic underflow")]
MathUnderflow = 0x1779,
#[error("Round winning tile has already been revealed")]
AlreadyRevealed = 0x177A,
#[error("Slot hash entropy is unavailable or invalid")]
InvalidSlotHash = 0x177B,
#[error("Round winning tile has not been revealed yet")]
RoundNotRevealed = 0x177C,
#[error("Round is not in the finished state")]
RoundNotFinished = 0x177D,
#[error("Round is not in the settled state")]
RoundNotSettled = 0x177E,
#[error("Swap program account does not match the configured swap program")]
InvalidSwapProgram = 0x177F,
#[error("Round stake has already been swapped into BTC")]
AlreadySwapped = 0x1780,
#[error("Swap spent more USD than the budgeted amount")]
SwapOverspent = 0x1781,
#[error("Swap output is below the minimum acceptable amount")]
SlippageExceeded = 0x1782,
#[error("Share amount must be greater than zero")]
InvalidShareAmount = 0x1783,
#[error("Miner does not hold enough Sats Vault shares")]
InsufficientShares = 0x1784,
#[error("Strike jackpot was already triggered on the provided round")]
StrikeAlreadyTriggered = 0x1785,
#[error("Epoch iteration is not accepting ticket purchases")]
EpochNotOpen = 0x1786,
#[error("Epoch iteration window has not elapsed yet")]
EpochWindowNotElapsed = 0x1787,
#[error("Epoch iteration is not in the settling state")]
EpochNotSettling = 0x1788,
#[error("Epoch iteration is not in the settled state")]
EpochNotSettled = 0x1789,
#[error("Supplied page does not contain the current winning ticket")]
EpochInvalidPage = 0x178A,
#[error("Signer is not a winner of this epoch draw")]
EpochNotAWinner = 0x178B,
#[error("Epoch reward has already been claimed")]
EpochAlreadyClaimed = 0x178C,
#[error("Epoch iteration has reached the maximum number of participants")]
EpochMaxParticipants = 0x178D,
#[error("Tickets count must be greater than zero")]
InvalidTicketsCount = 0x178E,
#[error("Miner does not have enough hashrate")]
InsufficientHashrate = 0x178F,
#[error("1 BTC Vault iteration is not accepting ticket purchases")]
OneBtcNotOpen = 0x1790,
#[error("1 BTC Vault iteration is not in the settled state")]
OneBtcNotSettled = 0x1791,
#[error("1 BTC Vault has not accumulated enough BTC to trigger a draw")]
OneBtcNotTriggerable = 0x1792,
#[error("1 BTC Vault draw has no participants")]
OneBtcNoParticipants = 0x1793,
#[error("Ticket does not hold the winning ticket for this draw")]
OneBtcNotAWinner = 0x1794,
#[error("The winning ticket cannot be closed until the prize is claimed")]
OneBtcWinningTicketLocked = 0x1795,
#[error("Epoch page has already been sealed")]
EpochPageAlreadySealed = 0x1796,
#[error("Epoch page is not sealed yet")]
EpochPageNotSealed = 0x1797,
#[error("Epoch sealed page chain does not reconcile with the iteration's ticket total")]
EpochSealMismatch = 0x1798,
#[error("Treasury has no accrued fees to withdraw")]
TreasuryEmpty = 0x1799,
#[error("Claim amount must be greater than zero")]
InvalidClaimAmount = 0x179A,
#[error("Miner does not hold enough unclaimed USD")]
InsufficientUnclaimedUsd = 0x179B,
#[error("Automation balance cannot cover the per-round deploy amount")]
InsufficientAutomationBalance = 0x179C,
#[error("Automation amount must be greater than zero")]
InvalidAutomationAmount = 0x179D,
#[error("Selection mask does not match the automation strategy")]
InvalidAutomationStrategyMask = 0x179E,
#[error("Deploy amount is below the 1 USD minimum")]
DeployAmountBelowMinimum = 0x179F,
#[error("Epoch iteration duration must be greater than zero")]
InvalidEpochIterationDuration = 0x17A0,
#[error("Unclaimed hashrate bps must not exceed 10_000")]
InvalidUnclaimedHashrateBps = 0x17A1,
#[error("Strike trigger modulus must be greater than zero")]
InvalidStrikeTriggerModulus = 0x17A2,
#[error("Sats Vault round fee bps plus deploy fee bps must stay below 10_000")]
InvalidSwapBps = 0x17A3,
}
impl From<SatrushError> for solana_program_error::ProgramError {
fn from(e: SatrushError) -> Self {
solana_program_error::ProgramError::Custom(e as u32)
}
}