df_hyperliquid_core/live/account/orders.rs
1//! An account's orders on the socket: the resting ones on one dex, each status change as it
2//! happens, and the order history.
3
4use crate::account::history::OpenOrder;
5use crate::account::{FrontendOrder, OrderRecord};
6use crate::utils::Address;
7use serde::Deserialize;
8
9/// One order's new status on `orderUpdates`: `open`, `filled`, `canceled`, `triggered`,
10/// `rejected`, `marginCanceled`, `badAloPxRejected` and the rest the info docs list.
11#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
12#[serde(rename_all = "camelCase")]
13#[non_exhaustive]
14pub struct OrderUpdate {
15 /// The order as it stands after the change.
16 pub order: OpenOrder,
17 /// The new status, as the venue writes it: `open`, `filled`, `canceled` and so on.
18 pub status: String,
19 /// Milliseconds.
20 pub status_timestamp: u64,
21}
22
23/// `openOrders`: every resting order on one dex, with its trigger and type.
24#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
25#[non_exhaustive]
26pub struct OpenOrders {
27 /// The dex, `""` for the first perp dex.
28 pub dex: String,
29 /// The account the orders belong to.
30 pub user: Address,
31 /// Every resting order on the dex.
32 pub orders: Vec<FrontendOrder>,
33}
34
35/// `userHistoricalOrders`: orders and what became of them, the latest first.
36#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
37#[serde(rename_all = "camelCase")]
38#[non_exhaustive]
39pub struct HistoricalOrders {
40 /// The account the orders belong to.
41 pub user: Address,
42 /// `isSnapshot`: true on the first frame, which carries past orders; false when not sent.
43 #[serde(default)]
44 pub is_snapshot: bool,
45 /// `orderHistory`: the orders in this frame, each with its last status.
46 #[serde(rename = "orderHistory")]
47 pub orders: Vec<OrderRecord>,
48}
49
50#[cfg(test)]
51#[path = "tests/orders.rs"]
52mod tests;