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
pub use pallet_fee_market::{
Instance1 as WithPangoroFeeMarket, Instance2 as WithPangolinParachainFeeMarket,
Instance3 as WithPangolinParachainAlphaFeeMarket,
};
use core::cmp;
use frame_support::traits::LockIdentifier;
use sp_runtime::{Permill, SaturatedConversion};
use crate::{
weights::{
pallet_fee_market_pangolin_parachain_fee_market::WeightInfo as PangolinParachainWeightInfo,
pallet_fee_market_pangoro_fee_market::WeightInfo as PangoroWeightInfo,
},
*,
};
use pallet_fee_market::{BalanceOf, Config, Slasher};
pub struct FeeMarketSlasher;
impl<T, I> Slasher<T, I> for FeeMarketSlasher
where
T: Config<I>,
I: 'static,
{
fn cal_slash_amount(
collateral_per_order: BalanceOf<T, I>,
timeout: T::BlockNumber,
) -> BalanceOf<T, I> {
const SLASH_PER_BLOCK: Balance = 2 * COIN;
let collateral_per_order = collateral_per_order.saturated_into::<Balance>();
let timeout = timeout.saturated_into::<Balance>();
let slash_value = timeout.saturating_mul(SLASH_PER_BLOCK);
cmp::min(collateral_per_order, slash_value).saturated_into()
}
}
frame_support::parameter_types! {
pub const MinimumRelayFee: Balance = 15 * COIN;
pub const CollateralPerOrder: Balance = 50 * COIN;
pub const Slot: BlockNumber = 300;
pub const DutyRelayersRewardRatio: Permill = Permill::from_percent(20);
pub const MessageRelayersRewardRatio: Permill = Permill::from_percent(80);
pub const ConfirmRelayersRewardRatio: Permill = Permill::from_percent(20);
pub const AssignedRelayerSlashRatio: Permill = Permill::from_percent(20);
pub const PangoroFeeMarketLockId: LockIdentifier = *b"da/feelf";
pub const PangolinParachainFeeMarketLockId: LockIdentifier = *b"da/feepa";
pub const PangolinParachainAlphaFeeMarketLockId: LockIdentifier = *b"da/feeph";
}
impl Config<WithPangoroFeeMarket> for Runtime {
type AssignedRelayerSlashRatio = AssignedRelayerSlashRatio;
type CollateralPerOrder = CollateralPerOrder;
type ConfirmRelayersRewardRatio = ConfirmRelayersRewardRatio;
type Currency = Ring;
type DutyRelayersRewardRatio = DutyRelayersRewardRatio;
type Event = Event;
type LockId = PangoroFeeMarketLockId;
type MessageRelayersRewardRatio = MessageRelayersRewardRatio;
type MinimumRelayFee = MinimumRelayFee;
type Slasher = FeeMarketSlasher;
type Slot = Slot;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = PangoroWeightInfo<Self>;
}
impl Config<WithPangolinParachainFeeMarket> for Runtime {
type AssignedRelayerSlashRatio = AssignedRelayerSlashRatio;
type CollateralPerOrder = CollateralPerOrder;
type ConfirmRelayersRewardRatio = ConfirmRelayersRewardRatio;
type Currency = Ring;
type DutyRelayersRewardRatio = DutyRelayersRewardRatio;
type Event = Event;
type LockId = PangolinParachainFeeMarketLockId;
type MessageRelayersRewardRatio = MessageRelayersRewardRatio;
type MinimumRelayFee = MinimumRelayFee;
type Slasher = FeeMarketSlasher;
type Slot = Slot;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = PangolinParachainWeightInfo<Self>;
}
impl Config<WithPangolinParachainAlphaFeeMarket> for Runtime {
type AssignedRelayerSlashRatio = AssignedRelayerSlashRatio;
type CollateralPerOrder = CollateralPerOrder;
type ConfirmRelayersRewardRatio = ConfirmRelayersRewardRatio;
type Currency = Ring;
type DutyRelayersRewardRatio = DutyRelayersRewardRatio;
type Event = Event;
type LockId = PangolinParachainAlphaFeeMarketLockId;
type MessageRelayersRewardRatio = MessageRelayersRewardRatio;
type MinimumRelayFee = MinimumRelayFee;
type Slasher = FeeMarketSlasher;
type Slot = Slot;
type TreasuryPalletId = TreasuryPalletId;
type WeightInfo = PangolinParachainWeightInfo<Self>;
}