1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5#[serde(rename_all = "camelCase")]
6pub struct OrderWire {
7 pub asset: u32,
9 pub is_buy: bool,
11 pub limit_px: String,
13 pub sz: String,
15 pub reduce_only: bool,
17 pub order_type: OrderTypeWire,
19 #[serde(skip_serializing_if = "Option::is_none")]
21 pub cloid: Option<String>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
26pub struct OrderTypeWire {
27 pub limit: Option<LimitOrderType>,
29 pub trigger: Option<TriggerOrderType>,
30}
31
32#[derive(Debug, Clone, Serialize, Deserialize)]
34pub struct LimitOrderType {
35 pub tif: String,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
40#[serde(rename_all = "camelCase")]
41pub struct TriggerOrderType {
42 pub trigger_px: String,
43 pub is_market: bool,
44 pub tpsl: String,
45}
46
47#[derive(Debug, Clone, Serialize, Deserialize)]
49pub struct Signature {
50 pub r: String,
52 pub s: String,
54 pub v: u8,
56}
57
58#[derive(Debug, thiserror::Error)]
60pub enum ExchangeError {
61 #[error("Signing error: {0}")]
62 SigningError(String),
63 #[error("Serialization error: {0}")]
64 SerializationError(String),
65 #[error("HTTP error: {0}")]
66 HttpError(String),
67 #[error("API error: {0}")]
68 ApiError(String),
69 #[error("Invalid address: {0}")]
70 InvalidAddress(String),
71}