Skip to main content

hypercall_sdk_types/
requests.rs

1//! API request types.
2
3use crate::{Side, TimeInForce, WalletAddress};
4use serde::{Deserialize, Serialize};
5
6/// Request body for placing an order.
7#[derive(Debug, Clone, Serialize, Deserialize)]
8#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
9pub struct PlaceOrderRequest {
10    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
11    pub wallet: WalletAddress,
12    /// Price as string (must match signed value exactly)
13    pub price: String,
14    /// Size as string (must match signed value exactly)
15    pub size: String,
16    pub symbol: String,
17    pub side: Side,
18    #[serde(default)]
19    pub tif: TimeInForce,
20    pub client_id: Option<String>,
21    pub nonce: u64,
22    pub signature: String,
23    #[serde(default)]
24    pub mmp_enabled: bool,
25    /// Optional builder code address for fee rebates
26    #[serde(skip_serializing_if = "Option::is_none")]
27    #[cfg_attr(feature = "utoipa", schema(value_type = Option<String>))]
28    pub builder_code_address: Option<WalletAddress>,
29}
30
31/// Request to cancel an order.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
34pub struct CancelOrderRequest {
35    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
36    pub wallet: WalletAddress,
37    pub order_id: u64,
38    pub nonce: u64,
39    pub signature: String,
40}
41
42/// Request to cancel an order by client ID.
43#[derive(Debug, Clone, Serialize, Deserialize)]
44#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
45pub struct CancelOrderByClientIdRequest {
46    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
47    pub wallet: WalletAddress,
48    pub client_id: String,
49    pub nonce: u64,
50    pub signature: String,
51}
52
53/// Request to cancel an order by client ID through the public cloid endpoint.
54#[derive(Debug, Clone, Serialize, Deserialize)]
55#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
56pub struct CancelOrderByCloidRequest {
57    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
58    pub wallet: WalletAddress,
59    pub client_id: String,
60    pub nonce: u64,
61    pub signature: String,
62}
63
64/// Request to set margin mode.
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
67pub struct SetMarginModeRequest {
68    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
69    pub wallet: WalletAddress,
70    pub margin_mode: String,
71    pub nonce: u64,
72    pub signature: String,
73}
74
75/// Bulk order placement request.
76#[derive(Debug, Clone, Serialize, Deserialize)]
77#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
78pub struct BulkPlaceOrderRequest {
79    pub orders: Vec<PlaceOrderRequest>,
80}
81
82/// Bulk cancel request.
83#[derive(Debug, Clone, Serialize, Deserialize)]
84#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
85pub struct BulkCancelOrderRequest {
86    pub cancels: Vec<CancelOrderRequest>,
87}
88
89/// Request to approve an agent wallet.
90#[derive(Debug, Clone, Serialize, Deserialize)]
91#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
92pub struct ApproveAgentRequest {
93    /// Agent wallet address to authorize
94    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
95    pub agent: WalletAddress,
96    /// Nonce for replay protection
97    pub nonce: u64,
98    /// EIP-712 signature from wallet owner
99    pub signature: String,
100}
101
102/// Request to revoke an agent wallet.
103#[derive(Debug, Clone, Serialize, Deserialize)]
104#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
105pub struct RevokeAgentRequest {
106    /// Agent wallet address to revoke
107    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
108    pub agent: WalletAddress,
109    /// Nonce for replay protection
110    pub nonce: u64,
111    /// EIP-712 signature from wallet owner
112    pub signature: String,
113}
114
115/// Request to atomically cancel an existing order and place a new one.
116#[derive(Debug, Clone, Serialize, Deserialize)]
117#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
118pub struct ReplaceOrderRequest {
119    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
120    pub wallet: WalletAddress,
121    /// ID of the order to cancel
122    pub order_id: u64,
123    /// New order price as string (must match signed value exactly)
124    pub price: String,
125    /// New order size as string (must match signed value exactly)
126    pub size: String,
127    /// New order symbol
128    pub symbol: String,
129    /// New order side
130    pub side: Side,
131    /// New order time-in-force
132    #[serde(default)]
133    pub tif: TimeInForce,
134    /// Optional client-provided order ID for the new order
135    pub client_id: Option<String>,
136    pub nonce: u64,
137    pub signature: String,
138    #[serde(default)]
139    pub mmp_enabled: bool,
140    /// Optional builder code address for fee rebates
141    #[serde(skip_serializing_if = "Option::is_none")]
142    #[cfg_attr(feature = "utoipa", schema(value_type = Option<String>))]
143    pub builder_code_address: Option<WalletAddress>,
144}
145
146/// Faucet request (testnet only).
147#[derive(Debug, Clone, Serialize, Deserialize)]
148#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
149pub struct FaucetRequest {
150    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
151    pub wallet: WalletAddress,
152    pub amount: f64,
153}
154
155// RFQ Requests
156
157/// A single leg in an RFQ request.
158#[derive(Debug, Clone, Serialize, Deserialize)]
159#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
160pub struct RfqLegRequest {
161    pub instrument: String,
162    pub side: Side,
163    pub size: String,
164}
165
166/// Request to submit an RFQ.
167#[derive(Debug, Clone, Serialize, Deserialize)]
168#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
169pub struct SubmitRfqRequest {
170    pub rfq_id: String,
171    pub legs: Vec<RfqLegRequest>,
172    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
173    pub wallet_address: WalletAddress,
174    pub nonce: u64,
175    pub signature: String,
176    /// When set, the RFQ auto-executes the first quote satisfying the taker's
177    /// directional limit. Buy RFQs use this as a max debit. Sell RFQs use it
178    /// as a min credit. The taker must sign the `SubmitAutoExecuteRfq`
179    /// EIP-712 type instead of `SubmitRFQ`.
180    #[serde(default, skip_serializing_if = "Option::is_none")]
181    pub auto_accept_limit: Option<String>,
182}
183
184/// Request to accept an RFQ quote.
185#[derive(Debug, Clone, Serialize, Deserialize)]
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187pub struct AcceptRfqRequest {
188    pub rfq_id: String,
189    pub quote_id: String,
190    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
191    pub wallet_address: WalletAddress,
192    pub nonce: u64,
193    pub signature: String,
194}
195
196/// Admin request to register or update a quote provider.
197#[derive(Debug, Clone, Serialize, Deserialize)]
198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
199pub struct RegisterQuoteProviderRequest {
200    #[cfg_attr(feature = "utoipa", schema(value_type = String))]
201    pub wallet_address: WalletAddress,
202    pub tier: String,
203    pub allowed_underlyings: Option<Vec<String>>,
204    pub max_notional_per_quote: String,
205    pub max_open_notional: String,
206}