1use thiserror::Error;
4
5#[derive(Error, Debug)]
6pub enum ProgramError {
7 #[error("Insufficient collateral")]
8 InsufficientCollateral,
9
10 #[error("Excessive leverage")]
11 ExcessiveLeverage,
12
13 #[error("Position not found")]
14 PositionNotFound,
15
16 #[error("Invalid oracle price")]
17 InvalidOraclePrice,
18
19 #[error("Market not found")]
20 MarketNotFound,
21
22 #[error("Unauthorized access")]
23 Unauthorized,
24
25 #[error("Oracle price stale")]
26 StalePriceData,
27
28 #[error("Position cannot be liquidated")]
29 CannotLiquidate,
30
31 #[error("Insufficient liquidity")]
32 InsufficientLiquidity,
33
34 #[error("Invalid amount")]
35 InvalidAmount,
36
37 #[error("Account already exists")]
38 AccountAlreadyExists,
39
40 #[error("Account not initialized")]
41 AccountNotInitialized,
42
43 #[error("Risk threshold exceeded")]
44 RiskThresholdExceeded,
45
46 #[error("Mathematical overflow")]
47 Overflow,
48
49 #[error("Invalid configuration")]
50 InvalidConfiguration,
51}
52
53pub type Result<T> = std::result::Result<T, ProgramError>;