Skip to main content

bullet_exchange_interface/message/admin/
mod.rs

1//! Protocol admin operations.
2
3use crate::decimals::PositiveDecimal;
4use crate::define_enum;
5use crate::message::CreateVaultArgs;
6use crate::types::{AdminType, AssetId, MarketId, OrderId, TriggerOrderId};
7
8mod args;
9pub use args::*;
10
11define_enum! {
12    /// Protocol admin operations.
13    ///
14    /// These operations require Protocol admin authorization and are used for
15    /// protocol-level configuration, market management, and emergency actions.
16    enum AdminAction<Address> {
17        // =========================================================================
18        // Market Operations (0-19)
19        // =========================================================================
20        /// Initialize a new perp market.
21        InitPerpMarket { args: InitPerpMarketArgs } = 0,
22
23        /// Update perp market configuration.
24        UpdatePerpMarket { args: UpdatePerpMarketArgs } = 1,
25
26        /// Initialize a new spot market.
27        InitSpotMarket { args: InitSpotMarketArgs } = 2,
28
29        /// Update spot market configuration.
30        UpdateSpotMarket { args: UpdateSpotMarketArgs } = 3,
31
32        /// Halt a perp market with settlement price.
33        HaltPerpMarket {
34            market_id: MarketId,
35            settlement_price: PositiveDecimal,
36        } = 4,
37
38        /// Unhalt a perp market.
39        UnhaltPerpMarket { market_id: MarketId } = 5,
40
41        /// Halt a spot market.
42        HaltSpotMarket { market_id: MarketId } = 6,
43
44        /// Unhalt a spot market.
45        UnhaltSpotMarket { market_id: MarketId } = 7,
46
47        /// Prune market data.
48        PruneMarket { market_id: MarketId } = 8,
49
50        /// Delete a market.
51        DeleteMarket { market_id: MarketId } = 9,
52
53        /// Cleanup user market state.
54        CleanupUserMarketState {
55            market_id: MarketId,
56            users: Vec<Address>,
57        } = 10,
58
59        /// Update perp market leverage table.
60        UpdatePerpLeverageTable {
61            market_id: MarketId,
62            args: SurrogateLeverageTableArgs,
63        } = 11,
64
65        /// Delete an asset.
66        DeleteAsset { asset_id: AssetId } = 12,
67
68        // Reserved: 13-19
69
70        // =========================================================================
71        // Asset Operations (20-29)
72        // =========================================================================
73        /// Initialize asset info.
74        InitAssetInfo { args: InitAssetInfoArgs } = 20,
75
76        /// Update asset info.
77        UpdateAssetInfo { args: UpdateAssetInfoArgs } = 21,
78        // Reserved: 22-29
79
80        // =========================================================================
81        // Borrow/Lend Operations (30-39)
82        // =========================================================================
83        /// Initialize a borrow/lend pool.
84        InitBorrowLendPool { args: InitBorrowLendPoolArgs } = 30,
85
86        /// Update borrow/lend pool configuration.
87        UpdateBorrowLendPool { args: UpdateBorrowLendPoolArgs } = 31,
88
89        /// Halt a borrow/lend pool.
90        HaltBorrowLendPool { asset_id: AssetId } = 32,
91
92        /// Unhalt a borrow/lend pool.
93        UnhaltBorrowLendPool { asset_id: AssetId } = 33,
94        // Reserved: 34-39
95
96        // =========================================================================
97        // Configuration Operations (40-49)
98        // =========================================================================
99        /// Update global configuration.
100        UpdateGlobalConfig {
101            args: UpdateGlobalConfigArgs<Address>,
102        } = 40,
103
104        /// Update perp liquidation configuration.
105        UpdatePerpLiquidationConfig {
106            args: UpdatePerpLiquidationConfigArgs,
107        } = 41,
108
109        /// Update global vault configuration.
110        UpdateGlobalVaultConfig { args: UpdateGlobalVaultConfigArgs } = 42,
111
112        /// Update admin addresses.
113        UpdateAdmin {
114            admin_type: AdminType,
115            new_admin: Address,
116        } = 43,
117
118        // Reserved: 44-49
119
120        // =========================================================================
121        // Treasury Operations (50-59)
122        // =========================================================================
123        /// Withdraw from protocol treasury.
124        WithdrawFromTreasury {
125            asset_id: AssetId,
126            amount: PositiveDecimal,
127            to: Address,
128        } = 50,
129        // Reserved: 51-59
130
131        // =========================================================================
132        // Force/Emergency Operations (60-69)
133        // =========================================================================
134        /// Force cancel user orders.
135        CancelOrders {
136            cancels: Vec<(MarketId, OrderId, Address)>,
137        } = 60,
138
139        /// Force cancel user trigger orders.
140        CancelTriggerOrders {
141            cancels: Vec<(MarketId, TriggerOrderId, Address)>,
142        } = 61,
143
144        /// Force settle perp positions.
145        ForceSettlePerpPosition {
146            market_id: MarketId,
147            users: Vec<Address>,
148        } = 62,
149
150        /// Auto-deleverage positions.
151        AutoDeleverage {
152            counterparty_a: Address,
153            counterparty_a_sub_account_index: Option<u8>,
154            counterparty_b: Address,
155            counterparty_b_sub_account_index: Option<u8>,
156            market_id: MarketId,
157            size: Option<PositiveDecimal>,
158            settlement_price: PositiveDecimal,
159        } = 63,
160
161        /// Admin deposit to any user account (creates account if needed).
162        /// Funds come from the admin's wallet.
163        Deposit {
164            user_address: Address,
165            asset_id: AssetId,
166            amount: PositiveDecimal,
167        } = 64,
168
169        ForceRemoveDelegate { delegator: Address, delegate: Address } = 65,
170
171        /// Initialize a new protocol-owned vault.
172        ///
173        /// Behaves identically to a user-created vault but is flagged with
174        /// `AccountVariant::ProtocolVault` so future protocol-specific behavior
175        /// (e.g. governance-only withdrawals, fee exemptions) can branch on it.
176        InitProtocolVault { args: CreateVaultArgs<Address> } = 66,
177        // Reserved: 67-69
178    }
179}