df_hyperliquid_core/deploy/perp/
sub.rs1use crate::utils::Address;
5use crate::utils::sign::Map;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10#[non_exhaustive]
11pub enum PerpKind {
12 RegisterAsset2,
14 RegisterAsset,
16 SetOracle,
18 SetFundingMultipliers,
20 SetFundingInterestRates,
22 SetFundingClamps,
24 HaltTrading,
26 InsertMarginTable,
28 SetMarginTableIds,
30 SetFeeRecipient,
32 SetOpenInterestCaps,
34 SetSubDeployers,
36 SetMarginModes,
38 SetDeployerFees,
40 SetPerpAnnotation,
42 DisableDex,
44}
45
46impl PerpKind {
47 pub const ALL: [PerpKind; 16] = [
49 PerpKind::RegisterAsset2,
50 PerpKind::RegisterAsset,
51 PerpKind::SetOracle,
52 PerpKind::SetFundingMultipliers,
53 PerpKind::SetFundingInterestRates,
54 PerpKind::SetFundingClamps,
55 PerpKind::HaltTrading,
56 PerpKind::InsertMarginTable,
57 PerpKind::SetMarginTableIds,
58 PerpKind::SetFeeRecipient,
59 PerpKind::SetOpenInterestCaps,
60 PerpKind::SetSubDeployers,
61 PerpKind::SetMarginModes,
62 PerpKind::SetDeployerFees,
63 PerpKind::SetPerpAnnotation,
64 PerpKind::DisableDex,
65 ];
66
67 #[must_use]
69 pub const fn wire(self) -> &'static str {
70 match self {
71 PerpKind::RegisterAsset2 => "registerAsset2",
72 PerpKind::RegisterAsset => "registerAsset",
73 PerpKind::SetOracle => "setOracle",
74 PerpKind::SetFundingMultipliers => "setFundingMultipliers",
75 PerpKind::SetFundingInterestRates => "setFundingInterestRates",
76 PerpKind::SetFundingClamps => "setFundingClamps",
77 PerpKind::HaltTrading => "haltTrading",
78 PerpKind::InsertMarginTable => "insertMarginTable",
79 PerpKind::SetMarginTableIds => "setMarginTableIds",
80 PerpKind::SetFeeRecipient => "setFeeRecipient",
81 PerpKind::SetOpenInterestCaps => "setOpenInterestCaps",
82 PerpKind::SetSubDeployers => "setSubDeployers",
83 PerpKind::SetMarginModes => "setMarginModes",
84 PerpKind::SetDeployerFees => "setDeployerFees",
85 PerpKind::SetPerpAnnotation => "setPerpAnnotation",
86 PerpKind::DisableDex => "disableDex",
87 }
88 }
89}
90
91#[derive(Debug, Clone, Copy, PartialEq, Eq)]
94pub struct SubDeployer {
95 pub variant: PerpKind,
97 pub user: Address,
99 pub allowed: bool,
101}
102
103impl SubDeployer {
104 #[must_use]
106 pub fn wire(&self) -> Map {
107 Map::new().put("variant", self.variant.wire()).put("user", self.user.to_hex()).put("allowed", self.allowed)
108 }
109}