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