df_hyperliquid_core/deploy/
aligned.rs1use crate::deploy::error::BadDeploy;
6use crate::utils::Dec;
7use crate::utils::sign::{L1Action, Map};
8
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
13pub struct ValidatorL1Stream {
14 risk_free_rate: Dec,
15}
16
17impl ValidatorL1Stream {
18 pub fn new(risk_free_rate: Dec) -> Result<Self, BadDeploy> {
20 if risk_free_rate.is_negative() {
21 return Err(BadDeploy::OutOfRange {
22 what: "a risk-free rate",
23 least: "0",
24 most: "any",
25 value: risk_free_rate.to_wire(),
26 });
27 }
28 Ok(ValidatorL1Stream { risk_free_rate })
29 }
30
31 #[must_use]
33 pub const fn risk_free_rate(self) -> Dec {
34 self.risk_free_rate
35 }
36}
37
38impl L1Action for ValidatorL1Stream {
39 fn action(&self) -> Map {
40 Map::new().put("type", "validatorL1Stream").put("riskFreeRate", self.risk_free_rate.to_wire())
41 }
42}
43
44#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
46#[non_exhaustive]
47pub enum AqaRole {
48 Technical,
50 Treasury,
53}
54
55impl AqaRole {
56 #[must_use]
58 pub const fn wire(self) -> &'static str {
59 match self {
60 AqaRole::Technical => "technical",
61 AqaRole::Treasury => "treasury",
62 }
63 }
64}
65
66#[derive(Debug, Clone, Copy, PartialEq, Eq)]
70pub struct AuthorizeAqav2Role {
71 pub token: u32,
73 pub role: AqaRole,
75}
76
77impl L1Action for AuthorizeAqav2Role {
78 fn action(&self) -> Map {
79 Map::new().put("type", "authorizeAqav2Role").put("token", self.token).put("role", self.role.wire())
80 }
81}
82
83#[cfg(test)]
84#[path = "tests/aligned.rs"]
85mod tests;