pallet_torus0/
fee.rs

1use core::marker::PhantomData;
2
3use codec::{Decode, Encode, MaxEncodedLen};
4use polkadot_sdk::{
5    frame_election_provider_support::Get, frame_support::DebugNoBound, sp_runtime::Percent,
6};
7use scale_info::TypeInfo;
8
9#[derive(DebugNoBound, Decode, Encode, MaxEncodedLen, PartialEq, Eq, TypeInfo)]
10#[scale_info(skip_type_params(T))]
11pub struct ValidatorFeeConstraints<T: crate::Config> {
12    pub min_staking_fee: Percent,
13    pub min_weight_control_fee: Percent,
14    pub _pd: PhantomData<T>,
15}
16
17impl<T: crate::Config> Default for ValidatorFeeConstraints<T> {
18    fn default() -> Self {
19        Self {
20            min_staking_fee: Percent::from_percent(T::DefaultMinStakingFee::get()),
21            min_weight_control_fee: Percent::from_percent(T::DefaultMinWeightControlFee::get()),
22            _pd: PhantomData,
23        }
24    }
25}
26
27#[derive(DebugNoBound, Decode, Encode, MaxEncodedLen, PartialEq, Eq, TypeInfo)]
28#[scale_info(skip_type_params(T))]
29pub struct ValidatorFee<T: crate::Config> {
30    pub staking_fee: Percent,
31    pub weight_control_fee: Percent,
32    pub _pd: PhantomData<T>,
33}
34
35impl<T: crate::Config> Default for ValidatorFee<T> {
36    fn default() -> Self {
37        let fee_constraints = crate::FeeConstraints::<T>::get();
38
39        Self {
40            staking_fee: fee_constraints.min_staking_fee,
41            weight_control_fee: fee_constraints.min_weight_control_fee,
42            _pd: PhantomData,
43        }
44    }
45}