df_hyperliquid_core/deploy/perp/
sub.rs1use crate::utils::Address;
5use crate::utils::sign::Map;
6
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
10pub enum PerpKind {
11 RegisterAsset2,
13 RegisterAsset,
15 SetOracle,
17 SetFundingMultipliers,
19 SetFundingInterestRates,
21 SetFundingClamps,
23 HaltTrading,
25 InsertMarginTable,
27 SetMarginTableIds,
29 SetFeeRecipient,
31 SetOpenInterestCaps,
33 SetSubDeployers,
35 SetMarginModes,
37 SetDeployerFees,
39 SetPerpAnnotation,
41 DisableDex,
43}
44
45impl PerpKind {
46 pub const ALL: [PerpKind; 16] = [
48 PerpKind::RegisterAsset2,
49 PerpKind::RegisterAsset,
50 PerpKind::SetOracle,
51 PerpKind::SetFundingMultipliers,
52 PerpKind::SetFundingInterestRates,
53 PerpKind::SetFundingClamps,
54 PerpKind::HaltTrading,
55 PerpKind::InsertMarginTable,
56 PerpKind::SetMarginTableIds,
57 PerpKind::SetFeeRecipient,
58 PerpKind::SetOpenInterestCaps,
59 PerpKind::SetSubDeployers,
60 PerpKind::SetMarginModes,
61 PerpKind::SetDeployerFees,
62 PerpKind::SetPerpAnnotation,
63 PerpKind::DisableDex,
64 ];
65
66 #[must_use]
68 pub const fn wire(self) -> &'static str {
69 match self {
70 PerpKind::RegisterAsset2 => "registerAsset2",
71 PerpKind::RegisterAsset => "registerAsset",
72 PerpKind::SetOracle => "setOracle",
73 PerpKind::SetFundingMultipliers => "setFundingMultipliers",
74 PerpKind::SetFundingInterestRates => "setFundingInterestRates",
75 PerpKind::SetFundingClamps => "setFundingClamps",
76 PerpKind::HaltTrading => "haltTrading",
77 PerpKind::InsertMarginTable => "insertMarginTable",
78 PerpKind::SetMarginTableIds => "setMarginTableIds",
79 PerpKind::SetFeeRecipient => "setFeeRecipient",
80 PerpKind::SetOpenInterestCaps => "setOpenInterestCaps",
81 PerpKind::SetSubDeployers => "setSubDeployers",
82 PerpKind::SetMarginModes => "setMarginModes",
83 PerpKind::SetDeployerFees => "setDeployerFees",
84 PerpKind::SetPerpAnnotation => "setPerpAnnotation",
85 PerpKind::DisableDex => "disableDex",
86 }
87 }
88}
89
90#[derive(Debug, Clone, Copy, PartialEq, Eq)]
93pub struct SubDeployer {
94 pub variant: PerpKind,
96 pub user: Address,
98 pub allowed: bool,
100}
101
102impl SubDeployer {
103 #[must_use]
105 pub fn wire(&self) -> Map {
106 Map::new().put("variant", self.variant.wire()).put("user", self.user.to_hex()).put("allowed", self.allowed)
107 }
108}