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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
use crate::{AssetId, Balance, CurrencyId};
use codec::alloc::string::{String, ToString};
#[cfg(not(feature = "std"))]
use sp_arithmetic::traits::Saturating;
use tidefi_primitives_macro::assets;
#[cfg(feature = "std")]
use {
serde::{Deserialize, Serialize},
strum_macros::EnumIter,
};
pub enum Algo {
SR25519,
SECP256K1,
WEB3,
}
#[assets]
pub enum Asset {
#[asset::id = 1]
#[asset::symbol = "TDFY"]
#[asset::name = "Tidefi Token"]
#[asset::decimals = 12]
#[asset::algo = "SR25519"]
#[asset::min_stake = 10_000_000_000_000]
#[asset::max_stake = 500_000_000_000_000_000]
Tdfy,
#[asset::id = 2]
#[asset::symbol = "BTC"]
#[asset::name = "Bitcoin"]
#[asset::decimals = 8]
#[asset::algo = "SECP256K1"]
#[asset::unit = "satoshi"]
#[asset::prefix = "₿"]
#[asset::pot]
#[asset::min_stake = 100]
#[asset::max_stake = 500_000_000]
Bitcoin,
#[asset::id = 3]
#[asset::symbol = "ETH"]
#[asset::name = "Ethereum"]
#[asset::decimals = 18]
#[asset::algo = "WEB3"]
#[asset::unit = "wei"]
#[asset::prefix = "Ξ"]
#[asset::min_stake = 100_000]
#[asset::max_stake = 20_000_000_000_000_000_000]
Ethereum,
#[asset::id = 4]
#[asset::symbol = "USDT"]
#[asset::name = "Tether"]
#[asset::decimals = 6]
#[asset::algo = "WEB3"]
#[asset::base_chain = "Ethereum"]
#[asset::min_stake = 1_000_000]
#[asset::max_stake = 100_000_000_000]
Tether,
#[asset::id = 5]
#[asset::symbol = "USDC"]
#[asset::name = "USD Coin"]
#[asset::decimals = 6]
#[asset::algo = "WEB3"]
#[asset::base_chain = "Ethereum"]
#[asset::min_stake = 1_000_000]
#[asset::max_stake = 100_000_000_000]
USDCoin,
#[asset::id = 6]
#[asset::symbol = "ATH"]
#[asset::name = "All Time High"]
#[asset::decimals = 12]
#[asset::algo = "SR25519"]
#[asset::min_stake = 10_000_000_000_000]
#[asset::max_stake = 500_000_000_000_000_000]
AllTimeHigh,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_saturation_of_assets() {
assert_eq!(Asset::Bitcoin.saturating_mul(10), 1_000_000_000);
assert_eq!(Asset::Tdfy.saturating_mul(912), 912_000_000_000_000);
assert_eq!(
Asset::USDCoin.saturating_mul(838_912_012),
838_912_012_000_000
);
}
}