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