1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use solana_program::{decode_error::DecodeError, program_error::ProgramError};
use thiserror::Error;
#[derive(Clone, Debug, Eq, Error, PartialEq)]
pub enum OptionsError {
#[error("Expiration has passed, cannot mint")]
CantMintExpired,
#[error("Incorrect mint on the quote asset account, cannot mint")]
IncorrectQuoteAssetKey,
#[error("Same quote and underlying asset, cannot create market")]
QuoteAndUnderlyingAssetMustDiffer,
#[error("OptionWriter was not found in registry")]
OptionWriterNotFound,
#[error("OptionMarket has not expired yet")]
OptionMarketNotExpired,
#[error("OptionMarket has expired")]
OptionMarketHasExpired,
#[error("Incorrect pool was accessed")]
IncorrectPool,
#[error("Option or writer token does not match market")]
IncorrectMarketTokens,
#[error("The OptionMarket address does not match")]
BadMarketAddress,
#[error("The OptionMarket owner is incorrect")]
BadMarketOwner,
#[error("The OptionMarket is already initiated")]
MarketAlreadyInitialized,
#[error("Initializing the market with invalid parameters")]
InvalidInitializationParameters,
#[error("The fee owner is incorrect")]
BadFeeOwner,
#[error("Invalid token program id")]
InvalidTokenProgram,
}
impl From<OptionsError> for ProgramError {
fn from(e: OptionsError) -> Self {
ProgramError::Custom(e as u32)
}
}
impl<T> DecodeError<T> for OptionsError {
fn type_of() -> &'static str {
"OptionsError"
}
}