mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 14:27:57 +00:00
Implements a % cap on staking rewards from era inflation (#1660)
This PR implements an (optional) cap of the era inflation that is allocated to staking rewards. The remaining is minted directly into the [`RewardRemainder`](https://github.com/paritytech/polkadot-sdk/blob/fb0fd3e62445eb2dee2b2456a0c8574d1ecdcc73/substrate/frame/staking/src/pallet/mod.rs#L160) account, which is the treasury pot account in Polkadot and Kusama. The staking pallet now has a percent storage item, `MaxStakersRewards`, which defines the max percentage of the era inflation that should be allocated to staking rewards. The remaining era inflation (i.e. `remaining = max_era_payout - staking_payout.min(staking_payout * MaxStakersRewards))` is minted directly into the treasury. The `MaxStakersRewards` can be set by a privileged origin through the `set_staking_configs` extrinsic. **To finish** - [x] run benchmarks for westend-runtime Replaces https://github.com/paritytech/polkadot-sdk/pull/1483 Closes https://github.com/paritytech/polkadot-sdk/issues/403 --------- Co-authored-by: command-bot <>
This commit is contained in:
@@ -202,6 +202,12 @@
|
||||
//! ```nocompile
|
||||
//! remaining_payout = max_yearly_inflation * total_tokens / era_per_year - staker_payout
|
||||
//! ```
|
||||
//!
|
||||
//! Note, however, that it is possible to set a cap on the total `staker_payout` for the era through
|
||||
//! the `MaxStakersRewards` storage type. The `era_payout` implementor must ensure that the
|
||||
//! `max_payout = remaining_payout + (staker_payout * max_stakers_rewards)`. The excess payout that
|
||||
//! is not allocated for stakers is the era remaining reward.
|
||||
//!
|
||||
//! The remaining reward is send to the configurable end-point [`Config::RewardRemainder`].
|
||||
//!
|
||||
//! ### Reward Calculation
|
||||
@@ -897,8 +903,10 @@ impl<Balance: Default> EraPayout<Balance> for () {
|
||||
/// Adaptor to turn a `PiecewiseLinear` curve definition into an `EraPayout` impl, used for
|
||||
/// backwards compatibility.
|
||||
pub struct ConvertCurve<T>(sp_std::marker::PhantomData<T>);
|
||||
impl<Balance: AtLeast32BitUnsigned + Clone, T: Get<&'static PiecewiseLinear<'static>>>
|
||||
EraPayout<Balance> for ConvertCurve<T>
|
||||
impl<Balance, T> EraPayout<Balance> for ConvertCurve<T>
|
||||
where
|
||||
Balance: AtLeast32BitUnsigned + Clone + Copy,
|
||||
T: Get<&'static PiecewiseLinear<'static>>,
|
||||
{
|
||||
fn era_payout(
|
||||
total_staked: Balance,
|
||||
@@ -912,7 +920,7 @@ impl<Balance: AtLeast32BitUnsigned + Clone, T: Get<&'static PiecewiseLinear<'sta
|
||||
// Duration of era; more than u64::MAX is rewarded as u64::MAX.
|
||||
era_duration_millis,
|
||||
);
|
||||
let rest = max_payout.saturating_sub(validator_payout.clone());
|
||||
let rest = max_payout.saturating_sub(validator_payout);
|
||||
(validator_payout, rest)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user