Skip to main content

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")]
13pub struct OrderUpdate {
14    /// The order as it stands after the change.
15    pub order: OpenOrder,
16    /// The new status, as the venue writes it: `open`, `filled`, `canceled` and so on.
17    pub status: String,
18    /// Milliseconds.
19    pub status_timestamp: u64,
20}
21
22/// `openOrders`: every resting order on one dex, with its trigger and type.
23#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
24pub struct OpenOrders {
25    /// The dex, `""` for the first perp dex.
26    pub dex: String,
27    /// The account the orders belong to.
28    pub user: Address,
29    /// Every resting order on the dex.
30    pub orders: Vec<FrontendOrder>,
31}
32
33/// `userHistoricalOrders`: orders and what became of them, the latest first.
34#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct HistoricalOrders {
37    /// The account the orders belong to.
38    pub user: Address,
39    /// `isSnapshot`: true on the first frame, which carries past orders; false when not sent.
40    #[serde(default)]
41    pub is_snapshot: bool,
42    /// `orderHistory`: the orders in this frame, each with its last status.
43    #[serde(rename = "orderHistory")]
44    pub orders: Vec<OrderRecord>,
45}
46
47#[cfg(test)]
48#[path = "tests/orders.rs"]
49mod tests;