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