use crate::utils::Address;
use crate::utils::sign::Map;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum PerpKind {
RegisterAsset2,
RegisterAsset,
SetOracle,
SetFundingMultipliers,
SetFundingInterestRates,
SetFundingClamps,
HaltTrading,
InsertMarginTable,
SetMarginTableIds,
SetFeeRecipient,
SetOpenInterestCaps,
SetSubDeployers,
SetMarginModes,
SetDeployerFees,
SetPerpAnnotation,
DisableDex,
}
impl PerpKind {
pub const ALL: [PerpKind; 16] = [
PerpKind::RegisterAsset2,
PerpKind::RegisterAsset,
PerpKind::SetOracle,
PerpKind::SetFundingMultipliers,
PerpKind::SetFundingInterestRates,
PerpKind::SetFundingClamps,
PerpKind::HaltTrading,
PerpKind::InsertMarginTable,
PerpKind::SetMarginTableIds,
PerpKind::SetFeeRecipient,
PerpKind::SetOpenInterestCaps,
PerpKind::SetSubDeployers,
PerpKind::SetMarginModes,
PerpKind::SetDeployerFees,
PerpKind::SetPerpAnnotation,
PerpKind::DisableDex,
];
#[must_use]
pub const fn wire(self) -> &'static str {
match self {
PerpKind::RegisterAsset2 => "registerAsset2",
PerpKind::RegisterAsset => "registerAsset",
PerpKind::SetOracle => "setOracle",
PerpKind::SetFundingMultipliers => "setFundingMultipliers",
PerpKind::SetFundingInterestRates => "setFundingInterestRates",
PerpKind::SetFundingClamps => "setFundingClamps",
PerpKind::HaltTrading => "haltTrading",
PerpKind::InsertMarginTable => "insertMarginTable",
PerpKind::SetMarginTableIds => "setMarginTableIds",
PerpKind::SetFeeRecipient => "setFeeRecipient",
PerpKind::SetOpenInterestCaps => "setOpenInterestCaps",
PerpKind::SetSubDeployers => "setSubDeployers",
PerpKind::SetMarginModes => "setMarginModes",
PerpKind::SetDeployerFees => "setDeployerFees",
PerpKind::SetPerpAnnotation => "setPerpAnnotation",
PerpKind::DisableDex => "disableDex",
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct SubDeployer {
pub variant: PerpKind,
pub user: Address,
pub allowed: bool,
}
impl SubDeployer {
#[must_use]
pub fn wire(&self) -> Map {
Map::new().put("variant", self.variant.wire()).put("user", self.user.to_hex()).put("allowed", self.allowed)
}
}