1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use cosmwasm_std::{Decimal, StdError};
use thiserror::Error;
#[derive(Error, Debug, PartialEq)]
pub enum ContractError {
#[error("{0}")]
Std(#[from] StdError),
#[error("Unauthorized")]
Unauthorized {},
#[error("Semver parsing error: {0}")]
SemVer(String),
#[error("Insufficient funds sent")]
InsufficientFundsSend {},
#[error("Unexpected Error")]
UnexpectedError {},
#[error("Insufficient collateral")]
InsufficientCollateral {},
#[error("Premature liquidation")]
PrematureLiquidation {},
#[error("Duplicated liquidation")]
DuplicatedLiquidation {},
#[error("Failed liquidation")]
FailedLiquidation {},
#[error("Insufficient balance")]
InsufficientBalance {},
#[error("Insufficient balance for funding payment")]
InsufficientBalanceForFundingPayment {},
#[error("Invalid coin type")]
InvalidCoinType {},
#[error("Invalid position effect")]
InvalidPositionEffect {},
#[error("Invalid position direction")]
InvalidPositionDirection {},
#[error("Invalid cw20 token")]
Invalidcw20token {},
#[error("Invalid order data")]
InvalidOrderData {},
#[error("Insufficient open amount to close")]
InsufficientOpenPositionToClose {
intended_close_amount: Decimal,
can_be_closed: Decimal,
},
#[error("Unsupported Denom")]
InvalidDenom { unsupported_denom: String },
#[error("Twap does not exist")]
TwapNotExist {},
#[error("Order not found")]
OrderNotFound {},
#[error("User not whitelisted for this feature")]
UnwhitelistedUser {},
#[error("Pool does not have enough liquidity")]
InsufficientLiquidity {},
}
impl From<semver::Error> for ContractError {
fn from(err: semver::Error) -> Self {
Self::SemVer(err.to_string())
}
}