1use astroport::asset::AssetInfo;
2use cosmwasm_std::{DivideByZeroError, OverflowError, StdError};
3use thiserror::Error;
4
5#[derive(Error, Debug, PartialEq)]
7pub enum ContractError {
8 #[error("{0}")]
9 Std(#[from] StdError),
10
11 #[error("Unauthorized")]
12 Unauthorized {},
13
14 #[error("Invalid bridge {0} to {1}")]
15 InvalidBridge(AssetInfo, AssetInfo),
16
17 #[error("Invalid bridge. Pool {0} to {1} not found")]
18 InvalidBridgeNoPool(String, String),
19
20 #[error("Invalid bridge destination. {0} cannot be swapped to ASTRO")]
21 InvalidBridgeDestination(String),
22
23 #[error("Max bridge length of {0} was reached")]
24 MaxBridgeDepth(u64),
25
26 #[error("Cannot swap {0}. No swap destinations")]
27 CannotSwap(AssetInfo),
28
29 #[error("Incorrect governance percent of its share")]
30 IncorrectGovernancePercent {},
31
32 #[error("Governance percent must be 100% when staking contract is not set")]
33 GovernancePercentMustBe100 {},
34
35 #[error("Incorrect max spread")]
36 IncorrectMaxSpread {},
37
38 #[error("Cannot collect. Remove duplicate asset")]
39 DuplicatedAsset {},
40
41 #[error("Rewards collecting is already enabled")]
42 RewardsAlreadyEnabled {},
43
44 #[error("An error occurred during migration")]
45 MigrationError {},
46
47 #[error("Collect cooldown is not expired. Next collect is possible at {next_collect_ts}")]
48 Cooldown { next_collect_ts: u64 },
49
50 #[error("Incorrect cooldown. Min: {min}, Max: {max}")]
51 IncorrectCooldown { min: u64, max: u64 },
52}
53
54impl From<OverflowError> for ContractError {
55 fn from(o: OverflowError) -> Self {
56 StdError::from(o).into()
57 }
58}
59
60impl From<DivideByZeroError> for ContractError {
61 fn from(err: DivideByZeroError) -> Self {
62 StdError::from(err).into()
63 }
64}