astroport_pair_stable/
error.rs1use cosmwasm_std::{
2 CheckedMultiplyRatioError, ConversionOverflowError, OverflowError, StdError, Uint128,
3};
4use cw_utils::PaymentError;
5use thiserror::Error;
6
7use astroport::{asset::MINIMUM_LIQUIDITY_AMOUNT, pair::MAX_FEE_SHARE_BPS};
8use astroport_circular_buffer::error::BufferError;
9
10use crate::math::{MAX_AMP, MAX_AMP_CHANGE, MIN_AMP_CHANGING_TIME};
11
12#[derive(Error, Debug, PartialEq)]
14pub enum ContractError {
15 #[error("{0}")]
16 Std(#[from] StdError),
17
18 #[error("{0}")]
19 CheckedMultiplyRatioError(#[from] CheckedMultiplyRatioError),
20
21 #[error("{0}")]
22 CircularBuffer(#[from] BufferError),
23
24 #[error("{0}")]
25 PaymentError(#[from] PaymentError),
26
27 #[error("Unauthorized")]
28 Unauthorized {},
29
30 #[error("CW20 tokens can be swapped via Cw20::Send message only")]
31 Cw20DirectSwap {},
32
33 #[error("Doubling assets in asset infos")]
34 DoublingAssets {},
35
36 #[error("Event of zero transfer")]
37 InvalidZeroAmount {},
38
39 #[error("Insufficient amount of liquidity")]
40 LiquidityAmountTooSmall {},
41
42 #[error("Provided spread amount exceeds allowed limit")]
43 AllowedSpreadAssertion {},
44
45 #[error("Operation exceeds max spread limit")]
46 MaxSpreadAssertion {},
47
48 #[error("Native token balance mismatch between the argument and the transferred")]
49 AssetMismatch {},
50
51 #[error(
52 "Amp coefficient must be greater than 0 and less than or equal to {}",
53 MAX_AMP
54 )]
55 IncorrectAmp {},
56
57 #[error(
58 "The difference between the old and new amp value must not exceed {} times",
59 MAX_AMP_CHANGE
60 )]
61 MaxAmpChangeAssertion {},
62
63 #[error(
64 "Amp coefficient cannot be changed more often than once per {} seconds",
65 MIN_AMP_CHANGING_TIME
66 )]
67 MinAmpChangingTimeAssertion {},
68
69 #[error("You need to provide init params")]
70 InitParamsNotFound {},
71
72 #[error("Incentives address is not set in factory. Cannot autostake")]
73 AutoStakeError {},
74
75 #[error("It is not possible to provide liquidity with one token for an empty pool")]
76 InvalidProvideLPsWithSingleToken {},
77
78 #[error("The asset {0} does not belong to the pair")]
79 InvalidAsset(String),
80
81 #[error("Ask or offer asset is missed")]
82 VariableAssetMissed {},
83
84 #[error("Source and target assets are the same")]
85 SameAssets {},
86
87 #[error("Invalid number of assets. This pair support only {0} assets")]
88 InvalidNumberOfAssets(usize),
89
90 #[error("Contract can't be migrated!")]
91 MigrationError {},
92
93 #[error("Initial liquidity must be more than {}", MINIMUM_LIQUIDITY_AMOUNT)]
94 MinimumLiquidityAmountError {},
95
96 #[error("Failed to parse or process reply message")]
97 FailedToParseReply {},
98
99 #[error(
100 "Fee share is 0 or exceeds maximum allowed value of {} bps",
101 MAX_FEE_SHARE_BPS
102 )]
103 FeeShareOutOfBounds {},
104
105 #[error("Slippage is more than expected: received {0}, expected {1} LP tokens")]
106 ProvideSlippageViolation(Uint128, Uint128),
107
108 #[error("Received {received} {asset_name} but expected {expected}")]
109 WithdrawSlippageViolation {
110 asset_name: String,
111 received: Uint128,
112 expected: Uint128,
113 },
114
115 #[error("Wrong asset length: expected {expected}, actual {actual}")]
116 WrongAssetLength { expected: usize, actual: usize },
117
118 #[error("Operation is not supported")]
119 NotSupported {},
120}
121
122impl From<OverflowError> for ContractError {
123 fn from(o: OverflowError) -> Self {
124 StdError::from(o).into()
125 }
126}
127
128impl From<ConversionOverflowError> for ContractError {
129 fn from(o: ConversionOverflowError) -> Self {
130 StdError::from(o).into()
131 }
132}