Skip to main content

df_hyperliquid_core/trade/
error.rs

1use crate::trade::order::OverCap;
2use crate::utils::{BadUnits, Dec};
3
4/// What would be refused, or would trade the wrong way, before anything is
5/// signed.
6#[derive(Debug, Clone, PartialEq, Eq, thiserror::Error)]
7pub enum TradeError {
8    #[error("a slippage is a fraction from 0 to 0.5, which {0} is not")]
9    Slippage(Dec),
10    #[error("{0} leaves no price on the asset's grid")]
11    NoPrice(Dec),
12    #[error("{0} leaves no size at the asset's size decimals")]
13    NoSize(Dec),
14    #[error("a TWAP runs 5 to 1440 minutes, not {0}")]
15    TwapMinutes(u32),
16    #[error("leverage is a whole number of at least 1")]
17    NoLeverage,
18    #[error("isolated margin moves a non-zero amount of USDC: {0}")]
19    Margin(BadUnits),
20    #[error(transparent)]
21    OverCap(#[from] OverCap),
22}