drasi_source_hyperliquid/
types.rs1use serde::{Deserialize, Serialize};
18
19#[derive(Debug, Clone, Serialize)]
20pub struct InfoRequest {
21 #[serde(rename = "type")]
22 pub req_type: String,
23}
24
25#[derive(Debug, Clone, Deserialize)]
26#[serde(rename_all = "camelCase")]
27pub struct PerpAsset {
28 pub name: String,
29 pub sz_decimals: u32,
30 pub max_leverage: u32,
31 #[serde(default)]
32 pub is_delisted: Option<bool>,
33}
34
35#[derive(Debug, Clone, Deserialize)]
36pub struct MetaResponse {
37 pub universe: Vec<PerpAsset>,
38}
39
40#[derive(Debug, Clone, Deserialize)]
41#[serde(rename_all = "camelCase")]
42pub struct SpotPair {
43 pub name: String,
44 pub tokens: Vec<u32>,
45 #[serde(default)]
46 pub index: Option<u32>,
47}
48
49#[derive(Debug, Clone, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct SpotToken {
52 pub name: String,
53 pub sz_decimals: u32,
54 pub wei_decimals: u32,
55 pub index: u32,
56 #[serde(default)]
57 pub token_id: Option<String>,
58}
59
60#[derive(Debug, Clone, Deserialize)]
61pub struct SpotMetaResponse {
62 pub universe: Vec<SpotPair>,
63 pub tokens: Vec<SpotToken>,
64}
65
66#[derive(Debug, Clone, Deserialize)]
67#[serde(rename_all = "camelCase")]
68pub struct AssetCtx {
69 pub funding: String,
70 pub open_interest: String,
71 pub prev_day_px: String,
72 pub day_ntl_vlm: String,
73 pub premium: Option<String>,
74 pub oracle_px: String,
75 pub mark_px: String,
76 pub mid_px: Option<String>,
77 pub impact_pxs: Option<Vec<String>>,
78 pub day_base_vlm: String,
79}
80
81#[derive(Debug, Clone, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub struct L2Level {
84 pub px: String,
85 pub sz: String,
86 pub n: u32,
87}
88
89#[derive(Debug, Clone, Deserialize)]
90pub struct L2Book {
91 pub coin: String,
92 pub time: i64,
93 pub levels: Vec<Vec<L2Level>>,
94}
95
96#[derive(Debug, Clone, Deserialize)]
97#[serde(rename_all = "camelCase")]
98pub struct Trade {
99 pub coin: String,
100 pub side: String,
101 pub px: String,
102 pub sz: String,
103 pub time: i64,
104 #[serde(default)]
105 pub hash: Option<String>,
106 pub tid: u64,
107}
108
109#[derive(Debug, Clone, Deserialize)]
110#[serde(rename_all = "camelCase")]
111pub struct Liquidation {
112 pub coin: String,
113 pub side: String,
114 pub px: String,
115 pub sz: String,
116 pub time: i64,
117 #[serde(default)]
118 pub hash: Option<String>,
119}
120
121#[derive(Debug, Clone, Deserialize)]
122pub struct WsMessage {
123 pub channel: String,
124 pub data: serde_json::Value,
125}
126
127#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
128pub struct FundingSnapshot {
129 pub rate: f64,
130 pub premium: f64,
131 pub mark_price: f64,
132 pub open_interest: f64,
133 pub volume_24h: f64,
134 pub timestamp: i64,
135}