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
use super::*;
use scale_info::TypeInfo;
pub type AssetBalance = u128;
pub const DEFAULT_FEE_RATE: u128 = 30;
pub const FEE_ADJUSTMENT: u128 = 10000;
#[derive(Clone, Copy, Encode, Decode, RuntimeDebug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub enum PairStatus<Balance, BlockNumber, Account> {
Trading(PairMetadata<Balance, Account>),
Bootstrap(BootstrapParameter<Balance, BlockNumber, Account>),
Disable,
}
impl<Balance, BlockNumber, Account> Default for PairStatus<Balance, BlockNumber, Account> {
fn default() -> Self {
Self::Disable
}
}
impl<BlockNumber, Account> PairStatus<AssetBalance, BlockNumber, Account> {
pub fn fee_rate(&self) -> AssetBalance {
match self {
Self::Trading(pair) => pair.fee_rate,
_ => DEFAULT_FEE_RATE,
}
}
}
#[derive(Encode, Decode, Clone, Copy, RuntimeDebug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub struct BootstrapParameter<Balance, BlockNumber, Account> {
pub target_supply: (Balance, Balance),
pub capacity_supply: (Balance, Balance),
pub accumulated_supply: (Balance, Balance),
pub end_block_number: BlockNumber,
pub pair_account: Account,
}
#[derive(Encode, Decode, Clone, Copy, RuntimeDebug, PartialEq, Eq, MaxEncodedLen, TypeInfo)]
pub struct PairMetadata<Balance, Account> {
pub pair_account: Account,
pub total_supply: Balance,
pub fee_rate: Balance,
}