use crate::order::OrderKind;
#[derive(Debug, thiserror::Error)]
pub enum ConfigError {
#[error("unsupported domain")]
UnsupportedDomain,
}
#[derive(Clone, Copy, strum::EnumString, strum::Display)]
#[repr(u8)]
#[non_exhaustive]
#[strum(serialize_all = "kebab-case")]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "enum-iter", derive(strum::EnumIter))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "clap", clap(rename_all = "kebab-case"))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
pub enum DomainDisabledFlag {
MarketSwap = 0,
MarketIncrease = 1,
MarketDecrease = 2,
Liquidation = 3,
AutoDeleveraging = 4,
LimitSwap = 5,
LimitIncrease = 6,
LimitDecrease = 7,
StopLossDecrease = 8,
Deposit = 9,
Withdrawal = 10,
Shift = 11,
GlvDeposit = 12,
GlvWithdrawal = 13,
GlvShift = 14,
}
impl TryFrom<OrderKind> for DomainDisabledFlag {
type Error = ConfigError;
fn try_from(kind: OrderKind) -> Result<Self, Self::Error> {
match kind {
OrderKind::MarketSwap => Ok(Self::MarketSwap),
OrderKind::MarketIncrease => Ok(Self::MarketIncrease),
OrderKind::MarketDecrease => Ok(Self::MarketDecrease),
OrderKind::Liquidation => Ok(Self::Liquidation),
OrderKind::AutoDeleveraging => Ok(Self::AutoDeleveraging),
OrderKind::LimitSwap => Ok(Self::LimitSwap),
OrderKind::LimitIncrease => Ok(Self::LimitIncrease),
OrderKind::LimitDecrease => Ok(Self::LimitDecrease),
OrderKind::StopLossDecrease => Ok(Self::StopLossDecrease),
}
}
}
#[derive(Clone, Copy, Default, strum::EnumString, strum::Display)]
#[repr(u8)]
#[non_exhaustive]
#[strum(serialize_all = "kebab-case")]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "enum-iter", derive(strum::EnumIter))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "clap", clap(rename_all = "kebab-case"))]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
#[cfg_attr(feature = "serde", serde(rename_all = "kebab-case"))]
pub enum ActionDisabledFlag {
#[default]
Default = 0,
Create = 1,
Update = 2,
Execute = 3,
Cancel = 4,
}
pub fn display_feature(domain: DomainDisabledFlag, action: ActionDisabledFlag) -> String {
let action = match action {
ActionDisabledFlag::Default => String::new(),
action => format!(":{action}"),
};
format!("{domain}{action}")
}
#[derive(strum::EnumString, strum::Display, Clone, Copy)]
#[strum(serialize_all = "snake_case")]
#[non_exhaustive]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "enum-iter", derive(strum::EnumIter))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "clap", clap(rename_all = "snake_case"))]
pub enum AmountKey {
ClaimableTimeWindow,
RecentTimeWindow,
RequestExpiration,
OracleMaxAge,
OracleMaxTimestampRange,
OracleMaxFutureTimestampExcess,
AdlPricesMaxStaleness,
MinPositionAgeForManualClose,
MarketClosedPricesMaxStaleness,
}
#[derive(strum::EnumString, strum::Display, Clone, Copy)]
#[strum(serialize_all = "snake_case")]
#[non_exhaustive]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "enum-iter", derive(strum::EnumIter))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "clap", clap(rename_all = "snake_case"))]
pub enum FactorKey {
OracleRefPriceDeviation,
OrderFeeDiscountForReferredUser,
}
#[derive(strum::EnumString, strum::Display, Clone, Copy)]
#[strum(serialize_all = "snake_case")]
#[non_exhaustive]
#[cfg_attr(feature = "debug", derive(Debug))]
#[cfg_attr(feature = "enum-iter", derive(strum::EnumIter))]
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
#[cfg_attr(feature = "clap", clap(rename_all = "snake_case"))]
pub enum AddressKey {
Holding,
}