Treasury burning can be directed (#6671)

* Treasury burning can be directed

Also, Society is a imbalance handler

* Build

* Introduce from_permill in perthings.

* Rename to from_perthousand to avoid confusion with Permill

* Fixes
This commit is contained in:
Gavin Wood
2020-07-17 12:04:42 +02:00
committed by GitHub
parent cad18b0fae
commit 85e1f9aa8d
6 changed files with 85 additions and 6 deletions
+7 -1
View File
@@ -184,6 +184,9 @@ pub trait Trait: frame_system::Trait {
/// Percentage of spare funds (if any) that are burnt per spend period.
type Burn: Get<Permill>;
/// Handler for the unbalanced decrease when treasury funds are burned.
type BurnDestination: OnUnbalanced<NegativeImbalanceOf<Self>>;
/// Weight information for extrinsics in this pallet.
type WeightInfo: WeightInfo;
}
@@ -771,7 +774,10 @@ impl<T: Trait> Module<T> {
// burn some proportion of the remaining budget if we run a surplus.
let burn = (T::Burn::get() * budget_remaining).min(budget_remaining);
budget_remaining -= burn;
imbalance.subsume(T::Currency::burn(burn));
let (debit, credit) = T::Currency::pair(burn);
imbalance.subsume(debit);
T::BurnDestination::on_unbalanced(credit);
Self::deposit_event(RawEvent::Burnt(burn))
}
+1
View File
@@ -149,6 +149,7 @@ impl Trait for Test {
type ProposalBondMinimum = ProposalBondMinimum;
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
type WeightInfo = ();
}
type System = frame_system::Module<Test>;