Skip to main content

bullet_exchange_interface/message/admin/
args.rs

1//! Argument types for admin operations.
2
3use std::collections::BTreeMap;
4
5use crate::decimals::{PositiveDecimal, SurrogateDecimal};
6use crate::define_struct;
7use crate::string::CustomString;
8use crate::types::{AssetId, MarketId, TokenId, TradingMode};
9
10// =============================================================================
11// Market Args
12// =============================================================================
13
14define_struct! {
15    struct InitPerpMarketArgs {
16        market_id: MarketId,
17        base_asset_id: AssetId,
18        name: CustomString,
19        trading_mode: TradingMode,
20        min_tick_size: PositiveDecimal,
21        min_lot_size: PositiveDecimal,
22        max_orders_per_side: u16,
23        max_orders_per_user: u16,
24        max_trigger_orders_per_user: u16,
25        min_interest_rate_clamp: SurrogateDecimal,
26        max_interest_rate_clamp: SurrogateDecimal,
27        min_funding_rate_clamp: SurrogateDecimal,
28        max_funding_rate_clamp: SurrogateDecimal,
29        max_oi_notional: PositiveDecimal,
30        max_order_to_mark_price_deviation_ratio: PositiveDecimal,
31        max_trigger_to_comparison_price_deviation_ratio: PositiveDecimal,
32        max_order_to_trigger_price_deviation_ratio: PositiveDecimal,
33        impact_margin: PositiveDecimal,
34        interest_rate: SurrogateDecimal,
35        leverage_table_args: SurrogateLeverageTableArgs,
36        taker_fees_tenth_bps: Vec<i16>,
37        maker_fees_tenth_bps: Vec<i16>,
38    }
39}
40
41define_struct! {
42    struct UpdatePerpMarketArgs {
43        market_id: MarketId,
44        impact_margin: Option<PositiveDecimal>,
45        interest_rate: Option<SurrogateDecimal>,
46        leverage_table_args: Option<SurrogateLeverageTableArgs>,
47        maker_fees_tenth_bps: Option<Vec<i16>>,
48        max_funding_rate_clamp: Option<SurrogateDecimal>,
49        max_interest_rate_clamp: Option<SurrogateDecimal>,
50        max_oi_notional: Option<PositiveDecimal>,
51        max_order_to_mark_price_deviation_ratio: Option<PositiveDecimal>,
52        max_order_to_trigger_price_deviation_ratio: Option<PositiveDecimal>,
53        max_orders_per_side: Option<u16>,
54        max_orders_per_user: Option<u16>,
55        max_trigger_orders_per_user: Option<u16>,
56        max_trigger_to_comparison_price_deviation_ratio: Option<PositiveDecimal>,
57        min_funding_rate_clamp: Option<SurrogateDecimal>,
58        min_interest_rate_clamp: Option<SurrogateDecimal>,
59        min_lot_size: Option<PositiveDecimal>,
60        min_tick_size: Option<PositiveDecimal>,
61        taker_fees_tenth_bps: Option<Vec<i16>>,
62    }
63}
64
65define_struct! {
66    struct InitSpotMarketArgs {
67        market_id: MarketId,
68        base_asset_id: AssetId,
69        quote_asset_id: AssetId,
70        base_min_lot_size: PositiveDecimal,
71        quote_min_lot_size: PositiveDecimal,
72        max_orders_per_side: u16,
73        max_orders_per_user: u16,
74        max_trigger_orders_per_user: u16,
75        taker_fees_tenth_bps: Vec<i16>,
76        maker_fees_tenth_bps: Vec<i16>,
77        max_order_to_trigger_price_deviation_ratio: PositiveDecimal,
78        name: CustomString,
79    }
80}
81
82define_struct! {
83    struct UpdateSpotMarketArgs {
84        market_id: MarketId,
85        base_min_lot_size: Option<PositiveDecimal>,
86        quote_min_lot_size: Option<PositiveDecimal>,
87        max_orders_per_side: Option<u16>,
88        max_orders_per_user: Option<u16>,
89        max_trigger_orders_per_user: Option<u16>,
90        taker_fees_tenth_bps: Option<Vec<i16>>,
91        maker_fees_tenth_bps: Option<Vec<i16>>,
92        max_order_to_trigger_price_deviation_ratio: Option<PositiveDecimal>,
93    }
94}
95
96define_struct! {
97    struct LeverageTableArgs {
98        table: BTreeMap<PositiveDecimal, u16>,
99    }
100}
101
102define_struct! {
103    struct SurrogateLeverageTableArgs {
104        table: BTreeMap<CustomString, u16>,
105    }
106}
107// =============================================================================
108// Asset Args
109// =============================================================================
110
111define_struct! {
112    struct InitAssetInfoArgs {
113        asset_id: AssetId,
114        asset_name: CustomString,
115        token_id: Option<TokenId>,
116        decimals: u8,
117        withdraw_fee: PositiveDecimal,
118    }
119}
120
121define_struct! {
122    struct InitAssetInfoArgsV1 {
123        asset_id: AssetId,
124        asset_name: CustomString,
125        token_id: Option<TokenId>,
126        decimals: u8,
127        withdraw_fee: PositiveDecimal,
128        pyth_lazer_feed_id: Option<u32>,
129        pyth_lazer_quote_feed_id: Option<u32>,
130    }
131}
132
133define_struct! {
134    struct UpdateAssetInfoArgs {
135        asset_id: AssetId,
136        withdraw_fee: PositiveDecimal,
137    }
138}
139
140define_struct! {
141    struct UpdateAssetInfoArgsV1 {
142        asset_id: AssetId,
143        withdraw_fee: PositiveDecimal,
144        pyth_lazer_feed_id: Option<u32>,
145        pyth_lazer_quote_feed_id: Option<u32>,
146    }
147}
148
149// =============================================================================
150// Borrow/Lend Pool Args
151// =============================================================================
152
153define_struct! {
154    struct InitBorrowLendPoolArgs {
155        asset_id: AssetId,
156        optimal_utilization_rate: PositiveDecimal,
157        min_borrow_rate: PositiveDecimal,
158        max_borrow_rate: PositiveDecimal,
159        optimal_borrow_rate: PositiveDecimal,
160        asset_weight: PositiveDecimal,
161        initial_liability_weight: PositiveDecimal,
162        maintenance_liability_weight: PositiveDecimal,
163        deposit_limit: PositiveDecimal,
164        borrow_limit: PositiveDecimal,
165        max_utilization_rate: PositiveDecimal,
166        liquidation_total_reward_ratio: PositiveDecimal,
167        protocol_reward_ratio: PositiveDecimal,
168        liability_liquidation_limit_ratio: PositiveDecimal,
169        interest_fee_tenth_bps: u16,
170    }
171}
172
173define_struct! {
174    struct UpdateBorrowLendPoolArgs {
175        asset_id: AssetId,
176        optimal_utilization_rate: Option<PositiveDecimal>,
177        min_borrow_rate: Option<PositiveDecimal>,
178        max_borrow_rate: Option<PositiveDecimal>,
179        optimal_borrow_rate: Option<PositiveDecimal>,
180        asset_weight: Option<PositiveDecimal>,
181        initial_liability_weight: Option<PositiveDecimal>,
182        maintenance_liability_weight: Option<PositiveDecimal>,
183        deposit_limit: Option<PositiveDecimal>,
184        borrow_limit: Option<PositiveDecimal>,
185        max_utilization_rate: Option<PositiveDecimal>,
186        liquidation_total_reward_ratio: Option<PositiveDecimal>,
187        protocol_reward_ratio: Option<PositiveDecimal>,
188        liability_liquidation_limit_ratio: Option<PositiveDecimal>,
189        interest_fee_tenth_bps: Option<u16>,
190    }
191}
192
193// =============================================================================
194// Config Args
195// =============================================================================
196
197define_struct! {
198    struct UpdatePerpLiquidationConfigArgs {
199        liquidation_fee: Option<PositiveDecimal>,
200        liquidation_ioc_buffer: Option<PositiveDecimal>,
201        backstop_liquidation_threshold: Option<PositiveDecimal>,
202        liquidation_protocol_reward_ratio: Option<PositiveDecimal>,
203    }
204}
205
206define_struct! {
207    struct UpdateGlobalConfigArgs<Address> {
208        max_orders_per_user: Option<u16>,
209        max_trigger_orders_per_user: Option<u16>,
210        max_orders_per_batch_msg: Option<u16>,
211        max_trigger_orders_to_execute_per_msg: Option<u16>,
212        min_notional_twap_value: Option<PositiveDecimal>,
213        min_notional_twap_value_per_order: Option<PositiveDecimal>,
214        twap_execution_interval_seconds: Option<u64>,
215        deposit_limits_per_user: Option<Vec<(AssetId, PositiveDecimal)>>,
216        whitelisted_users_for_deposit: Option<Vec<Address>>,
217    }
218}
219
220define_struct! {
221    struct UpdateGlobalConfigArgsV1<Address> {
222        max_orders_per_user: Option<u16>,
223        max_trigger_orders_per_user: Option<u16>,
224        max_orders_per_batch_msg: Option<u16>,
225        max_trigger_orders_to_execute_per_msg: Option<u16>,
226        min_notional_twap_value: Option<PositiveDecimal>,
227        min_notional_twap_value_per_order: Option<PositiveDecimal>,
228        twap_execution_interval_seconds: Option<u64>,
229        deposit_limits_per_user: Option<Vec<(AssetId, PositiveDecimal)>>,
230        whitelisted_users_for_deposit: Option<Vec<Address>>,
231        pyth_lazer_trusted_signers: Option<Vec<[u8; 32]>>,
232    }
233}
234
235define_struct! {
236    struct UpdateGlobalVaultConfigArgs {
237        leader_minimum_holding_percentage: Option<u8>,
238        creation_fee_usdc: Option<PositiveDecimal>,
239        min_deposit_value: Option<PositiveDecimal>,
240    }
241}