1use {
2 num_derive::FromPrimitive,
3 solana_program::{
4 decode_error::DecodeError,
5 msg,
6 program_error::{PrintProgramError, ProgramError},
7 },
8 thiserror::Error,
9};
10
11#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
13pub enum AuctionError {
14 #[error("Account does not have correct owner")]
16 IncorrectOwner,
17
18 #[error("Lamport balance below rent-exempt threshold")]
20 NotRentExempt,
21
22 #[error("Bid account provided does not match the derived address.")]
24 InvalidBidAccount,
25
26 #[error("Auction account specified is invalid.")]
28 InvalidAuctionAccount,
29
30 #[error("Balance too low to make bid.")]
32 BalanceTooLow,
33
34 #[error("Auction is not currently running.")]
36 InvalidState,
37
38 #[error("Bid is too small.")]
40 BidTooSmall,
41
42 #[error("Invalid auction state transition.")]
44 AuctionTransitionInvalid,
45
46 #[error("Failed to derive an account from seeds.")]
48 DerivedKeyInvalid,
49
50 #[error("Token transfer failed")]
52 TokenTransferFailed,
53
54 #[error("Token mint to failed")]
56 TokenMintToFailed,
57
58 #[error("Token burn failed")]
60 TokenBurnFailed,
61
62 #[error("Invalid authority")]
64 InvalidAuthority,
65
66 #[error("Authority not signer")]
68 AuthorityNotSigner,
69
70 #[error("Numerical overflow")]
72 NumericalOverflowError,
73
74 #[error("Bidder pot token account does not match")]
76 BidderPotTokenAccountOwnerMismatch,
77
78 #[error("Uninitialized")]
80 Uninitialized,
81
82 #[error("Metadata account is missing or invalid.")]
84 MetadataInvalid,
85
86 #[error("Bidder pot is missing, and required for SPL trades.")]
88 BidderPotDoesNotExist,
89
90 #[error("Existing Bid is already active.")]
92 BidAlreadyActive,
93
94 #[error("Incorrect mint specified, must match auction.")]
96 IncorrectMint,
97
98 #[error("Must reveal price when ending a blinded auction.")]
100 MustReveal,
101
102 #[error("The revealing hash is invalid.")]
104 InvalidReveal,
105
106 #[error("The pot for this bid is already empty.")]
108 BidderPotEmpty,
109
110 #[error(" This is not a valid token program")]
112 InvalidTokenProgram,
113
114 #[error("Accept payment delegate should be none")]
116 DelegateShouldBeNone,
117
118 #[error("Accept payment close authority should be none")]
120 CloseAuthorityShouldBeNone,
121
122 #[error("Data type mismatch")]
124 DataTypeMismatch,
125
126 #[error("Bid must be multiple of tick size")]
128 BidMustBeMultipleOfTickSize,
129
130 #[error("During the gap window, gap between next lowest bid must be of a certain percentage")]
132 GapBetweenBidsTooSmall,
133
134 #[error("Gap tick size percentage must be between 0 and 100")]
136 InvalidGapTickSizePercentage,
137
138 #[error("Bidder Pot Token Must be a new account")]
140 BidderPotTokenAccountMustBeNew,
141}
142
143impl PrintProgramError for AuctionError {
144 fn print<E>(&self) {
145 msg!(&self.to_string());
146 }
147}
148
149impl From<AuctionError> for ProgramError {
150 fn from(e: AuctionError) -> Self {
151 ProgramError::Custom(e as u32)
152 }
153}
154
155impl<T> DecodeError<T> for AuctionError {
156 fn type_of() -> &'static str {
157 "Vault Error"
158 }
159}