dexter_multi_staking/
error.rs1use cosmwasm_std::{OverflowError, StdError, Uint128};
2use thiserror::Error;
3
4#[derive(Error, Debug)]
5pub enum ContractError {
6 #[error("{0}")]
7 Std(#[from] StdError),
8
9 #[error("Unauthorized")]
10 Unauthorized,
11
12 #[error("Invalid number of assets received. Expected {correct_number}, got {received_number}")]
13 InvalidNumberOfAssets {
14 correct_number: u8,
15 received_number: u8,
16 },
17
18 #[error("Invalid asset received. Expected {correct_asset}, got {received_asset}")]
19 InvalidAsset {
20 correct_asset: String,
21 received_asset: String,
22 },
23
24 #[error("Less amount received for {asset}. Expected {correct_amount}, got {received_amount}")]
25 LessAmountReceived {
26 asset: String,
27 correct_amount: Uint128,
28 received_amount: Uint128,
29 },
30
31 #[error("Can't unbond more than bonded. Current bond amount: {current_bond_amount}, Amount to unbond {amount_to_unbond}")]
32 CantUnbondMoreThanBonded {
33 current_bond_amount: Uint128,
34 amount_to_unbond: Uint128,
35 },
36
37 #[error("Can't allow any more LP token unbonds, limit reached! First unlock existing unbonds, then initiate new unbond.")]
38 CantAllowAnyMoreLpTokenUnbonds,
39
40 #[error("Can't allow any more LP tokens, limit reached!")]
41 CantAllowAnyMoreLpTokens,
42
43 #[error("LP Token is already allowed")]
44 LpTokenAlreadyAllowed,
45
46 #[error("LP Token is not allowed for staking")]
47 LpTokenNotAllowed,
48
49 #[error("Block time cannot be in the past")]
50 BlockTimeInPast,
51
52 #[error("Invalid block times. Start block time {start_block_time} is greater than end block time {end_block_time}")]
53 InvalidBlockTimes {
54 start_block_time: u64,
55 end_block_time: u64,
56 },
57
58 #[error(
59 "Start block time should be later than current block time. Start block time {start_block_time}, Current block time {current_block_time}"
60 )]
61 InvalidStartBlockTime {
62 start_block_time: u64,
63 current_block_time: u64,
64 },
65
66 #[error("Proposal not found for ID: {proposal_id}")]
67 ProposalNotFound { proposal_id: u64 },
68
69 #[error("Duplicate review found for ID: {proposal_id}")]
70 DuplicateReview { proposal_id: u64 },
71
72 #[error("Can't query by only proposer! LP token addr must be given")]
73 InvalidQuery,
74
75 #[error("Impossible contract state: {error}")]
76 ImpossibleContractState { error: String },
77
78 #[error("No reward state found for the asset since the reward is not distributed for it yet")]
79 NoRewardState,
80
81 #[error("No reward state found for the asset for the user since the reward is not distributed to the user yet")]
82 NoUserRewardState,
83
84 #[error("Invalid amount. Amount cannot be zero")]
85 ZeroAmount,
86
87 #[error("Can't perform this operation while reward schedule is active")]
88 RewardScheduleIsActive,
89
90 #[error("Unallocated reward for this schedule has already been claimed by the creator")]
91 UnallocatedRewardAlreadyClaimed,
92
93 #[error("This reward schedule has no unallocated reward to claim by the creator")]
94 NoUnallocatedReward,
95
96 #[error("Token lock doesn't exist")]
97 TokenLockNotFound,
98
99 #[error("Invalid instant unbond fee. Max allowed: {max_allowed}, Received: {received}")]
100 InvalidInstantUnbondFee { max_allowed: u64, received: u64 },
101
102 #[error("Invalid instant unbond min fee. Max allowed: {max_allowed}, Received: {received}")]
103 InvalidInstantUnbondMinFee { max_allowed: u64, received: u64 },
104
105 #[error("Invalid instant unlock fee tier interval. Max allowed: {max_allowed} i.e. equal to unlock period, Received: {received}")]
106 InvalidFeeTierInterval { max_allowed: u64, received: u64 },
107
108 #[error("Invalid contract version for upgrade {upgrade_version}. Expected: {expected}, Actual: {actual}")]
109 InvalidContractVersionForUpgrade {
110 upgrade_version: String,
111 expected: String,
112 actual: String,
113 },
114
115 #[error("No locks exist for the user")]
116 NoLocks,
117
118 #[error("No valid lock found from supplied input which can be unlocked")]
119 NoValidLocks,
120}
121
122impl From<OverflowError> for ContractError {
123 fn from(o: OverflowError) -> Self {
124 StdError::from(o).into()
125 }
126}