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
// --- paritytech ---
use frame_support::PalletId;
use sp_npos_elections::NposSolution;
use sp_runtime::Perbill;
use sp_staking::{EraIndex, SessionIndex};
// --- darwinia-network ---
use crate::*;
use darwinia_staking::{Config, UseNominatorsMap};

pub const MAX_NOMINATIONS: u32 = <NposCompactSolution24 as NposSolution>::LIMIT as u32;

frame_support::parameter_types! {
	pub const StakingPalletId: PalletId = PalletId(*b"da/staki");
	pub const SessionsPerEra: SessionIndex = PANGOLIN_SESSIONS_PER_ERA;
	pub const BondingDurationInEra: EraIndex = BondingDurationInBlockNumber::get()
		/ (PANGORO_SESSIONS_PER_ERA as BlockNumber * PANGORO_BLOCKS_PER_SESSION);
	pub const BondingDurationInBlockNumber: BlockNumber = 14 * DAYS;
	pub const SlashDeferDuration: EraIndex = BondingDurationInEra::get() - 1;
	pub const MaxNominatorRewardedPerValidator: u32 = 64;
	pub const OffendingValidatorsThreshold: Perbill = Perbill::from_percent(17);
	pub const Cap: Balance = RING_HARD_CAP;
	pub const TotalPower: Power = TOTAL_POWER;
}

impl Config for Runtime {
	type BondingDurationInBlockNumber = BondingDurationInBlockNumber;
	type BondingDurationInEra = BondingDurationInEra;
	type Cap = Cap;
	type ElectionProvider = ElectionProviderMultiPhase;
	type Event = Event;
	type GenesisElectionProvider = GenesisElectionOf<Self>;
	type KtonCurrency = Kton;
	// rewards are minted from the void
	type KtonReward = ();
	// send the slashed funds to the treasury.
	type KtonSlash = KtonTreasury;
	type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
	type NextNewSession = Session;
	type OffendingValidatorsThreshold = OffendingValidatorsThreshold;
	type PalletId = StakingPalletId;
	type RingCurrency = Ring;
	// rewards are minted from the void
	type RingReward = ();
	type RingRewardRemainder = Treasury;
	// send the slashed funds to the treasury.
	type RingSlash = Treasury;
	type SessionInterface = Self;
	type SessionsPerEra = SessionsPerEra;
	/// A super-majority of the council can cancel the slash.
	type SlashCancelOrigin = RootOrAtLeastHalf<CouncilCollective>;
	type SlashDeferDuration = SlashDeferDuration;
	// Use the nominator map to iter voter AND no-ops for all SortedListProvider hooks. The
	// migration to bags-list is a no-op, but the storage version will be updated.
	type SortedListProvider = UseNominatorsMap<Self>;
	type TotalPower = TotalPower;
	type UnixTime = Timestamp;
	type WeightInfo = ();

	const MAX_NOMINATIONS: u32 = MAX_NOMINATIONS;
}