Skip to main content

bullet_exchange_interface/
event.rs

1use rust_decimal::Decimal;
2
3use crate::decimals::PositiveDecimal;
4use crate::time::UnixTimestampMicros;
5use crate::types::{
6    AssetId, BorrowType, ClientOrderId, FeeTier, MarketId, OrderId, OrderType, RepayType, Side,
7    TakeFromInsuranceFundReason, TradeId, TriggerDirection, TriggerOrderId, TriggerPriceCondition,
8    TwapId,
9};
10
11#[derive(
12    borsh::BorshDeserialize,
13    borsh::BorshSerialize,
14    serde::Serialize,
15    serde::Deserialize,
16    PartialEq,
17    Clone,
18    Debug,
19    schemars::JsonSchema,
20    strum::AsRefStr,
21    strum::Display,
22)]
23#[serde(rename_all = "snake_case")]
24#[schemars(rename = "FillType")]
25pub enum FillType {
26    Orderbook,
27    Liquidation,
28    BackstopLiquidation,
29    #[serde(rename = "adl")]
30    ADL,
31}
32
33#[derive(
34    borsh::BorshDeserialize,
35    borsh::BorshSerialize,
36    serde::Serialize,
37    serde::Deserialize,
38    PartialEq,
39    Eq,
40    Clone,
41    Copy,
42    Debug,
43    schemars::JsonSchema,
44    strum::AsRefStr,
45    strum::Display,
46)]
47#[serde(rename_all = "snake_case")]
48#[schemars(rename = "CancelReason")]
49pub enum CancelReason {
50    // user-initiated
51    /// User invoked a cancel action directly (CancelOrders / CancelMarketOrders /
52    /// CancelAllOrders / CancelTriggerOrders / CancelTwapOrder)
53    UserRequested,
54    /// User amended an order (cancel + replace)
55    Amended,
56    /// User placed orders with replace=true; existing market orders wiped
57    Replaced,
58
59    // admin-initiated
60    /// AdminAction::CancelOrders / AdminCancelTriggerOrders
61    AdminRequested,
62    /// Admin pruned the market
63    MarketPruned,
64    /// Market was halted; resting orders cleared
65    MarketHalted,
66
67    // risk-driven
68    /// Account undercollateralized — covers cross-margin
69    /// (PublicAction::ForceCancelOrders) and iso-margin
70    /// (PublicAction::ForceCancelIsoOrders). The cancelled order's margin
71    /// mode disambiguates which one fired.
72    MarginCall,
73    /// User's resting orders cancelled as part of regular liquidation
74    /// (public/liquidate_perp_positions, public/liquidate_iso_perp_position)
75    Liquidation,
76    /// User's resting orders cancelled as part of backstop / insurance-fund
77    /// liquidation. Applies to liquidatee and any liquidator whose trigger
78    /// orders on that market are cleared during takeover.
79    BackstopLiquidation,
80
81    // matching-engine / lifecycle
82    /// Reduce-only order auto-canceled because the position it would have
83    /// reduced shrank to zero
84    ReduceOnlyZeroSize,
85
86    /// A trigger that would have opened/added position was
87    /// auto-canceled because a fill made it stale
88    OpeningTriggerOrphaned,
89
90    /// Linked TPSL sibling canceled because its pair leg fired, was
91    /// rejected, or failed during execution
92    TpslSiblingCancelled,
93
94    /// Trigger fired but couldn't execute — no position to close,
95    /// post-execution margin failure, no liquidity, or runtime error.
96    /// The accompanying RejectTriggerOrder / FailureExecuteTriggerOrder
97    /// event in the same tx carries the specific cause.
98    TriggerExecutionFailed,
99
100    /// TWAP slice schedule exhausted (next-slice size rounded to zero)
101    TwapCompleted,
102
103    /// Order evicted to make room when orderbook hit its capacity limit
104    OrderbookOverflow,
105}
106
107#[derive(
108    borsh::BorshDeserialize,
109    borsh::BorshSerialize,
110    serde::Serialize,
111    serde::Deserialize,
112    PartialEq,
113    Clone,
114    Debug,
115    schemars::JsonSchema,
116    strum::AsRefStr,
117    strum::Display,
118)]
119#[serde(rename_all = "snake_case")]
120#[schemars(rename = "Event")]
121#[non_exhaustive]
122pub enum Event<Address> {
123    /// Market initialized
124    InitializePerpMarket {
125        market_id: MarketId,
126        execution_timestamp: UnixTimestampMicros,
127    },
128    /// Market updated
129    UpdateMarket {
130        market_id: MarketId,
131        execution_timestamp: UnixTimestampMicros,
132    },
133    /// Market deleted
134    DeleteMarket {
135        market_id: MarketId,
136        execution_timestamp: UnixTimestampMicros,
137    },
138    /// Borrow lend initialized
139    InitializeBorrowLendPool {
140        asset_id: AssetId,
141        execution_timestamp: UnixTimestampMicros,
142    },
143    /// Borrow lend updated
144    UpdateBorrowLendPool {
145        asset_id: AssetId,
146        execution_timestamp: UnixTimestampMicros,
147    },
148    /// Deposit
149    Deposit {
150        user_address: Address,
151        asset_id: AssetId,
152        amount: PositiveDecimal,
153        amount_notional: PositiveDecimal,
154        execution_timestamp: UnixTimestampMicros,
155    },
156    /// Order placed
157    PlaceOrder {
158        user_address: Address,
159        order_id: OrderId,
160        market_id: MarketId,
161        price: PositiveDecimal,
162        size: PositiveDecimal,
163        side: Side,
164        order_type: OrderType,
165        source: OrderSource,
166        execution_timestamp: UnixTimestampMicros,
167        client_order_id: Option<ClientOrderId>,
168    },
169    /// Order canceled
170    CancelOrder {
171        user_address: Address,
172        order_id: OrderId,
173        market_id: MarketId,
174        execution_timestamp: UnixTimestampMicros,
175        client_order_id: Option<ClientOrderId>,
176    },
177    /// Force cancel orders, occurs when a user's account is at risk
178    ForceCancelOrders {
179        user_address: Address,
180        cancelled_orders: Vec<(MarketId, Vec<OrderId>)>,
181        cancelled_trigger_orders: Vec<(MarketId, Vec<TriggerOrderId>)>,
182        execution_timestamp: UnixTimestampMicros,
183    },
184    /// Trigger order created
185    CreateTriggerOrder {
186        user_address: Address,
187        trigger_order_id: TriggerOrderId,
188        market_id: MarketId,
189        order_price: PositiveDecimal,
190        trigger_price: PositiveDecimal,
191        trigger_direction: TriggerDirection,
192        price_condition: TriggerPriceCondition,
193        size: Option<PositiveDecimal>,
194        side: Side,
195        order_type: OrderType,
196        execution_timestamp: UnixTimestampMicros,
197    },
198    /// Trigger order activated for execution
199    ActivateTriggerOrder {
200        trigger_order_id: TriggerOrderId,
201        market_id: MarketId,
202        price_condition: TriggerPriceCondition,
203        execution_timestamp: UnixTimestampMicros,
204    },
205    /// Edit existing trigger order active / inactive
206    EditTriggerOrder {
207        user_address: Address,
208        trigger_order_id: TriggerOrderId,
209        size_added: Option<PositiveDecimal>,
210        execution_timestamp: UnixTimestampMicros,
211    },
212    /// Active trigger order executed from queue
213    TryExecuteTriggerOrder {
214        user_address: Address,
215        trigger_order_id: TriggerOrderId,
216        execution_timestamp: UnixTimestampMicros,
217    },
218    /// Active trigger order successfully executed
219    SuccessfulExecuteTriggerOrder {
220        user_address: Address,
221        trigger_order_id: TriggerOrderId,
222        market_id: MarketId,
223        order_price: PositiveDecimal,
224        trigger_price: PositiveDecimal,
225        trigger_direction: TriggerDirection,
226        price_condition: TriggerPriceCondition,
227        executed_size: PositiveDecimal,
228        side: Side,
229        order_type: OrderType,
230        execution_timestamp: UnixTimestampMicros,
231    },
232    FailureExecuteTriggerOrder {
233        user_address: Address,
234        trigger_order_id: TriggerOrderId,
235        reason: String,
236        execution_timestamp: UnixTimestampMicros,
237    },
238    /// Trigger order cancelled (active / inactive)
239    CancelTriggerOrder {
240        user_address: Address,
241        trigger_order_id: TriggerOrderId,
242        market_id: MarketId,
243        execution_timestamp: UnixTimestampMicros,
244    },
245    /// Active trigger order rejected while trying to be executed
246    RejectTriggerOrder {
247        user_address: Address,
248        trigger_order_id: TriggerOrderId,
249        reason: String,
250        execution_timestamp: UnixTimestampMicros,
251    },
252    /// Trigger order being executed reactivated
253    ReactivateTriggerOrder {
254        user_address: Address,
255        trigger_order_id: TriggerOrderId,
256        reason: String,
257        execution_timestamp: UnixTimestampMicros,
258    },
259    /// Twap order created
260    CreateTwapOrder {
261        user_address: Address,
262        twap_id: TwapId,
263        market_id: MarketId,
264        total_size: PositiveDecimal,
265        total_duration_seconds: u64,
266        side: Side,
267        reduce_only: bool,
268    },
269    /// Twap order successfully executed
270    SuccessfulExecuteTwapOrder {
271        user_address: Address,
272        twap_id: TwapId,
273        market_id: MarketId,
274        order_price: PositiveDecimal,
275        executed_size: PositiveDecimal,
276        side: Side,
277        order_type: OrderType,
278        execution_timestamp: UnixTimestampMicros,
279    },
280    /// Active twap order rejected while trying to be executed
281    RejectTwapOrder {
282        user_address: Address,
283        twap_id: TwapId,
284        reason: String,
285        execution_timestamp: UnixTimestampMicros,
286    },
287    /// Whole twap order cancelled
288    CancelTwap {
289        user_address: Address,
290        twap_id: TwapId,
291        execution_timestamp: UnixTimestampMicros,
292    },
293
294    /// Premium Index Updated
295    UpdatePremiumIndex {
296        market_id: MarketId,
297        premium_index: Decimal,
298        execution_timestamp: UnixTimestampMicros,
299    },
300    /// Premium Index Update Failed
301    UpdatePremiumIndexFailed {
302        market_id: MarketId,
303        error: String,
304        execution_timestamp: UnixTimestampMicros,
305    },
306    /// Funding Rate Updated
307    UpdateFundingRate {
308        market_id: MarketId,
309        funding_rate: Decimal,
310        execution_timestamp: UnixTimestampMicros,
311    },
312    /// Funding Rate Update Failed
313    UpdateFundingRateFailed {
314        market_id: MarketId,
315        error: String,
316        execution_timestamp: UnixTimestampMicros,
317    },
318    /// Funding Rate Applied
319    ApplyFundingRate {
320        user_address: Address,
321        market_id: MarketId,
322        funding_applied: Decimal,
323        execution_timestamp: UnixTimestampMicros,
324    },
325    /// Funding Rate Application Failed
326    ApplyFundingRateFailed {
327        user_address: Address,
328        error: String,
329        execution_timestamp: UnixTimestampMicros,
330    },
331    /// Oracle Price Updated
332    UpdateOraclePrice {
333        asset_id: AssetId,
334        oracle_price: PositiveDecimal,
335        publish_timestamp: UnixTimestampMicros,
336        execution_timestamp: UnixTimestampMicros,
337    },
338    /// Mark Price Updated
339    UpdateMarkPrice {
340        market_id: MarketId,
341        median_cex_price: PositiveDecimal,
342        diff_ema: Decimal,
343        publish_timestamp: UnixTimestampMicros,
344        execution_timestamp: UnixTimestampMicros,
345    },
346    /// Price Update Failed
347    UpdateOraclePriceFailed {
348        asset_id: AssetId,
349        error: String,
350        execution_timestamp: UnixTimestampMicros,
351    },
352    /// Mark Price Update Failed
353    UpdateMarkPriceFailed {
354        market_id: MarketId,
355        error: String,
356        execution_timestamp: UnixTimestampMicros,
357    },
358    Borrow {
359        user_address: Address,
360        asset_id: AssetId,
361        amount: PositiveDecimal,
362        borrow_type: BorrowType,
363        execution_timestamp: UnixTimestampMicros,
364    },
365    RepayBorrow {
366        user_address: Address,
367        asset_id: AssetId,
368        amount: PositiveDecimal,
369        repay_type: RepayType,
370        execution_timestamp: UnixTimestampMicros,
371    },
372    UsdcUnrealizedLossBorrowRebalance {
373        user_address: Address,
374        cached_unrealized_loss: PositiveDecimal,
375        internal_repayment: PositiveDecimal,
376        execution_timestamp: UnixTimestampMicros,
377    },
378    Withdraw {
379        user_address: Address,
380        asset_id: AssetId,
381        amount: PositiveDecimal,
382        amount_notional: PositiveDecimal,
383        fee: PositiveDecimal,
384        execution_timestamp: UnixTimestampMicros,
385    },
386    Trade {
387        user_address: Address,
388        market_id: MarketId,
389        price: PositiveDecimal,
390        size: PositiveDecimal,
391        side: Side,
392        order_id: OrderId,
393        is_maker: bool,
394        is_full_fill: bool,
395        realized_pnl: Decimal,
396        fee: Decimal,
397        net_fee: PositiveDecimal, /* Taker fee netted against maker rebate. For perps this is
398                                   * USDC, for spot it is in the maker's collateral asset */
399        trade_id: TradeId,
400        is_liquidation: bool,
401        client_order_id: Option<ClientOrderId>,
402        execution_timestamp: UnixTimestampMicros,
403        fee_asset: AssetId,
404    },
405    ForceSettlePerpPosition {
406        user_address: Address,
407        market_id: MarketId,
408        price: PositiveDecimal,
409        size: PositiveDecimal,
410        side: Side,
411        realized_pnl: Decimal,
412        execution_timestamp: UnixTimestampMicros,
413    },
414    CleanupUserMarketState {
415        user_address: Address,
416        market_id: MarketId,
417        execution_timestamp: UnixTimestampMicros,
418    },
419    LiquidateBorrowLendLiability {
420        liquidatee_address: Address,
421        liquidator_address: Address,
422        liability_asset_id: AssetId,
423        collateral_asset_id: AssetId,
424        liability_oracle_price: PositiveDecimal,
425        liability_size: PositiveDecimal,
426        collateral_size: PositiveDecimal,
427        liquidator_reward: PositiveDecimal,
428        protocol_reward: PositiveDecimal,
429        execution_timestamp: UnixTimestampMicros,
430    },
431    BackstopLiquidatePerpPosition {
432        liquidatee_address: Address,
433        liquidator_address: Address,
434        market_id: MarketId,
435        mark_price: PositiveDecimal,
436        size: PositiveDecimal,
437        side: Side,
438        realized_pnl: Decimal,
439        liquidator_reward: PositiveDecimal,
440        protocol_reward: PositiveDecimal,
441        execution_timestamp: UnixTimestampMicros,
442    },
443    BackstopLiquidatePerp {
444        liquidatee_address: Address,
445        liquidator_address: Address,
446        liquidator_reward: PositiveDecimal,
447        protocol_reward: PositiveDecimal,
448        liquidation_loss: Decimal,
449        execution_timestamp: UnixTimestampMicros,
450    },
451    AutoDeleverage {
452        user: Address,
453        counterparty: Address,
454        market_id: MarketId,
455        fill_price: PositiveDecimal,
456        size: PositiveDecimal,
457        user_realized_pnl: Decimal,
458        counterparty_realized_pnl: Decimal,
459        execution_timestamp: UnixTimestampMicros,
460    },
461    UpdateReduceOnlyLimitOrder {
462        user_address: Address,
463        order_id: OrderId,
464        market_id: MarketId,
465        previous_size: PositiveDecimal,
466        new_size: PositiveDecimal,
467        execution_timestamp: UnixTimestampMicros,
468    },
469    BootOrder {
470        user_address: Address,
471        order_id: OrderId,
472        market_id: MarketId,
473        execution_timestamp: UnixTimestampMicros,
474    },
475    AccrueInterestOnBorrowLend {
476        asset_id: AssetId,
477        utilization_rate: PositiveDecimal,
478        time_elapsed: u64,
479        borrow_rate: PositiveDecimal,
480        prev_cumulative_borrow_rate: PositiveDecimal,
481        new_cumulative_borrow_rate: PositiveDecimal,
482        prev_cumulative_deposit_rate: PositiveDecimal,
483        new_cumulative_deposit_rate: PositiveDecimal,
484        new_debt: PositiveDecimal,
485        protocol_reward: PositiveDecimal,
486        execution_timestamp: UnixTimestampMicros,
487    },
488    InitializeSpotMarket {
489        market_id: MarketId,
490        execution_timestamp: UnixTimestampMicros,
491    },
492    /// Deposit
493    DepositVault {
494        vault_address: Address,
495        user_address: Address,
496        asset_id: AssetId,
497        amount: PositiveDecimal,
498        amount_notional: PositiveDecimal,
499        shares: PositiveDecimal,
500        execution_timestamp: UnixTimestampMicros,
501    },
502    /// Withdraw
503    QueueWithdrawVault {
504        vault_address: Address,
505        user_address: Address,
506        shares: PositiveDecimal,
507        execution_timestamp: UnixTimestampMicros,
508    },
509    /// Withdraw
510    ProcessWithdrawVault {
511        vault_address: Address,
512        user_address: Address,
513        shares: PositiveDecimal,
514        amount: PositiveDecimal,
515        asset_id: AssetId,
516        execution_timestamp: UnixTimestampMicros,
517    },
518    CollectVaultFees {
519        vault_address: Address,
520        high_watermark: PositiveDecimal,
521        shares_minted_to_leader: PositiveDecimal,
522        execution_timestamp: UnixTimestampMicros,
523    },
524    DepositSpotCollateral {
525        user_address: Address,
526        asset_id: AssetId,
527        amount: PositiveDecimal,
528        execution_timestamp: UnixTimestampMicros,
529    },
530    // deprecated - can't be removed since used in old slots and discriminators have to stay
531    // constant
532    WithdrawSpotCollateral {
533        user_address: Address,
534        asset_id: AssetId,
535        amount: PositiveDecimal,
536        execution_timestamp: UnixTimestampMicros,
537    },
538    HaltPerpMarket {
539        market_id: MarketId,
540        settlement_price: PositiveDecimal,
541        execution_timestamp: UnixTimestampMicros,
542    },
543    HaltSpotMarket {
544        market_id: MarketId,
545        execution_timestamp: UnixTimestampMicros,
546    },
547    UnhaltPerpMarket {
548        market_id: MarketId,
549        execution_timestamp: UnixTimestampMicros,
550    },
551    UnhaltSpotMarket {
552        market_id: MarketId,
553        execution_timestamp: UnixTimestampMicros,
554    },
555    HaltBorrowLendPool {
556        asset_id: AssetId,
557        execution_timestamp: UnixTimestampMicros,
558    },
559    UnhaltBorrowLendPool {
560        asset_id: AssetId,
561        execution_timestamp: UnixTimestampMicros,
562    },
563    AdminAddTradingCredits {
564        user_address: Address,
565        amount: PositiveDecimal,
566        execution_timestamp: UnixTimestampMicros,
567    },
568    AdminRemoveTradingCredits {
569        user_address: Address,
570        amount: PositiveDecimal,
571        execution_timestamp: UnixTimestampMicros,
572    },
573    UseTradingCredits {
574        user_address: Address,
575        amount: PositiveDecimal,
576        execution_timestamp: UnixTimestampMicros,
577    },
578    ClaimReferralRewards {
579        address: Address,
580        amount_claimed: PositiveDecimal,
581        total_rewards: PositiveDecimal,
582    },
583    UpdateUserFeeTier {
584        user_address: Address,
585        fee_tier: FeeTier,
586        execution_timestamp: UnixTimestampMicros,
587    },
588    UpdateUserFeeDiscountBps {
589        user_address: Address,
590        fee_discount_bps: u16,
591        execution_timestamp: UnixTimestampMicros,
592    },
593    WithdrawSpotCollateralV2 {
594        user_address: Address,
595        asset_id: AssetId,
596        amount: PositiveDecimal,
597        execution_timestamp: UnixTimestampMicros,
598        fee: PositiveDecimal,
599    },
600    /// Asset is deleted.
601    DeleteAsset {
602        asset_id: AssetId,
603        execution_timestamp: UnixTimestampMicros,
604    },
605    /// Trigger Orders are pending and should be executed.
606    PendingTriggerOrders {
607        market_id: MarketId,
608        execution_timestamp: UnixTimestampMicros,
609    },
610    DelegateUser {
611        delegator: Address,
612        delegate: Address,
613        name: String,
614        execution_timestamp: UnixTimestampMicros,
615    },
616    RevokeDelegation {
617        delegator: Address,
618        delegate: Address,
619        execution_timestamp: UnixTimestampMicros,
620    },
621    AdminRevokeDelegation {
622        delegator: Address,
623        delegate: Address,
624        execution_timestamp: UnixTimestampMicros,
625    },
626    AdminDeleteDelegateConfig {
627        delegator: Address,
628        delegate: Address,
629        name: String,
630        execution_timestamp: UnixTimestampMicros,
631    },
632    DepositIso {
633        user_address: Address,
634        market_id: MarketId,
635        amount: PositiveDecimal,
636        execution_timestamp: UnixTimestampMicros,
637    },
638    WithdrawIso {
639        user_address: Address,
640        market_id: MarketId,
641        amount: PositiveDecimal,
642        fee: PositiveDecimal,
643        execution_timestamp: UnixTimestampMicros,
644    },
645    TakeFromInsuranceFund {
646        reason: TakeFromInsuranceFundReason,
647        amount: PositiveDecimal,
648        execution_timestamp: UnixTimestampMicros,
649    },
650    DelegateUserV1 {
651        delegator: Address,
652        delegate: Address,
653        name: String,
654        expires_at: Option<UnixTimestampMicros>,
655        flags: u32,
656        execution_timestamp: UnixTimestampMicros,
657    },
658    // supersedes Trade; adds cumulative order progress (filled_size, filled_cot, remaining_size)
659    TradeV1 {
660        user_address: Address,
661        market_id: MarketId,
662        price: PositiveDecimal,
663        size: PositiveDecimal,
664        side: Side,
665        order_id: OrderId,
666        is_maker: bool,
667        is_full_fill: bool,
668        realized_pnl: Decimal,
669        fee: Decimal,
670        net_fee: PositiveDecimal,
671        trade_id: TradeId,
672        client_order_id: Option<ClientOrderId>,
673        execution_timestamp: UnixTimestampMicros,
674        fee_asset: AssetId,
675        fill_type: FillType,
676        // None for OTC fills (backstop liquidation, ADL): these originate from a position,
677        // not an order, so per-order cumulative progress is undefined. Some(_) for all
678        // matching-engine fills.
679        cumulative_filled_size: Option<PositiveDecimal>,
680        cumulative_filled_cot: Option<PositiveDecimal>,
681        // None for OTC fills
682        remaining_size: Option<PositiveDecimal>,
683    },
684    InitializeAssetInfo {
685        asset_id: AssetId,
686        name: String,
687        execution_timestamp: UnixTimestampMicros,
688    },
689    InitializePerpMarketV1 {
690        market_id: MarketId,
691        name: String,
692        base_asset_id: AssetId,
693        execution_timestamp: UnixTimestampMicros,
694    },
695    InitializeSpotMarketV1 {
696        market_id: MarketId,
697        name: String,
698        base_asset_id: AssetId,
699        quote_asset_id: AssetId,
700        execution_timestamp: UnixTimestampMicros,
701    },
702    /// supersedes CancelOrder; adds reason
703    CancelOrderV1 {
704        user_address: Address,
705        order_id: OrderId,
706        market_id: MarketId,
707        execution_timestamp: UnixTimestampMicros,
708        client_order_id: Option<ClientOrderId>,
709        reason: CancelReason,
710    },
711    /// supersedes CancelTriggerOrder; adds reason
712    CancelTriggerOrderV1 {
713        user_address: Address,
714        trigger_order_id: TriggerOrderId,
715        market_id: MarketId,
716        execution_timestamp: UnixTimestampMicros,
717        reason: CancelReason,
718    },
719    /// supersedes CancelTwap; adds reason
720    CancelTwapV1 {
721        user_address: Address,
722        twap_id: TwapId,
723        market_id: MarketId,
724        execution_timestamp: UnixTimestampMicros,
725        reason: CancelReason,
726    },
727}
728
729impl<Address> Event<Address> {
730    pub fn event_key(&self) -> &'static str {
731        match self {
732            Self::AccrueInterestOnBorrowLend { .. } => "Exchange/AccrueInterestOnBorrowLend",
733            Self::ActivateTriggerOrder { .. } => "Exchange/ActivateTriggerOrder",
734            Self::AdminAddTradingCredits { .. } => "Exchange/AdminAddTradingCredits",
735            Self::AdminRemoveTradingCredits { .. } => "Exchange/AdminRemoveTradingCredits",
736            Self::ApplyFundingRate { .. } => "Exchange/ApplyFundingRate",
737            Self::ApplyFundingRateFailed { .. } => "Exchange/ApplyFundingRateFailed",
738            Self::AutoDeleverage { .. } => "Exchange/AutoDeleverage",
739            Self::BackstopLiquidatePerp { .. } => "Exchange/BackstopLiquidatePerp",
740            Self::BackstopLiquidatePerpPosition { .. } => "Exchange/BackstopLiquidatePerpPosition",
741            Self::BootOrder { .. } => "Exchange/BootOrder",
742            Self::Borrow { .. } => "Exchange/Borrow",
743            Self::CancelOrder { .. } => "Exchange/CancelOrder",
744            Self::CancelTriggerOrder { .. } => "Exchange/CancelTriggerOrder",
745            Self::CancelTwap { .. } => "Exchange/CancelTwap",
746            Self::ClaimReferralRewards { .. } => "Exchange/ClaimReferralRewards",
747            Self::CleanupUserMarketState { .. } => "Exchange/CleanupUserMarketState",
748            Self::CollectVaultFees { .. } => "Exchange/CollectVaultFees",
749            Self::CreateTriggerOrder { .. } => "Exchange/CreateTriggerOrder",
750            Self::CreateTwapOrder { .. } => "Exchange/CreateTwapOrder",
751            Self::DeleteMarket { .. } => "Exchange/DeleteMarket",
752            Self::DeleteAsset { .. } => "Exchange/DeleteAsset",
753            Self::Deposit { .. } => "Exchange/Deposit",
754            Self::DepositSpotCollateral { .. } => "Exchange/DepositSpotCollateral",
755            Self::DepositVault { .. } => "Exchange/DepositVault",
756            Self::EditTriggerOrder { .. } => "Exchange/EditTriggerOrder",
757            Self::FailureExecuteTriggerOrder { .. } => "Exchange/FailureExecuteTriggerOrder",
758            Self::ForceCancelOrders { .. } => "Exchange/ForceCancelOrders",
759            Self::ForceSettlePerpPosition { .. } => "Exchange/ForceSettlePerpPosition",
760            Self::HaltBorrowLendPool { .. } => "Exchange/HaltBorrowLendPool",
761            Self::HaltPerpMarket { .. } => "Exchange/HaltPerpMarket",
762            Self::HaltSpotMarket { .. } => "Exchange/HaltSpotMarket",
763            Self::InitializeBorrowLendPool { .. } => "Exchange/InitializeBorrowLendPool",
764            Self::InitializePerpMarket { .. } => "Exchange/InitializePerpMarket",
765            Self::InitializeSpotMarket { .. } => "Exchange/InitializeSpotMarket",
766            Self::LiquidateBorrowLendLiability { .. } => "Exchange/LiquidateBorrowLendLiability",
767            Self::PendingTriggerOrders { .. } => "Exchange/PendingTriggerOrders",
768            Self::PlaceOrder { .. } => "Exchange/PlaceOrder",
769            Self::ProcessWithdrawVault { .. } => "Exchange/ProcessWithdrawVault",
770            Self::QueueWithdrawVault { .. } => "Exchange/QueueWithdrawVault",
771            Self::ReactivateTriggerOrder { .. } => "Exchange/ReactivateTriggerOrder",
772            Self::RejectTriggerOrder { .. } => "Exchange/RejectTriggerOrder",
773            Self::RejectTwapOrder { .. } => "Exchange/RejectTwapOrder",
774            Self::RepayBorrow { .. } => "Exchange/RepayBorrow",
775            Self::SuccessfulExecuteTriggerOrder { .. } => "Exchange/SuccessfulExecuteTriggerOrder",
776            Self::SuccessfulExecuteTwapOrder { .. } => "Exchange/SuccessfulExecuteTwapOrder",
777            Self::Trade { .. } => "Exchange/Trade",
778            Self::TradeV1 { .. } => "Exchange/TradeV1",
779            Self::TryExecuteTriggerOrder { .. } => "Exchange/TryExecuteTriggerOrder",
780            Self::UnhaltBorrowLendPool { .. } => "Exchange/UnhaltBorrowLendPool",
781            Self::UnhaltPerpMarket { .. } => "Exchange/UnhaltPerpMarket",
782            Self::UnhaltSpotMarket { .. } => "Exchange/UnhaltSpotMarket",
783            Self::UpdateBorrowLendPool { .. } => "Exchange/UpdateBorrowLendPool",
784            Self::UpdateFundingRate { .. } => "Exchange/UpdateFundingRate",
785            Self::UpdateFundingRateFailed { .. } => "Exchange/UpdateFundingRateFailed",
786            Self::UpdateMarkPrice { .. } => "Exchange/UpdateMarkPrice",
787            Self::UpdateMarkPriceFailed { .. } => "Exchange/UpdateMarkPriceFailed",
788            Self::UpdateMarket { .. } => "Exchange/UpdateMarket",
789            Self::UpdateOraclePrice { .. } => "Exchange/UpdateOraclePrice",
790            Self::UpdateOraclePriceFailed { .. } => "Exchange/UpdateOraclePriceFailed",
791            Self::UpdatePremiumIndex { .. } => "Exchange/UpdatePremiumIndex",
792            Self::UpdatePremiumIndexFailed { .. } => "Exchange/UpdatePremiumIndexFailed",
793            Self::UpdateReduceOnlyLimitOrder { .. } => "Exchange/UpdateReduceOnlyLimitOrder",
794            Self::UpdateUserFeeDiscountBps { .. } => "Exchange/UpdateUserFeeDiscountBps",
795            Self::UpdateUserFeeTier { .. } => "Exchange/UpdateUserFeeTier",
796            Self::UsdcUnrealizedLossBorrowRebalance { .. } => {
797                "Exchange/UsdcUnrealizedLossBorrowRebalance"
798            }
799            Self::UseTradingCredits { .. } => "Exchange/UseTradingCredits",
800            Self::Withdraw { .. } => "Exchange/Withdraw",
801            Self::WithdrawSpotCollateral { .. } => "Exchange/WithdrawSpotCollateral",
802            Self::WithdrawSpotCollateralV2 { .. } => "Exchange/WithdrawSpotCollateralV2",
803            Self::DelegateUser { .. } => "Exchange/DelegateUser",
804            Self::RevokeDelegation { .. } => "Exchange/RevokeDelegation",
805            Self::AdminRevokeDelegation { .. } => "Exchange/AdminRevokeDelegation",
806            Self::AdminDeleteDelegateConfig { .. } => "Exchange/AdminDeleteDelegateConfig",
807            Self::DepositIso { .. } => "Exchange/DepositIso",
808            Self::WithdrawIso { .. } => "Exchange/WithdrawIso",
809            Self::TakeFromInsuranceFund { .. } => "Exchange/TakeFromInsuranceFund",
810            Self::DelegateUserV1 { .. } => "Exchange/DelegateUserV1",
811            Self::InitializeAssetInfo { .. } => "Exchange/InitializeAssetInfo",
812            Self::InitializePerpMarketV1 { .. } => "Exchange/InitializePerpMarketV1",
813            Self::InitializeSpotMarketV1 { .. } => "Exchange/InitializeSpotMarketV1",
814            Self::CancelOrderV1 { .. } => "Exchange/CancelOrderV1",
815            Self::CancelTriggerOrderV1 { .. } => "Exchange/CancelTriggerOrderV1",
816            Self::CancelTwapV1 { .. } => "Exchange/CancelTwapV1",
817        }
818    }
819}
820
821crate::define_simple_enum!(OrderSource { Admin, Liquidate, User, Trigger, Twap });