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
49// Market ---------------------------------------------------------------
50
51/// While creating ordered map with invalid parameters,
52/// or changing them improperly for an existent map.
53pub const InvalidMarketParameters: u64 = 1000;
54/// Tried to call `update_funding` before enough time has passed since the
55/// last update.
56pub const UpdatingFundingTooEarly: u64 = 1001;
57/// Margin ratio update proposal already exists for market
58pub const ProposalAlreadyExists: u64 = 1002;
59/// Margin ratio update proposal cannot be commited too early
60pub const PrematureProposal: u64 = 1003;
61/// Margin ratio update proposal delay is outside the valid range
62pub const InvalidProposalDelay: u64 = 1004;
63/// Margin ratio update proposal does not exist for market
64pub const ProposalDoesNotExist: u64 = 1005;
65/// Exchange has no available fees to withdraw
66pub const NoFeesAccrued: u64 = 1006;
67/// Tried to withdraw more insurance funds than the allowed amount
68pub const InsufficientInsuranceSurplus: u64 = 1007;
69/// Cannot create a market for which a price feed does not exist
70pub const NoPriceFeedForMarket: u64 = 1008;
71/// Cannot delete a proposal that already matured. It can only be committed.
72pub const ProposalAlreadyMatured: u64 = 1009;
73
74// Position  ---------------------------------------------------------------
75
76/// Tried placing a new pending order when the position already has the maximum
77/// allowed number of pending orders.
78pub const MaxPendingOrdersExceeded: u64 = 2000;
79/// Used for checking both liqee and liqor positions during liquidation
80pub const PositionBelowIMR: u64 = 2001;
81/// When leaving liqee's position with a margin ratio above tolerance,
82/// meaning that liqor has overbought position
83pub const PositionAboveTolerance: u64 = 2002;
84/// An operation brought an account below initial margin requirements.
85pub const InitialMarginRequirementViolated: u64 = 2003;
86/// Position is above MMR, so can't be liquidated.
87pub const PositionAboveMMR: u64 = 2004;
88/// Cannot realize bad debt via means other than calling 'liquidate'.
89pub const PositionBadDebt: u64 = 2005;
90/// Cannot withdraw more than the account's free collateral.
91pub const InsufficientFreeCollateral: u64 = 2006;
92/// Cannot have more than 1 position in a market.
93pub const PositionAlreadyExists: u64 = 2007;
94/// Cannot compute deallocate amount for a target MR < IMR.
95pub const DeallocateTargetMrTooLow: u64 = 2008;
96
97// Orderbook & OrderedMap -------------------------------------------------------
98
99/// While creating ordered map with wrong parameters.
100pub const InvalidMapParameters: u64 = 3000;
101/// While searching for a key, but it doesn't exist.
102pub const KeyNotExist: u64 = 3001;
103/// While inserting already existing key.
104pub const KeyAlreadyExists: u64 = 3002;
105/// When attempting to destroy a non-empty map
106pub const DestroyNotEmpty: u64 = 3003;
107/// Invalid user tries to modify an order
108pub const InvalidUserForOrder: u64 = 3004;
109/// Orderbook flag requirements violated
110pub const FlagRequirementsViolated: u64 = 3005;
111/// Minimum size matched not reached
112pub const NotEnoughLiquidity: u64 = 3006;
113/// When trying to change a map configuration, but the map has
114/// length less than 4
115pub const MapTooSmall: u64 = 3007;
116/// When taker matches its own order
117pub const SelfTrading: u64 = 3008;