Skip to main content

df_hyperliquid_core/deploy/
error.rs

1//! What a spot deploy, perp deploy or aligned quote action is refused for before it is signed: a
2//! name, figure or list the docs rule out.
3
4/// Why a `spotDeploy`, `perpDeploy`, `validatorL1Stream` or `requestEvmContract` action could not
5/// be made: a value outside what the venue's docs allow, caught before anything is signed.
6#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
7pub enum BadDeploy {
8    /// A dex name or deployer label that is not 2 to 4 lower case letters.
9    #[error("`{0}` is no dex name or deployer label: those are 2 to 4 lower case letters")]
10    Name(String),
11    /// A deployer trading fee share that is not a percentage from 0% to 100%.
12    #[error("a deployer trading fee share is a percentage from 0% to 100%, such as `99.4%`, which `{0}` is not")]
13    FeeShare(String),
14    /// A decimal outside the range the docs allow.
15    #[error("{what} is a decimal from {least} to {most}, which `{value}` is not")]
16    OutOfRange {
17        /// What the value is, such as `a funding clamp`.
18        what: &'static str,
19        /// The lowest value allowed, as text.
20        least: &'static str,
21        /// The highest value allowed, as text; `any` when there is no upper limit.
22        most: &'static str,
23        /// The value given, as it would be sent.
24        value: String,
25    },
26    /// A text longer than the docs allow.
27    #[error("{what} is at most {most} bytes, which `{value}` is over")]
28    TooLong {
29        /// What the text is, such as `a keyword`.
30        what: &'static str,
31        /// The most UTF-8 bytes allowed.
32        most: usize,
33        /// The text given.
34        value: String,
35    },
36    /// An annotation with more than 2 keywords; holds how many were given.
37    #[error("an annotation takes at most 2 keywords, not {0}")]
38    Keywords(usize),
39    /// A coin given twice in one per-coin list; holds the coin.
40    #[error("`{0}` is listed twice")]
41    Twice(String),
42    /// A `setOracle` with more than 2 lists of mark prices; holds how many were given.
43    #[error("setOracle takes at most 2 lists of mark prices, not {0}")]
44    MarkPxs(usize),
45    /// A margin table with no tiers, more than 3, a leverage outside 1 to 50, or tiers out of order.
46    #[error("a margin table takes 1 to 3 tiers, lower bounds rising, max leverage falling and each from 1 to 50")]
47    MarginTiers,
48    /// A `setMarginTableIds` that gives a coin table id 0; holds the coin.
49    #[error("`{0}` is given margin table 0, and a margin table id is never 0")]
50    MarginTableZero(String),
51    /// An `evmExtraWeiDecimals` outside -2 to 18; holds the value given.
52    #[error("evmExtraWeiDecimals is from -2 to 18, not {0}")]
53    EvmExtraWeiDecimals(i8),
54    /// A `setSubDeployers` with no grants.
55    #[error("setting sub-deployers needs at least one grant")]
56    NoGrants,
57}