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    pub start_time_seconds: u64,
13    pub duration_seconds: u64,
14    /// HYPE.
15    pub start_gas: Dec,
16    /// What a slot costs now, in HYPE; `null` once the round has ended.
17    #[serde(default)]
18    pub current_gas: Option<Dec>,
19    /// What the slot sold at, once it sold.
20    #[serde(default)]
21    pub end_gas: Option<Dec>,
22}
23
24impl GasAuction {
25    /// When it ends, Unix seconds.
26    #[must_use]
27    pub const fn ends_at(&self) -> u64 {
28        self.start_time_seconds.saturating_add(self.duration_seconds)
29    }
30
31    /// Whether it runs at `now_seconds`: from its start, until its end.
32    #[must_use]
33    pub const fn is_running(&self, now_seconds: u64) -> bool {
34        now_seconds >= self.start_time_seconds && now_seconds < self.ends_at()
35    }
36}
37
38#[cfg(test)]
39#[path = "tests/auction.rs"]
40mod tests;