manifest/program/
error.rs1use solana_program::program_error::ProgramError;
2use thiserror::Error;
3
4#[derive(Debug, Error)]
5#[repr(u32)]
6pub enum ManifestError {
7 #[error("Invalid market parameters error")]
8 InvalidMarketParameters = 0,
9 #[error("Invalid deposit accounts error")]
10 InvalidDepositAccounts = 1,
11 #[error("Invalid withdraw accounts error")]
12 InvalidWithdrawAccounts = 2,
13 #[error("Invalid cancel error")]
14 InvalidCancel = 3,
15 #[error("Internal free list corruption error")]
16 InvalidFreeList = 4,
17 #[error("Cannot claim a second seat for the same trader")]
18 AlreadyClaimedSeat = 5,
19 #[error("Matched on a post only order")]
20 PostOnlyCrosses = 6,
21 #[error("New order is already expired")]
22 AlreadyExpired = 7,
23 #[error("Less than minimum out amount")]
24 InsufficientOut = 8,
25 #[error("Invalid place order from wallet params")]
26 InvalidPlaceOrderFromWalletParams = 9,
27 #[error("Index hint did not match actual index")]
28 WrongIndexHintParams = 10,
29 #[error("Price is not positive")]
30 PriceNotPositive = 11,
31 #[error("Order settlement would overflow")]
32 OrderWouldOverflow = 12,
33 #[error("Order is too small to settle any value")]
34 OrderTooSmall = 13,
35 #[error("Overflow in token addition")]
36 Overflow = 14,
37 #[error("Missing Global account")]
38 MissingGlobal = 15,
39 #[error("Insufficient funds on global account to rest an order")]
40 GlobalInsufficient = 16,
41 #[error("Account key did not match expected")]
42 IncorrectAccount = 17,
43 #[error("Mint not allowed for market")]
44 InvalidMint = 18,
45 #[error("Cannot claim a new global seat, use evict")]
46 TooManyGlobalSeats = 19,
47 #[error("Can only evict the lowest depositor")]
48 InvalidEvict = 20,
49 #[error("Tried to clean order that was not eligible to be cleaned")]
50 InvalidClean = 21,
51}
52
53impl From<ManifestError> for ProgramError {
54 fn from(e: ManifestError) -> Self {
55 ProgramError::Custom(e as u32)
56 }
57}
58
59#[cfg(feature = "certora")]
60#[macro_export]
61macro_rules! require {
62 ($test:expr, $err:expr, $($arg:tt)*) => {{
63 ::cvt::cvt_assume!($test);
64 Ok::<(), crate::ProgramError>(())
65 }};
66}
67
68#[cfg(not(feature = "certora"))]
69#[macro_export]
70macro_rules! require {
71 ($test:expr, $err:expr, $($arg:tt)*) => {
72 if $test {
73 Ok(())
74 } else {
75 #[cfg(target_os = "solana")]
76 solana_program::msg!("[{}:{}] {}", std::file!(), std::line!(), std::format_args!($($arg)*));
77 #[cfg(not(target_os = "solana"))]
78 std::println!("[{}:{}] {}", std::file!(), std::line!(), std::format_args!($($arg)*));
79 Err(($err))
80 }
81 };
82}