jup_perps_client/errors/
perpetuals.rs1use num_derive::FromPrimitive;
9use thiserror::Error;
10
11#[derive(Clone, Debug, Eq, Error, FromPrimitive, PartialEq)]
12pub enum PerpetualsError {
13 #[error("Overflow in arithmetic operation")]
15 MathOverflow = 0x1770,
16 #[error("Unsupported price oracle")]
18 UnsupportedOracle = 0x1771,
19 #[error("Invalid oracle account")]
21 InvalidOracleAccount = 0x1772,
22 #[error("Stale oracle price")]
24 StaleOraclePrice = 0x1773,
25 #[error("Invalid oracle price")]
27 InvalidOraclePrice = 0x1774,
28 #[error("Instruction is not allowed in production")]
30 InvalidEnvironment = 0x1775,
31 #[error("Invalid collateral account")]
33 InvalidCollateralAccount = 0x1776,
34 #[error("Invalid collateral amount")]
36 InvalidCollateralAmount = 0x1777,
37 #[error("Collateral slippage")]
39 CollateralSlippage = 0x1778,
40 #[error("Invalid position state")]
42 InvalidPositionState = 0x1779,
43 #[error("Invalid perpetuals config")]
45 InvalidPerpetualsConfig = 0x177A,
46 #[error("Invalid pool config")]
48 InvalidPoolConfig = 0x177B,
49 #[error("Invalid instruction")]
51 InvalidInstruction = 0x177C,
52 #[error("Invalid custody config")]
54 InvalidCustodyConfig = 0x177D,
55 #[error("Invalid custody balance")]
57 InvalidCustodyBalance = 0x177E,
58 #[error("Invalid argument")]
60 InvalidArgument = 0x177F,
61 #[error("Invalid position request")]
63 InvalidPositionRequest = 0x1780,
64 #[error("Invalid position request input ata")]
66 InvalidPositionRequestInputAta = 0x1781,
67 #[error("Invalid mint")]
69 InvalidMint = 0x1782,
70 #[error("Insufficient token amount")]
72 InsufficientTokenAmount = 0x1783,
73 #[error("Insufficient token amount returned")]
75 InsufficientAmountReturned = 0x1784,
76 #[error("Price slippage limit exceeded")]
78 MaxPriceSlippage = 0x1785,
79 #[error("Position leverage limit exceeded")]
81 MaxLeverage = 0x1786,
82 #[error("Custody amount limit exceeded")]
84 CustodyAmountLimit = 0x1787,
85 #[error("Pool amount limit exceeded")]
87 PoolAmountLimit = 0x1788,
88 #[error("Personal pool amount limit exceeded")]
90 PersonalPoolAmountLimit = 0x1789,
91 #[error("Token is not supported")]
93 UnsupportedToken = 0x178A,
94 #[error("Instruction is not allowed at this time")]
96 InstructionNotAllowed = 0x178B,
97 #[error("Jupiter Program ID mismatch")]
99 JupiterProgramMismatch = 0x178C,
100 #[error("Program ID mismatch")]
102 ProgramMismatch = 0x178D,
103 #[error("Address mismatch")]
105 AddressMismatch = 0x178E,
106 #[error("Missing keeper ATA")]
108 KeeperATAMissing = 0x178F,
109 #[error("Swap amount mismatch")]
111 SwapAmountMismatch = 0x1790,
112 #[error("CPI not allowed")]
114 CPINotAllowed = 0x1791,
115 #[error("Invalid Keeper")]
117 InvalidKeeper = 0x1792,
118 #[error("Exceed execution period")]
120 ExceedExecutionPeriod = 0x1793,
121 #[error("Invalid Request Type")]
123 InvalidRequestType = 0x1794,
124 #[error("Invalid Trigger Price")]
126 InvalidTriggerPrice = 0x1795,
127 #[error("Trigger Price Slippage")]
129 TriggerPriceSlippage = 0x1796,
130 #[error("Missing Trigger Price")]
132 MissingTriggerPrice = 0x1797,
133 #[error("Missing Price Slippage")]
135 MissingPriceSlippage = 0x1798,
136 #[error("Invalid Price Calc Mode")]
138 InvalidPriceCalcMode = 0x1799,
139 #[error("Request Updated Too Recent")]
141 RequestUpdatedTooRecent = 0x179A,
142 #[error("Exceed Token Weightage")]
144 ExceedTokenWeightage = 0x179B,
145 #[error("Oracle Publish Time Too Early")]
147 OraclePublishTimeTooEarly = 0x179C,
148 #[error("Pull Oracle Publish Time Too Early")]
150 PullOraclePublishTimeTooEarly = 0x179D,
151 #[error("Stale Pull Oracle Price")]
153 StalePullOraclePrice = 0x179E,
154 #[error("Invalid Pull Oracle Price")]
156 InvalidPullOraclePrice = 0x179F,
157 #[error("Pull Oracle Not Verified")]
159 PullOracleNotVerified = 0x17A0,
160 #[error("Price Diff Between Pull and Push Oracle is Too Large")]
162 PriceDiffTooLarge = 0x17A1,
163 #[error("Invalid Doves Oracle Price")]
165 InvalidDovesOraclePrice = 0x17A2,
166 #[error("Invalid Request Time")]
168 InvalidRequestTime = 0x17A3,
169 #[error("Position Updated Too Recent")]
171 PositionUpdatedTooRecent = 0x17A4,
172 #[error("Ledger token account does not match")]
174 LedgerTokenAccountDoesNotMatch = 0x17A5,
175 #[error("Invalid token ledger")]
177 InvalidTokenLedger = 0x17A6,
178 #[error("Oracle Price Difference Too Large")]
180 OraclePriceDifferenceTooLarge = 0x17A7,
181 #[error("Invalid Oracle Signer")]
183 InvalidOracleSigner = 0x17A8,
184 #[error("Invalid Oracle Timestamp")]
186 InvalidOracleTimestamp = 0x17A9,
187 #[error("New Max Global Long Size Too Low")]
189 InvalidMaxGlobalLongSize = 0x17AA,
190 #[error("New Max Global Short Size Too Low")]
192 InvalidMaxGlobalShortSize = 0x17AB,
193 #[error("Borrows disabled for this custody")]
195 BorrowsDisabled = 0x17AC,
196 #[error("Borrows limit exceeded for this custody")]
198 BorrowLimitsExceeded = 0x17AD,
199 #[error("Withdraw exceeds margin of the custody")]
201 WithdrawExceedsMarginLimits = 0x17AE,
202 #[error("Cannot liquidate")]
204 CannotLiquidate = 0x17AF,
205 #[error("Cannot delegate stake to deactivated account")]
207 CannotDelegateStake = 0x17B0,
208 #[error("Max total staked amount exceeded")]
210 ExceededMaxTotalStakedAmount = 0x17B1,
211 #[error("LP token price change exceeds limit")]
213 LpTokenPriceChangeLimitExceeded = 0x17B2,
214}
215
216impl From<PerpetualsError> for solana_program::program_error::ProgramError {
217 fn from(e: PerpetualsError) -> Self {
218 solana_program::program_error::ProgramError::Custom(e as u32)
219 }
220}