mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 11:51:01 +00:00
staking: Flexible generation of reward curve and associated tweaks (#8327)
* Initial abstraction * Alter rest of APIs * Fixes * Some extra getters in Gilt pallet. * Refactor Gilt to avoid u128 conversions * Simplify and improve pow in per_things * Add scalar division to per_things * Renaming from_fraction -> from_float, drop _approximation * Fixes * Fixes * Fixes * Fixes * Make stuff build * Fixes * Fixes * Fixes * Fixes * Update .gitignore Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/gilt/src/lib.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Update frame/gilt/src/mock.rs Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com> * Fixes * Fixes * Fixes Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com> Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
This commit is contained in:
@@ -260,7 +260,7 @@ impl Config for Test {
|
||||
type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
|
||||
type BondingDuration = BondingDuration;
|
||||
type SessionInterface = Self;
|
||||
type RewardCurve = RewardCurve;
|
||||
type EraPayout = ConvertCurve<RewardCurve>;
|
||||
type NextNewSession = Session;
|
||||
type ElectionLookahead = ElectionLookahead;
|
||||
type Call = Call;
|
||||
@@ -670,25 +670,22 @@ pub(crate) fn start_active_era(era_index: EraIndex) {
|
||||
}
|
||||
|
||||
pub(crate) fn current_total_payout_for_duration(duration: u64) -> Balance {
|
||||
let reward = inflation::compute_total_payout(
|
||||
<Test as Config>::RewardCurve::get(),
|
||||
let (payout, _rest) = <Test as Config>::EraPayout::era_payout(
|
||||
Staking::eras_total_stake(active_era()),
|
||||
Balances::total_issuance(),
|
||||
duration,
|
||||
)
|
||||
.0;
|
||||
assert!(reward > 0);
|
||||
reward
|
||||
);
|
||||
assert!(payout > 0);
|
||||
payout
|
||||
}
|
||||
|
||||
pub(crate) fn maximum_payout_for_duration(duration: u64) -> Balance {
|
||||
inflation::compute_total_payout(
|
||||
<Test as Config>::RewardCurve::get(),
|
||||
0,
|
||||
let (payout, rest) = <Test as Config>::EraPayout::era_payout(
|
||||
Staking::eras_total_stake(active_era()),
|
||||
Balances::total_issuance(),
|
||||
duration,
|
||||
)
|
||||
.1
|
||||
);
|
||||
payout + rest
|
||||
}
|
||||
|
||||
/// Time it takes to finish a session.
|
||||
|
||||
Reference in New Issue
Block a user