From 89f21b27c8bfc4c87cd9ff83ddbfdb38fe17cb6d Mon Sep 17 00:00:00 2001
From: librelois <c@elo.tf>
Date: Fri, 13 May 2022 21:30:22 +0200
Subject: [PATCH] fix(pallet-ud): SquareMoneyGrowthRate precision should be
 PerBill

---
 pallets/universal-dividend/src/lib.rs  | 6 +++---
 pallets/universal-dividend/src/mock.rs | 2 +-
 runtime/g1/src/parameters.rs           | 4 ++--
 runtime/gdev/src/parameters.rs         | 4 ++--
 runtime/gtest/src/parameters.rs        | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/pallets/universal-dividend/src/lib.rs b/pallets/universal-dividend/src/lib.rs
index 264a66ccd..a415df97a 100644
--- a/pallets/universal-dividend/src/lib.rs
+++ b/pallets/universal-dividend/src/lib.rs
@@ -29,7 +29,7 @@ mod benchmarking;
 
 use frame_support::traits::{tokens::ExistenceRequirement, Currency};
 use sp_arithmetic::{
-    per_things::Permill,
+    per_things::Perbill,
     traits::{One, Saturating, Zero},
 };
 use sp_runtime::traits::StaticLookup;
@@ -71,7 +71,7 @@ pub mod pallet {
         type MembersIds: Get<Vec<<Self as frame_system::Config>::AccountId>>;
         #[pallet::constant]
         /// Square of the money growth rate per ud reevaluation period
-        type SquareMoneyGrowthRate: Get<Permill>;
+        type SquareMoneyGrowthRate: Get<Perbill>;
         #[pallet::constant]
         /// Universal dividend creation period
         type UdCreationPeriod: Get<Self::BlockNumber>;
@@ -250,7 +250,7 @@ pub mod pallet {
         }
         fn reeval_ud_formula(
             ud_t: BalanceOf<T>,
-            c_square: Permill,
+            c_square: Perbill,
             monetary_mass: BalanceOf<T>,
             mut members_count: BalanceOf<T>,
             count_uds_beetween_two_reevals: BalanceOf<T>, // =(dt/udFrequency)
diff --git a/pallets/universal-dividend/src/mock.rs b/pallets/universal-dividend/src/mock.rs
index 6c48595d8..63738dcd5 100644
--- a/pallets/universal-dividend/src/mock.rs
+++ b/pallets/universal-dividend/src/mock.rs
@@ -97,7 +97,7 @@ impl pallet_balances::Config for Test {
 
 parameter_types! {
     pub const MembersCount: u64 = 3;
-    pub const SquareMoneyGrowthRate: Permill = Permill::from_percent(10);
+    pub const SquareMoneyGrowthRate: Perbill = Perbill::from_percent(10);
     pub const UdCreationPeriod: BlockNumber = 2;
     pub const UdReevalPeriod: BlockNumber = 8;
 }
diff --git a/runtime/g1/src/parameters.rs b/runtime/g1/src/parameters.rs
index 128b59b27..fa7e5e98d 100644
--- a/runtime/g1/src/parameters.rs
+++ b/runtime/g1/src/parameters.rs
@@ -18,7 +18,7 @@ use common_runtime::constants::*;
 use common_runtime::{Balance, BlockNumber};
 use frame_support::parameter_types;
 use frame_support::weights::constants::WEIGHT_PER_SECOND;
-use sp_arithmetic::Permill;
+use sp_arithmetic::Perbill;
 use sp_runtime::transaction_validity::TransactionPriority;
 
 parameter_types! {
@@ -83,7 +83,7 @@ frame_support::parameter_types! {
 // Universal dividend
 parameter_types! {
     // 0.002_381_440 = 0.0488^2
-    pub const SquareMoneyGrowthRate: Permill = Permill::from_parts(2_381_440);
+    pub const SquareMoneyGrowthRate: Perbill = Perbill::from_parts(2_381_440);
     pub const UdCreationPeriod: BlockNumber = DAYS;
     pub const UdReevalPeriod: BlockNumber = 2_620_800; // 86400 * 182 / 6
 }
diff --git a/runtime/gdev/src/parameters.rs b/runtime/gdev/src/parameters.rs
index d65b17cca..229c8eb25 100644
--- a/runtime/gdev/src/parameters.rs
+++ b/runtime/gdev/src/parameters.rs
@@ -18,7 +18,7 @@ use common_runtime::constants::*;
 use common_runtime::{Balance, BlockNumber};
 use frame_support::parameter_types;
 use frame_support::weights::constants::WEIGHT_PER_SECOND;
-use sp_arithmetic::Permill;
+use sp_arithmetic::Perbill;
 use sp_runtime::transaction_validity::TransactionPriority;
 
 parameter_types! {
@@ -81,7 +81,7 @@ frame_support::parameter_types! {
 // Universal dividend
 parameter_types! {
     // 0.002_381_440 = 0.0488^2
-    pub const SquareMoneyGrowthRate: Permill = Permill::from_parts(2_381_440);
+    pub const SquareMoneyGrowthRate: Perbill = Perbill::from_parts(2_381_440);
 }
 
 // Multisig
diff --git a/runtime/gtest/src/parameters.rs b/runtime/gtest/src/parameters.rs
index ef26b0f20..5b1a0f76f 100644
--- a/runtime/gtest/src/parameters.rs
+++ b/runtime/gtest/src/parameters.rs
@@ -18,7 +18,7 @@ use common_runtime::constants::*;
 use common_runtime::{Balance, BlockNumber};
 use frame_support::parameter_types;
 use frame_support::weights::constants::WEIGHT_PER_SECOND;
-use sp_arithmetic::Permill;
+use sp_arithmetic::Perbill;
 use sp_runtime::transaction_validity::TransactionPriority;
 
 parameter_types! {
@@ -83,7 +83,7 @@ frame_support::parameter_types! {
 // Universal dividend
 parameter_types! {
     // 0.002_381_440 = 0.0488^2
-    pub const SquareMoneyGrowthRate: Permill = Permill::from_parts(2_381_440);
+    pub const SquareMoneyGrowthRate: Perbill = Perbill::from_parts(2_381_440);
     pub const UdCreationPeriod: BlockNumber = DAYS;
     pub const UdFirstReeval: BlockNumber = 2 * DAYS;
     pub const UdReevalPeriod: BlockNumber = 100_800; // 86400 * 7 / 6
-- 
GitLab