af_iperps/
errors.rs

1#![expect(non_upper_case_globals, reason = "Copied from Move")]
2
3// ClearingHouse ---------------------------------------------------------------
4
5/// Cannot deposit/withdraw zero coins to/from the account's collateral.
6pub const DepositOrWithdrawAmountZero: u64 = 0;
7/// Orderbook size or price are invalid values
8pub const InvalidSizeOrPrice: u64 = 1;
9/// Index price returned from oracle is 0 or invalid value
10pub const BadIndexPrice: u64 = 2;
11/// Order value in USD is too low
12pub const OrderUsdValueTooLow: u64 = 4;
13/// Passed a vector of invalid order ids to perform force cancellation
14/// during liquidation
15pub const InvalidForceCancelIds: u64 = 5;
16/// Liquidate must be the first operation of the session, if performed.
17pub const LiquidateNotFirstOperation: u64 = 6;
18/// Passed a vector of invalid order ids to cancel
19pub const InvalidCancelOrderIds: u64 = 7;
20/// Ticket has already passed `expire_timestamp` and can only be cancelled
21pub const StopOrderTicketExpired: u64 = 8;
22/// Index price is not at correct value to satisfy stop order conditions
23pub const StopOrderConditionsViolated: u64 = 9;
24/// Index price is not at correct value to satisfy stop order conditions
25pub const WrongOrderDetails: u64 = 10;
26/// Invalid base price feed storage for the clearing house
27pub const InvalidBasePriceFeedStorage: u64 = 11;
28/// Same liquidator and liqee account ids
29pub const SelfLiquidation: u64 = 12;
30/// User trying to access the subaccount is not the one specified by parent
31pub const InvalidSubAccountUser: u64 = 13;
32/// The parent `Account` trying to delete the subaccount is not the correct one.
33pub const WrongParentForSubAccount: u64 = 14;
34/// Raised when trying to delete a subaccount still containing collateral.
35pub const SubAccountContainsCollateral: u64 = 15;
36/// Raised when trying to call a function with the wrong package's version
37pub const WrongVersion: u64 = 16;
38/// Raised when trying to have a session composed by only `start_session` and `end_session`
39pub const EmptySession: u64 = 17;
40/// Market already registered in the registry
41pub const MarketAlreadyRegistered: u64 = 18;
42/// Collateral is not registered in the registry
43pub const CollateralIsNotRegistered: u64 = 19;
44/// Market is not registered in the registry
45pub const MarketIsNotRegistered: u64 = 20;
46/// Invalid collateral price feed storage for the clearing house
47pub const InvalidCollateralPriceFeedStorage: u64 = 21;
48/// Fees accrued are negative
49pub const NegativeFeesAccrued: u64 = 22;
50/// Reduce only conditions are not respected for stop order execution
51pub const NotReduceOnlyStopOrder: u64 = 23;
52/// Stop order gas cost provided is not enough
53pub const NotEnoughGasForStopOrder: u64 = 24;
54
55// Market ---------------------------------------------------------------
56
57/// While creating ordered map with invalid parameters,
58/// or changing them improperly for an existent map.
59pub const InvalidMarketParameters: u64 = 1000;
60/// Tried to call `update_funding` before enough time has passed since the
61/// last update.
62pub const UpdatingFundingTooEarly: u64 = 1001;
63/// Margin ratio update proposal already exists for market
64pub const ProposalAlreadyExists: u64 = 1002;
65/// Margin ratio update proposal cannot be commited too early
66pub const PrematureProposal: u64 = 1003;
67/// Margin ratio update proposal delay is outside the valid range
68pub const InvalidProposalDelay: u64 = 1004;
69/// Margin ratio update proposal does not exist for market
70pub const ProposalDoesNotExist: u64 = 1005;
71/// Exchange has no available fees to withdraw
72pub const NoFeesAccrued: u64 = 1006;
73/// Tried to withdraw more insurance funds than the allowed amount
74pub const InsufficientInsuranceSurplus: u64 = 1007;
75/// Cannot create a market for which a price feed does not exist
76pub const NoPriceFeedForMarket: u64 = 1008;
77/// Cannot delete a proposal that already matured. It can only be committed.
78pub const ProposalAlreadyMatured: u64 = 1009;
79
80// Position  ---------------------------------------------------------------
81
82/// Tried placing a new pending order when the position already has the maximum
83/// allowed number of pending orders.
84pub const MaxPendingOrdersExceeded: u64 = 2000;
85/// Used for checking both liqee and liqor positions during liquidation
86pub const PositionBelowIMR: u64 = 2001;
87/// When leaving liqee's position with a margin ratio above tolerance,
88/// meaning that liqor has overbought position
89pub const PositionAboveTolerance: u64 = 2002;
90/// An operation brought an account below initial margin requirements.
91pub const InitialMarginRequirementViolated: u64 = 2003;
92/// Position is above MMR, so can't be liquidated.
93pub const PositionAboveMMR: u64 = 2004;
94/// Cannot realize bad debt via means other than calling 'liquidate'.
95pub const PositionBadDebt: u64 = 2005;
96/// Cannot withdraw more than the account's free collateral.
97pub const InsufficientFreeCollateral: u64 = 2006;
98/// Cannot have more than 1 position in a market.
99pub const PositionAlreadyExists: u64 = 2007;
100/// Cannot compute deallocate amount for a target MR < IMR.
101pub const DeallocateTargetMrTooLow: u64 = 2008;
102
103// Orderbook & OrderedMap -------------------------------------------------------
104
105/// While creating ordered map with wrong parameters.
106pub const InvalidMapParameters: u64 = 3000;
107/// While searching for a key, but it doesn't exist.
108pub const KeyNotExist: u64 = 3001;
109/// While inserting already existing key.
110pub const KeyAlreadyExists: u64 = 3002;
111/// When attempting to destroy a non-empty map
112pub const DestroyNotEmpty: u64 = 3003;
113/// Invalid user tries to modify an order
114pub const InvalidUserForOrder: u64 = 3004;
115/// Orderbook flag requirements violated
116pub const FlagRequirementsViolated: u64 = 3005;
117/// Minimum size matched not reached
118pub const NotEnoughLiquidity: u64 = 3006;
119/// When trying to change a map configuration, but the map has
120/// length less than 4
121pub const MapTooSmall: u64 = 3007;
122/// When taker matches its own order
123pub const SelfTrading: u64 = 3008;