Skip to main content

df_hyperliquid_core/deploy/
auction.rs

1//! The Dutch auction a deploy slot is bought in, the one shape a spot token, a spot pair and a HIP-3 perp past
2//! a dex's first three all answer. Each round is 31 hours; its price is HYPE and is never refunded.
3
4use serde::Deserialize;
5
6use crate::utils::dec::Dec;
7
8/// One round of a deploy auction. Seconds, not milliseconds.
9#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct GasAuction {
12    /// When the round started, Unix seconds.
13    pub start_time_seconds: u64,
14    /// How long the round runs, in seconds.
15    pub duration_seconds: u64,
16    /// The price the round opened at, in HYPE.
17    pub start_gas: Dec,
18    /// What a slot costs now, in HYPE; `null` once the round has ended.
19    #[serde(default)]
20    pub current_gas: Option<Dec>,
21    /// What the slot sold at, once it sold.
22    #[serde(default)]
23    pub end_gas: Option<Dec>,
24}
25
26impl GasAuction {
27    /// When it ends, Unix seconds.
28    #[must_use]
29    pub const fn ends_at(&self) -> u64 {
30        self.start_time_seconds.saturating_add(self.duration_seconds)
31    }
32
33    /// Whether it runs at `now_seconds`: from its start, until its end.
34    #[must_use]
35    pub const fn is_running(&self, now_seconds: u64) -> bool {
36        now_seconds >= self.start_time_seconds && now_seconds < self.ends_at()
37    }
38}
39
40#[cfg(test)]
41#[path = "tests/auction.rs"]
42mod tests;