git.delta.rocks / unique-network / refs/commits / 1f5718ca8c83

difftreelog

Merge pull request #1027 from UniqueNetwork/feature/promo-rate

Yaroslav Bolyukin2023-11-16parents: #32f66f7 #48d2385.patch.diff
in: master
feature(runtime): app promoi rate is changed

4 files changed

modifiedjs-packages/tests/sub/appPromotion/appPromotion.test.tsdiffbeforeafterboth
--- a/js-packages/tests/sub/appPromotion/appPromotion.test.ts
+++ b/js-packages/tests/sub/appPromotion/appPromotion.test.ts
@@ -983,8 +983,8 @@
 function calculateIncome(base: bigint, iter = 0, calcPeriod: bigint = UNLOCKING_PERIOD): bigint {
   const DAY = 7200n;
   const ACCURACY = 1_000_000_000n;
-  // 5n / 10_000n = 0.05% p/day
-  const income = base + base * (ACCURACY * (calcPeriod * 5n) / (10_000n * DAY)) / ACCURACY ;
+  // 453_256n / 1_000_000_000n = 0.0453256% /day
+  const income = base + base * (ACCURACY * (calcPeriod * 453_256n) / (1_000_000_000n * DAY)) / ACCURACY ;
 
   if(iter > 1) {
     return calculateIncome(income, iter - 1, calcPeriod);
modifiedpallets/collator-selection/src/mock.rsdiffbeforeafterboth
--- a/pallets/collator-selection/src/mock.rs
+++ b/pallets/collator-selection/src/mock.rs
@@ -208,7 +208,7 @@
 	pub const DefaultWeightToFeeCoefficient: u64 = 100_000;
 	pub const DefaultMinGasPrice: u64 = 100_000;
 	pub const MaxXcmAllowedLocations: u32 = 16;
-	pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);
+	pub AppPromotionDailyRate: Perbill = Perbill::from_parts(453_256);
 	pub const DayRelayBlocks: u32 = 1;
 	pub const LicenceBondIdentifier: [u8; 16] = *b"licenceidentifie";
 }
modifiedruntime/common/config/pallets/app_promotion.rsdiffbeforeafterboth
before · runtime/common/config/pallets/app_promotion.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{parameter_types, PalletId};18use sp_arithmetic::Perbill;19use up_common::{20	constants::{DAYS, RELAY_DAYS, UNIQUE},21	types::Balance,22};2324use crate::{25	runtime_common::config::pallets::{RelayChainBlockNumberProvider, TreasuryAccountId},26	Balances, BlockNumber, EvmContractHelpers, Maintenance, Runtime, RuntimeEvent, Unique,27};2829parameter_types! {30	pub const AppPromotionId: PalletId = PalletId(*b"appstake");31	pub const RecalculationInterval: BlockNumber = RELAY_DAYS;32	pub const PendingInterval: BlockNumber = 7 * DAYS;33	pub const Nominal: Balance = UNIQUE;34	pub const HoldAndFreezeIdentifier: [u8; 16] = *b"appstakeappstake";35	pub IntervalIncome: Perbill = Perbill::from_rational(5u32, 10_000);36	pub MaintenanceMode: bool =  Maintenance::is_enabled();37}3839impl pallet_app_promotion::Config for Runtime {40	type PalletId = AppPromotionId;41	type CollectionHandler = Unique;42	type ContractHandler = EvmContractHelpers;43	type Currency = Balances;44	type WeightInfo = pallet_app_promotion::weights::SubstrateWeight<Self>;45	type TreasuryAccountId = TreasuryAccountId;46	type RelayBlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;47	type RecalculationInterval = RecalculationInterval;48	type PendingInterval = PendingInterval;49	type Nominal = Nominal;50	type IntervalIncome = IntervalIncome;51	type RuntimeEvent = RuntimeEvent;52	type FreezeIdentifier = HoldAndFreezeIdentifier;53	type IsMaintenanceModeEnabled = MaintenanceMode;54}
after · runtime/common/config/pallets/app_promotion.rs
1// Copyright 2019-2022 Unique Network (Gibraltar) Ltd.2// This file is part of Unique Network.34// Unique Network is free software: you can redistribute it and/or modify5// it under the terms of the GNU General Public License as published by6// the Free Software Foundation, either version 3 of the License, or7// (at your option) any later version.89// Unique Network is distributed in the hope that it will be useful,10// but WITHOUT ANY WARRANTY; without even the implied warranty of11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the12// GNU General Public License for more details.1314// You should have received a copy of the GNU General Public License15// along with Unique Network. If not, see <http://www.gnu.org/licenses/>.1617use frame_support::{parameter_types, PalletId};18use up_common::{19	constants::{DAYS, RELAY_DAYS, UNIQUE},20	types::Balance,21};2223use super::AppPromotionDailyRate;24use crate::{25	runtime_common::config::pallets::{RelayChainBlockNumberProvider, TreasuryAccountId},26	Balances, BlockNumber, EvmContractHelpers, Maintenance, Runtime, RuntimeEvent, Unique,27};2829parameter_types! {30	pub const AppPromotionId: PalletId = PalletId(*b"appstake");31	pub const RecalculationInterval: BlockNumber = RELAY_DAYS;32	pub const PendingInterval: BlockNumber = 7 * DAYS;33	pub const Nominal: Balance = UNIQUE;34	pub const HoldAndFreezeIdentifier: [u8; 16] = *b"appstakeappstake";35	pub MaintenanceMode: bool =  Maintenance::is_enabled();36}3738impl pallet_app_promotion::Config for Runtime {39	type PalletId = AppPromotionId;40	type CollectionHandler = Unique;41	type ContractHandler = EvmContractHelpers;42	type Currency = Balances;43	type WeightInfo = pallet_app_promotion::weights::SubstrateWeight<Self>;44	type TreasuryAccountId = TreasuryAccountId;45	type RelayBlockNumberProvider = RelayChainBlockNumberProvider<Runtime>;46	type RecalculationInterval = RecalculationInterval;47	type PendingInterval = PendingInterval;48	type Nominal = Nominal;49	type IntervalIncome = AppPromotionDailyRate;50	type RuntimeEvent = RuntimeEvent;51	type FreezeIdentifier = HoldAndFreezeIdentifier;52	type IsMaintenanceModeEnabled = MaintenanceMode;53}
modifiedruntime/common/config/pallets/mod.rsdiffbeforeafterboth
--- a/runtime/common/config/pallets/mod.rs
+++ b/runtime/common/config/pallets/mod.rs
@@ -151,7 +151,7 @@
 }
 
 parameter_types! {
-	pub AppPromotionDailyRate: Perbill = Perbill::from_rational(5u32, 10_000);
+	pub AppPromotionDailyRate: Perbill = Perbill::from_parts(453_256);
 	pub const MaxCollators: u32 = MAX_COLLATORS;
 	pub const LicenseBond: Balance = GENESIS_LICENSE_BOND;