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 UpdateAssetInfoArgs {
123        asset_id: AssetId,
124        withdraw_fee: PositiveDecimal,
125    }
126}
127
128// =============================================================================
129// Borrow/Lend Pool Args
130// =============================================================================
131
132define_struct! {
133    struct InitBorrowLendPoolArgs {
134        asset_id: AssetId,
135        optimal_utilization_rate: PositiveDecimal,
136        min_borrow_rate: PositiveDecimal,
137        max_borrow_rate: PositiveDecimal,
138        optimal_borrow_rate: PositiveDecimal,
139        asset_weight: PositiveDecimal,
140        initial_liability_weight: PositiveDecimal,
141        maintenance_liability_weight: PositiveDecimal,
142        deposit_limit: PositiveDecimal,
143        borrow_limit: PositiveDecimal,
144        max_utilization_rate: PositiveDecimal,
145        liquidation_total_reward_ratio: PositiveDecimal,
146        protocol_reward_ratio: PositiveDecimal,
147        liability_liquidation_limit_ratio: PositiveDecimal,
148        interest_fee_tenth_bps: u16,
149    }
150}
151
152define_struct! {
153    struct UpdateBorrowLendPoolArgs {
154        asset_id: AssetId,
155        optimal_utilization_rate: Option<PositiveDecimal>,
156        min_borrow_rate: Option<PositiveDecimal>,
157        max_borrow_rate: Option<PositiveDecimal>,
158        optimal_borrow_rate: Option<PositiveDecimal>,
159        asset_weight: Option<PositiveDecimal>,
160        initial_liability_weight: Option<PositiveDecimal>,
161        maintenance_liability_weight: Option<PositiveDecimal>,
162        deposit_limit: Option<PositiveDecimal>,
163        borrow_limit: Option<PositiveDecimal>,
164        max_utilization_rate: Option<PositiveDecimal>,
165        liquidation_total_reward_ratio: Option<PositiveDecimal>,
166        protocol_reward_ratio: Option<PositiveDecimal>,
167        liability_liquidation_limit_ratio: Option<PositiveDecimal>,
168        interest_fee_tenth_bps: Option<u16>,
169    }
170}
171
172// =============================================================================
173// Config Args
174// =============================================================================
175
176define_struct! {
177    struct UpdatePerpLiquidationConfigArgs {
178        liquidation_fee: Option<PositiveDecimal>,
179        liquidation_ioc_buffer: Option<PositiveDecimal>,
180        backstop_liquidation_threshold: Option<PositiveDecimal>,
181        liquidation_protocol_reward_ratio: Option<PositiveDecimal>,
182    }
183}
184
185define_struct! {
186    struct UpdateGlobalConfigArgs<Address> {
187        max_orders_per_user: Option<u16>,
188        max_trigger_orders_per_user: Option<u16>,
189        max_orders_per_batch_msg: Option<u16>,
190        max_trigger_orders_to_execute_per_msg: Option<u16>,
191        min_notional_twap_value: Option<PositiveDecimal>,
192        min_notional_twap_value_per_order: Option<PositiveDecimal>,
193        twap_execution_interval_seconds: Option<u64>,
194        deposit_limits_per_user: Option<Vec<(AssetId, PositiveDecimal)>>,
195        whitelisted_users_for_deposit: Option<Vec<Address>>,
196    }
197}
198
199define_struct! {
200    struct UpdateGlobalVaultConfigArgs {
201        leader_minimum_holding_percentage: Option<u8>,
202        creation_fee_usdc: Option<PositiveDecimal>,
203        min_deposit_value: Option<PositiveDecimal>,
204    }
205}