Allow the treasury to have a maximum bound on the bond (#10689)

* Allow the treasury to have a maximum bound on the bond

* Update frame/treasury/src/lib.rs

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>

Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
This commit is contained in:
Gavin Wood
2022-01-19 15:08:53 +01:00
committed by GitHub
parent 2c3787288a
commit f2c8fe35a3
7 changed files with 15 additions and 1 deletions
+1
View File
@@ -880,6 +880,7 @@ impl pallet_treasury::Config for Runtime {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
type BurnDestination = ();
+1
View File
@@ -199,6 +199,7 @@ As mentioned above, Bounties, Tips and Lottery have been extracted out of treasu
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ProposalBondMinimum;
type ProposalBondMaximum = ();
type SpendPeriod = SpendPeriod;
type Burn = Burn;
+ type BurnDestination = ();
+1
View File
@@ -117,6 +117,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
@@ -121,6 +121,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = ();
+1
View File
@@ -137,6 +137,7 @@ impl pallet_treasury::Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.
+9 -1
View File
@@ -168,6 +168,10 @@ pub mod pallet {
#[pallet::constant]
type ProposalBondMinimum: Get<BalanceOf<Self, I>>;
/// Maximum amount of funds that should be placed in a deposit for making a proposal.
#[pallet::constant]
type ProposalBondMaximum: Get<Option<BalanceOf<Self, I>>>;
/// Period between successive spends.
#[pallet::constant]
type SpendPeriod: Get<Self::BlockNumber>;
@@ -404,7 +408,11 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// The needed bond for a proposal whose spend is `value`.
fn calculate_bond(value: BalanceOf<T, I>) -> BalanceOf<T, I> {
T::ProposalBondMinimum::get().max(T::ProposalBond::get() * value)
let mut r = T::ProposalBondMinimum::get().max(T::ProposalBond::get() * value);
if let Some(m) = T::ProposalBondMaximum::get() {
r = r.min(m);
}
r
}
/// Spend some money! returns number of approvals before spend.
+1
View File
@@ -115,6 +115,7 @@ impl Config for Test {
type OnSlash = ();
type ProposalBond = ProposalBond;
type ProposalBondMinimum = ConstU64<1>;
type ProposalBondMaximum = ();
type SpendPeriod = ConstU64<2>;
type Burn = Burn;
type BurnDestination = (); // Just gets burned.