From 5fba1e0c655b33027c5ad9733ec5e7cf6cc458fa Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 7 Sep 2023 12:31:26 +0000 Subject: [PATCH 01/83] make rewards calculations aware of curve --- pallets/proof-of-stake/src/lib.rs | 48 +-- pallets/proof-of-stake/src/reward_info.rs | 383 ++++++++++++++++------ 2 files changed, 311 insertions(+), 120 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 426009495e..2ad99bcd19 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -25,7 +25,7 @@ use sp_runtime::{traits::SaturatedConversion, Perbill}; use sp_std::{convert::TryInto, prelude::*}; mod reward_info; -use reward_info::RewardInfo; +use reward_info::{AsymptoticCurveRewards, RewardInfo, RewardsCalculator}; mod benchmarking; #[cfg(test)] @@ -294,11 +294,14 @@ impl Pallet { pool_ratio_at_last_checkpoint: pool_ratio_current, missing_at_last_checkpoint: U256::from(0u128), }); - rewards_info.activate_more::( - current_time, - pool_ratio_current, - liquidity_assets_added, + + let calc = RewardsCalculator::::new::( + liquidity_asset_id, + rewards_info, )?; + let rewards_info = calc + .activate_more(liquidity_assets_added) + .map_err(|err| Into::>::into(err))?; RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); @@ -332,11 +335,14 @@ impl Pallet { Error::::NotEnoughAssets ); - rewards_info.activate_less::( - current_time, - pool_ratio_current, - liquidity_assets_burned, + let calc = RewardsCalculator::::new::( + liquidity_asset_id, + rewards_info, )?; + let rewards_info = calc + .activate_less(liquidity_assets_burned) + .map_err(|err| Into::>::into(err))?; + RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { @@ -395,11 +401,13 @@ impl ProofOfStakeRewardsApi for Pallet { let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; - let pool_rewards_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?; - let current_rewards = rewards_info - .calculate_rewards(Self::get_current_rewards_time()?, pool_rewards_ratio_current) - .ok_or(Error::::CalculateRewardsMathError)?; + let calc = RewardsCalculator::::new::( + liquidity_asset_id, + rewards_info.clone(), + )?; + let current_rewards = + calc.calculate_rewards().map_err(|err| Into::>::into(err))?; let total_available_rewards = current_rewards .checked_add(rewards_info.rewards_not_yet_claimed) @@ -483,14 +491,16 @@ impl ProofOfStakeRewardsApi for Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; + let current_rewards = match rewards_info.activated_amount { 0 => 0u128, - _ => rewards_info - .calculate_rewards( - Self::get_current_rewards_time()?, - Self::get_pool_rewards(liquidity_asset_id)?, - ) - .ok_or(Error::::CalculateRewardsMathError)?, + _ => { + let calc = RewardsCalculator::::new::( + liquidity_asset_id, + rewards_info.clone(), + )?; + calc.calculate_rewards().map_err(|err| Into::>::into(err))? + }, }; Ok(current_rewards diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 6909f83a7b..00f1aec643 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -1,8 +1,8 @@ use frame_support::dispatch::DispatchResult; -use crate::{Config, Error}; +use crate::{Config, Error, Pallet}; use frame_support::pallet_prelude::*; -use mangata_types::Balance; +use mangata_types::{Balance, TokenId}; use sp_core::U256; use sp_std::{convert::TryInto, prelude::*}; @@ -33,118 +33,62 @@ pub struct RewardInfo { pub missing_at_last_checkpoint: U256, } -impl RewardInfo { - pub fn calculate_missing_at_checkpoint(&self, current_time: u32) -> Option { - let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); - let q_pow = calculate_q_pow(Q, time_passed); - Some(self.missing_at_last_checkpoint * U256::from(REWARDS_PRECISION) / q_pow) - } - - pub fn activate_more( - &mut self, - current_time: u32, - pool_ratio_current: U256, - liquidity_assets_added: Balance, - ) -> DispatchResult { - let activated_amount = self - .activated_amount - .checked_add(liquidity_assets_added) - .ok_or(Error::::LiquidityCheckpointMathError)?; - - let missing_at_last_checkpoint = self - .calculate_missing_at_checkpoint(current_time) - .and_then(|v| v.checked_add(U256::from(liquidity_assets_added))) - .ok_or(Error::::LiquidityCheckpointMathError)?; +pub struct RewardsContext { + pub current_time: u32, + pub pool_ratio_current: U256, +} - let user_current_rewards = self - .calculate_rewards(current_time, pool_ratio_current) - .ok_or(Error::::CalculateRewardsMathError)?; +pub struct RewardsCalculator { + rewards_context: RewardsContext, + rewards_info: RewardInfo, + _curve: sp_std::marker::PhantomData, +} - let rewards_not_yet_claimed = user_current_rewards - .checked_add(self.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(self.rewards_already_claimed)) - .ok_or(Error::::LiquidityCheckpointMathError)?; - - self.activated_amount = activated_amount; - self.pool_ratio_at_last_checkpoint = pool_ratio_current; - self.rewards_already_claimed = 0_u128; - self.missing_at_last_checkpoint = missing_at_last_checkpoint; - self.rewards_not_yet_claimed = rewards_not_yet_claimed; - self.last_checkpoint = current_time; - Ok(()) +impl RewardsCalculator { + pub fn new( + asset_id: TokenId, + rewards_info: RewardInfo, + ) -> sp_std::result::Result { + Ok(Self { + rewards_context: RewardsContext { + current_time: Pallet::::get_current_rewards_time()?, + pool_ratio_current: Pallet::::get_pool_rewards(asset_id)?, + }, + rewards_info, + _curve: PhantomData::, + }) } +} - pub fn activate_less( - &mut self, - current_time: u32, - pool_ratio_current: U256, - liquidity_assets_removed: Balance, - ) -> DispatchResult { - let activated_amount = self - .activated_amount - .checked_sub(liquidity_assets_removed) - .ok_or(Error::::LiquidityCheckpointMathError)?; - - let missing_at_checkpoint_new = self - .calculate_missing_at_checkpoint(current_time) - .ok_or(Error::::LiquidityCheckpointMathError)?; +pub trait CurveRewards { + fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; + fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; +} - let activated_amount_new = self - .activated_amount - .checked_sub(liquidity_assets_removed) - .ok_or(Error::::LiquidityCheckpointMathError)?; - let missing_at_checkpoint_after_burn = U256::from(activated_amount_new) - .checked_mul(missing_at_checkpoint_new) - .and_then(|v| v.checked_div(self.activated_amount.into())) - .ok_or(Error::::LiquidityCheckpointMathError)?; +pub struct AsymptoticCurveRewards(RewardsContext, RewardInfo); - let user_current_rewards = self - .calculate_rewards(current_time, pool_ratio_current) - .ok_or(Error::::CalculateRewardsMathError)?; - let total_available_rewards = user_current_rewards - .checked_add(self.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(self.rewards_already_claimed)) - .ok_or(Error::::LiquidityCheckpointMathError)?; - - self.activated_amount = activated_amount; - self.pool_ratio_at_last_checkpoint = pool_ratio_current; - self.rewards_already_claimed = 0_u128; - self.missing_at_last_checkpoint = missing_at_checkpoint_after_burn; - self.rewards_not_yet_claimed = total_available_rewards; - self.last_checkpoint = current_time; - Ok(()) +impl CurveRewards for AsymptoticCurveRewards { + fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { + let time_passed = ctx.current_time.checked_sub(user_info.last_checkpoint).unwrap(); + let q_pow = calculate_q_pow(Q, time_passed); + Some(user_info.missing_at_last_checkpoint * U256::from(REWARDS_PRECISION) / q_pow) } - pub fn calculate_rewards( - &self, - current_time: u32, - pool_rewards_ratio_current: U256, - ) -> Option { + fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { let pool_rewards_ratio_new = - pool_rewards_ratio_current.checked_sub(self.pool_ratio_at_last_checkpoint)?; + ctx.pool_ratio_current.checked_sub(user_info.pool_ratio_at_last_checkpoint)?; - let user_rewards_base: U256 = U256::from(self.activated_amount) + let rewards_base: U256 = U256::from(user_info.activated_amount) .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 - let (cumulative_work, cummulative_work_max_possible) = - self.calculate_cumulative_work_max_ratio(current_time)?; - - user_rewards_base - .checked_mul(cumulative_work)? - .checked_div(cummulative_work_max_possible)? - .try_into() - .ok() - } - - fn calculate_cumulative_work_max_ratio(&self, current_time: u32) -> Option<(U256, U256)> { - let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); + let time_passed = ctx.current_time.checked_sub(user_info.last_checkpoint).unwrap(); // .ok_or(Error::::PastTimeCalculation)?; let mut cummulative_work = U256::from(0); let mut cummulative_work_max_possible_for_ratio = U256::from(1); - if time_passed != 0 && self.activated_amount != 0 { - let liquidity_assets_amount_u256: U256 = self.activated_amount.into(); + if time_passed != 0 && user_info.activated_amount != 0 { + let liquidity_assets_amount_u256: U256 = user_info.activated_amount.into(); // whole formula: missing_at_last_checkpoint*106/6 - missing_at_last_checkpoint*106*precision/6/q_pow // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well @@ -154,7 +98,7 @@ impl RewardInfo { // whole formula: missing_at_last_checkpoint*Q*100/(Q*100-100) - missing_at_last_checkpoint*Q*100/(Q*100-100)*REWARDS_PRECISION/q_pow // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well - let base = self + let base = user_info .missing_at_last_checkpoint .checked_mul(U256::from(libm::floor(Q * 100_f64) as u128))? .checked_div(U256::from(libm::floor(Q * 100_f64 - 100_f64) as u128))?; @@ -163,12 +107,249 @@ impl RewardInfo { let cummulative_missing_new = base - base * U256::from(REWARDS_PRECISION) / q_pow - - self.missing_at_last_checkpoint; + user_info.missing_at_last_checkpoint; cummulative_work = - cummulative_work_max_possible_for_ratio.checked_sub(cummulative_missing_new)?; + cummulative_work_max_possible_for_ratio.checked_sub(cummulative_missing_new)? } - Some((cummulative_work, cummulative_work_max_possible_for_ratio)) + rewards_base + .checked_mul(cummulative_work)? + .checked_div(cummulative_work_max_possible_for_ratio)? + .try_into() + .ok() } } + +#[derive(Debug)] +pub enum RewardsCalcError { + CheckpointMathError, +} + +impl Into> for RewardsCalcError { + fn into(self) -> Error { + Error::::LiquidityCheckpointMathError + } +} + +impl RewardsCalculator { + pub fn activate_more( + self, + liquidity_assets_added: Balance, + ) -> sp_std::result::Result { + let activated_amount = self + .rewards_info + .activated_amount + .checked_add(liquidity_assets_added) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let missing_at_last_checkpoint = + T::calculate_curve_position(&self.rewards_context, &self.rewards_info) + .and_then(|v| v.checked_add(U256::from(liquidity_assets_added))) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let user_current_rewards = self.calculate_rewards_impl()?; + + let rewards_not_yet_claimed = user_current_rewards + .checked_add(self.rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + Ok(RewardInfo { + activated_amount, + pool_ratio_at_last_checkpoint: self.rewards_context.pool_ratio_current, + rewards_already_claimed: 0_u128, + missing_at_last_checkpoint, + rewards_not_yet_claimed, + last_checkpoint: self.rewards_context.current_time, + }) + } + + pub fn activate_less( + self, + liquidity_assets_removed: Balance, + ) -> sp_std::result::Result { + let activated_amount = self + .rewards_info + .activated_amount + .checked_sub(liquidity_assets_removed) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let missing_at_checkpoint_new = + T::calculate_curve_position(&self.rewards_context, &self.rewards_info) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let activated_amount_new = self + .rewards_info + .activated_amount + .checked_sub(liquidity_assets_removed) + .ok_or(RewardsCalcError::CheckpointMathError)?; + let missing_at_checkpoint_after_burn = U256::from(activated_amount_new) + .checked_mul(missing_at_checkpoint_new) + .and_then(|v| v.checked_div(self.rewards_info.activated_amount.into())) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let user_current_rewards = self.calculate_rewards_impl()?; + + let total_available_rewards = user_current_rewards + .checked_add(self.rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + Ok(RewardInfo { + activated_amount, + pool_ratio_at_last_checkpoint: self.rewards_context.pool_ratio_current, + rewards_already_claimed: 0_u128, + missing_at_last_checkpoint: missing_at_checkpoint_after_burn, + rewards_not_yet_claimed: total_available_rewards, + last_checkpoint: self.rewards_context.current_time, + }) + } + + pub fn calculate_rewards(self) -> sp_std::result::Result { + self.calculate_rewards_impl() + } + + fn calculate_rewards_impl(&self) -> sp_std::result::Result { + T::calculate_curve_rewards(&self.rewards_context, &self.rewards_info) + .ok_or(RewardsCalcError::CheckpointMathError) + } +} + +// impl RewardInfo { +// pub fn calculate_missing_at_checkpoint(&self, current_time: u32) -> Option { +// let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); +// let q_pow = calculate_q_pow(Q, time_passed); +// Some(self.missing_at_last_checkpoint * U256::from(REWARDS_PRECISION) / q_pow) +// } +// +// pub fn activate_more( +// &mut self, +// current_time: u32, +// pool_ratio_current: U256, +// liquidity_assets_added: Balance, +// ) -> DispatchResult { +// let activated_amount = self +// .activated_amount +// .checked_add(liquidity_assets_added) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// let missing_at_last_checkpoint = self +// .calculate_missing_at_checkpoint(current_time) +// .and_then(|v| v.checked_add(U256::from(liquidity_assets_added))) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// let user_current_rewards = self +// .calculate_rewards(current_time, pool_ratio_current) +// .ok_or(Error::::CalculateRewardsMathError)?; +// +// let rewards_not_yet_claimed = user_current_rewards +// .checked_add(self.rewards_not_yet_claimed) +// .and_then(|v| v.checked_sub(self.rewards_already_claimed)) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// self.activated_amount = activated_amount; +// self.pool_ratio_at_last_checkpoint = pool_ratio_current; +// self.rewards_already_claimed = 0_u128; +// self.missing_at_last_checkpoint = missing_at_last_checkpoint; +// self.rewards_not_yet_claimed = rewards_not_yet_claimed; +// self.last_checkpoint = current_time; +// Ok(()) +// } +// +// pub fn activate_less( +// &mut self, +// current_time: u32, +// pool_ratio_current: U256, +// liquidity_assets_removed: Balance, +// ) -> DispatchResult { +// let activated_amount = self +// .activated_amount +// .checked_sub(liquidity_assets_removed) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// let missing_at_checkpoint_new = self +// .calculate_missing_at_checkpoint(current_time) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// let activated_amount_new = self +// .activated_amount +// .checked_sub(liquidity_assets_removed) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// let missing_at_checkpoint_after_burn = U256::from(activated_amount_new) +// .checked_mul(missing_at_checkpoint_new) +// .and_then(|v| v.checked_div(self.activated_amount.into())) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// let user_current_rewards = self +// .calculate_rewards(current_time, pool_ratio_current) +// .ok_or(Error::::CalculateRewardsMathError)?; +// let total_available_rewards = user_current_rewards +// .checked_add(self.rewards_not_yet_claimed) +// .and_then(|v| v.checked_sub(self.rewards_already_claimed)) +// .ok_or(Error::::LiquidityCheckpointMathError)?; +// +// self.activated_amount = activated_amount; +// self.pool_ratio_at_last_checkpoint = pool_ratio_current; +// self.rewards_already_claimed = 0_u128; +// self.missing_at_last_checkpoint = missing_at_checkpoint_after_burn; +// self.rewards_not_yet_claimed = total_available_rewards; +// self.last_checkpoint = current_time; +// Ok(()) +// } +// +// pub fn calculate_rewards( +// &self, +// current_time: u32, +// pool_rewards_ratio_current: U256, +// ) -> Option { +// let pool_rewards_ratio_new = +// pool_rewards_ratio_current.checked_sub(self.pool_ratio_at_last_checkpoint)?; +// +// let user_rewards_base: U256 = U256::from(self.activated_amount) +// .checked_mul(pool_rewards_ratio_new)? +// .checked_div(U256::from(u128::MAX))?; // always fit into u128 +// +// self.calculate_curve_rewards(user_rewards_base, current_time) +// } +// +// fn calculate_curve_rewards(&self, base_rewards: U256, current_time: u32) -> Option { +// let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); +// // .ok_or(Error::::PastTimeCalculation)?; +// let mut cummulative_work = U256::from(0); +// let mut cummulative_work_max_possible_for_ratio = U256::from(1); +// +// if time_passed != 0 && self.activated_amount != 0 { +// let liquidity_assets_amount_u256: U256 = self.activated_amount.into(); +// +// // whole formula: missing_at_last_checkpoint*106/6 - missing_at_last_checkpoint*106*precision/6/q_pow +// // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well +// +// cummulative_work_max_possible_for_ratio = +// liquidity_assets_amount_u256.checked_mul(U256::from(time_passed))?; +// +// // whole formula: missing_at_last_checkpoint*Q*100/(Q*100-100) - missing_at_last_checkpoint*Q*100/(Q*100-100)*REWARDS_PRECISION/q_pow +// // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well +// let base = self +// .missing_at_last_checkpoint +// .checked_mul(U256::from(libm::floor(Q * 100_f64) as u128))? +// .checked_div(U256::from(libm::floor(Q * 100_f64 - 100_f64) as u128))?; +// +// let q_pow = calculate_q_pow(Q, time_passed.checked_add(1)?); +// +// let cummulative_missing_new = base - +// base * U256::from(REWARDS_PRECISION) / q_pow - +// self.missing_at_last_checkpoint; +// +// cummulative_work = +// cummulative_work_max_possible_for_ratio.checked_sub(cummulative_missing_new)? +// } +// +// base_rewards +// .checked_mul(cummulative_work)? +// .checked_div(cummulative_work_max_possible_for_ratio)? +// .try_into() +// .ok() +// +// } +// } From 6c4bfdfda48949d1adf3e9a6e33073016f32c2a8 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 12 Sep 2023 05:29:41 +0000 Subject: [PATCH 02/83] add: PoS::reward_pool extrinsic --- Cargo.lock | 2 +- Cargo.toml | 4 +- pallets/proof-of-stake/Cargo.toml | 1 + pallets/proof-of-stake/src/lib.rs | 187 +++++++++++++++++++-- pallets/proof-of-stake/src/mock.rs | 45 +++++- pallets/proof-of-stake/src/tests.rs | 242 +++++++++++++++++++++++++++- runtime/common/src/lib.rs | 8 +- 7 files changed, 465 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13f334f04a..18ae550c0f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6786,6 +6786,7 @@ dependencies = [ "log", "mangata-support", "mangata-types", + "mockall", "orml-tokens", "orml-traits", "pallet-bootstrap", @@ -7381,7 +7382,6 @@ dependencies = [ [[package]] name = "parachain-staking" version = "3.0.0" -source = "git+https://github.com/mangata-finance//moonbeam?branch=mangata-dev#2ac7a339be795ee58603e3cb68e65fedc1b1c295" dependencies = [ "aquamarine", "frame-benchmarking", diff --git a/Cargo.toml b/Cargo.toml index aeae1a639f..c8c03cba34 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,8 +55,8 @@ orml-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-l # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/mangata-finance/moonbeam"] # parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/update-staking-benchmarks" } -parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } -# parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } +# parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } +parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } [patch."https://github.com/mangata-finance/crowdloan-rewards"] pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "mangata-dev" } diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index 68feb0a224..077522c1fd 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -41,6 +41,7 @@ lazy_static = "1.1.1" env_logger = "0.9.0" serial_test = { version = "0.6.0", default-features = false } test-case = "2.0.2" +mockall = "0.11.0" [features] default = ['std'] diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 2ad99bcd19..bafc0ccd8c 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -3,10 +3,13 @@ use frame_benchmarking::Zero; use frame_support::{ dispatch::{DispatchError, DispatchResult}, - ensure, + ensure }; use frame_system::ensure_signed; +use frame_support::storage::bounded_btree_map::BoundedBTreeMap; use sp_core::U256; +use sp_runtime::traits::AccountIdConversion; +use mangata_support::traits::Valuate; use frame_support::{ pallet_prelude::*, @@ -54,9 +57,14 @@ pub use weights::WeightInfo; type AccountIdOf = ::AccountId; +const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!"); + #[frame_support::pallet] pub mod pallet { - use super::*; + use frame_support::traits::Currency; +use mangata_support::traits::PoolCreateApi; + +use super::*; #[pallet::pallet] #[pallet::without_storage_info] @@ -66,7 +74,7 @@ pub mod pallet { impl Hooks for Pallet {} #[cfg(feature = "runtime-benchmarks")] - pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} + pub trait PoSBenchmarkingConrfig: pallet_issuance::Config {} #[cfg(feature = "runtime-benchmarks")] impl PoSBenchmarkingConfig for T {} @@ -90,7 +98,10 @@ pub mod pallet { type LiquidityMiningIssuanceVault: Get; #[pallet::constant] type RewardsDistributionPeriod: Get; + type RewardsSchedulesLimit: Get; + type MinRewardsPerSession: Get; type WeightInfo: WeightInfo; + type ValuationApi: Valuate; } #[pallet::error] @@ -112,6 +123,10 @@ pub mod pallet { CalculateRewardsAllMathError, MissingRewardsInfoError, DeprecatedExtrinsic, + CannotScheduleRewardsInPast, + PoolDoesNotExist, + TooManySchedules, + TooLittleRewardsPerSession, } #[pallet::event] @@ -135,6 +150,17 @@ pub mod pallet { ValueQuery, >; + // #[pallet::storage] + // pub type UserRewards3rdPartyInfo = StorageDoubleMap< + // _, + // Twox64Concat, + // AccountIdOf, + // Twox64Concat, + // (TokenId, TokenId), + // RewardInfo, + // ValueQuery, + // >; + #[pallet::storage] /// Stores information about pool weight and accumulated rewards. The accumulated /// rewards amount is the number of rewards that can be claimed per liquidity @@ -143,6 +169,26 @@ pub mod pallet { pub type PromotedPoolRewards = StorageValue<_, BTreeMap, ValueQuery>; + #[pallet::storage] + pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap, ValueQuery>; + + #[pallet::storage] + #[pallet::getter(fn schedules)] + pub type RewardsSchedules = + StorageValue<_, BoundedBTreeMap<(T::BlockNumber, TokenId, TokenId, Balance, u64), (), T::RewardsSchedulesLimit>, ValueQuery>; + + #[pallet::storage] + pub type ScheduleId = StorageValue<_, u64, ValueQuery>; + + + // #[pallet::storage] + // pub type Rewards3rdParty = + // StorageValue<_, BTreeMap, ValueQuery>; + // + // #[pallet::storage] + // pub type Rewards3rdParty = + // StorageValue<_, BTreeMap, ValueQuery>; + #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] /// Information about single token rewards pub struct PromotedPools { @@ -242,10 +288,88 @@ pub mod pallet { amount, ) } + + /// Schedules rewards for selected liquidity token + /// - tokens - pair of tokens + /// - amount - amount of the token + /// - schedule_end - till when the rewards should be distributed, rewards are + /// distributed starting from the *next* session till + #[transactional] + #[pallet::call_index(4)] + #[pallet::weight(<::WeightInfo>::claim_rewards_all())] + pub fn reward_pool( + origin: OriginFor, + pool: (TokenId, TokenId), + token_id: TokenId, + amount: Balance, + schedule_end: T::BlockNumber, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + let rewarded_token = ::ValuationApi::get_liquidity_asset(pool.0, pool.1) + .map_err(|_| Error::::PoolDoesNotExist)?; + + let current_session = Self::session_index(); + ensure!( + schedule_end.saturated_into::() > current_session, + Error::::CannotScheduleRewardsInPast + ); + + let amount_per_session = schedule_end.saturated_into::() + .checked_sub(current_session) + .and_then(|v| amount.checked_div(v.into())) + .ok_or(Error::::MathOverflow)?; + + // TODO: use valuation instead amount directly + ensure!(amount_per_session >= T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession); + + + T::Currency::transfer( + token_id.into(), + &sender, + &Self::pallet_account(), + amount.into(), + ExistenceRequirement::KeepAlive, + )?; + + let current_session = Self::session_index(); + let schedule_id = ScheduleId::::get(); + + RewardsSchedules::::try_mutate(|map| { + + let key: Option<(_,_,_,_,_)> = map + .first_key_value() + .map(|(x,y)| x.clone()); + + + if let Some(val) = key { + if current_session > val.0.saturated_into::() { + map.remove_entry(&val); + } + } + + map.try_insert((schedule_end, rewarded_token, token_id, amount_per_session, schedule_id), ()) + }).or(Err(Error::::TooManySchedules))?; + + ScheduleId::::mutate(|v| *v += 1); + + Ok(()) + } } } impl Pallet { + fn pallet_account() -> T::AccountId { + PALLET_ID.into_account_truncating() + } + + pub fn session_index() -> u32 { + frame_system::Pallet::::block_number() + .saturated_into::() + .checked_div(T::RewardsDistributionPeriod::get()) + .unwrap_or(0) + } + pub fn rewards_period() -> u32 { ::RewardsDistributionPeriod::get() } @@ -285,27 +409,32 @@ impl Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; let current_time: u32 = Self::get_current_rewards_time()?; let pool_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?; - let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) - .unwrap_or(RewardInfo { + let default_rewards = RewardInfo { activated_amount: 0_u128, rewards_not_yet_claimed: 0_u128, rewards_already_claimed: 0_u128, last_checkpoint: current_time, pool_ratio_at_last_checkpoint: pool_ratio_current, missing_at_last_checkpoint: U256::from(0u128), - }); + }; - let calc = RewardsCalculator::::new::( - liquidity_asset_id, - rewards_info, - )?; - let rewards_info = calc - .activate_more(liquidity_assets_added) - .map_err(|err| Into::>::into(err))?; - RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); + // Curved rewards + { + let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) + .unwrap_or(default_rewards); + let calc = RewardsCalculator::::new::( + liquidity_asset_id, + rewards_info, + )?; + let rewards_info = calc + .activate_more(liquidity_assets_added) + .map_err(|err| Into::>::into(err))?; + + RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); + } + - //TODO: refactor storage name TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { if let Some(val) = active_amount.checked_add(liquidity_assets_added) { *active_amount = val; @@ -513,6 +642,34 @@ impl ProofOfStakeRewardsApi for Pallet { impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { + + let schedules = RewardsSchedules::::get(); + let mut pools = PromotedPoolRewards3rdParty::::get(); + + let it = schedules + .iter() + .filter_map(|((session, rewarded_token, tokenid, amount, _),())|{ + if (*session).saturated_into::() <= Self::session_index() { + Some((rewarded_token, tokenid, amount)) + } else { + None + } + }); + + for (staked_token, token, amount) in it { + let activated_amount = Self::total_activated_amount(token); + let rewards = pools.get(token).cloned().unwrap_or_default(); + let rewards_for_liquidity = U256::from(*amount) + .checked_mul(U256::from(u128::MAX)) + .and_then(|x| x.checked_div(activated_amount.into())) + .and_then(|x| x.checked_add(rewards)); + + if let Some(val) = rewards_for_liquidity { + pools.insert(*token, val); + } + } + + let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { // benchmark with max of X prom pools let activated_pools: Vec<_> = promoted_pools diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index fa95825027..651feb810d 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -12,7 +12,7 @@ use sp_runtime::{ use crate as pos; use frame_support::{ construct_runtime, parameter_types, - traits::{tokens::currency::MultiTokenCurrency, ConstU32, Contains, Everything}, + traits::{tokens::currency::MultiTokenCurrency, ConstU32, ConstU128, Contains, Everything}, PalletId, }; @@ -202,6 +202,45 @@ lazy_static::lazy_static! { }; } +mockall::mock! { + pub ValuationApi {} + + impl Valuate for ValuationApi { + type Balance = Balance; + type CurrencyId = TokenId; + + fn get_liquidity_asset( + first_asset_id: TokenId, + second_asset_id: TokenId, + ) -> Result; + + fn get_liquidity_token_mga_pool( + liquidity_token_id: TokenId, + ) -> Result<(TokenId, TokenId), DispatchError>; + + fn valuate_liquidity_token( + liquidity_token_id: TokenId, + liquidity_token_amount: Balance, + ) -> Balance; + + fn scale_liquidity_by_mga_valuation( + mga_valuation: Balance, + liquidity_token_amount: Balance, + mga_token_amount: Balance, + ) -> Balance; + + fn get_pool_state(liquidity_token_id: TokenId) -> Option<(Balance, Balance)>; + + fn get_reserves( + first_asset_id: TokenId, + second_asset_id: TokenId, + ) -> Result<(Balance, Balance), DispatchError>; + + + + } +} + impl pos::Config for Test { type RuntimeEvent = RuntimeEvent; type ActivationReservesProvider = TokensActivationPassthrough; @@ -209,7 +248,10 @@ impl pos::Config for Test { type Currency = MultiTokenCurrencyAdapter; type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; + type RewardsSchedulesLimit = ConstU32<10>; + type MinRewardsPerSession = ConstU128<10>; type WeightInfo = (); + type ValuationApi = MockValuationApi; } pub struct TokensActivationPassthrough(PhantomData); @@ -327,3 +369,4 @@ macro_rules! assert_event_emitted { } }; } + diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index ea311c85d2..c11a2fac4e 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3,6 +3,7 @@ #![allow(non_snake_case)] use super::*; +use serial_test::serial; use crate::mock::*; use frame_support::{assert_err, assert_ok}; @@ -34,6 +35,16 @@ fn initialize_liquidity_rewards() { ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); } + +pub(crate) fn roll_to_session(n: u32) { + let block = n * Pallet::::rewards_period(); + + if block < System::block_number().saturated_into::() { + panic!("cannot roll to past block"); + } + forward_to_block(block); +} + fn forward_to_block(n: u32) { forward_to_block_with_custom_rewards(n, 10000); } @@ -41,7 +52,6 @@ fn forward_to_block(n: u32) { fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { while System::block_number().saturated_into::() <= n { if System::block_number().saturated_into::() % ProofOfStake::rewards_period() == 0 { - println!("NEW SESSION"); ProofOfStake::distribute_rewards(rewards); } System::set_block_number(System::block_number().saturated_into::() + 1); @@ -966,6 +976,7 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { }); } + pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option) { let mut session_number: u32; let mut session_issuance: (Balance, Balance); @@ -1090,3 +1101,232 @@ fn claim_rewards_from_pool_that_has_been_disabled() { assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 0); }); } + +const MILLION: u128 = 1_000_000; +const ALICE: u128 = 2; +const BOB: u128 = 3; + +#[test] +#[serial] +fn user_can_provide_3rdparty_rewards() { + new_test_ext().execute_with(|| { + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + System::set_block_number(1); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + roll_to_session(5); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 6u32.into()).unwrap(); + }); +} + +#[test] +#[serial] +fn cant_schedule_rewards_in_past() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + roll_to_session(5); + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 1u32.into()), + Error::::CannotScheduleRewardsInPast + ); + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 4u32.into()), + Error::::CannotScheduleRewardsInPast + ); + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 5u32.into()), + Error::::CannotScheduleRewardsInPast + ); + }); +} + +#[test] +#[serial] +fn cannot_reward_unexisting_pool() { + new_test_ext().execute_with(|| { + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Err(Error::::PoolDoesNotExist.into())); + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), + Error::::PoolDoesNotExist + ); + + }); +} + +#[test] +#[serial] +fn rewards_are_stored_in_pallet_account() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + assert_eq!(TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), 0); + assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION); + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), + ); + + assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION - amount); + assert_eq!(TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), amount); + }); +} + +#[test] +#[serial] +fn rewards_schedule_is_stored() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let liquidity_token_id = 10u32; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(liquidity_token_id)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), + ); + + assert_eq!( + ProofOfStake::schedules().into_inner(), + BTreeMap::from([((5u64, liquidity_token_id, token_id, amount/5, 0), ())]) + ); + + }); +} + +#[test] +#[serial] +fn number_of_active_schedules_is_limited() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + + let max_schedules: u32 = <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); + for i in 0..(max_schedules) { + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, (5u32 + i).into()) + ); + } + + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 100u32.into()), + Error::::TooManySchedules + ); + + roll_to_session(10); + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 100u32.into()) + ); + + }); +} + +#[test] +#[serial] +fn duplicated_schedules_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) + ); + + assert_eq!(1, ProofOfStake::schedules().len()); + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) + ); + assert_eq!(2, ProofOfStake::schedules().len()); + + }); +} + + +#[test] +#[serial] +fn reject_schedule_with_too_little_rewards_per_session() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + roll_to_session(4); + + let min_rewards = <::MinRewardsPerSession as sp_core::Get>::get(); + + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, min_rewards - 1, 5u32.into()), + Error::::TooLittleRewardsPerSession + ); + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, min_rewards, 5u32.into()) + ); + }); +} + + +#[test] +#[serial] +fn user_can_claim_3rdparty_rewards() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) + ); + + }); +} diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 7eb1bfdb64..69c8dd3170 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1150,13 +1150,13 @@ where /// Reward payments delay (number of rounds) pub const RewardPaymentDelay: u32 = 2; /// Minimum collators selected per round, default at genesis and minimum forever after - pub const MinSelectedCandidates: u32 = 25; + pub const MinSelectedCandidates: u32 = 50; /// Maximum collator candidates allowed - pub const MaxCollatorCandidates: u32 = 50; + pub const MaxCollatorCandidates: u32 = 100; /// Maximum delegators allowed per candidate - pub const MaxTotalDelegatorsPerCandidate: u32 = 25; + pub const MaxTotalDelegatorsPerCandidate: u32 = 30; /// Maximum delegators counted per candidate - pub const MaxDelegatorsPerCandidate: u32 = 12; + pub const MaxDelegatorsPerCandidate: u32 = 30; /// Maximum delegations per delegator pub const MaxDelegationsPerDelegator: u32 = 30; /// Default fixed percent a collator takes off the top of due rewards From 1709ea7c9d08359272995a50edcd75c190746bd1 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 15 Sep 2023 11:37:52 +0200 Subject: [PATCH 03/83] preliminary rewards claim --- pallets/proof-of-stake/src/lib.rs | 162 +++++++++++++++++----- pallets/proof-of-stake/src/mock.rs | 1 + pallets/proof-of-stake/src/reward_info.rs | 77 +++++++++- pallets/proof-of-stake/src/tests.rs | 63 ++++++++- 4 files changed, 263 insertions(+), 40 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index bafc0ccd8c..8f567cb557 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -28,7 +28,7 @@ use sp_runtime::{traits::SaturatedConversion, Perbill}; use sp_std::{convert::TryInto, prelude::*}; mod reward_info; -use reward_info::{AsymptoticCurveRewards, RewardInfo, RewardsCalculator}; +use reward_info::{AsymptoticCurveRewards, ConstCurveRewards, RewardInfo, RewardsCalculator}; mod benchmarking; #[cfg(test)] @@ -100,6 +100,7 @@ use super::*; type RewardsDistributionPeriod: Get; type RewardsSchedulesLimit: Get; type MinRewardsPerSession: Get; + type MaxRewardTokensPerPool: Get; type WeightInfo: WeightInfo; type ValuationApi: Valuate; } @@ -127,6 +128,7 @@ use super::*; PoolDoesNotExist, TooManySchedules, TooLittleRewardsPerSession, + PoolRewardTokensLimitExceeded, } #[pallet::event] @@ -150,16 +152,16 @@ use super::*; ValueQuery, >; - // #[pallet::storage] - // pub type UserRewards3rdPartyInfo = StorageDoubleMap< - // _, - // Twox64Concat, - // AccountIdOf, - // Twox64Concat, - // (TokenId, TokenId), - // RewardInfo, - // ValueQuery, - // >; + #[pallet::storage] + pub type UserRewards3rdPartyInfo = StorageDoubleMap< + _, + Twox64Concat, + AccountIdOf, + Twox64Concat, + (TokenId, TokenId), + RewardInfo, + ValueQuery, + >; #[pallet::storage] /// Stores information about pool weight and accumulated rewards. The accumulated @@ -170,13 +172,18 @@ use super::*; StorageValue<_, BTreeMap, ValueQuery>; #[pallet::storage] - pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap, ValueQuery>; + pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; + + // pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap<(TokenId), U256>, ValueQuery>; #[pallet::storage] #[pallet::getter(fn schedules)] pub type RewardsSchedules = StorageValue<_, BoundedBTreeMap<(T::BlockNumber, TokenId, TokenId, Balance, u64), (), T::RewardsSchedulesLimit>, ValueQuery>; + #[pallet::storage] + pub type RewardTokensPerPool = StorageMap<_, Twox64Concat, TokenId, BoundedBTreeMap, ValueQuery>; + #[pallet::storage] pub type ScheduleId = StorageValue<_, u64, ValueQuery>; @@ -322,7 +329,14 @@ use super::*; // TODO: use valuation instead amount directly ensure!(amount_per_session >= T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession); + println!("hello worldd!!!!"); + RewardTokensPerPool::::try_mutate(rewarded_token, |tokens| { + println!("{tokens:?}"); + tokens.try_insert(token_id,()) + }).or(Err(Error::::PoolRewardTokensLimitExceeded))?; + + println!("{rewarded_token} =>>> {:?}",RewardTokensPerPool::::get(rewarded_token)); T::Currency::transfer( token_id.into(), @@ -359,6 +373,50 @@ use super::*; } impl Pallet { + + fn calculate_rewards_amount_3rdparty( + user: AccountIdOf, + liquidity_asset_id: TokenId, + ) -> Result, DispatchError> { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + let mut result: sp_std::vec::Vec<_> = Default::default(); + + // TODO: get rid of collect + let reward_tokens = RewardTokensPerPool::::get(liquidity_asset_id) + .iter() + .map(|(x,_)| *x) + .collect::>(); + + + for i in reward_tokens{ + println!(";iittititiitititit"); + + let rewards_info = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, i)); + println!("REWARDS INFO {rewards_info:?}"); + if let Ok(info) = rewards_info{ + let current_rewards = match info.activated_amount { + 0 => 0u128, + _ => { + let calc = RewardsCalculator::::new2::( + user.clone(), + liquidity_asset_id, + i + )?; + calc.calculate_rewards().map_err(|err| Into::>::into(err))? + }, + }; + + let total_rewards = current_rewards + .checked_add(info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(info.rewards_already_claimed)) + .ok_or(Error::::CalculateRewardsMathError)?; + result.push((i, total_rewards)); + } + } + Ok(result) + + } fn pallet_account() -> T::AccountId { PALLET_ID.into_account_truncating() } @@ -385,6 +443,15 @@ impl Pallet { .ok_or(Error::::NotAPromotedPool)?) } + fn get_pool_rewards_3rdparty(liquidity_asset_id: TokenId, reward_asset_id: TokenId) -> Result { + println!("ret_pool_rewards_3rdparty {liquidity_asset_id} {reward_asset_id}"); + Ok(*PromotedPoolRewards3rdParty::::get() + .get(&(liquidity_asset_id, reward_asset_id)) + //TODO: no error or some dedicated error + .ok_or(Error::::NotAPromotedPool)?) + } + + fn get_current_rewards_time() -> Result { >::block_number() .saturated_into::() @@ -394,9 +461,12 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { - if Self::get_pool_rewards(liquidity_asset_id).is_ok() { + println!("ensure_is_promoted_pool {liquidity_asset_id}"); + if Self::get_pool_rewards(liquidity_asset_id).is_ok() || !RewardTokensPerPool::::get(liquidity_asset_id).is_empty() { + println!("ensure_is_promoted_pool ok"); Ok(()) } else { + println!("ensure_is_promoted_pool err"); Err(DispatchError::from(Error::::NotAPromotedPool)) } } @@ -407,25 +477,37 @@ impl Pallet { liquidity_assets_added: Balance, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let current_time: u32 = Self::get_current_rewards_time()?; - let pool_ratio_current = Self::get_pool_rewards(liquidity_asset_id)?; - let default_rewards = RewardInfo { - activated_amount: 0_u128, - rewards_not_yet_claimed: 0_u128, - rewards_already_claimed: 0_u128, - last_checkpoint: current_time, - pool_ratio_at_last_checkpoint: pool_ratio_current, - missing_at_last_checkpoint: U256::from(0u128), - }; + println!("set_liquidity_minting_checkpoint1"); + + { + let reward_tokens = RewardTokensPerPool::::get(liquidity_asset_id) + .iter() + .map(|(x,_)| *x) + // NOTE: get rid of collect + .collect::>(); + + + for i in reward_tokens{ + let calc = RewardsCalculator::::new2::( + user.clone(), + liquidity_asset_id, + i + )?; + + let rewards_info = calc + .activate_more(liquidity_assets_added) + .map_err(|err| Into::>::into(err))?; + + UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id,i), rewards_info); + } + } + println!("set_liquidity_minting_checkpoint2"); - // Curved rewards { - let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) - .unwrap_or(default_rewards); let calc = RewardsCalculator::::new::( + user.clone(), liquidity_asset_id, - rewards_info, )?; let rewards_info = calc .activate_more(liquidity_assets_added) @@ -435,11 +517,15 @@ impl Pallet { } + println!("set_liquidity_minting_checkpoint3"); + TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { if let Some(val) = active_amount.checked_add(liquidity_assets_added) { + println!("!!!!!!!!!!!!!!!!!!!!!!!!!"); *active_amount = val; Ok(()) } else { + println!("$$$$$$$$$$$$$$$$$$$$$$$$$"); Err(()) } }) @@ -465,8 +551,8 @@ impl Pallet { ); let calc = RewardsCalculator::::new::( + user.clone(), liquidity_asset_id, - rewards_info, )?; let rewards_info = calc .activate_less(liquidity_assets_burned) @@ -532,8 +618,8 @@ impl ProofOfStakeRewardsApi for Pallet { .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; let calc = RewardsCalculator::::new::( + user.clone(), liquidity_asset_id, - rewards_info.clone(), )?; let current_rewards = calc.calculate_rewards().map_err(|err| Into::>::into(err))?; @@ -572,6 +658,7 @@ impl ProofOfStakeRewardsApi for Pallet { use_balance_from: Option, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; + println!("activate_liquidity"); ensure!( ::ActivationReservesProvider::can_activate( liquidity_asset_id, @@ -613,6 +700,7 @@ impl ProofOfStakeRewardsApi for Pallet { Ok(()) } + fn calculate_rewards_amount( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -625,8 +713,8 @@ impl ProofOfStakeRewardsApi for Pallet { 0 => 0u128, _ => { let calc = RewardsCalculator::::new::( + user.clone(), liquidity_asset_id, - rewards_info.clone(), )?; calc.calculate_rewards().map_err(|err| Into::>::into(err))? }, @@ -649,7 +737,7 @@ impl LiquidityMiningApi for Pallet { let it = schedules .iter() .filter_map(|((session, rewarded_token, tokenid, amount, _),())|{ - if (*session).saturated_into::() <= Self::session_index() { + if (*session).saturated_into::() > Self::session_index() { Some((rewarded_token, tokenid, amount)) } else { None @@ -657,17 +745,23 @@ impl LiquidityMiningApi for Pallet { }); for (staked_token, token, amount) in it { - let activated_amount = Self::total_activated_amount(token); - let rewards = pools.get(token).cloned().unwrap_or_default(); + println!("STAKED TOKEN: {staked_token} TOKEN: {token} AMOUNT: {amount}"); + + let activated_amount = Self::total_activated_amount(staked_token); + println!("ACTIVATED AMOUNT: {activated_amount}"); + // NOTE: fix + let rewards = pools.get(&(*staked_token, *token)).cloned().unwrap_or_default(); let rewards_for_liquidity = U256::from(*amount) .checked_mul(U256::from(u128::MAX)) .and_then(|x| x.checked_div(activated_amount.into())) .and_then(|x| x.checked_add(rewards)); if let Some(val) = rewards_for_liquidity { - pools.insert(*token, val); + pools.insert((*staked_token,*token), val); } } + println!("STORING POOLS: {pools:?}"); + PromotedPoolRewards3rdParty::::put(pools); let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 651feb810d..2bd2de9286 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -250,6 +250,7 @@ impl pos::Config for Test { type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; type MinRewardsPerSession = ConstU128<10>; + type MaxRewardTokensPerPool = ConstU32<5>; type WeightInfo = (); type ValuationApi = MockValuationApi; } diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 00f1aec643..0e042cb004 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -44,27 +44,78 @@ pub struct RewardsCalculator { _curve: sp_std::marker::PhantomData, } -impl RewardsCalculator { +impl RewardsCalculator { pub fn new( + user: T::AccountId, asset_id: TokenId, - rewards_info: RewardInfo, ) -> sp_std::result::Result { + let current_time: u32 = Pallet::::get_current_rewards_time()?; + let pool_ratio_current = Pallet::::get_pool_rewards(asset_id)?; + let default_rewards = RewardInfo { + activated_amount: 0_u128, + rewards_not_yet_claimed: 0_u128, + rewards_already_claimed: 0_u128, + last_checkpoint: current_time, + pool_ratio_at_last_checkpoint: pool_ratio_current, + missing_at_last_checkpoint: U256::from(0u128), + }; + + let rewards_info = crate::RewardsInfo::::try_get(user.clone(), asset_id) + .unwrap_or(default_rewards); + Ok(Self { rewards_context: RewardsContext { current_time: Pallet::::get_current_rewards_time()?, pool_ratio_current: Pallet::::get_pool_rewards(asset_id)?, }, rewards_info, - _curve: PhantomData::, + _curve: PhantomData::, }) } } +impl RewardsCalculator { + pub fn new2( + user: T::AccountId, + asset_id: TokenId, + reward_asset_id: TokenId, + ) -> sp_std::result::Result { + + let current_time: u32 = Pallet::::get_current_rewards_time()?; + + // TODO: do not ignore error + let pool_ratio_current = Pallet::::get_pool_rewards_3rdparty(asset_id, reward_asset_id).unwrap_or_default(); + let default_rewards = RewardInfo { + activated_amount: 0_u128, + rewards_not_yet_claimed: 0_u128, + rewards_already_claimed: 0_u128, + last_checkpoint: current_time, + pool_ratio_at_last_checkpoint: pool_ratio_current, + missing_at_last_checkpoint: U256::from(0u128), + }; + + let rewards_info = crate::RewardsInfo::::try_get(user.clone(), asset_id) + .unwrap_or(default_rewards); + + Ok(Self { + rewards_context: RewardsContext { + current_time: Pallet::::get_current_rewards_time()?, + pool_ratio_current, + }, + rewards_info, + _curve: PhantomData::, + }) + + } +} + + pub trait CurveRewards { fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; } +pub struct ConstCurveRewards(RewardsContext, RewardInfo); pub struct AsymptoticCurveRewards(RewardsContext, RewardInfo); impl CurveRewards for AsymptoticCurveRewards { @@ -121,6 +172,26 @@ impl CurveRewards for AsymptoticCurveRewards { } } +impl CurveRewards for ConstCurveRewards { + fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { + Some( U256::from(0) ) + } + + fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { + println!("context: {:?}", ctx.pool_ratio_current); + let pool_rewards_ratio_new = + ctx.pool_ratio_current.checked_sub(user_info.pool_ratio_at_last_checkpoint)?; + let rewards_base: U256 = U256::from(user_info.activated_amount) + .checked_mul(pool_rewards_ratio_new)? + .checked_div(U256::from(u128::MAX))?; // always fit into u128 + println!("BASE : {rewards_base}"); + + rewards_base + .try_into() + .ok() + } +} + #[derive(Debug)] pub enum RewardsCalcError { CheckpointMathError, diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index c11a2fac4e..b3f1373736 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1105,6 +1105,8 @@ fn claim_rewards_from_pool_that_has_been_disabled() { const MILLION: u128 = 1_000_000; const ALICE: u128 = 2; const BOB: u128 = 3; +const CHARLIE: u128 = 4; +const EVE: u128 = 5; #[test] #[serial] @@ -1310,23 +1312,78 @@ fn reject_schedule_with_too_little_rewards_per_session() { }); } +#[test] +#[serial] +fn number_of_reward_tokens_per_pool_is_limited() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(10u32)); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + for _ in 0..<::MaxRewardTokensPerPool as sp_core::Get>::get() { + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + assert_ok!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) + ); + } + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + assert_err!( + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), + Error::::PoolRewardTokensLimitExceeded + ); + + + + }); +} + #[test] #[serial] fn user_can_claim_3rdparty_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); + + roll_to_session(1); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, ), + Ok(vec![(token_id, 1000)]) + ); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) + roll_to_session(2); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, ), + Ok(vec![(token_id, 2000)]) ); + + + }); } From 0fb361b9bec2b2ba6c00791ddc585438a85bd271 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 20 Sep 2023 15:12:08 +0200 Subject: [PATCH 04/83] wip --- pallets/proof-of-stake/src/lib.rs | 455 ++++++++++++++++------ pallets/proof-of-stake/src/reward_info.rs | 153 +------- pallets/proof-of-stake/src/tests.rs | 178 ++++++++- 3 files changed, 525 insertions(+), 261 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 8f567cb557..12258cf33d 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -55,6 +55,12 @@ pub use pallet::*; pub mod weights; pub use weights::WeightInfo; +#[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] +pub enum ScheduleActivationKind { + ActivateKind(Option), + ActivatedLiquidity(TokenId) +} + type AccountIdOf = ::AccountId; const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!"); @@ -212,6 +218,11 @@ use super::*; pub type TotalActivatedLiquidity = StorageMap<_, Twox64Concat, TokenId, u128, ValueQuery>; + // NOTE: possibly merge with above + #[pallet::storage] + pub type TotalActivatedLiquidity3rdParty = + StorageMap<_, Twox64Concat, TokenId, BTreeMap, ValueQuery>; + #[pallet::call] impl Pallet { /// Claims liquidity mining rewards @@ -270,7 +281,7 @@ use super::*; ) -> DispatchResult { let sender = ensure_signed(origin)?; - >::activate_liquidity( + Self::activate_liquidity_for_liquidity_minting( sender, liquidity_token_id, amount, @@ -329,14 +340,14 @@ use super::*; // TODO: use valuation instead amount directly ensure!(amount_per_session >= T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession); - println!("hello worldd!!!!"); + RewardTokensPerPool::::try_mutate(rewarded_token, |tokens| { - println!("{tokens:?}"); + tokens.try_insert(token_id,()) }).or(Err(Error::::PoolRewardTokensLimitExceeded))?; - println!("{rewarded_token} =>>> {:?}",RewardTokensPerPool::::get(rewarded_token)); + T::Currency::transfer( token_id.into(), @@ -369,54 +380,244 @@ use super::*; Ok(()) } + + /// Increases number of tokens used for liquidity mining purposes. + /// + /// Parameters: + /// - liquidity_token_id - id of the token + /// - amount - amount of the token + /// - use_balance_from - where from tokens should be used + #[transactional] + #[pallet::call_index(5)] + #[pallet::weight(<::WeightInfo>::activate_liquidity())] + pub fn activate_liquidity_for_rewards_schedule( + origin: OriginFor, + liquidity_token_id: TokenId, + amount: Balance, + reward_token: TokenId, + use_balance_from: Option, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + Self::activate_liquidity_for_schedule( + sender, + liquidity_token_id, + amount, + use_balance_from.unwrap_or(ScheduleActivationKind::ActivateKind(None)), + reward_token, + ) + } + + /// Increases number of tokens used for liquidity mining purposes. + /// + /// Parameters: + /// - liquidity_token_id - id of the token + /// - amount - amount of the token + /// - use_balance_from - where from tokens should be used + #[transactional] + #[pallet::call_index(6)] + #[pallet::weight(<::WeightInfo>::activate_liquidity())] + pub fn deactivate_liquidity_for_rewards_schedule( + origin: OriginFor, + liquidity_token_id: TokenId, + amount: Balance, + reward_token: TokenId, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + Self::deactivate_liquidity_for_schedule( + sender, + liquidity_token_id, + amount, + reward_token, + ) + } + } } +pub enum RewardsKind{ + RewardsLiquidityMinting, + Rewards3rdParty(TokenId), +} + impl Pallet { - fn calculate_rewards_amount_3rdparty( + fn activate_liquidity_for_schedule( user: AccountIdOf, liquidity_asset_id: TokenId, - ) -> Result, DispatchError> { + amount: Balance, + use_balance_from: ScheduleActivationKind, + reward_token: TokenId + ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let mut result: sp_std::vec::Vec<_> = Default::default(); + match use_balance_from{ + ScheduleActivationKind::ActivateKind(ref use_balance_from) => { + ensure!( + ::ActivationReservesProvider::can_activate( + liquidity_asset_id, + &user, + amount, + use_balance_from.clone(), + ), + Error::::NotEnoughAssets + ); + }, + ScheduleActivationKind::ActivatedLiquidity(token_id) => { + let already_activated_amount = + UserRewards3rdPartyInfo::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; + let available_amount = + UserRewards3rdPartyInfo::::get(user.clone(), (liquidity_asset_id, token_id)).activated_amount; + println!("already_activated_amount : {already_activated_amount:?}"); + println!("available_amount : {available_amount:?}"); + + ensure!( + already_activated_amount + amount <= available_amount , + Error::::NotEnoughAssets + ); + } + } - // TODO: get rid of collect - let reward_tokens = RewardTokensPerPool::::get(liquidity_asset_id) - .iter() - .map(|(x,_)| *x) - .collect::>(); - - - for i in reward_tokens{ - println!(";iittititiitititit"); - - let rewards_info = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, i)); - println!("REWARDS INFO {rewards_info:?}"); - if let Ok(info) = rewards_info{ - let current_rewards = match info.activated_amount { - 0 => 0u128, - _ => { - let calc = RewardsCalculator::::new2::( - user.clone(), - liquidity_asset_id, - i - )?; - calc.calculate_rewards().map_err(|err| Into::>::into(err))? - }, - }; + Self::set_liquidity_minting_checkpoint_3rdparty(user.clone(), liquidity_asset_id, amount, reward_token)?; - let total_rewards = current_rewards - .checked_add(info.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(info.rewards_already_claimed)) - .ok_or(Error::::CalculateRewardsMathError)?; - result.push((i, total_rewards)); - } + if let ScheduleActivationKind::ActivateKind(use_balance_from) = use_balance_from { + ::ActivationReservesProvider::activate( + liquidity_asset_id, + &user, + amount, + use_balance_from, + )?; } - Ok(result) + + Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); + + Ok(()) + } + + + fn activate_liquidity_for_liquidity_minting( + user: AccountIdOf, + liquidity_asset_id: TokenId, + amount: Balance, + use_balance_from: Option, + ) -> DispatchResult { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + ensure!( + ::ActivationReservesProvider::can_activate( + liquidity_asset_id, + &user, + amount, + use_balance_from.clone() + ), + Error::::NotEnoughAssets + ); + + Self::set_liquidity_minting_checkpoint(user.clone(), liquidity_asset_id, amount)?; + + // This must not fail due storage edits above + ::ActivationReservesProvider::activate( + liquidity_asset_id, + &user, + amount, + use_balance_from, + )?; + Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); + + Ok(()) + } + + fn deactivate_liquidity_for_liquidity_minting( + user: AccountIdOf, + liquidity_asset_id: TokenId, + amount: Balance, + ) -> DispatchResult { + + if amount > 0 { + Self::set_liquidity_burning_checkpoint(user.clone(), liquidity_asset_id, amount)?; + Pallet::::deposit_event(Event::LiquidityDeactivated( + user, + liquidity_asset_id, + amount, + )); + } + Ok(()) + + } + + fn deactivate_liquidity_for_schedule( + user: AccountIdOf, + liquidity_asset_id: TokenId, + amount: Balance, + rewards_asset_id: TokenId + ) -> DispatchResult { + + if amount > 0 { + Self::set_liquidity_burning_checkpoint_for_schedule(user.clone(), liquidity_asset_id, amount, rewards_asset_id)?; + Pallet::::deposit_event(Event::LiquidityDeactivated( + user, + liquidity_asset_id, + amount, + )); + } + Ok(()) } + + + + + fn calculate_rewards_amount_3rdparty( + user: AccountIdOf, + liquidity_asset_id: TokenId, + rewards_asset_id: TokenId, + ) -> Result { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + // let mut result: sp_std::vec::vec<_> = default::default(); + // + // // todo: get rid of collect + // let reward_tokens = rewardtokensperpool::::get(liquidity_asset_id) + // .iter() + // .filter_map(|(token_id,_)| + // userrewards3rdpartyinfo::::try_get(user.clone(), (liquidity_asset_id, token_id)) + // ) + // .map(|info| (info.last_checkpoint, info.activated_amount) + // .sort() + // .first + // .collect::>(); + // + // + + + // let rewards_info = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)); + // + println!("hello world 0000"); + if let Ok(info) = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)){ + println!("hello world"); + let current_rewards = match info.activated_amount { + 0 => 0u128, + _ => { + let calc = RewardsCalculator::::new2::( + user.clone(), + liquidity_asset_id, + rewards_asset_id + )?; + calc.calculate_rewards().map_err(|err| Into::>::into(err))? + }, + }; + + Ok(current_rewards + .checked_add(info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(info.rewards_already_claimed)) + .ok_or(Error::::CalculateRewardsMathError)? + ) + }else{ + Ok(0u128) + } + } + fn pallet_account() -> T::AccountId { PALLET_ID.into_account_truncating() } @@ -444,7 +645,7 @@ impl Pallet { } fn get_pool_rewards_3rdparty(liquidity_asset_id: TokenId, reward_asset_id: TokenId) -> Result { - println!("ret_pool_rewards_3rdparty {liquidity_asset_id} {reward_asset_id}"); + Ok(*PromotedPoolRewards3rdParty::::get() .get(&(liquidity_asset_id, reward_asset_id)) //TODO: no error or some dedicated error @@ -461,12 +662,12 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { - println!("ensure_is_promoted_pool {liquidity_asset_id}"); + if Self::get_pool_rewards(liquidity_asset_id).is_ok() || !RewardTokensPerPool::::get(liquidity_asset_id).is_empty() { - println!("ensure_is_promoted_pool ok"); + Ok(()) } else { - println!("ensure_is_promoted_pool err"); + Err(DispatchError::from(Error::::NotAPromotedPool)) } } @@ -478,32 +679,6 @@ impl Pallet { ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - println!("set_liquidity_minting_checkpoint1"); - - { - let reward_tokens = RewardTokensPerPool::::get(liquidity_asset_id) - .iter() - .map(|(x,_)| *x) - // NOTE: get rid of collect - .collect::>(); - - - for i in reward_tokens{ - let calc = RewardsCalculator::::new2::( - user.clone(), - liquidity_asset_id, - i - )?; - - let rewards_info = calc - .activate_more(liquidity_assets_added) - .map_err(|err| Into::>::into(err))?; - - UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id,i), rewards_info); - } - } - println!("set_liquidity_minting_checkpoint2"); - { let calc = RewardsCalculator::::new::( user.clone(), @@ -512,20 +687,18 @@ impl Pallet { let rewards_info = calc .activate_more(liquidity_assets_added) .map_err(|err| Into::>::into(err))?; + println!("liq minting rewards_info : {rewards_info:?}"); RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); } - - println!("set_liquidity_minting_checkpoint3"); - TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { if let Some(val) = active_amount.checked_add(liquidity_assets_added) { - println!("!!!!!!!!!!!!!!!!!!!!!!!!!"); + *active_amount = val; Ok(()) } else { - println!("$$$$$$$$$$$$$$$$$$$$$$$$$"); + Err(()) } }) @@ -534,6 +707,40 @@ impl Pallet { Ok(()) } + fn set_liquidity_minting_checkpoint_3rdparty( + user: AccountIdOf, + liquidity_asset_id: TokenId, + liquidity_assets_added: Balance, + liquidity_assets_reward: TokenId, + ) -> DispatchResult { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + { + let calc = RewardsCalculator::::new2::( + user.clone(), + liquidity_asset_id, + liquidity_assets_reward + )?; + let rewards_info = calc + .activate_more(liquidity_assets_added) + .map_err(|err| Into::>::into(err))?; + + UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id, liquidity_assets_reward), rewards_info); + } + + + TotalActivatedLiquidity3rdParty::::mutate(liquidity_asset_id, |activations| { + activations + .entry(liquidity_assets_reward) + // NOTE: handle overflow + .and_modify(|val| *val += liquidity_assets_added) + .or_insert(liquidity_assets_added); + + }); + + Ok(()) + } + fn set_liquidity_burning_checkpoint( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -578,6 +785,42 @@ impl Pallet { Ok(()) } + + + fn set_liquidity_burning_checkpoint_for_schedule( + user: AccountIdOf, + liquidity_asset_id: TokenId, + liquidity_assets_burned: Balance, + reward_token: TokenId, + ) -> DispatchResult { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + let calc = RewardsCalculator::::new2::( + user.clone(), + liquidity_asset_id, + reward_token, + )?; + + let rewards_info = calc + .activate_less(liquidity_assets_burned) + .map_err(|err| Into::>::into(err))?; + + UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); + + TotalActivatedLiquidity3rdParty::::mutate(liquidity_asset_id, |activations| { + activations + .entry(reward_token) + .and_modify(|val| *val -= liquidity_assets_burned); + }); + + ::ActivationReservesProvider::deactivate( + liquidity_asset_id, + &user, + liquidity_assets_burned, + ); + + Ok(()) + } } impl ProofOfStakeRewardsApi for Pallet { @@ -657,30 +900,12 @@ impl ProofOfStakeRewardsApi for Pallet { amount: Self::Balance, use_balance_from: Option, ) -> DispatchResult { - Self::ensure_is_promoted_pool(liquidity_asset_id)?; - println!("activate_liquidity"); - ensure!( - ::ActivationReservesProvider::can_activate( - liquidity_asset_id, - &user, - amount, - use_balance_from.clone() - ), - Error::::NotEnoughAssets - ); - - Self::set_liquidity_minting_checkpoint(user.clone(), liquidity_asset_id, amount)?; - - // This must not fail due storage edits above - ::ActivationReservesProvider::activate( + Self::activate_liquidity_for_liquidity_minting( + user, liquidity_asset_id, - &user, amount, use_balance_from, - )?; - Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); - - Ok(()) + ) } fn deactivate_liquidity( @@ -688,16 +913,11 @@ impl ProofOfStakeRewardsApi for Pallet { liquidity_asset_id: Self::CurrencyId, amount: Self::Balance, ) -> DispatchResult { - if amount > 0 { - Self::set_liquidity_burning_checkpoint(user.clone(), liquidity_asset_id, amount)?; - Pallet::::deposit_event(Event::LiquidityDeactivated( - user, - liquidity_asset_id, - amount, - )); - } - - Ok(()) + Self::deactivate_liquidity_for_liquidity_minting( + user, + liquidity_asset_id, + amount, + ) } @@ -737,7 +957,7 @@ impl LiquidityMiningApi for Pallet { let it = schedules .iter() .filter_map(|((session, rewarded_token, tokenid, amount, _),())|{ - if (*session).saturated_into::() > Self::session_index() { + if (*session).saturated_into::() >= Self::session_index() { Some((rewarded_token, tokenid, amount)) } else { None @@ -745,22 +965,27 @@ impl LiquidityMiningApi for Pallet { }); for (staked_token, token, amount) in it { - println!("STAKED TOKEN: {staked_token} TOKEN: {token} AMOUNT: {amount}"); - let activated_amount = Self::total_activated_amount(staked_token); - println!("ACTIVATED AMOUNT: {activated_amount}"); - // NOTE: fix - let rewards = pools.get(&(*staked_token, *token)).cloned().unwrap_or_default(); - let rewards_for_liquidity = U256::from(*amount) - .checked_mul(U256::from(u128::MAX)) - .and_then(|x| x.checked_div(activated_amount.into())) - .and_then(|x| x.checked_add(rewards)); + let activated_3rdparty_rewards = TotalActivatedLiquidity3rdParty::::get(staked_token); + + if let Some(activated_amount) = activated_3rdparty_rewards.get(&token){ + let activated_amount = U256::from(*activated_amount); + // NOTE: fix + let rewards = pools.get(&(*staked_token, *token)).cloned().unwrap_or_default(); + let rewards_for_liquidity = U256::from(*amount) + .checked_mul(U256::from(u128::MAX)) + .and_then(|x| x.checked_div(activated_amount)) + .and_then(|x| x.checked_add(rewards)); + if let Some(val) = rewards_for_liquidity { pools.insert((*staked_token,*token), val); } + + } } - println!("STORING POOLS: {pools:?}"); + + println!("POOLS : {:?}", pools); PromotedPoolRewards3rdParty::::put(pools); diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 0e042cb004..e5321722bd 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -94,8 +94,12 @@ impl RewardsCalculator { missing_at_last_checkpoint: U256::from(0u128), }; - let rewards_info = crate::RewardsInfo::::try_get(user.clone(), asset_id) - .unwrap_or(default_rewards); + + let rewards_info = crate::UserRewards3rdPartyInfo::::try_get( + user.clone(), + (asset_id, reward_asset_id) + ).unwrap_or(default_rewards); + Ok(Self { rewards_context: RewardsContext { @@ -178,12 +182,16 @@ impl CurveRewards for ConstCurveRewards { } fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { - println!("context: {:?}", ctx.pool_ratio_current); + + println!("pool_ratio_at_last_checkpoint {}", user_info.pool_ratio_at_last_checkpoint); + println!("pool_ratio now {}", ctx.pool_ratio_current); let pool_rewards_ratio_new = ctx.pool_ratio_current.checked_sub(user_info.pool_ratio_at_last_checkpoint)?; + let rewards_base: U256 = U256::from(user_info.activated_amount) .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 + println!("BASE : {rewards_base}"); rewards_base @@ -226,6 +234,7 @@ impl RewardsCalculator { .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) .ok_or(RewardsCalcError::CheckpointMathError)?; + println!("STORING {}", self.rewards_context.pool_ratio_current); Ok(RewardInfo { activated_amount, pool_ratio_at_last_checkpoint: self.rewards_context.pool_ratio_current, @@ -286,141 +295,3 @@ impl RewardsCalculator { .ok_or(RewardsCalcError::CheckpointMathError) } } - -// impl RewardInfo { -// pub fn calculate_missing_at_checkpoint(&self, current_time: u32) -> Option { -// let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); -// let q_pow = calculate_q_pow(Q, time_passed); -// Some(self.missing_at_last_checkpoint * U256::from(REWARDS_PRECISION) / q_pow) -// } -// -// pub fn activate_more( -// &mut self, -// current_time: u32, -// pool_ratio_current: U256, -// liquidity_assets_added: Balance, -// ) -> DispatchResult { -// let activated_amount = self -// .activated_amount -// .checked_add(liquidity_assets_added) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// let missing_at_last_checkpoint = self -// .calculate_missing_at_checkpoint(current_time) -// .and_then(|v| v.checked_add(U256::from(liquidity_assets_added))) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// let user_current_rewards = self -// .calculate_rewards(current_time, pool_ratio_current) -// .ok_or(Error::::CalculateRewardsMathError)?; -// -// let rewards_not_yet_claimed = user_current_rewards -// .checked_add(self.rewards_not_yet_claimed) -// .and_then(|v| v.checked_sub(self.rewards_already_claimed)) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// self.activated_amount = activated_amount; -// self.pool_ratio_at_last_checkpoint = pool_ratio_current; -// self.rewards_already_claimed = 0_u128; -// self.missing_at_last_checkpoint = missing_at_last_checkpoint; -// self.rewards_not_yet_claimed = rewards_not_yet_claimed; -// self.last_checkpoint = current_time; -// Ok(()) -// } -// -// pub fn activate_less( -// &mut self, -// current_time: u32, -// pool_ratio_current: U256, -// liquidity_assets_removed: Balance, -// ) -> DispatchResult { -// let activated_amount = self -// .activated_amount -// .checked_sub(liquidity_assets_removed) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// let missing_at_checkpoint_new = self -// .calculate_missing_at_checkpoint(current_time) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// let activated_amount_new = self -// .activated_amount -// .checked_sub(liquidity_assets_removed) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// let missing_at_checkpoint_after_burn = U256::from(activated_amount_new) -// .checked_mul(missing_at_checkpoint_new) -// .and_then(|v| v.checked_div(self.activated_amount.into())) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// let user_current_rewards = self -// .calculate_rewards(current_time, pool_ratio_current) -// .ok_or(Error::::CalculateRewardsMathError)?; -// let total_available_rewards = user_current_rewards -// .checked_add(self.rewards_not_yet_claimed) -// .and_then(|v| v.checked_sub(self.rewards_already_claimed)) -// .ok_or(Error::::LiquidityCheckpointMathError)?; -// -// self.activated_amount = activated_amount; -// self.pool_ratio_at_last_checkpoint = pool_ratio_current; -// self.rewards_already_claimed = 0_u128; -// self.missing_at_last_checkpoint = missing_at_checkpoint_after_burn; -// self.rewards_not_yet_claimed = total_available_rewards; -// self.last_checkpoint = current_time; -// Ok(()) -// } -// -// pub fn calculate_rewards( -// &self, -// current_time: u32, -// pool_rewards_ratio_current: U256, -// ) -> Option { -// let pool_rewards_ratio_new = -// pool_rewards_ratio_current.checked_sub(self.pool_ratio_at_last_checkpoint)?; -// -// let user_rewards_base: U256 = U256::from(self.activated_amount) -// .checked_mul(pool_rewards_ratio_new)? -// .checked_div(U256::from(u128::MAX))?; // always fit into u128 -// -// self.calculate_curve_rewards(user_rewards_base, current_time) -// } -// -// fn calculate_curve_rewards(&self, base_rewards: U256, current_time: u32) -> Option { -// let time_passed = current_time.checked_sub(self.last_checkpoint).unwrap(); -// // .ok_or(Error::::PastTimeCalculation)?; -// let mut cummulative_work = U256::from(0); -// let mut cummulative_work_max_possible_for_ratio = U256::from(1); -// -// if time_passed != 0 && self.activated_amount != 0 { -// let liquidity_assets_amount_u256: U256 = self.activated_amount.into(); -// -// // whole formula: missing_at_last_checkpoint*106/6 - missing_at_last_checkpoint*106*precision/6/q_pow -// // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well -// -// cummulative_work_max_possible_for_ratio = -// liquidity_assets_amount_u256.checked_mul(U256::from(time_passed))?; -// -// // whole formula: missing_at_last_checkpoint*Q*100/(Q*100-100) - missing_at_last_checkpoint*Q*100/(Q*100-100)*REWARDS_PRECISION/q_pow -// // q_pow is multiplied by precision, thus there needs to be *precision in numenator as well -// let base = self -// .missing_at_last_checkpoint -// .checked_mul(U256::from(libm::floor(Q * 100_f64) as u128))? -// .checked_div(U256::from(libm::floor(Q * 100_f64 - 100_f64) as u128))?; -// -// let q_pow = calculate_q_pow(Q, time_passed.checked_add(1)?); -// -// let cummulative_missing_new = base - -// base * U256::from(REWARDS_PRECISION) / q_pow - -// self.missing_at_last_checkpoint; -// -// cummulative_work = -// cummulative_work_max_possible_for_ratio.checked_sub(cummulative_missing_new)? -// } -// -// base_rewards -// .checked_mul(cummulative_work)? -// .checked_div(cummulative_work_max_possible_for_ratio)? -// .try_into() -// .ok() -// -// } -// } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index b3f1373736..a7255d1daa 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1368,22 +1368,190 @@ fn user_can_claim_3rdparty_rewards() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, ), - Ok(vec![(token_id, 1000)]) + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), + Ok(0) ); + + roll_to_session(2); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), + Ok(1000) + ); + + roll_to_session(3); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), + Ok(1500) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), + Ok(500) + ); + }); +} + +#[test] +#[serial] +fn overlapping_3rdparty_rewards_works() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_reward_token, amount, 10u32.into()).unwrap(); + + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None).unwrap(); + + roll_to_session(5); + let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into()).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, None).unwrap(); + + roll_to_session(6); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_reward_token_id), + Ok(10000) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_reward_token), + Ok(5000) + ); + + }); +} + + +#[test] +#[serial] +fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_reward_token, amount, 10u32.into()).unwrap(); + + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None).unwrap(); + + roll_to_session(5); + let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into()).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_reward_token)) ).unwrap(); + + roll_to_session(6); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_reward_token_id), + Ok(10000) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_reward_token), + Ok(5000) + ); + }); +} + + +#[test] +#[serial] +fn deactivate_3rdparty_rewards() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + roll_to_session(2); + assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, ), - Ok(vec![(token_id, 2000)]) + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), + Ok(500) ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), + Ok(500) + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id).unwrap(); + roll_to_session(3); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), + Ok(1500) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), + Ok(500) + ); }); } + From 5beb83b9238ae6b4d4847e7d09def73bf1f75418 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 21 Sep 2023 07:01:35 +0200 Subject: [PATCH 05/83] nmap --- pallets/proof-of-stake/src/lib.rs | 383 +++++++++++++--------- pallets/proof-of-stake/src/reward_info.rs | 24 +- pallets/proof-of-stake/src/tests.rs | 224 +++++++++++-- 3 files changed, 433 insertions(+), 198 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 12258cf33d..9448a9ac16 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -55,14 +55,20 @@ pub use pallet::*; pub mod weights; pub use weights::WeightInfo; +type AccountIdOf = ::AccountId; + + +/// Wrapper over origin ActivateKind that is used in [`Pallet::activat_liquidity`] +/// with extension that allows activating liquidity that was already used for: +/// - `ActivatedLiquidity` - already activated liquidity (for scheduled rewards) +/// - `LiquidityMining` - already activated liquidity (for liquidity mining rewards) #[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] pub enum ScheduleActivationKind { ActivateKind(Option), - ActivatedLiquidity(TokenId) + ActivatedLiquidity(TokenId), + LiquidityMining, } -type AccountIdOf = ::AccountId; - const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!"); #[frame_support::pallet] @@ -104,8 +110,11 @@ use super::*; type LiquidityMiningIssuanceVault: Get; #[pallet::constant] type RewardsDistributionPeriod: Get; + /// The maximum number of schedules that can be active at one moment type RewardsSchedulesLimit: Get; + /// The minimum number of rewards per session for schedule rewards type MinRewardsPerSession: Get; + /// The maximum number of reward tokens per pool type MaxRewardTokensPerPool: Get; type WeightInfo: WeightInfo; type ValuationApi: Valuate; @@ -130,11 +139,14 @@ use super::*; CalculateRewardsAllMathError, MissingRewardsInfoError, DeprecatedExtrinsic, + /// Cannot schedule rewards in past CannotScheduleRewardsInPast, + /// Pool does not exist PoolDoesNotExist, + /// Too many schedules TooManySchedules, + /// Too little rewards per session TooLittleRewardsPerSession, - PoolRewardTokensLimitExceeded, } #[pallet::event] @@ -158,17 +170,6 @@ use super::*; ValueQuery, >; - #[pallet::storage] - pub type UserRewards3rdPartyInfo = StorageDoubleMap< - _, - Twox64Concat, - AccountIdOf, - Twox64Concat, - (TokenId, TokenId), - RewardInfo, - ValueQuery, - >; - #[pallet::storage] /// Stores information about pool weight and accumulated rewards. The accumulated /// rewards amount is the number of rewards that can be claimed per liquidity @@ -177,31 +178,6 @@ use super::*; pub type PromotedPoolRewards = StorageValue<_, BTreeMap, ValueQuery>; - #[pallet::storage] - pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; - - // pub type PromotedPoolRewards3rdParty = StorageValue<_, BTreeMap<(TokenId), U256>, ValueQuery>; - - #[pallet::storage] - #[pallet::getter(fn schedules)] - pub type RewardsSchedules = - StorageValue<_, BoundedBTreeMap<(T::BlockNumber, TokenId, TokenId, Balance, u64), (), T::RewardsSchedulesLimit>, ValueQuery>; - - #[pallet::storage] - pub type RewardTokensPerPool = StorageMap<_, Twox64Concat, TokenId, BoundedBTreeMap, ValueQuery>; - - #[pallet::storage] - pub type ScheduleId = StorageValue<_, u64, ValueQuery>; - - - // #[pallet::storage] - // pub type Rewards3rdParty = - // StorageValue<_, BTreeMap, ValueQuery>; - // - // #[pallet::storage] - // pub type Rewards3rdParty = - // StorageValue<_, BTreeMap, ValueQuery>; - #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] /// Information about single token rewards pub struct PromotedPools { @@ -218,11 +194,77 @@ use super::*; pub type TotalActivatedLiquidity = StorageMap<_, Twox64Concat, TokenId, u128, ValueQuery>; - // NOTE: possibly merge with above + // ////////////////////////////////////////////////////////////////////////////////////////////// + // 3rd Party Rewards + // ////////////////////////////////////////////////////////////////////////////////////////////// + + /// Stores information about pool weight and accumulated rewards #[pallet::storage] - pub type TotalActivatedLiquidity3rdParty = + pub type RewardsInfoForScheduleRewards = StorageDoubleMap< + _, + Twox64Concat, + AccountIdOf, + Twox64Concat, + (TokenId, TokenId), + RewardInfo, + ValueQuery, + >; + + /// How much scheduled rewards per single liquidty_token should be distribute_rewards + /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic + #[pallet::storage] + pub type ScheduleRewardsPerSingleLiquidity = StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; + + /// List of activated schedules sorted by expiry date + #[pallet::storage] + #[pallet::getter(fn schedules)] + pub type RewardsSchedules = + StorageValue<_, BoundedBTreeMap<(T::BlockNumber, TokenId, TokenId, Balance, u64), (), T::RewardsSchedulesLimit>, ValueQuery>; + + /// Unique id of the schedule + #[pallet::storage] + pub type ScheduleId = StorageValue<_, u64, ValueQuery>; + + /// Maps liquidity token to list of tokens that it ever was rewarded with + #[pallet::storage] + pub type RewardTokensPerPool = StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (), ValueQuery>; + + /// Total amount of activated liquidity for each schedule + /// `BTreeMap` is used because of storage reads write optiomization in `distribute_rewards` + #[pallet::storage] + pub type TotalActivatedLiquidityForSchedules = StorageMap<_, Twox64Concat, TokenId, BTreeMap, ValueQuery>; + /// Tracks how much liquidity user activated for particular (liq token, reward token) pair + /// StorageNMap was used because it only require single read to know if user deactivated all + /// liquidity associated with particular liquidity_token that is rewarded. If so part of the + /// liquididty tokens can be unlocked. + #[pallet::storage] + pub type ActivatedLiquidityForSchedules = StorageNMap< + _, + ( + NMapKey>, + NMapKey, + NMapKey + ), + u128, + OptionQuery, + >; + + /// Tracks how much of the liquidity was activated for schedule rewards and not yet + /// liquidity mining rewards. That information is essential to properly handle tocken unlcocks + /// when liquidity is deactivated. + #[pallet::storage] + pub type ActivatedLockedLiquidityForSchedules = StorageDoubleMap< + _, + Twox64Concat, + AccountIdOf, + Twox64Concat, + TokenId, + u128, + ValueQuery, + >; + #[pallet::call] impl Pallet { /// Claims liquidity mining rewards @@ -310,10 +352,11 @@ use super::*; /// Schedules rewards for selected liquidity token /// - tokens - pair of tokens /// - amount - amount of the token - /// - schedule_end - till when the rewards should be distributed, rewards are - /// distributed starting from the *next* session till + /// - schedule_end - id of the last rewarded seession. Rewards will be distributedd equally between sessions in range (now .. + /// schedule_end). Distribution starts from the *next* session till `schedule_end`. #[transactional] #[pallet::call_index(4)] + // NOTE: implement benchmark #[pallet::weight(<::WeightInfo>::claim_rewards_all())] pub fn reward_pool( origin: OriginFor, @@ -342,12 +385,7 @@ use super::*; ensure!(amount_per_session >= T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession); - RewardTokensPerPool::::try_mutate(rewarded_token, |tokens| { - - tokens.try_insert(token_id,()) - }).or(Err(Error::::PoolRewardTokensLimitExceeded))?; - - + RewardTokensPerPool::::insert(rewarded_token, token_id, ()); T::Currency::transfer( token_id.into(), @@ -386,7 +424,8 @@ use super::*; /// Parameters: /// - liquidity_token_id - id of the token /// - amount - amount of the token - /// - use_balance_from - where from tokens should be used + /// - use_balance_from - where from tokens should be used. If set to `None` then tokens will + /// be taken from available balance #[transactional] #[pallet::call_index(5)] #[pallet::weight(<::WeightInfo>::activate_liquidity())] @@ -443,59 +482,6 @@ pub enum RewardsKind{ impl Pallet { - fn activate_liquidity_for_schedule( - user: AccountIdOf, - liquidity_asset_id: TokenId, - amount: Balance, - use_balance_from: ScheduleActivationKind, - reward_token: TokenId - ) -> DispatchResult { - Self::ensure_is_promoted_pool(liquidity_asset_id)?; - - match use_balance_from{ - ScheduleActivationKind::ActivateKind(ref use_balance_from) => { - ensure!( - ::ActivationReservesProvider::can_activate( - liquidity_asset_id, - &user, - amount, - use_balance_from.clone(), - ), - Error::::NotEnoughAssets - ); - }, - ScheduleActivationKind::ActivatedLiquidity(token_id) => { - let already_activated_amount = - UserRewards3rdPartyInfo::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; - let available_amount = - UserRewards3rdPartyInfo::::get(user.clone(), (liquidity_asset_id, token_id)).activated_amount; - println!("already_activated_amount : {already_activated_amount:?}"); - println!("available_amount : {available_amount:?}"); - - ensure!( - already_activated_amount + amount <= available_amount , - Error::::NotEnoughAssets - ); - } - } - - Self::set_liquidity_minting_checkpoint_3rdparty(user.clone(), liquidity_asset_id, amount, reward_token)?; - - if let ScheduleActivationKind::ActivateKind(use_balance_from) = use_balance_from { - ::ActivationReservesProvider::activate( - liquidity_asset_id, - &user, - amount, - use_balance_from, - )?; - } - - Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); - - Ok(()) - } - - fn activate_liquidity_for_liquidity_minting( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -516,7 +502,6 @@ impl Pallet { Self::set_liquidity_minting_checkpoint(user.clone(), liquidity_asset_id, amount)?; - // This must not fail due storage edits above ::ActivationReservesProvider::activate( liquidity_asset_id, &user, @@ -546,6 +531,73 @@ impl Pallet { } + fn activate_liquidity_for_schedule( + user: AccountIdOf, + liquidity_asset_id: TokenId, + amount: Balance, + use_balance_from: ScheduleActivationKind, + reward_token: TokenId + ) -> DispatchResult { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + match use_balance_from{ + ScheduleActivationKind::ActivateKind(ref use_balance_from) => { + ensure!( + ::ActivationReservesProvider::can_activate( + liquidity_asset_id, + &user, + amount, + use_balance_from.clone(), + ), + Error::::NotEnoughAssets + ); + ActivatedLockedLiquidityForSchedules::::mutate(user.clone(), liquidity_asset_id, |val| *val += amount); + }, + ScheduleActivationKind::ActivatedLiquidity(token_id) => { + let already_activated_amount = + RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; + let available_amount = + RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, token_id)).activated_amount; + ensure!( + already_activated_amount + amount <= available_amount , + Error::::NotEnoughAssets + ); + } + ScheduleActivationKind::LiquidityMining => { + let already_activated_amount = + RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; + let available_amount = + RewardsInfo::::get(user.clone(), liquidity_asset_id).activated_amount; + ensure!( + already_activated_amount + amount <= available_amount , + Error::::NotEnoughAssets + ); + }, + } + + Self::set_liquidity_minting_checkpoint_3rdparty(user.clone(), liquidity_asset_id, amount, reward_token)?; + + match use_balance_from { + ScheduleActivationKind::ActivateKind(use_balance_from) => { + ::ActivationReservesProvider::activate( + liquidity_asset_id, + &user, + amount, + use_balance_from, + )?; + }, + ScheduleActivationKind::LiquidityMining => { + }, + _ => {} + + } + + Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); + + Ok(()) + } + + fn deactivate_liquidity_for_schedule( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -575,31 +627,11 @@ impl Pallet { ) -> Result { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - // let mut result: sp_std::vec::vec<_> = default::default(); - // - // // todo: get rid of collect - // let reward_tokens = rewardtokensperpool::::get(liquidity_asset_id) - // .iter() - // .filter_map(|(token_id,_)| - // userrewards3rdpartyinfo::::try_get(user.clone(), (liquidity_asset_id, token_id)) - // ) - // .map(|info| (info.last_checkpoint, info.activated_amount) - // .sort() - // .first - // .collect::>(); - // - // - - - // let rewards_info = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)); - // - println!("hello world 0000"); - if let Ok(info) = UserRewards3rdPartyInfo::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)){ - println!("hello world"); + if let Ok(info) = RewardsInfoForScheduleRewards::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)){ let current_rewards = match info.activated_amount { 0 => 0u128, _ => { - let calc = RewardsCalculator::::new2::( + let calc = RewardsCalculator::schedule_rewards::( user.clone(), liquidity_asset_id, rewards_asset_id @@ -644,15 +676,6 @@ impl Pallet { .ok_or(Error::::NotAPromotedPool)?) } - fn get_pool_rewards_3rdparty(liquidity_asset_id: TokenId, reward_asset_id: TokenId) -> Result { - - Ok(*PromotedPoolRewards3rdParty::::get() - .get(&(liquidity_asset_id, reward_asset_id)) - //TODO: no error or some dedicated error - .ok_or(Error::::NotAPromotedPool)?) - } - - fn get_current_rewards_time() -> Result { >::block_number() .saturated_into::() @@ -662,12 +685,9 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { - - if Self::get_pool_rewards(liquidity_asset_id).is_ok() || !RewardTokensPerPool::::get(liquidity_asset_id).is_empty() { - + if Self::get_pool_rewards(liquidity_asset_id).is_ok() || RewardTokensPerPool::::iter_prefix_values(liquidity_asset_id).next().is_some() { Ok(()) } else { - Err(DispatchError::from(Error::::NotAPromotedPool)) } } @@ -680,14 +700,13 @@ impl Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; { - let calc = RewardsCalculator::::new::( + let calc = RewardsCalculator::mining_rewards::( user.clone(), liquidity_asset_id, )?; let rewards_info = calc .activate_more(liquidity_assets_added) .map_err(|err| Into::>::into(err))?; - println!("liq minting rewards_info : {rewards_info:?}"); RewardsInfo::::insert(user.clone(), liquidity_asset_id, rewards_info); } @@ -716,7 +735,7 @@ impl Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; { - let calc = RewardsCalculator::::new2::( + let calc = RewardsCalculator::schedule_rewards::( user.clone(), liquidity_asset_id, liquidity_assets_reward @@ -724,12 +743,26 @@ impl Pallet { let rewards_info = calc .activate_more(liquidity_assets_added) .map_err(|err| Into::>::into(err))?; - - UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id, liquidity_assets_reward), rewards_info); + RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, liquidity_assets_reward), rewards_info); } + ActivatedLiquidityForSchedules::::try_mutate_exists( + (user.clone(), liquidity_asset_id, liquidity_assets_reward ), + |v| + { + match v { + Some(x) => { + v.as_mut().map(|a| *a += liquidity_assets_added); + }, + None => { + *v = Some(liquidity_assets_added); + }, + }; + Ok::<(),Error>(()) + } + )?; - TotalActivatedLiquidity3rdParty::::mutate(liquidity_asset_id, |activations| { + TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { activations .entry(liquidity_assets_reward) // NOTE: handle overflow @@ -757,7 +790,7 @@ impl Pallet { Error::::NotEnoughAssets ); - let calc = RewardsCalculator::::new::( + let calc = RewardsCalculator::mining_rewards::( user.clone(), liquidity_asset_id, )?; @@ -795,7 +828,7 @@ impl Pallet { ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let calc = RewardsCalculator::::new2::( + let calc = RewardsCalculator::schedule_rewards::( user.clone(), liquidity_asset_id, reward_token, @@ -805,19 +838,48 @@ impl Pallet { .activate_less(liquidity_assets_burned) .map_err(|err| Into::>::into(err))?; - UserRewards3rdPartyInfo::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); + RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); - TotalActivatedLiquidity3rdParty::::mutate(liquidity_asset_id, |activations| { + TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { activations .entry(reward_token) .and_modify(|val| *val -= liquidity_assets_burned); }); - ::ActivationReservesProvider::deactivate( - liquidity_asset_id, - &user, - liquidity_assets_burned, - ); + ActivatedLiquidityForSchedules::::try_mutate_exists( + (user.clone(), liquidity_asset_id, reward_token), + |v| + { + v.and_then(|a| a.checked_sub(liquidity_assets_burned) + .and_then(|val| { + if val > 0 { + *v = Some(val); + }else{ + *v = None; + } + Some(val) + }) + ).ok_or(Error::::MathOverflow) + } + )?; + + + + if let None = ActivatedLiquidityForSchedules::::iter_prefix_values( (user.clone(), liquidity_asset_id), + ).next(){ + + let amount = ActivatedLockedLiquidityForSchedules::::mutate(user.clone(), liquidity_asset_id, |val| { + let prev = *val; + *val = 0; + prev + }); + + ::ActivationReservesProvider::deactivate( + liquidity_asset_id, + &user, + amount, + ); + } Ok(()) } @@ -860,7 +922,7 @@ impl ProofOfStakeRewardsApi for Pallet { let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; - let calc = RewardsCalculator::::new::( + let calc = RewardsCalculator::mining_rewards::( user.clone(), liquidity_asset_id, )?; @@ -932,7 +994,7 @@ impl ProofOfStakeRewardsApi for Pallet { let current_rewards = match rewards_info.activated_amount { 0 => 0u128, _ => { - let calc = RewardsCalculator::::new::( + let calc = RewardsCalculator::mining_rewards::( user.clone(), liquidity_asset_id, )?; @@ -952,7 +1014,7 @@ impl LiquidityMiningApi for Pallet { fn distribute_rewards(liquidity_mining_rewards: Balance) { let schedules = RewardsSchedules::::get(); - let mut pools = PromotedPoolRewards3rdParty::::get(); + let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); let it = schedules .iter() @@ -966,7 +1028,7 @@ impl LiquidityMiningApi for Pallet { for (staked_token, token, amount) in it { - let activated_3rdparty_rewards = TotalActivatedLiquidity3rdParty::::get(staked_token); + let activated_3rdparty_rewards = TotalActivatedLiquidityForSchedules::::get(staked_token); if let Some(activated_amount) = activated_3rdparty_rewards.get(&token){ let activated_amount = U256::from(*activated_amount); @@ -985,8 +1047,7 @@ impl LiquidityMiningApi for Pallet { } } - println!("POOLS : {:?}", pools); - PromotedPoolRewards3rdParty::::put(pools); + ScheduleRewardsPerSingleLiquidity::::put(pools); let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index e5321722bd..d2707536b8 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -44,8 +44,8 @@ pub struct RewardsCalculator { _curve: sp_std::marker::PhantomData, } -impl RewardsCalculator { - pub fn new( +impl RewardsCalculator { + pub fn mining_rewards( user: T::AccountId, asset_id: TokenId, ) -> sp_std::result::Result { @@ -74,17 +74,27 @@ impl RewardsCalculator { } } -impl RewardsCalculator { - pub fn new2( +impl RewardsCalculator { + pub fn schedule_rewards( user: T::AccountId, asset_id: TokenId, reward_asset_id: TokenId, ) -> sp_std::result::Result { let current_time: u32 = Pallet::::get_current_rewards_time()?; + ensure!( + crate::RewardTokensPerPool::::try_get(asset_id, reward_asset_id).is_ok(), + crate::Error::::NotAPromotedPool + ); + + let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); + + let pool_ratio_current = pool_map.get(&(asset_id, reward_asset_id)) + .cloned() + .unwrap_or(U256::from(0)); + + - // TODO: do not ignore error - let pool_ratio_current = Pallet::::get_pool_rewards_3rdparty(asset_id, reward_asset_id).unwrap_or_default(); let default_rewards = RewardInfo { activated_amount: 0_u128, rewards_not_yet_claimed: 0_u128, @@ -95,7 +105,7 @@ impl RewardsCalculator { }; - let rewards_info = crate::UserRewards3rdPartyInfo::::try_get( + let rewards_info = crate::RewardsInfoForScheduleRewards::::try_get( user.clone(), (asset_id, reward_asset_id) ).unwrap_or(default_rewards); diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index a7255d1daa..ed9bfb4521 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1312,36 +1312,6 @@ fn reject_schedule_with_too_little_rewards_per_session() { }); } -#[test] -#[serial] -fn number_of_reward_tokens_per_pool_is_limited() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - for _ in 0..<::MaxRewardTokensPerPool as sp_core::Get>::get() { - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) - ); - } - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), - Error::::PoolRewardTokensLimitExceeded - ); - - - - }); -} - - #[test] #[serial] fn user_can_claim_3rdparty_rewards() { @@ -1555,3 +1525,197 @@ fn deactivate_3rdparty_rewards() { }); } + +#[test] +#[serial] +fn claim_rewards_from_multiple_schedules_using_single_liquidity() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), + Ok(0) + ); + + roll_to_session(1); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), + Ok(1000) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), + Ok(2000) + ); + + }); +} + +#[test] +#[serial] +fn liquidity_minting_liquidity_can_be_resused() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + + ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, Some(ScheduleActivationKind::LiquidityMining)).unwrap(); + + roll_to_session(1); + + assert_eq!( + ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), + Ok(200) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), + Ok(1000) + ); + + }); +} + +#[test] +#[serial] +fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + + ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); + assert_err!( + TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + orml_tokens::Error::::BalanceTooLow + ); + + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, Some(ScheduleActivationKind::LiquidityMining)).unwrap(); + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); + + ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 200, first_token_id).unwrap(); + assert_err!( + TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 101, ExistenceRequirement::AllowDeath), + orml_tokens::Error::::BalanceTooLow + ); + + assert_ok!( + TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath) + ); + }); +} + +#[test] +#[serial] +fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + + assert_err!( + TokensOf::::transfer(0, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + orml_tokens::Error::::BalanceTooLow + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id).unwrap(); + assert_err!( + TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + orml_tokens::Error::::BalanceTooLow + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id).unwrap(); + + assert_ok!( + TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + ); + }); +} + From d26c215d5ff1066643de81058ff158168f983258 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Sep 2023 10:43:35 +0200 Subject: [PATCH 06/83] schedule rewards extrinsics --- pallets/proof-of-stake/src/lib.rs | 76 ++++++++++++++++++----- pallets/proof-of-stake/src/reward_info.rs | 19 ++++-- pallets/proof-of-stake/src/tests.rs | 67 ++++++++++++++++++++ 3 files changed, 144 insertions(+), 18 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 9448a9ac16..ebb87cf1dc 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -447,7 +447,7 @@ use super::*; ) } - /// Increases number of tokens used for liquidity mining purposes. + /// Decreases number of tokens used for liquidity mining purposes. /// /// Parameters: /// - liquidity_token_id - id of the token @@ -472,6 +472,28 @@ use super::*; ) } + /// Claims liquidity mining rewards + /// - tokens - pair of tokens + /// - amount - amount of the token + /// - reward_token - id of the token that is rewarded + #[transactional] + #[pallet::call_index(7)] + #[pallet::weight(<::WeightInfo>::activate_liquidity())] + pub fn claim_schedule_rewards_all( + origin: OriginFor, + liquidity_token_id: TokenId, + reward_token: TokenId, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + Self::claim_schedule_rewards_all_impl( + sender, + liquidity_token_id, + reward_token, + )?; + Ok(()) + } + } } @@ -883,6 +905,41 @@ impl Pallet { Ok(()) } + + fn claim_schedule_rewards_all_impl( + user: T::AccountId, + liquidity_asset_id: TokenId, + reward_token: TokenId, + ) -> Result { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + + let calc = RewardsCalculator::schedule_rewards::( + user.clone(), + liquidity_asset_id, + reward_token, + )?; + let (rewards_info, total_available_rewards) = calc.claim_rewards() + .map_err(|err| Into::>::into(err))?; + + ::Currency::transfer( + reward_token.into(), + &Self::pallet_account(), + &user, + total_available_rewards.into(), + ExistenceRequirement::KeepAlive, + )?; + + RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); + + Pallet::::deposit_event(Event::RewardsClaimed( + user, + liquidity_asset_id, + total_available_rewards, + )); + + Ok(total_available_rewards) + } + } impl ProofOfStakeRewardsApi for Pallet { @@ -913,29 +970,19 @@ impl ProofOfStakeRewardsApi for Pallet { PromotedPoolRewards::::get().contains_key(&liquidity_token_id) } + fn claim_rewards_all( user: T::AccountId, liquidity_asset_id: Self::CurrencyId, ) -> Result { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let mut rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) - .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; - let calc = RewardsCalculator::mining_rewards::( user.clone(), liquidity_asset_id, )?; - let current_rewards = - calc.calculate_rewards().map_err(|err| Into::>::into(err))?; - - let total_available_rewards = current_rewards - .checked_add(rewards_info.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(rewards_info.rewards_already_claimed)) - .ok_or(Error::::CalculateRewardsAllMathError)?; - - rewards_info.rewards_not_yet_claimed = 0_u128; - rewards_info.rewards_already_claimed = current_rewards; + let (rewards_info, total_available_rewards) = calc.claim_rewards() + .map_err(|err| Into::>::into(err))?; ::Currency::transfer( Self::native_token_id().into(), @@ -956,6 +1003,7 @@ impl ProofOfStakeRewardsApi for Pallet { Ok(total_available_rewards) } + fn activate_liquidity( user: T::AccountId, liquidity_asset_id: Self::CurrencyId, diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index d2707536b8..29403f7291 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -193,8 +193,6 @@ impl CurveRewards for ConstCurveRewards { fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { - println!("pool_ratio_at_last_checkpoint {}", user_info.pool_ratio_at_last_checkpoint); - println!("pool_ratio now {}", ctx.pool_ratio_current); let pool_rewards_ratio_new = ctx.pool_ratio_current.checked_sub(user_info.pool_ratio_at_last_checkpoint)?; @@ -202,8 +200,6 @@ impl CurveRewards for ConstCurveRewards { .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 - println!("BASE : {rewards_base}"); - rewards_base .try_into() .ok() @@ -296,6 +292,21 @@ impl RewardsCalculator { }) } + pub fn claim_rewards(self) -> sp_std::result::Result<(RewardInfo, Balance), RewardsCalcError>{ + let current_rewards = self.calculate_rewards_impl()?; + + let total_available_rewards = current_rewards + .checked_add(self.rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) + .ok_or(RewardsCalcError::CheckpointMathError)?; + + let mut info = self.rewards_info.clone(); + + info.rewards_not_yet_claimed = 0_u128; + info.rewards_already_claimed = current_rewards; + Ok((info, total_available_rewards)) + } + pub fn calculate_rewards(self) -> sp_std::result::Result { self.calculate_rewards_impl() } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index ed9bfb4521..1608d5abd3 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1719,3 +1719,70 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() }); } + +#[test] +#[serial] +fn can_claim_schedule_rewards() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN : u32 = 5; + let valuation_mock = MockValuationApi::get_liquidity_asset_context(); + valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + + roll_to_session(1); + + assert_eq!( + TokensOf::::free_balance(first_token_id, &BOB), + 0, + ); + assert_eq!( + TokensOf::::free_balance(second_token_id, &BOB), + 0, + ); + + ProofOfStake::claim_schedule_rewards_all( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + first_token_id, + ).unwrap(); + ProofOfStake::claim_schedule_rewards_all( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + second_token_id, + ).unwrap(); + + assert_eq!( TokensOf::::free_balance(first_token_id, &BOB), 1000,); + assert_eq!( TokensOf::::free_balance(second_token_id, &BOB), 1000,); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), + Ok(0) + ); + + }); +} + From 30193b12affde56dc9ffd665641c19a939e3c9e5 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Sep 2023 11:28:18 +0200 Subject: [PATCH 07/83] docs for Proof of Stake --- pallets/proof-of-stake/src/lib.rs | 418 +++++++++------ pallets/proof-of-stake/src/mock.rs | 5 +- pallets/proof-of-stake/src/reward_info.rs | 60 +-- pallets/proof-of-stake/src/tests.rs | 620 +++++++++++++++++----- 4 files changed, 775 insertions(+), 328 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index ebb87cf1dc..464f647800 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1,15 +1,107 @@ #![cfg_attr(not(feature = "std"), no_std)] +//! # Proof of Stake Module +//! +//! The goal of the Proof of Stake module is to reward people for providing liquidity to the Mangata DEX. +//! +//! ## Types of Rewards +//! +//! ### Liquidity Mining Rewards +//! +//! As described in Mangata tokenomics, during each session, some of the rewards are minted and distributed +//! among promoted pools. The council decides which pool to promote, and each promoted pool has a weight +//! assigned that determines how much of the rewards should +//! be distributed to that pool. +//! +//! The final amount of tokens that a user receives depends on: +//! - the amount of activated liquidity - rewards are distributed proportionally to the amount of +//! activated liquidity. +//! - the liquidity token itself - the more weight is assigned to the pool, the more rewards it receives. +//! - the time of liquidity activation - the longer a user stores liquidity, the more rewards they receive +//! (based on an asymptotic curve). +//! +//! Activated Liquidity cannot be transferred to another account; it is considered locked. The moment +//! liquidity is unlocked, the user loses the ability to claim rewards for that liquidity. +//! +//! #### Storage entries +//! +//! - [`TotalActivatedLiquidity`] - Stores information about the total amount of activated liquidity for +//! each liquidity token. +//! - [`PromotedPoolRewards`] - Stores information about the total amount of rewards for each liquidity +//! token. +//! - [`RewardsInfo`] - Stores information about rewards for liquidity mining. +//! - [`ScheduleActivationKind`] - Wrapper over origin ActivateKind that is used in +//! +//! #### Extrinsics +//! +//! - [`Pallet::activate_liquidity`] - Activates liquidity for liquidity mining rewards. +//! - [`Pallet::deactivate_liquidity`] - Deactivates liquidity for liquidity mining rewards. +//! - [`Pallet::claim_rewards_all`] - Claims all rewards for all liquidity tokens. +//! - [`Pallet::update_pool_promotion`] - Enables/disables the pool for liquidity mining rewards. +//! +//! ### Scheduled Rewards +//! +//! Anyone can provide tokens to reward people who store a particular liquidity token. Any +//! liquidity token can be rewarded with any other token provided by the user. Liquidity can be +//! activated for multiple scheduled rewards related to that liquidity token. Tokens will remain +//! locked (untransferable) as long as there is at least one schedule for which these rewards are +//! activated. +//! +//! #### Storage entries +//! +//! - [`RewardsInfoForScheduleRewards`] - Stores information about rewards for scheduled rewards. +//! - [`ScheduleRewardsPerSingleLiquidity`] - Stores the amount of rewards per single liquidity token. +//! - [`RewardsSchedules`] - Stores information about scheduled rewards. +//! - [`ScheduleId`] - Stores the unique id of the schedule. +//! - [`RewardTokensPerPool`] - Stores information about which reward tokens are used for a particular +//! liquidity token. +//! - [`TotalActivatedLiquidityForSchedules`] - Stores information about the total amount of activated +//! liquidity for each schedule. +//! - [`ActivatedLiquidityForSchedules`] - Stores information about how much liquidity was activated for +//! each schedule. +//! - [`ActivatedLockedLiquidityForSchedules`] - Stores information about how much liquidity was activated +//! for each schedule and not yet liquidity mining rewards. +//! +//! +//! #### Extrinsics +//! +//! - [`Pallet::reward_pool`] - Schedules rewards for the selected liquidity token. +//! - [`Pallet::activate_liquidity_for_rewards_schedule`] - Activates liquidity for scheduled rewards. +//! - [`Pallet::deactivate_liquidity_for_rewards_schedule`] - Deactivates liquidity for scheduled rewards. +//! - [`Pallet::claim_schedule_rewards_all`] - Claims all scheduled rewards for all liquidity tokens. +//! +//! ## Reusing a Single Liquidity Token for Multiple Rewards +//! +//! It may happen that a single liquidity token is rewarded with: +//! - Liquidity Mining Rewards - because the pool was promoted by the council. +//! - Scheduled rewards with token X - because Alice decided to do so. +//! - Scheduled rewards with token Y - because Bob decided to do so. +//! +//! In that case, a single liquidity token can be used to obtain rewards from multiple sources. There are +//! several options to do that: +//! +//! - The user can reuse liquidity used for liquidity mining rewards to claim scheduled rewards. In +//! this case, [`Pallet::activate_liquidity_for_rewards_schedule`] should be used with [`ActivateKind::LiquidityMining`]. +//! +//! - The user can reuse liquidity used for scheduled rewards (X) to sign up for rewards from other tokens (provided by Bob). In that case, [`Pallet::activate_liquidity_for_rewards_schedule`] should be used with [`ActivateKind::ActivatedLiquidity(X)`]. +//! +//! - The user can't directly provide liquidity activated for scheduled rewards to activate it for liquidity mining rewards. Instead: +//! * Liquidity used for schedule rewards can be deactivated [`Pallet::deactivate_liquidity_for_rewards_schedule`]. +//! * Liquidity can be activated for liquidity mining rewards [`Pallet::activate_liquidity`]. +//! * Liquidity can be activated for scheduled rewards [`Pallet::activate_liquidity_for_rewards_schedule`] with [`ScheduleActivationKind::Mining`]. + +use frame_support::pallet_prelude::*; + use frame_benchmarking::Zero; use frame_support::{ dispatch::{DispatchError, DispatchResult}, - ensure + ensure, + storage::bounded_btree_map::BoundedBTreeMap, }; use frame_system::ensure_signed; -use frame_support::storage::bounded_btree_map::BoundedBTreeMap; +use mangata_support::traits::Valuate; use sp_core::U256; use sp_runtime::traits::AccountIdConversion; -use mangata_support::traits::Valuate; use frame_support::{ pallet_prelude::*, @@ -57,7 +149,6 @@ pub use weights::WeightInfo; type AccountIdOf = ::AccountId; - /// Wrapper over origin ActivateKind that is used in [`Pallet::activat_liquidity`] /// with extension that allows activating liquidity that was already used for: /// - `ActivatedLiquidity` - already activated liquidity (for scheduled rewards) @@ -74,9 +165,9 @@ const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!") #[frame_support::pallet] pub mod pallet { use frame_support::traits::Currency; -use mangata_support::traits::PoolCreateApi; + use mangata_support::traits::PoolCreateApi; -use super::*; + use super::*; #[pallet::pallet] #[pallet::without_storage_info] @@ -117,7 +208,10 @@ use super::*; /// The maximum number of reward tokens per pool type MaxRewardTokensPerPool: Get; type WeightInfo: WeightInfo; - type ValuationApi: Valuate; + type ValuationApi: Valuate< + Balance = mangata_types::Balance, + CurrencyId = mangata_types::TokenId, + >; } #[pallet::error] @@ -213,13 +307,21 @@ use super::*; /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] - pub type ScheduleRewardsPerSingleLiquidity = StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; + pub type ScheduleRewardsPerSingleLiquidity = + StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; /// List of activated schedules sorted by expiry date #[pallet::storage] #[pallet::getter(fn schedules)] - pub type RewardsSchedules = - StorageValue<_, BoundedBTreeMap<(T::BlockNumber, TokenId, TokenId, Balance, u64), (), T::RewardsSchedulesLimit>, ValueQuery>; + pub type RewardsSchedules = StorageValue< + _, + BoundedBTreeMap< + (T::BlockNumber, TokenId, TokenId, Balance, u64), + (), + T::RewardsSchedulesLimit, + >, + ValueQuery, + >; /// Unique id of the schedule #[pallet::storage] @@ -227,7 +329,8 @@ use super::*; /// Maps liquidity token to list of tokens that it ever was rewarded with #[pallet::storage] - pub type RewardTokensPerPool = StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (), ValueQuery>; + pub type RewardTokensPerPool = + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (), ValueQuery>; /// Total amount of activated liquidity for each schedule /// `BTreeMap` is used because of storage reads write optiomization in `distribute_rewards` @@ -241,29 +344,22 @@ use super::*; /// liquididty tokens can be unlocked. #[pallet::storage] pub type ActivatedLiquidityForSchedules = StorageNMap< - _, + _, ( - NMapKey>, - NMapKey, - NMapKey - ), + NMapKey>, + NMapKey, + NMapKey, + ), u128, - OptionQuery, + OptionQuery, >; /// Tracks how much of the liquidity was activated for schedule rewards and not yet /// liquidity mining rewards. That information is essential to properly handle tocken unlcocks /// when liquidity is deactivated. #[pallet::storage] - pub type ActivatedLockedLiquidityForSchedules = StorageDoubleMap< - _, - Twox64Concat, - AccountIdOf, - Twox64Concat, - TokenId, - u128, - ValueQuery, - >; + pub type ActivatedLockedLiquidityForSchedules = + StorageDoubleMap<_, Twox64Concat, AccountIdOf, Twox64Concat, TokenId, u128, ValueQuery>; #[pallet::call] impl Pallet { @@ -376,14 +472,17 @@ use super::*; Error::::CannotScheduleRewardsInPast ); - let amount_per_session = schedule_end.saturated_into::() + let amount_per_session = schedule_end + .saturated_into::() .checked_sub(current_session) .and_then(|v| amount.checked_div(v.into())) .ok_or(Error::::MathOverflow)?; // TODO: use valuation instead amount directly - ensure!(amount_per_session >= T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession); - + ensure!( + amount_per_session >= T::MinRewardsPerSession::get(), + Error::::TooLittleRewardsPerSession + ); RewardTokensPerPool::::insert(rewarded_token, token_id, ()); @@ -399,11 +498,7 @@ use super::*; let schedule_id = ScheduleId::::get(); RewardsSchedules::::try_mutate(|map| { - - let key: Option<(_,_,_,_,_)> = map - .first_key_value() - .map(|(x,y)| x.clone()); - + let key: Option<(_, _, _, _, _)> = map.first_key_value().map(|(x, y)| x.clone()); if let Some(val) = key { if current_session > val.0.saturated_into::() { @@ -411,8 +506,12 @@ use super::*; } } - map.try_insert((schedule_end, rewarded_token, token_id, amount_per_session, schedule_id), ()) - }).or(Err(Error::::TooManySchedules))?; + map.try_insert( + (schedule_end, rewarded_token, token_id, amount_per_session, schedule_id), + (), + ) + }) + .or(Err(Error::::TooManySchedules))?; ScheduleId::::mutate(|v| *v += 1); @@ -486,24 +585,18 @@ use super::*; ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::claim_schedule_rewards_all_impl( - sender, - liquidity_token_id, - reward_token, - )?; + Self::claim_schedule_rewards_all_impl(sender, liquidity_token_id, reward_token)?; Ok(()) } - } } -pub enum RewardsKind{ +pub enum RewardsKind { RewardsLiquidityMinting, Rewards3rdParty(TokenId), } impl Pallet { - fn activate_liquidity_for_liquidity_minting( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -540,7 +633,6 @@ impl Pallet { liquidity_asset_id: TokenId, amount: Balance, ) -> DispatchResult { - if amount > 0 { Self::set_liquidity_burning_checkpoint(user.clone(), liquidity_asset_id, amount)?; Pallet::::deposit_event(Event::LiquidityDeactivated( @@ -550,7 +642,6 @@ impl Pallet { )); } Ok(()) - } fn activate_liquidity_for_schedule( @@ -558,11 +649,11 @@ impl Pallet { liquidity_asset_id: TokenId, amount: Balance, use_balance_from: ScheduleActivationKind, - reward_token: TokenId + reward_token: TokenId, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - match use_balance_from{ + match use_balance_from { ScheduleActivationKind::ActivateKind(ref use_balance_from) => { ensure!( ::ActivationReservesProvider::can_activate( @@ -573,31 +664,49 @@ impl Pallet { ), Error::::NotEnoughAssets ); - ActivatedLockedLiquidityForSchedules::::mutate(user.clone(), liquidity_asset_id, |val| *val += amount); + ActivatedLockedLiquidityForSchedules::::mutate( + user.clone(), + liquidity_asset_id, + |val| *val += amount, + ); }, ScheduleActivationKind::ActivatedLiquidity(token_id) => { - let already_activated_amount = - RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; - let available_amount = - RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, token_id)).activated_amount; + let already_activated_amount = RewardsInfoForScheduleRewards::::get( + user.clone(), + (liquidity_asset_id, reward_token), + ) + .activated_amount; + let available_amount = RewardsInfoForScheduleRewards::::get( + user.clone(), + (liquidity_asset_id, token_id), + ) + .activated_amount; ensure!( - already_activated_amount + amount <= available_amount , + already_activated_amount + amount <= available_amount, Error::::NotEnoughAssets ); - } + }, ScheduleActivationKind::LiquidityMining => { - let already_activated_amount = - RewardsInfoForScheduleRewards::::get(user.clone(), (liquidity_asset_id, reward_token)).activated_amount; + let already_activated_amount = RewardsInfoForScheduleRewards::::get( + user.clone(), + (liquidity_asset_id, reward_token), + ) + .activated_amount; let available_amount = RewardsInfo::::get(user.clone(), liquidity_asset_id).activated_amount; ensure!( - already_activated_amount + amount <= available_amount , + already_activated_amount + amount <= available_amount, Error::::NotEnoughAssets ); }, } - Self::set_liquidity_minting_checkpoint_3rdparty(user.clone(), liquidity_asset_id, amount, reward_token)?; + Self::set_liquidity_minting_checkpoint_3rdparty( + user.clone(), + liquidity_asset_id, + amount, + reward_token, + )?; match use_balance_from { ScheduleActivationKind::ActivateKind(use_balance_from) => { @@ -608,10 +717,8 @@ impl Pallet { use_balance_from, )?; }, - ScheduleActivationKind::LiquidityMining => { - }, - _ => {} - + ScheduleActivationKind::LiquidityMining => {}, + _ => {}, } Pallet::::deposit_event(Event::LiquidityActivated(user, liquidity_asset_id, amount)); @@ -619,16 +726,19 @@ impl Pallet { Ok(()) } - fn deactivate_liquidity_for_schedule( user: AccountIdOf, liquidity_asset_id: TokenId, amount: Balance, - rewards_asset_id: TokenId + rewards_asset_id: TokenId, ) -> DispatchResult { - if amount > 0 { - Self::set_liquidity_burning_checkpoint_for_schedule(user.clone(), liquidity_asset_id, amount, rewards_asset_id)?; + Self::set_liquidity_burning_checkpoint_for_schedule( + user.clone(), + liquidity_asset_id, + amount, + rewards_asset_id, + )?; Pallet::::deposit_event(Event::LiquidityDeactivated( user, liquidity_asset_id, @@ -636,12 +746,8 @@ impl Pallet { )); } Ok(()) - } - - - fn calculate_rewards_amount_3rdparty( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -649,14 +755,17 @@ impl Pallet { ) -> Result { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - if let Ok(info) = RewardsInfoForScheduleRewards::::try_get(user.clone(), (liquidity_asset_id, rewards_asset_id)){ + if let Ok(info) = RewardsInfoForScheduleRewards::::try_get( + user.clone(), + (liquidity_asset_id, rewards_asset_id), + ) { let current_rewards = match info.activated_amount { 0 => 0u128, _ => { let calc = RewardsCalculator::schedule_rewards::( user.clone(), liquidity_asset_id, - rewards_asset_id + rewards_asset_id, )?; calc.calculate_rewards().map_err(|err| Into::>::into(err))? }, @@ -665,9 +774,8 @@ impl Pallet { Ok(current_rewards .checked_add(info.rewards_not_yet_claimed) .and_then(|v| v.checked_sub(info.rewards_already_claimed)) - .ok_or(Error::::CalculateRewardsMathError)? - ) - }else{ + .ok_or(Error::::CalculateRewardsMathError)?) + } else { Ok(0u128) } } @@ -707,7 +815,11 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { - if Self::get_pool_rewards(liquidity_asset_id).is_ok() || RewardTokensPerPool::::iter_prefix_values(liquidity_asset_id).next().is_some() { + if Self::get_pool_rewards(liquidity_asset_id).is_ok() || + RewardTokensPerPool::::iter_prefix_values(liquidity_asset_id) + .next() + .is_some() + { Ok(()) } else { Err(DispatchError::from(Error::::NotAPromotedPool)) @@ -722,10 +834,7 @@ impl Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; { - let calc = RewardsCalculator::mining_rewards::( - user.clone(), - liquidity_asset_id, - )?; + let calc = RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; let rewards_info = calc .activate_more(liquidity_assets_added) .map_err(|err| Into::>::into(err))?; @@ -735,11 +844,9 @@ impl Pallet { TotalActivatedLiquidity::::try_mutate(liquidity_asset_id, |active_amount| { if let Some(val) = active_amount.checked_add(liquidity_assets_added) { - *active_amount = val; Ok(()) } else { - Err(()) } }) @@ -760,28 +867,31 @@ impl Pallet { let calc = RewardsCalculator::schedule_rewards::( user.clone(), liquidity_asset_id, - liquidity_assets_reward + liquidity_assets_reward, )?; let rewards_info = calc .activate_more(liquidity_assets_added) .map_err(|err| Into::>::into(err))?; - RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, liquidity_assets_reward), rewards_info); + RewardsInfoForScheduleRewards::::insert( + user.clone(), + (liquidity_asset_id, liquidity_assets_reward), + rewards_info, + ); } - ActivatedLiquidityForSchedules::::try_mutate_exists( - (user.clone(), liquidity_asset_id, liquidity_assets_reward ), - |v| - { + ActivatedLiquidityForSchedules::::try_mutate_exists( + (user.clone(), liquidity_asset_id, liquidity_assets_reward), + |v| { match v { Some(x) => { v.as_mut().map(|a| *a += liquidity_assets_added); }, None => { - *v = Some(liquidity_assets_added); - }, + *v = Some(liquidity_assets_added); + }, }; - Ok::<(),Error>(()) - } + Ok::<(), Error>(()) + }, )?; TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { @@ -790,7 +900,6 @@ impl Pallet { // NOTE: handle overflow .and_modify(|val| *val += liquidity_assets_added) .or_insert(liquidity_assets_added); - }); Ok(()) @@ -812,10 +921,7 @@ impl Pallet { Error::::NotEnoughAssets ); - let calc = RewardsCalculator::mining_rewards::( - user.clone(), - liquidity_asset_id, - )?; + let calc = RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; let rewards_info = calc .activate_less(liquidity_assets_burned) .map_err(|err| Into::>::into(err))?; @@ -841,7 +947,6 @@ impl Pallet { Ok(()) } - fn set_liquidity_burning_checkpoint_for_schedule( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -860,7 +965,11 @@ impl Pallet { .activate_less(liquidity_assets_burned) .map_err(|err| Into::>::into(err))?; - RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); + RewardsInfoForScheduleRewards::::insert( + user.clone(), + (liquidity_asset_id, reward_token), + rewards_info, + ); TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { activations @@ -868,33 +977,38 @@ impl Pallet { .and_modify(|val| *val -= liquidity_assets_burned); }); - ActivatedLiquidityForSchedules::::try_mutate_exists( - (user.clone(), liquidity_asset_id, reward_token), - |v| - { - v.and_then(|a| a.checked_sub(liquidity_assets_burned) - .and_then(|val| { + ActivatedLiquidityForSchedules::::try_mutate_exists( + (user.clone(), liquidity_asset_id, reward_token), + |v| { + v.and_then(|a| { + a.checked_sub(liquidity_assets_burned).and_then(|val| { if val > 0 { *v = Some(val); - }else{ + } else { *v = None; } Some(val) }) - ).ok_or(Error::::MathOverflow) - } + }) + .ok_or(Error::::MathOverflow) + }, )?; - - - if let None = ActivatedLiquidityForSchedules::::iter_prefix_values( (user.clone(), liquidity_asset_id), - ).next(){ - - let amount = ActivatedLockedLiquidityForSchedules::::mutate(user.clone(), liquidity_asset_id, |val| { - let prev = *val; - *val = 0; - prev - }); + if let None = ActivatedLiquidityForSchedules::::iter_prefix_values(( + user.clone(), + liquidity_asset_id, + )) + .next() + { + let amount = ActivatedLockedLiquidityForSchedules::::mutate( + user.clone(), + liquidity_asset_id, + |val| { + let prev = *val; + *val = 0; + prev + }, + ); ::ActivationReservesProvider::deactivate( liquidity_asset_id, @@ -918,8 +1032,8 @@ impl Pallet { liquidity_asset_id, reward_token, )?; - let (rewards_info, total_available_rewards) = calc.claim_rewards() - .map_err(|err| Into::>::into(err))?; + let (rewards_info, total_available_rewards) = + calc.claim_rewards().map_err(|err| Into::>::into(err))?; ::Currency::transfer( reward_token.into(), @@ -929,7 +1043,11 @@ impl Pallet { ExistenceRequirement::KeepAlive, )?; - RewardsInfoForScheduleRewards::::insert(user.clone(), (liquidity_asset_id, reward_token), rewards_info); + RewardsInfoForScheduleRewards::::insert( + user.clone(), + (liquidity_asset_id, reward_token), + rewards_info, + ); Pallet::::deposit_event(Event::RewardsClaimed( user, @@ -939,7 +1057,6 @@ impl Pallet { Ok(total_available_rewards) } - } impl ProofOfStakeRewardsApi for Pallet { @@ -970,19 +1087,15 @@ impl ProofOfStakeRewardsApi for Pallet { PromotedPoolRewards::::get().contains_key(&liquidity_token_id) } - fn claim_rewards_all( user: T::AccountId, liquidity_asset_id: Self::CurrencyId, ) -> Result { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let calc = RewardsCalculator::mining_rewards::( - user.clone(), - liquidity_asset_id, - )?; - let (rewards_info, total_available_rewards) = calc.claim_rewards() - .map_err(|err| Into::>::into(err))?; + let calc = RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; + let (rewards_info, total_available_rewards) = + calc.claim_rewards().map_err(|err| Into::>::into(err))?; ::Currency::transfer( Self::native_token_id().into(), @@ -1003,7 +1116,6 @@ impl ProofOfStakeRewardsApi for Pallet { Ok(total_available_rewards) } - fn activate_liquidity( user: T::AccountId, liquidity_asset_id: Self::CurrencyId, @@ -1023,14 +1135,9 @@ impl ProofOfStakeRewardsApi for Pallet { liquidity_asset_id: Self::CurrencyId, amount: Self::Balance, ) -> DispatchResult { - Self::deactivate_liquidity_for_liquidity_minting( - user, - liquidity_asset_id, - amount, - ) + Self::deactivate_liquidity_for_liquidity_minting(user, liquidity_asset_id, amount) } - fn calculate_rewards_amount( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -1042,10 +1149,8 @@ impl ProofOfStakeRewardsApi for Pallet { let current_rewards = match rewards_info.activated_amount { 0 => 0u128, _ => { - let calc = RewardsCalculator::mining_rewards::( - user.clone(), - liquidity_asset_id, - )?; + let calc = + RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; calc.calculate_rewards().map_err(|err| Into::>::into(err))? }, }; @@ -1060,25 +1165,25 @@ impl ProofOfStakeRewardsApi for Pallet { impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { - let schedules = RewardsSchedules::::get(); let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); - let it = schedules - .iter() - .filter_map(|((session, rewarded_token, tokenid, amount, _),())|{ - if (*session).saturated_into::() >= Self::session_index() { - Some((rewarded_token, tokenid, amount)) - } else { - None - } - }); + let it = + schedules + .iter() + .filter_map(|((session, rewarded_token, tokenid, amount, _), ())| { + if (*session).saturated_into::() >= Self::session_index() { + Some((rewarded_token, tokenid, amount)) + } else { + None + } + }); for (staked_token, token, amount) in it { + let activated_3rdparty_rewards = + TotalActivatedLiquidityForSchedules::::get(staked_token); - let activated_3rdparty_rewards = TotalActivatedLiquidityForSchedules::::get(staked_token); - - if let Some(activated_amount) = activated_3rdparty_rewards.get(&token){ + if let Some(activated_amount) = activated_3rdparty_rewards.get(&token) { let activated_amount = U256::from(*activated_amount); // NOTE: fix let rewards = pools.get(&(*staked_token, *token)).cloned().unwrap_or_default(); @@ -1087,17 +1192,14 @@ impl LiquidityMiningApi for Pallet { .and_then(|x| x.checked_div(activated_amount)) .and_then(|x| x.checked_add(rewards)); - if let Some(val) = rewards_for_liquidity { - pools.insert((*staked_token,*token), val); + pools.insert((*staked_token, *token), val); } - } } ScheduleRewardsPerSingleLiquidity::::put(pools); - let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { // benchmark with max of X prom pools let activated_pools: Vec<_> = promoted_pools diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 2bd2de9286..32dadbda5a 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -12,7 +12,7 @@ use sp_runtime::{ use crate as pos; use frame_support::{ construct_runtime, parameter_types, - traits::{tokens::currency::MultiTokenCurrency, ConstU32, ConstU128, Contains, Everything}, + traits::{tokens::currency::MultiTokenCurrency, ConstU128, ConstU32, Contains, Everything}, PalletId, }; @@ -248,7 +248,7 @@ impl pos::Config for Test { type Currency = MultiTokenCurrencyAdapter; type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; - type RewardsSchedulesLimit = ConstU32<10>; + type RewardsSchedulesLimit = ConstU32<10>; type MinRewardsPerSession = ConstU128<10>; type MaxRewardTokensPerPool = ConstU32<5>; type WeightInfo = (); @@ -370,4 +370,3 @@ macro_rules! assert_event_emitted { } }; } - diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 29403f7291..228989b026 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -52,16 +52,16 @@ impl RewardsCalculator { let current_time: u32 = Pallet::::get_current_rewards_time()?; let pool_ratio_current = Pallet::::get_pool_rewards(asset_id)?; let default_rewards = RewardInfo { - activated_amount: 0_u128, - rewards_not_yet_claimed: 0_u128, - rewards_already_claimed: 0_u128, - last_checkpoint: current_time, - pool_ratio_at_last_checkpoint: pool_ratio_current, - missing_at_last_checkpoint: U256::from(0u128), - }; + activated_amount: 0_u128, + rewards_not_yet_claimed: 0_u128, + rewards_already_claimed: 0_u128, + last_checkpoint: current_time, + pool_ratio_at_last_checkpoint: pool_ratio_current, + missing_at_last_checkpoint: U256::from(0u128), + }; - let rewards_info = crate::RewardsInfo::::try_get(user.clone(), asset_id) - .unwrap_or(default_rewards); + let rewards_info = + crate::RewardsInfo::::try_get(user.clone(), asset_id).unwrap_or(default_rewards); Ok(Self { rewards_context: RewardsContext { @@ -80,7 +80,6 @@ impl RewardsCalculator { asset_id: TokenId, reward_asset_id: TokenId, ) -> sp_std::result::Result { - let current_time: u32 = Pallet::::get_current_rewards_time()?; ensure!( crate::RewardTokensPerPool::::try_get(asset_id, reward_asset_id).is_ok(), @@ -89,27 +88,23 @@ impl RewardsCalculator { let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); - let pool_ratio_current = pool_map.get(&(asset_id, reward_asset_id)) - .cloned() - .unwrap_or(U256::from(0)); - - + let pool_ratio_current = + pool_map.get(&(asset_id, reward_asset_id)).cloned().unwrap_or(U256::from(0)); let default_rewards = RewardInfo { - activated_amount: 0_u128, - rewards_not_yet_claimed: 0_u128, - rewards_already_claimed: 0_u128, - last_checkpoint: current_time, - pool_ratio_at_last_checkpoint: pool_ratio_current, - missing_at_last_checkpoint: U256::from(0u128), - }; - + activated_amount: 0_u128, + rewards_not_yet_claimed: 0_u128, + rewards_already_claimed: 0_u128, + last_checkpoint: current_time, + pool_ratio_at_last_checkpoint: pool_ratio_current, + missing_at_last_checkpoint: U256::from(0u128), + }; let rewards_info = crate::RewardsInfoForScheduleRewards::::try_get( user.clone(), - (asset_id, reward_asset_id) - ).unwrap_or(default_rewards); - + (asset_id, reward_asset_id), + ) + .unwrap_or(default_rewards); Ok(Self { rewards_context: RewardsContext { @@ -119,11 +114,9 @@ impl RewardsCalculator { rewards_info, _curve: PhantomData::, }) - } } - pub trait CurveRewards { fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option; @@ -186,13 +179,12 @@ impl CurveRewards for AsymptoticCurveRewards { } } -impl CurveRewards for ConstCurveRewards { +impl CurveRewards for ConstCurveRewards { fn calculate_curve_position(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { - Some( U256::from(0) ) + Some(U256::from(0)) } fn calculate_curve_rewards(ctx: &RewardsContext, user_info: &RewardInfo) -> Option { - let pool_rewards_ratio_new = ctx.pool_ratio_current.checked_sub(user_info.pool_ratio_at_last_checkpoint)?; @@ -200,9 +192,7 @@ impl CurveRewards for ConstCurveRewards { .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 - rewards_base - .try_into() - .ok() + rewards_base.try_into().ok() } } @@ -292,7 +282,7 @@ impl RewardsCalculator { }) } - pub fn claim_rewards(self) -> sp_std::result::Result<(RewardInfo, Balance), RewardsCalcError>{ + pub fn claim_rewards(self) -> sp_std::result::Result<(RewardInfo, Balance), RewardsCalcError> { let current_rewards = self.calculate_rewards_impl()?; let total_available_rewards = current_rewards diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 1608d5abd3..8ba8543e55 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3,9 +3,9 @@ #![allow(non_snake_case)] use super::*; -use serial_test::serial; use crate::mock::*; use frame_support::{assert_err, assert_ok}; +use serial_test::serial; use mangata_support::traits::{ComputeIssuance, GetIssuance}; @@ -35,11 +35,10 @@ fn initialize_liquidity_rewards() { ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); } - pub(crate) fn roll_to_session(n: u32) { let block = n * Pallet::::rewards_period(); - if block < System::block_number().saturated_into::() { + if block < System::block_number().saturated_into::() { panic!("cannot roll to past block"); } forward_to_block(block); @@ -976,7 +975,6 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { }); } - pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option) { let mut session_number: u32; let mut session_issuance: (Balance, Balance); @@ -1121,9 +1119,23 @@ fn user_can_provide_3rdparty_rewards() { let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 10u32.into(), + ) + .unwrap(); roll_to_session(5); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 6u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 6u32.into(), + ) + .unwrap(); }); } @@ -1141,15 +1153,33 @@ fn cant_schedule_rewards_in_past() { roll_to_session(5); assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 1u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 1u32.into() + ), Error::::CannotScheduleRewardsInPast ); assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 4u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 4u32.into() + ), Error::::CannotScheduleRewardsInPast ); assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair,token_id, amount, 5u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + ), Error::::CannotScheduleRewardsInPast ); }); @@ -1160,17 +1190,24 @@ fn cant_schedule_rewards_in_past() { fn cannot_reward_unexisting_pool() { new_test_ext().execute_with(|| { let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Err(Error::::PoolDoesNotExist.into())); + valuation_mock + .expect() + .return_const(Err(Error::::PoolDoesNotExist.into())); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + ), Error::::PoolDoesNotExist ); - }); } @@ -1189,12 +1226,19 @@ fn rewards_are_stored_in_pallet_account() { assert_eq!(TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), 0); assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + ),); assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION - amount); - assert_eq!(TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), amount); + assert_eq!( + TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), + amount + ); }); } @@ -1211,15 +1255,18 @@ fn rewards_schedule_is_stored() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()), - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + ),); assert_eq!( ProofOfStake::schedules().into_inner(), - BTreeMap::from([((5u64, liquidity_token_id, token_id, amount/5, 0), ())]) + BTreeMap::from([((5u64, liquidity_token_id, token_id, amount / 5, 0), ())]) ); - }); } @@ -1235,25 +1282,38 @@ fn number_of_active_schedules_is_limited() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - - let max_schedules: u32 = <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); + let max_schedules: u32 = + <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); for i in 0..(max_schedules) { - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, (5u32 + i).into()) - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + (5u32 + i).into() + )); } assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 100u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 100u32.into() + ), Error::::TooManySchedules ); roll_to_session(10); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 100u32.into()) - ); - + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 100u32.into() + )); }); } @@ -1269,22 +1329,27 @@ fn duplicated_schedules_works() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + )); assert_eq!(1, ProofOfStake::schedules().len()); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 5u32.into()) - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 5u32.into() + )); assert_eq!(2, ProofOfStake::schedules().len()); - }); } - #[test] #[serial] fn reject_schedule_with_too_little_rewards_per_session() { @@ -1302,13 +1367,23 @@ fn reject_schedule_with_too_little_rewards_per_session() { let min_rewards = <::MinRewardsPerSession as sp_core::Get>::get(); assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, min_rewards - 1, 5u32.into()), + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + min_rewards - 1, + 5u32.into() + ), Error::::TooLittleRewardsPerSession ); - assert_ok!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, min_rewards, 5u32.into()) - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + min_rewards, + 5u32.into() + )); }); } @@ -1317,7 +1392,7 @@ fn reject_schedule_with_too_little_rewards_per_session() { fn user_can_claim_3rdparty_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1337,18 +1412,38 @@ fn user_can_claim_3rdparty_rewards() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 10u32.into(), + ) + .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + token_id, + None, + ) + .unwrap(); assert_eq!( ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), Ok(0) ); - roll_to_session(2); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + token_id, + None, + ) + .unwrap(); assert_eq!( ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), Ok(0) @@ -1375,7 +1470,7 @@ fn user_can_claim_3rdparty_rewards() { fn overlapping_3rdparty_rewards_works() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1393,38 +1488,72 @@ fn overlapping_3rdparty_rewards_works() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_reward_token, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_reward_token, + amount, + 10u32.into(), + ) + .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_reward_token, + None, + ) + .unwrap(); roll_to_session(5); let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into()).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, None).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_reward_token_id, + 100_000, + 15u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_reward_token_id, + None, + ) + .unwrap(); roll_to_session(6); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_reward_token_id), + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + second_reward_token_id + ), Ok(10000) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_reward_token), + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + first_reward_token + ), Ok(5000) ); - }); } - #[test] #[serial] fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1442,37 +1571,72 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_reward_token, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_reward_token, + amount, + 10u32.into(), + ) + .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_reward_token, + None, + ) + .unwrap(); roll_to_session(5); let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into()).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_reward_token)) ).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_reward_token_id, + 100_000, + 15u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_reward_token_id, + Some(ScheduleActivationKind::ActivatedLiquidity(first_reward_token)), + ) + .unwrap(); roll_to_session(6); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_reward_token_id), + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + second_reward_token_id + ), Ok(10000) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_reward_token), + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + first_reward_token + ), Ok(5000) ); }); } - #[test] #[serial] fn deactivate_3rdparty_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1491,11 +1655,32 @@ fn deactivate_3rdparty_rewards() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + token_id, + amount, + 10u32.into(), + ) + .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + token_id, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + token_id, + None, + ) + .unwrap(); roll_to_session(2); @@ -1508,7 +1693,13 @@ fn deactivate_3rdparty_rewards() { ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), Ok(500) ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, token_id).unwrap(); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + token_id, + ) + .unwrap(); roll_to_session(3); @@ -1521,17 +1712,15 @@ fn deactivate_3rdparty_rewards() { ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), Ok(500) ); - }); } - #[test] #[serial] fn claim_rewards_from_multiple_schedules_using_single_liquidity() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1550,11 +1739,39 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_token_id, + 2 * amount, + 10u32.into(), + ) + .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_token_id, + Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), + ) + .unwrap(); assert_eq!( ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), @@ -1575,7 +1792,6 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), Ok(2000) ); - }); } @@ -1584,7 +1800,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { fn liquidity_minting_liquidity_can_be_resused() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1603,23 +1819,41 @@ fn liquidity_minting_liquidity_can_be_resused() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_token_id, + 2 * amount, + 10u32.into(), + ) + .unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, Some(ScheduleActivationKind::LiquidityMining)).unwrap(); + ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + Some(ScheduleActivationKind::LiquidityMining), + ) + .unwrap(); roll_to_session(1); - assert_eq!( - ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), - Ok(200) - ); + assert_eq!(ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), Ok(200)); assert_eq!( ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), Ok(1000) ); - }); } @@ -1628,7 +1862,7 @@ fn liquidity_minting_liquidity_can_be_resused() { fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1647,29 +1881,80 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, 2 * amount, 10u32.into()).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_token_id, + 2 * amount, + 10u32.into(), + ) + .unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None).unwrap(); + ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None) + .unwrap(); assert_err!( - TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, Some(ScheduleActivationKind::LiquidityMining)).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + Some(ScheduleActivationKind::LiquidityMining), + ) + .unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + None, + ) + .unwrap(); - ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 200, first_token_id).unwrap(); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 200, + first_token_id, + ) + .unwrap(); assert_err!( - TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 101, ExistenceRequirement::AllowDeath), + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 101, + ExistenceRequirement::AllowDeath + ), orml_tokens::Error::::BalanceTooLow ); - assert_ok!( - TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath) - ); + assert_ok!(TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + )); }); } @@ -1678,7 +1963,7 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1697,35 +1982,84 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_token_id, + Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), + ) + .unwrap(); assert_err!( TokensOf::::transfer(0, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id).unwrap(); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + ) + .unwrap(); assert_err!( - TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id).unwrap(); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_token_id, + ) + .unwrap(); - assert_ok!( - TokensOf::::transfer(LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), - ); + assert_ok!(TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ),); }); } - #[test] #[serial] fn can_claim_schedule_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); - const LIQUIDITY_TOKEN : u32 = 5; + const LIQUIDITY_TOKEN: u32 = 5; let valuation_mock = MockValuationApi::get_liquidity_asset_context(); valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -1744,35 +2078,59 @@ fn can_claim_schedule_rewards() { let amount = 10_000u128; ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, first_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, second_token_id, amount, 10u32.into()).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_token_id, None).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_token_id, Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id))).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_token_id, + Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), + ) + .unwrap(); roll_to_session(1); - assert_eq!( - TokensOf::::free_balance(first_token_id, &BOB), - 0, - ); - assert_eq!( - TokensOf::::free_balance(second_token_id, &BOB), - 0, - ); + assert_eq!(TokensOf::::free_balance(first_token_id, &BOB), 0,); + assert_eq!(TokensOf::::free_balance(second_token_id, &BOB), 0,); ProofOfStake::claim_schedule_rewards_all( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, first_token_id, - ).unwrap(); + ) + .unwrap(); ProofOfStake::claim_schedule_rewards_all( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, second_token_id, - ).unwrap(); + ) + .unwrap(); - assert_eq!( TokensOf::::free_balance(first_token_id, &BOB), 1000,); - assert_eq!( TokensOf::::free_balance(second_token_id, &BOB), 1000,); + assert_eq!(TokensOf::::free_balance(first_token_id, &BOB), 1000,); + assert_eq!(TokensOf::::free_balance(second_token_id, &BOB), 1000,); assert_eq!( ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), @@ -1782,7 +2140,5 @@ fn can_claim_schedule_rewards() { ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), Ok(0) ); - }); } - From 9844c685cc7ce91bced46f259e197bb7dbb190ea Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Sep 2023 11:59:43 +0200 Subject: [PATCH 08/83] annotate R/W in distribute_rewards --- pallets/proof-of-stake/src/lib.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 464f647800..4fa5528056 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1165,7 +1165,11 @@ impl ProofOfStakeRewardsApi for Pallet { impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { + + // R:1 W:0 let schedules = RewardsSchedules::::get(); + + // R:1 W:0 let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); let it = @@ -1180,8 +1184,8 @@ impl LiquidityMiningApi for Pallet { }); for (staked_token, token, amount) in it { - let activated_3rdparty_rewards = - TotalActivatedLiquidityForSchedules::::get(staked_token); + // R: T::RewardsSchedulesLimit - in most pesimistic case + let activated_3rdparty_rewards = TotalActivatedLiquidityForSchedules::::get(staked_token); if let Some(activated_amount) = activated_3rdparty_rewards.get(&token) { let activated_amount = U256::from(*activated_amount); @@ -1198,6 +1202,7 @@ impl LiquidityMiningApi for Pallet { } } + // single write ScheduleRewardsPerSingleLiquidity::::put(pools); let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { From 243ce161e26f65e3d57c9daea81ce81190039db4 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 22 Sep 2023 12:16:35 +0200 Subject: [PATCH 09/83] refactor storage entry type for TotalActivatedLiquidityForSchedules --- pallets/proof-of-stake/src/lib.rs | 56 ++++++++++++++----------------- 1 file changed, 25 insertions(+), 31 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 4fa5528056..04dd8a03fd 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -333,10 +333,9 @@ pub mod pallet { StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (), ValueQuery>; /// Total amount of activated liquidity for each schedule - /// `BTreeMap` is used because of storage reads write optiomization in `distribute_rewards` #[pallet::storage] pub type TotalActivatedLiquidityForSchedules = - StorageMap<_, Twox64Concat, TokenId, BTreeMap, ValueQuery>; + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; /// Tracks how much liquidity user activated for particular (liq token, reward token) pair /// StorageNMap was used because it only require single read to know if user deactivated all @@ -894,13 +893,10 @@ impl Pallet { }, )?; - TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { - activations - .entry(liquidity_assets_reward) - // NOTE: handle overflow - .and_modify(|val| *val += liquidity_assets_added) - .or_insert(liquidity_assets_added); - }); + TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |amount| -> DispatchResult { + *amount = amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; + Ok(()) + })?; Ok(()) } @@ -971,11 +967,10 @@ impl Pallet { rewards_info, ); - TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, |activations| { - activations - .entry(reward_token) - .and_modify(|val| *val -= liquidity_assets_burned); - }); + TotalActivatedLiquidityForSchedules::::try_mutate(liquidity_asset_id, reward_token, |amount| -> DispatchResult{ + *amount = amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; + Ok(()) + })?; ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), @@ -1183,26 +1178,25 @@ impl LiquidityMiningApi for Pallet { } }); - for (staked_token, token, amount) in it { + for (staked_token, rewarded_token, amount) in it { // R: T::RewardsSchedulesLimit - in most pesimistic case - let activated_3rdparty_rewards = TotalActivatedLiquidityForSchedules::::get(staked_token); - - if let Some(activated_amount) = activated_3rdparty_rewards.get(&token) { - let activated_amount = U256::from(*activated_amount); - // NOTE: fix - let rewards = pools.get(&(*staked_token, *token)).cloned().unwrap_or_default(); - let rewards_for_liquidity = U256::from(*amount) - .checked_mul(U256::from(u128::MAX)) - .and_then(|x| x.checked_div(activated_amount)) - .and_then(|x| x.checked_add(rewards)); - - if let Some(val) = rewards_for_liquidity { - pools.insert((*staked_token, *token), val); - } - } + match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { + 0 => {}, + activated_amount => { + let activated_amount = U256::from(activated_amount); + let rewards = pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); + let rewards_for_liquidity = U256::from(*amount) + .checked_mul(U256::from(u128::MAX)) + .and_then(|x| x.checked_div(activated_amount)) + .and_then(|x| x.checked_add(rewards)); + + if let Some(val) = rewards_for_liquidity { + pools.insert((*staked_token, *rewarded_token), val); + } + }, + } } - // single write ScheduleRewardsPerSingleLiquidity::::put(pools); let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { From 398a0baa7094936e317a267d50d0693a6afbc2b3 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 25 Sep 2023 07:43:10 +0200 Subject: [PATCH 10/83] replace proceduram macros with generic fn --- pallets/proof-of-stake/src/benchmarking.rs | 65 +++++++---- pallets/proof-of-stake/src/lib.rs | 86 +++++++++------ pallets/proof-of-stake/src/tests.rs | 120 ++++++++++++--------- 3 files changed, 166 insertions(+), 105 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 4066363d90..d7bc7f99da 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -12,38 +12,42 @@ use crate::Pallet as PoS; const MILION: u128 = 1_000__000_000__000_000; -#[macro_export] -macro_rules! init { - () => { - frame_system::Pallet::::set_block_number(1_u32.into()); - pallet_issuance::Pallet::::initialize(); - }; +fn init() where + T: frame_system::Config, + T: pallet_issuance::Config, +{ + frame_system::Pallet::::set_block_number(1_u32.into()); + pallet_issuance::Pallet::::initialize(); } -#[macro_export] -macro_rules! forward_to_next_session { - () => { + + +fn forward_to_next_session() where + T: frame_system::Config, + T: pallet_issuance::Config, + T: Config +{ let current_block: u32 = frame_system::Pallet::::block_number().saturated_into::(); let blocks_per_session: u32 = PoS::::rewards_period(); let target_block_nr: u32; let target_session_nr: u32; - if (current_block == 0_u32 || current_block == 1_u32) { + if current_block == 0_u32 || current_block == 1_u32 { target_session_nr = 1_u32; target_block_nr = blocks_per_session; } else { // to fail on user trying to manage block nr on its own assert!(current_block % blocks_per_session == 0); target_session_nr = (current_block / blocks_per_session) + 1_u32; - target_block_nr = (target_session_nr * blocks_per_session); + target_block_nr = target_session_nr * blocks_per_session; } frame_system::Pallet::::set_block_number(target_block_nr.into()); pallet_issuance::Pallet::::compute_issuance(target_session_nr); - }; } + benchmarks! { claim_rewards_all{ // 1. create @@ -52,7 +56,7 @@ benchmarks! { // 4. wait some // 5. claim all - init!(); + init::(); let caller: ::AccountId = whitelisted_caller(); let initial_amount:mangata_types::Balance = 1000000000000000000000; let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); @@ -72,12 +76,12 @@ benchmarks! { let half_of_minted_liquidity = total_minted_liquidity.into() / 2_u128; let quater_of_minted_liquidity = total_minted_liquidity.into() / 4_u128; - forward_to_next_session!(); + forward_to_next_session::(); PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); - forward_to_next_session!(); - forward_to_next_session!(); + forward_to_next_session::(); + forward_to_next_session::(); assert!(PoS::::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap() > 0); @@ -113,7 +117,7 @@ benchmarks! { // 4 wait some time // 5 mint some - init!(); + init::(); let caller: ::AccountId = whitelisted_caller(); let initial_amount:mangata_types::Balance = 1000000000000000000000; let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); @@ -140,7 +144,7 @@ benchmarks! { quater_of_minted_liquidity ); - forward_to_next_session!(); + forward_to_next_session::(); }: activate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity, None) verify { @@ -158,7 +162,7 @@ benchmarks! { // 3 mint some tokens // deactivate some tokens (all or some - to be checked) - init!(); + init::(); let caller: ::AccountId = whitelisted_caller(); let initial_amount:mangata_types::Balance = 1000000000000000000000; let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); @@ -184,7 +188,7 @@ benchmarks! { half_of_minted_liquidity ); - forward_to_next_session!(); + forward_to_next_session::(); }: deactivate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity.into()) verify { @@ -194,5 +198,26 @@ benchmarks! { ); } + // reward_pool{ + // // 1 crate pool + // // 2 promote pool + // // 3 mint some tokens + // // deactivate some tokens (all or some - to be checked) + // + // init::(); + // let caller: ::AccountId = whitelisted_caller(); + // let initial_amount:mangata_types::Balance = 1000000000000000000000; + // let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); + // let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + // let non_native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + // let reward_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); + // + // forward_to_next_session::(); + // + // }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,non_native_asset_id), reward_asset_id.into(), 10000, 10u32.into()) + // verify { + // // + // } + impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 04dd8a03fd..64b0afe235 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -177,7 +177,7 @@ pub mod pallet { impl Hooks for Pallet {} #[cfg(feature = "runtime-benchmarks")] - pub trait PoSBenchmarkingConrfig: pallet_issuance::Config {} + pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} #[cfg(feature = "runtime-benchmarks")] impl PoSBenchmarkingConfig for T {} @@ -241,6 +241,8 @@ pub mod pallet { TooManySchedules, /// Too little rewards per session TooLittleRewardsPerSession, + /// Reward token not paired with native token + RewardTokenNotPairdWithNativeToken, } #[pallet::event] @@ -462,8 +464,9 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - let rewarded_token = ::ValuationApi::get_liquidity_asset(pool.0, pool.1) - .map_err(|_| Error::::PoolDoesNotExist)?; + let liquidity_token_id = + ::ValuationApi::get_liquidity_asset(pool.0, pool.1) + .map_err(|_| Error::::PoolDoesNotExist)?; let current_session = Self::session_index(); ensure!( @@ -477,13 +480,18 @@ pub mod pallet { .and_then(|v| amount.checked_div(v.into())) .ok_or(Error::::MathOverflow)?; - // TODO: use valuation instead amount directly ensure!( - amount_per_session >= T::MinRewardsPerSession::get(), + pool.0 == Self::native_token_id() || pool.1 == Self::native_token_id(), + Error::::RewardTokenNotPairdWithNativeToken + ); + + ensure!( + ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount) >= + T::MinRewardsPerSession::get(), Error::::TooLittleRewardsPerSession ); - RewardTokensPerPool::::insert(rewarded_token, token_id, ()); + RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); T::Currency::transfer( token_id.into(), @@ -506,7 +514,7 @@ pub mod pallet { } map.try_insert( - (schedule_end, rewarded_token, token_id, amount_per_session, schedule_id), + (schedule_end, liquidity_token_id, token_id, amount_per_session, schedule_id), (), ) }) @@ -893,10 +901,15 @@ impl Pallet { }, )?; - TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |amount| -> DispatchResult { - *amount = amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; - Ok(()) - })?; + TotalActivatedLiquidityForSchedules::::mutate( + liquidity_asset_id, + liquidity_assets_reward, + |amount| -> DispatchResult { + *amount = + amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; + Ok(()) + }, + )?; Ok(()) } @@ -967,10 +980,15 @@ impl Pallet { rewards_info, ); - TotalActivatedLiquidityForSchedules::::try_mutate(liquidity_asset_id, reward_token, |amount| -> DispatchResult{ - *amount = amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; - Ok(()) - })?; + TotalActivatedLiquidityForSchedules::::try_mutate( + liquidity_asset_id, + reward_token, + |amount| -> DispatchResult { + *amount = + amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; + Ok(()) + }, + )?; ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), @@ -1160,11 +1178,10 @@ impl ProofOfStakeRewardsApi for Pallet { impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { - - // R:1 W:0 + // R:1 W:0 let schedules = RewardsSchedules::::get(); - // R:1 W:0 + // R:1 W:0 let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); let it = @@ -1179,22 +1196,23 @@ impl LiquidityMiningApi for Pallet { }); for (staked_token, rewarded_token, amount) in it { - // R: T::RewardsSchedulesLimit - in most pesimistic case - match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { - 0 => {}, - activated_amount => { - let activated_amount = U256::from(activated_amount); - let rewards = pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); - let rewards_for_liquidity = U256::from(*amount) - .checked_mul(U256::from(u128::MAX)) - .and_then(|x| x.checked_div(activated_amount)) - .and_then(|x| x.checked_add(rewards)); - - if let Some(val) = rewards_for_liquidity { - pools.insert((*staked_token, *rewarded_token), val); - } - }, - } + // R: T::RewardsSchedulesLimit - in most pesimistic case + match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { + 0 => {}, + activated_amount => { + let activated_amount = U256::from(activated_amount); + let rewards = + pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); + let rewards_for_liquidity = U256::from(*amount) + .checked_mul(U256::from(u128::MAX)) + .and_then(|x| x.checked_div(activated_amount)) + .and_then(|x| x.checked_add(rewards)); + + if let Some(val) = rewards_for_liquidity { + pools.insert((*staked_token, *rewarded_token), val); + } + }, + } } ScheduleRewardsPerSingleLiquidity::::put(pools); diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 8ba8543e55..8fcd8aec11 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1110,8 +1110,10 @@ const EVE: u128 = 5; #[serial] fn user_can_provide_3rdparty_rewards() { new_test_ext().execute_with(|| { - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); System::set_block_number(1); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1144,8 +1146,10 @@ fn user_can_provide_3rdparty_rewards() { fn cant_schedule_rewards_in_past() { new_test_ext().execute_with(|| { System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1189,10 +1193,12 @@ fn cant_schedule_rewards_in_past() { #[serial] fn cannot_reward_unexisting_pool() { new_test_ext().execute_with(|| { - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock .expect() .return_const(Err(Error::::PoolDoesNotExist.into())); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1216,8 +1222,10 @@ fn cannot_reward_unexisting_pool() { fn rewards_are_stored_in_pallet_account() { new_test_ext().execute_with(|| { System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1248,8 +1256,10 @@ fn rewards_schedule_is_stored() { new_test_ext().execute_with(|| { System::set_block_number(1); let liquidity_token_id = 10u32; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(liquidity_token_id)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(liquidity_token_id)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1275,8 +1285,10 @@ fn rewards_schedule_is_stored() { fn number_of_active_schedules_is_limited() { new_test_ext().execute_with(|| { System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1322,8 +1334,10 @@ fn number_of_active_schedules_is_limited() { fn duplicated_schedules_works() { new_test_ext().execute_with(|| { System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1355,8 +1369,10 @@ fn duplicated_schedules_works() { fn reject_schedule_with_too_little_rewards_per_session() { new_test_ext().execute_with(|| { System::set_block_number(1); - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(10u32)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(1u128); let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); @@ -1364,26 +1380,10 @@ fn reject_schedule_with_too_little_rewards_per_session() { roll_to_session(4); - let min_rewards = <::MinRewardsPerSession as sp_core::Get>::get(); - assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - min_rewards - 1, - 5u32.into() - ), + ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, 1, 5u32.into()), Error::::TooLittleRewardsPerSession ); - - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - min_rewards, - 5u32.into() - )); }); } @@ -1393,8 +1393,10 @@ fn user_can_claim_3rdparty_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1471,8 +1473,10 @@ fn overlapping_3rdparty_rewards_works() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1554,8 +1558,10 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1637,8 +1643,10 @@ fn deactivate_3rdparty_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1721,8 +1729,10 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1801,8 +1811,10 @@ fn liquidity_minting_liquidity_can_be_resused() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1863,8 +1875,10 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -1964,8 +1978,10 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); @@ -2060,8 +2076,10 @@ fn can_claim_schedule_rewards() { new_test_ext().execute_with(|| { System::set_block_number(1); const LIQUIDITY_TOKEN: u32 = 5; - let valuation_mock = MockValuationApi::get_liquidity_asset_context(); - valuation_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); From 50cf2228a2ad07c3e667a85e0fc11427e7481075 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 25 Sep 2023 09:49:25 +0200 Subject: [PATCH 11/83] workaround for XYK capabilities in benchmark code --- Cargo.lock | 1 + pallets/proof-of-stake/Cargo.toml | 1 + pallets/proof-of-stake/src/benchmarking.rs | 40 ++++++------ pallets/proof-of-stake/src/lib.rs | 52 ++++++++++++++-- pallets/proof-of-stake/src/mock.rs | 71 +++++++++++++++++++--- 5 files changed, 130 insertions(+), 35 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 18ae550c0f..30825a1e55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6792,6 +6792,7 @@ dependencies = [ "pallet-bootstrap", "pallet-issuance", "pallet-vesting-mangata", + "pallet-xyk", "parity-scale-codec", "rustc-hex", "scale-info", diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index 077522c1fd..c222722179 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -42,6 +42,7 @@ env_logger = "0.9.0" serial_test = { version = "0.6.0", default-features = false } test-case = "2.0.2" mockall = "0.11.0" +pallet-xyk = { path = "../xyk" } [features] default = ['std'] diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index d7bc7f99da..f5ab3b6bf9 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -198,26 +198,26 @@ benchmarks! { ); } - // reward_pool{ - // // 1 crate pool - // // 2 promote pool - // // 3 mint some tokens - // // deactivate some tokens (all or some - to be checked) - // - // init::(); - // let caller: ::AccountId = whitelisted_caller(); - // let initial_amount:mangata_types::Balance = 1000000000000000000000; - // let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - // let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - // let non_native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - // let reward_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); - // - // forward_to_next_session::(); - // - // }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,non_native_asset_id), reward_asset_id.into(), 10000, 10u32.into()) - // verify { - // // - // } + reward_pool{ + // 1 crate pool + // 2 promote pool + // 3 mint some tokens + // deactivate some tokens (all or some - to be checked) + + init::(); + let caller: ::AccountId = whitelisted_caller(); + let initial_amount:mangata_types::Balance = 1000000000000000000000; + let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); + let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + let non_native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); + let reward_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); + + forward_to_next_session::(); + + }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,non_native_asset_id), reward_asset_id.into(), 10000, 10u32.into()) + verify { + // + } impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 64b0afe235..be949ab226 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -93,6 +93,7 @@ use frame_support::pallet_prelude::*; use frame_benchmarking::Zero; +use frame_support::traits::Nothing; use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, @@ -110,7 +111,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use mangata_support::traits::{ - ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, + ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, XykFunctionsTrait }; use mangata_types::{multipurpose_liquidity::ActivateKind, Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; @@ -183,10 +184,45 @@ pub mod pallet { #[cfg(not(feature = "runtime-benchmarks"))] pub trait PoSBenchmarkingConfig {} - #[cfg(not(feature = "runtime-benchmarks"))] impl PoSBenchmarkingConfig for T {} + + #[cfg(not(feature = "runtime-benchmarks"))] + pub trait ValutationApiTrait: Valuate< + Balance = mangata_types::Balance, + CurrencyId = mangata_types::TokenId, + >{} + + #[cfg(feature = "runtime-benchmarks")] + pub trait ValutationApiTrait: Valuate< + Balance = mangata_types::Balance, + CurrencyId = mangata_types::TokenId, + > + XykFunctionsTrait{} + + + #[cfg(not(feature = "runtime-benchmarks"))] + impl ValutationApiTrait for T where + C: Config, + T: Valuate< + Balance = mangata_types::Balance, + CurrencyId = mangata_types::TokenId, + >, + { + } + + #[cfg(feature = "runtime-benchmarks")] + impl ValutationApiTrait for T where + C: Config, + T: Valuate< + Balance = mangata_types::Balance, + CurrencyId = mangata_types::TokenId, + >, + T : XykFunctionsTrait + { + } + + #[pallet::config] pub trait Config: frame_system::Config + PoSBenchmarkingConfig { type RuntimeEvent: From> + IsType<::RuntimeEvent>; @@ -208,10 +244,14 @@ pub mod pallet { /// The maximum number of reward tokens per pool type MaxRewardTokensPerPool: Get; type WeightInfo: WeightInfo; - type ValuationApi: Valuate< - Balance = mangata_types::Balance, - CurrencyId = mangata_types::TokenId, - >; + type ValuationApi: ValutationApiTrait; + + // type ValuationApi: Valuate< + // Balance = mangata_types::Balance, + // CurrencyId = mangata_types::TokenId, + // >; + // #[cfg(feature = "runtime-benchmarks")] + // type Xyk: XykFunctionsTrait; } #[pallet::error] diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 32dadbda5a..d3080e65db 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -1,9 +1,11 @@ // Copyright (C) 2020 Mangata team use super::*; +use mangata_support::traits::GetMaintenanceStatusTrait; use sp_core::H256; +use pallet_xyk::AssetMetadataMutationTrait; use sp_runtime::{ testing::Header, traits::{AccountIdConversion, BlakeTwo256, IdentityLookup}, @@ -43,6 +45,7 @@ construct_runtime!( ProofOfStake: pos::{Pallet, Call, Storage, Event}, Vesting: pallet_vesting_mangata::{Pallet, Call, Storage, Event}, Issuance: pallet_issuance::{Pallet, Event, Storage}, + Xyk: pallet_xyk::{Pallet, Event, Storage}, } ); @@ -193,15 +196,6 @@ lazy_static::lazy_static! { }; } -pub struct MockMaintenanceStatusProvider; - -lazy_static::lazy_static! { - static ref MAINTENANCE_STATUS: Mutex = { - let m: bool = false; - Mutex::new(m) - }; -} - mockall::mock! { pub ValuationApi {} @@ -235,12 +229,55 @@ mockall::mock! { first_asset_id: TokenId, second_asset_id: TokenId, ) -> Result<(Balance, Balance), DispatchError>; + } +} +pub struct AssetMetadataMutation; +impl AssetMetadataMutationTrait for AssetMetadataMutation { + fn set_asset_info( + _asset: TokenId, + _name: Vec, + _symbol: Vec, + _decimals: u32, + ) -> DispatchResult { + Ok(()) + } +} +pub struct MockMaintenanceStatusProvider; +impl GetMaintenanceStatusTrait for MockMaintenanceStatusProvider { + fn is_maintenance() -> bool { + false + } + fn is_upgradable() -> bool { + true } } + +impl pallet_xyk::XykBenchmarkingConfig for Test {} + +impl pallet_xyk::Config for Test { + type RuntimeEvent = RuntimeEvent; + type MaintenanceStatusProvider = MockMaintenanceStatusProvider; + type ActivationReservesProvider = TokensActivationPassthrough; + type Currency = MultiTokenCurrencyAdapter; + type NativeCurrencyId = NativeCurrencyId; + type TreasuryPalletId = TreasuryPalletId; + type BnbTreasurySubAccDerive = BnbTreasurySubAccDerive; + type LiquidityMiningRewards = ProofOfStake; + type PoolFeePercentage = ConstU128<20>; + type TreasuryFeePercentage = ConstU128<5>; + type BuyAndBurnFeePercentage = ConstU128<5>; + type WeightInfo = (); + type DisallowedPools = (); + type DisabledTokens = Nothing; + type VestingProvider = Vesting; + type AssetMetadataMutation = AssetMetadataMutation; +} + +#[cfg(not(feature = "runtime-benchmarks"))] impl pos::Config for Test { type RuntimeEvent = RuntimeEvent; type ActivationReservesProvider = TokensActivationPassthrough; @@ -255,6 +292,22 @@ impl pos::Config for Test { type ValuationApi = MockValuationApi; } + +#[cfg(feature = "runtime-benchmarks")] +impl pos::Config for Test { + type RuntimeEvent = RuntimeEvent; + type ActivationReservesProvider = TokensActivationPassthrough; + type NativeCurrencyId = NativeCurrencyId; + type Currency = MultiTokenCurrencyAdapter; + type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; + type RewardsDistributionPeriod = ConstU32<10>; + type RewardsSchedulesLimit = ConstU32<10>; + type MinRewardsPerSession = ConstU128<10>; + type MaxRewardTokensPerPool = ConstU32<5>; + type WeightInfo = (); + type ValuationApi = Xyk; +} + pub struct TokensActivationPassthrough(PhantomData); impl ActivationReservesProviderTrait for TokensActivationPassthrough From 1cc2256a9f3a7ec8220695b515a9d2ec571dbfb8 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 25 Sep 2023 12:35:21 +0200 Subject: [PATCH 12/83] benchmark for PoS::reward_pool --- pallets/proof-of-stake/src/benchmarking.rs | 119 +++++++++++++++------ pallets/proof-of-stake/src/lib.rs | 42 ++++---- pallets/proof-of-stake/src/mock.rs | 2 - 3 files changed, 104 insertions(+), 59 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index f5ab3b6bf9..8435259eed 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -12,7 +12,8 @@ use crate::Pallet as PoS; const MILION: u128 = 1_000__000_000__000_000; -fn init() where +fn init() +where T: frame_system::Config, T: pallet_issuance::Config, { @@ -20,34 +21,36 @@ fn init() where pallet_issuance::Pallet::::initialize(); } +type TokensOf = ::Currency; +type AccountIdOf = ::AccountId; +type XykOf = ::ValuationApi; - -fn forward_to_next_session() where +fn forward_to_next_session() +where T: frame_system::Config, T: pallet_issuance::Config, - T: Config + T: Config, { - let current_block: u32 = frame_system::Pallet::::block_number().saturated_into::(); - - let blocks_per_session: u32 = PoS::::rewards_period(); - let target_block_nr: u32; - let target_session_nr: u32; - - if current_block == 0_u32 || current_block == 1_u32 { - target_session_nr = 1_u32; - target_block_nr = blocks_per_session; - } else { - // to fail on user trying to manage block nr on its own - assert!(current_block % blocks_per_session == 0); - target_session_nr = (current_block / blocks_per_session) + 1_u32; - target_block_nr = target_session_nr * blocks_per_session; - } + let current_block: u32 = frame_system::Pallet::::block_number().saturated_into::(); + + let blocks_per_session: u32 = PoS::::rewards_period(); + let target_block_nr: u32; + let target_session_nr: u32; + + if current_block == 0_u32 || current_block == 1_u32 { + target_session_nr = 1_u32; + target_block_nr = blocks_per_session; + } else { + // to fail on user trying to manage block nr on its own + assert!(current_block % blocks_per_session == 0); + target_session_nr = (current_block / blocks_per_session) + 1_u32; + target_block_nr = target_session_nr * blocks_per_session; + } - frame_system::Pallet::::set_block_number(target_block_nr.into()); - pallet_issuance::Pallet::::compute_issuance(target_session_nr); + frame_system::Pallet::::set_block_number(target_block_nr.into()); + pallet_issuance::Pallet::::compute_issuance(target_session_nr); } - benchmarks! { claim_rewards_all{ // 1. create @@ -199,25 +202,75 @@ benchmarks! { } reward_pool{ - // 1 crate pool - // 2 promote pool - // 3 mint some tokens - // deactivate some tokens (all or some - to be checked) + // 1 crate as many schedules as possible + // 2 wait for one of the schedules to expire + // 3 create new schedule that will replace the expired one init::(); + + let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); - let initial_amount:mangata_types::Balance = 1000000000000000000000; - let expected_native_asset_id : TokenId = ::NativeCurrencyId::get().into(); - let native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let non_native_asset_id : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); - let reward_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); + let native_asset_id = ::NativeCurrencyId::get(); + loop { + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + if token_id > native_asset_id { + break; + } + } + + let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); + + for _ in 0 .. schedules_limit - 1 { + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let reward_token = token_id + 1; + + PoS::::reward_pool( + RawOrigin::Signed(caller.clone().into()).into(), + (native_asset_id, token_id), + reward_token.into(), + MILION, + 10u32.into(), + ).unwrap(); + } + + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let reward_token = token_id + 1; + PoS::::reward_pool( + RawOrigin::Signed(caller.clone().into()).into(), + (native_asset_id, token_id), + reward_token.into(), + MILION, + 2u32.into(), + ).unwrap(); + + forward_to_next_session::(); + forward_to_next_session::(); forward_to_next_session::(); - }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,non_native_asset_id), reward_asset_id.into(), 10000, 10u32.into()) + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let reward_token = token_id + 1; + + assert_eq!( + RewardsSchedules::::get().len() as u32, + schedules_limit + ); + + }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,token_id), reward_token.into(), MILION, 10u32.into()) verify { - // + + assert_eq!( + RewardsSchedules::::get().len() as u32, + schedules_limit + ); + } + + impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index be949ab226..422f2948b0 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -93,11 +93,11 @@ use frame_support::pallet_prelude::*; use frame_benchmarking::Zero; -use frame_support::traits::Nothing; use frame_support::{ dispatch::{DispatchError, DispatchResult}, ensure, storage::bounded_btree_map::BoundedBTreeMap, + traits::Nothing, }; use frame_system::ensure_signed; use mangata_support::traits::Valuate; @@ -111,7 +111,7 @@ use frame_support::{ }; use frame_system::pallet_prelude::*; use mangata_support::traits::{ - ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, XykFunctionsTrait + ActivationReservesProviderTrait, LiquidityMiningApi, ProofOfStakeRewardsApi, XykFunctionsTrait, }; use mangata_types::{multipurpose_liquidity::ActivateKind, Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyExtended, MultiTokenReservableCurrency}; @@ -187,42 +187,36 @@ pub mod pallet { #[cfg(not(feature = "runtime-benchmarks"))] impl PoSBenchmarkingConfig for T {} - #[cfg(not(feature = "runtime-benchmarks"))] - pub trait ValutationApiTrait: Valuate< - Balance = mangata_types::Balance, - CurrencyId = mangata_types::TokenId, - >{} + pub trait ValutationApiTrait: + Valuate + { + } #[cfg(feature = "runtime-benchmarks")] - pub trait ValutationApiTrait: Valuate< - Balance = mangata_types::Balance, - CurrencyId = mangata_types::TokenId, - > + XykFunctionsTrait{} - + pub trait ValutationApiTrait: + Valuate + + XykFunctionsTrait + { + } #[cfg(not(feature = "runtime-benchmarks"))] - impl ValutationApiTrait for T where + impl ValutationApiTrait for T + where C: Config, - T: Valuate< - Balance = mangata_types::Balance, - CurrencyId = mangata_types::TokenId, - >, + T: Valuate, { } #[cfg(feature = "runtime-benchmarks")] - impl ValutationApiTrait for T where + impl ValutationApiTrait for T + where C: Config, - T: Valuate< - Balance = mangata_types::Balance, - CurrencyId = mangata_types::TokenId, - >, - T : XykFunctionsTrait + T: Valuate, + T: XykFunctionsTrait, { } - #[pallet::config] pub trait Config: frame_system::Config + PoSBenchmarkingConfig { type RuntimeEvent: From> + IsType<::RuntimeEvent>; diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index d3080e65db..1209e57255 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -255,7 +255,6 @@ impl GetMaintenanceStatusTrait for MockMaintenanceStatusProvider { } } - impl pallet_xyk::XykBenchmarkingConfig for Test {} impl pallet_xyk::Config for Test { @@ -292,7 +291,6 @@ impl pos::Config for Test { type ValuationApi = MockValuationApi; } - #[cfg(feature = "runtime-benchmarks")] impl pos::Config for Test { type RuntimeEvent = RuntimeEvent; From 74a6ddd7d286b290ac92ed0f55017746f90598be Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 25 Sep 2023 13:51:04 +0200 Subject: [PATCH 13/83] benchmark for PoS::activate_liquidity_for_rewards_schedule --- pallets/proof-of-stake/src/benchmarking.rs | 48 ++++++++++++++++++++++ pallets/proof-of-stake/src/lib.rs | 8 +++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 8435259eed..b879e4c074 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -270,6 +270,54 @@ benchmarks! { } + activate_liquidity_for_rewards_schedule{ + // 1 create pool that can be rewarded + // 2 create token that is githeven as reward + // 3 create new schedule that will replace the expired one + + init::(); + + let schedules_limit = ::RewardsSchedulesLimit::get(); + let caller: ::AccountId = whitelisted_caller(); + let native_asset_id = ::NativeCurrencyId::get(); + + loop { + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + if token_id > native_asset_id { + break; + } + } + + let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); + + let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let liquidity_asset_id = first_token_id + 1; + + let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let reward_token_id = second_token_id + 1; + + let rewards_amount = 20_000u128; + + PoS::::reward_pool( + RawOrigin::Signed(caller.clone().into()).into(), + (native_asset_id, first_token_id), + reward_token_id.into(), + rewards_amount, + 2u32.into(), + ).unwrap(); + + }: activate_liquidity_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id, None) + verify { + forward_to_next_session::(); + assert_eq!( + PoS::::calculate_rewards_amount_3rdparty(caller, liquidity_asset_id, reward_token_id).unwrap(), + rewards_amount/2 + ) + } + impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 422f2948b0..f9d424b652 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -390,7 +390,7 @@ pub mod pallet { >; /// Tracks how much of the liquidity was activated for schedule rewards and not yet - /// liquidity mining rewards. That information is essential to properly handle tocken unlcocks + /// liquidity mining rewards. That information is essential to properly handle token unlcocks /// when liquidity is deactivated. #[pallet::storage] pub type ActivatedLockedLiquidityForSchedules = @@ -695,6 +695,7 @@ impl Pallet { Self::ensure_is_promoted_pool(liquidity_asset_id)?; match use_balance_from { + // 1R 1W ScheduleActivationKind::ActivateKind(ref use_balance_from) => { ensure!( ::ActivationReservesProvider::can_activate( @@ -711,6 +712,7 @@ impl Pallet { |val| *val += amount, ); }, + // 2R ScheduleActivationKind::ActivatedLiquidity(token_id) => { let already_activated_amount = RewardsInfoForScheduleRewards::::get( user.clone(), @@ -856,6 +858,7 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { + //NOTE: 2 separate functions for separate rewards if Self::get_pool_rewards(liquidity_asset_id).is_ok() || RewardTokensPerPool::::iter_prefix_values(liquidity_asset_id) .next() @@ -1295,3 +1298,6 @@ impl LiquidityMiningApi for Pallet { }); } } + +// TODO: valuate rewards in MGX +// TODO: dedicated ensures for every activation kind From 7dc7046fcd3ab89ba06fc0e15706f80dce830309 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 09:30:01 +0200 Subject: [PATCH 14/83] Benchmarks for PoS::deactivate_liquidity_for_rewards_schedule --- pallets/proof-of-stake/src/benchmarking.rs | 84 +++++++++++++++++++++- pallets/proof-of-stake/src/lib.rs | 6 ++ 2 files changed, 88 insertions(+), 2 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index b879e4c074..3582b8697d 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -3,6 +3,7 @@ use super::*; use frame_benchmarking::{account, benchmarks, whitelisted_caller}; +use frame_support::traits::WithdrawReasons; use frame_system::RawOrigin; use mangata_support::traits::{ComputeIssuance, ProofOfStakeRewardsApi}; use orml_tokens::MultiTokenCurrencyExtended; @@ -272,8 +273,8 @@ benchmarks! { activate_liquidity_for_rewards_schedule{ // 1 create pool that can be rewarded - // 2 create token that is githeven as reward - // 3 create new schedule that will replace the expired one + // 2 create token that is used as reward + // 3 activate rewards init::(); @@ -318,7 +319,86 @@ benchmarks! { ) } + deactivate_liquidity_for_rewards_schedule{ + // 1 create pool that can be rewarded + // 2 create token that is used as reward + // 3 activate rewards + // 4 deactivate rewards and unlock them + + init::(); + + let schedules_limit = ::RewardsSchedulesLimit::get(); + let caller: ::AccountId = whitelisted_caller(); + let native_asset_id = ::NativeCurrencyId::get(); + + loop { + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + if token_id > native_asset_id { + break; + } + } + + let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); + + let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let liquidity_asset_id = first_token_id + 1; + + let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let reward_token_id = second_token_id + 1; + + let rewards_amount = 20_000u128; + + PoS::::reward_pool( + RawOrigin::Signed(caller.clone().into()).into(), + (native_asset_id, first_token_id), + reward_token_id.into(), + rewards_amount, + 2u32.into(), + ).unwrap(); + + // println!("{:?}", TokensOf::::free_balance(reward_token_id.into(), &caller)); + + assert!(TokensOf::::ensure_can_withdraw( + liquidity_asset_id.into(), + &caller, + MILION.into(), + WithdrawReasons::all(), + Default::default(), + ).is_ok()); + + PoS::::activate_liquidity_for_rewards_schedule( + RawOrigin::Signed(caller.clone().into()).into(), + liquidity_asset_id, + 10_000u128, + reward_token_id, + None + ).unwrap(); + + assert!( + TokensOf::::ensure_can_withdraw( + liquidity_asset_id.into(), + &caller, + MILION.into(), + WithdrawReasons::all(), + Default::default(), + ).is_err() + ); + + }: deactivate_liquidity_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id) + verify { + + assert!(TokensOf::::ensure_can_withdraw( + liquidity_asset_id.into(), + &caller, + MILION.into(), + WithdrawReasons::all(), + Default::default(), + ).is_ok()); + } impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index f9d424b652..19e325613c 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -658,6 +658,7 @@ impl Pallet { Self::set_liquidity_minting_checkpoint(user.clone(), liquidity_asset_id, amount)?; + println!("activate"); ::ActivationReservesProvider::activate( liquidity_asset_id, &user, @@ -753,6 +754,7 @@ impl Pallet { match use_balance_from { ScheduleActivationKind::ActivateKind(use_balance_from) => { + println!("activate"); ::ActivationReservesProvider::activate( liquidity_asset_id, &user, @@ -923,6 +925,7 @@ impl Pallet { ); } + println!("MINTING : {user:?} {liquidity_asset_id} {liquidity_assets_reward}"); ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, liquidity_assets_reward), |v| { @@ -1027,10 +1030,12 @@ impl Pallet { }, )?; + println!("BURNING : {user} {liquidity_asset_id} {reward_token}"); ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), |v| { v.and_then(|a| { + println!("{a} {liquidity_assets_burned}"); a.checked_sub(liquidity_assets_burned).and_then(|val| { if val > 0 { *v = Some(val); @@ -1060,6 +1065,7 @@ impl Pallet { }, ); + println!("deactivate"); ::ActivationReservesProvider::deactivate( liquidity_asset_id, &user, From 9ce2c487ce95c24a9b49e4f7314d6555867bd3e6 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 09:45:04 +0200 Subject: [PATCH 15/83] include new extrinsics in PoS::Weight --- pallets/proof-of-stake/src/lib.rs | 6 +++--- pallets/proof-of-stake/src/weights.rs | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 19e325613c..d188f86523 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -488,7 +488,7 @@ pub mod pallet { #[transactional] #[pallet::call_index(4)] // NOTE: implement benchmark - #[pallet::weight(<::WeightInfo>::claim_rewards_all())] + #[pallet::weight(<::WeightInfo>::reward_pool())] pub fn reward_pool( origin: OriginFor, pool: (TokenId, TokenId), @@ -568,7 +568,7 @@ pub mod pallet { /// be taken from available balance #[transactional] #[pallet::call_index(5)] - #[pallet::weight(<::WeightInfo>::activate_liquidity())] + #[pallet::weight(<::WeightInfo>::activate_liquidity_for_rewards_schedule())] pub fn activate_liquidity_for_rewards_schedule( origin: OriginFor, liquidity_token_id: TokenId, @@ -595,7 +595,7 @@ pub mod pallet { /// - use_balance_from - where from tokens should be used #[transactional] #[pallet::call_index(6)] - #[pallet::weight(<::WeightInfo>::activate_liquidity())] + #[pallet::weight(<::WeightInfo>::deactivate_liquidity_for_rewards_schedule())] pub fn deactivate_liquidity_for_rewards_schedule( origin: OriginFor, liquidity_token_id: TokenId, diff --git a/pallets/proof-of-stake/src/weights.rs b/pallets/proof-of-stake/src/weights.rs index 49e10aa4c8..024cc3133e 100644 --- a/pallets/proof-of-stake/src/weights.rs +++ b/pallets/proof-of-stake/src/weights.rs @@ -59,6 +59,9 @@ pub trait WeightInfo { fn update_pool_promotion() -> Weight; fn activate_liquidity() -> Weight; fn deactivate_liquidity() -> Weight; + fn deactivate_liquidity_for_rewards_schedule() -> Weight; + fn activate_liquidity_for_rewards_schedule() -> Weight; + fn reward_pool() -> Weight; } // For backwards compatibility and tests @@ -97,4 +100,22 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + + fn deactivate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn activate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn reward_pool() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } } From 504710499acc8d64e6aed2d98cb48b912c3e6a87 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 11:01:12 +0200 Subject: [PATCH 16/83] valuate MGX rewards properly --- pallets/proof-of-stake/src/lib.rs | 9 ++++++--- pallets/proof-of-stake/src/tests.rs | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index d188f86523..b75a5a5800 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -188,7 +188,7 @@ pub mod pallet { impl PoSBenchmarkingConfig for T {} #[cfg(not(feature = "runtime-benchmarks"))] - pub trait ValutationApiTrait: + pub trait ValutationApiTrait: Valuate { } @@ -521,7 +521,9 @@ pub mod pallet { ensure!( ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount) >= - T::MinRewardsPerSession::get(), + T::MinRewardsPerSession::get() || + ((token_id == Into::::into(Self::native_token_id())) && + amount_per_session >= T::MinRewardsPerSession::get()), Error::::TooLittleRewardsPerSession ); @@ -1305,5 +1307,6 @@ impl LiquidityMiningApi for Pallet { } } -// TODO: valuate rewards in MGX // TODO: dedicated ensures for every activation kind +// TODO: clean up test setup +// TODO: test schedule rewards without liquidity mining rewards diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 8fcd8aec11..0de86ee514 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1387,6 +1387,35 @@ fn reject_schedule_with_too_little_rewards_per_session() { }); } +#[test] +#[serial] +fn accept_schedule_valuated_in_native_token() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(1u128); + + let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(ProofOfStake::native_token_id(), &ALICE, 10).unwrap(); + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + + roll_to_session(4); + + assert_ok!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + ProofOfStake::native_token_id(), + 10, + 5u32.into() + ), + // Error::::TooLittleRewardsPerSession + ); + }); +} + #[test] #[serial] fn user_can_claim_3rdparty_rewards() { From 280a56b095081a55b43b85e7d2ca2b20b4b676b3 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 11:11:46 +0200 Subject: [PATCH 17/83] remove unnecessary pool promotion --- pallets/proof-of-stake/src/lib.rs | 1 - pallets/proof-of-stake/src/tests.rs | 5 ----- 2 files changed, 6 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index b75a5a5800..911febfb85 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1309,4 +1309,3 @@ impl LiquidityMiningApi for Pallet { // TODO: dedicated ensures for every activation kind // TODO: clean up test setup -// TODO: test schedule rewards without liquidity mining rewards diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 0de86ee514..626729dc2a 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1442,7 +1442,6 @@ fn user_can_claim_3rdparty_rewards() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, @@ -1520,7 +1519,6 @@ fn overlapping_3rdparty_rewards_works() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, @@ -1605,7 +1603,6 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, @@ -1691,7 +1688,6 @@ fn deactivate_3rdparty_rewards() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, @@ -1777,7 +1773,6 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); let amount = 10_000u128; - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, From 6c84c1106976c8ad28c095c29f32da77ff25236c Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 13:06:33 +0200 Subject: [PATCH 18/83] wip --- pallets/proof-of-stake/src/lib.rs | 4 +- pallets/proof-of-stake/src/mock.rs | 34 +++++ pallets/proof-of-stake/src/tests.rs | 184 ++++++++++++++++++++-------- 3 files changed, 171 insertions(+), 51 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 911febfb85..7bc6f04b0a 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -764,7 +764,6 @@ impl Pallet { use_balance_from, )?; }, - ScheduleActivationKind::LiquidityMining => {}, _ => {}, } @@ -927,7 +926,6 @@ impl Pallet { ); } - println!("MINTING : {user:?} {liquidity_asset_id} {liquidity_assets_reward}"); ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, liquidity_assets_reward), |v| { @@ -1307,5 +1305,5 @@ impl LiquidityMiningApi for Pallet { } } -// TODO: dedicated ensures for every activation kind // TODO: clean up test setup +// TODO: dedicated 3rdparty rewards api diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 1209e57255..a70a73d077 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -394,6 +394,40 @@ pub fn new_test_ext() -> sp_io::TestExternalities { ext } +pub struct ExtBuilder { + ext: sp_io::TestExternalities, +} + +impl ExtBuilder { + pub fn new() -> Self { + let t = frame_system::GenesisConfig::default() + .build_storage::() + .expect("Frame system builds valid default genesis config"); + + let mut ext = sp_io::TestExternalities::new(t); + Self { ext } + } + + fn create_if_does_not_exists(&mut self, token_id: TokenId) { + self.ext.execute_with(|| { + while token_id >= Tokens::next_asset_id() { + Tokens::create(RuntimeOrigin::root(), 0, 0).unwrap(); + } + }); + } + + pub fn issue(mut self, who: AccountId, token_id: TokenId, balance: Balance) -> Self { + self.create_if_does_not_exists(token_id); + self.ext + .execute_with(|| Tokens::mint(RuntimeOrigin::root(), token_id, who, balance).unwrap()); + return self + } + + pub fn build(self) -> sp_io::TestExternalities { + self.ext + } +} + /// Compares the system events with passed in events /// Prints highlighted diff iff assert_eq fails #[macro_export] diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 626729dc2a..72ccb8648c 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1101,6 +1101,10 @@ fn claim_rewards_from_pool_that_has_been_disabled() { } const MILLION: u128 = 1_000_000; +const REWARDED_PAIR: (TokenId, TokenId) = (0u32, 4u32); +const REWARD_AMOUNT: u128 = 10_000u128; +const REWARD_TOKEN: u32 = 5u32; +const LIQUIDITY_TOKEN: u32 = 10; const ALICE: u128 = 2; const BOB: u128 = 3; const CHARLIE: u128 = 4; @@ -1109,32 +1113,31 @@ const EVE: u128 = 5; #[test] #[serial] fn user_can_provide_3rdparty_rewards() { - new_test_ext().execute_with(|| { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); System::set_block_number(1); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT/2, 10u32.into(), ) .unwrap(); + roll_to_session(5); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT/2, 6u32.into(), ) .unwrap(); @@ -1144,24 +1147,23 @@ fn user_can_provide_3rdparty_rewards() { #[test] #[serial] fn cant_schedule_rewards_in_past() { - new_test_ext().execute_with(|| { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { System::set_block_number(1); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(10u32)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - roll_to_session(5); assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 1u32.into() ), Error::::CannotScheduleRewardsInPast @@ -1169,9 +1171,9 @@ fn cant_schedule_rewards_in_past() { assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 4u32.into() ), Error::::CannotScheduleRewardsInPast @@ -1179,9 +1181,9 @@ fn cant_schedule_rewards_in_past() { assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 5u32.into() ), Error::::CannotScheduleRewardsInPast @@ -1192,24 +1194,23 @@ fn cant_schedule_rewards_in_past() { #[test] #[serial] fn cannot_reward_unexisting_pool() { - new_test_ext().execute_with(|| { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock .expect() .return_const(Err(Error::::PoolDoesNotExist.into())); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 5u32.into() ), Error::::PoolDoesNotExist @@ -1220,32 +1221,32 @@ fn cannot_reward_unexisting_pool() { #[test] #[serial] fn rewards_are_stored_in_pallet_account() { - new_test_ext().execute_with(|| { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(10u32)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - assert_eq!(TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), 0); - assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION); + assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), 0); + assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), REWARD_AMOUNT); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 5u32.into() ),); - assert_eq!(TokensOf::::free_balance(token_id, &ALICE), MILLION - amount); + assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), 0); assert_eq!( - TokensOf::::free_balance(token_id, &Pallet::::pallet_account()), - amount + TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), + REWARD_AMOUNT ); }); } @@ -2184,3 +2185,90 @@ fn can_claim_schedule_rewards() { ); }); } + +#[test] +#[serial] +fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_liq_minting() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN: u32 = 5; + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); + + assert_err!( + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_token_id, + None, + ), + Error::::NotAPromotedPool + ); + }); +} + + +#[test] +#[serial] +fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_schedule_rewards() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN: u32 = 5; + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); + assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + + let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_token_id, + amount, + 10u32.into(), + ) + .unwrap(); + + assert_err!( + ProofOfStake::activate_liquidity( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + None, + ), + Error::::NotAPromotedPool + ); + }); +} From bf719f6919da892192249b4d1b4d015ca83a113e Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 26 Sep 2023 17:00:15 +0200 Subject: [PATCH 19/83] tests cleanup --- pallets/proof-of-stake/src/mock.rs | 2 +- pallets/proof-of-stake/src/tests.rs | 1936 +++++++++++++-------------- 2 files changed, 957 insertions(+), 981 deletions(-) diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index a70a73d077..a7541ee8a3 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -417,7 +417,7 @@ impl ExtBuilder { } pub fn issue(mut self, who: AccountId, token_id: TokenId, balance: Balance) -> Self { - self.create_if_does_not_exists(token_id); + self.create_if_does_not_exists(token_id); self.ext .execute_with(|| Tokens::mint(RuntimeOrigin::root(), token_id, who, balance).unwrap()); return self diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 72ccb8648c..82a4f99737 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1104,6 +1104,8 @@ const MILLION: u128 = 1_000_000; const REWARDED_PAIR: (TokenId, TokenId) = (0u32, 4u32); const REWARD_AMOUNT: u128 = 10_000u128; const REWARD_TOKEN: u32 = 5u32; +const FIRST_REWARD_TOKEN: u32 = REWARD_TOKEN; +const SECOND_REWARD_TOKEN: u32 = 6u32; const LIQUIDITY_TOKEN: u32 = 10; const ALICE: u128 = 2; const BOB: u128 = 3; @@ -1113,196 +1115,196 @@ const EVE: u128 = 5; #[test] #[serial] fn user_can_provide_3rdparty_rewards() { - ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - System::set_block_number(1); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT/2, - 10u32.into(), - ) - .unwrap(); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + System::set_block_number(1); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT / 2, + 10u32.into(), + ) + .unwrap(); - roll_to_session(5); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT/2, - 6u32.into(), - ) - .unwrap(); - }); + roll_to_session(5); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT / 2, + 6u32.into(), + ) + .unwrap(); + }); } #[test] #[serial] fn cant_schedule_rewards_in_past() { - ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { - System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - roll_to_session(5); - assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 1u32.into() - ), - Error::::CannotScheduleRewardsInPast - ); - assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 4u32.into() - ), - Error::::CannotScheduleRewardsInPast - ); - assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 5u32.into() - ), - Error::::CannotScheduleRewardsInPast - ); - }); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + roll_to_session(5); + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 1u32.into() + ), + Error::::CannotScheduleRewardsInPast + ); + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 4u32.into() + ), + Error::::CannotScheduleRewardsInPast + ); + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 5u32.into() + ), + Error::::CannotScheduleRewardsInPast + ); + }); } #[test] #[serial] fn cannot_reward_unexisting_pool() { - ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock - .expect() - .return_const(Err(Error::::PoolDoesNotExist.into())); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 5u32.into() - ), - Error::::PoolDoesNotExist - ); - }); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock + .expect() + .return_const(Err(Error::::PoolDoesNotExist.into())); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 5u32.into() + ), + Error::::PoolDoesNotExist + ); + }); } #[test] #[serial] fn rewards_are_stored_in_pallet_account() { - ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { - - System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), 0); - assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), REWARD_AMOUNT); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_eq!( + TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), + 0 + ); + assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), REWARD_AMOUNT); - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 5u32.into() - ),); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 5u32.into() + ),); - assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), 0); - assert_eq!( - TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), - REWARD_AMOUNT - ); - }); + assert_eq!(TokensOf::::free_balance(REWARD_TOKEN, &ALICE), 0); + assert_eq!( + TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), + REWARD_AMOUNT + ); + }); } #[test] #[serial] fn rewards_schedule_is_stored() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - let liquidity_token_id = 10u32; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(liquidity_token_id)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, - 5u32.into() - ),); - - assert_eq!( - ProofOfStake::schedules().into_inner(), - BTreeMap::from([((5u64, liquidity_token_id, token_id, amount / 5, 0), ())]) - ); - }); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 5u32.into() + ),); + + let rewards_per_session = REWARD_AMOUNT / 5; + assert_eq!( + ProofOfStake::schedules().into_inner(), + BTreeMap::from([( + (5u64, LIQUIDITY_TOKEN, REWARD_TOKEN, rewards_per_session, 0), + () + )]) + ); + }); } #[test] #[serial] fn number_of_active_schedules_is_limited() { - new_test_ext().execute_with(|| { + ExtBuilder::new().issue(ALICE, REWARD_TOKEN, MILLION).build().execute_with(|| { System::set_block_number(1); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(10u32)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - let max_schedules: u32 = <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); for i in 0..(max_schedules) { assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, (5u32 + i).into() )); } @@ -1310,9 +1312,9 @@ fn number_of_active_schedules_is_limited() { assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 100u32.into() ), Error::::TooManySchedules @@ -1322,9 +1324,9 @@ fn number_of_active_schedules_is_limited() { assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, 100u32.into() )); }); @@ -1333,942 +1335,916 @@ fn number_of_active_schedules_is_limited() { #[test] #[serial] fn duplicated_schedules_works() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, - 5u32.into() - )); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT / 2, + 5u32.into() + )); - assert_eq!(1, ProofOfStake::schedules().len()); + assert_eq!(1, ProofOfStake::schedules().len()); - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, - 5u32.into() - )); - assert_eq!(2, ProofOfStake::schedules().len()); - }); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT / 2, + 5u32.into() + )); + assert_eq!(2, ProofOfStake::schedules().len()); + }); } #[test] #[serial] fn reject_schedule_with_too_little_rewards_per_session() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(1u128); - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - roll_to_session(4); - - assert_err!( - ProofOfStake::reward_pool(RuntimeOrigin::signed(ALICE), pair, token_id, 1, 5u32.into()), - Error::::TooLittleRewardsPerSession - ); - }); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(1u128); + + roll_to_session(4); + + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 1, + 5u32.into() + ), + Error::::TooLittleRewardsPerSession + ); + }); } #[test] #[serial] fn accept_schedule_valuated_in_native_token() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(1u128); - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(ProofOfStake::native_token_id(), &ALICE, 10).unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + ExtBuilder::new() + .issue(ALICE, ProofOfStake::native_token_id(), REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(1u128); + + roll_to_session(4); - roll_to_session(4); - - assert_ok!( - ProofOfStake::reward_pool( + assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - pair, + REWARDED_PAIR, ProofOfStake::native_token_id(), 10, 5u32.into() - ), - // Error::::TooLittleRewardsPerSession - ); - }); + ),); + }); } #[test] #[serial] fn user_can_claim_3rdparty_rewards() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .issue(EVE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); + + let amount = 10_000u128; - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(0) + ); + + roll_to_session(2); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1000) + ); + + roll_to_session(3); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1500) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(500) + ); + }); +} - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; +#[test] +#[serial] +fn overlapping_3rdparty_rewards_works() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + const LIQUIDITY_TOKEN: u32 = 5; + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); + + let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); + let amount = 10_000u128; - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, - 10u32.into(), - ) - .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + first_reward_token, + amount, + 10u32.into(), + ) + .unwrap(); - roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - token_id, - None, - ) - .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), - Ok(0) - ); + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_reward_token, + None, + ) + .unwrap(); - roll_to_session(2); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(CHARLIE), - LIQUIDITY_TOKEN, - 100, - token_id, - None, - ) - .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), - Ok(0) - ); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), - Ok(1000) - ); + roll_to_session(5); + let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_reward_token_id, + 100_000, + 15u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_reward_token_id, + None, + ) + .unwrap(); - roll_to_session(3); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), - Ok(1500) - ); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), - Ok(500) - ); - }); + roll_to_session(6); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + second_reward_token_id + ), + Ok(10000) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + first_reward_token + ), + Ok(5000) + ); + }); } #[test] #[serial] -fn overlapping_3rdparty_rewards_works() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); +fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 200) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; + roll_to_session(5); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 100_000, + 15u32.into(), + ) + .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_reward_token, - amount, - 10u32.into(), - ) - .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + ) + .unwrap(); - roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_reward_token, - None, - ) - .unwrap(); + roll_to_session(6); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN + ), + Ok(10000) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN + ), + Ok(5000) + ); + }); +} - roll_to_session(5); - let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_reward_token_id, - 100_000, - 15u32.into(), - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_reward_token_id, - None, - ) - .unwrap(); +#[test] +#[serial] +fn deactivate_3rdparty_rewards() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); - roll_to_session(6); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( - BOB, + roll_to_session(1); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, - second_reward_token_id - ), - Ok(10000) - ); + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( - BOB, + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, - first_reward_token - ), - Ok(5000) - ); - }); + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + roll_to_session(2); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(500) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(500) + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + ) + .unwrap(); + + roll_to_session(3); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1500) + ); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(500) + ); + }); } #[test] #[serial] -fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_reward_token, - amount, - 10u32.into(), - ) - .unwrap(); - - roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_reward_token, - None, - ) - .unwrap(); - - roll_to_session(5); - let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_reward_token_id, - 100_000, - 15u32.into(), - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_reward_token_id, - Some(ScheduleActivationKind::ActivatedLiquidity(first_reward_token)), - ) - .unwrap(); +fn claim_rewards_from_multiple_schedules_using_single_liquidity() { + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + System::set_block_number(1); - roll_to_session(6); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 2 * REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( - BOB, + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, - second_reward_token_id - ), - Ok(10000) - ); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( - BOB, + 100, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, - first_reward_token - ), - Ok(5000) - ); - }); -} - -#[test] -#[serial] -fn deactivate_3rdparty_rewards() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - token_id, - amount, - 10u32.into(), - ) - .unwrap(); - - roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - token_id, - None, - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(CHARLIE), - LIQUIDITY_TOKEN, - 100, - token_id, - None, - ) - .unwrap(); - - roll_to_session(2); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), - Ok(500) - ); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), - Ok(500) - ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(CHARLIE), - LIQUIDITY_TOKEN, - 100, - token_id, - ) - .unwrap(); - - roll_to_session(3); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, token_id), - Ok(1500) - ); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(CHARLIE, LIQUIDITY_TOKEN, token_id), - Ok(500) - ); - }); -} - -#[test] -#[serial] -fn claim_rewards_from_multiple_schedules_using_single_liquidity() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_token_id, - 2 * amount, - 10u32.into(), - ) - .unwrap(); - - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - None, - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_token_id, - Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), - ) - .unwrap(); - - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), - Ok(0) - ); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), - Ok(0) - ); - - roll_to_session(1); + 100, + SECOND_REWARD_TOKEN, + Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + ) + .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), - Ok(1000) - ); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), - Ok(2000) - ); - }); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN + ), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN + ), + Ok(0) + ); + + roll_to_session(1); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN + ), + Ok(1000) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN + ), + Ok(2000) + ); + }); } #[test] #[serial] fn liquidity_minting_liquidity_can_be_resused() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_token_id, - 2 * amount, - 10u32.into(), - ) - .unwrap(); - - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None) + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 2 * REWARD_AMOUNT, + 10u32.into(), + ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - Some(ScheduleActivationKind::LiquidityMining), - ) - .unwrap(); - roll_to_session(1); + ProofOfStake::activate_liquidity( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + Some(ScheduleActivationKind::LiquidityMining), + ) + .unwrap(); - assert_eq!(ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), Ok(200)); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), - Ok(1000) - ); - }); + roll_to_session(1); + + assert_eq!(ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), Ok(200)); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN + ), + Ok(1000) + ); + }); } #[test] #[serial] fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_token_id, - 2 * amount, - 10u32.into(), - ) - .unwrap(); + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 2 * REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None) + ProofOfStake::activate_liquidity( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + None, + ) .unwrap(); - assert_err!( - TokensOf::::transfer( + assert_err!( + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), + orml_tokens::Error::::BalanceTooLow + ); + + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, - &BOB, - &CHARLIE, 100, - ExistenceRequirement::AllowDeath - ), - orml_tokens::Error::::BalanceTooLow - ); - - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - Some(ScheduleActivationKind::LiquidityMining), - ) - .unwrap(); + FIRST_REWARD_TOKEN, + Some(ScheduleActivationKind::LiquidityMining), + ) + .unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - None, - ) - .unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 200, - first_token_id, - ) - .unwrap(); - assert_err!( - TokensOf::::transfer( + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 200, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + assert_err!( + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 101, + ExistenceRequirement::AllowDeath + ), + orml_tokens::Error::::BalanceTooLow + ); + + assert_ok!(TokensOf::::transfer( LIQUIDITY_TOKEN, &BOB, &CHARLIE, - 101, + 100, ExistenceRequirement::AllowDeath - ), - orml_tokens::Error::::BalanceTooLow - ); - - assert_ok!(TokensOf::::transfer( - LIQUIDITY_TOKEN, - &BOB, - &CHARLIE, - 100, - ExistenceRequirement::AllowDeath - )); - }); + )); + }); } #[test] #[serial] fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 2 * REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + ) + .unwrap(); - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - None, - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_token_id, - Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), - ) - .unwrap(); + assert_err!( + TokensOf::::transfer( + 0, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), + orml_tokens::Error::::BalanceTooLow + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + assert_err!( + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), + orml_tokens::Error::::BalanceTooLow + ); + ProofOfStake::deactivate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + ) + .unwrap(); - assert_err!( - TokensOf::::transfer(0, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath), - orml_tokens::Error::::BalanceTooLow - ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - ) - .unwrap(); - assert_err!( - TokensOf::::transfer( + assert_ok!(TokensOf::::transfer( LIQUIDITY_TOKEN, &BOB, &CHARLIE, 100, ExistenceRequirement::AllowDeath - ), - orml_tokens::Error::::BalanceTooLow - ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_token_id, - ) - .unwrap(); - - assert_ok!(TokensOf::::transfer( - LIQUIDITY_TOKEN, - &BOB, - &CHARLIE, - 100, - ExistenceRequirement::AllowDeath - ),); - }); + ),); + }); } #[test] #[serial] fn can_claim_schedule_rewards() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + System::set_block_number(1); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_token_id, - amount, - 10u32.into(), - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - None, - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_token_id, - Some(ScheduleActivationKind::ActivatedLiquidity(first_token_id)), - ) - .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + SECOND_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + ) + .unwrap(); - roll_to_session(1); + roll_to_session(1); - assert_eq!(TokensOf::::free_balance(first_token_id, &BOB), 0,); - assert_eq!(TokensOf::::free_balance(second_token_id, &BOB), 0,); + assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 0,); + assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 0,); - ProofOfStake::claim_schedule_rewards_all( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - first_token_id, - ) - .unwrap(); - ProofOfStake::claim_schedule_rewards_all( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - second_token_id, - ) - .unwrap(); + ProofOfStake::claim_schedule_rewards_all( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(); - assert_eq!(TokensOf::::free_balance(first_token_id, &BOB), 1000,); - assert_eq!(TokensOf::::free_balance(second_token_id, &BOB), 1000,); + ProofOfStake::claim_schedule_rewards_all( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, first_token_id), - Ok(0) - ); - assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, second_token_id), - Ok(0) - ); - }); + assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 1000,); + assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 1000,); + + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN + ), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_rewards_amount_3rdparty( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN + ), + Ok(0) + ); + }); } #[test] #[serial] fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_liq_minting() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8).unwrap(); - - assert_err!( - ProofOfStake::activate_liquidity_for_rewards_schedule( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_token_id, - None, - ), - Error::::NotAPromotedPool - ); - }); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + System::set_block_number(1); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + + assert_err!( + ProofOfStake::activate_liquidity_for_rewards_schedule( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ), + Error::::NotAPromotedPool + ); + }); } - #[test] #[serial] fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_schedule_rewards() { - new_test_ext().execute_with(|| { - System::set_block_number(1); - const LIQUIDITY_TOKEN: u32 = 5; - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - - assert_eq!(0, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(1, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(2, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(3, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(4, TokensOf::::create(&ALICE, 0).unwrap()); - assert_eq!(5, TokensOf::::create(&ALICE, 0).unwrap()); - - let first_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - let second_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - - let pair: (TokenId, TokenId) = (0u32.into(), 4u32.into()); - let amount = 10_000u128; - - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - first_token_id, - amount, - 10u32.into(), - ) - .unwrap(); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); - assert_err!( - ProofOfStake::activate_liquidity( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - None, - ), - Error::::NotAPromotedPool - ); - }); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + assert_err!( + ProofOfStake::activate_liquidity( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + None, + ), + Error::::NotAPromotedPool + ); + }); } From 4b5f06acccc904e35f36b42e329d8d93d812f9a0 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 12:19:02 +0200 Subject: [PATCH 20/83] wip rpc/runtime api --- node/Cargo.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/node/Cargo.toml b/node/Cargo.toml index 000f3df6aa..7c74378f50 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -143,6 +143,8 @@ polkadot-test-service = { git = "https://github.com/mangata-finance/polkadot", b # Mangata dependencies xyk-rpc = { default-features = false, version = '2.0.0', path = '../pallets/xyk/rpc' } xyk-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/xyk/runtime-api' } +proof-of-stake-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } +proof-of-stake-rpc = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } [dev-dependencies] From 87f7df41326289f0a882dd99ae5ff7a90eaae78d Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 13:01:10 +0200 Subject: [PATCH 21/83] rpc/runtime api --- Cargo.lock | 127 ++++++++++++++++++ node/Cargo.toml | 2 +- pallets/proof-of-stake/rpc/Cargo.toml | 36 +++++ pallets/proof-of-stake/rpc/src/lib.rs | 78 +++++++++++ pallets/proof-of-stake/runtime-api/Cargo.toml | 30 +++++ pallets/proof-of-stake/runtime-api/src/lib.rs | 122 +++++++++++++++++ 6 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 pallets/proof-of-stake/rpc/Cargo.toml create mode 100644 pallets/proof-of-stake/rpc/src/lib.rs create mode 100644 pallets/proof-of-stake/runtime-api/Cargo.toml create mode 100644 pallets/proof-of-stake/runtime-api/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index 30825a1e55..1b8d1058a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3235,6 +3235,10 @@ name = "futures-timer" version = "3.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" +dependencies = [ + "gloo-timers", + "send_wrapper", +] [[package]] name = "futures-util" @@ -3370,6 +3374,51 @@ dependencies = [ "regex", ] +[[package]] +name = "gloo-net" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9902a044653b26b99f7e3693a42f171312d9be8b26b5697bd1e43ad1f8a35e10" +dependencies = [ + "futures-channel", + "futures-core", + "futures-sink", + "gloo-utils", + "js-sys", + "pin-project", + "serde", + "serde_json", + "thiserror", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "gloo-timers" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b995a66bb87bebce9a0f4a95aed01daca4872c050bfcb21653361c03bc35e5c" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gloo-utils" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "037fcb07216cb3a30f7292bd0176b050b7b9a052ba830ef7d5d65f6dc64ba58e" +dependencies = [ + "js-sys", + "serde", + "serde_json", + "wasm-bindgen", + "web-sys", +] + [[package]] name = "group" version = "0.12.1" @@ -3638,6 +3687,7 @@ dependencies = [ "rustls-native-certs", "tokio", "tokio-rustls", + "webpki-roots", ] [[package]] @@ -3906,10 +3956,13 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7d291e3a5818a2384645fd9756362e6d89cf0541b0b916fa7702ea4a9833608e" dependencies = [ + "jsonrpsee-client-transport", "jsonrpsee-core", + "jsonrpsee-http-client", "jsonrpsee-proc-macros", "jsonrpsee-server", "jsonrpsee-types", + "jsonrpsee-wasm-client", "jsonrpsee-ws-client", "tracing", ] @@ -3920,7 +3973,11 @@ version = "0.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "965de52763f2004bc91ac5bcec504192440f0b568a5d621c59d9dbd6f886c3fb" dependencies = [ + "anyhow", + "futures-channel", + "futures-timer", "futures-util", + "gloo-net", "http", "jsonrpsee-core", "jsonrpsee-types", @@ -3961,6 +4018,26 @@ dependencies = [ "thiserror", "tokio", "tracing", + "wasm-bindgen-futures", +] + +[[package]] +name = "jsonrpsee-http-client" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc345b0a43c6bc49b947ebeb936e886a419ee3d894421790c969cc56040542ad" +dependencies = [ + "async-trait", + "hyper", + "hyper-rustls", + "jsonrpsee-core", + "jsonrpsee-types", + "rustc-hash", + "serde", + "serde_json", + "thiserror", + "tokio", + "tracing", ] [[package]] @@ -4012,6 +4089,17 @@ dependencies = [ "tracing", ] +[[package]] +name = "jsonrpsee-wasm-client" +version = "0.16.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77310456f43c6c89bcba1f6b2fc2a28300da7c341f320f5128f8c83cc63232d" +dependencies = [ + "jsonrpsee-client-transport", + "jsonrpsee-core", + "jsonrpsee-types", +] + [[package]] name = "jsonrpsee-ws-client" version = "0.16.2" @@ -5014,6 +5102,8 @@ dependencies = [ "polkadot-runtime-common", "polkadot-service", "polkadot-test-service", + "proof-of-stake-rpc", + "proof-of-stake-runtime-api", "sc-basic-authorship-ver", "sc-block-builder-ver", "sc-chain-spec", @@ -9185,6 +9275,37 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "proof-of-stake-rpc" +version = "2.0.0" +dependencies = [ + "jsonrpsee", + "parity-scale-codec", + "proof-of-stake-runtime-api", + "serde", + "sp-api", + "sp-blockchain", + "sp-core", + "sp-rpc", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "proof-of-stake-runtime-api" +version = "2.0.0" +dependencies = [ + "frame-support", + "frame-system", + "parity-scale-codec", + "serde", + "serde_json", + "sp-api", + "sp-core", + "sp-runtime", + "sp-std", +] + [[package]] name = "prost" version = "0.11.9" @@ -11427,6 +11548,12 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "send_wrapper" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0" + [[package]] name = "separator" version = "0.4.1" diff --git a/node/Cargo.toml b/node/Cargo.toml index 7c74378f50..9b0b2abac1 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -144,7 +144,7 @@ polkadot-test-service = { git = "https://github.com/mangata-finance/polkadot", b xyk-rpc = { default-features = false, version = '2.0.0', path = '../pallets/xyk/rpc' } xyk-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/xyk/runtime-api' } proof-of-stake-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } -proof-of-stake-rpc = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } +proof-of-stake-rpc = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/rpc' } [dev-dependencies] diff --git a/pallets/proof-of-stake/rpc/Cargo.toml b/pallets/proof-of-stake/rpc/Cargo.toml new file mode 100644 index 0000000000..705babe0f5 --- /dev/null +++ b/pallets/proof-of-stake/rpc/Cargo.toml @@ -0,0 +1,36 @@ +[package] +authors = ['Mangata team'] +name = "proof-of-stake-rpc" +version = "2.0.0" +edition = "2018" +description = "RPC calls for Proof of Stake" +license = "GPL-3.0-or-later" + +[dependencies] +codec = { package = "parity-scale-codec", version = "3.0.0" } +jsonrpsee = { version = "0.16.2", features = ["server", "client", "macros"] } +serde = { version = "1.0.126", features = ["derive"], optional = true } + +# Substrate packages + +sp-api = { version = '4.0.0-dev', default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-blockchain = { version = '4.0.0-dev', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-rpc = { version = '6.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-core = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-std = { version = '5.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-runtime = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } + +# local packages + +proof-of-stake-runtime-api = { version = "2.0.0", path = "../runtime-api", default-features = false } + +[features] +default = ["std"] +std = [ + "serde", + "sp-api/std", + "sp-core/std", + "sp-std/std", + "sp-runtime/std", + "proof-of-stake-runtime-api/std" +] diff --git a/pallets/proof-of-stake/rpc/src/lib.rs b/pallets/proof-of-stake/rpc/src/lib.rs new file mode 100644 index 0000000000..64a893a87d --- /dev/null +++ b/pallets/proof-of-stake/rpc/src/lib.rs @@ -0,0 +1,78 @@ +// Copyright (C) 2021 Mangata team + +use codec::Codec; +use jsonrpsee::{ + core::{async_trait, Error as JsonRpseeError, RpcResult}, + proc_macros::rpc, + types::error::{CallError, ErrorObject}, +}; +use sp_api::ProvideRuntimeApi; +use sp_blockchain::HeaderBackend; +use sp_core::U256; +use sp_rpc::number::NumberOrHex; +use sp_runtime::{ + generic::BlockId, + traits::{Block as BlockT, MaybeDisplay, MaybeFromStr}, +}; +use sp_std::convert::{TryFrom, TryInto}; +use std::sync::Arc; +pub use proof_of_stake_runtime_api::XykApi as XykRuntimeApi; +use proof_of_stake_runtime_api::{RpcAmountsResult, RpcAssetMetadata, XYKRpcResult}; + +#[rpc(client, server)] +pub trait ProofOfStakeApi< + BlockHash, + Balance, + TokenId, + AccountId +> +{ + #[method(name = "foo")] + fn foo( + &self, + account: AccountId, + liquidity_token: TokenId, + reward_token: TokenId, + at: Option, + ) -> RpcResult; +} + +pub struct ProofOfStake { + client: Arc, + _marker: std::marker::PhantomData, +} + +impl ProofOfStake { + pub fn new(client: Arc) -> Self { + Self { client, _marker: Default::default() } + } +} + +#[async_trait] +impl + ProofOfStakeApiServer< + ::Hash, + NumberOrHex, + TokenId, + AccountId + > for ProofOfStake +where + Block: BlockT, + C: Send + Sync + 'static, + C: ProvideRuntimeApi, + C: HeaderBackend, + C::Api: XykRuntimeApi, + Balance: Codec + MaybeDisplay + MaybeFromStr + TryFrom, + TokenId: Codec + MaybeDisplay + MaybeFromStr, + AccountId: Codec + MaybeDisplay + MaybeFromStr, +{ + fn foo( + &self, + account: AccountId, + liquidity_token: TokenId, + reward_token: TokenId, + at: Option, + ) -> RpcResult> { + } + +} diff --git a/pallets/proof-of-stake/runtime-api/Cargo.toml b/pallets/proof-of-stake/runtime-api/Cargo.toml new file mode 100644 index 0000000000..34d8be4bf3 --- /dev/null +++ b/pallets/proof-of-stake/runtime-api/Cargo.toml @@ -0,0 +1,30 @@ +[package] +authors = ['Mangata team'] +name = "proof-of-stake-runtime-api" +version = "2.0.0" +edition = "2018" +license = "GPL-3.0-or-later" + +[dependencies] +serde = { version = "1.0.126", optional = true, features = ["derive"] } +sp-api = { version = '4.0.0-dev', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-std = { default-features = false, version = '5.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-runtime = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +frame-support = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +frame-system = { default-features = false, version = '4.0.0-dev' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +sp-core = { default-features = false, version = '7.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] } + +[dev-dependencies] +serde_json = "1.0.68" + +[features] +default = ["std"] +std = [ + "serde", + "sp-api/std", + "codec/std", + "sp-runtime/std", + "frame-support/std", + 'frame-system/std' +] diff --git a/pallets/proof-of-stake/runtime-api/src/lib.rs b/pallets/proof-of-stake/runtime-api/src/lib.rs new file mode 100644 index 0000000000..9af1f6bfc2 --- /dev/null +++ b/pallets/proof-of-stake/runtime-api/src/lib.rs @@ -0,0 +1,122 @@ +// Copyright (C) 2021 Mangata team +#![cfg_attr(not(feature = "std"), no_std)] +#![allow(clippy::too_many_arguments)] +#![allow(clippy::unnecessary_mut_passed)] +use codec::{Codec, Decode, Encode}; +#[cfg(feature = "std")] +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use sp_runtime::traits::{MaybeDisplay, MaybeFromStr}; +use sp_std::vec::Vec; +// Workaround for substrate/serde issue +#[derive(Eq, PartialEq, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub struct XYKRpcResult { + #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] + #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] + #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] + #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] + pub price: Balance, +} + +#[derive(Eq, PartialEq, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub struct RpcAmountsResult { + #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] + #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] + #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] + #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] + pub first_asset_amount: Balance, + #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] + #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] + #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] + #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] + pub second_asset_amount: Balance, +} + +#[derive(Eq, PartialEq, Encode, Decode, Default)] +#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] +#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] +pub struct RpcAssetMetadata { + pub token_id: TokenId, + pub decimals: u32, + pub name: Vec, + pub symbol: Vec, +} + +#[cfg(feature = "std")] +fn serialize_as_string( + t: &T, + serializer: S, +) -> Result { + serializer.serialize_str(&t.to_string()) +} + +#[cfg(feature = "std")] +fn deserialize_from_string<'de, D: Deserializer<'de>, T: std::str::FromStr>( + deserializer: D, +) -> Result { + let s = String::deserialize(deserializer)?; + s.parse::().map_err(|_| serde::de::Error::custom("Parse from string failed")) +} + +sp_api::decl_runtime_apis! { + pub trait XykApi where + Balance: Codec + MaybeDisplay + MaybeFromStr, + TokenId: Codec + MaybeDisplay + MaybeFromStr, + AccountId: Codec + MaybeDisplay + MaybeFromStr,{ + fn calculate_sell_price( + input_reserve: Balance, + output_reserve: Balance, + sell_amount: Balance + ) -> XYKRpcResult; + fn calculate_buy_price( + input_reserve: Balance, + output_reserve: Balance, + buy_amount: Balance + ) -> XYKRpcResult; + fn calculate_sell_price_id( + sold_token_id: TokenId, + bought_token_id: TokenId, + sell_amount: Balance + ) -> XYKRpcResult; + fn calculate_buy_price_id( + sold_token_id: TokenId, + bought_token_id: TokenId, + buy_amount: Balance + ) -> XYKRpcResult; + fn get_burn_amount( + first_asset_id: TokenId, + second_asset_id: TokenId, + liquidity_asset_amount: Balance, + ) -> RpcAmountsResult; + fn get_max_instant_burn_amount( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> XYKRpcResult; + fn get_max_instant_unreserve_amount( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> XYKRpcResult; + fn calculate_rewards_amount( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> XYKRpcResult; + fn calculate_balanced_sell_amount( + total_amount: Balance, + reserve_amount: Balance, + ) -> XYKRpcResult; + fn get_liq_tokens_for_trading( + ) -> Vec; + fn is_buy_asset_lock_free( + path: sp_std::vec::Vec, + input_amount: Balance, + ) -> Option; + fn is_sell_asset_lock_free( + path: sp_std::vec::Vec, + input_amount: Balance, + ) -> Option; + fn get_tradeable_tokens() -> Vec>; + } +} From 9792895f15c104d0fd366edbc5a861fa4b3e9132 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 12:55:37 +0000 Subject: [PATCH 22/83] renaming --- Cargo.lock | 1 + pallets/proof-of-stake/runtime-api/src/lib.rs | 115 ++----------- pallets/proof-of-stake/src/benchmarking.rs | 8 +- pallets/proof-of-stake/src/lib.rs | 149 +++++++++++----- pallets/proof-of-stake/src/mock.rs | 1 - pallets/proof-of-stake/src/tests.rs | 160 +++++++++--------- pallets/proof-of-stake/src/weights.rs | 26 ++- runtime/mangata-kusama/Cargo.toml | 2 + runtime/mangata-kusama/src/lib.rs | 30 +++- .../src/weights/pallet_proof_of_stake.rs | 41 +++++ 10 files changed, 291 insertions(+), 242 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1b8d1058a6..b47f9a9963 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5031,6 +5031,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", + "proof-of-stake-runtime-api", "scale-info", "serde", "smallvec", diff --git a/pallets/proof-of-stake/runtime-api/src/lib.rs b/pallets/proof-of-stake/runtime-api/src/lib.rs index 9af1f6bfc2..812438f4bf 100644 --- a/pallets/proof-of-stake/runtime-api/src/lib.rs +++ b/pallets/proof-of-stake/runtime-api/src/lib.rs @@ -1,122 +1,29 @@ // Copyright (C) 2021 Mangata team #![cfg_attr(not(feature = "std"), no_std)] -#![allow(clippy::too_many_arguments)] -#![allow(clippy::unnecessary_mut_passed)] use codec::{Codec, Decode, Encode}; -#[cfg(feature = "std")] -use serde::{Deserialize, Deserializer, Serialize, Serializer}; use sp_runtime::traits::{MaybeDisplay, MaybeFromStr}; use sp_std::vec::Vec; -// Workaround for substrate/serde issue -#[derive(Eq, PartialEq, Encode, Decode, Default)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] -#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] -pub struct XYKRpcResult { - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - pub price: Balance, -} - -#[derive(Eq, PartialEq, Encode, Decode, Default)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] -#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] -pub struct RpcAmountsResult { - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - pub first_asset_amount: Balance, - #[cfg_attr(feature = "std", serde(bound(serialize = "Balance: std::fmt::Display")))] - #[cfg_attr(feature = "std", serde(serialize_with = "serialize_as_string"))] - #[cfg_attr(feature = "std", serde(bound(deserialize = "Balance: std::str::FromStr")))] - #[cfg_attr(feature = "std", serde(deserialize_with = "deserialize_from_string"))] - pub second_asset_amount: Balance, -} - -#[derive(Eq, PartialEq, Encode, Decode, Default)] -#[cfg_attr(feature = "std", derive(Debug, Serialize, Deserialize))] -#[cfg_attr(feature = "std", serde(rename_all = "camelCase"))] -pub struct RpcAssetMetadata { - pub token_id: TokenId, - pub decimals: u32, - pub name: Vec, - pub symbol: Vec, -} - -#[cfg(feature = "std")] -fn serialize_as_string( - t: &T, - serializer: S, -) -> Result { - serializer.serialize_str(&t.to_string()) -} - -#[cfg(feature = "std")] -fn deserialize_from_string<'de, D: Deserializer<'de>, T: std::str::FromStr>( - deserializer: D, -) -> Result { - let s = String::deserialize(deserializer)?; - s.parse::().map_err(|_| serde::de::Error::custom("Parse from string failed")) -} sp_api::decl_runtime_apis! { - pub trait XykApi where + pub trait ProofOfStakeApi where Balance: Codec + MaybeDisplay + MaybeFromStr, TokenId: Codec + MaybeDisplay + MaybeFromStr, AccountId: Codec + MaybeDisplay + MaybeFromStr,{ - fn calculate_sell_price( - input_reserve: Balance, - output_reserve: Balance, - sell_amount: Balance - ) -> XYKRpcResult; - fn calculate_buy_price( - input_reserve: Balance, - output_reserve: Balance, - buy_amount: Balance - ) -> XYKRpcResult; - fn calculate_sell_price_id( - sold_token_id: TokenId, - bought_token_id: TokenId, - sell_amount: Balance - ) -> XYKRpcResult; - fn calculate_buy_price_id( - sold_token_id: TokenId, - bought_token_id: TokenId, - buy_amount: Balance - ) -> XYKRpcResult; - fn get_burn_amount( - first_asset_id: TokenId, - second_asset_id: TokenId, - liquidity_asset_amount: Balance, - ) -> RpcAmountsResult; - fn get_max_instant_burn_amount( + + fn calculate_native_rewards_amount( user: AccountId, liquidity_asset_id: TokenId, - ) -> XYKRpcResult; - fn get_max_instant_unreserve_amount( + ) -> Balance; + + fn calculate_3rdparty_rewards_amount( user: AccountId, liquidity_asset_id: TokenId, - ) -> XYKRpcResult; - fn calculate_rewards_amount( + reward_asset_id: TokenId, + ) -> Balance; + + fn calculate_3rdparty_rewards_amount_all( user: AccountId, liquidity_asset_id: TokenId, - ) -> XYKRpcResult; - fn calculate_balanced_sell_amount( - total_amount: Balance, - reserve_amount: Balance, - ) -> XYKRpcResult; - fn get_liq_tokens_for_trading( - ) -> Vec; - fn is_buy_asset_lock_free( - path: sp_std::vec::Vec, - input_amount: Balance, - ) -> Option; - fn is_sell_asset_lock_free( - path: sp_std::vec::Vec, - input_amount: Balance, - ) -> Option; - fn get_tradeable_tokens() -> Vec>; + ) -> Vec<(TokenId, Balance)>; } } diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 3582b8697d..78bf94e4df 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -159,7 +159,7 @@ benchmarks! { ) } - deactivate_liquidity{ + deactivate_liquidity_for_native_rewards{ // deactivate // 1 crate pool // 2 promote pool @@ -194,7 +194,7 @@ benchmarks! { forward_to_next_session::(); - }: deactivate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity.into()) + }: deactivate_liquidity_for_native_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity.into()) verify { assert_eq!( PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, @@ -319,7 +319,7 @@ benchmarks! { ) } - deactivate_liquidity_for_rewards_schedule{ + deactivate_liquidity_for_native_rewards_for_rewards_schedule{ // 1 create pool that can be rewarded // 2 create token that is used as reward // 3 activate rewards @@ -388,7 +388,7 @@ benchmarks! { ); - }: deactivate_liquidity_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id) + }: deactivate_liquidity_for_native_rewards_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id) verify { assert!(TokensOf::::ensure_can_withdraw( diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 7bc6f04b0a..8eb471b919 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -30,13 +30,13 @@ //! - [`PromotedPoolRewards`] - Stores information about the total amount of rewards for each liquidity //! token. //! - [`RewardsInfo`] - Stores information about rewards for liquidity mining. -//! - [`ScheduleActivationKind`] - Wrapper over origin ActivateKind that is used in +//! - [`ThirdPartyActivationKind`] - Wrapper over origin ActivateKind that is used in //! //! #### Extrinsics //! //! - [`Pallet::activate_liquidity`] - Activates liquidity for liquidity mining rewards. -//! - [`Pallet::deactivate_liquidity`] - Deactivates liquidity for liquidity mining rewards. -//! - [`Pallet::claim_rewards_all`] - Claims all rewards for all liquidity tokens. +//! - [`Pallet::deactivate_liquidity_for_native_rewards`] - Deactivates liquidity for liquidity mining rewards. +//! - [`Pallet::claim_native_rewards`] - Claims all rewards for all liquidity tokens. //! - [`Pallet::update_pool_promotion`] - Enables/disables the pool for liquidity mining rewards. //! //! ### Scheduled Rewards @@ -66,9 +66,9 @@ //! #### Extrinsics //! //! - [`Pallet::reward_pool`] - Schedules rewards for the selected liquidity token. -//! - [`Pallet::activate_liquidity_for_rewards_schedule`] - Activates liquidity for scheduled rewards. -//! - [`Pallet::deactivate_liquidity_for_rewards_schedule`] - Deactivates liquidity for scheduled rewards. -//! - [`Pallet::claim_schedule_rewards_all`] - Claims all scheduled rewards for all liquidity tokens. +//! - [`Pallet::activate_liquidity_for_3rdparty_rewards`] - Activates liquidity for scheduled rewards. +//! - [`Pallet::deactivate_liquidity_for_3rdparty_rewards`] - Deactivates liquidity for scheduled rewards. +//! - [`Pallet::claim_3rdparty_rewards`] - Claims all scheduled rewards for all liquidity tokens. //! //! ## Reusing a Single Liquidity Token for Multiple Rewards //! @@ -81,14 +81,15 @@ //! several options to do that: //! //! - The user can reuse liquidity used for liquidity mining rewards to claim scheduled rewards. In -//! this case, [`Pallet::activate_liquidity_for_rewards_schedule`] should be used with [`ActivateKind::LiquidityMining`]. +//! this case, [`Pallet::activate_liquidity_for_3rdparty_rewards`] should be used with [`ActivateKind::LiquidityMining`]. //! -//! - The user can reuse liquidity used for scheduled rewards (X) to sign up for rewards from other tokens (provided by Bob). In that case, [`Pallet::activate_liquidity_for_rewards_schedule`] should be used with [`ActivateKind::ActivatedLiquidity(X)`]. +//! - The user can reuse liquidity used for scheduled rewards (X) to sign up for rewards from other tokens (provided by Bob). In that case, [`Pallet::activate_liquidity_for_3rdparty_rewards`] should be used with [`ActivateKind::ActivatedLiquidity(X)`]. //! //! - The user can't directly provide liquidity activated for scheduled rewards to activate it for liquidity mining rewards. Instead: -//! * Liquidity used for schedule rewards can be deactivated [`Pallet::deactivate_liquidity_for_rewards_schedule`]. +//! * Liquidity used for schedule rewards can be deactivated +//! [`Pallet::deactivate_liquidity_for_3rdparty_rewards`]. //! * Liquidity can be activated for liquidity mining rewards [`Pallet::activate_liquidity`]. -//! * Liquidity can be activated for scheduled rewards [`Pallet::activate_liquidity_for_rewards_schedule`] with [`ScheduleActivationKind::Mining`]. +//! * Liquidity can be activated for scheduled rewards [`Pallet::activate_liquidity_for_3rdparty_rewards`] with [`ThirdPartyActivationKind::Mining`]. use frame_support::pallet_prelude::*; @@ -155,7 +156,7 @@ type AccountIdOf = ::AccountId; /// - `ActivatedLiquidity` - already activated liquidity (for scheduled rewards) /// - `LiquidityMining` - already activated liquidity (for liquidity mining rewards) #[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)] -pub enum ScheduleActivationKind { +pub enum ThirdPartyActivationKind { ActivateKind(Option), ActivatedLiquidity(TokenId), LiquidityMining, @@ -235,17 +236,8 @@ pub mod pallet { type RewardsSchedulesLimit: Get; /// The minimum number of rewards per session for schedule rewards type MinRewardsPerSession: Get; - /// The maximum number of reward tokens per pool - type MaxRewardTokensPerPool: Get; type WeightInfo: WeightInfo; type ValuationApi: ValutationApiTrait; - - // type ValuationApi: Valuate< - // Balance = mangata_types::Balance, - // CurrencyId = mangata_types::TokenId, - // >; - // #[cfg(feature = "runtime-benchmarks")] - // type Xyk: XykFunctionsTrait; } #[pallet::error] @@ -401,7 +393,8 @@ pub mod pallet { /// Claims liquidity mining rewards #[transactional] #[pallet::call_index(0)] - #[pallet::weight(<::WeightInfo>::claim_rewards_all())] + #[pallet::weight(<::WeightInfo>::claim_native_rewards())] + #[deprecated(note = "claim_native_rewards should be used instead")] pub fn claim_rewards_all( origin: OriginFor, liquidity_token_id: TokenId, @@ -446,6 +439,7 @@ pub mod pallet { #[transactional] #[pallet::call_index(2)] #[pallet::weight(<::WeightInfo>::activate_liquidity())] + #[deprecated(note = "activate_liquidity_for_native_rewards should be used instead")] pub fn activate_liquidity( origin: OriginFor, liquidity_token_id: TokenId, @@ -454,7 +448,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::activate_liquidity_for_liquidity_minting( + Self::activate_liquidity_for_native_rewards_impl( sender, liquidity_token_id, amount, @@ -465,7 +459,8 @@ pub mod pallet { /// Decreases number of tokens used for liquidity mining purposes #[transactional] #[pallet::call_index(3)] - #[pallet::weight(<::WeightInfo>::deactivate_liquidity())] + #[pallet::weight(<::WeightInfo>::deactivate_liquidity_for_native_rewards())] + #[deprecated(note = "deactivate_liquidity_for_native_rewards should be used instead")] pub fn deactivate_liquidity( origin: OriginFor, liquidity_token_id: TokenId, @@ -473,7 +468,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - >::deactivate_liquidity( + Self::deactivate_liquidity_for_native_rewards_impl( sender, liquidity_token_id, amount, @@ -487,7 +482,6 @@ pub mod pallet { /// schedule_end). Distribution starts from the *next* session till `schedule_end`. #[transactional] #[pallet::call_index(4)] - // NOTE: implement benchmark #[pallet::weight(<::WeightInfo>::reward_pool())] pub fn reward_pool( origin: OriginFor, @@ -570,21 +564,21 @@ pub mod pallet { /// be taken from available balance #[transactional] #[pallet::call_index(5)] - #[pallet::weight(<::WeightInfo>::activate_liquidity_for_rewards_schedule())] - pub fn activate_liquidity_for_rewards_schedule( + #[pallet::weight(<::WeightInfo>::activate_liquidity_for_3rdparty_rewards())] + pub fn activate_liquidity_for_3rdparty_rewards( origin: OriginFor, liquidity_token_id: TokenId, amount: Balance, reward_token: TokenId, - use_balance_from: Option, + use_balance_from: Option, ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::activate_liquidity_for_schedule( + Self::activate_liquidity_for_3rdparty_rewards_impl( sender, liquidity_token_id, amount, - use_balance_from.unwrap_or(ScheduleActivationKind::ActivateKind(None)), + use_balance_from.unwrap_or(ThirdPartyActivationKind::ActivateKind(None)), reward_token, ) } @@ -597,8 +591,8 @@ pub mod pallet { /// - use_balance_from - where from tokens should be used #[transactional] #[pallet::call_index(6)] - #[pallet::weight(<::WeightInfo>::deactivate_liquidity_for_rewards_schedule())] - pub fn deactivate_liquidity_for_rewards_schedule( + #[pallet::weight(<::WeightInfo>::deactivate_liquidity_for_3rdparty_rewards())] + pub fn deactivate_liquidity_for_3rdparty_rewards( origin: OriginFor, liquidity_token_id: TokenId, amount: Balance, @@ -606,7 +600,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::deactivate_liquidity_for_schedule( + Self::deactivate_liquidity_for_3rdparty_rewards_impl( sender, liquidity_token_id, amount, @@ -620,8 +614,8 @@ pub mod pallet { /// - reward_token - id of the token that is rewarded #[transactional] #[pallet::call_index(7)] - #[pallet::weight(<::WeightInfo>::activate_liquidity())] - pub fn claim_schedule_rewards_all( + #[pallet::weight(<::WeightInfo>::claim_3rdparty_rewards())] + pub fn claim_3rdparty_rewards( origin: OriginFor, liquidity_token_id: TokenId, reward_token: TokenId, @@ -631,6 +625,68 @@ pub mod pallet { Self::claim_schedule_rewards_all_impl(sender, liquidity_token_id, reward_token)?; Ok(()) } + + /// Increases number of tokens used for liquidity mining purposes. + /// + /// Parameters: + /// - liquidity_token_id - id of the token + /// - amount - amount of the token + /// - use_balance_from - where from tokens should be used + #[transactional] + #[pallet::call_index(8)] + #[pallet::weight(<::WeightInfo>::activate_liquidity())] + pub fn activate_liquidity_for_native_rewards( + origin: OriginFor, + liquidity_token_id: TokenId, + amount: Balance, + use_balance_from: Option, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + Self::activate_liquidity_for_native_rewards_impl( + sender, + liquidity_token_id, + amount, + use_balance_from, + ) + } + + /// Decreases number of tokens used for liquidity mining purposes + #[transactional] + #[pallet::call_index(9)] + #[pallet::weight(<::WeightInfo>::deactivate_liquidity_for_native_rewards())] + pub fn deactivate_liquidity_for_native_rewards( + origin: OriginFor, + liquidity_token_id: TokenId, + amount: Balance, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + Self::deactivate_liquidity_for_native_rewards_impl( + sender, + liquidity_token_id, + amount, + ) + } + + #[transactional] + #[pallet::call_index(10)] + #[pallet::weight(<::WeightInfo>::claim_native_rewards())] + #[deprecated(note = "claim_native_rewards should be used instead")] + pub fn claim_native_rewards( + origin: OriginFor, + liquidity_token_id: TokenId, + ) -> DispatchResult { + let sender = ensure_signed(origin)?; + + >::claim_rewards_all( + sender, + liquidity_token_id, + )?; + + Ok(()) + } + } } @@ -640,7 +696,7 @@ pub enum RewardsKind { } impl Pallet { - fn activate_liquidity_for_liquidity_minting( + fn activate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, amount: Balance, @@ -672,7 +728,7 @@ impl Pallet { Ok(()) } - fn deactivate_liquidity_for_liquidity_minting( + fn deactivate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, amount: Balance, @@ -688,18 +744,18 @@ impl Pallet { Ok(()) } - fn activate_liquidity_for_schedule( + fn activate_liquidity_for_3rdparty_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, amount: Balance, - use_balance_from: ScheduleActivationKind, + use_balance_from: ThirdPartyActivationKind, reward_token: TokenId, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; match use_balance_from { // 1R 1W - ScheduleActivationKind::ActivateKind(ref use_balance_from) => { + ThirdPartyActivationKind::ActivateKind(ref use_balance_from) => { ensure!( ::ActivationReservesProvider::can_activate( liquidity_asset_id, @@ -716,7 +772,7 @@ impl Pallet { ); }, // 2R - ScheduleActivationKind::ActivatedLiquidity(token_id) => { + ThirdPartyActivationKind::ActivatedLiquidity(token_id) => { let already_activated_amount = RewardsInfoForScheduleRewards::::get( user.clone(), (liquidity_asset_id, reward_token), @@ -732,7 +788,7 @@ impl Pallet { Error::::NotEnoughAssets ); }, - ScheduleActivationKind::LiquidityMining => { + ThirdPartyActivationKind::LiquidityMining => { let already_activated_amount = RewardsInfoForScheduleRewards::::get( user.clone(), (liquidity_asset_id, reward_token), @@ -755,7 +811,7 @@ impl Pallet { )?; match use_balance_from { - ScheduleActivationKind::ActivateKind(use_balance_from) => { + ThirdPartyActivationKind::ActivateKind(use_balance_from) => { println!("activate"); ::ActivationReservesProvider::activate( liquidity_asset_id, @@ -772,7 +828,7 @@ impl Pallet { Ok(()) } - fn deactivate_liquidity_for_schedule( + fn deactivate_liquidity_for_3rdparty_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, amount: Balance, @@ -1178,7 +1234,7 @@ impl ProofOfStakeRewardsApi for Pallet { amount: Self::Balance, use_balance_from: Option, ) -> DispatchResult { - Self::activate_liquidity_for_liquidity_minting( + Self::activate_liquidity_for_native_rewards_impl( user, liquidity_asset_id, amount, @@ -1191,7 +1247,7 @@ impl ProofOfStakeRewardsApi for Pallet { liquidity_asset_id: Self::CurrencyId, amount: Self::Balance, ) -> DispatchResult { - Self::deactivate_liquidity_for_liquidity_minting(user, liquidity_asset_id, amount) + Self::deactivate_liquidity_for_native_rewards_impl(user, liquidity_asset_id, amount) } fn calculate_rewards_amount( @@ -1307,3 +1363,4 @@ impl LiquidityMiningApi for Pallet { // TODO: clean up test setup // TODO: dedicated 3rdparty rewards api +// benchmark for claim 3rdparty rewards diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index a7541ee8a3..14aed844e8 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -286,7 +286,6 @@ impl pos::Config for Test { type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; type MinRewardsPerSession = ConstU128<10>; - type MaxRewardTokensPerPool = ConstU32<5>; type WeightInfo = (); type ValuationApi = MockValuationApi; } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 82a4f99737..7f98c4a5ce 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -13,7 +13,7 @@ type TokensOf = ::Currency; fn mint_and_activate_tokens(who: AccountId, token_id: TokenId, amount: Balance) { TokensOf::::mint(token_id, &who, amount).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(who), token_id, amount, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(who), token_id, amount, None).unwrap(); } fn initialize_liquidity_rewards() { @@ -32,7 +32,7 @@ fn initialize_liquidity_rewards() { pools.get_mut(&4).unwrap().rewards = U256::from(0); }); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); } pub(crate) fn roll_to_session(n: u32) { @@ -75,7 +75,7 @@ fn liquidity_rewards_single_user_mint_W() { let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 2u8).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); let rewards_info = ProofOfStake::get_rewards_info(2, 4); @@ -144,7 +144,7 @@ fn liquidity_rewards_three_users_burn_W() { TokensOf::::transfer(1, &2, &4, 1000000, ExistenceRequirement::AllowDeath).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(100); @@ -156,7 +156,7 @@ fn liquidity_rewards_three_users_burn_W() { mint_and_activate_tokens(4, 4, 10000); forward_to_block(240); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(4), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000).unwrap(); forward_to_block(400); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 95965); @@ -189,14 +189,14 @@ fn liquidity_rewards_claim_W() { TokensOf::::create(&acc_id, 10000).unwrap(); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(10); forward_to_block(90); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 12142); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 2562); @@ -260,7 +260,7 @@ fn liquidity_rewards_work_after_burn_W() { TokensOf::::transfer(1, &2, &4, 1000000, ExistenceRequirement::AllowDeath).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(100); @@ -272,7 +272,7 @@ fn liquidity_rewards_work_after_burn_W() { mint_and_activate_tokens(4, 4, 10000); forward_to_block(240); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(4), 4, 10000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 10000).unwrap(); forward_to_block(400); assert_eq!(ProofOfStake::calculate_rewards_amount(4, 4).unwrap(), 948); @@ -301,7 +301,7 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); assert_err!( TokensOf::::transfer(4, &2, &3, 10, ExistenceRequirement::AllowDeath), @@ -311,7 +311,7 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) .unwrap(); TokensOf::::transfer(4, &2, &3, 10, ExistenceRequirement::AllowDeath).unwrap(); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); @@ -335,10 +335,10 @@ fn liquidity_rewards_deactivate_more_NW() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); assert_err!( - ProofOfStake::deactivate_liquidity( + ProofOfStake::deactivate_liquidity_for_native_rewards( RuntimeOrigin::signed(2), 4, liquidity_tokens_owned + 1 @@ -366,7 +366,7 @@ fn liquidity_rewards_activate_more_NW() { let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); assert_err!( - ProofOfStake::activate_liquidity( + ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(2), 4, liquidity_tokens_owned + 1, @@ -409,7 +409,7 @@ fn liquidity_rewards_claim_pool_not_promoted() { TokensOf::::create(&acc_id, amount).unwrap(); assert_err!( - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 7), + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 7), Error::::NotAPromotedPool, ); }); @@ -452,25 +452,25 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(10); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 291); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) .unwrap(); let rewards_info = ProofOfStake::get_rewards_info(2, 4); assert_eq!(rewards_info.rewards_not_yet_claimed, 291); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 12433); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); let rewards_info = ProofOfStake::get_rewards_info(2, 4); assert_eq!(rewards_info.rewards_already_claimed, 12142); @@ -493,7 +493,7 @@ fn extreme_case_pool_ratio() { TokensOf::::create(&acc_id, max).unwrap(); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 1, None).unwrap(); PromotedPoolRewards::::mutate(|pools| { pools.get_mut(&4).unwrap().rewards = U256::from(u128::MAX) * U256::from(u128::MAX); @@ -630,7 +630,7 @@ fn rewards_storage_right_amounts_start1() { TokensOf::::transfer(2, &2, &5, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(1, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); mint_and_activate_tokens(3, 4, 10000); mint_and_activate_tokens(4, 4, 10000); mint_and_activate_tokens(5, 4, 10000); @@ -642,11 +642,11 @@ fn rewards_storage_right_amounts_start1() { PromotedPoolRewards::::get().get(&4).unwrap().rewards ); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(3), 4).unwrap(); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(4), 4).unwrap(); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(5), 4).unwrap(); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(6), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(3), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(4), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(5), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(6), 4).unwrap(); let mut rewards_info = ProofOfStake::get_rewards_info(2, 4); assert_eq!(rewards_info.rewards_not_yet_claimed, 0); @@ -676,7 +676,7 @@ fn rewards_storage_right_amounts_start1() { // usecase 3 claim (all) let mut user_balance_before = TokensOf::::free_balance(0, &2); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); let mut user_balance_after = TokensOf::::free_balance(0, &2); rewards_info = ProofOfStake::get_rewards_info(2, 4); @@ -687,7 +687,7 @@ fn rewards_storage_right_amounts_start1() { // usecase 6 burn some user_balance_before = TokensOf::::free_balance(0, &3); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(3), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); user_balance_after = TokensOf::::free_balance(0, &3); rewards_info = ProofOfStake::get_rewards_info(3, 4); @@ -710,7 +710,7 @@ fn rewards_storage_right_amounts_start1() { // usecase 8 deactivate some user_balance_before = TokensOf::::free_balance(0, &5); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); user_balance_after = TokensOf::::free_balance(0, &5); rewards_info = ProofOfStake::get_rewards_info(5, 4); @@ -721,7 +721,7 @@ fn rewards_storage_right_amounts_start1() { // usecase 16 claim some user_balance_before = TokensOf::::free_balance(0, &6); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(6), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(6), 4).unwrap(); user_balance_after = TokensOf::::free_balance(0, &6); rewards_info = ProofOfStake::get_rewards_info(6, 4); @@ -767,7 +767,7 @@ fn rewards_storage_right_amounts_start2() { TokensOf::::transfer(2, &2, &5, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(1, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); mint_and_activate_tokens(3, 4, 10000); mint_and_activate_tokens(4, 4, 10000); mint_and_activate_tokens(5, 4, 10000); @@ -778,10 +778,10 @@ fn rewards_storage_right_amounts_start2() { PromotedPoolRewards::::get().get(&4).unwrap().rewards ); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(2), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(3), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(4), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); forward_to_block_with_custom_rewards(200, 20000); //its really weird that rewards are //decreased from 40k to 20k in single @@ -812,7 +812,7 @@ fn rewards_storage_right_amounts_start2() { // usecase 2 claim_all let mut user_balance_before = TokensOf::::free_balance(0, &2); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); let mut user_balance_after = TokensOf::::free_balance(0, &2); rewards_info = ProofOfStake::get_rewards_info(2, 4); @@ -823,7 +823,7 @@ fn rewards_storage_right_amounts_start2() { // usecase 9 burn some user_balance_before = TokensOf::::free_balance(0, &3); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(3), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); user_balance_after = TokensOf::::free_balance(0, &3); rewards_info = ProofOfStake::get_rewards_info(3, 4); @@ -845,7 +845,7 @@ fn rewards_storage_right_amounts_start2() { // usecase 11 deactivate some user_balance_before = TokensOf::::free_balance(0, &5); - ProofOfStake::deactivate_liquidity(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); user_balance_after = TokensOf::::free_balance(0, &5); rewards_info = ProofOfStake::get_rewards_info(5, 4); @@ -888,7 +888,7 @@ fn rewards_storage_right_amounts_start3() { TokensOf::::transfer(1, &2, &4, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &4, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); mint_and_activate_tokens(3, 4, 10000); forward_to_block_with_custom_rewards(100, 20000); @@ -907,7 +907,7 @@ fn rewards_storage_right_amounts_start3() { // usecase 1 claim (all) let mut user_balance_before = TokensOf::::free_balance(0, &2); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); let mut user_balance_after = TokensOf::::free_balance(0, &2); rewards_info = ProofOfStake::get_rewards_info(2, 4); @@ -918,7 +918,7 @@ fn rewards_storage_right_amounts_start3() { // usecase 17 claim some user_balance_before = TokensOf::::free_balance(0, &3); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(3), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(3), 4).unwrap(); user_balance_after = TokensOf::::free_balance(0, &3); rewards_info = ProofOfStake::get_rewards_info(3, 4); @@ -965,13 +965,13 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { ) .unwrap(); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(3), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(3, 4).unwrap(), 14704); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(3), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(3), 4).unwrap(); }); } @@ -1022,7 +1022,7 @@ fn test_migrated_from_pallet_issuance() { assert_eq!(1, TokensOf::::create(&99999, 1_000_000u128).unwrap()); ProofOfStake::enable(1, 1u8); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(99999), 1, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(99999), 1, 1, None).unwrap(); roll_to_while_minting(4, None); assert_eq!( @@ -1037,7 +1037,7 @@ fn test_migrated_from_pallet_issuance() { assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); ProofOfStake::enable(2, 1u8); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(99999), 2, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(99999), 2, 1, None).unwrap(); roll_to_while_minting(14, None); assert_eq!( U256::from_dec_str("191427546923208537313638702283778366195067525").unwrap(), @@ -1085,7 +1085,7 @@ fn claim_rewards_from_pool_that_has_been_disabled() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) .unwrap(); forward_to_block(10); @@ -1094,7 +1094,7 @@ fn claim_rewards_from_pool_that_has_been_disabled() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 0u8).unwrap(); - ProofOfStake::claim_rewards_all(RuntimeOrigin::signed(2), 4).unwrap(); + ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 0); }); @@ -1452,7 +1452,7 @@ fn user_can_claim_3rdparty_rewards() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1466,7 +1466,7 @@ fn user_can_claim_3rdparty_rewards() { ); roll_to_session(2); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, @@ -1533,7 +1533,7 @@ fn overlapping_3rdparty_rewards_works() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1552,7 +1552,7 @@ fn overlapping_3rdparty_rewards_works() { 15u32.into(), ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1608,7 +1608,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1627,12 +1627,12 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, SECOND_REWARD_TOKEN, - Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); @@ -1683,7 +1683,7 @@ fn deactivate_3rdparty_rewards() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1692,7 +1692,7 @@ fn deactivate_3rdparty_rewards() { ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, @@ -1716,7 +1716,7 @@ fn deactivate_3rdparty_rewards() { ), Ok(500) ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, @@ -1775,7 +1775,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1783,12 +1783,12 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { None, ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, SECOND_REWARD_TOKEN, - Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); @@ -1864,19 +1864,19 @@ fn liquidity_minting_liquidity_can_be_resused() { ) .unwrap(); - ProofOfStake::activate_liquidity( + ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, None, ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, FIRST_REWARD_TOKEN, - Some(ScheduleActivationKind::LiquidityMining), + Some(ThirdPartyActivationKind::LiquidityMining), ) .unwrap(); @@ -1928,7 +1928,7 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { ) .unwrap(); - ProofOfStake::activate_liquidity( + ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1946,17 +1946,17 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, FIRST_REWARD_TOKEN, - Some(ScheduleActivationKind::LiquidityMining), + Some(ThirdPartyActivationKind::LiquidityMining), ) .unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -1965,7 +1965,7 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { ) .unwrap(); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 200, @@ -2028,7 +2028,7 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -2037,12 +2037,12 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, SECOND_REWARD_TOKEN, - Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); @@ -2056,7 +2056,7 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() ), orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -2073,7 +2073,7 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() ), orml_tokens::Error::::BalanceTooLow ); - ProofOfStake::deactivate_liquidity_for_rewards_schedule( + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -2125,7 +2125,7 @@ fn can_claim_schedule_rewards() { 10u32.into(), ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -2133,12 +2133,12 @@ fn can_claim_schedule_rewards() { None, ) .unwrap(); - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, SECOND_REWARD_TOKEN, - Some(ScheduleActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), + Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); @@ -2147,14 +2147,14 @@ fn can_claim_schedule_rewards() { assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 0,); assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 0,); - ProofOfStake::claim_schedule_rewards_all( + ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, ) .unwrap(); - ProofOfStake::claim_schedule_rewards_all( + ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, @@ -2201,7 +2201,7 @@ fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_li .unwrap(); assert_err!( - ProofOfStake::activate_liquidity_for_rewards_schedule( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, @@ -2238,7 +2238,7 @@ fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_sche .unwrap(); assert_err!( - ProofOfStake::activate_liquidity( + ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, diff --git a/pallets/proof-of-stake/src/weights.rs b/pallets/proof-of-stake/src/weights.rs index 024cc3133e..9c350e9331 100644 --- a/pallets/proof-of-stake/src/weights.rs +++ b/pallets/proof-of-stake/src/weights.rs @@ -56,11 +56,13 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { fn claim_rewards_all() -> Weight; + fn claim_native_rewards() -> Weight; + fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; fn activate_liquidity() -> Weight; - fn deactivate_liquidity() -> Weight; - fn deactivate_liquidity_for_rewards_schedule() -> Weight; - fn activate_liquidity_for_rewards_schedule() -> Weight; + fn deactivate_liquidity_for_native_rewards() -> Weight; + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; + fn activate_liquidity_for_3rdparty_rewards() -> Weight; fn reward_pool() -> Weight; } @@ -95,19 +97,19 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) // Storage: Tokens Accounts (r:1 w:1) - fn deactivate_liquidity() -> Weight { + fn deactivate_liquidity_for_native_rewards() -> Weight{ (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - fn deactivate_liquidity_for_rewards_schedule() -> Weight { + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - fn activate_liquidity_for_rewards_schedule() -> Weight { + fn activate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -118,4 +120,16 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn claim_native_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } } diff --git a/runtime/mangata-kusama/Cargo.toml b/runtime/mangata-kusama/Cargo.toml index 9c6ca2cd7d..041c170072 100644 --- a/runtime/mangata-kusama/Cargo.toml +++ b/runtime/mangata-kusama/Cargo.toml @@ -32,6 +32,7 @@ pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', pallet-maintenance = { path = '../../pallets/maintenance', default-features = false } pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false} mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +proof-of-stake-runtime-api = { path = '../../pallets/proof-of-stake/runtime-api', default-features = false} # Substrate Dependencies ## Substrate Primitive Dependencies @@ -169,6 +170,7 @@ std = [ "pallet-treasury/std", "pallet-xyk/std", "pallet-proof-of-stake/std", + "proof-of-stake-runtime-api/std", "pallet-bootstrap/std", "xyk-runtime-api/std", "parachain-staking/std", diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 92625d101f..29649cbaea 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -274,10 +274,14 @@ impl pallet_proof_of_stake::Config for Runtime { type ActivationReservesProvider = MultiPurposeLiquidity; type NativeCurrencyId = tokens::MgxTokenId; type Currency = orml_tokens::MultiTokenCurrencyAdapter; - //TODO: fix type LiquidityMiningIssuanceVault = cfg::pallet_issuance::LiquidityMiningIssuanceVault; type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; + // TODO: allign + type RewardsSchedulesLimit = frame_support::traits::ConstU32<10>; + type MinRewardsPerSession = frame_support::traits::ConstU128<10>; + type MaxRewardTokensPerPool = frame_support::traits::ConstU32<5>; + type ValuationApi = Xyk; } impl pallet_bootstrap::BootstrapBenchmarkingConfig for Runtime {} @@ -768,6 +772,30 @@ mod benches { impl_runtime_apis! { + impl proof_of_stake_runtime_api::ProofOfStakeApi for Runtime{ + fn calculate_native_rewards_amount( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> Balance{ + todo!(); + } + + fn calculate_3rdparty_rewards_amount( + user: AccountId, + liquidity_asset_id: TokenId, + reward_asset_id: TokenId, + ) -> Balance{ + todo!(); + } + + fn calculate_3rdparty_rewards_amount_all( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> Vec<(TokenId, Balance)>{ + todo!(); + } + } + impl ver_api::VerApi for Runtime { fn get_signer( tx: ::Extrinsic, diff --git a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs index d7f3024fd8..d799da4557 100644 --- a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs +++ b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs @@ -60,6 +60,9 @@ pub trait WeightInfo { fn update_pool_promotion() -> Weight; fn activate_liquidity() -> Weight; fn deactivate_liquidity() -> Weight; + fn deactivate_liquidity_for_rewards_schedule() -> Weight; + fn activate_liquidity_for_rewards_schedule() -> Weight; + fn reward_pool() -> Weight; } /// Weights for pallet_proof_of_stake using the Mangata node and recommended hardware. @@ -113,6 +116,25 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + + + fn deactivate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn activate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn reward_pool() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } } // For backwards compatibility and tests @@ -165,4 +187,23 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + + fn deactivate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn activate_liquidity_for_rewards_schedule() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn reward_pool() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + } From eca4e5a47dea4f38c88bd2a13f1d78256323b4f7 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 13:58:06 +0000 Subject: [PATCH 23/83] runtime compiles --- pallets/proof-of-stake/runtime-api/src/lib.rs | 2 +- pallets/proof-of-stake/src/lib.rs | 58 ++++++++++++------- pallets/proof-of-stake/src/weights.rs | 13 +---- runtime/mangata-kusama/src/lib.rs | 13 +++-- .../src/weights/pallet_proof_of_stake.rs | 50 +++++++++++----- 5 files changed, 83 insertions(+), 53 deletions(-) diff --git a/pallets/proof-of-stake/runtime-api/src/lib.rs b/pallets/proof-of-stake/runtime-api/src/lib.rs index 812438f4bf..6f0012f1db 100644 --- a/pallets/proof-of-stake/runtime-api/src/lib.rs +++ b/pallets/proof-of-stake/runtime-api/src/lib.rs @@ -21,7 +21,7 @@ sp_api::decl_runtime_apis! { reward_asset_id: TokenId, ) -> Balance; - fn calculate_3rdparty_rewards_amount_all( + fn calculate_3rdparty_rewards_all( user: AccountId, liquidity_asset_id: TokenId, ) -> Vec<(TokenId, Balance)>; diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 8eb471b919..721aa4aaa5 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -438,7 +438,7 @@ pub mod pallet { /// - use_balance_from - where from tokens should be used #[transactional] #[pallet::call_index(2)] - #[pallet::weight(<::WeightInfo>::activate_liquidity())] + #[pallet::weight(<::WeightInfo>::activate_liquidity_for_native_rewards())] #[deprecated(note = "activate_liquidity_for_native_rewards should be used instead")] pub fn activate_liquidity( origin: OriginFor, @@ -634,7 +634,7 @@ pub mod pallet { /// - use_balance_from - where from tokens should be used #[transactional] #[pallet::call_index(8)] - #[pallet::weight(<::WeightInfo>::activate_liquidity())] + #[pallet::weight(<::WeightInfo>::activate_liquidity_for_native_rewards())] pub fn activate_liquidity_for_native_rewards( origin: OriginFor, liquidity_token_id: TokenId, @@ -728,6 +728,30 @@ impl Pallet { Ok(()) } + pub fn calculate_native_rewards_amount( + user: AccountIdOf, + liquidity_asset_id: TokenId, + ) -> Result { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + let rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) + .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; + + let current_rewards = match rewards_info.activated_amount { + 0 => 0u128, + _ => { + let calc = + RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; + calc.calculate_rewards().map_err(|err| Into::>::into(err))? + }, + }; + + Ok(current_rewards + .checked_add(rewards_info.rewards_not_yet_claimed) + .and_then(|v| v.checked_sub(rewards_info.rewards_already_claimed)) + .ok_or(Error::::CalculateRewardsMathError)?) + } + + fn deactivate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -850,7 +874,16 @@ impl Pallet { Ok(()) } - fn calculate_rewards_amount_3rdparty( + pub fn calculate_3rdparty_rewards_all( + user: AccountIdOf, + liquidity_asset_id: TokenId, + ) -> Result, DispatchError> { + Self::ensure_is_promoted_pool(liquidity_asset_id)?; + todo!(); + + } + + pub fn calculate_rewards_amount_3rdparty( user: AccountIdOf, liquidity_asset_id: TokenId, rewards_asset_id: TokenId, @@ -1254,23 +1287,9 @@ impl ProofOfStakeRewardsApi for Pallet { user: AccountIdOf, liquidity_asset_id: TokenId, ) -> Result { - Self::ensure_is_promoted_pool(liquidity_asset_id)?; - let rewards_info = RewardsInfo::::try_get(user.clone(), liquidity_asset_id) - .or(Err(DispatchError::from(Error::::MissingRewardsInfoError)))?; - let current_rewards = match rewards_info.activated_amount { - 0 => 0u128, - _ => { - let calc = - RewardsCalculator::mining_rewards::(user.clone(), liquidity_asset_id)?; - calc.calculate_rewards().map_err(|err| Into::>::into(err))? - }, - }; + Self::calculate_native_rewards_amount(user, liquidity_asset_id) - Ok(current_rewards - .checked_add(rewards_info.rewards_not_yet_claimed) - .and_then(|v| v.checked_sub(rewards_info.rewards_already_claimed)) - .ok_or(Error::::CalculateRewardsMathError)?) } } @@ -1361,6 +1380,5 @@ impl LiquidityMiningApi for Pallet { } } -// TODO: clean up test setup -// TODO: dedicated 3rdparty rewards api // benchmark for claim 3rdparty rewards +// limit min total amount of rewards not per session diff --git a/pallets/proof-of-stake/src/weights.rs b/pallets/proof-of-stake/src/weights.rs index 9c350e9331..7e015e5147 100644 --- a/pallets/proof-of-stake/src/weights.rs +++ b/pallets/proof-of-stake/src/weights.rs @@ -55,11 +55,10 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { - fn claim_rewards_all() -> Weight; fn claim_native_rewards() -> Weight; fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; - fn activate_liquidity() -> Weight; + fn activate_liquidity_for_native_rewards() -> Weight; fn deactivate_liquidity_for_native_rewards() -> Weight; fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; fn activate_liquidity_for_3rdparty_rewards() -> Weight; @@ -68,14 +67,6 @@ pub trait WeightInfo { // For backwards compatibility and tests impl WeightInfo for () { - // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) - // Storage: ProofOfStake RewardsInfo (r:1 w:1) - // Storage: Tokens Accounts (r:2 w:2) - fn claim_rewards_all() -> Weight { - (Weight::from_parts(97_590_000, 0)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - } // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) fn update_pool_promotion() -> Weight { (Weight::from_parts(52_090_000, 0)) @@ -87,7 +78,7 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Storage: ProofOfStake RewardsInfo (r:1 w:1) // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) - fn activate_liquidity() -> Weight { + fn activate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(116_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 29649cbaea..45a3365995 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -280,7 +280,6 @@ impl pallet_proof_of_stake::Config for Runtime { // TODO: allign type RewardsSchedulesLimit = frame_support::traits::ConstU32<10>; type MinRewardsPerSession = frame_support::traits::ConstU128<10>; - type MaxRewardTokensPerPool = frame_support::traits::ConstU32<5>; type ValuationApi = Xyk; } @@ -534,7 +533,6 @@ impl pallet_issuance::Config for Runtime { type RuntimeEvent = RuntimeEvent; type NativeCurrencyId = tokens::MgxTokenId; type Tokens = orml_tokens::MultiTokenCurrencyAdapter; - //TODO type BlocksPerRound = cfg::parachain_staking::BlocksPerRound; type HistoryLimit = cfg::pallet_issuance::HistoryLimit; type LiquidityMiningIssuanceVault = cfg::pallet_issuance::LiquidityMiningIssuanceVault; @@ -777,7 +775,8 @@ impl_runtime_apis! { user: AccountId, liquidity_asset_id: TokenId, ) -> Balance{ - todo!(); + ProofOfStake::calculate_native_rewards_amount(user, liquidity_asset_id) + .unwrap_or_default() } fn calculate_3rdparty_rewards_amount( @@ -785,14 +784,16 @@ impl_runtime_apis! { liquidity_asset_id: TokenId, reward_asset_id: TokenId, ) -> Balance{ - todo!(); + ProofOfStake::calculate_rewards_amount_3rdparty(user, liquidity_asset_id, reward_asset_id) + .unwrap_or_default() } - fn calculate_3rdparty_rewards_amount_all( + fn calculate_3rdparty_rewards_all( user: AccountId, liquidity_asset_id: TokenId, ) -> Vec<(TokenId, Balance)>{ - todo!(); + ProofOfStake::calculate_3rdparty_rewards_all(user, liquidity_asset_id) + .unwrap_or_default() } } diff --git a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs index d799da4557..99a6a2573d 100644 --- a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs +++ b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs @@ -56,12 +56,13 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { - fn claim_rewards_all() -> Weight; + fn claim_native_rewards() -> Weight; + fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; - fn activate_liquidity() -> Weight; - fn deactivate_liquidity() -> Weight; - fn deactivate_liquidity_for_rewards_schedule() -> Weight; - fn activate_liquidity_for_rewards_schedule() -> Weight; + fn activate_liquidity_for_native_rewards() -> Weight; + fn deactivate_liquidity_for_native_rewards() -> Weight; + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; + fn activate_liquidity_for_3rdparty_rewards() -> Weight; fn reward_pool() -> Weight; } @@ -74,7 +75,13 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_rewards_all() -> Weight { + fn claim_native_rewards() -> Weight { + (Weight::from_parts(81_410_000, 0)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + + fn claim_3rdparty_rewards() -> Weight { (Weight::from_parts(81_410_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) @@ -96,7 +103,7 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) - fn activate_liquidity() -> Weight { + fn activate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(94_130_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) @@ -111,20 +118,20 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn deactivate_liquidity() -> Weight { + fn deactivate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(82_600_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } - fn deactivate_liquidity_for_rewards_schedule() -> Weight { + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - fn activate_liquidity_for_rewards_schedule() -> Weight { + fn activate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -145,11 +152,24 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_rewards_all() -> Weight { + fn claim_native_rewards() -> Weight { (Weight::from_parts(81_410_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } + + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfo (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(81_410_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + } + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { @@ -167,7 +187,7 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) - fn activate_liquidity() -> Weight { + fn activate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(94_130_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -182,19 +202,19 @@ impl WeightInfo for () { // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn deactivate_liquidity() -> Weight { + fn deactivate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(82_600_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - fn deactivate_liquidity_for_rewards_schedule() -> Weight { + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - fn activate_liquidity_for_rewards_schedule() -> Weight { + fn activate_liquidity_for_3rdparty_rewards() -> Weight { (Weight::from_parts(118_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) From e20091aa91be79d35ef03acc058ac0a026591f0e Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 14:58:27 +0000 Subject: [PATCH 24/83] align runtime configs --- Cargo.lock | 1 + pallets/proof-of-stake/src/lib.rs | 12 +-- pallets/proof-of-stake/src/mock.rs | 5 +- pallets/proof-of-stake/src/tests.rs | 2 +- runtime/common/src/lib.rs | 11 +++ runtime/mangata-kusama/src/lib.rs | 5 +- runtime/mangata-rococo/Cargo.toml | 2 + runtime/mangata-rococo/src/lib.rs | 31 ++++++++ .../src/weights/pallet_proof_of_stake.rs | 79 ++++++++++++++++--- 9 files changed, 126 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b47f9a9963..4cb285b114 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5222,6 +5222,7 @@ dependencies = [ "polkadot-parachain", "polkadot-primitives", "polkadot-runtime-common", + "proof-of-stake-runtime-api", "scale-info", "serde", "smallvec", diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 721aa4aaa5..2a6aa0b241 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -235,7 +235,7 @@ pub mod pallet { /// The maximum number of schedules that can be active at one moment type RewardsSchedulesLimit: Get; /// The minimum number of rewards per session for schedule rewards - type MinRewardsPerSession: Get; + type Min3rdPartyRewards: Get; type WeightInfo: WeightInfo; type ValuationApi: ValutationApiTrait; } @@ -266,7 +266,7 @@ pub mod pallet { /// Too many schedules TooManySchedules, /// Too little rewards per session - TooLittleRewardsPerSession, + TooLittleRewards, /// Reward token not paired with native token RewardTokenNotPairdWithNativeToken, } @@ -515,10 +515,10 @@ pub mod pallet { ensure!( ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount) >= - T::MinRewardsPerSession::get() || + T::Min3rdPartyRewards::get() || ((token_id == Into::::into(Self::native_token_id())) && - amount_per_session >= T::MinRewardsPerSession::get()), - Error::::TooLittleRewardsPerSession + amount_per_session >= T::Min3rdPartyRewards::get()), + Error::::TooLittleRewards ); RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); @@ -1381,4 +1381,4 @@ impl LiquidityMiningApi for Pallet { } // benchmark for claim 3rdparty rewards -// limit min total amount of rewards not per session +// move runtime configs to common runtime diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 14aed844e8..cd50e1cce0 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -285,7 +285,7 @@ impl pos::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; - type MinRewardsPerSession = ConstU128<10>; + type Min3rdPartyRewards = ConstU128<10>; type WeightInfo = (); type ValuationApi = MockValuationApi; } @@ -299,8 +299,7 @@ impl pos::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; - type MinRewardsPerSession = ConstU128<10>; - type MaxRewardTokensPerPool = ConstU32<5>; + type Min3rdPartyRewards = ConstU128<10>; type WeightInfo = (); type ValuationApi = Xyk; } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 7f98c4a5ce..7cc1d4faa9 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1389,7 +1389,7 @@ fn reject_schedule_with_too_little_rewards_per_session() { 1, 5u32.into() ), - Error::::TooLittleRewardsPerSession + Error::::TooLittleRewards ); }); } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 69c8dd3170..8b749ad82c 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1366,4 +1366,15 @@ where pub const AnnouncementDepositFactor: Balance = deposit(0, 68); } } + + pub mod pallet_proof_of_stake { + use super::*; + + parameter_types! { + pub const RewardsSchedulesLimit: u32 = 150; + // TODO: allign properly + pub const Min3rdPartyRewards: u128 = 100 * 30_000 * currency::DOLLARS; + } + } + } diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 45a3365995..49585e9692 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -277,9 +277,8 @@ impl pallet_proof_of_stake::Config for Runtime { type LiquidityMiningIssuanceVault = cfg::pallet_issuance::LiquidityMiningIssuanceVault; type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; - // TODO: allign - type RewardsSchedulesLimit = frame_support::traits::ConstU32<10>; - type MinRewardsPerSession = frame_support::traits::ConstU128<10>; + type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; + type Min3rdPartyRewards = cfg::pallet_proof_of_stake::Min3rdPartyRewards; type ValuationApi = Xyk; } diff --git a/runtime/mangata-rococo/Cargo.toml b/runtime/mangata-rococo/Cargo.toml index 4d78499f5d..d93243be28 100644 --- a/runtime/mangata-rococo/Cargo.toml +++ b/runtime/mangata-rococo/Cargo.toml @@ -32,6 +32,7 @@ pallet-multipurpose-liquidity = { path = '../../pallets/multipurpose-liquidity', pallet-maintenance = { path = '../../pallets/maintenance', default-features = false } pallet-fee-lock = { path = '../../pallets/fee-lock', default-features = false} mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +proof-of-stake-runtime-api = { path = '../../pallets/proof-of-stake/runtime-api', default-features = false} # Substrate Dependencies ## Substrate Primitive Dependencies @@ -175,6 +176,7 @@ std = [ "pallet-treasury/std", "pallet-xyk/std", "pallet-proof-of-stake/std", + "proof-of-stake-runtime-api/std", "pallet-bootstrap/std", "xyk-runtime-api/std", "parachain-staking/std", diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index 5aa713b617..0782b792a1 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -277,6 +277,9 @@ impl pallet_proof_of_stake::Config for Runtime { type LiquidityMiningIssuanceVault = cfg::pallet_issuance::LiquidityMiningIssuanceVault; type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; + type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; + type Min3rdPartyRewards = cfg::pallet_proof_of_stake::Min3rdPartyRewards; + type ValuationApi = Xyk; } impl pallet_bootstrap::BootstrapBenchmarkingConfig for Runtime {} @@ -781,6 +784,34 @@ mod benches { impl_runtime_apis! { + impl proof_of_stake_runtime_api::ProofOfStakeApi for Runtime{ + fn calculate_native_rewards_amount( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> Balance{ + ProofOfStake::calculate_native_rewards_amount(user, liquidity_asset_id) + .unwrap_or_default() + } + + fn calculate_3rdparty_rewards_amount( + user: AccountId, + liquidity_asset_id: TokenId, + reward_asset_id: TokenId, + ) -> Balance{ + ProofOfStake::calculate_rewards_amount_3rdparty(user, liquidity_asset_id, reward_asset_id) + .unwrap_or_default() + } + + fn calculate_3rdparty_rewards_all( + user: AccountId, + liquidity_asset_id: TokenId, + ) -> Vec<(TokenId, Balance)>{ + ProofOfStake::calculate_3rdparty_rewards_all(user, liquidity_asset_id) + .unwrap_or_default() + } + } + + impl ver_api::VerApi for Runtime { fn get_signer( tx: ::Extrinsic, diff --git a/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs b/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs index d7f3024fd8..99a6a2573d 100644 --- a/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs +++ b/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs @@ -56,10 +56,14 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { - fn claim_rewards_all() -> Weight; + fn claim_native_rewards() -> Weight; + fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; - fn activate_liquidity() -> Weight; - fn deactivate_liquidity() -> Weight; + fn activate_liquidity_for_native_rewards() -> Weight; + fn deactivate_liquidity_for_native_rewards() -> Weight; + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; + fn activate_liquidity_for_3rdparty_rewards() -> Weight; + fn reward_pool() -> Weight; } /// Weights for pallet_proof_of_stake using the Mangata node and recommended hardware. @@ -71,7 +75,13 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_rewards_all() -> Weight { + fn claim_native_rewards() -> Weight { + (Weight::from_parts(81_410_000, 0)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) + } + + fn claim_3rdparty_rewards() -> Weight { (Weight::from_parts(81_410_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) @@ -93,7 +103,7 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) - fn activate_liquidity() -> Weight { + fn activate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(94_130_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) @@ -108,11 +118,30 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn deactivate_liquidity() -> Weight { + fn deactivate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(82_600_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + + + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn activate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn reward_pool() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } } // For backwards compatibility and tests @@ -123,11 +152,24 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_rewards_all() -> Weight { + fn claim_native_rewards() -> Weight { (Weight::from_parts(81_410_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } + + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfo (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(81_410_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) + } + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { @@ -145,7 +187,7 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) - fn activate_liquidity() -> Weight { + fn activate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(94_130_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -160,9 +202,28 @@ impl WeightInfo for () { // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn deactivate_liquidity() -> Weight { + fn deactivate_liquidity_for_native_rewards() -> Weight { (Weight::from_parts(82_600_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn activate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + + fn reward_pool() -> Weight { + (Weight::from_parts(118_250_000, 0)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().writes(4 as u64)) + } + } From a0ec565b733bedced71340df29d9c1a4b767a819 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 27 Sep 2023 15:44:11 +0000 Subject: [PATCH 25/83] runtime api implemented --- node/Cargo.toml | 4 ++-- node/src/rpc.rs | 2 ++ pallets/proof-of-stake/runtime-api/src/lib.rs | 2 +- pallets/proof-of-stake/src/lib.rs | 22 ++++++++----------- runtime/mangata-kusama/src/lib.rs | 4 ++-- runtime/mangata-rococo/src/lib.rs | 4 ++-- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/node/Cargo.toml b/node/Cargo.toml index 9b0b2abac1..5d888bf37f 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -143,8 +143,8 @@ polkadot-test-service = { git = "https://github.com/mangata-finance/polkadot", b # Mangata dependencies xyk-rpc = { default-features = false, version = '2.0.0', path = '../pallets/xyk/rpc' } xyk-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/xyk/runtime-api' } -proof-of-stake-runtime-api = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } -proof-of-stake-rpc = { default-features = false, version = '2.0.0', path = '../pallets/proof-of-stake/rpc' } +proof-of-stake-runtime-api = { version = '2.0.0', path = '../pallets/proof-of-stake/runtime-api' } +proof-of-stake-rpc = { version = '2.0.0', path = '../pallets/proof-of-stake/rpc' } [dev-dependencies] diff --git a/node/src/rpc.rs b/node/src/rpc.rs index 3c8abbe28d..e43501c90b 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -53,6 +53,7 @@ where use pallet_transaction_payment_mangata_rpc::{TransactionPayment, TransactionPaymentApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; use xyk_rpc::{Xyk, XykApiServer}; + use proof_of_stake_rpc::{ProofOfStake, ProofOfStakeApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; @@ -60,6 +61,7 @@ where module.merge(System::new(client.clone(), pool.clone(), deny_unsafe).into_rpc())?; module.merge(TransactionPayment::new(client.clone()).into_rpc())?; module.merge(Xyk::new(client.clone()).into_rpc())?; + module.merge(ProofOfStake::new(client.clone()).into_rpc())?; Ok(module) } diff --git a/pallets/proof-of-stake/runtime-api/src/lib.rs b/pallets/proof-of-stake/runtime-api/src/lib.rs index 6f0012f1db..a81e86b9c2 100644 --- a/pallets/proof-of-stake/runtime-api/src/lib.rs +++ b/pallets/proof-of-stake/runtime-api/src/lib.rs @@ -24,6 +24,6 @@ sp_api::decl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, liquidity_asset_id: TokenId, - ) -> Vec<(TokenId, Balance)>; + ) -> Vec<(TokenId, TokenId, Balance)>; } } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 2a6aa0b241..2f727e1ae4 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -6,7 +6,7 @@ //! //! ## Types of Rewards //! -//! ### Liquidity Mining Rewards +//! ### Native Rewards //! //! As described in Mangata tokenomics, during each session, some of the rewards are minted and distributed //! among promoted pools. The council decides which pool to promote, and each promoted pool has a weight @@ -39,7 +39,7 @@ //! - [`Pallet::claim_native_rewards`] - Claims all rewards for all liquidity tokens. //! - [`Pallet::update_pool_promotion`] - Enables/disables the pool for liquidity mining rewards. //! -//! ### Scheduled Rewards +//! ### 3rd Party Rewards //! //! Anyone can provide tokens to reward people who store a particular liquidity token. Any //! liquidity token can be rewarded with any other token provided by the user. Liquidity can be @@ -690,11 +690,6 @@ pub mod pallet { } } -pub enum RewardsKind { - RewardsLiquidityMinting, - Rewards3rdParty(TokenId), -} - impl Pallet { fn activate_liquidity_for_native_rewards_impl( user: AccountIdOf, @@ -876,11 +871,12 @@ impl Pallet { pub fn calculate_3rdparty_rewards_all( user: AccountIdOf, - liquidity_asset_id: TokenId, - ) -> Result, DispatchError> { - Self::ensure_is_promoted_pool(liquidity_asset_id)?; - todo!(); - + ) -> Result, DispatchError> { + RewardsInfoForScheduleRewards::::iter_prefix(user.clone()) + .map(|((liq_token, reward_token), _)| + Self::calculate_rewards_amount_3rdparty(user.clone(), liq_token, reward_token) + .map(|amount| (liq_token, reward_token, amount)) + ).collect::, _>>() } pub fn calculate_rewards_amount_3rdparty( @@ -1381,4 +1377,4 @@ impl LiquidityMiningApi for Pallet { } // benchmark for claim 3rdparty rewards -// move runtime configs to common runtime +// test for calculate_3rdparty_rewards_all diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 49585e9692..8d690fa1cf 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -790,8 +790,8 @@ impl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, liquidity_asset_id: TokenId, - ) -> Vec<(TokenId, Balance)>{ - ProofOfStake::calculate_3rdparty_rewards_all(user, liquidity_asset_id) + ) -> Vec<(TokenId, TokenId, Balance)>{ + ProofOfStake::calculate_3rdparty_rewards_all(user) .unwrap_or_default() } } diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index 0782b792a1..ab3572101e 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -805,8 +805,8 @@ impl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, liquidity_asset_id: TokenId, - ) -> Vec<(TokenId, Balance)>{ - ProofOfStake::calculate_3rdparty_rewards_all(user, liquidity_asset_id) + ) -> Vec<(TokenId, TokenId, Balance)>{ + ProofOfStake::calculate_3rdparty_rewards_all(user) .unwrap_or_default() } } From 0c461b9486e6f383a4b4360c62e113b0f3f01250 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 28 Sep 2023 07:33:30 +0000 Subject: [PATCH 26/83] benchmarks for PoS::claim_3rdparty_rewards --- pallets/proof-of-stake/src/benchmarking.rs | 108 ++++++++++++++++++--- pallets/proof-of-stake/src/lib.rs | 4 +- pallets/proof-of-stake/src/tests.rs | 40 ++++---- 3 files changed, 115 insertions(+), 37 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 78bf94e4df..96a9615c92 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -53,7 +53,7 @@ where } benchmarks! { - claim_rewards_all{ + claim_native_rewards{ // 1. create // 2. promote // 3. mint @@ -82,14 +82,14 @@ benchmarks! { forward_to_next_session::(); - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity_for_native_rewards(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); forward_to_next_session::(); forward_to_next_session::(); assert!(PoS::::calculate_rewards_amount(caller.clone(), liquidity_asset_id).unwrap() > 0); - }: claim_rewards_all(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id) + }: claim_native_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id) verify { assert_eq!( @@ -113,7 +113,7 @@ benchmarks! { ); } - activate_liquidity{ + activate_liquidity_for_native_rewards{ // activate : // 1 crate pool // 2 promote pool @@ -141,7 +141,7 @@ benchmarks! { let half_of_minted_liquidity = total_minted_liquidity / 2_u128; let quater_of_minted_liquidity = total_minted_liquidity / 4_u128; - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity_for_native_rewards(RawOrigin::Signed(caller.clone()).into(), liquidity_asset_id.into(), quater_of_minted_liquidity, None).unwrap(); assert_eq!( PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, @@ -150,7 +150,7 @@ benchmarks! { forward_to_next_session::(); - }: activate_liquidity(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity, None) + }: activate_liquidity_for_native_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id.into(), quater_of_minted_liquidity, None) verify { assert_eq!( @@ -185,7 +185,7 @@ benchmarks! { let half_of_minted_liquidity = total_minted_liquidity.into() / 2_u128; let quater_of_minted_liquidity = total_minted_liquidity.into() / 4_u128; - PoS::::activate_liquidity(RawOrigin::Signed(caller.clone().into()).into(), liquidity_asset_id.into(), half_of_minted_liquidity, None).unwrap(); + PoS::::activate_liquidity_for_native_rewards(RawOrigin::Signed(caller.clone().into()).into(), liquidity_asset_id.into(), half_of_minted_liquidity, None).unwrap(); assert_eq!( PoS::::get_rewards_info(caller.clone(), liquidity_asset_id).activated_amount, @@ -271,7 +271,7 @@ benchmarks! { } - activate_liquidity_for_rewards_schedule{ + activate_liquidity_for_3rdparty_rewards{ // 1 create pool that can be rewarded // 2 create token that is used as reward // 3 activate rewards @@ -310,16 +310,16 @@ benchmarks! { 2u32.into(), ).unwrap(); - }: activate_liquidity_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id, None) + }: activate_liquidity_for_3rdparty_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id, None) verify { forward_to_next_session::(); assert_eq!( - PoS::::calculate_rewards_amount_3rdparty(caller, liquidity_asset_id, reward_token_id).unwrap(), + PoS::::calculate_3rdparty_rewards_amount(caller, liquidity_asset_id, reward_token_id).unwrap(), rewards_amount/2 ) } - deactivate_liquidity_for_native_rewards_for_rewards_schedule{ + deactivate_liquidity_for_3rdparty_rewards{ // 1 create pool that can be rewarded // 2 create token that is used as reward // 3 activate rewards @@ -359,8 +359,6 @@ benchmarks! { 2u32.into(), ).unwrap(); - // println!("{:?}", TokensOf::::free_balance(reward_token_id.into(), &caller)); - assert!(TokensOf::::ensure_can_withdraw( liquidity_asset_id.into(), &caller, @@ -369,7 +367,7 @@ benchmarks! { Default::default(), ).is_ok()); - PoS::::activate_liquidity_for_rewards_schedule( + PoS::::activate_liquidity_for_3rdparty_rewards( RawOrigin::Signed(caller.clone().into()).into(), liquidity_asset_id, 10_000u128, @@ -388,7 +386,7 @@ benchmarks! { ); - }: deactivate_liquidity_for_native_rewards_for_rewards_schedule(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id) + }: deactivate_liquidity_for_3rdparty_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id) verify { assert!(TokensOf::::ensure_can_withdraw( @@ -400,5 +398,85 @@ benchmarks! { ).is_ok()); } + + claim_3rdparty_rewards{ + // 1 create pool that can be rewarded + // 2 create token that is used as reward + // 3 activate rewards + // 4 wait for rewards to be avialble + // 5 claim rewards + + init::(); + + let schedules_limit = ::RewardsSchedulesLimit::get(); + let caller: ::AccountId = whitelisted_caller(); + let native_asset_id = ::NativeCurrencyId::get(); + + loop { + let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + if token_id > native_asset_id { + break; + } + } + + let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); + + let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let liquidity_asset_id = first_token_id + 1; + + let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let reward_token_id = second_token_id + 1; + + let rewards_amount = 20_000u128; + + PoS::::reward_pool( + RawOrigin::Signed(caller.clone().into()).into(), + (native_asset_id, first_token_id), + reward_token_id.into(), + rewards_amount, + 2u32.into(), + ).unwrap(); + + PoS::::activate_liquidity_for_3rdparty_rewards( + RawOrigin::Signed(caller.clone().into()).into(), + liquidity_asset_id, + 10_000u128, + reward_token_id, + None + ).unwrap(); + + forward_to_next_session::(); + assert_eq!( + PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), + 10_000u128 + ); + forward_to_next_session::(); + assert_eq!( + PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), + 20_000u128 + ); + forward_to_next_session::(); + assert_eq!( + PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), + 20_000u128 + ); + + let balance_before:u128 = TokensOf::::free_balance(reward_token_id.into(), &caller).into(); + + }: claim_3rdparty_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, reward_token_id) + verify { + + let balance_after:u128 = TokensOf::::free_balance(reward_token_id.into(), &caller).into(); + assert_eq!( + PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), + 0u128 + ); + + assert_eq!(balance_after - balance_before, 20_000u128); + } + impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 2f727e1ae4..96142a0d1f 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -874,12 +874,12 @@ impl Pallet { ) -> Result, DispatchError> { RewardsInfoForScheduleRewards::::iter_prefix(user.clone()) .map(|((liq_token, reward_token), _)| - Self::calculate_rewards_amount_3rdparty(user.clone(), liq_token, reward_token) + Self::calculate_3rdparty_rewards_amount(user.clone(), liq_token, reward_token) .map(|amount| (liq_token, reward_token, amount)) ).collect::, _>>() } - pub fn calculate_rewards_amount_3rdparty( + pub fn calculate_3rdparty_rewards_amount( user: AccountIdOf, liquidity_asset_id: TokenId, rewards_asset_id: TokenId, diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 7cc1d4faa9..4e0b6286d9 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1461,7 +1461,7 @@ fn user_can_claim_3rdparty_rewards() { ) .unwrap(); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(0) ); @@ -1475,7 +1475,7 @@ fn user_can_claim_3rdparty_rewards() { ) .unwrap(); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN @@ -1483,17 +1483,17 @@ fn user_can_claim_3rdparty_rewards() { Ok(0) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1000) ); roll_to_session(3); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN @@ -1564,7 +1564,7 @@ fn overlapping_3rdparty_rewards_works() { roll_to_session(6); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, second_reward_token_id @@ -1573,7 +1573,7 @@ fn overlapping_3rdparty_rewards_works() { ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, first_reward_token @@ -1639,7 +1639,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { roll_to_session(6); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN @@ -1648,7 +1648,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN @@ -1704,12 +1704,12 @@ fn deactivate_3rdparty_rewards() { roll_to_session(2); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(500) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN @@ -1727,12 +1727,12 @@ fn deactivate_3rdparty_rewards() { roll_to_session(3); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN @@ -1793,7 +1793,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { .unwrap(); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN @@ -1801,7 +1801,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { Ok(0) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN @@ -1812,7 +1812,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { roll_to_session(1); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN @@ -1820,7 +1820,7 @@ fn claim_rewards_from_multiple_schedules_using_single_liquidity() { Ok(1000) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN @@ -1884,7 +1884,7 @@ fn liquidity_minting_liquidity_can_be_resused() { assert_eq!(ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), Ok(200)); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN @@ -2165,7 +2165,7 @@ fn can_claim_schedule_rewards() { assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 1000,); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN @@ -2173,7 +2173,7 @@ fn can_claim_schedule_rewards() { Ok(0) ); assert_eq!( - ProofOfStake::calculate_rewards_amount_3rdparty( + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN From 251905034e92c849bb4152a09c3ebcad3d98f1e0 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 28 Sep 2023 09:07:52 +0000 Subject: [PATCH 27/83] test for calculate_3rdparty_rewards_all --- node/src/rpc.rs | 2 +- pallets/proof-of-stake/rpc/src/lib.rs | 21 +- pallets/proof-of-stake/src/lib.rs | 34 +-- pallets/proof-of-stake/src/tests.rs | 424 +++++++++++++++++++++----- runtime/common/src/lib.rs | 1 - 5 files changed, 362 insertions(+), 120 deletions(-) diff --git a/node/src/rpc.rs b/node/src/rpc.rs index e43501c90b..d19d75d00e 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -51,9 +51,9 @@ where P: TransactionPool + Sync + Send + 'static, { use pallet_transaction_payment_mangata_rpc::{TransactionPayment, TransactionPaymentApiServer}; + use proof_of_stake_rpc::{ProofOfStake, ProofOfStakeApiServer}; use substrate_frame_rpc_system::{System, SystemApiServer}; use xyk_rpc::{Xyk, XykApiServer}; - use proof_of_stake_rpc::{ProofOfStake, ProofOfStakeApiServer}; let mut module = RpcExtension::new(()); let FullDeps { client, pool, deny_unsafe } = deps; diff --git a/pallets/proof-of-stake/rpc/src/lib.rs b/pallets/proof-of-stake/rpc/src/lib.rs index 64a893a87d..fc309cb757 100644 --- a/pallets/proof-of-stake/rpc/src/lib.rs +++ b/pallets/proof-of-stake/rpc/src/lib.rs @@ -6,6 +6,8 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorObject}, }; +pub use proof_of_stake_runtime_api::XykApi as XykRuntimeApi; +use proof_of_stake_runtime_api::{RpcAmountsResult, RpcAssetMetadata, XYKRpcResult}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::U256; @@ -16,17 +18,9 @@ use sp_runtime::{ }; use sp_std::convert::{TryFrom, TryInto}; use std::sync::Arc; -pub use proof_of_stake_runtime_api::XykApi as XykRuntimeApi; -use proof_of_stake_runtime_api::{RpcAmountsResult, RpcAssetMetadata, XYKRpcResult}; #[rpc(client, server)] -pub trait ProofOfStakeApi< - BlockHash, - Balance, - TokenId, - AccountId -> -{ +pub trait ProofOfStakeApi { #[method(name = "foo")] fn foo( &self, @@ -50,12 +44,8 @@ impl ProofOfStake { #[async_trait] impl - ProofOfStakeApiServer< - ::Hash, - NumberOrHex, - TokenId, - AccountId - > for ProofOfStake + ProofOfStakeApiServer<::Hash, NumberOrHex, TokenId, AccountId> + for ProofOfStake where Block: BlockT, C: Send + Sync + 'static, @@ -74,5 +64,4 @@ where at: Option, ) -> RpcResult> { } - } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 96142a0d1f..c0f7a38ece 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -394,7 +394,7 @@ pub mod pallet { #[transactional] #[pallet::call_index(0)] #[pallet::weight(<::WeightInfo>::claim_native_rewards())] - #[deprecated(note = "claim_native_rewards should be used instead")] + #[deprecated(note = "claim_native_rewards should be used instead")] pub fn claim_rewards_all( origin: OriginFor, liquidity_token_id: TokenId, @@ -468,11 +468,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::deactivate_liquidity_for_native_rewards_impl( - sender, - liquidity_token_id, - amount, - ) + Self::deactivate_liquidity_for_native_rewards_impl(sender, liquidity_token_id, amount) } /// Schedules rewards for selected liquidity token @@ -662,17 +658,13 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::deactivate_liquidity_for_native_rewards_impl( - sender, - liquidity_token_id, - amount, - ) + Self::deactivate_liquidity_for_native_rewards_impl(sender, liquidity_token_id, amount) } #[transactional] #[pallet::call_index(10)] #[pallet::weight(<::WeightInfo>::claim_native_rewards())] - #[deprecated(note = "claim_native_rewards should be used instead")] + #[deprecated(note = "claim_native_rewards should be used instead")] pub fn claim_native_rewards( origin: OriginFor, liquidity_token_id: TokenId, @@ -686,7 +678,6 @@ pub mod pallet { Ok(()) } - } } @@ -746,7 +737,6 @@ impl Pallet { .ok_or(Error::::CalculateRewardsMathError)?) } - fn deactivate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -872,11 +862,14 @@ impl Pallet { pub fn calculate_3rdparty_rewards_all( user: AccountIdOf, ) -> Result, DispatchError> { - RewardsInfoForScheduleRewards::::iter_prefix(user.clone()) - .map(|((liq_token, reward_token), _)| - Self::calculate_3rdparty_rewards_amount(user.clone(), liq_token, reward_token) - .map(|amount| (liq_token, reward_token, amount)) - ).collect::, _>>() + let mut result = RewardsInfoForScheduleRewards::::iter_prefix(user.clone()) + .map(|((liq_token, reward_token), _)| { + Self::calculate_3rdparty_rewards_amount(user.clone(), liq_token, reward_token) + .map(|amount| (liq_token, reward_token, amount)) + }) + .collect::, _>>(); + result.as_mut().map(|v| v.sort()); + result } pub fn calculate_3rdparty_rewards_amount( @@ -1283,9 +1276,7 @@ impl ProofOfStakeRewardsApi for Pallet { user: AccountIdOf, liquidity_asset_id: TokenId, ) -> Result { - Self::calculate_native_rewards_amount(user, liquidity_asset_id) - } } @@ -1376,5 +1367,4 @@ impl LiquidityMiningApi for Pallet { } } -// benchmark for claim 3rdparty rewards // test for calculate_3rdparty_rewards_all diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 4e0b6286d9..021cb35605 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -5,6 +5,7 @@ use super::*; use crate::mock::*; use frame_support::{assert_err, assert_ok}; +use mockall::predicate::eq; use serial_test::serial; use mangata_support::traits::{ComputeIssuance, GetIssuance}; @@ -13,7 +14,13 @@ type TokensOf = ::Currency; fn mint_and_activate_tokens(who: AccountId, token_id: TokenId, amount: Balance) { TokensOf::::mint(token_id, &who, amount).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(who), token_id, amount, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(who), + token_id, + amount, + None, + ) + .unwrap(); } fn initialize_liquidity_rewards() { @@ -32,7 +39,8 @@ fn initialize_liquidity_rewards() { pools.get_mut(&4).unwrap().rewards = U256::from(0); }); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None) + .unwrap(); } pub(crate) fn roll_to_session(n: u32) { @@ -75,8 +83,13 @@ fn liquidity_rewards_single_user_mint_W() { let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 2u8).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); let rewards_info = ProofOfStake::get_rewards_info(2, 4); @@ -144,8 +157,13 @@ fn liquidity_rewards_three_users_burn_W() { TokensOf::::transfer(1, &2, &4, 1000000, ExistenceRequirement::AllowDeath).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(100); @@ -156,7 +174,8 @@ fn liquidity_rewards_three_users_burn_W() { mint_and_activate_tokens(4, 4, 10000); forward_to_block(240); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000) + .unwrap(); forward_to_block(400); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 95965); @@ -189,8 +208,13 @@ fn liquidity_rewards_claim_W() { TokensOf::::create(&acc_id, 10000).unwrap(); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(10); forward_to_block(90); @@ -260,8 +284,13 @@ fn liquidity_rewards_work_after_burn_W() { TokensOf::::transfer(1, &2, &4, 1000000, ExistenceRequirement::AllowDeath).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); @@ -272,7 +301,8 @@ fn liquidity_rewards_work_after_burn_W() { mint_and_activate_tokens(4, 4, 10000); forward_to_block(240); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 10000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 10000) + .unwrap(); forward_to_block(400); assert_eq!(ProofOfStake::calculate_rewards_amount(4, 4).unwrap(), 948); @@ -301,8 +331,13 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); assert_err!( TokensOf::::transfer(4, &2, &3, 10, ExistenceRequirement::AllowDeath), orml_tokens::Error::::BalanceTooLow, @@ -311,8 +346,12 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { forward_to_block(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) - .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + ) + .unwrap(); TokensOf::::transfer(4, &2, &3, 10, ExistenceRequirement::AllowDeath).unwrap(); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); }); @@ -335,8 +374,13 @@ fn liquidity_rewards_deactivate_more_NW() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); assert_err!( ProofOfStake::deactivate_liquidity_for_native_rewards( RuntimeOrigin::signed(2), @@ -452,20 +496,34 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(10); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 291); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned) - .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + ) + .unwrap(); let rewards_info = ProofOfStake::get_rewards_info(2, 4); assert_eq!(rewards_info.rewards_not_yet_claimed, 291); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(100); @@ -493,7 +551,8 @@ fn extreme_case_pool_ratio() { TokensOf::::create(&acc_id, max).unwrap(); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 1, None) + .unwrap(); PromotedPoolRewards::::mutate(|pools| { pools.get_mut(&4).unwrap().rewards = U256::from(u128::MAX) * U256::from(u128::MAX); @@ -630,7 +689,13 @@ fn rewards_storage_right_amounts_start1() { TokensOf::::transfer(2, &2, &5, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(1, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + 10000, + None, + ) + .unwrap(); mint_and_activate_tokens(3, 4, 10000); mint_and_activate_tokens(4, 4, 10000); mint_and_activate_tokens(5, 4, 10000); @@ -687,7 +752,8 @@ fn rewards_storage_right_amounts_start1() { // usecase 6 burn some user_balance_before = TokensOf::::free_balance(0, &3); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000) + .unwrap(); user_balance_after = TokensOf::::free_balance(0, &3); rewards_info = ProofOfStake::get_rewards_info(3, 4); @@ -710,7 +776,8 @@ fn rewards_storage_right_amounts_start1() { // usecase 8 deactivate some user_balance_before = TokensOf::::free_balance(0, &5); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000) + .unwrap(); user_balance_after = TokensOf::::free_balance(0, &5); rewards_info = ProofOfStake::get_rewards_info(5, 4); @@ -767,7 +834,13 @@ fn rewards_storage_right_amounts_start2() { TokensOf::::transfer(2, &2, &5, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(1, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &6, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + 10000, + None, + ) + .unwrap(); mint_and_activate_tokens(3, 4, 10000); mint_and_activate_tokens(4, 4, 10000); mint_and_activate_tokens(5, 4, 10000); @@ -778,10 +851,14 @@ fn rewards_storage_right_amounts_start2() { PromotedPoolRewards::::get().get(&4).unwrap().rewards ); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000).unwrap(); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 5000) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000) + .unwrap(); forward_to_block_with_custom_rewards(200, 20000); //its really weird that rewards are //decreased from 40k to 20k in single @@ -823,7 +900,8 @@ fn rewards_storage_right_amounts_start2() { // usecase 9 burn some user_balance_before = TokensOf::::free_balance(0, &3); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, 5000) + .unwrap(); user_balance_after = TokensOf::::free_balance(0, &3); rewards_info = ProofOfStake::get_rewards_info(3, 4); @@ -845,7 +923,8 @@ fn rewards_storage_right_amounts_start2() { // usecase 11 deactivate some user_balance_before = TokensOf::::free_balance(0, &5); - ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000).unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000) + .unwrap(); user_balance_after = TokensOf::::free_balance(0, &5); rewards_info = ProofOfStake::get_rewards_info(5, 4); @@ -888,7 +967,13 @@ fn rewards_storage_right_amounts_start3() { TokensOf::::transfer(1, &2, &4, 20010, ExistenceRequirement::AllowDeath).unwrap(); TokensOf::::transfer(2, &2, &4, 20010, ExistenceRequirement::AllowDeath).unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, 10000, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + 10000, + None, + ) + .unwrap(); mint_and_activate_tokens(3, 4, 10000); forward_to_block_with_custom_rewards(100, 20000); @@ -965,8 +1050,13 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { ) .unwrap(); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(3), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(3), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(100); @@ -1022,7 +1112,13 @@ fn test_migrated_from_pallet_issuance() { assert_eq!(1, TokensOf::::create(&99999, 1_000_000u128).unwrap()); ProofOfStake::enable(1, 1u8); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(99999), 1, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(99999), + 1, + 1, + None, + ) + .unwrap(); roll_to_while_minting(4, None); assert_eq!( @@ -1037,7 +1133,13 @@ fn test_migrated_from_pallet_issuance() { assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); ProofOfStake::enable(2, 1u8); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(99999), 2, 1, None).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(99999), + 2, + 1, + None, + ) + .unwrap(); roll_to_while_minting(14, None); assert_eq!( U256::from_dec_str("191427546923208537313638702283778366195067525").unwrap(), @@ -1085,8 +1187,13 @@ fn claim_rewards_from_pool_that_has_been_disabled() { ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), 4, 1u8).unwrap(); let liquidity_tokens_owned = TokensOf::::free_balance(4, &2); - ProofOfStake::activate_liquidity_for_native_rewards(RuntimeOrigin::signed(2), 4, liquidity_tokens_owned, None) - .unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(2), + 4, + liquidity_tokens_owned, + None, + ) + .unwrap(); forward_to_block(10); @@ -1102,11 +1209,15 @@ fn claim_rewards_from_pool_that_has_been_disabled() { const MILLION: u128 = 1_000_000; const REWARDED_PAIR: (TokenId, TokenId) = (0u32, 4u32); +const FIRST_REWARDED_PAIR: (TokenId, TokenId) = (0u32, 4u32); +const SECOND_REWARDED_PAIR: (TokenId, TokenId) = (0u32, 5u32); const REWARD_AMOUNT: u128 = 10_000u128; const REWARD_TOKEN: u32 = 5u32; const FIRST_REWARD_TOKEN: u32 = REWARD_TOKEN; const SECOND_REWARD_TOKEN: u32 = 6u32; const LIQUIDITY_TOKEN: u32 = 10; +const FIRST_LIQUIDITY_TOKEN: u32 = 10; +const SECOND_LIQUIDITY_TOKEN: u32 = 11; const ALICE: u128 = 2; const BOB: u128 = 3; const CHARLIE: u128 = 4; @@ -1744,88 +1855,241 @@ fn deactivate_3rdparty_rewards() { #[test] #[serial] -fn claim_rewards_from_multiple_schedules_using_single_liquidity() { +fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() { ExtBuilder::new() - .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) - .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) - .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(ALICE, FIRST_REWARD_TOKEN, 2 * REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 4 * REWARD_AMOUNT) + .issue(BOB, FIRST_LIQUIDITY_TOKEN, 100) + .issue(BOB, SECOND_LIQUIDITY_TOKEN, 100) .build() .execute_with(|| { let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + get_liquidity_asset_mock + .expect() + .with(eq(FIRST_REWARDED_PAIR.0), eq(FIRST_REWARDED_PAIR.1)) + .return_const(Ok(FIRST_LIQUIDITY_TOKEN)); + get_liquidity_asset_mock + .expect() + .with(eq(SECOND_REWARDED_PAIR.0), eq(SECOND_REWARDED_PAIR.1)) + .return_const(Ok(SECOND_LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); System::set_block_number(1); - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, + FIRST_REWARDED_PAIR, FIRST_REWARD_TOKEN, REWARD_AMOUNT, 10u32.into(), ) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + 100u128, + FIRST_REWARD_TOKEN, + None, + ) + .unwrap(); + + roll_to_session(1); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![(FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 1 * 1000u128),] + ); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, + FIRST_REWARDED_PAIR, SECOND_REWARD_TOKEN, 2 * REWARD_AMOUNT, - 10u32.into(), + 11u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + 100u128, + SECOND_REWARD_TOKEN, + Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); + roll_to_session(2); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] + ); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + SECOND_REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 12u32.into(), + ) + .unwrap(); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, + SECOND_LIQUIDITY_TOKEN, + 100u128, FIRST_REWARD_TOKEN, None, ) .unwrap(); + + roll_to_session(3); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 3 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 2 * 2000u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 1 * 1000u128), + ] + ); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + SECOND_REWARDED_PAIR, + SECOND_REWARD_TOKEN, + 2 * REWARD_AMOUNT, + 13u32.into(), + ) + .unwrap(); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, + SECOND_LIQUIDITY_TOKEN, + 100u128, SECOND_REWARD_TOKEN, Some(ThirdPartyActivationKind::ActivatedLiquidity(FIRST_REWARD_TOKEN)), ) .unwrap(); + roll_to_session(4); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - FIRST_REWARD_TOKEN - ), - Ok(0) + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 4 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] + ); + + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] ); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - SECOND_REWARD_TOKEN - ), - Ok(0) + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] ); - roll_to_session(1); + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] + ); + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + SECOND_LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - FIRST_REWARD_TOKEN - ), - Ok(1000) + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), + ] ); + + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + SECOND_LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(); + assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - SECOND_REWARD_TOKEN - ), - Ok(2000) + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + ] + ); + + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + FIRST_LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + ) + .unwrap(); + + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + SECOND_LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + SECOND_LIQUIDITY_TOKEN, + 100, + SECOND_REWARD_TOKEN, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), + (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0u128), + ] ); }); } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 8b749ad82c..7bdff2fdac 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1376,5 +1376,4 @@ where pub const Min3rdPartyRewards: u128 = 100 * 30_000 * currency::DOLLARS; } } - } From af3a2e066e6b43531661de666b2e25a008230c60 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 28 Sep 2023 10:02:39 +0000 Subject: [PATCH 28/83] Align Proof of stake runtime api to share interface with other runtime apis --- Cargo.lock | 1 + node/src/rpc.rs | 1 + node/src/service.rs | 2 + pallets/bootstrap/src/tests.rs | 2 - pallets/proof-of-stake/rpc/Cargo.toml | 1 + pallets/proof-of-stake/rpc/src/lib.rs | 92 ++++++++++++++++++++--- pallets/proof-of-stake/src/lib.rs | 5 -- pallets/proof-of-stake/src/reward_info.rs | 1 - runtime/mangata-kusama/src/lib.rs | 6 +- runtime/mangata-rococo/src/lib.rs | 7 +- 10 files changed, 92 insertions(+), 26 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4cb285b114..2664e59056 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9282,6 +9282,7 @@ name = "proof-of-stake-rpc" version = "2.0.0" dependencies = [ "jsonrpsee", + "mangata-types", "parity-scale-codec", "proof-of-stake-runtime-api", "serde", diff --git a/node/src/rpc.rs b/node/src/rpc.rs index d19d75d00e..63023cac00 100644 --- a/node/src/rpc.rs +++ b/node/src/rpc.rs @@ -46,6 +46,7 @@ where C::Api: pallet_transaction_payment_mangata_rpc::TransactionPaymentRuntimeApi, C::Api: substrate_frame_rpc_system::AccountNonceApi, C::Api: xyk_rpc::XykRuntimeApi, + C::Api: proof_of_stake_rpc::ProofOfStakeRuntimeApi, C::Api: BlockBuilder, C::Api: VerNonceApi, P: TransactionPool + Sync + Send + 'static, diff --git a/node/src/service.rs b/node/src/service.rs index 5ebfe00e75..0b2e5a2201 100644 --- a/node/src/service.rs +++ b/node/src/service.rs @@ -308,6 +308,7 @@ where + substrate_frame_rpc_system::AccountNonceApi + ver_api::VerApi + ver_api::VerNonceApi + + proof_of_stake_rpc::ProofOfStakeRuntimeApi + xyk_rpc::XykRuntimeApi + sp_consensus_aura::AuraApi, sc_client_api::StateBackendFor, Block>: sp_api::StateBackend, @@ -532,6 +533,7 @@ where + ver_api::VerApi + ver_api::VerNonceApi + xyk_rpc::XykRuntimeApi + + proof_of_stake_rpc::ProofOfStakeRuntimeApi + sp_consensus_aura::AuraApi, { start_node_impl::( diff --git a/pallets/bootstrap/src/tests.rs b/pallets/bootstrap/src/tests.rs index 487daafd98..150850e8ea 100644 --- a/pallets/bootstrap/src/tests.rs +++ b/pallets/bootstrap/src/tests.rs @@ -728,10 +728,8 @@ fn test_bootstrap_state_transitions() { Bootstrap::on_initialize(BOOTSTRAP_PUBLIC_START); assert_eq!(Bootstrap::phase(), BootstrapPhase::Public); - println!("{:?}", Bootstrap::phase()); for i in BOOTSTRAP_PUBLIC_START..BOOTSTRAP_FINISH { Bootstrap::on_initialize(i); - println!("{:?}", Bootstrap::phase()); assert_eq!(Bootstrap::phase(), BootstrapPhase::Public); } diff --git a/pallets/proof-of-stake/rpc/Cargo.toml b/pallets/proof-of-stake/rpc/Cargo.toml index 705babe0f5..4a76093273 100644 --- a/pallets/proof-of-stake/rpc/Cargo.toml +++ b/pallets/proof-of-stake/rpc/Cargo.toml @@ -19,6 +19,7 @@ sp-rpc = { version = '6.0.0', default-features = false, git = "https://github.co sp-core = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } sp-std = { version = '5.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } sp-runtime = { version = '7.0.0', default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } +mangata-types = { default-features = false, git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } # local packages diff --git a/pallets/proof-of-stake/rpc/src/lib.rs b/pallets/proof-of-stake/rpc/src/lib.rs index fc309cb757..58d15682cd 100644 --- a/pallets/proof-of-stake/rpc/src/lib.rs +++ b/pallets/proof-of-stake/rpc/src/lib.rs @@ -6,8 +6,8 @@ use jsonrpsee::{ proc_macros::rpc, types::error::{CallError, ErrorObject}, }; -pub use proof_of_stake_runtime_api::XykApi as XykRuntimeApi; -use proof_of_stake_runtime_api::{RpcAmountsResult, RpcAssetMetadata, XYKRpcResult}; +pub use proof_of_stake_runtime_api::ProofOfStakeApi as ProofOfStakeRuntimeApi; +// use proof_of_stake_runtime_api::{RpcAmountsResult, RpcAssetMetadata, XYKRpcResult}; use sp_api::ProvideRuntimeApi; use sp_blockchain::HeaderBackend; use sp_core::U256; @@ -21,14 +21,29 @@ use std::sync::Arc; #[rpc(client, server)] pub trait ProofOfStakeApi { - #[method(name = "foo")] - fn foo( + #[method(name = "pos_calculate_native_rewards_amount")] + fn calculate_native_rewards_amount( &self, account: AccountId, liquidity_token: TokenId, - reward_token: TokenId, at: Option, - ) -> RpcResult; + ) -> RpcResult; + + #[method(name = "pos_calculate_3rdparty_rewards_amount")] + fn calculate_3rdparty_rewards_amount( + &self, + account: AccountId, + liquidity_token: TokenId, + rewards_token: TokenId, + at: Option, + ) -> RpcResult; + + #[method(name = "pos_calculate_3rdparty_rewards_all")] + fn calculate_3rdparty_rewards_all( + &self, + account: AccountId, + at: Option, + ) -> RpcResult>; } pub struct ProofOfStake { @@ -44,24 +59,77 @@ impl ProofOfStake { #[async_trait] impl - ProofOfStakeApiServer<::Hash, NumberOrHex, TokenId, AccountId> + ProofOfStakeApiServer<::Hash, Balance, TokenId, AccountId> for ProofOfStake where Block: BlockT, C: Send + Sync + 'static, C: ProvideRuntimeApi, C: HeaderBackend, - C::Api: XykRuntimeApi, - Balance: Codec + MaybeDisplay + MaybeFromStr + TryFrom, + C::Api: ProofOfStakeRuntimeApi, + Balance: Codec + MaybeDisplay + MaybeFromStr + Into, TokenId: Codec + MaybeDisplay + MaybeFromStr, AccountId: Codec + MaybeDisplay + MaybeFromStr, { - fn foo( + fn calculate_native_rewards_amount( + &self, + account: AccountId, + liquidity_token: TokenId, + at: Option<::Hash>, + ) -> RpcResult { + let api = self.client.runtime_api(); + let at = self.client.info().best_hash; + + api.calculate_native_rewards_amount(at, account, liquidity_token) + .map(Into::::into) + .map_err(|e| { + JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + 1, + "Unable to serve the request", + Some(format!("{:?}", e)), + ))) + }) + } + + fn calculate_3rdparty_rewards_amount( &self, account: AccountId, liquidity_token: TokenId, reward_token: TokenId, - at: Option, - ) -> RpcResult> { + at: Option<::Hash>, + ) -> RpcResult { + let api = self.client.runtime_api(); + let at = self.client.info().best_hash; + + api.calculate_3rdparty_rewards_amount(at, account, liquidity_token, reward_token) + .map(Into::::into) + .map_err(|e| { + JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + 1, + "Unable to serve the request", + Some(format!("{:?}", e)), + ))) + }) + } + + + fn calculate_3rdparty_rewards_all( + &self, + account: AccountId, + at: Option<::Hash>, + ) -> RpcResult> { + let api = self.client.runtime_api(); + let at = self.client.info().best_hash; + + todo!(); + // api.calculate_3rdparty_rewards_all(at, account) + // .map_err(|e| { + // JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + // 1, + // "Unable to serve the request", + // Some(format!("{:?}", e)), + // ))) + // }) } + } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index c0f7a38ece..5a4e97cd1d 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -702,7 +702,6 @@ impl Pallet { Self::set_liquidity_minting_checkpoint(user.clone(), liquidity_asset_id, amount)?; - println!("activate"); ::ActivationReservesProvider::activate( liquidity_asset_id, &user, @@ -821,7 +820,6 @@ impl Pallet { match use_balance_from { ThirdPartyActivationKind::ActivateKind(use_balance_from) => { - println!("activate"); ::ActivationReservesProvider::activate( liquidity_asset_id, &user, @@ -1108,12 +1106,10 @@ impl Pallet { }, )?; - println!("BURNING : {user} {liquidity_asset_id} {reward_token}"); ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), |v| { v.and_then(|a| { - println!("{a} {liquidity_assets_burned}"); a.checked_sub(liquidity_assets_burned).and_then(|val| { if val > 0 { *v = Some(val); @@ -1143,7 +1139,6 @@ impl Pallet { }, ); - println!("deactivate"); ::ActivationReservesProvider::deactivate( liquidity_asset_id, &user, diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 228989b026..b4ba8c7e85 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -230,7 +230,6 @@ impl RewardsCalculator { .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) .ok_or(RewardsCalcError::CheckpointMathError)?; - println!("STORING {}", self.rewards_context.pool_ratio_current); Ok(RewardInfo { activated_amount, pool_ratio_at_last_checkpoint: self.rewards_context.pool_ratio_current, diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 8d690fa1cf..bcf96473ee 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -774,7 +774,7 @@ impl_runtime_apis! { user: AccountId, liquidity_asset_id: TokenId, ) -> Balance{ - ProofOfStake::calculate_native_rewards_amount(user, liquidity_asset_id) + pallet_proof_of_stake::Pallet::::calculate_native_rewards_amount(user, liquidity_asset_id) .unwrap_or_default() } @@ -783,7 +783,7 @@ impl_runtime_apis! { liquidity_asset_id: TokenId, reward_asset_id: TokenId, ) -> Balance{ - ProofOfStake::calculate_rewards_amount_3rdparty(user, liquidity_asset_id, reward_asset_id) + pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_amount(user, liquidity_asset_id, reward_asset_id) .unwrap_or_default() } @@ -791,7 +791,7 @@ impl_runtime_apis! { user: AccountId, liquidity_asset_id: TokenId, ) -> Vec<(TokenId, TokenId, Balance)>{ - ProofOfStake::calculate_3rdparty_rewards_all(user) + pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_all(user) .unwrap_or_default() } } diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index ab3572101e..164c6fcb78 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -784,12 +784,13 @@ mod benches { impl_runtime_apis! { + impl proof_of_stake_runtime_api::ProofOfStakeApi for Runtime{ fn calculate_native_rewards_amount( user: AccountId, liquidity_asset_id: TokenId, ) -> Balance{ - ProofOfStake::calculate_native_rewards_amount(user, liquidity_asset_id) + pallet_proof_of_stake::Pallet::::calculate_native_rewards_amount(user, liquidity_asset_id) .unwrap_or_default() } @@ -798,7 +799,7 @@ impl_runtime_apis! { liquidity_asset_id: TokenId, reward_asset_id: TokenId, ) -> Balance{ - ProofOfStake::calculate_rewards_amount_3rdparty(user, liquidity_asset_id, reward_asset_id) + pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_amount(user, liquidity_asset_id, reward_asset_id) .unwrap_or_default() } @@ -806,7 +807,7 @@ impl_runtime_apis! { user: AccountId, liquidity_asset_id: TokenId, ) -> Vec<(TokenId, TokenId, Balance)>{ - ProofOfStake::calculate_3rdparty_rewards_all(user) + pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_all(user) .unwrap_or_default() } } From fba56e9f3b565bdb7c2e5acbb13bd9b500afa743 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 29 Sep 2023 08:43:10 +0200 Subject: [PATCH 29/83] remove local patch to parachain staking --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c8c03cba34..aeae1a639f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,8 +55,8 @@ orml-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-l # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/mangata-finance/moonbeam"] # parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/update-staking-benchmarks" } -# parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } -parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } +parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } +# parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } [patch."https://github.com/mangata-finance/crowdloan-rewards"] pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "mangata-dev" } From 139b1f199d47315d1bf08108197f3a95080ac001 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sun, 1 Oct 2023 10:01:56 +0000 Subject: [PATCH 30/83] fix formatting --- Cargo.lock | 1 + pallets/proof-of-stake/rpc/src/lib.rs | 34 +++++++++++++-------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2664e59056..7f3ac00573 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7475,6 +7475,7 @@ dependencies = [ [[package]] name = "parachain-staking" version = "3.0.0" +source = "git+https://github.com/mangata-finance//moonbeam?branch=mangata-dev#2ac7a339be795ee58603e3cb68e65fedc1b1c295" dependencies = [ "aquamarine", "frame-benchmarking", diff --git a/pallets/proof-of-stake/rpc/src/lib.rs b/pallets/proof-of-stake/rpc/src/lib.rs index 58d15682cd..2e3798352a 100644 --- a/pallets/proof-of-stake/rpc/src/lib.rs +++ b/pallets/proof-of-stake/rpc/src/lib.rs @@ -81,14 +81,14 @@ where let at = self.client.info().best_hash; api.calculate_native_rewards_amount(at, account, liquidity_token) - .map(Into::::into) - .map_err(|e| { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - 1, - "Unable to serve the request", - Some(format!("{:?}", e)), - ))) - }) + .map(Into::::into) + .map_err(|e| { + JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + 1, + "Unable to serve the request", + Some(format!("{:?}", e)), + ))) + }) } fn calculate_3rdparty_rewards_amount( @@ -102,17 +102,16 @@ where let at = self.client.info().best_hash; api.calculate_3rdparty_rewards_amount(at, account, liquidity_token, reward_token) - .map(Into::::into) - .map_err(|e| { - JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - 1, - "Unable to serve the request", - Some(format!("{:?}", e)), - ))) - }) + .map(Into::::into) + .map_err(|e| { + JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + 1, + "Unable to serve the request", + Some(format!("{:?}", e)), + ))) + }) } - fn calculate_3rdparty_rewards_all( &self, account: AccountId, @@ -131,5 +130,4 @@ where // ))) // }) } - } From 15126f93f8c2b2bf0e7f5b6aed7d574940570f1d Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sun, 1 Oct 2023 10:51:34 +0000 Subject: [PATCH 31/83] fix ut --- pallets/bootstrap/src/mock.rs | 3 +++ pallets/xyk/src/mock.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pallets/bootstrap/src/mock.rs b/pallets/bootstrap/src/mock.rs index 41e286b08a..d748fdeedf 100644 --- a/pallets/bootstrap/src/mock.rs +++ b/pallets/bootstrap/src/mock.rs @@ -165,6 +165,9 @@ impl pallet_proof_of_stake::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10000>; type WeightInfo = (); + type RewardsSchedulesLimit = ConstU32<10>; + type Min3rdPartyRewards = ConstU128<10>; + type ValuationApi = Xyk; } impl BootstrapBenchmarkingConfig for Test {} diff --git a/pallets/xyk/src/mock.rs b/pallets/xyk/src/mock.rs index cefb152129..84be772aed 100644 --- a/pallets/xyk/src/mock.rs +++ b/pallets/xyk/src/mock.rs @@ -329,6 +329,9 @@ impl pallet_proof_of_stake::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type WeightInfo = (); + type RewardsSchedulesLimit = ConstU32<10>; + type Min3rdPartyRewards = ConstU128<10>; + type ValuationApi = XykStorage; } #[cfg(feature = "runtime-benchmarks")] @@ -340,6 +343,9 @@ impl pallet_proof_of_stake::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<1200>; type WeightInfo = (); + type RewardsSchedulesLimit = ConstU32<10>; + type Min3rdPartyRewards = ConstU128<10>; + type ValuationApi = XykStorage; } pub struct TokensActivationPassthrough(PhantomData); From 35b1ebe006757e20a1a8de18d7e1722d7bce2247 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 2 Oct 2023 06:19:16 +0000 Subject: [PATCH 32/83] run PoS runtime benchmarks tests separately --- .github/workflows/reusable-build-and-test.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-build-and-test.yml b/.github/workflows/reusable-build-and-test.yml index 3242073998..a06b8e3f16 100644 --- a/.github/workflows/reusable-build-and-test.yml +++ b/.github/workflows/reusable-build-and-test.yml @@ -225,9 +225,12 @@ jobs: /usr/local/cargo/registry key: cargo-benchmark-cache-${{ inputs.cache_version }}-${{ hashFiles('Cargo.lock') }} - name: Run benchmarks tests - run: cargo test --release -j8 --features=runtime-benchmarks -p pallet-xyk -p pallet-issuance -p pallet-multipurpose-liquidity -p pallet-fee-lock -p pallet-proof-of-stake -p pallet-proof-of-stake + run: cargo test --release -j8 --features=runtime-benchmarks -p pallet-xyk -p pallet-issuance -p pallet-multipurpose-liquidity -p pallet-fee-lock - name: Run benchmarks tests run: cargo test --release -j8 --features=runtime-benchmarks -p pallet-bootstrap + # NOTE: MGX-742 + - name: Run benchmarks tests + run: cargo test --release -j8 --features=runtime-benchmarks -p pallet-proof-of-stake build-and-run-try-runtime: name: Run try-runtime checks From c0fafcdcd1b490a5f30eb891517888644f2e73f2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 2 Oct 2023 07:37:58 +0000 Subject: [PATCH 33/83] fix runtime benchmarks --- pallets/proof-of-stake/src/benchmarking.rs | 89 +++++++++++----------- pallets/proof-of-stake/src/lib.rs | 3 + pallets/proof-of-stake/src/mock.rs | 2 +- 3 files changed, 49 insertions(+), 45 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 96a9615c92..986cff9cf3 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -220,31 +220,34 @@ benchmarks! { } } - let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); + let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit + 1); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); for _ in 0 .. schedules_limit - 1 { - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token = token_id + 1; + let balance:u128 = TokensOf::::free_balance(reward_token.into(), &caller).into(); + assert_eq!(balance, REWARDS_AMOUNT); PoS::::reward_pool( RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, token_id), reward_token.into(), - MILION, + REWARDS_AMOUNT, 10u32.into(), ).unwrap(); } - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token = token_id + 1; PoS::::reward_pool( RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, token_id), reward_token.into(), - MILION, + REWARDS_AMOUNT, 2u32.into(), ).unwrap(); @@ -252,8 +255,8 @@ benchmarks! { forward_to_next_session::(); forward_to_next_session::(); - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), token_id.into(), MILION.into()).unwrap(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token = token_id + 1; assert_eq!( @@ -261,7 +264,7 @@ benchmarks! { schedules_limit ); - }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,token_id), reward_token.into(), MILION, 10u32.into()) + }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,token_id), reward_token.into(), REWARDS_AMOUNT, 10u32.into()) verify { assert_eq!( @@ -281,32 +284,32 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); loop { - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); if token_id > native_asset_id { break; } } - let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); - let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let first_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), first_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let liquidity_asset_id = first_token_id + 1; - let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let second_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), second_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token_id = second_token_id + 1; - let rewards_amount = 20_000u128; PoS::::reward_pool( RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, first_token_id), reward_token_id.into(), - rewards_amount, + REWARDS_AMOUNT, 2u32.into(), ).unwrap(); @@ -315,7 +318,7 @@ benchmarks! { forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller, liquidity_asset_id, reward_token_id).unwrap(), - rewards_amount/2 + REWARDS_AMOUNT/2 ) } @@ -330,39 +333,38 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); loop { - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); if token_id > native_asset_id { break; } } - let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); - let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let first_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), first_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let liquidity_asset_id = first_token_id + 1; - let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let second_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), second_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token_id = second_token_id + 1; - let rewards_amount = 20_000u128; - PoS::::reward_pool( RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, first_token_id), reward_token_id.into(), - rewards_amount, + REWARDS_AMOUNT, 2u32.into(), ).unwrap(); assert!(TokensOf::::ensure_can_withdraw( liquidity_asset_id.into(), &caller, - MILION.into(), + REWARDS_AMOUNT.into(), WithdrawReasons::all(), Default::default(), ).is_ok()); @@ -379,7 +381,7 @@ benchmarks! { TokensOf::::ensure_can_withdraw( liquidity_asset_id.into(), &caller, - MILION.into(), + REWARDS_AMOUNT.into(), WithdrawReasons::all(), Default::default(), ).is_err() @@ -392,7 +394,7 @@ benchmarks! { assert!(TokensOf::::ensure_can_withdraw( liquidity_asset_id.into(), &caller, - MILION.into(), + REWARDS_AMOUNT.into(), WithdrawReasons::all(), Default::default(), ).is_ok()); @@ -411,32 +413,31 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); loop { - let token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); + let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); if token_id > native_asset_id { break; } } - let native_asset_amount: u128 = MILION * Into::::into(schedules_limit); + let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); - let first_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), first_token_id.into(), MILION.into()).unwrap(); + let first_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), first_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let liquidity_asset_id = first_token_id + 1; - let second_token_id = TokensOf::::create(&caller, MILION.into()).unwrap().into(); - XykOf::::create_pool(caller.clone(), native_asset_id.into(), MILION.into(), second_token_id.into(), MILION.into()).unwrap(); + let second_token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); + XykOf::::create_pool(caller.clone(), native_asset_id.into(), REWARDS_AMOUNT.into(), second_token_id.into(), REWARDS_AMOUNT.into()).unwrap(); let reward_token_id = second_token_id + 1; - let rewards_amount = 20_000u128; - PoS::::reward_pool( RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, first_token_id), reward_token_id.into(), - rewards_amount, + REWARDS_AMOUNT, 2u32.into(), ).unwrap(); @@ -451,17 +452,17 @@ benchmarks! { forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), - 10_000u128 + REWARDS_AMOUNT / 2 ); forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), - 20_000u128 + REWARDS_AMOUNT ); forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), - 20_000u128 + REWARDS_AMOUNT ); let balance_before:u128 = TokensOf::::free_balance(reward_token_id.into(), &caller).into(); @@ -475,7 +476,7 @@ benchmarks! { 0u128 ); - assert_eq!(balance_after - balance_before, 20_000u128); + assert_eq!(balance_after - balance_before, REWARDS_AMOUNT); } impl_benchmark_test_suite!(PoS, crate::mock::new_test_ext(), crate::mock::Test) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 5a4e97cd1d..aeae157e53 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -509,6 +509,9 @@ pub mod pallet { Error::::RewardTokenNotPairdWithNativeToken ); + let valutation = + ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount); + ensure!( ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount) >= T::Min3rdPartyRewards::get() || diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index cd50e1cce0..e87d04afd3 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -299,7 +299,7 @@ impl pos::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<10>; + type Min3rdPartyRewards = ConstU128<100_000>; type WeightInfo = (); type ValuationApi = Xyk; } From 80b9c92869ea4f2577f1945970b68ab2d05b39c5 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 2 Oct 2023 22:47:08 +0200 Subject: [PATCH 34/83] apply benchmarks from ref machine --- .../src/weights/block_weights.rs | 21 +- .../src/weights/extrinsic_weights.rs | 21 +- .../src/weights/frame_system.rs | 58 ++-- .../src/weights/orml_asset_registry.rs | 10 +- .../mangata-kusama/src/weights/orml_tokens.rs | 30 +- .../src/weights/pallet_bootstrap.rs | 18 +- .../src/weights/pallet_collective_mangata.rs | 242 ++++++------- .../src/weights/pallet_crowdloan_rewards.rs | 216 ++++++------ .../src/weights/pallet_fee_lock.rs | 10 +- .../src/weights/pallet_issuance.rs | 22 +- .../weights/pallet_multipurpose_liquidity.rs | 10 +- .../src/weights/pallet_proof_of_stake.rs | 231 +++++++++---- .../src/weights/pallet_session.rs | 10 +- .../src/weights/pallet_timestamp.rs | 10 +- .../src/weights/pallet_treasury.rs | 42 +-- .../src/weights/pallet_utility_mangata.rs | 46 +-- .../src/weights/pallet_vesting_mangata.rs | 86 ++--- .../mangata-kusama/src/weights/pallet_xyk.rs | 170 +++++----- .../src/weights/parachain_staking.rs | 318 +++++++++--------- .../src/weights/block_weights.rs | 21 +- .../src/weights/extrinsic_weights.rs | 21 +- .../src/weights/frame_system.rs | 58 ++-- .../src/weights/orml_asset_registry.rs | 10 +- .../mangata-rococo/src/weights/orml_tokens.rs | 30 +- .../src/weights/pallet_bootstrap.rs | 18 +- .../src/weights/pallet_collective_mangata.rs | 242 ++++++------- .../src/weights/pallet_crowdloan_rewards.rs | 216 ++++++------ .../src/weights/pallet_fee_lock.rs | 10 +- .../src/weights/pallet_issuance.rs | 22 +- .../weights/pallet_multipurpose_liquidity.rs | 10 +- .../src/weights/pallet_proof_of_stake.rs | 231 +++++++++---- .../src/weights/pallet_session.rs | 10 +- .../src/weights/pallet_timestamp.rs | 10 +- .../src/weights/pallet_treasury.rs | 42 +-- .../src/weights/pallet_utility_mangata.rs | 46 +-- .../src/weights/pallet_vesting_mangata.rs | 86 ++--- .../mangata-rococo/src/weights/pallet_xyk.rs | 170 +++++----- .../src/weights/parachain_staking.rs | 318 +++++++++--------- 38 files changed, 1726 insertions(+), 1416 deletions(-) diff --git a/runtime/mangata-kusama/src/weights/block_weights.rs b/runtime/mangata-kusama/src/weights/block_weights.rs index 1e38e0097a..e190a4a858 100644 --- a/runtime/mangata-kusama/src/weights/block_weights.rs +++ b/runtime/mangata-kusama/src/weights/block_weights.rs @@ -1,6 +1,7 @@ + //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18 (Y/M/D) -//! HOSTNAME: `995c44fb4e67`, CPU: `AMD EPYC 7B13` +//! DATE: 2023-10-02 (Y/M/D) +//! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Mangata Kusama Local` //! WARMUPS: `10`, REPEAT: `100` @@ -29,17 +30,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 7_631_910, 8_052_540 - /// Average: 7_692_887 - /// Median: 7_661_290 - /// Std-Dev: 104885.3 + /// Min, Max: 7_983_500, 8_609_050 + /// Average: 8_057_882 + /// Median: 8_023_430 + /// Std-Dev: 118109.32 /// /// Percentiles nanoseconds: - /// 99th: 8_034_380 - /// 95th: 8_023_380 - /// 75th: 7_674_100 + /// 99th: 8_567_140 + /// 95th: 8_382_280 + /// 75th: 8_036_000 pub const BlockExecutionWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(7_692_887), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(8_057_882), 0); } #[cfg(test)] diff --git a/runtime/mangata-kusama/src/weights/extrinsic_weights.rs b/runtime/mangata-kusama/src/weights/extrinsic_weights.rs index 92fca50754..033bf75d8f 100644 --- a/runtime/mangata-kusama/src/weights/extrinsic_weights.rs +++ b/runtime/mangata-kusama/src/weights/extrinsic_weights.rs @@ -1,6 +1,7 @@ + //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18 (Y/M/D) -//! HOSTNAME: `995c44fb4e67`, CPU: `AMD EPYC 7B13` +//! DATE: 2023-10-02 (Y/M/D) +//! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Mangata Kusama Local` //! WARMUPS: `10`, REPEAT: `100` @@ -29,17 +30,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 114_329, 115_887 - /// Average: 114_756 - /// Median: 114_639 - /// Std-Dev: 309.81 + /// Min, Max: 116_665, 118_803 + /// Average: 117_078 + /// Median: 117_010 + /// Std-Dev: 306.32 /// /// Percentiles nanoseconds: - /// 99th: 115_799 - /// 95th: 115_437 - /// 75th: 114_859 + /// 99th: 118_109 + /// 95th: 117_513 + /// 75th: 117_236 pub const ExtrinsicBaseWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(114_756), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(117_078), 0); } #[cfg(test)] diff --git a/runtime/mangata-kusama/src/weights/frame_system.rs b/runtime/mangata-kusama/src/weights/frame_system.rs index e2b9f77ec8..9bcfdbb3d8 100644 --- a/runtime/mangata-kusama/src/weights/frame_system.rs +++ b/runtime/mangata-kusama/src/weights/frame_system.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,46 +68,46 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl frame_system::WeightInfo for ModuleWeight { fn remark(b: u32, ) -> Weight { - (Weight::from_parts(10_114_579, 0)) + (Weight::from_parts(9_964_525, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(518, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(589, 0)).saturating_mul(b as u64)) } fn remark_with_event(b: u32, ) -> Weight { - (Weight::from_parts(30_615_946, 0)) + (Weight::from_parts(29_205_376, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(1_708, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(1_778, 0)).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) // Storage: unknown `0x3a686561707061676573` (r:0 w:1) // Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - (Weight::from_parts(7_640_000, 0)) + (Weight::from_parts(7_610_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn set_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_030_000, 0)) - // Standard Error: 2_557 - .saturating_add((Weight::from_parts(1_227_455, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_160_000, 0)) + // Standard Error: 2_435 + .saturating_add((Weight::from_parts(1_226_647, 0)).saturating_mul(i as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_170_000, 0)) - // Standard Error: 1_127 - .saturating_add((Weight::from_parts(837_671, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_090_000, 0)) + // Standard Error: 1_110 + .saturating_add((Weight::from_parts(840_132, 0)).saturating_mul(i as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_prefix(p: u32, ) -> Weight { - (Weight::from_parts(7_530_000, 0)) - // Standard Error: 1_363 - .saturating_add((Weight::from_parts(1_454_847, 0)).saturating_mul(p as u64)) + (Weight::from_parts(7_640_000, 0)) + // Standard Error: 1_374 + .saturating_add((Weight::from_parts(1_459_706, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } @@ -116,46 +116,46 @@ impl frame_system::WeightInfo for ModuleWeight { // For backwards compatibility and tests impl WeightInfo for () { fn remark(b: u32, ) -> Weight { - (Weight::from_parts(10_114_579, 0)) + (Weight::from_parts(9_964_525, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(518, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(589, 0)).saturating_mul(b as u64)) } fn remark_with_event(b: u32, ) -> Weight { - (Weight::from_parts(30_615_946, 0)) + (Weight::from_parts(29_205_376, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(1_708, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(1_778, 0)).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) // Storage: unknown `0x3a686561707061676573` (r:0 w:1) // Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - (Weight::from_parts(7_640_000, 0)) + (Weight::from_parts(7_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn set_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_030_000, 0)) - // Standard Error: 2_557 - .saturating_add((Weight::from_parts(1_227_455, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_160_000, 0)) + // Standard Error: 2_435 + .saturating_add((Weight::from_parts(1_226_647, 0)).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_170_000, 0)) - // Standard Error: 1_127 - .saturating_add((Weight::from_parts(837_671, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_090_000, 0)) + // Standard Error: 1_110 + .saturating_add((Weight::from_parts(840_132, 0)).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_prefix(p: u32, ) -> Weight { - (Weight::from_parts(7_530_000, 0)) - // Standard Error: 1_363 - .saturating_add((Weight::from_parts(1_454_847, 0)).saturating_mul(p as u64)) + (Weight::from_parts(7_640_000, 0)) + // Standard Error: 1_374 + .saturating_add((Weight::from_parts(1_459_706, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } diff --git a/runtime/mangata-kusama/src/weights/orml_asset_registry.rs b/runtime/mangata-kusama/src/weights/orml_asset_registry.rs index 341ffe99df..8242233fca 100644 --- a/runtime/mangata-kusama/src/weights/orml_asset_registry.rs +++ b/runtime/mangata-kusama/src/weights/orml_asset_registry.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for orml_asset_registry //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -72,7 +72,7 @@ impl orml_asset_registry::WeightInfo for ModuleWeight Weight { - (Weight::from_parts(48_380_000, 0)) + (Weight::from_parts(48_560_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -81,7 +81,7 @@ impl orml_asset_registry::WeightInfo for ModuleWeight Weight { - (Weight::from_parts(33_520_000, 0)) + (Weight::from_parts(33_480_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -98,7 +98,7 @@ impl WeightInfo for () { // Storage: AssetRegistry LocationToAssetId (r:1 w:1) // Proof Skipped: AssetRegistry LocationToAssetId (max_values: None, max_size: None, mode: Measured) fn register_asset() -> Weight { - (Weight::from_parts(48_380_000, 0)) + (Weight::from_parts(48_560_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -107,7 +107,7 @@ impl WeightInfo for () { // Storage: AssetRegistry LocationToAssetId (r:1 w:1) // Proof Skipped: AssetRegistry LocationToAssetId (max_values: None, max_size: None, mode: Measured) fn update_asset() -> Weight { - (Weight::from_parts(33_520_000, 0)) + (Weight::from_parts(33_480_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/orml_tokens.rs b/runtime/mangata-kusama/src/weights/orml_tokens.rs index 06359ec572..5508f3d7cb 100644 --- a/runtime/mangata-kusama/src/weights/orml_tokens.rs +++ b/runtime/mangata-kusama/src/weights/orml_tokens.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for orml_tokens //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -73,7 +73,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer() -> Weight { - (Weight::from_parts(53_910_000, 0)) + (Weight::from_parts(54_300_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -82,7 +82,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_all() -> Weight { - (Weight::from_parts(56_060_000, 0)) + (Weight::from_parts(56_740_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -91,7 +91,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_keep_alive() -> Weight { - (Weight::from_parts(51_300_000, 0)) + (Weight::from_parts(52_380_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -100,7 +100,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn force_transfer() -> Weight { - (Weight::from_parts(57_360_000, 0)) + (Weight::from_parts(58_360_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -109,7 +109,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn set_balance() -> Weight { - (Weight::from_parts(31_560_000, 0)) + (Weight::from_parts(32_250_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -122,7 +122,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn create() -> Weight { - (Weight::from_parts(58_330_000, 0)) + (Weight::from_parts(58_930_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -135,7 +135,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn mint() -> Weight { - (Weight::from_parts(58_720_000, 0)) + (Weight::from_parts(59_170_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -148,7 +148,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer() -> Weight { - (Weight::from_parts(53_910_000, 0)) + (Weight::from_parts(54_300_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -157,7 +157,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_all() -> Weight { - (Weight::from_parts(56_060_000, 0)) + (Weight::from_parts(56_740_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -166,7 +166,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_keep_alive() -> Weight { - (Weight::from_parts(51_300_000, 0)) + (Weight::from_parts(52_380_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -175,7 +175,7 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn force_transfer() -> Weight { - (Weight::from_parts(57_360_000, 0)) + (Weight::from_parts(58_360_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -184,7 +184,7 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn set_balance() -> Weight { - (Weight::from_parts(31_560_000, 0)) + (Weight::from_parts(32_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -197,7 +197,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn create() -> Weight { - (Weight::from_parts(58_330_000, 0)) + (Weight::from_parts(58_930_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -210,7 +210,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn mint() -> Weight { - (Weight::from_parts(58_720_000, 0)) + (Weight::from_parts(59_170_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_bootstrap.rs b/runtime/mangata-kusama/src/weights/pallet_bootstrap.rs index b07baf19f9..7ebdf94b14 100644 --- a/runtime/mangata-kusama/src/weights/pallet_bootstrap.rs +++ b/runtime/mangata-kusama/src/weights/pallet_bootstrap.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_bootstrap //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -78,7 +78,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn schedule_bootstrap() -> Weight { - (Weight::from_parts(34_440_000, 0)) + (Weight::from_parts(34_000_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -103,7 +103,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn provision() -> Weight { - (Weight::from_parts(103_400_000, 0)) + (Weight::from_parts(106_729_000, 0)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -136,7 +136,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn claim_and_activate_liquidity_tokens() -> Weight { - (Weight::from_parts(216_740_000, 0)) + (Weight::from_parts(226_960_000, 0)) .saturating_add(T::DbWeight::get().reads(17 as u64)) .saturating_add(T::DbWeight::get().writes(8 as u64)) } @@ -167,7 +167,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn finalize() -> Weight { - (Weight::from_parts(79_290_000, 0)) + (Weight::from_parts(79_150_000, 0)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(7 as u64)) } @@ -188,7 +188,7 @@ impl WeightInfo for () { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn schedule_bootstrap() -> Weight { - (Weight::from_parts(34_440_000, 0)) + (Weight::from_parts(34_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -213,7 +213,7 @@ impl WeightInfo for () { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn provision() -> Weight { - (Weight::from_parts(103_400_000, 0)) + (Weight::from_parts(106_729_000, 0)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -246,7 +246,7 @@ impl WeightInfo for () { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn claim_and_activate_liquidity_tokens() -> Weight { - (Weight::from_parts(216_740_000, 0)) + (Weight::from_parts(226_960_000, 0)) .saturating_add(RocksDbWeight::get().reads(17 as u64)) .saturating_add(RocksDbWeight::get().writes(8 as u64)) } @@ -277,7 +277,7 @@ impl WeightInfo for () { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn finalize() -> Weight { - (Weight::from_parts(79_290_000, 0)) + (Weight::from_parts(79_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(7 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_collective_mangata.rs b/runtime/mangata-kusama/src/weights/pallet_collective_mangata.rs index ff2788893c..ded612958c 100644 --- a/runtime/mangata-kusama/src/weights/pallet_collective_mangata.rs +++ b/runtime/mangata-kusama/src/weights/pallet_collective_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_collective_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -80,11 +80,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Prime (r:0 w:1) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_140_000, 0)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(5_481_522, 0)).saturating_mul(m as u64)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(10_538_444, 0)).saturating_mul(p as u64)) + (Weight::from_parts(90_800_000, 0)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(5_566_250, 0)).saturating_mul(m as u64)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(10_729_781, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -93,11 +93,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Members (r:1 w:0) // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(29_943_956, 0)) - // Standard Error: 73 - .saturating_add((Weight::from_parts(2_027, 0)).saturating_mul(b as u64)) - // Standard Error: 761 - .saturating_add((Weight::from_parts(27_217, 0)).saturating_mul(m as u64)) + (Weight::from_parts(31_313_537, 0)) + // Standard Error: 94 + .saturating_add((Weight::from_parts(1_862, 0)).saturating_mul(b as u64)) + // Standard Error: 972 + .saturating_add((Weight::from_parts(25_991, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Council Members (r:1 w:0) @@ -105,11 +105,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:1 w:0) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn propose_execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(33_627_672, 0)) - // Standard Error: 82 - .saturating_add((Weight::from_parts(2_315, 0)).saturating_mul(b as u64)) - // Standard Error: 855 - .saturating_add((Weight::from_parts(45_555, 0)).saturating_mul(m as u64)) + (Weight::from_parts(34_536_810, 0)) + // Standard Error: 85 + .saturating_add((Weight::from_parts(2_168, 0)).saturating_mul(b as u64)) + // Standard Error: 883 + .saturating_add((Weight::from_parts(45_007, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) } // Storage: Council Members (r:1 w:0) @@ -125,13 +125,13 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Voting (r:0 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(48_107_905, 0)) - // Standard Error: 148 - .saturating_add((Weight::from_parts(4_689, 0)).saturating_mul(b as u64)) - // Standard Error: 1_547 - .saturating_add((Weight::from_parts(33_696, 0)).saturating_mul(m as u64)) - // Standard Error: 1_527 - .saturating_add((Weight::from_parts(306_730, 0)).saturating_mul(p as u64)) + (Weight::from_parts(49_784_354, 0)) + // Standard Error: 163 + .saturating_add((Weight::from_parts(4_191, 0)).saturating_mul(b as u64)) + // Standard Error: 1_705 + .saturating_add((Weight::from_parts(35_364, 0)).saturating_mul(m as u64)) + // Standard Error: 1_683 + .saturating_add((Weight::from_parts(301_218, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -140,58 +140,58 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn vote(m: u32, ) -> Weight { - (Weight::from_parts(45_661_933, 0)) - // Standard Error: 1_152 - .saturating_add((Weight::from_parts(70_484, 0)).saturating_mul(m as u64)) + (Weight::from_parts(45_999_012, 0)) + // Standard Error: 944 + .saturating_add((Weight::from_parts(70_544, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(65_240_157, 0)) - // Standard Error: 1_748 - .saturating_add((Weight::from_parts(56_035, 0)).saturating_mul(m as u64)) - // Standard Error: 1_704 - .saturating_add((Weight::from_parts(287_256, 0)).saturating_mul(p as u64)) + (Weight::from_parts(67_599_850, 0)) + // Standard Error: 1_737 + .saturating_add((Weight::from_parts(80_078, 0)).saturating_mul(m as u64)) + // Standard Error: 1_694 + .saturating_add((Weight::from_parts(294_524, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_748_886, 0)) - // Standard Error: 304 - .saturating_add((Weight::from_parts(2_436, 0)).saturating_mul(b as u64)) - // Standard Error: 3_220 - .saturating_add((Weight::from_parts(73_314, 0)).saturating_mul(m as u64)) - // Standard Error: 3_139 - .saturating_add((Weight::from_parts(313_478, 0)).saturating_mul(p as u64)) + (Weight::from_parts(94_619_427, 0)) + // Standard Error: 307 + .saturating_add((Weight::from_parts(2_144, 0)).saturating_mul(b as u64)) + // Standard Error: 3_251 + .saturating_add((Weight::from_parts(94_352, 0)).saturating_mul(m as u64)) + // Standard Error: 3_169 + .saturating_add((Weight::from_parts(315_046, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) @@ -199,20 +199,20 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(69_217_092, 0)) - // Standard Error: 1_867 - .saturating_add((Weight::from_parts(66_672, 0)).saturating_mul(m as u64)) - // Standard Error: 1_821 - .saturating_add((Weight::from_parts(286_625, 0)).saturating_mul(p as u64)) + (Weight::from_parts(71_391_246, 0)) + // Standard Error: 1_912 + .saturating_add((Weight::from_parts(92_748, 0)).saturating_mul(m as u64)) + // Standard Error: 1_865 + .saturating_add((Weight::from_parts(298_046, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) @@ -220,13 +220,13 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(95_973_593, 0)) - // Standard Error: 310 - .saturating_add((Weight::from_parts(2_185, 0)).saturating_mul(b as u64)) - // Standard Error: 3_288 - .saturating_add((Weight::from_parts(68_870, 0)).saturating_mul(m as u64)) - // Standard Error: 3_205 - .saturating_add((Weight::from_parts(311_244, 0)).saturating_mul(p as u64)) + (Weight::from_parts(98_330_423, 0)) + // Standard Error: 297 + .saturating_add((Weight::from_parts(3_678, 0)).saturating_mul(b as u64)) + // Standard Error: 3_149 + .saturating_add((Weight::from_parts(97_124, 0)).saturating_mul(m as u64)) + // Standard Error: 3_070 + .saturating_add((Weight::from_parts(313_849, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -239,9 +239,9 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn disapprove_proposal(p: u32, ) -> Weight { - (Weight::from_parts(36_150_886, 0)) - // Standard Error: 1_532 - .saturating_add((Weight::from_parts(281_687, 0)).saturating_mul(p as u64)) + (Weight::from_parts(36_844_726, 0)) + // Standard Error: 1_413 + .saturating_add((Weight::from_parts(281_628, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -258,11 +258,11 @@ impl WeightInfo for () { // Storage: Council Prime (r:0 w:1) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_140_000, 0)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(5_481_522, 0)).saturating_mul(m as u64)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(10_538_444, 0)).saturating_mul(p as u64)) + (Weight::from_parts(90_800_000, 0)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(5_566_250, 0)).saturating_mul(m as u64)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(10_729_781, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) @@ -271,11 +271,11 @@ impl WeightInfo for () { // Storage: Council Members (r:1 w:0) // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(29_943_956, 0)) - // Standard Error: 73 - .saturating_add((Weight::from_parts(2_027, 0)).saturating_mul(b as u64)) - // Standard Error: 761 - .saturating_add((Weight::from_parts(27_217, 0)).saturating_mul(m as u64)) + (Weight::from_parts(31_313_537, 0)) + // Standard Error: 94 + .saturating_add((Weight::from_parts(1_862, 0)).saturating_mul(b as u64)) + // Standard Error: 972 + .saturating_add((Weight::from_parts(25_991, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) } // Storage: Council Members (r:1 w:0) @@ -283,11 +283,11 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:1 w:0) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn propose_execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(33_627_672, 0)) - // Standard Error: 82 - .saturating_add((Weight::from_parts(2_315, 0)).saturating_mul(b as u64)) - // Standard Error: 855 - .saturating_add((Weight::from_parts(45_555, 0)).saturating_mul(m as u64)) + (Weight::from_parts(34_536_810, 0)) + // Standard Error: 85 + .saturating_add((Weight::from_parts(2_168, 0)).saturating_mul(b as u64)) + // Standard Error: 883 + .saturating_add((Weight::from_parts(45_007, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) } // Storage: Council Members (r:1 w:0) @@ -303,13 +303,13 @@ impl WeightInfo for () { // Storage: Council Voting (r:0 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(48_107_905, 0)) - // Standard Error: 148 - .saturating_add((Weight::from_parts(4_689, 0)).saturating_mul(b as u64)) - // Standard Error: 1_547 - .saturating_add((Weight::from_parts(33_696, 0)).saturating_mul(m as u64)) - // Standard Error: 1_527 - .saturating_add((Weight::from_parts(306_730, 0)).saturating_mul(p as u64)) + (Weight::from_parts(49_784_354, 0)) + // Standard Error: 163 + .saturating_add((Weight::from_parts(4_191, 0)).saturating_mul(b as u64)) + // Standard Error: 1_705 + .saturating_add((Weight::from_parts(35_364, 0)).saturating_mul(m as u64)) + // Standard Error: 1_683 + .saturating_add((Weight::from_parts(301_218, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -318,58 +318,58 @@ impl WeightInfo for () { // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn vote(m: u32, ) -> Weight { - (Weight::from_parts(45_661_933, 0)) - // Standard Error: 1_152 - .saturating_add((Weight::from_parts(70_484, 0)).saturating_mul(m as u64)) + (Weight::from_parts(45_999_012, 0)) + // Standard Error: 944 + .saturating_add((Weight::from_parts(70_544, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(65_240_157, 0)) - // Standard Error: 1_748 - .saturating_add((Weight::from_parts(56_035, 0)).saturating_mul(m as u64)) - // Standard Error: 1_704 - .saturating_add((Weight::from_parts(287_256, 0)).saturating_mul(p as u64)) + (Weight::from_parts(67_599_850, 0)) + // Standard Error: 1_737 + .saturating_add((Weight::from_parts(80_078, 0)).saturating_mul(m as u64)) + // Standard Error: 1_694 + .saturating_add((Weight::from_parts(294_524, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_748_886, 0)) - // Standard Error: 304 - .saturating_add((Weight::from_parts(2_436, 0)).saturating_mul(b as u64)) - // Standard Error: 3_220 - .saturating_add((Weight::from_parts(73_314, 0)).saturating_mul(m as u64)) - // Standard Error: 3_139 - .saturating_add((Weight::from_parts(313_478, 0)).saturating_mul(p as u64)) + (Weight::from_parts(94_619_427, 0)) + // Standard Error: 307 + .saturating_add((Weight::from_parts(2_144, 0)).saturating_mul(b as u64)) + // Standard Error: 3_251 + .saturating_add((Weight::from_parts(94_352, 0)).saturating_mul(m as u64)) + // Standard Error: 3_169 + .saturating_add((Weight::from_parts(315_046, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) @@ -377,20 +377,20 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(69_217_092, 0)) - // Standard Error: 1_867 - .saturating_add((Weight::from_parts(66_672, 0)).saturating_mul(m as u64)) - // Standard Error: 1_821 - .saturating_add((Weight::from_parts(286_625, 0)).saturating_mul(p as u64)) + (Weight::from_parts(71_391_246, 0)) + // Standard Error: 1_912 + .saturating_add((Weight::from_parts(92_748, 0)).saturating_mul(m as u64)) + // Standard Error: 1_865 + .saturating_add((Weight::from_parts(298_046, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) @@ -398,13 +398,13 @@ impl WeightInfo for () { // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(95_973_593, 0)) - // Standard Error: 310 - .saturating_add((Weight::from_parts(2_185, 0)).saturating_mul(b as u64)) - // Standard Error: 3_288 - .saturating_add((Weight::from_parts(68_870, 0)).saturating_mul(m as u64)) - // Standard Error: 3_205 - .saturating_add((Weight::from_parts(311_244, 0)).saturating_mul(p as u64)) + (Weight::from_parts(98_330_423, 0)) + // Standard Error: 297 + .saturating_add((Weight::from_parts(3_678, 0)).saturating_mul(b as u64)) + // Standard Error: 3_149 + .saturating_add((Weight::from_parts(97_124, 0)).saturating_mul(m as u64)) + // Standard Error: 3_070 + .saturating_add((Weight::from_parts(313_849, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -417,9 +417,9 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn disapprove_proposal(p: u32, ) -> Weight { - (Weight::from_parts(36_150_886, 0)) - // Standard Error: 1_532 - .saturating_add((Weight::from_parts(281_687, 0)).saturating_mul(p as u64)) + (Weight::from_parts(36_844_726, 0)) + // Standard Error: 1_413 + .saturating_add((Weight::from_parts(281_628, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_crowdloan_rewards.rs b/runtime/mangata-kusama/src/weights/pallet_crowdloan_rewards.rs index dbdf56c152..a0016cb225 100644 --- a/runtime/mangata-kusama/src/weights/pallet_crowdloan_rewards.rs +++ b/runtime/mangata-kusama/src/weights/pallet_crowdloan_rewards.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_crowdloan_rewards //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,220 +68,234 @@ pub trait WeightInfo { /// Weights for pallet_crowdloan_rewards using the Mangata node and recommended hardware. pub struct ModuleWeight(PhantomData); impl pallet_crowdloan_rewards::WeightInfo for ModuleWeight { + // Storage: Crowdloan Initialized (r:1 w:0) + // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:0 w:1) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) fn set_crowdloan_allocation() -> Weight { - (Weight::from_parts(5_800_000, 0)) + (Weight::from_parts(13_860_000, 0)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:1) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:1) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:100 w:100) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:100 w:0) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:100 w:100) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: System Account (r:100 w:100) - // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:100 w:100) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn initialize_reward_vec(x: u32, ) -> Weight { - (Weight::from_parts(170_661_769, 0)) - // Standard Error: 50_081 - .saturating_add((Weight::from_parts(71_125_436, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(x as u64))) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - .saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(x as u64))) + (Weight::from_parts(95_783_300, 0)) + // Standard Error: 25_873 + .saturating_add((Weight::from_parts(24_362_858, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(x as u64))) } // Storage: Crowdloan Initialized (r:1 w:1) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:0) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:0 w:1) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanPeriod (r:0 w:1) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) fn complete_initialization() -> Weight { - (Weight::from_parts(21_060_000, 0)) + (Weight::from_parts(27_331_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Crowdloan CrowdloanPeriod (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) + // Storage: Vesting Vesting (r:1 w:1) + // Proof: Vesting Vesting (max_values: None, max_size: Some(1869), added: 4344, mode: MaxEncodedLen) + // Storage: Tokens Locks (r:1 w:1) + // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn claim() -> Weight { - (Weight::from_parts(68_230_000, 0)) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + (Weight::from_parts(129_060_000, 0)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn update_reward_address() -> Weight { - (Weight::from_parts(31_860_000, 0)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + (Weight::from_parts(34_900_000, 0)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:1 w:1) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:1 w:1) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:1 w:1) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn associate_native_identity() -> Weight { - (Weight::from_parts(147_350_000, 0)) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + (Weight::from_parts(114_790_000, 0)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn change_association_with_relay_keys(x: u32, ) -> Weight { - (Weight::from_parts(34_693_550, 0)) - // Standard Error: 8_870 - .saturating_add((Weight::from_parts(62_853_805, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + (Weight::from_parts(42_648_512, 0)) + // Standard Error: 10_539 + .saturating_add((Weight::from_parts(63_038_369, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } } // For backwards compatibility and tests impl WeightInfo for () { + // Storage: Crowdloan Initialized (r:1 w:0) + // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:0 w:1) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) fn set_crowdloan_allocation() -> Weight { - (Weight::from_parts(5_800_000, 0)) + (Weight::from_parts(13_860_000, 0)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:1) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:1) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:100 w:100) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:100 w:0) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:100 w:100) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: System Account (r:100 w:100) - // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:100 w:100) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn initialize_reward_vec(x: u32, ) -> Weight { - (Weight::from_parts(170_661_769, 0)) - // Standard Error: 50_081 - .saturating_add((Weight::from_parts(71_125_436, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().reads((5 as u64).saturating_mul(x as u64))) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - .saturating_add(RocksDbWeight::get().writes((4 as u64).saturating_mul(x as u64))) + (Weight::from_parts(95_783_300, 0)) + // Standard Error: 25_873 + .saturating_add((Weight::from_parts(24_362_858, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(x as u64))) } // Storage: Crowdloan Initialized (r:1 w:1) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:0) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:0 w:1) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanPeriod (r:0 w:1) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) fn complete_initialization() -> Weight { - (Weight::from_parts(21_060_000, 0)) + (Weight::from_parts(27_331_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Crowdloan CrowdloanPeriod (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) + // Storage: Vesting Vesting (r:1 w:1) + // Proof: Vesting Vesting (max_values: None, max_size: Some(1869), added: 4344, mode: MaxEncodedLen) + // Storage: Tokens Locks (r:1 w:1) + // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn claim() -> Weight { - (Weight::from_parts(68_230_000, 0)) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + (Weight::from_parts(129_060_000, 0)) + .saturating_add(RocksDbWeight::get().reads(10 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn update_reward_address() -> Weight { - (Weight::from_parts(31_860_000, 0)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + (Weight::from_parts(34_900_000, 0)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:1 w:1) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:1 w:1) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:1 w:1) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn associate_native_identity() -> Weight { - (Weight::from_parts(147_350_000, 0)) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + (Weight::from_parts(114_790_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn change_association_with_relay_keys(x: u32, ) -> Weight { - (Weight::from_parts(34_693_550, 0)) - // Standard Error: 8_870 - .saturating_add((Weight::from_parts(62_853_805, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + (Weight::from_parts(42_648_512, 0)) + // Standard Error: 10_539 + .saturating_add((Weight::from_parts(63_038_369, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } } diff --git a/runtime/mangata-kusama/src/weights/pallet_fee_lock.rs b/runtime/mangata-kusama/src/weights/pallet_fee_lock.rs index 5320f4b45e..7057d5cf29 100644 --- a/runtime/mangata-kusama/src/weights/pallet_fee_lock.rs +++ b/runtime/mangata-kusama/src/weights/pallet_fee_lock.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_fee_lock //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -66,7 +66,7 @@ impl pallet_fee_lock::WeightInfo for ModuleWeight { // Storage: FeeLock FeeLockMetadata (r:1 w:1) // Proof: FeeLock FeeLockMetadata (max_values: Some(1), max_size: Some(438), added: 933, mode: MaxEncodedLen) fn update_fee_lock_metadata() -> Weight { - (Weight::from_parts(30_789_000, 0)) + (Weight::from_parts(31_000_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -81,7 +81,7 @@ impl pallet_fee_lock::WeightInfo for ModuleWeight { // Storage: FeeLock UnlockQueue (r:1 w:1) // Proof: FeeLock UnlockQueue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) fn unlock_fee() -> Weight { - (Weight::from_parts(56_080_000, 0)) + (Weight::from_parts(56_920_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -92,7 +92,7 @@ impl WeightInfo for () { // Storage: FeeLock FeeLockMetadata (r:1 w:1) // Proof: FeeLock FeeLockMetadata (max_values: Some(1), max_size: Some(438), added: 933, mode: MaxEncodedLen) fn update_fee_lock_metadata() -> Weight { - (Weight::from_parts(30_789_000, 0)) + (Weight::from_parts(31_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -107,7 +107,7 @@ impl WeightInfo for () { // Storage: FeeLock UnlockQueue (r:1 w:1) // Proof: FeeLock UnlockQueue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) fn unlock_fee() -> Weight { - (Weight::from_parts(56_080_000, 0)) + (Weight::from_parts(56_920_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_issuance.rs b/runtime/mangata-kusama/src/weights/pallet_issuance.rs index 5df4b34f6d..c7f3821ac2 100644 --- a/runtime/mangata-kusama/src/weights/pallet_issuance.rs +++ b/runtime/mangata-kusama/src/weights/pallet_issuance.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_issuance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -71,14 +71,14 @@ impl pallet_issuance::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:0) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn init_issuance_config() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_870_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Issuance IsTGEFinalized (r:1 w:1) // Proof Skipped: Issuance IsTGEFinalized (max_values: Some(1), max_size: None, mode: Measured) fn finalize_tge() -> Weight { - (Weight::from_parts(15_849_000, 0)) + (Weight::from_parts(15_920_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -97,9 +97,9 @@ impl pallet_issuance::WeightInfo for ModuleWeight { // Storage: Issuance TGETotal (r:1 w:1) // Proof Skipped: Issuance TGETotal (max_values: Some(1), max_size: None, mode: Measured) fn execute_tge(x: u32, ) -> Weight { - (Weight::from_parts(26_585_737, 0)) - // Standard Error: 16_829 - .saturating_add((Weight::from_parts(83_061_110, 0)).saturating_mul(x as u64)) + (Weight::from_parts(32_064_606, 0)) + // Standard Error: 26_264 + .saturating_add((Weight::from_parts(85_431_002, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -116,14 +116,14 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:0) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn init_issuance_config() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_870_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Issuance IsTGEFinalized (r:1 w:1) // Proof Skipped: Issuance IsTGEFinalized (max_values: Some(1), max_size: None, mode: Measured) fn finalize_tge() -> Weight { - (Weight::from_parts(15_849_000, 0)) + (Weight::from_parts(15_920_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -142,9 +142,9 @@ impl WeightInfo for () { // Storage: Issuance TGETotal (r:1 w:1) // Proof Skipped: Issuance TGETotal (max_values: Some(1), max_size: None, mode: Measured) fn execute_tge(x: u32, ) -> Weight { - (Weight::from_parts(26_585_737, 0)) - // Standard Error: 16_829 - .saturating_add((Weight::from_parts(83_061_110, 0)).saturating_mul(x as u64)) + (Weight::from_parts(32_064_606, 0)) + // Standard Error: 26_264 + .saturating_add((Weight::from_parts(85_431_002, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) diff --git a/runtime/mangata-kusama/src/weights/pallet_multipurpose_liquidity.rs b/runtime/mangata-kusama/src/weights/pallet_multipurpose_liquidity.rs index 3fb479e9b7..4e536d93e4 100644 --- a/runtime/mangata-kusama/src/weights/pallet_multipurpose_liquidity.rs +++ b/runtime/mangata-kusama/src/weights/pallet_multipurpose_liquidity.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_multipurpose_liquidity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -76,7 +76,7 @@ impl pallet_multipurpose_liquidity::WeightInfo for Modu // Storage: MultiPurposeLiquidity RelockStatus (r:1 w:1) // Proof: MultiPurposeLiquidity RelockStatus (max_values: None, max_size: Some(1845), added: 4320, mode: MaxEncodedLen) fn reserve_vesting_liquidity_tokens() -> Weight { - (Weight::from_parts(127_250_000, 0)) + (Weight::from_parts(130_870_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -91,7 +91,7 @@ impl pallet_multipurpose_liquidity::WeightInfo for Modu // Storage: Tokens Locks (r:1 w:1) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn unreserve_and_relock_instance() -> Weight { - (Weight::from_parts(122_689_000, 0)) + (Weight::from_parts(126_300_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -112,7 +112,7 @@ impl WeightInfo for () { // Storage: MultiPurposeLiquidity RelockStatus (r:1 w:1) // Proof: MultiPurposeLiquidity RelockStatus (max_values: None, max_size: Some(1845), added: 4320, mode: MaxEncodedLen) fn reserve_vesting_liquidity_tokens() -> Weight { - (Weight::from_parts(127_250_000, 0)) + (Weight::from_parts(130_870_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -127,7 +127,7 @@ impl WeightInfo for () { // Storage: Tokens Locks (r:1 w:1) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn unreserve_and_relock_instance() -> Weight { - (Weight::from_parts(122_689_000, 0)) + (Weight::from_parts(126_300_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs index 99a6a2573d..6aac9c8080 100644 --- a/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs +++ b/runtime/mangata-kusama/src/weights/pallet_proof_of_stake.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_proof_of_stake //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -57,13 +57,13 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { fn claim_native_rewards() -> Weight; - fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; fn activate_liquidity_for_native_rewards() -> Weight; fn deactivate_liquidity_for_native_rewards() -> Weight; - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; - fn activate_liquidity_for_3rdparty_rewards() -> Weight; fn reward_pool() -> Weight; + fn activate_liquidity_for_3rdparty_rewards() -> Weight; + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; + fn claim_3rdparty_rewards() -> Weight; } /// Weights for pallet_proof_of_stake using the Mangata node and recommended hardware. @@ -76,20 +76,14 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn claim_native_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - - fn claim_3rdparty_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) + (Weight::from_parts(86_750_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { - (Weight::from_parts(18_600_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -104,7 +98,7 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(94_130_000, 0)) + (Weight::from_parts(100_109_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -119,61 +113,113 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn deactivate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(82_600_000, 0)) + (Weight::from_parts(91_990_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } - - - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Xyk LiquidityPools (r:1 w:0) + // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) + // Storage: Xyk Pools (r:1 w:0) + // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleId (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:0 w:1) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + fn reward_pool() -> Weight { + (Weight::from_parts(179_050_000, 0)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } - + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + (Weight::from_parts(120_360_000, 0)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } - - fn reward_pool() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:2 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(125_160_000, 0)) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ProofOfStake RewardsInfo (r:1 w:1) - // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_native_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(94_980_000, 0)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } +} +// For backwards compatibility and tests +impl WeightInfo for () { // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake RewardsInfo (r:1 w:1) // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_3rdparty_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) + fn claim_native_rewards() -> Weight { + (Weight::from_parts(86_750_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } - // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { - (Weight::from_parts(18_600_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -188,7 +234,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(94_130_000, 0)) + (Weight::from_parts(100_109_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -203,27 +249,92 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn deactivate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(82_600_000, 0)) + (Weight::from_parts(91_990_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Xyk LiquidityPools (r:1 w:0) + // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) + // Storage: Xyk Pools (r:1 w:0) + // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleId (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:0 w:1) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + fn reward_pool() -> Weight { + (Weight::from_parts(179_050_000, 0)) + .saturating_add(RocksDbWeight::get().reads(9 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } - + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + (Weight::from_parts(120_360_000, 0)) + .saturating_add(RocksDbWeight::get().reads(10 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } - - fn reward_pool() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:2 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(125_160_000, 0)) + .saturating_add(RocksDbWeight::get().reads(11 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) + } + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(94_980_000, 0)) + .saturating_add(RocksDbWeight::get().reads(7 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) } - } diff --git a/runtime/mangata-kusama/src/weights/pallet_session.rs b/runtime/mangata-kusama/src/weights/pallet_session.rs index 1a2b8fef84..3b9299b1a8 100644 --- a/runtime/mangata-kusama/src/weights/pallet_session.rs +++ b/runtime/mangata-kusama/src/weights/pallet_session.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_session //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,7 +68,7 @@ impl pallet_session::WeightInfo for ModuleWeight { // Storage: Session KeyOwner (r:1 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_480_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -77,7 +77,7 @@ impl pallet_session::WeightInfo for ModuleWeight { // Storage: Session KeyOwner (r:0 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - (Weight::from_parts(17_900_000, 0)) + (Weight::from_parts(17_880_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -90,7 +90,7 @@ impl WeightInfo for () { // Storage: Session KeyOwner (r:1 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_480_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -99,7 +99,7 @@ impl WeightInfo for () { // Storage: Session KeyOwner (r:0 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - (Weight::from_parts(17_900_000, 0)) + (Weight::from_parts(17_880_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_timestamp.rs b/runtime/mangata-kusama/src/weights/pallet_timestamp.rs index a2a3ba9ec3..a32d4dafb2 100644 --- a/runtime/mangata-kusama/src/weights/pallet_timestamp.rs +++ b/runtime/mangata-kusama/src/weights/pallet_timestamp.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -66,12 +66,12 @@ impl pallet_timestamp::WeightInfo for ModuleWeight { // Storage: Timestamp Now (r:1 w:1) // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - (Weight::from_parts(11_000_000, 0)) + (Weight::from_parts(10_120_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (Weight::from_parts(5_280_000, 0)) + (Weight::from_parts(5_220_000, 0)) } } @@ -80,11 +80,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:1) // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - (Weight::from_parts(11_000_000, 0)) + (Weight::from_parts(10_120_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (Weight::from_parts(5_280_000, 0)) + (Weight::from_parts(5_220_000, 0)) } } diff --git a/runtime/mangata-kusama/src/weights/pallet_treasury.rs b/runtime/mangata-kusama/src/weights/pallet_treasury.rs index 34eb8ab30f..89616a60b5 100644 --- a/runtime/mangata-kusama/src/weights/pallet_treasury.rs +++ b/runtime/mangata-kusama/src/weights/pallet_treasury.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,7 +68,7 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl pallet_treasury::WeightInfo for ModuleWeight { fn spend() -> Weight { - (Weight::from_parts(420_000, 0)) + (Weight::from_parts(530_000, 0)) } // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -77,7 +77,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Treasury Proposals (r:0 w:1) // Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - (Weight::from_parts(45_080_000, 0)) + (Weight::from_parts(46_150_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -88,7 +88,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - (Weight::from_parts(50_770_000, 0)) + (Weight::from_parts(52_520_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -97,16 +97,16 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_proposal(p: u32, ) -> Weight { - (Weight::from_parts(20_245_010, 0)) - // Standard Error: 1_597 - .saturating_add((Weight::from_parts(65_488, 0)).saturating_mul(p as u64)) + (Weight::from_parts(20_564_531, 0)) + // Standard Error: 1_841 + .saturating_add((Weight::from_parts(64_381, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - (Weight::from_parts(12_149_000, 0)) + (Weight::from_parts(12_011_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -121,9 +121,9 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn on_initialize_proposals(p: u32, ) -> Weight { - (Weight::from_parts(40_502_670, 0)) - // Standard Error: 6_134 - .saturating_add((Weight::from_parts(4_155_700, 0)).saturating_mul(p as u64)) + (Weight::from_parts(41_108_943, 0)) + // Standard Error: 7_113 + .saturating_add((Weight::from_parts(4_261_200, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -133,7 +133,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // For backwards compatibility and tests impl WeightInfo for () { fn spend() -> Weight { - (Weight::from_parts(420_000, 0)) + (Weight::from_parts(530_000, 0)) } // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -142,7 +142,7 @@ impl WeightInfo for () { // Storage: Treasury Proposals (r:0 w:1) // Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - (Weight::from_parts(45_080_000, 0)) + (Weight::from_parts(46_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -153,7 +153,7 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - (Weight::from_parts(50_770_000, 0)) + (Weight::from_parts(52_520_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -162,16 +162,16 @@ impl WeightInfo for () { // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_proposal(p: u32, ) -> Weight { - (Weight::from_parts(20_245_010, 0)) - // Standard Error: 1_597 - .saturating_add((Weight::from_parts(65_488, 0)).saturating_mul(p as u64)) + (Weight::from_parts(20_564_531, 0)) + // Standard Error: 1_841 + .saturating_add((Weight::from_parts(64_381, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - (Weight::from_parts(12_149_000, 0)) + (Weight::from_parts(12_011_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -186,9 +186,9 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn on_initialize_proposals(p: u32, ) -> Weight { - (Weight::from_parts(40_502_670, 0)) - // Standard Error: 6_134 - .saturating_add((Weight::from_parts(4_155_700, 0)).saturating_mul(p as u64)) + (Weight::from_parts(41_108_943, 0)) + // Standard Error: 7_113 + .saturating_add((Weight::from_parts(4_261_200, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) diff --git a/runtime/mangata-kusama/src/weights/pallet_utility_mangata.rs b/runtime/mangata-kusama/src/weights/pallet_utility_mangata.rs index 8f55cdf831..933c8abfba 100644 --- a/runtime/mangata-kusama/src/weights/pallet_utility_mangata.rs +++ b/runtime/mangata-kusama/src/weights/pallet_utility_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_utility_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -67,49 +67,49 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl pallet_utility_mangata::WeightInfo for ModuleWeight { fn batch(c: u32, ) -> Weight { - (Weight::from_parts(19_140_183, 0)) - // Standard Error: 3_444 - .saturating_add((Weight::from_parts(9_410_608, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_547_364, 0)) + // Standard Error: 3_907 + .saturating_add((Weight::from_parts(9_787_750, 0)).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (Weight::from_parts(10_120_000, 0)) + (Weight::from_parts(10_100_000, 0)) } fn batch_all(c: u32, ) -> Weight { - (Weight::from_parts(14_978_625, 0)) - // Standard Error: 2_992 - .saturating_add((Weight::from_parts(9_802_086, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_586_041, 0)) + // Standard Error: 3_411 + .saturating_add((Weight::from_parts(10_269_425, 0)).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (Weight::from_parts(16_510_000, 0)) + (Weight::from_parts(17_000_000, 0)) } fn force_batch(c: u32, ) -> Weight { - (Weight::from_parts(18_073_256, 0)) - // Standard Error: 3_525 - .saturating_add((Weight::from_parts(9_368_770, 0)).saturating_mul(c as u64)) + (Weight::from_parts(13_747_173, 0)) + // Standard Error: 3_163 + .saturating_add((Weight::from_parts(9_823_460, 0)).saturating_mul(c as u64)) } } // For backwards compatibility and tests impl WeightInfo for () { fn batch(c: u32, ) -> Weight { - (Weight::from_parts(19_140_183, 0)) - // Standard Error: 3_444 - .saturating_add((Weight::from_parts(9_410_608, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_547_364, 0)) + // Standard Error: 3_907 + .saturating_add((Weight::from_parts(9_787_750, 0)).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (Weight::from_parts(10_120_000, 0)) + (Weight::from_parts(10_100_000, 0)) } fn batch_all(c: u32, ) -> Weight { - (Weight::from_parts(14_978_625, 0)) - // Standard Error: 2_992 - .saturating_add((Weight::from_parts(9_802_086, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_586_041, 0)) + // Standard Error: 3_411 + .saturating_add((Weight::from_parts(10_269_425, 0)).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (Weight::from_parts(16_510_000, 0)) + (Weight::from_parts(17_000_000, 0)) } fn force_batch(c: u32, ) -> Weight { - (Weight::from_parts(18_073_256, 0)) - // Standard Error: 3_525 - .saturating_add((Weight::from_parts(9_368_770, 0)).saturating_mul(c as u64)) + (Weight::from_parts(13_747_173, 0)) + // Standard Error: 3_163 + .saturating_add((Weight::from_parts(9_823_460, 0)).saturating_mul(c as u64)) } } diff --git a/runtime/mangata-kusama/src/weights/pallet_vesting_mangata.rs b/runtime/mangata-kusama/src/weights/pallet_vesting_mangata.rs index f58fc1d6e6..1c975632c9 100644 --- a/runtime/mangata-kusama/src/weights/pallet_vesting_mangata.rs +++ b/runtime/mangata-kusama/src/weights/pallet_vesting_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_vesting_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -75,9 +75,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(52_309_417, 0)) - // Standard Error: 7_565 - .saturating_add((Weight::from_parts(219_965, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_243_152, 0)) + // Standard Error: 7_939 + .saturating_add((Weight::from_parts(234_970, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -88,9 +88,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_355_755, 0)) - // Standard Error: 3_270 - .saturating_add((Weight::from_parts(44_362, 0)).saturating_mul(s as u64)) + (Weight::from_parts(73_252_114, 0)) + // Standard Error: 3_434 + .saturating_add((Weight::from_parts(27_698, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -101,9 +101,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_other_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_645_987, 0)) - // Standard Error: 7_779 - .saturating_add((Weight::from_parts(207_339, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_977_339, 0)) + // Standard Error: 7_858 + .saturating_add((Weight::from_parts(223_279, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -116,9 +116,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn vest_other_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_436_663, 0)) - // Standard Error: 2_844 - .saturating_add((Weight::from_parts(76_147, 0)).saturating_mul(s as u64)) + (Weight::from_parts(72_574_520, 0)) + // Standard Error: 3_250 + .saturating_add((Weight::from_parts(67_290, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -131,9 +131,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Locks (r:1 w:0) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn force_vested_transfer(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(83_196_714, 0)) - // Standard Error: 29_574 - .saturating_add((Weight::from_parts(415_253, 0)).saturating_mul(s as u64)) + (Weight::from_parts(88_550_017, 0)) + // Standard Error: 13_455 + .saturating_add((Weight::from_parts(335_869, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -144,9 +144,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn not_unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(54_058_391, 0)) - // Standard Error: 7_609 - .saturating_add((Weight::from_parts(223_040, 0)).saturating_mul(s as u64)) + (Weight::from_parts(54_212_340, 0)) + // Standard Error: 8_032 + .saturating_add((Weight::from_parts(248_035, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -157,9 +157,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_022_178, 0)) - // Standard Error: 12_945 - .saturating_add((Weight::from_parts(320_024, 0)).saturating_mul(s as u64)) + (Weight::from_parts(52_783_090, 0)) + // Standard Error: 13_737 + .saturating_add((Weight::from_parts(346_445, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -174,9 +174,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(52_309_417, 0)) - // Standard Error: 7_565 - .saturating_add((Weight::from_parts(219_965, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_243_152, 0)) + // Standard Error: 7_939 + .saturating_add((Weight::from_parts(234_970, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -187,9 +187,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_355_755, 0)) - // Standard Error: 3_270 - .saturating_add((Weight::from_parts(44_362, 0)).saturating_mul(s as u64)) + (Weight::from_parts(73_252_114, 0)) + // Standard Error: 3_434 + .saturating_add((Weight::from_parts(27_698, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -200,9 +200,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_other_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_645_987, 0)) - // Standard Error: 7_779 - .saturating_add((Weight::from_parts(207_339, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_977_339, 0)) + // Standard Error: 7_858 + .saturating_add((Weight::from_parts(223_279, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -215,9 +215,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn vest_other_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_436_663, 0)) - // Standard Error: 2_844 - .saturating_add((Weight::from_parts(76_147, 0)).saturating_mul(s as u64)) + (Weight::from_parts(72_574_520, 0)) + // Standard Error: 3_250 + .saturating_add((Weight::from_parts(67_290, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -230,9 +230,9 @@ impl WeightInfo for () { // Storage: Tokens Locks (r:1 w:0) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn force_vested_transfer(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(83_196_714, 0)) - // Standard Error: 29_574 - .saturating_add((Weight::from_parts(415_253, 0)).saturating_mul(s as u64)) + (Weight::from_parts(88_550_017, 0)) + // Standard Error: 13_455 + .saturating_add((Weight::from_parts(335_869, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -243,9 +243,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn not_unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(54_058_391, 0)) - // Standard Error: 7_609 - .saturating_add((Weight::from_parts(223_040, 0)).saturating_mul(s as u64)) + (Weight::from_parts(54_212_340, 0)) + // Standard Error: 8_032 + .saturating_add((Weight::from_parts(248_035, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -256,9 +256,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_022_178, 0)) - // Standard Error: 12_945 - .saturating_add((Weight::from_parts(320_024, 0)).saturating_mul(s as u64)) + (Weight::from_parts(52_783_090, 0)) + // Standard Error: 13_737 + .saturating_add((Weight::from_parts(346_445, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/pallet_xyk.rs b/runtime/mangata-kusama/src/weights/pallet_xyk.rs index 62a52673ce..c1f831ff19 100644 --- a/runtime/mangata-kusama/src/weights/pallet_xyk.rs +++ b/runtime/mangata-kusama/src/weights/pallet_xyk.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_xyk //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -90,7 +90,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: Xyk LiquidityPools (r:0 w:1) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn create_pool() -> Weight { - (Weight::from_parts(199_311_000, 0)) + (Weight::from_parts(202_790_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) .saturating_add(T::DbWeight::get().writes(12 as u64)) } @@ -98,6 +98,10 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:3 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -105,12 +109,16 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn sell_asset() -> Weight { - (Weight::from_parts(226_860_000, 0)) - .saturating_add(T::DbWeight::get().reads(14 as u64)) + (Weight::from_parts(244_940_000, 0)) + .saturating_add(T::DbWeight::get().reads(16 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) // Storage: Xyk Pools (r:297 w:198) @@ -119,14 +127,12 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_sell_asset(x: u32, ) -> Weight { - (Weight::from_parts(618_130_000, 0)) - // Standard Error: 306_187 - .saturating_add((Weight::from_parts(245_461_340, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(661_629_000, 0)) + // Standard Error: 425_962 + .saturating_add((Weight::from_parts(272_288_151, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -134,6 +140,10 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -141,28 +151,30 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn buy_asset() -> Weight { - (Weight::from_parts(233_140_000, 0)) - .saturating_add(T::DbWeight::get().reads(15 as u64)) + (Weight::from_parts(253_260_000, 0)) + .saturating_add(T::DbWeight::get().reads(18 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:297 w:198) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:400 w:400) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_buy_asset(x: u32, ) -> Weight { - (Weight::from_parts(632_069_000, 0)) - // Standard Error: 339_491 - .saturating_add((Weight::from_parts(252_882_037, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(691_040_000, 0)) + // Standard Error: 480_931 + .saturating_add((Weight::from_parts(286_614_272, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -187,7 +199,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn mint_liquidity() -> Weight { - (Weight::from_parts(234_080_000, 0)) + (Weight::from_parts(241_610_000, 0)) .saturating_add(T::DbWeight::get().reads(15 as u64)) .saturating_add(T::DbWeight::get().writes(10 as u64)) } @@ -208,17 +220,17 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn mint_liquidity_using_vesting_native_tokens() -> Weight { - (Weight::from_parts(270_350_000, 0)) + (Weight::from_parts(277_529_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) .saturating_add(T::DbWeight::get().writes(11 as u64)) } // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:1 w:2) + // Storage: Xyk LiquidityAssets (r:1 w:0) // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Xyk Pools (r:1 w:2) + // Storage: Xyk Pools (r:1 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:5 w:5) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -230,17 +242,19 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityPools (r:0 w:1) - // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn burn_liquidity() -> Weight { - (Weight::from_parts(216_470_000, 0)) + (Weight::from_parts(223_960_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) - .saturating_add(T::DbWeight::get().writes(14 as u64)) + .saturating_add(T::DbWeight::get().writes(10 as u64)) } // Storage: Xyk LiquidityPools (r:1 w:0) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:7 w:7) @@ -249,16 +263,12 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn provide_liquidity_with_conversion() -> Weight { - (Weight::from_parts(369_290_000, 0)) + (Weight::from_parts(386_749_000, 0)) .saturating_add(T::DbWeight::get().reads(22 as u64)) .saturating_add(T::DbWeight::get().writes(11 as u64)) } @@ -272,16 +282,16 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:8 w:8) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:2 w:2) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:2 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:2 w:2) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) @@ -289,7 +299,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn compound_rewards() -> Weight { - (Weight::from_parts(514_330_000, 0)) + (Weight::from_parts(546_000_000, 0)) .saturating_add(T::DbWeight::get().reads(25 as u64)) .saturating_add(T::DbWeight::get().writes(16 as u64)) } @@ -316,7 +326,7 @@ impl WeightInfo for () { // Storage: Xyk LiquidityPools (r:0 w:1) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn create_pool() -> Weight { - (Weight::from_parts(199_311_000, 0)) + (Weight::from_parts(202_790_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) .saturating_add(RocksDbWeight::get().writes(12 as u64)) } @@ -324,6 +334,10 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:3 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -331,12 +345,16 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn sell_asset() -> Weight { - (Weight::from_parts(226_860_000, 0)) - .saturating_add(RocksDbWeight::get().reads(14 as u64)) + (Weight::from_parts(244_940_000, 0)) + .saturating_add(RocksDbWeight::get().reads(16 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) // Storage: Xyk Pools (r:297 w:198) @@ -345,14 +363,12 @@ impl WeightInfo for () { // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_sell_asset(x: u32, ) -> Weight { - (Weight::from_parts(618_130_000, 0)) - // Standard Error: 306_187 - .saturating_add((Weight::from_parts(245_461_340, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(661_629_000, 0)) + // Standard Error: 425_962 + .saturating_add((Weight::from_parts(272_288_151, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(29 as u64)) + .saturating_add(RocksDbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) .saturating_add(RocksDbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -360,6 +376,10 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -367,28 +387,30 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn buy_asset() -> Weight { - (Weight::from_parts(233_140_000, 0)) - .saturating_add(RocksDbWeight::get().reads(15 as u64)) + (Weight::from_parts(253_260_000, 0)) + .saturating_add(RocksDbWeight::get().reads(18 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:297 w:198) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:400 w:400) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_buy_asset(x: u32, ) -> Weight { - (Weight::from_parts(632_069_000, 0)) - // Standard Error: 339_491 - .saturating_add((Weight::from_parts(252_882_037, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(691_040_000, 0)) + // Standard Error: 480_931 + .saturating_add((Weight::from_parts(286_614_272, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(29 as u64)) + .saturating_add(RocksDbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) .saturating_add(RocksDbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -413,7 +435,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn mint_liquidity() -> Weight { - (Weight::from_parts(234_080_000, 0)) + (Weight::from_parts(241_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(15 as u64)) .saturating_add(RocksDbWeight::get().writes(10 as u64)) } @@ -434,17 +456,17 @@ impl WeightInfo for () { // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn mint_liquidity_using_vesting_native_tokens() -> Weight { - (Weight::from_parts(270_350_000, 0)) + (Weight::from_parts(277_529_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) .saturating_add(RocksDbWeight::get().writes(11 as u64)) } // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:1 w:2) + // Storage: Xyk LiquidityAssets (r:1 w:0) // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Xyk Pools (r:1 w:2) + // Storage: Xyk Pools (r:1 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:5 w:5) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -456,17 +478,19 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityPools (r:0 w:1) - // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn burn_liquidity() -> Weight { - (Weight::from_parts(216_470_000, 0)) + (Weight::from_parts(223_960_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) - .saturating_add(RocksDbWeight::get().writes(14 as u64)) + .saturating_add(RocksDbWeight::get().writes(10 as u64)) } // Storage: Xyk LiquidityPools (r:1 w:0) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:7 w:7) @@ -475,16 +499,12 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn provide_liquidity_with_conversion() -> Weight { - (Weight::from_parts(369_290_000, 0)) + (Weight::from_parts(386_749_000, 0)) .saturating_add(RocksDbWeight::get().reads(22 as u64)) .saturating_add(RocksDbWeight::get().writes(11 as u64)) } @@ -498,16 +518,16 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:8 w:8) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:2 w:2) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:2 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:2 w:2) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) @@ -515,7 +535,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn compound_rewards() -> Weight { - (Weight::from_parts(514_330_000, 0)) + (Weight::from_parts(546_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(25 as u64)) .saturating_add(RocksDbWeight::get().writes(16 as u64)) } diff --git a/runtime/mangata-kusama/src/weights/parachain_staking.rs b/runtime/mangata-kusama/src/weights/parachain_staking.rs index b2b31ca20e..aa9ad00b32 100644 --- a/runtime/mangata-kusama/src/weights/parachain_staking.rs +++ b/runtime/mangata-kusama/src/weights/parachain_staking.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for parachain_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -99,14 +99,14 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking TotalSelected (r:1 w:1) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) fn set_total_selected() -> Weight { - (Weight::from_parts(18_120_000, 0)) + (Weight::from_parts(18_150_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CollatorCommission (r:1 w:1) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) fn set_collator_commission() -> Weight { - (Weight::from_parts(18_170_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -133,11 +133,11 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn join_candidates(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(123_467_272, 0)) - // Standard Error: 5_457 - .saturating_add((Weight::from_parts(146_813, 0)).saturating_mul(x as u64)) - // Standard Error: 2_600 - .saturating_add((Weight::from_parts(190_628, 0)).saturating_mul(y as u64)) + (Weight::from_parts(128_769_592, 0)) + // Standard Error: 5_183 + .saturating_add((Weight::from_parts(124_370, 0)).saturating_mul(x as u64)) + // Standard Error: 5_120 + .saturating_add((Weight::from_parts(134_647, 0)).saturating_mul(y as u64)) .saturating_add(T::DbWeight::get().reads(11 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -148,9 +148,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(39_282_701, 0)) - // Standard Error: 2_623 - .saturating_add((Weight::from_parts(167_522, 0)).saturating_mul(x as u64)) + (Weight::from_parts(40_966_197, 0)) + // Standard Error: 1_766 + .saturating_add((Weight::from_parts(121_647, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -158,20 +158,20 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) - // Storage: MultiPurposeLiquidity ReserveStatus (r:25 w:25) + // Storage: MultiPurposeLiquidity ReserveStatus (r:30 w:30) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:25 w:25) + // Storage: Tokens Accounts (r:30 w:30) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: ParachainStaking DelegatorState (r:24 w:24) + // Storage: ParachainStaking DelegatorState (r:29 w:29) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CandidateAggregator (r:1 w:0) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(60_685_134, 0)) - // Standard Error: 31_073 - .saturating_add((Weight::from_parts(31_446_338, 0)).saturating_mul(x as u64)) + (Weight::from_parts(61_759_888, 0)) + // Standard Error: 25_405 + .saturating_add((Weight::from_parts(31_682_004, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -182,9 +182,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn cancel_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(37_579_077, 0)) - // Standard Error: 2_367 - .saturating_add((Weight::from_parts(161_581, 0)).saturating_mul(x as u64)) + (Weight::from_parts(39_197_562, 0)) + // Standard Error: 1_699 + .saturating_add((Weight::from_parts(119_579, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -195,7 +195,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_offline() -> Weight { - (Weight::from_parts(38_880_000, 0)) + (Weight::from_parts(39_200_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -206,7 +206,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_online() -> Weight { - (Weight::from_parts(38_290_000, 0)) + (Weight::from_parts(38_610_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -219,7 +219,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_more() -> Weight { - (Weight::from_parts(55_150_000, 0)) + (Weight::from_parts(56_000_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -234,7 +234,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_less() -> Weight { - (Weight::from_parts(57_430_000, 0)) + (Weight::from_parts(57_740_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -251,7 +251,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_more() -> Weight { - (Weight::from_parts(89_831_000, 0)) + (Weight::from_parts(90_910_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -268,21 +268,21 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_less() -> Weight { - (Weight::from_parts(85_290_000, 0)) + (Weight::from_parts(87_720_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_more() -> Weight { - (Weight::from_parts(29_900_000, 0)) + (Weight::from_parts(30_420_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_less() -> Weight { - (Weight::from_parts(29_190_000, 0)) + (Weight::from_parts(29_860_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -307,11 +307,11 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn delegate(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(126_644_715, 0)) - // Standard Error: 7_517 - .saturating_add((Weight::from_parts(346_672, 0)).saturating_mul(x as u64)) - // Standard Error: 19_666 - .saturating_add((Weight::from_parts(396_238, 0)).saturating_mul(y as u64)) + (Weight::from_parts(127_734_458, 0)) + // Standard Error: 7_698 + .saturating_add((Weight::from_parts(369_909, 0)).saturating_mul(x as u64)) + // Standard Error: 7_439 + .saturating_add((Weight::from_parts(357_907, 0)).saturating_mul(y as u64)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -320,7 +320,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_delegators() -> Weight { - (Weight::from_parts(32_340_000, 0)) + (Weight::from_parts(33_410_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -339,9 +339,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_delegators(x: u32, ) -> Weight { - (Weight::from_parts(24_536_934, 0)) - // Standard Error: 26_983 - .saturating_add((Weight::from_parts(37_923_839, 0)).saturating_mul(x as u64)) + (Weight::from_parts(24_848_761, 0)) + // Standard Error: 26_767 + .saturating_add((Weight::from_parts(38_484_757, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(4 as u64)) @@ -350,7 +350,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_leave_delegators() -> Weight { - (Weight::from_parts(30_410_000, 0)) + (Weight::from_parts(31_130_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -359,7 +359,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_revoke_delegation() -> Weight { - (Weight::from_parts(33_440_000, 0)) + (Weight::from_parts(34_070_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -372,7 +372,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_more() -> Weight { - (Weight::from_parts(56_360_000, 0)) + (Weight::from_parts(56_650_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -381,7 +381,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_less() -> Weight { - (Weight::from_parts(33_850_000, 0)) + (Weight::from_parts(34_280_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -400,7 +400,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_revoke_delegation() -> Weight { - (Weight::from_parts(110_750_000, 0)) + (Weight::from_parts(111_770_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -419,7 +419,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_more() -> Weight { - (Weight::from_parts(104_580_000, 0)) + (Weight::from_parts(103_940_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -438,28 +438,28 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_less() -> Weight { - (Weight::from_parts(100_440_000, 0)) + (Weight::from_parts(99_690_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_revoke_delegation() -> Weight { - (Weight::from_parts(30_630_000, 0)) + (Weight::from_parts(31_370_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_more() -> Weight { - (Weight::from_parts(35_770_000, 0)) + (Weight::from_parts(35_290_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_less() -> Weight { - (Weight::from_parts(35_660_000, 0)) + (Weight::from_parts(35_540_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -468,22 +468,22 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn add_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(28_003_682, 0)) - // Standard Error: 2_159 - .saturating_add((Weight::from_parts(179_452, 0)).saturating_mul(x as u64)) + (Weight::from_parts(28_340_872, 0)) + // Standard Error: 2_236 + .saturating_add((Weight::from_parts(153_025, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn remove_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(20_637_967, 0)) - // Standard Error: 1_732 - .saturating_add((Weight::from_parts(159_921, 0)).saturating_mul(x as u64)) + (Weight::from_parts(20_686_950, 0)) + // Standard Error: 1_638 + .saturating_add((Weight::from_parts(140_026, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking CandidateState (r:99 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking DelegatorState (r:1 w:0) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) @@ -492,8 +492,8 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidateAggregator (r:1 w:1) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) fn aggregator_update_metadata() -> Weight { - (Weight::from_parts(738_010_000, 0)) - .saturating_add(T::DbWeight::get().reads(52 as u64)) + (Weight::from_parts(1_946_910_000, 0)) + .saturating_add(T::DbWeight::get().reads(102 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:0) @@ -503,20 +503,20 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) // Proof Skipped: ParachainStaking AggregatorMetadata (max_values: None, max_size: None, mode: Measured) fn update_candidate_aggregator() -> Weight { - (Weight::from_parts(97_980_000, 0)) + (Weight::from_parts(122_120_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:14 w:14) + // Storage: Tokens Accounts (r:32 w:32) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: System Account (r:14 w:13) + // Storage: System Account (r:32 w:31) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_collator_rewards() -> Weight { - (Weight::from_parts(646_079_000, 0)) - .saturating_add(T::DbWeight::get().reads(30 as u64)) - .saturating_add(T::DbWeight::get().writes(28 as u64)) + (Weight::from_parts(1_493_000_000, 0)) + .saturating_add(T::DbWeight::get().reads(66 as u64)) + .saturating_add(T::DbWeight::get().writes(64 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:1 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) @@ -525,14 +525,14 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_delegator_reward() -> Weight { - (Weight::from_parts(81_750_000, 0)) + (Weight::from_parts(87_790_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn passive_session_change() -> Weight { - (Weight::from_parts(7_450_000, 0)) + (Weight::from_parts(7_670_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: ParachainStaking Round (r:1 w:1) @@ -551,9 +551,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: Issuance SessionIssuance (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking RoundAggregatorInfo (r:1 w:2) // Proof Skipped: ParachainStaking RoundAggregatorInfo (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AwardedPts (r:27 w:26) + // Storage: ParachainStaking AwardedPts (r:52 w:51) // Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AtStake (r:26 w:52) + // Storage: ParachainStaking AtStake (r:51 w:102) // Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CollatorCommission (r:1 w:0) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) @@ -571,37 +571,41 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking TotalSelected (r:1 w:0) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking CandidateState (r:26 w:0) + // Storage: ParachainStaking CandidateState (r:51 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: Issuance IssuanceConfigStore (r:1 w:0) // Proof Skipped: Issuance IssuanceConfigStore (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:0) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:100 w:0) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Session NextKeys (r:26 w:0) + // Storage: Session NextKeys (r:51 w:0) // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) // Storage: Aura Authorities (r:1 w:0) // Proof: Aura Authorities (max_values: Some(1), max_size: Some(3200004), added: 3200499, mode: MaxEncodedLen) // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:26) + // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:51) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) // Storage: Session Validators (r:0 w:1) // Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { - (Weight::from_parts(962_696_231, 0)) - // Standard Error: 23_712 - .saturating_add((Weight::from_parts(18_001_066, 0)).saturating_mul(x as u64)) - // Standard Error: 102_677 - .saturating_add((Weight::from_parts(5_760_381, 0)).saturating_mul(y as u64)) - // Standard Error: 242_115 - .saturating_add((Weight::from_parts(29_808_290, 0)).saturating_mul(z as u64)) - .saturating_add(T::DbWeight::get().reads(124 as u64)) + (Weight::from_parts(1_634_783_507, 0)) + // Standard Error: 32_199 + .saturating_add((Weight::from_parts(18_829_187, 0)).saturating_mul(x as u64)) + // Standard Error: 66_033 + .saturating_add((Weight::from_parts(7_604_897, 0)).saturating_mul(y as u64)) + // Standard Error: 114_378 + .saturating_add((Weight::from_parts(47_173_573, 0)).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(226 as u64)) .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(x as u64))) - .saturating_add(T::DbWeight::get().writes(119 as u64)) + .saturating_add(T::DbWeight::get().writes(220 as u64)) } } @@ -610,14 +614,14 @@ impl WeightInfo for () { // Storage: ParachainStaking TotalSelected (r:1 w:1) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) fn set_total_selected() -> Weight { - (Weight::from_parts(18_120_000, 0)) + (Weight::from_parts(18_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CollatorCommission (r:1 w:1) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) fn set_collator_commission() -> Weight { - (Weight::from_parts(18_170_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -644,11 +648,11 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn join_candidates(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(123_467_272, 0)) - // Standard Error: 5_457 - .saturating_add((Weight::from_parts(146_813, 0)).saturating_mul(x as u64)) - // Standard Error: 2_600 - .saturating_add((Weight::from_parts(190_628, 0)).saturating_mul(y as u64)) + (Weight::from_parts(128_769_592, 0)) + // Standard Error: 5_183 + .saturating_add((Weight::from_parts(124_370, 0)).saturating_mul(x as u64)) + // Standard Error: 5_120 + .saturating_add((Weight::from_parts(134_647, 0)).saturating_mul(y as u64)) .saturating_add(RocksDbWeight::get().reads(11 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -659,9 +663,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(39_282_701, 0)) - // Standard Error: 2_623 - .saturating_add((Weight::from_parts(167_522, 0)).saturating_mul(x as u64)) + (Weight::from_parts(40_966_197, 0)) + // Standard Error: 1_766 + .saturating_add((Weight::from_parts(121_647, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -669,20 +673,20 @@ impl WeightInfo for () { // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) - // Storage: MultiPurposeLiquidity ReserveStatus (r:25 w:25) + // Storage: MultiPurposeLiquidity ReserveStatus (r:30 w:30) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:25 w:25) + // Storage: Tokens Accounts (r:30 w:30) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: ParachainStaking DelegatorState (r:24 w:24) + // Storage: ParachainStaking DelegatorState (r:29 w:29) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CandidateAggregator (r:1 w:0) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(60_685_134, 0)) - // Standard Error: 31_073 - .saturating_add((Weight::from_parts(31_446_338, 0)).saturating_mul(x as u64)) + (Weight::from_parts(61_759_888, 0)) + // Standard Error: 25_405 + .saturating_add((Weight::from_parts(31_682_004, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) @@ -693,9 +697,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn cancel_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(37_579_077, 0)) - // Standard Error: 2_367 - .saturating_add((Weight::from_parts(161_581, 0)).saturating_mul(x as u64)) + (Weight::from_parts(39_197_562, 0)) + // Standard Error: 1_699 + .saturating_add((Weight::from_parts(119_579, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -706,7 +710,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_offline() -> Weight { - (Weight::from_parts(38_880_000, 0)) + (Weight::from_parts(39_200_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -717,7 +721,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_online() -> Weight { - (Weight::from_parts(38_290_000, 0)) + (Weight::from_parts(38_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -730,7 +734,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_more() -> Weight { - (Weight::from_parts(55_150_000, 0)) + (Weight::from_parts(56_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -745,7 +749,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_less() -> Weight { - (Weight::from_parts(57_430_000, 0)) + (Weight::from_parts(57_740_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -762,7 +766,7 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_more() -> Weight { - (Weight::from_parts(89_831_000, 0)) + (Weight::from_parts(90_910_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -779,21 +783,21 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_less() -> Weight { - (Weight::from_parts(85_290_000, 0)) + (Weight::from_parts(87_720_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_more() -> Weight { - (Weight::from_parts(29_900_000, 0)) + (Weight::from_parts(30_420_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_less() -> Weight { - (Weight::from_parts(29_190_000, 0)) + (Weight::from_parts(29_860_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -818,11 +822,11 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn delegate(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(126_644_715, 0)) - // Standard Error: 7_517 - .saturating_add((Weight::from_parts(346_672, 0)).saturating_mul(x as u64)) - // Standard Error: 19_666 - .saturating_add((Weight::from_parts(396_238, 0)).saturating_mul(y as u64)) + (Weight::from_parts(127_734_458, 0)) + // Standard Error: 7_698 + .saturating_add((Weight::from_parts(369_909, 0)).saturating_mul(x as u64)) + // Standard Error: 7_439 + .saturating_add((Weight::from_parts(357_907, 0)).saturating_mul(y as u64)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -831,7 +835,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_delegators() -> Weight { - (Weight::from_parts(32_340_000, 0)) + (Weight::from_parts(33_410_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -850,9 +854,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_delegators(x: u32, ) -> Weight { - (Weight::from_parts(24_536_934, 0)) - // Standard Error: 26_983 - .saturating_add((Weight::from_parts(37_923_839, 0)).saturating_mul(x as u64)) + (Weight::from_parts(24_848_761, 0)) + // Standard Error: 26_767 + .saturating_add((Weight::from_parts(38_484_757, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -861,7 +865,7 @@ impl WeightInfo for () { // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_leave_delegators() -> Weight { - (Weight::from_parts(30_410_000, 0)) + (Weight::from_parts(31_130_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -870,7 +874,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_revoke_delegation() -> Weight { - (Weight::from_parts(33_440_000, 0)) + (Weight::from_parts(34_070_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -883,7 +887,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_more() -> Weight { - (Weight::from_parts(56_360_000, 0)) + (Weight::from_parts(56_650_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -892,7 +896,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_less() -> Weight { - (Weight::from_parts(33_850_000, 0)) + (Weight::from_parts(34_280_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -911,7 +915,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_revoke_delegation() -> Weight { - (Weight::from_parts(110_750_000, 0)) + (Weight::from_parts(111_770_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -930,7 +934,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_more() -> Weight { - (Weight::from_parts(104_580_000, 0)) + (Weight::from_parts(103_940_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -949,28 +953,28 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_less() -> Weight { - (Weight::from_parts(100_440_000, 0)) + (Weight::from_parts(99_690_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_revoke_delegation() -> Weight { - (Weight::from_parts(30_630_000, 0)) + (Weight::from_parts(31_370_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_more() -> Weight { - (Weight::from_parts(35_770_000, 0)) + (Weight::from_parts(35_290_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_less() -> Weight { - (Weight::from_parts(35_660_000, 0)) + (Weight::from_parts(35_540_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -979,22 +983,22 @@ impl WeightInfo for () { // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn add_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(28_003_682, 0)) - // Standard Error: 2_159 - .saturating_add((Weight::from_parts(179_452, 0)).saturating_mul(x as u64)) + (Weight::from_parts(28_340_872, 0)) + // Standard Error: 2_236 + .saturating_add((Weight::from_parts(153_025, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn remove_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(20_637_967, 0)) - // Standard Error: 1_732 - .saturating_add((Weight::from_parts(159_921, 0)).saturating_mul(x as u64)) + (Weight::from_parts(20_686_950, 0)) + // Standard Error: 1_638 + .saturating_add((Weight::from_parts(140_026, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } - // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking CandidateState (r:99 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking DelegatorState (r:1 w:0) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) @@ -1003,8 +1007,8 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidateAggregator (r:1 w:1) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) fn aggregator_update_metadata() -> Weight { - (Weight::from_parts(738_010_000, 0)) - .saturating_add(RocksDbWeight::get().reads(52 as u64)) + (Weight::from_parts(1_946_910_000, 0)) + .saturating_add(RocksDbWeight::get().reads(102 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:0) @@ -1014,20 +1018,20 @@ impl WeightInfo for () { // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) // Proof Skipped: ParachainStaking AggregatorMetadata (max_values: None, max_size: None, mode: Measured) fn update_candidate_aggregator() -> Weight { - (Weight::from_parts(97_980_000, 0)) + (Weight::from_parts(122_120_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:14 w:14) + // Storage: Tokens Accounts (r:32 w:32) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: System Account (r:14 w:13) + // Storage: System Account (r:32 w:31) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_collator_rewards() -> Weight { - (Weight::from_parts(646_079_000, 0)) - .saturating_add(RocksDbWeight::get().reads(30 as u64)) - .saturating_add(RocksDbWeight::get().writes(28 as u64)) + (Weight::from_parts(1_493_000_000, 0)) + .saturating_add(RocksDbWeight::get().reads(66 as u64)) + .saturating_add(RocksDbWeight::get().writes(64 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:1 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) @@ -1036,14 +1040,14 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_delegator_reward() -> Weight { - (Weight::from_parts(81_750_000, 0)) + (Weight::from_parts(87_790_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn passive_session_change() -> Weight { - (Weight::from_parts(7_450_000, 0)) + (Weight::from_parts(7_670_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) } // Storage: ParachainStaking Round (r:1 w:1) @@ -1062,9 +1066,9 @@ impl WeightInfo for () { // Proof Skipped: Issuance SessionIssuance (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking RoundAggregatorInfo (r:1 w:2) // Proof Skipped: ParachainStaking RoundAggregatorInfo (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AwardedPts (r:27 w:26) + // Storage: ParachainStaking AwardedPts (r:52 w:51) // Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AtStake (r:26 w:52) + // Storage: ParachainStaking AtStake (r:51 w:102) // Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CollatorCommission (r:1 w:0) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) @@ -1082,36 +1086,40 @@ impl WeightInfo for () { // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking TotalSelected (r:1 w:0) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking CandidateState (r:26 w:0) + // Storage: ParachainStaking CandidateState (r:51 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: Issuance IssuanceConfigStore (r:1 w:0) // Proof Skipped: Issuance IssuanceConfigStore (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:0) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:100 w:0) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Session NextKeys (r:26 w:0) + // Storage: Session NextKeys (r:51 w:0) // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) // Storage: Aura Authorities (r:1 w:0) // Proof: Aura Authorities (max_values: Some(1), max_size: Some(3200004), added: 3200499, mode: MaxEncodedLen) // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:26) + // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:51) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) // Storage: Session Validators (r:0 w:1) // Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { - (Weight::from_parts(962_696_231, 0)) - // Standard Error: 23_712 - .saturating_add((Weight::from_parts(18_001_066, 0)).saturating_mul(x as u64)) - // Standard Error: 102_677 - .saturating_add((Weight::from_parts(5_760_381, 0)).saturating_mul(y as u64)) - // Standard Error: 242_115 - .saturating_add((Weight::from_parts(29_808_290, 0)).saturating_mul(z as u64)) - .saturating_add(RocksDbWeight::get().reads(124 as u64)) + (Weight::from_parts(1_634_783_507, 0)) + // Standard Error: 32_199 + .saturating_add((Weight::from_parts(18_829_187, 0)).saturating_mul(x as u64)) + // Standard Error: 66_033 + .saturating_add((Weight::from_parts(7_604_897, 0)).saturating_mul(y as u64)) + // Standard Error: 114_378 + .saturating_add((Weight::from_parts(47_173_573, 0)).saturating_mul(z as u64)) + .saturating_add(RocksDbWeight::get().reads(226 as u64)) .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) - .saturating_add(RocksDbWeight::get().writes(119 as u64)) + .saturating_add(RocksDbWeight::get().writes(220 as u64)) } } diff --git a/runtime/mangata-rococo/src/weights/block_weights.rs b/runtime/mangata-rococo/src/weights/block_weights.rs index 1e38e0097a..e190a4a858 100644 --- a/runtime/mangata-rococo/src/weights/block_weights.rs +++ b/runtime/mangata-rococo/src/weights/block_weights.rs @@ -1,6 +1,7 @@ + //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18 (Y/M/D) -//! HOSTNAME: `995c44fb4e67`, CPU: `AMD EPYC 7B13` +//! DATE: 2023-10-02 (Y/M/D) +//! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` //! //! SHORT-NAME: `block`, LONG-NAME: `BlockExecution`, RUNTIME: `Mangata Kusama Local` //! WARMUPS: `10`, REPEAT: `100` @@ -29,17 +30,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 7_631_910, 8_052_540 - /// Average: 7_692_887 - /// Median: 7_661_290 - /// Std-Dev: 104885.3 + /// Min, Max: 7_983_500, 8_609_050 + /// Average: 8_057_882 + /// Median: 8_023_430 + /// Std-Dev: 118109.32 /// /// Percentiles nanoseconds: - /// 99th: 8_034_380 - /// 95th: 8_023_380 - /// 75th: 7_674_100 + /// 99th: 8_567_140 + /// 95th: 8_382_280 + /// 75th: 8_036_000 pub const BlockExecutionWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(7_692_887), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(8_057_882), 0); } #[cfg(test)] diff --git a/runtime/mangata-rococo/src/weights/extrinsic_weights.rs b/runtime/mangata-rococo/src/weights/extrinsic_weights.rs index 92fca50754..033bf75d8f 100644 --- a/runtime/mangata-rococo/src/weights/extrinsic_weights.rs +++ b/runtime/mangata-rococo/src/weights/extrinsic_weights.rs @@ -1,6 +1,7 @@ + //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18 (Y/M/D) -//! HOSTNAME: `995c44fb4e67`, CPU: `AMD EPYC 7B13` +//! DATE: 2023-10-02 (Y/M/D) +//! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` //! //! SHORT-NAME: `extrinsic`, LONG-NAME: `ExtrinsicBase`, RUNTIME: `Mangata Kusama Local` //! WARMUPS: `10`, REPEAT: `100` @@ -29,17 +30,17 @@ parameter_types! { /// Calculated by multiplying the *Average* with `1.0` and adding `0`. /// /// Stats nanoseconds: - /// Min, Max: 114_329, 115_887 - /// Average: 114_756 - /// Median: 114_639 - /// Std-Dev: 309.81 + /// Min, Max: 116_665, 118_803 + /// Average: 117_078 + /// Median: 117_010 + /// Std-Dev: 306.32 /// /// Percentiles nanoseconds: - /// 99th: 115_799 - /// 95th: 115_437 - /// 75th: 114_859 + /// 99th: 118_109 + /// 95th: 117_513 + /// 75th: 117_236 pub const ExtrinsicBaseWeight: Weight = - Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(114_756), 0); + Weight::from_parts(WEIGHT_REF_TIME_PER_NANOS.saturating_mul(117_078), 0); } #[cfg(test)] diff --git a/runtime/mangata-rococo/src/weights/frame_system.rs b/runtime/mangata-rococo/src/weights/frame_system.rs index e2b9f77ec8..9bcfdbb3d8 100644 --- a/runtime/mangata-rococo/src/weights/frame_system.rs +++ b/runtime/mangata-rococo/src/weights/frame_system.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for frame_system //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,46 +68,46 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl frame_system::WeightInfo for ModuleWeight { fn remark(b: u32, ) -> Weight { - (Weight::from_parts(10_114_579, 0)) + (Weight::from_parts(9_964_525, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(518, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(589, 0)).saturating_mul(b as u64)) } fn remark_with_event(b: u32, ) -> Weight { - (Weight::from_parts(30_615_946, 0)) + (Weight::from_parts(29_205_376, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(1_708, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(1_778, 0)).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) // Storage: unknown `0x3a686561707061676573` (r:0 w:1) // Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - (Weight::from_parts(7_640_000, 0)) + (Weight::from_parts(7_610_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn set_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_030_000, 0)) - // Standard Error: 2_557 - .saturating_add((Weight::from_parts(1_227_455, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_160_000, 0)) + // Standard Error: 2_435 + .saturating_add((Weight::from_parts(1_226_647, 0)).saturating_mul(i as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_170_000, 0)) - // Standard Error: 1_127 - .saturating_add((Weight::from_parts(837_671, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_090_000, 0)) + // Standard Error: 1_110 + .saturating_add((Weight::from_parts(840_132, 0)).saturating_mul(i as u64)) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_prefix(p: u32, ) -> Weight { - (Weight::from_parts(7_530_000, 0)) - // Standard Error: 1_363 - .saturating_add((Weight::from_parts(1_454_847, 0)).saturating_mul(p as u64)) + (Weight::from_parts(7_640_000, 0)) + // Standard Error: 1_374 + .saturating_add((Weight::from_parts(1_459_706, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } @@ -116,46 +116,46 @@ impl frame_system::WeightInfo for ModuleWeight { // For backwards compatibility and tests impl WeightInfo for () { fn remark(b: u32, ) -> Weight { - (Weight::from_parts(10_114_579, 0)) + (Weight::from_parts(9_964_525, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(518, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(589, 0)).saturating_mul(b as u64)) } fn remark_with_event(b: u32, ) -> Weight { - (Weight::from_parts(30_615_946, 0)) + (Weight::from_parts(29_205_376, 0)) // Standard Error: 0 - .saturating_add((Weight::from_parts(1_708, 0)).saturating_mul(b as u64)) + .saturating_add((Weight::from_parts(1_778, 0)).saturating_mul(b as u64)) } // Storage: System Digest (r:1 w:1) // Proof Skipped: System Digest (max_values: Some(1), max_size: None, mode: Measured) // Storage: unknown `0x3a686561707061676573` (r:0 w:1) // Proof Skipped: unknown `0x3a686561707061676573` (r:0 w:1) fn set_heap_pages() -> Weight { - (Weight::from_parts(7_640_000, 0)) + (Weight::from_parts(7_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn set_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_030_000, 0)) - // Standard Error: 2_557 - .saturating_add((Weight::from_parts(1_227_455, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_160_000, 0)) + // Standard Error: 2_435 + .saturating_add((Weight::from_parts(1_226_647, 0)).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_storage(i: u32, ) -> Weight { - (Weight::from_parts(4_170_000, 0)) - // Standard Error: 1_127 - .saturating_add((Weight::from_parts(837_671, 0)).saturating_mul(i as u64)) + (Weight::from_parts(4_090_000, 0)) + // Standard Error: 1_110 + .saturating_add((Weight::from_parts(840_132, 0)).saturating_mul(i as u64)) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(i as u64))) } // Storage: Skipped Metadata (r:0 w:0) // Proof Skipped: Skipped Metadata (max_values: None, max_size: None, mode: Measured) fn kill_prefix(p: u32, ) -> Weight { - (Weight::from_parts(7_530_000, 0)) - // Standard Error: 1_363 - .saturating_add((Weight::from_parts(1_454_847, 0)).saturating_mul(p as u64)) + (Weight::from_parts(7_640_000, 0)) + // Standard Error: 1_374 + .saturating_add((Weight::from_parts(1_459_706, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes((1 as u64).saturating_mul(p as u64))) } diff --git a/runtime/mangata-rococo/src/weights/orml_asset_registry.rs b/runtime/mangata-rococo/src/weights/orml_asset_registry.rs index 341ffe99df..8242233fca 100644 --- a/runtime/mangata-rococo/src/weights/orml_asset_registry.rs +++ b/runtime/mangata-rococo/src/weights/orml_asset_registry.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for orml_asset_registry //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -72,7 +72,7 @@ impl orml_asset_registry::WeightInfo for ModuleWeight Weight { - (Weight::from_parts(48_380_000, 0)) + (Weight::from_parts(48_560_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -81,7 +81,7 @@ impl orml_asset_registry::WeightInfo for ModuleWeight Weight { - (Weight::from_parts(33_520_000, 0)) + (Weight::from_parts(33_480_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -98,7 +98,7 @@ impl WeightInfo for () { // Storage: AssetRegistry LocationToAssetId (r:1 w:1) // Proof Skipped: AssetRegistry LocationToAssetId (max_values: None, max_size: None, mode: Measured) fn register_asset() -> Weight { - (Weight::from_parts(48_380_000, 0)) + (Weight::from_parts(48_560_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -107,7 +107,7 @@ impl WeightInfo for () { // Storage: AssetRegistry LocationToAssetId (r:1 w:1) // Proof Skipped: AssetRegistry LocationToAssetId (max_values: None, max_size: None, mode: Measured) fn update_asset() -> Weight { - (Weight::from_parts(33_520_000, 0)) + (Weight::from_parts(33_480_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/orml_tokens.rs b/runtime/mangata-rococo/src/weights/orml_tokens.rs index 06359ec572..5508f3d7cb 100644 --- a/runtime/mangata-rococo/src/weights/orml_tokens.rs +++ b/runtime/mangata-rococo/src/weights/orml_tokens.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for orml_tokens //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -73,7 +73,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer() -> Weight { - (Weight::from_parts(53_910_000, 0)) + (Weight::from_parts(54_300_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -82,7 +82,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_all() -> Weight { - (Weight::from_parts(56_060_000, 0)) + (Weight::from_parts(56_740_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -91,7 +91,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_keep_alive() -> Weight { - (Weight::from_parts(51_300_000, 0)) + (Weight::from_parts(52_380_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -100,7 +100,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn force_transfer() -> Weight { - (Weight::from_parts(57_360_000, 0)) + (Weight::from_parts(58_360_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -109,7 +109,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn set_balance() -> Weight { - (Weight::from_parts(31_560_000, 0)) + (Weight::from_parts(32_250_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -122,7 +122,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn create() -> Weight { - (Weight::from_parts(58_330_000, 0)) + (Weight::from_parts(58_930_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -135,7 +135,7 @@ impl orml_tokens::WeightInfo for ModuleWeight { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn mint() -> Weight { - (Weight::from_parts(58_720_000, 0)) + (Weight::from_parts(59_170_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -148,7 +148,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer() -> Weight { - (Weight::from_parts(53_910_000, 0)) + (Weight::from_parts(54_300_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -157,7 +157,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_all() -> Weight { - (Weight::from_parts(56_060_000, 0)) + (Weight::from_parts(56_740_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -166,7 +166,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn transfer_keep_alive() -> Weight { - (Weight::from_parts(51_300_000, 0)) + (Weight::from_parts(52_380_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -175,7 +175,7 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn force_transfer() -> Weight { - (Weight::from_parts(57_360_000, 0)) + (Weight::from_parts(58_360_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -184,7 +184,7 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn set_balance() -> Weight { - (Weight::from_parts(31_560_000, 0)) + (Weight::from_parts(32_250_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -197,7 +197,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn create() -> Weight { - (Weight::from_parts(58_330_000, 0)) + (Weight::from_parts(58_930_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -210,7 +210,7 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn mint() -> Weight { - (Weight::from_parts(58_720_000, 0)) + (Weight::from_parts(59_170_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_bootstrap.rs b/runtime/mangata-rococo/src/weights/pallet_bootstrap.rs index b07baf19f9..7ebdf94b14 100644 --- a/runtime/mangata-rococo/src/weights/pallet_bootstrap.rs +++ b/runtime/mangata-rococo/src/weights/pallet_bootstrap.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_bootstrap //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -78,7 +78,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn schedule_bootstrap() -> Weight { - (Weight::from_parts(34_440_000, 0)) + (Weight::from_parts(34_000_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -103,7 +103,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn provision() -> Weight { - (Weight::from_parts(103_400_000, 0)) + (Weight::from_parts(106_729_000, 0)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -136,7 +136,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn claim_and_activate_liquidity_tokens() -> Weight { - (Weight::from_parts(216_740_000, 0)) + (Weight::from_parts(226_960_000, 0)) .saturating_add(T::DbWeight::get().reads(17 as u64)) .saturating_add(T::DbWeight::get().writes(8 as u64)) } @@ -167,7 +167,7 @@ impl pallet_bootstrap::WeightInfo for ModuleWeight { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn finalize() -> Weight { - (Weight::from_parts(79_290_000, 0)) + (Weight::from_parts(79_150_000, 0)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(7 as u64)) } @@ -188,7 +188,7 @@ impl WeightInfo for () { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn schedule_bootstrap() -> Weight { - (Weight::from_parts(34_440_000, 0)) + (Weight::from_parts(34_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -213,7 +213,7 @@ impl WeightInfo for () { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn provision() -> Weight { - (Weight::from_parts(103_400_000, 0)) + (Weight::from_parts(106_729_000, 0)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -246,7 +246,7 @@ impl WeightInfo for () { // Storage: Bootstrap ProvisionAccounts (r:0 w:1) // Proof Skipped: Bootstrap ProvisionAccounts (max_values: None, max_size: None, mode: Measured) fn claim_and_activate_liquidity_tokens() -> Weight { - (Weight::from_parts(216_740_000, 0)) + (Weight::from_parts(226_960_000, 0)) .saturating_add(RocksDbWeight::get().reads(17 as u64)) .saturating_add(RocksDbWeight::get().writes(8 as u64)) } @@ -277,7 +277,7 @@ impl WeightInfo for () { // Storage: Bootstrap ActivePair (r:0 w:1) // Proof Skipped: Bootstrap ActivePair (max_values: Some(1), max_size: None, mode: Measured) fn finalize() -> Weight { - (Weight::from_parts(79_290_000, 0)) + (Weight::from_parts(79_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(7 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_collective_mangata.rs b/runtime/mangata-rococo/src/weights/pallet_collective_mangata.rs index ff2788893c..ded612958c 100644 --- a/runtime/mangata-rococo/src/weights/pallet_collective_mangata.rs +++ b/runtime/mangata-rococo/src/weights/pallet_collective_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_collective_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -80,11 +80,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Prime (r:0 w:1) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_140_000, 0)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(5_481_522, 0)).saturating_mul(m as u64)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(10_538_444, 0)).saturating_mul(p as u64)) + (Weight::from_parts(90_800_000, 0)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(5_566_250, 0)).saturating_mul(m as u64)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(10_729_781, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -93,11 +93,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Members (r:1 w:0) // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(29_943_956, 0)) - // Standard Error: 73 - .saturating_add((Weight::from_parts(2_027, 0)).saturating_mul(b as u64)) - // Standard Error: 761 - .saturating_add((Weight::from_parts(27_217, 0)).saturating_mul(m as u64)) + (Weight::from_parts(31_313_537, 0)) + // Standard Error: 94 + .saturating_add((Weight::from_parts(1_862, 0)).saturating_mul(b as u64)) + // Standard Error: 972 + .saturating_add((Weight::from_parts(25_991, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: Council Members (r:1 w:0) @@ -105,11 +105,11 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:1 w:0) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn propose_execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(33_627_672, 0)) - // Standard Error: 82 - .saturating_add((Weight::from_parts(2_315, 0)).saturating_mul(b as u64)) - // Standard Error: 855 - .saturating_add((Weight::from_parts(45_555, 0)).saturating_mul(m as u64)) + (Weight::from_parts(34_536_810, 0)) + // Standard Error: 85 + .saturating_add((Weight::from_parts(2_168, 0)).saturating_mul(b as u64)) + // Standard Error: 883 + .saturating_add((Weight::from_parts(45_007, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) } // Storage: Council Members (r:1 w:0) @@ -125,13 +125,13 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Voting (r:0 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(48_107_905, 0)) - // Standard Error: 148 - .saturating_add((Weight::from_parts(4_689, 0)).saturating_mul(b as u64)) - // Standard Error: 1_547 - .saturating_add((Weight::from_parts(33_696, 0)).saturating_mul(m as u64)) - // Standard Error: 1_527 - .saturating_add((Weight::from_parts(306_730, 0)).saturating_mul(p as u64)) + (Weight::from_parts(49_784_354, 0)) + // Standard Error: 163 + .saturating_add((Weight::from_parts(4_191, 0)).saturating_mul(b as u64)) + // Standard Error: 1_705 + .saturating_add((Weight::from_parts(35_364, 0)).saturating_mul(m as u64)) + // Standard Error: 1_683 + .saturating_add((Weight::from_parts(301_218, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -140,58 +140,58 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn vote(m: u32, ) -> Weight { - (Weight::from_parts(45_661_933, 0)) - // Standard Error: 1_152 - .saturating_add((Weight::from_parts(70_484, 0)).saturating_mul(m as u64)) + (Weight::from_parts(45_999_012, 0)) + // Standard Error: 944 + .saturating_add((Weight::from_parts(70_544, 0)).saturating_mul(m as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(65_240_157, 0)) - // Standard Error: 1_748 - .saturating_add((Weight::from_parts(56_035, 0)).saturating_mul(m as u64)) - // Standard Error: 1_704 - .saturating_add((Weight::from_parts(287_256, 0)).saturating_mul(p as u64)) + (Weight::from_parts(67_599_850, 0)) + // Standard Error: 1_737 + .saturating_add((Weight::from_parts(80_078, 0)).saturating_mul(m as u64)) + // Standard Error: 1_694 + .saturating_add((Weight::from_parts(294_524, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_748_886, 0)) - // Standard Error: 304 - .saturating_add((Weight::from_parts(2_436, 0)).saturating_mul(b as u64)) - // Standard Error: 3_220 - .saturating_add((Weight::from_parts(73_314, 0)).saturating_mul(m as u64)) - // Standard Error: 3_139 - .saturating_add((Weight::from_parts(313_478, 0)).saturating_mul(p as u64)) + (Weight::from_parts(94_619_427, 0)) + // Standard Error: 307 + .saturating_add((Weight::from_parts(2_144, 0)).saturating_mul(b as u64)) + // Standard Error: 3_251 + .saturating_add((Weight::from_parts(94_352, 0)).saturating_mul(m as u64)) + // Standard Error: 3_169 + .saturating_add((Weight::from_parts(315_046, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) @@ -199,20 +199,20 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(69_217_092, 0)) - // Standard Error: 1_867 - .saturating_add((Weight::from_parts(66_672, 0)).saturating_mul(m as u64)) - // Standard Error: 1_821 - .saturating_add((Weight::from_parts(286_625, 0)).saturating_mul(p as u64)) + (Weight::from_parts(71_391_246, 0)) + // Standard Error: 1_912 + .saturating_add((Weight::from_parts(92_748, 0)).saturating_mul(m as u64)) + // Standard Error: 1_865 + .saturating_add((Weight::from_parts(298_046, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) @@ -220,13 +220,13 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(95_973_593, 0)) - // Standard Error: 310 - .saturating_add((Weight::from_parts(2_185, 0)).saturating_mul(b as u64)) - // Standard Error: 3_288 - .saturating_add((Weight::from_parts(68_870, 0)).saturating_mul(m as u64)) - // Standard Error: 3_205 - .saturating_add((Weight::from_parts(311_244, 0)).saturating_mul(p as u64)) + (Weight::from_parts(98_330_423, 0)) + // Standard Error: 297 + .saturating_add((Weight::from_parts(3_678, 0)).saturating_mul(b as u64)) + // Standard Error: 3_149 + .saturating_add((Weight::from_parts(97_124, 0)).saturating_mul(m as u64)) + // Standard Error: 3_070 + .saturating_add((Weight::from_parts(313_849, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -239,9 +239,9 @@ impl pallet_collective_mangata::WeightInfo for ModuleWe // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn disapprove_proposal(p: u32, ) -> Weight { - (Weight::from_parts(36_150_886, 0)) - // Standard Error: 1_532 - .saturating_add((Weight::from_parts(281_687, 0)).saturating_mul(p as u64)) + (Weight::from_parts(36_844_726, 0)) + // Standard Error: 1_413 + .saturating_add((Weight::from_parts(281_628, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -258,11 +258,11 @@ impl WeightInfo for () { // Storage: Council Prime (r:0 w:1) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) fn set_members(m: u32, _n: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_140_000, 0)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(5_481_522, 0)).saturating_mul(m as u64)) - // Standard Error: 69_195 - .saturating_add((Weight::from_parts(10_538_444, 0)).saturating_mul(p as u64)) + (Weight::from_parts(90_800_000, 0)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(5_566_250, 0)).saturating_mul(m as u64)) + // Standard Error: 69_203 + .saturating_add((Weight::from_parts(10_729_781, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) @@ -271,11 +271,11 @@ impl WeightInfo for () { // Storage: Council Members (r:1 w:0) // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) fn execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(29_943_956, 0)) - // Standard Error: 73 - .saturating_add((Weight::from_parts(2_027, 0)).saturating_mul(b as u64)) - // Standard Error: 761 - .saturating_add((Weight::from_parts(27_217, 0)).saturating_mul(m as u64)) + (Weight::from_parts(31_313_537, 0)) + // Standard Error: 94 + .saturating_add((Weight::from_parts(1_862, 0)).saturating_mul(b as u64)) + // Standard Error: 972 + .saturating_add((Weight::from_parts(25_991, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) } // Storage: Council Members (r:1 w:0) @@ -283,11 +283,11 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:1 w:0) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn propose_execute(b: u32, m: u32, ) -> Weight { - (Weight::from_parts(33_627_672, 0)) - // Standard Error: 82 - .saturating_add((Weight::from_parts(2_315, 0)).saturating_mul(b as u64)) - // Standard Error: 855 - .saturating_add((Weight::from_parts(45_555, 0)).saturating_mul(m as u64)) + (Weight::from_parts(34_536_810, 0)) + // Standard Error: 85 + .saturating_add((Weight::from_parts(2_168, 0)).saturating_mul(b as u64)) + // Standard Error: 883 + .saturating_add((Weight::from_parts(45_007, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) } // Storage: Council Members (r:1 w:0) @@ -303,13 +303,13 @@ impl WeightInfo for () { // Storage: Council Voting (r:0 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn propose_proposed(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(48_107_905, 0)) - // Standard Error: 148 - .saturating_add((Weight::from_parts(4_689, 0)).saturating_mul(b as u64)) - // Standard Error: 1_547 - .saturating_add((Weight::from_parts(33_696, 0)).saturating_mul(m as u64)) - // Standard Error: 1_527 - .saturating_add((Weight::from_parts(306_730, 0)).saturating_mul(p as u64)) + (Weight::from_parts(49_784_354, 0)) + // Standard Error: 163 + .saturating_add((Weight::from_parts(4_191, 0)).saturating_mul(b as u64)) + // Standard Error: 1_705 + .saturating_add((Weight::from_parts(35_364, 0)).saturating_mul(m as u64)) + // Standard Error: 1_683 + .saturating_add((Weight::from_parts(301_218, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -318,58 +318,58 @@ impl WeightInfo for () { // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) fn vote(m: u32, ) -> Weight { - (Weight::from_parts(45_661_933, 0)) - // Standard Error: 1_152 - .saturating_add((Weight::from_parts(70_484, 0)).saturating_mul(m as u64)) + (Weight::from_parts(45_999_012, 0)) + // Standard Error: 944 + .saturating_add((Weight::from_parts(70_544, 0)).saturating_mul(m as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_early_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(65_240_157, 0)) - // Standard Error: 1_748 - .saturating_add((Weight::from_parts(56_035, 0)).saturating_mul(m as u64)) - // Standard Error: 1_704 - .saturating_add((Weight::from_parts(287_256, 0)).saturating_mul(p as u64)) + (Weight::from_parts(67_599_850, 0)) + // Standard Error: 1_737 + .saturating_add((Weight::from_parts(80_078, 0)).saturating_mul(m as u64)) + // Standard Error: 1_694 + .saturating_add((Weight::from_parts(294_524, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_early_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(90_748_886, 0)) - // Standard Error: 304 - .saturating_add((Weight::from_parts(2_436, 0)).saturating_mul(b as u64)) - // Standard Error: 3_220 - .saturating_add((Weight::from_parts(73_314, 0)).saturating_mul(m as u64)) - // Standard Error: 3_139 - .saturating_add((Weight::from_parts(313_478, 0)).saturating_mul(p as u64)) + (Weight::from_parts(94_619_427, 0)) + // Standard Error: 307 + .saturating_add((Weight::from_parts(2_144, 0)).saturating_mul(b as u64)) + // Standard Error: 3_251 + .saturating_add((Weight::from_parts(94_352, 0)).saturating_mul(m as u64)) + // Standard Error: 3_169 + .saturating_add((Weight::from_parts(315_046, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Proposals (r:1 w:1) @@ -377,20 +377,20 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn close_disapproved(m: u32, p: u32, ) -> Weight { - (Weight::from_parts(69_217_092, 0)) - // Standard Error: 1_867 - .saturating_add((Weight::from_parts(66_672, 0)).saturating_mul(m as u64)) - // Standard Error: 1_821 - .saturating_add((Weight::from_parts(286_625, 0)).saturating_mul(p as u64)) + (Weight::from_parts(71_391_246, 0)) + // Standard Error: 1_912 + .saturating_add((Weight::from_parts(92_748, 0)).saturating_mul(m as u64)) + // Standard Error: 1_865 + .saturating_add((Weight::from_parts(298_046, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } + // Storage: Council Members (r:1 w:0) + // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Voting (r:1 w:1) // Proof Skipped: Council Voting (max_values: None, max_size: None, mode: Measured) // Storage: Council ProposalProposedTime (r:1 w:1) // Proof Skipped: Council ProposalProposedTime (max_values: None, max_size: None, mode: Measured) - // Storage: Council Members (r:1 w:0) - // Proof Skipped: Council Members (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council Prime (r:1 w:0) // Proof Skipped: Council Prime (max_values: Some(1), max_size: None, mode: Measured) // Storage: Council ProposalOf (r:1 w:1) @@ -398,13 +398,13 @@ impl WeightInfo for () { // Storage: Council Proposals (r:1 w:1) // Proof Skipped: Council Proposals (max_values: Some(1), max_size: None, mode: Measured) fn close_approved(b: u32, m: u32, p: u32, ) -> Weight { - (Weight::from_parts(95_973_593, 0)) - // Standard Error: 310 - .saturating_add((Weight::from_parts(2_185, 0)).saturating_mul(b as u64)) - // Standard Error: 3_288 - .saturating_add((Weight::from_parts(68_870, 0)).saturating_mul(m as u64)) - // Standard Error: 3_205 - .saturating_add((Weight::from_parts(311_244, 0)).saturating_mul(p as u64)) + (Weight::from_parts(98_330_423, 0)) + // Standard Error: 297 + .saturating_add((Weight::from_parts(3_678, 0)).saturating_mul(b as u64)) + // Standard Error: 3_149 + .saturating_add((Weight::from_parts(97_124, 0)).saturating_mul(m as u64)) + // Standard Error: 3_070 + .saturating_add((Weight::from_parts(313_849, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -417,9 +417,9 @@ impl WeightInfo for () { // Storage: Council ProposalOf (r:0 w:1) // Proof Skipped: Council ProposalOf (max_values: None, max_size: None, mode: Measured) fn disapprove_proposal(p: u32, ) -> Weight { - (Weight::from_parts(36_150_886, 0)) - // Standard Error: 1_532 - .saturating_add((Weight::from_parts(281_687, 0)).saturating_mul(p as u64)) + (Weight::from_parts(36_844_726, 0)) + // Standard Error: 1_413 + .saturating_add((Weight::from_parts(281_628, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_crowdloan_rewards.rs b/runtime/mangata-rococo/src/weights/pallet_crowdloan_rewards.rs index dbdf56c152..a0016cb225 100644 --- a/runtime/mangata-rococo/src/weights/pallet_crowdloan_rewards.rs +++ b/runtime/mangata-rococo/src/weights/pallet_crowdloan_rewards.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_crowdloan_rewards //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,220 +68,234 @@ pub trait WeightInfo { /// Weights for pallet_crowdloan_rewards using the Mangata node and recommended hardware. pub struct ModuleWeight(PhantomData); impl pallet_crowdloan_rewards::WeightInfo for ModuleWeight { + // Storage: Crowdloan Initialized (r:1 w:0) + // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:0 w:1) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) fn set_crowdloan_allocation() -> Weight { - (Weight::from_parts(5_800_000, 0)) + (Weight::from_parts(13_860_000, 0)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:1) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:1) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:100 w:100) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:100 w:0) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:100 w:100) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: System Account (r:100 w:100) - // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:100 w:100) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn initialize_reward_vec(x: u32, ) -> Weight { - (Weight::from_parts(170_661_769, 0)) - // Standard Error: 50_081 - .saturating_add((Weight::from_parts(71_125_436, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().reads((5 as u64).saturating_mul(x as u64))) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - .saturating_add(T::DbWeight::get().writes((4 as u64).saturating_mul(x as u64))) + (Weight::from_parts(95_783_300, 0)) + // Standard Error: 25_873 + .saturating_add((Weight::from_parts(24_362_858, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(5 as u64)) + .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(x as u64))) + .saturating_add(T::DbWeight::get().writes(2 as u64)) + .saturating_add(T::DbWeight::get().writes((2 as u64).saturating_mul(x as u64))) } // Storage: Crowdloan Initialized (r:1 w:1) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:0) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:0 w:1) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanPeriod (r:0 w:1) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) fn complete_initialization() -> Weight { - (Weight::from_parts(21_060_000, 0)) + (Weight::from_parts(27_331_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Crowdloan CrowdloanPeriod (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) + // Storage: Vesting Vesting (r:1 w:1) + // Proof: Vesting Vesting (max_values: None, max_size: Some(1869), added: 4344, mode: MaxEncodedLen) + // Storage: Tokens Locks (r:1 w:1) + // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn claim() -> Weight { - (Weight::from_parts(68_230_000, 0)) - .saturating_add(T::DbWeight::get().reads(7 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) + (Weight::from_parts(129_060_000, 0)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn update_reward_address() -> Weight { - (Weight::from_parts(31_860_000, 0)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + (Weight::from_parts(34_900_000, 0)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:1 w:1) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:1 w:1) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:1 w:1) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn associate_native_identity() -> Weight { - (Weight::from_parts(147_350_000, 0)) - .saturating_add(T::DbWeight::get().reads(6 as u64)) - .saturating_add(T::DbWeight::get().writes(5 as u64)) + (Weight::from_parts(114_790_000, 0)) + .saturating_add(T::DbWeight::get().reads(4 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn change_association_with_relay_keys(x: u32, ) -> Weight { - (Weight::from_parts(34_693_550, 0)) - // Standard Error: 8_870 - .saturating_add((Weight::from_parts(62_853_805, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(2 as u64)) + (Weight::from_parts(42_648_512, 0)) + // Standard Error: 10_539 + .saturating_add((Weight::from_parts(63_038_369, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } } // For backwards compatibility and tests impl WeightInfo for () { + // Storage: Crowdloan Initialized (r:1 w:0) + // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:0 w:1) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) fn set_crowdloan_allocation() -> Weight { - (Weight::from_parts(5_800_000, 0)) + (Weight::from_parts(13_860_000, 0)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:1) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:1) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:100 w:100) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:100 w:0) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:100 w:100) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: System Account (r:100 w:100) - // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:100 w:100) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn initialize_reward_vec(x: u32, ) -> Weight { - (Weight::from_parts(170_661_769, 0)) - // Standard Error: 50_081 - .saturating_add((Weight::from_parts(71_125_436, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().reads((5 as u64).saturating_mul(x as u64))) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) - .saturating_add(RocksDbWeight::get().writes((4 as u64).saturating_mul(x as u64))) + (Weight::from_parts(95_783_300, 0)) + // Standard Error: 25_873 + .saturating_add((Weight::from_parts(24_362_858, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(5 as u64)) + .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(x as u64))) + .saturating_add(RocksDbWeight::get().writes(2 as u64)) + .saturating_add(RocksDbWeight::get().writes((2 as u64).saturating_mul(x as u64))) } // Storage: Crowdloan Initialized (r:1 w:1) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan InitializedRewardAmount (r:1 w:0) - // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan InitializedRewardAmount (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan CrowdloanAllocation (r:1 w:0) - // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan CrowdloanAllocation (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan TotalContributors (r:1 w:0) - // Proof Skipped: Crowdloan TotalContributors (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:0 w:1) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) + // Proof Skipped: Crowdloan TotalContributors (max_values: None, max_size: None, mode: Measured) + // Storage: Crowdloan CrowdloanPeriod (r:0 w:1) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) fn complete_initialization() -> Weight { - (Weight::from_parts(21_060_000, 0)) + (Weight::from_parts(27_331_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan Initialized (r:1 w:0) // Proof Skipped: Crowdloan Initialized (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Crowdloan InitRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan InitRelayBlock (max_values: Some(1), max_size: None, mode: Measured) - // Storage: Crowdloan EndRelayBlock (r:1 w:0) - // Proof Skipped: Crowdloan EndRelayBlock (max_values: Some(1), max_size: None, mode: Measured) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Crowdloan CrowdloanPeriod (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanPeriod (max_values: None, max_size: None, mode: Measured) + // Storage: Vesting Vesting (r:1 w:1) + // Proof: Vesting Vesting (max_values: None, max_size: Some(1869), added: 4344, mode: MaxEncodedLen) + // Storage: Tokens Locks (r:1 w:1) + // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn claim() -> Weight { - (Weight::from_parts(68_230_000, 0)) - .saturating_add(RocksDbWeight::get().reads(7 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + (Weight::from_parts(129_060_000, 0)) + .saturating_add(RocksDbWeight::get().reads(10 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn update_reward_address() -> Weight { - (Weight::from_parts(31_860_000, 0)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + (Weight::from_parts(34_900_000, 0)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan UnassociatedContributions (r:1 w:1) // Proof Skipped: Crowdloan UnassociatedContributions (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan ClaimedRelayChainIds (r:1 w:1) // Proof Skipped: Crowdloan ClaimedRelayChainIds (max_values: None, max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:1 w:1) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens NextCurrencyId (r:1 w:0) - // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:1 w:1) - // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn associate_native_identity() -> Weight { - (Weight::from_parts(147_350_000, 0)) - .saturating_add(RocksDbWeight::get().reads(6 as u64)) - .saturating_add(RocksDbWeight::get().writes(5 as u64)) + (Weight::from_parts(114_790_000, 0)) + .saturating_add(RocksDbWeight::get().reads(4 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) } + // Storage: Crowdloan CrowdloanId (r:1 w:0) + // Proof Skipped: Crowdloan CrowdloanId (max_values: Some(1), max_size: None, mode: Measured) // Storage: Crowdloan AccountsPayable (r:2 w:2) // Proof Skipped: Crowdloan AccountsPayable (max_values: None, max_size: None, mode: Measured) fn change_association_with_relay_keys(x: u32, ) -> Weight { - (Weight::from_parts(34_693_550, 0)) - // Standard Error: 8_870 - .saturating_add((Weight::from_parts(62_853_805, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(2 as u64)) + (Weight::from_parts(42_648_512, 0)) + // Standard Error: 10_539 + .saturating_add((Weight::from_parts(63_038_369, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } } diff --git a/runtime/mangata-rococo/src/weights/pallet_fee_lock.rs b/runtime/mangata-rococo/src/weights/pallet_fee_lock.rs index 5320f4b45e..7057d5cf29 100644 --- a/runtime/mangata-rococo/src/weights/pallet_fee_lock.rs +++ b/runtime/mangata-rococo/src/weights/pallet_fee_lock.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_fee_lock //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -66,7 +66,7 @@ impl pallet_fee_lock::WeightInfo for ModuleWeight { // Storage: FeeLock FeeLockMetadata (r:1 w:1) // Proof: FeeLock FeeLockMetadata (max_values: Some(1), max_size: Some(438), added: 933, mode: MaxEncodedLen) fn update_fee_lock_metadata() -> Weight { - (Weight::from_parts(30_789_000, 0)) + (Weight::from_parts(31_000_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -81,7 +81,7 @@ impl pallet_fee_lock::WeightInfo for ModuleWeight { // Storage: FeeLock UnlockQueue (r:1 w:1) // Proof: FeeLock UnlockQueue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) fn unlock_fee() -> Weight { - (Weight::from_parts(56_080_000, 0)) + (Weight::from_parts(56_920_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -92,7 +92,7 @@ impl WeightInfo for () { // Storage: FeeLock FeeLockMetadata (r:1 w:1) // Proof: FeeLock FeeLockMetadata (max_values: Some(1), max_size: Some(438), added: 933, mode: MaxEncodedLen) fn update_fee_lock_metadata() -> Weight { - (Weight::from_parts(30_789_000, 0)) + (Weight::from_parts(31_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -107,7 +107,7 @@ impl WeightInfo for () { // Storage: FeeLock UnlockQueue (r:1 w:1) // Proof: FeeLock UnlockQueue (max_values: None, max_size: Some(56), added: 2531, mode: MaxEncodedLen) fn unlock_fee() -> Weight { - (Weight::from_parts(56_080_000, 0)) + (Weight::from_parts(56_920_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_issuance.rs b/runtime/mangata-rococo/src/weights/pallet_issuance.rs index 5df4b34f6d..c7f3821ac2 100644 --- a/runtime/mangata-rococo/src/weights/pallet_issuance.rs +++ b/runtime/mangata-rococo/src/weights/pallet_issuance.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_issuance //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -71,14 +71,14 @@ impl pallet_issuance::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:0) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn init_issuance_config() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_870_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Issuance IsTGEFinalized (r:1 w:1) // Proof Skipped: Issuance IsTGEFinalized (max_values: Some(1), max_size: None, mode: Measured) fn finalize_tge() -> Weight { - (Weight::from_parts(15_849_000, 0)) + (Weight::from_parts(15_920_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -97,9 +97,9 @@ impl pallet_issuance::WeightInfo for ModuleWeight { // Storage: Issuance TGETotal (r:1 w:1) // Proof Skipped: Issuance TGETotal (max_values: Some(1), max_size: None, mode: Measured) fn execute_tge(x: u32, ) -> Weight { - (Weight::from_parts(26_585_737, 0)) - // Standard Error: 16_829 - .saturating_add((Weight::from_parts(83_061_110, 0)).saturating_mul(x as u64)) + (Weight::from_parts(32_064_606, 0)) + // Standard Error: 26_264 + .saturating_add((Weight::from_parts(85_431_002, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(2 as u64)) @@ -116,14 +116,14 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:0) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn init_issuance_config() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_870_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Issuance IsTGEFinalized (r:1 w:1) // Proof Skipped: Issuance IsTGEFinalized (max_values: Some(1), max_size: None, mode: Measured) fn finalize_tge() -> Weight { - (Weight::from_parts(15_849_000, 0)) + (Weight::from_parts(15_920_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -142,9 +142,9 @@ impl WeightInfo for () { // Storage: Issuance TGETotal (r:1 w:1) // Proof Skipped: Issuance TGETotal (max_values: Some(1), max_size: None, mode: Measured) fn execute_tge(x: u32, ) -> Weight { - (Weight::from_parts(26_585_737, 0)) - // Standard Error: 16_829 - .saturating_add((Weight::from_parts(83_061_110, 0)).saturating_mul(x as u64)) + (Weight::from_parts(32_064_606, 0)) + // Standard Error: 26_264 + .saturating_add((Weight::from_parts(85_431_002, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(2 as u64)) diff --git a/runtime/mangata-rococo/src/weights/pallet_multipurpose_liquidity.rs b/runtime/mangata-rococo/src/weights/pallet_multipurpose_liquidity.rs index 3fb479e9b7..4e536d93e4 100644 --- a/runtime/mangata-rococo/src/weights/pallet_multipurpose_liquidity.rs +++ b/runtime/mangata-rococo/src/weights/pallet_multipurpose_liquidity.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_multipurpose_liquidity //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -76,7 +76,7 @@ impl pallet_multipurpose_liquidity::WeightInfo for Modu // Storage: MultiPurposeLiquidity RelockStatus (r:1 w:1) // Proof: MultiPurposeLiquidity RelockStatus (max_values: None, max_size: Some(1845), added: 4320, mode: MaxEncodedLen) fn reserve_vesting_liquidity_tokens() -> Weight { - (Weight::from_parts(127_250_000, 0)) + (Weight::from_parts(130_870_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -91,7 +91,7 @@ impl pallet_multipurpose_liquidity::WeightInfo for Modu // Storage: Tokens Locks (r:1 w:1) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn unreserve_and_relock_instance() -> Weight { - (Weight::from_parts(122_689_000, 0)) + (Weight::from_parts(126_300_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -112,7 +112,7 @@ impl WeightInfo for () { // Storage: MultiPurposeLiquidity RelockStatus (r:1 w:1) // Proof: MultiPurposeLiquidity RelockStatus (max_values: None, max_size: Some(1845), added: 4320, mode: MaxEncodedLen) fn reserve_vesting_liquidity_tokens() -> Weight { - (Weight::from_parts(127_250_000, 0)) + (Weight::from_parts(130_870_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -127,7 +127,7 @@ impl WeightInfo for () { // Storage: Tokens Locks (r:1 w:1) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn unreserve_and_relock_instance() -> Weight { - (Weight::from_parts(122_689_000, 0)) + (Weight::from_parts(126_300_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs b/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs index 99a6a2573d..6aac9c8080 100644 --- a/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs +++ b/runtime/mangata-rococo/src/weights/pallet_proof_of_stake.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_proof_of_stake //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -57,13 +57,13 @@ use sp_std::marker::PhantomData; /// Weight functions needed for pallet_proof_of_stake. pub trait WeightInfo { fn claim_native_rewards() -> Weight; - fn claim_3rdparty_rewards() -> Weight; fn update_pool_promotion() -> Weight; fn activate_liquidity_for_native_rewards() -> Weight; fn deactivate_liquidity_for_native_rewards() -> Weight; - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; - fn activate_liquidity_for_3rdparty_rewards() -> Weight; fn reward_pool() -> Weight; + fn activate_liquidity_for_3rdparty_rewards() -> Weight; + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight; + fn claim_3rdparty_rewards() -> Weight; } /// Weights for pallet_proof_of_stake using the Mangata node and recommended hardware. @@ -76,20 +76,14 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn claim_native_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) - .saturating_add(T::DbWeight::get().reads(4 as u64)) - .saturating_add(T::DbWeight::get().writes(3 as u64)) - } - - fn claim_3rdparty_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) + (Weight::from_parts(86_750_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { - (Weight::from_parts(18_600_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -104,7 +98,7 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(94_130_000, 0)) + (Weight::from_parts(100_109_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } @@ -119,61 +113,113 @@ impl pallet_proof_of_stake::WeightInfo for ModuleWeight // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn deactivate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(82_600_000, 0)) + (Weight::from_parts(91_990_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } - - - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Xyk LiquidityPools (r:1 w:0) + // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) + // Storage: Xyk Pools (r:1 w:0) + // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleId (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:0 w:1) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + fn reward_pool() -> Weight { + (Weight::from_parts(179_050_000, 0)) + .saturating_add(T::DbWeight::get().reads(9 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } - + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + (Weight::from_parts(120_360_000, 0)) + .saturating_add(T::DbWeight::get().reads(10 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } - - fn reward_pool() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:2 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(125_160_000, 0)) + .saturating_add(T::DbWeight::get().reads(11 as u64)) + .saturating_add(T::DbWeight::get().writes(6 as u64)) } -} - -// For backwards compatibility and tests -impl WeightInfo for () { // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ProofOfStake RewardsInfo (r:1 w:1) - // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_native_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) - .saturating_add(RocksDbWeight::get().reads(4 as u64)) - .saturating_add(RocksDbWeight::get().writes(3 as u64)) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(94_980_000, 0)) + .saturating_add(T::DbWeight::get().reads(7 as u64)) + .saturating_add(T::DbWeight::get().writes(3 as u64)) } +} +// For backwards compatibility and tests +impl WeightInfo for () { // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake RewardsInfo (r:1 w:1) // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - fn claim_3rdparty_rewards() -> Weight { - (Weight::from_parts(81_410_000, 0)) + fn claim_native_rewards() -> Weight { + (Weight::from_parts(86_750_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } - // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn update_pool_promotion() -> Weight { - (Weight::from_parts(18_600_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -188,7 +234,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(94_130_000, 0)) + (Weight::from_parts(100_109_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } @@ -203,27 +249,92 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn deactivate_liquidity_for_native_rewards() -> Weight { - (Weight::from_parts(82_600_000, 0)) + (Weight::from_parts(91_990_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } - - fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Xyk LiquidityPools (r:1 w:0) + // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) + // Storage: Xyk Pools (r:1 w:0) + // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: System Account (r:1 w:1) + // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleId (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleId (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:0 w:1) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + fn reward_pool() -> Weight { + (Weight::from_parts(179_050_000, 0)) + .saturating_add(RocksDbWeight::get().reads(9 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } - + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) fn activate_liquidity_for_3rdparty_rewards() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + (Weight::from_parts(120_360_000, 0)) + .saturating_add(RocksDbWeight::get().reads(10 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) } - - fn reward_pool() -> Weight { - (Weight::from_parts(118_250_000, 0)) - .saturating_add(RocksDbWeight::get().reads(5 as u64)) - .saturating_add(RocksDbWeight::get().writes(4 as u64)) + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake TotalActivatedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake TotalActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLiquidityForSchedules (r:2 w:1) + // Proof Skipped: ProofOfStake ActivatedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ActivatedLockedLiquidityForSchedules (r:1 w:1) + // Proof Skipped: ProofOfStake ActivatedLockedLiquidityForSchedules (max_values: None, max_size: None, mode: Measured) + // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) + // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) + // Storage: Tokens Accounts (r:1 w:1) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn deactivate_liquidity_for_3rdparty_rewards() -> Weight { + (Weight::from_parts(125_160_000, 0)) + .saturating_add(RocksDbWeight::get().reads(11 as u64)) + .saturating_add(RocksDbWeight::get().writes(6 as u64)) + } + // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) + // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardTokensPerPool (r:2 w:0) + // Proof Skipped: ProofOfStake RewardTokensPerPool (max_values: None, max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:0) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsInfoForScheduleRewards (r:1 w:1) + // Proof Skipped: ProofOfStake RewardsInfoForScheduleRewards (max_values: None, max_size: None, mode: Measured) + // Storage: Tokens Accounts (r:2 w:2) + // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + fn claim_3rdparty_rewards() -> Weight { + (Weight::from_parts(94_980_000, 0)) + .saturating_add(RocksDbWeight::get().reads(7 as u64)) + .saturating_add(RocksDbWeight::get().writes(3 as u64)) } - } diff --git a/runtime/mangata-rococo/src/weights/pallet_session.rs b/runtime/mangata-rococo/src/weights/pallet_session.rs index 1a2b8fef84..3b9299b1a8 100644 --- a/runtime/mangata-rococo/src/weights/pallet_session.rs +++ b/runtime/mangata-rococo/src/weights/pallet_session.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_session //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,7 +68,7 @@ impl pallet_session::WeightInfo for ModuleWeight { // Storage: Session KeyOwner (r:1 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_480_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -77,7 +77,7 @@ impl pallet_session::WeightInfo for ModuleWeight { // Storage: Session KeyOwner (r:0 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - (Weight::from_parts(17_900_000, 0)) + (Weight::from_parts(17_880_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -90,7 +90,7 @@ impl WeightInfo for () { // Storage: Session KeyOwner (r:1 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn set_keys() -> Weight { - (Weight::from_parts(27_420_000, 0)) + (Weight::from_parts(27_480_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -99,7 +99,7 @@ impl WeightInfo for () { // Storage: Session KeyOwner (r:0 w:1) // Proof Skipped: Session KeyOwner (max_values: None, max_size: None, mode: Measured) fn purge_keys() -> Weight { - (Weight::from_parts(17_900_000, 0)) + (Weight::from_parts(17_880_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_timestamp.rs b/runtime/mangata-rococo/src/weights/pallet_timestamp.rs index a2a3ba9ec3..a32d4dafb2 100644 --- a/runtime/mangata-rococo/src/weights/pallet_timestamp.rs +++ b/runtime/mangata-rococo/src/weights/pallet_timestamp.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_timestamp //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -66,12 +66,12 @@ impl pallet_timestamp::WeightInfo for ModuleWeight { // Storage: Timestamp Now (r:1 w:1) // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - (Weight::from_parts(11_000_000, 0)) + (Weight::from_parts(10_120_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (Weight::from_parts(5_280_000, 0)) + (Weight::from_parts(5_220_000, 0)) } } @@ -80,11 +80,11 @@ impl WeightInfo for () { // Storage: Timestamp Now (r:1 w:1) // Proof: Timestamp Now (max_values: Some(1), max_size: Some(8), added: 503, mode: MaxEncodedLen) fn set() -> Weight { - (Weight::from_parts(11_000_000, 0)) + (Weight::from_parts(10_120_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } fn on_finalize() -> Weight { - (Weight::from_parts(5_280_000, 0)) + (Weight::from_parts(5_220_000, 0)) } } diff --git a/runtime/mangata-rococo/src/weights/pallet_treasury.rs b/runtime/mangata-rococo/src/weights/pallet_treasury.rs index 34eb8ab30f..89616a60b5 100644 --- a/runtime/mangata-rococo/src/weights/pallet_treasury.rs +++ b/runtime/mangata-rococo/src/weights/pallet_treasury.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_treasury //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -68,7 +68,7 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl pallet_treasury::WeightInfo for ModuleWeight { fn spend() -> Weight { - (Weight::from_parts(420_000, 0)) + (Weight::from_parts(530_000, 0)) } // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -77,7 +77,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Treasury Proposals (r:0 w:1) // Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - (Weight::from_parts(45_080_000, 0)) + (Weight::from_parts(46_150_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -88,7 +88,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - (Weight::from_parts(50_770_000, 0)) + (Weight::from_parts(52_520_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -97,16 +97,16 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_proposal(p: u32, ) -> Weight { - (Weight::from_parts(20_245_010, 0)) - // Standard Error: 1_597 - .saturating_add((Weight::from_parts(65_488, 0)).saturating_mul(p as u64)) + (Weight::from_parts(20_564_531, 0)) + // Standard Error: 1_841 + .saturating_add((Weight::from_parts(64_381, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - (Weight::from_parts(12_149_000, 0)) + (Weight::from_parts(12_011_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -121,9 +121,9 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn on_initialize_proposals(p: u32, ) -> Weight { - (Weight::from_parts(40_502_670, 0)) - // Standard Error: 6_134 - .saturating_add((Weight::from_parts(4_155_700, 0)).saturating_mul(p as u64)) + (Weight::from_parts(41_108_943, 0)) + // Standard Error: 7_113 + .saturating_add((Weight::from_parts(4_261_200, 0)).saturating_mul(p as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -133,7 +133,7 @@ impl pallet_treasury::WeightInfo for ModuleWeight { // For backwards compatibility and tests impl WeightInfo for () { fn spend() -> Weight { - (Weight::from_parts(420_000, 0)) + (Weight::from_parts(530_000, 0)) } // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -142,7 +142,7 @@ impl WeightInfo for () { // Storage: Treasury Proposals (r:0 w:1) // Proof: Treasury Proposals (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn propose_spend() -> Weight { - (Weight::from_parts(45_080_000, 0)) + (Weight::from_parts(46_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -153,7 +153,7 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn reject_proposal() -> Weight { - (Weight::from_parts(50_770_000, 0)) + (Weight::from_parts(52_520_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -162,16 +162,16 @@ impl WeightInfo for () { // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn approve_proposal(p: u32, ) -> Weight { - (Weight::from_parts(20_245_010, 0)) - // Standard Error: 1_597 - .saturating_add((Weight::from_parts(65_488, 0)).saturating_mul(p as u64)) + (Weight::from_parts(20_564_531, 0)) + // Standard Error: 1_841 + .saturating_add((Weight::from_parts(64_381, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: Treasury Approvals (r:1 w:1) // Proof: Treasury Approvals (max_values: Some(1), max_size: Some(402), added: 897, mode: MaxEncodedLen) fn remove_approval() -> Weight { - (Weight::from_parts(12_149_000, 0)) + (Weight::from_parts(12_011_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -186,9 +186,9 @@ impl WeightInfo for () { // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn on_initialize_proposals(p: u32, ) -> Weight { - (Weight::from_parts(40_502_670, 0)) - // Standard Error: 6_134 - .saturating_add((Weight::from_parts(4_155_700, 0)).saturating_mul(p as u64)) + (Weight::from_parts(41_108_943, 0)) + // Standard Error: 7_113 + .saturating_add((Weight::from_parts(4_261_200, 0)).saturating_mul(p as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(p as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) diff --git a/runtime/mangata-rococo/src/weights/pallet_utility_mangata.rs b/runtime/mangata-rococo/src/weights/pallet_utility_mangata.rs index 8f55cdf831..933c8abfba 100644 --- a/runtime/mangata-rococo/src/weights/pallet_utility_mangata.rs +++ b/runtime/mangata-rococo/src/weights/pallet_utility_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_utility_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -67,49 +67,49 @@ pub trait WeightInfo { pub struct ModuleWeight(PhantomData); impl pallet_utility_mangata::WeightInfo for ModuleWeight { fn batch(c: u32, ) -> Weight { - (Weight::from_parts(19_140_183, 0)) - // Standard Error: 3_444 - .saturating_add((Weight::from_parts(9_410_608, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_547_364, 0)) + // Standard Error: 3_907 + .saturating_add((Weight::from_parts(9_787_750, 0)).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (Weight::from_parts(10_120_000, 0)) + (Weight::from_parts(10_100_000, 0)) } fn batch_all(c: u32, ) -> Weight { - (Weight::from_parts(14_978_625, 0)) - // Standard Error: 2_992 - .saturating_add((Weight::from_parts(9_802_086, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_586_041, 0)) + // Standard Error: 3_411 + .saturating_add((Weight::from_parts(10_269_425, 0)).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (Weight::from_parts(16_510_000, 0)) + (Weight::from_parts(17_000_000, 0)) } fn force_batch(c: u32, ) -> Weight { - (Weight::from_parts(18_073_256, 0)) - // Standard Error: 3_525 - .saturating_add((Weight::from_parts(9_368_770, 0)).saturating_mul(c as u64)) + (Weight::from_parts(13_747_173, 0)) + // Standard Error: 3_163 + .saturating_add((Weight::from_parts(9_823_460, 0)).saturating_mul(c as u64)) } } // For backwards compatibility and tests impl WeightInfo for () { fn batch(c: u32, ) -> Weight { - (Weight::from_parts(19_140_183, 0)) - // Standard Error: 3_444 - .saturating_add((Weight::from_parts(9_410_608, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_547_364, 0)) + // Standard Error: 3_907 + .saturating_add((Weight::from_parts(9_787_750, 0)).saturating_mul(c as u64)) } fn as_derivative() -> Weight { - (Weight::from_parts(10_120_000, 0)) + (Weight::from_parts(10_100_000, 0)) } fn batch_all(c: u32, ) -> Weight { - (Weight::from_parts(14_978_625, 0)) - // Standard Error: 2_992 - .saturating_add((Weight::from_parts(9_802_086, 0)).saturating_mul(c as u64)) + (Weight::from_parts(9_586_041, 0)) + // Standard Error: 3_411 + .saturating_add((Weight::from_parts(10_269_425, 0)).saturating_mul(c as u64)) } fn dispatch_as() -> Weight { - (Weight::from_parts(16_510_000, 0)) + (Weight::from_parts(17_000_000, 0)) } fn force_batch(c: u32, ) -> Weight { - (Weight::from_parts(18_073_256, 0)) - // Standard Error: 3_525 - .saturating_add((Weight::from_parts(9_368_770, 0)).saturating_mul(c as u64)) + (Weight::from_parts(13_747_173, 0)) + // Standard Error: 3_163 + .saturating_add((Weight::from_parts(9_823_460, 0)).saturating_mul(c as u64)) } } diff --git a/runtime/mangata-rococo/src/weights/pallet_vesting_mangata.rs b/runtime/mangata-rococo/src/weights/pallet_vesting_mangata.rs index f58fc1d6e6..1c975632c9 100644 --- a/runtime/mangata-rococo/src/weights/pallet_vesting_mangata.rs +++ b/runtime/mangata-rococo/src/weights/pallet_vesting_mangata.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_vesting_mangata //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -75,9 +75,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(52_309_417, 0)) - // Standard Error: 7_565 - .saturating_add((Weight::from_parts(219_965, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_243_152, 0)) + // Standard Error: 7_939 + .saturating_add((Weight::from_parts(234_970, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -88,9 +88,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_355_755, 0)) - // Standard Error: 3_270 - .saturating_add((Weight::from_parts(44_362, 0)).saturating_mul(s as u64)) + (Weight::from_parts(73_252_114, 0)) + // Standard Error: 3_434 + .saturating_add((Weight::from_parts(27_698, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -101,9 +101,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_other_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_645_987, 0)) - // Standard Error: 7_779 - .saturating_add((Weight::from_parts(207_339, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_977_339, 0)) + // Standard Error: 7_858 + .saturating_add((Weight::from_parts(223_279, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -116,9 +116,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn vest_other_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_436_663, 0)) - // Standard Error: 2_844 - .saturating_add((Weight::from_parts(76_147, 0)).saturating_mul(s as u64)) + (Weight::from_parts(72_574_520, 0)) + // Standard Error: 3_250 + .saturating_add((Weight::from_parts(67_290, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -131,9 +131,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Locks (r:1 w:0) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn force_vested_transfer(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(83_196_714, 0)) - // Standard Error: 29_574 - .saturating_add((Weight::from_parts(415_253, 0)).saturating_mul(s as u64)) + (Weight::from_parts(88_550_017, 0)) + // Standard Error: 13_455 + .saturating_add((Weight::from_parts(335_869, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } @@ -144,9 +144,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn not_unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(54_058_391, 0)) - // Standard Error: 7_609 - .saturating_add((Weight::from_parts(223_040, 0)).saturating_mul(s as u64)) + (Weight::from_parts(54_212_340, 0)) + // Standard Error: 8_032 + .saturating_add((Weight::from_parts(248_035, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -157,9 +157,9 @@ impl pallet_vesting_mangata::WeightInfo for ModuleWeigh // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_022_178, 0)) - // Standard Error: 12_945 - .saturating_add((Weight::from_parts(320_024, 0)).saturating_mul(s as u64)) + (Weight::from_parts(52_783_090, 0)) + // Standard Error: 13_737 + .saturating_add((Weight::from_parts(346_445, 0)).saturating_mul(s as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -174,9 +174,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(52_309_417, 0)) - // Standard Error: 7_565 - .saturating_add((Weight::from_parts(219_965, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_243_152, 0)) + // Standard Error: 7_939 + .saturating_add((Weight::from_parts(234_970, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -187,9 +187,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_355_755, 0)) - // Standard Error: 3_270 - .saturating_add((Weight::from_parts(44_362, 0)).saturating_mul(s as u64)) + (Weight::from_parts(73_252_114, 0)) + // Standard Error: 3_434 + .saturating_add((Weight::from_parts(27_698, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -200,9 +200,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn vest_other_locked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_645_987, 0)) - // Standard Error: 7_779 - .saturating_add((Weight::from_parts(207_339, 0)).saturating_mul(s as u64)) + (Weight::from_parts(53_977_339, 0)) + // Standard Error: 7_858 + .saturating_add((Weight::from_parts(223_279, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -215,9 +215,9 @@ impl WeightInfo for () { // Storage: System Account (r:1 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn vest_other_unlocked(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(70_436_663, 0)) - // Standard Error: 2_844 - .saturating_add((Weight::from_parts(76_147, 0)).saturating_mul(s as u64)) + (Weight::from_parts(72_574_520, 0)) + // Standard Error: 3_250 + .saturating_add((Weight::from_parts(67_290, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -230,9 +230,9 @@ impl WeightInfo for () { // Storage: Tokens Locks (r:1 w:0) // Proof: Tokens Locks (max_values: None, max_size: Some(1261), added: 3736, mode: MaxEncodedLen) fn force_vested_transfer(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(83_196_714, 0)) - // Standard Error: 29_574 - .saturating_add((Weight::from_parts(415_253, 0)).saturating_mul(s as u64)) + (Weight::from_parts(88_550_017, 0)) + // Standard Error: 13_455 + .saturating_add((Weight::from_parts(335_869, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } @@ -243,9 +243,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn not_unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(54_058_391, 0)) - // Standard Error: 7_609 - .saturating_add((Weight::from_parts(223_040, 0)).saturating_mul(s as u64)) + (Weight::from_parts(54_212_340, 0)) + // Standard Error: 8_032 + .saturating_add((Weight::from_parts(248_035, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -256,9 +256,9 @@ impl WeightInfo for () { // Storage: Tokens Accounts (r:1 w:1) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) fn unlocking_merge_schedules(_l: u32, s: u32, ) -> Weight { - (Weight::from_parts(53_022_178, 0)) - // Standard Error: 12_945 - .saturating_add((Weight::from_parts(320_024, 0)).saturating_mul(s as u64)) + (Weight::from_parts(52_783_090, 0)) + // Standard Error: 13_737 + .saturating_add((Weight::from_parts(346_445, 0)).saturating_mul(s as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/pallet_xyk.rs b/runtime/mangata-rococo/src/weights/pallet_xyk.rs index 62a52673ce..c1f831ff19 100644 --- a/runtime/mangata-rococo/src/weights/pallet_xyk.rs +++ b/runtime/mangata-rococo/src/weights/pallet_xyk.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for pallet_xyk //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -90,7 +90,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: Xyk LiquidityPools (r:0 w:1) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn create_pool() -> Weight { - (Weight::from_parts(199_311_000, 0)) + (Weight::from_parts(202_790_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) .saturating_add(T::DbWeight::get().writes(12 as u64)) } @@ -98,6 +98,10 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:3 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -105,12 +109,16 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn sell_asset() -> Weight { - (Weight::from_parts(226_860_000, 0)) - .saturating_add(T::DbWeight::get().reads(14 as u64)) + (Weight::from_parts(244_940_000, 0)) + .saturating_add(T::DbWeight::get().reads(16 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) // Storage: Xyk Pools (r:297 w:198) @@ -119,14 +127,12 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_sell_asset(x: u32, ) -> Weight { - (Weight::from_parts(618_130_000, 0)) - // Standard Error: 306_187 - .saturating_add((Weight::from_parts(245_461_340, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(661_629_000, 0)) + // Standard Error: 425_962 + .saturating_add((Weight::from_parts(272_288_151, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -134,6 +140,10 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -141,28 +151,30 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn buy_asset() -> Weight { - (Weight::from_parts(233_140_000, 0)) - .saturating_add(T::DbWeight::get().reads(15 as u64)) + (Weight::from_parts(253_260_000, 0)) + .saturating_add(T::DbWeight::get().reads(18 as u64)) .saturating_add(T::DbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:297 w:198) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:400 w:400) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_buy_asset(x: u32, ) -> Weight { - (Weight::from_parts(632_069_000, 0)) - // Standard Error: 339_491 - .saturating_add((Weight::from_parts(252_882_037, 0)).saturating_mul(x as u64)) - .saturating_add(T::DbWeight::get().reads(1 as u64)) - .saturating_add(T::DbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(691_040_000, 0)) + // Standard Error: 480_931 + .saturating_add((Weight::from_parts(286_614_272, 0)).saturating_mul(x as u64)) + .saturating_add(T::DbWeight::get().reads(29 as u64)) + .saturating_add(T::DbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) .saturating_add(T::DbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -187,7 +199,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn mint_liquidity() -> Weight { - (Weight::from_parts(234_080_000, 0)) + (Weight::from_parts(241_610_000, 0)) .saturating_add(T::DbWeight::get().reads(15 as u64)) .saturating_add(T::DbWeight::get().writes(10 as u64)) } @@ -208,17 +220,17 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn mint_liquidity_using_vesting_native_tokens() -> Weight { - (Weight::from_parts(270_350_000, 0)) + (Weight::from_parts(277_529_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) .saturating_add(T::DbWeight::get().writes(11 as u64)) } // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:1 w:2) + // Storage: Xyk LiquidityAssets (r:1 w:0) // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Xyk Pools (r:1 w:2) + // Storage: Xyk Pools (r:1 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:5 w:5) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -230,17 +242,19 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityPools (r:0 w:1) - // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn burn_liquidity() -> Weight { - (Weight::from_parts(216_470_000, 0)) + (Weight::from_parts(223_960_000, 0)) .saturating_add(T::DbWeight::get().reads(14 as u64)) - .saturating_add(T::DbWeight::get().writes(14 as u64)) + .saturating_add(T::DbWeight::get().writes(10 as u64)) } // Storage: Xyk LiquidityPools (r:1 w:0) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:7 w:7) @@ -249,16 +263,12 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn provide_liquidity_with_conversion() -> Weight { - (Weight::from_parts(369_290_000, 0)) + (Weight::from_parts(386_749_000, 0)) .saturating_add(T::DbWeight::get().reads(22 as u64)) .saturating_add(T::DbWeight::get().writes(11 as u64)) } @@ -272,16 +282,16 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:8 w:8) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:2 w:2) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:2 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:2 w:2) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) @@ -289,7 +299,7 @@ impl pallet_xyk::WeightInfo for ModuleWeight { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn compound_rewards() -> Weight { - (Weight::from_parts(514_330_000, 0)) + (Weight::from_parts(546_000_000, 0)) .saturating_add(T::DbWeight::get().reads(25 as u64)) .saturating_add(T::DbWeight::get().writes(16 as u64)) } @@ -316,7 +326,7 @@ impl WeightInfo for () { // Storage: Xyk LiquidityPools (r:0 w:1) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn create_pool() -> Weight { - (Weight::from_parts(199_311_000, 0)) + (Weight::from_parts(202_790_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) .saturating_add(RocksDbWeight::get().writes(12 as u64)) } @@ -324,6 +334,10 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:1 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:3 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -331,12 +345,16 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn sell_asset() -> Weight { - (Weight::from_parts(226_860_000, 0)) - .saturating_add(RocksDbWeight::get().reads(14 as u64)) + (Weight::from_parts(244_940_000, 0)) + .saturating_add(RocksDbWeight::get().reads(16 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) // Storage: Xyk Pools (r:297 w:198) @@ -345,14 +363,12 @@ impl WeightInfo for () { // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_sell_asset(x: u32, ) -> Weight { - (Weight::from_parts(618_130_000, 0)) - // Standard Error: 306_187 - .saturating_add((Weight::from_parts(245_461_340, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(661_629_000, 0)) + // Standard Error: 425_962 + .saturating_add((Weight::from_parts(272_288_151, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(29 as u64)) + .saturating_add(RocksDbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) .saturating_add(RocksDbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -360,6 +376,10 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:0) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:6 w:6) @@ -367,28 +387,30 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn buy_asset() -> Weight { - (Weight::from_parts(233_140_000, 0)) - .saturating_add(RocksDbWeight::get().reads(15 as u64)) + (Weight::from_parts(253_260_000, 0)) + .saturating_add(RocksDbWeight::get().reads(18 as u64)) .saturating_add(RocksDbWeight::get().writes(9 as u64)) } // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:100 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:99 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:100 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:297 w:198) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:400 w:400) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) fn multiswap_buy_asset(x: u32, ) -> Weight { - (Weight::from_parts(632_069_000, 0)) - // Standard Error: 339_491 - .saturating_add((Weight::from_parts(252_882_037, 0)).saturating_mul(x as u64)) - .saturating_add(RocksDbWeight::get().reads(1 as u64)) - .saturating_add(RocksDbWeight::get().reads((8 as u64).saturating_mul(x as u64))) + (Weight::from_parts(691_040_000, 0)) + // Standard Error: 480_931 + .saturating_add((Weight::from_parts(286_614_272, 0)).saturating_mul(x as u64)) + .saturating_add(RocksDbWeight::get().reads(29 as u64)) + .saturating_add(RocksDbWeight::get().reads((10 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) .saturating_add(RocksDbWeight::get().writes((6 as u64).saturating_mul(x as u64))) } @@ -413,7 +435,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn mint_liquidity() -> Weight { - (Weight::from_parts(234_080_000, 0)) + (Weight::from_parts(241_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(15 as u64)) .saturating_add(RocksDbWeight::get().writes(10 as u64)) } @@ -434,17 +456,17 @@ impl WeightInfo for () { // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) fn mint_liquidity_using_vesting_native_tokens() -> Weight { - (Weight::from_parts(270_350_000, 0)) + (Weight::from_parts(277_529_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) .saturating_add(RocksDbWeight::get().writes(11 as u64)) } // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:1 w:2) + // Storage: Xyk LiquidityAssets (r:1 w:0) // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Xyk Pools (r:1 w:2) + // Storage: Xyk Pools (r:1 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:5 w:5) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) @@ -456,17 +478,19 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens TotalIssuance (r:1 w:1) // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityPools (r:0 w:1) - // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) fn burn_liquidity() -> Weight { - (Weight::from_parts(216_470_000, 0)) + (Weight::from_parts(223_960_000, 0)) .saturating_add(RocksDbWeight::get().reads(14 as u64)) - .saturating_add(RocksDbWeight::get().writes(14 as u64)) + .saturating_add(RocksDbWeight::get().writes(10 as u64)) } // Storage: Xyk LiquidityPools (r:1 w:0) // Proof: Xyk LiquidityPools (max_values: None, max_size: Some(41), added: 2516, mode: MaxEncodedLen) // Storage: AssetRegistry Metadata (r:2 w:0) // Proof Skipped: AssetRegistry Metadata (max_values: None, max_size: None, mode: Measured) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:1 w:1) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:4 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Tokens Accounts (r:7 w:7) @@ -475,16 +499,12 @@ impl WeightInfo for () { // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) - // Storage: Tokens TotalIssuance (r:1 w:1) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:0) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) fn provide_liquidity_with_conversion() -> Weight { - (Weight::from_parts(369_290_000, 0)) + (Weight::from_parts(386_749_000, 0)) .saturating_add(RocksDbWeight::get().reads(22 as u64)) .saturating_add(RocksDbWeight::get().writes(11 as u64)) } @@ -498,16 +518,16 @@ impl WeightInfo for () { // Proof Skipped: ProofOfStake RewardsInfo (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:8 w:8) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) + // Storage: Xyk LiquidityAssets (r:2 w:0) + // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) + // Storage: Tokens TotalIssuance (r:2 w:2) + // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) // Storage: Xyk Pools (r:2 w:1) // Proof: Xyk Pools (max_values: None, max_size: Some(64), added: 2539, mode: MaxEncodedLen) // Storage: Maintenance MaintenanceStatus (r:1 w:0) // Proof: Maintenance MaintenanceStatus (max_values: Some(1), max_size: Some(2), added: 497, mode: MaxEncodedLen) // Storage: System Account (r:2 w:2) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens TotalIssuance (r:2 w:2) - // Proof: Tokens TotalIssuance (max_values: None, max_size: Some(28), added: 2503, mode: MaxEncodedLen) - // Storage: Xyk LiquidityAssets (r:2 w:0) - // Proof: Xyk LiquidityAssets (max_values: None, max_size: Some(37), added: 2512, mode: MaxEncodedLen) // Storage: Tokens NextCurrencyId (r:1 w:0) // Proof: Tokens NextCurrencyId (max_values: Some(1), max_size: Some(4), added: 499, mode: MaxEncodedLen) // Storage: MultiPurposeLiquidity ReserveStatus (r:1 w:1) @@ -515,7 +535,7 @@ impl WeightInfo for () { // Storage: ProofOfStake TotalActivatedLiquidity (r:1 w:1) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) fn compound_rewards() -> Weight { - (Weight::from_parts(514_330_000, 0)) + (Weight::from_parts(546_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(25 as u64)) .saturating_add(RocksDbWeight::get().writes(16 as u64)) } diff --git a/runtime/mangata-rococo/src/weights/parachain_staking.rs b/runtime/mangata-rococo/src/weights/parachain_staking.rs index b2b31ca20e..aa9ad00b32 100644 --- a/runtime/mangata-rococo/src/weights/parachain_staking.rs +++ b/runtime/mangata-rococo/src/weights/parachain_staking.rs @@ -19,7 +19,7 @@ //! Autogenerated weights for parachain_staking //! //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev -//! DATE: 2023-05-18, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` +//! DATE: 2023-10-02, STEPS: `50`, REPEAT: 20, LOW RANGE: `[]`, HIGH RANGE: `[]` //! EXECUTION: Some(Wasm), WASM-EXECUTION: Compiled, CHAIN: Some("kusama"), DB CACHE: 1024 // Executed Command: @@ -99,14 +99,14 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking TotalSelected (r:1 w:1) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) fn set_total_selected() -> Weight { - (Weight::from_parts(18_120_000, 0)) + (Weight::from_parts(18_150_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CollatorCommission (r:1 w:1) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) fn set_collator_commission() -> Weight { - (Weight::from_parts(18_170_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -133,11 +133,11 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn join_candidates(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(123_467_272, 0)) - // Standard Error: 5_457 - .saturating_add((Weight::from_parts(146_813, 0)).saturating_mul(x as u64)) - // Standard Error: 2_600 - .saturating_add((Weight::from_parts(190_628, 0)).saturating_mul(y as u64)) + (Weight::from_parts(128_769_592, 0)) + // Standard Error: 5_183 + .saturating_add((Weight::from_parts(124_370, 0)).saturating_mul(x as u64)) + // Standard Error: 5_120 + .saturating_add((Weight::from_parts(134_647, 0)).saturating_mul(y as u64)) .saturating_add(T::DbWeight::get().reads(11 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -148,9 +148,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(39_282_701, 0)) - // Standard Error: 2_623 - .saturating_add((Weight::from_parts(167_522, 0)).saturating_mul(x as u64)) + (Weight::from_parts(40_966_197, 0)) + // Standard Error: 1_766 + .saturating_add((Weight::from_parts(121_647, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -158,20 +158,20 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) - // Storage: MultiPurposeLiquidity ReserveStatus (r:25 w:25) + // Storage: MultiPurposeLiquidity ReserveStatus (r:30 w:30) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:25 w:25) + // Storage: Tokens Accounts (r:30 w:30) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: ParachainStaking DelegatorState (r:24 w:24) + // Storage: ParachainStaking DelegatorState (r:29 w:29) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CandidateAggregator (r:1 w:0) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(60_685_134, 0)) - // Standard Error: 31_073 - .saturating_add((Weight::from_parts(31_446_338, 0)).saturating_mul(x as u64)) + (Weight::from_parts(61_759_888, 0)) + // Standard Error: 25_405 + .saturating_add((Weight::from_parts(31_682_004, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().reads((3 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(1 as u64)) @@ -182,9 +182,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn cancel_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(37_579_077, 0)) - // Standard Error: 2_367 - .saturating_add((Weight::from_parts(161_581, 0)).saturating_mul(x as u64)) + (Weight::from_parts(39_197_562, 0)) + // Standard Error: 1_699 + .saturating_add((Weight::from_parts(119_579, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -195,7 +195,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_offline() -> Weight { - (Weight::from_parts(38_880_000, 0)) + (Weight::from_parts(39_200_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -206,7 +206,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_online() -> Weight { - (Weight::from_parts(38_290_000, 0)) + (Weight::from_parts(38_610_000, 0)) .saturating_add(T::DbWeight::get().reads(3 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } @@ -219,7 +219,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_more() -> Weight { - (Weight::from_parts(55_150_000, 0)) + (Weight::from_parts(56_000_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -234,7 +234,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_less() -> Weight { - (Weight::from_parts(57_430_000, 0)) + (Weight::from_parts(57_740_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -251,7 +251,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_more() -> Weight { - (Weight::from_parts(89_831_000, 0)) + (Weight::from_parts(90_910_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } @@ -268,21 +268,21 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_less() -> Weight { - (Weight::from_parts(85_290_000, 0)) + (Weight::from_parts(87_720_000, 0)) .saturating_add(T::DbWeight::get().reads(6 as u64)) .saturating_add(T::DbWeight::get().writes(5 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_more() -> Weight { - (Weight::from_parts(29_900_000, 0)) + (Weight::from_parts(30_420_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_less() -> Weight { - (Weight::from_parts(29_190_000, 0)) + (Weight::from_parts(29_860_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -307,11 +307,11 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn delegate(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(126_644_715, 0)) - // Standard Error: 7_517 - .saturating_add((Weight::from_parts(346_672, 0)).saturating_mul(x as u64)) - // Standard Error: 19_666 - .saturating_add((Weight::from_parts(396_238, 0)).saturating_mul(y as u64)) + (Weight::from_parts(127_734_458, 0)) + // Standard Error: 7_698 + .saturating_add((Weight::from_parts(369_909, 0)).saturating_mul(x as u64)) + // Standard Error: 7_439 + .saturating_add((Weight::from_parts(357_907, 0)).saturating_mul(y as u64)) .saturating_add(T::DbWeight::get().reads(10 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -320,7 +320,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_delegators() -> Weight { - (Weight::from_parts(32_340_000, 0)) + (Weight::from_parts(33_410_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -339,9 +339,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_delegators(x: u32, ) -> Weight { - (Weight::from_parts(24_536_934, 0)) - // Standard Error: 26_983 - .saturating_add((Weight::from_parts(37_923_839, 0)).saturating_mul(x as u64)) + (Weight::from_parts(24_848_761, 0)) + // Standard Error: 26_767 + .saturating_add((Weight::from_parts(38_484_757, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().reads((1 as u64).saturating_mul(x as u64))) .saturating_add(T::DbWeight::get().writes(4 as u64)) @@ -350,7 +350,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_leave_delegators() -> Weight { - (Weight::from_parts(30_410_000, 0)) + (Weight::from_parts(31_130_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -359,7 +359,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_revoke_delegation() -> Weight { - (Weight::from_parts(33_440_000, 0)) + (Weight::from_parts(34_070_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -372,7 +372,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_more() -> Weight { - (Weight::from_parts(56_360_000, 0)) + (Weight::from_parts(56_650_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -381,7 +381,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_less() -> Weight { - (Weight::from_parts(33_850_000, 0)) + (Weight::from_parts(34_280_000, 0)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -400,7 +400,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_revoke_delegation() -> Weight { - (Weight::from_parts(110_750_000, 0)) + (Weight::from_parts(111_770_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -419,7 +419,7 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_more() -> Weight { - (Weight::from_parts(104_580_000, 0)) + (Weight::from_parts(103_940_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } @@ -438,28 +438,28 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_less() -> Weight { - (Weight::from_parts(100_440_000, 0)) + (Weight::from_parts(99_690_000, 0)) .saturating_add(T::DbWeight::get().reads(7 as u64)) .saturating_add(T::DbWeight::get().writes(6 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_revoke_delegation() -> Weight { - (Weight::from_parts(30_630_000, 0)) + (Weight::from_parts(31_370_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_more() -> Weight { - (Weight::from_parts(35_770_000, 0)) + (Weight::from_parts(35_290_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_less() -> Weight { - (Weight::from_parts(35_660_000, 0)) + (Weight::from_parts(35_540_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } @@ -468,22 +468,22 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn add_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(28_003_682, 0)) - // Standard Error: 2_159 - .saturating_add((Weight::from_parts(179_452, 0)).saturating_mul(x as u64)) + (Weight::from_parts(28_340_872, 0)) + // Standard Error: 2_236 + .saturating_add((Weight::from_parts(153_025, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(2 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn remove_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(20_637_967, 0)) - // Standard Error: 1_732 - .saturating_add((Weight::from_parts(159_921, 0)).saturating_mul(x as u64)) + (Weight::from_parts(20_686_950, 0)) + // Standard Error: 1_638 + .saturating_add((Weight::from_parts(140_026, 0)).saturating_mul(x as u64)) .saturating_add(T::DbWeight::get().reads(1 as u64)) .saturating_add(T::DbWeight::get().writes(1 as u64)) } - // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking CandidateState (r:99 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking DelegatorState (r:1 w:0) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) @@ -492,8 +492,8 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking CandidateAggregator (r:1 w:1) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) fn aggregator_update_metadata() -> Weight { - (Weight::from_parts(738_010_000, 0)) - .saturating_add(T::DbWeight::get().reads(52 as u64)) + (Weight::from_parts(1_946_910_000, 0)) + .saturating_add(T::DbWeight::get().reads(102 as u64)) .saturating_add(T::DbWeight::get().writes(2 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:0) @@ -503,20 +503,20 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) // Proof Skipped: ParachainStaking AggregatorMetadata (max_values: None, max_size: None, mode: Measured) fn update_candidate_aggregator() -> Weight { - (Weight::from_parts(97_980_000, 0)) + (Weight::from_parts(122_120_000, 0)) .saturating_add(T::DbWeight::get().reads(4 as u64)) .saturating_add(T::DbWeight::get().writes(3 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:14 w:14) + // Storage: Tokens Accounts (r:32 w:32) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: System Account (r:14 w:13) + // Storage: System Account (r:32 w:31) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_collator_rewards() -> Weight { - (Weight::from_parts(646_079_000, 0)) - .saturating_add(T::DbWeight::get().reads(30 as u64)) - .saturating_add(T::DbWeight::get().writes(28 as u64)) + (Weight::from_parts(1_493_000_000, 0)) + .saturating_add(T::DbWeight::get().reads(66 as u64)) + .saturating_add(T::DbWeight::get().writes(64 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:1 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) @@ -525,14 +525,14 @@ impl parachain_staking::WeightInfo for ModuleWeight // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_delegator_reward() -> Weight { - (Weight::from_parts(81_750_000, 0)) + (Weight::from_parts(87_790_000, 0)) .saturating_add(T::DbWeight::get().reads(5 as u64)) .saturating_add(T::DbWeight::get().writes(4 as u64)) } // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn passive_session_change() -> Weight { - (Weight::from_parts(7_450_000, 0)) + (Weight::from_parts(7_670_000, 0)) .saturating_add(T::DbWeight::get().reads(1 as u64)) } // Storage: ParachainStaking Round (r:1 w:1) @@ -551,9 +551,9 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: Issuance SessionIssuance (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking RoundAggregatorInfo (r:1 w:2) // Proof Skipped: ParachainStaking RoundAggregatorInfo (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AwardedPts (r:27 w:26) + // Storage: ParachainStaking AwardedPts (r:52 w:51) // Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AtStake (r:26 w:52) + // Storage: ParachainStaking AtStake (r:51 w:102) // Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CollatorCommission (r:1 w:0) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) @@ -571,37 +571,41 @@ impl parachain_staking::WeightInfo for ModuleWeight // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking TotalSelected (r:1 w:0) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking CandidateState (r:26 w:0) + // Storage: ParachainStaking CandidateState (r:51 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: Issuance IssuanceConfigStore (r:1 w:0) // Proof Skipped: Issuance IssuanceConfigStore (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:0) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:100 w:0) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Session NextKeys (r:26 w:0) + // Storage: Session NextKeys (r:51 w:0) // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) // Storage: Aura Authorities (r:1 w:0) // Proof: Aura Authorities (max_values: Some(1), max_size: Some(3200004), added: 3200499, mode: MaxEncodedLen) // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:26) + // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:51) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) // Storage: Session Validators (r:0 w:1) // Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { - (Weight::from_parts(962_696_231, 0)) - // Standard Error: 23_712 - .saturating_add((Weight::from_parts(18_001_066, 0)).saturating_mul(x as u64)) - // Standard Error: 102_677 - .saturating_add((Weight::from_parts(5_760_381, 0)).saturating_mul(y as u64)) - // Standard Error: 242_115 - .saturating_add((Weight::from_parts(29_808_290, 0)).saturating_mul(z as u64)) - .saturating_add(T::DbWeight::get().reads(124 as u64)) + (Weight::from_parts(1_634_783_507, 0)) + // Standard Error: 32_199 + .saturating_add((Weight::from_parts(18_829_187, 0)).saturating_mul(x as u64)) + // Standard Error: 66_033 + .saturating_add((Weight::from_parts(7_604_897, 0)).saturating_mul(y as u64)) + // Standard Error: 114_378 + .saturating_add((Weight::from_parts(47_173_573, 0)).saturating_mul(z as u64)) + .saturating_add(T::DbWeight::get().reads(226 as u64)) .saturating_add(T::DbWeight::get().reads((4 as u64).saturating_mul(x as u64))) - .saturating_add(T::DbWeight::get().writes(119 as u64)) + .saturating_add(T::DbWeight::get().writes(220 as u64)) } } @@ -610,14 +614,14 @@ impl WeightInfo for () { // Storage: ParachainStaking TotalSelected (r:1 w:1) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) fn set_total_selected() -> Weight { - (Weight::from_parts(18_120_000, 0)) + (Weight::from_parts(18_150_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CollatorCommission (r:1 w:1) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) fn set_collator_commission() -> Weight { - (Weight::from_parts(18_170_000, 0)) + (Weight::from_parts(18_530_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -644,11 +648,11 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn join_candidates(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(123_467_272, 0)) - // Standard Error: 5_457 - .saturating_add((Weight::from_parts(146_813, 0)).saturating_mul(x as u64)) - // Standard Error: 2_600 - .saturating_add((Weight::from_parts(190_628, 0)).saturating_mul(y as u64)) + (Weight::from_parts(128_769_592, 0)) + // Standard Error: 5_183 + .saturating_add((Weight::from_parts(124_370, 0)).saturating_mul(x as u64)) + // Standard Error: 5_120 + .saturating_add((Weight::from_parts(134_647, 0)).saturating_mul(y as u64)) .saturating_add(RocksDbWeight::get().reads(11 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -659,9 +663,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(39_282_701, 0)) - // Standard Error: 2_623 - .saturating_add((Weight::from_parts(167_522, 0)).saturating_mul(x as u64)) + (Weight::from_parts(40_966_197, 0)) + // Standard Error: 1_766 + .saturating_add((Weight::from_parts(121_647, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -669,20 +673,20 @@ impl WeightInfo for () { // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) - // Storage: MultiPurposeLiquidity ReserveStatus (r:25 w:25) + // Storage: MultiPurposeLiquidity ReserveStatus (r:30 w:30) // Proof: MultiPurposeLiquidity ReserveStatus (max_values: None, max_size: Some(124), added: 2599, mode: MaxEncodedLen) - // Storage: Tokens Accounts (r:25 w:25) + // Storage: Tokens Accounts (r:30 w:30) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: ParachainStaking DelegatorState (r:24 w:24) + // Storage: ParachainStaking DelegatorState (r:29 w:29) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CandidateAggregator (r:1 w:0) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(60_685_134, 0)) - // Standard Error: 31_073 - .saturating_add((Weight::from_parts(31_446_338, 0)).saturating_mul(x as u64)) + (Weight::from_parts(61_759_888, 0)) + // Standard Error: 25_405 + .saturating_add((Weight::from_parts(31_682_004, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().reads((3 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(1 as u64)) @@ -693,9 +697,9 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn cancel_leave_candidates(x: u32, ) -> Weight { - (Weight::from_parts(37_579_077, 0)) - // Standard Error: 2_367 - .saturating_add((Weight::from_parts(161_581, 0)).saturating_mul(x as u64)) + (Weight::from_parts(39_197_562, 0)) + // Standard Error: 1_699 + .saturating_add((Weight::from_parts(119_579, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -706,7 +710,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_offline() -> Weight { - (Weight::from_parts(38_880_000, 0)) + (Weight::from_parts(39_200_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -717,7 +721,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn go_online() -> Weight { - (Weight::from_parts(38_290_000, 0)) + (Weight::from_parts(38_610_000, 0)) .saturating_add(RocksDbWeight::get().reads(3 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } @@ -730,7 +734,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_more() -> Weight { - (Weight::from_parts(55_150_000, 0)) + (Weight::from_parts(56_000_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -745,7 +749,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_candidate_bond_less() -> Weight { - (Weight::from_parts(57_430_000, 0)) + (Weight::from_parts(57_740_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -762,7 +766,7 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_more() -> Weight { - (Weight::from_parts(89_831_000, 0)) + (Weight::from_parts(90_910_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } @@ -779,21 +783,21 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidatePool (r:1 w:1) // Proof Skipped: ParachainStaking CandidatePool (max_values: Some(1), max_size: None, mode: Measured) fn execute_candidate_bond_less() -> Weight { - (Weight::from_parts(85_290_000, 0)) + (Weight::from_parts(87_720_000, 0)) .saturating_add(RocksDbWeight::get().reads(6 as u64)) .saturating_add(RocksDbWeight::get().writes(5 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_more() -> Weight { - (Weight::from_parts(29_900_000, 0)) + (Weight::from_parts(30_420_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:1) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) fn cancel_candidate_bond_less() -> Weight { - (Weight::from_parts(29_190_000, 0)) + (Weight::from_parts(29_860_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -818,11 +822,11 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn delegate(x: u32, y: u32, ) -> Weight { - (Weight::from_parts(126_644_715, 0)) - // Standard Error: 7_517 - .saturating_add((Weight::from_parts(346_672, 0)).saturating_mul(x as u64)) - // Standard Error: 19_666 - .saturating_add((Weight::from_parts(396_238, 0)).saturating_mul(y as u64)) + (Weight::from_parts(127_734_458, 0)) + // Standard Error: 7_698 + .saturating_add((Weight::from_parts(369_909, 0)).saturating_mul(x as u64)) + // Standard Error: 7_439 + .saturating_add((Weight::from_parts(357_907, 0)).saturating_mul(y as u64)) .saturating_add(RocksDbWeight::get().reads(10 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -831,7 +835,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_leave_delegators() -> Weight { - (Weight::from_parts(32_340_000, 0)) + (Weight::from_parts(33_410_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -850,9 +854,9 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_leave_delegators(x: u32, ) -> Weight { - (Weight::from_parts(24_536_934, 0)) - // Standard Error: 26_983 - .saturating_add((Weight::from_parts(37_923_839, 0)).saturating_mul(x as u64)) + (Weight::from_parts(24_848_761, 0)) + // Standard Error: 26_767 + .saturating_add((Weight::from_parts(38_484_757, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().reads((1 as u64).saturating_mul(x as u64))) .saturating_add(RocksDbWeight::get().writes(4 as u64)) @@ -861,7 +865,7 @@ impl WeightInfo for () { // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_leave_delegators() -> Weight { - (Weight::from_parts(30_410_000, 0)) + (Weight::from_parts(31_130_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -870,7 +874,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_revoke_delegation() -> Weight { - (Weight::from_parts(33_440_000, 0)) + (Weight::from_parts(34_070_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -883,7 +887,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_more() -> Weight { - (Weight::from_parts(56_360_000, 0)) + (Weight::from_parts(56_650_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -892,7 +896,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn schedule_delegator_bond_less() -> Weight { - (Weight::from_parts(33_850_000, 0)) + (Weight::from_parts(34_280_000, 0)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -911,7 +915,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_revoke_delegation() -> Weight { - (Weight::from_parts(110_750_000, 0)) + (Weight::from_parts(111_770_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -930,7 +934,7 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_more() -> Weight { - (Weight::from_parts(104_580_000, 0)) + (Weight::from_parts(103_940_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } @@ -949,28 +953,28 @@ impl WeightInfo for () { // Storage: ParachainStaking Total (r:1 w:1) // Proof Skipped: ParachainStaking Total (max_values: None, max_size: None, mode: Measured) fn execute_delegator_bond_less() -> Weight { - (Weight::from_parts(100_440_000, 0)) + (Weight::from_parts(99_690_000, 0)) .saturating_add(RocksDbWeight::get().reads(7 as u64)) .saturating_add(RocksDbWeight::get().writes(6 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_revoke_delegation() -> Weight { - (Weight::from_parts(30_630_000, 0)) + (Weight::from_parts(31_370_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_more() -> Weight { - (Weight::from_parts(35_770_000, 0)) + (Weight::from_parts(35_290_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking DelegatorState (r:1 w:1) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) fn cancel_delegator_bond_less() -> Weight { - (Weight::from_parts(35_660_000, 0)) + (Weight::from_parts(35_540_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } @@ -979,22 +983,22 @@ impl WeightInfo for () { // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn add_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(28_003_682, 0)) - // Standard Error: 2_159 - .saturating_add((Weight::from_parts(179_452, 0)).saturating_mul(x as u64)) + (Weight::from_parts(28_340_872, 0)) + // Standard Error: 2_236 + .saturating_add((Weight::from_parts(153_025, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(2 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } // Storage: ParachainStaking StakingLiquidityTokens (r:1 w:1) // Proof Skipped: ParachainStaking StakingLiquidityTokens (max_values: Some(1), max_size: None, mode: Measured) fn remove_staking_liquidity_token(x: u32, ) -> Weight { - (Weight::from_parts(20_637_967, 0)) - // Standard Error: 1_732 - .saturating_add((Weight::from_parts(159_921, 0)).saturating_mul(x as u64)) + (Weight::from_parts(20_686_950, 0)) + // Standard Error: 1_638 + .saturating_add((Weight::from_parts(140_026, 0)).saturating_mul(x as u64)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) .saturating_add(RocksDbWeight::get().writes(1 as u64)) } - // Storage: ParachainStaking CandidateState (r:49 w:0) + // Storage: ParachainStaking CandidateState (r:99 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking DelegatorState (r:1 w:0) // Proof Skipped: ParachainStaking DelegatorState (max_values: None, max_size: None, mode: Measured) @@ -1003,8 +1007,8 @@ impl WeightInfo for () { // Storage: ParachainStaking CandidateAggregator (r:1 w:1) // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) fn aggregator_update_metadata() -> Weight { - (Weight::from_parts(738_010_000, 0)) - .saturating_add(RocksDbWeight::get().reads(52 as u64)) + (Weight::from_parts(1_946_910_000, 0)) + .saturating_add(RocksDbWeight::get().reads(102 as u64)) .saturating_add(RocksDbWeight::get().writes(2 as u64)) } // Storage: ParachainStaking CandidateState (r:1 w:0) @@ -1014,20 +1018,20 @@ impl WeightInfo for () { // Storage: ParachainStaking AggregatorMetadata (r:2 w:2) // Proof Skipped: ParachainStaking AggregatorMetadata (max_values: None, max_size: None, mode: Measured) fn update_candidate_aggregator() -> Weight { - (Weight::from_parts(97_980_000, 0)) + (Weight::from_parts(122_120_000, 0)) .saturating_add(RocksDbWeight::get().reads(4 as u64)) .saturating_add(RocksDbWeight::get().writes(3 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:2 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) - // Storage: Tokens Accounts (r:14 w:14) + // Storage: Tokens Accounts (r:32 w:32) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: System Account (r:14 w:13) + // Storage: System Account (r:32 w:31) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_collator_rewards() -> Weight { - (Weight::from_parts(646_079_000, 0)) - .saturating_add(RocksDbWeight::get().reads(30 as u64)) - .saturating_add(RocksDbWeight::get().writes(28 as u64)) + (Weight::from_parts(1_493_000_000, 0)) + .saturating_add(RocksDbWeight::get().reads(66 as u64)) + .saturating_add(RocksDbWeight::get().writes(64 as u64)) } // Storage: ParachainStaking RoundCollatorRewardInfo (r:1 w:1) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) @@ -1036,14 +1040,14 @@ impl WeightInfo for () { // Storage: System Account (r:2 w:1) // Proof Skipped: System Account (max_values: None, max_size: None, mode: Measured) fn payout_delegator_reward() -> Weight { - (Weight::from_parts(81_750_000, 0)) + (Weight::from_parts(87_790_000, 0)) .saturating_add(RocksDbWeight::get().reads(5 as u64)) .saturating_add(RocksDbWeight::get().writes(4 as u64)) } // Storage: ParachainStaking Round (r:1 w:0) // Proof Skipped: ParachainStaking Round (max_values: Some(1), max_size: None, mode: Measured) fn passive_session_change() -> Weight { - (Weight::from_parts(7_450_000, 0)) + (Weight::from_parts(7_670_000, 0)) .saturating_add(RocksDbWeight::get().reads(1 as u64)) } // Storage: ParachainStaking Round (r:1 w:1) @@ -1062,9 +1066,9 @@ impl WeightInfo for () { // Proof Skipped: Issuance SessionIssuance (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking RoundAggregatorInfo (r:1 w:2) // Proof Skipped: ParachainStaking RoundAggregatorInfo (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AwardedPts (r:27 w:26) + // Storage: ParachainStaking AwardedPts (r:52 w:51) // Proof Skipped: ParachainStaking AwardedPts (max_values: None, max_size: None, mode: Measured) - // Storage: ParachainStaking AtStake (r:26 w:52) + // Storage: ParachainStaking AtStake (r:51 w:102) // Proof Skipped: ParachainStaking AtStake (max_values: None, max_size: None, mode: Measured) // Storage: ParachainStaking CollatorCommission (r:1 w:0) // Proof Skipped: ParachainStaking CollatorCommission (max_values: Some(1), max_size: None, mode: Measured) @@ -1082,36 +1086,40 @@ impl WeightInfo for () { // Proof Skipped: ParachainStaking CandidateAggregator (max_values: Some(1), max_size: None, mode: Measured) // Storage: ParachainStaking TotalSelected (r:1 w:0) // Proof Skipped: ParachainStaking TotalSelected (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking CandidateState (r:26 w:0) + // Storage: ParachainStaking CandidateState (r:51 w:0) // Proof Skipped: ParachainStaking CandidateState (max_values: None, max_size: None, mode: Measured) // Storage: Issuance IssuanceConfigStore (r:1 w:0) // Proof Skipped: Issuance IssuanceConfigStore (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake RewardsSchedules (r:1 w:0) + // Proof Skipped: ProofOfStake RewardsSchedules (max_values: Some(1), max_size: None, mode: Measured) + // Storage: ProofOfStake ScheduleRewardsPerSingleLiquidity (r:1 w:1) + // Proof Skipped: ProofOfStake ScheduleRewardsPerSingleLiquidity (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake PromotedPoolRewards (r:1 w:1) // Proof Skipped: ProofOfStake PromotedPoolRewards (max_values: Some(1), max_size: None, mode: Measured) // Storage: ProofOfStake TotalActivatedLiquidity (r:100 w:0) // Proof Skipped: ProofOfStake TotalActivatedLiquidity (max_values: None, max_size: None, mode: Measured) // Storage: Tokens Accounts (r:2 w:2) // Proof: Tokens Accounts (max_values: None, max_size: Some(108), added: 2583, mode: MaxEncodedLen) - // Storage: Session NextKeys (r:26 w:0) + // Storage: Session NextKeys (r:51 w:0) // Proof Skipped: Session NextKeys (max_values: None, max_size: None, mode: Measured) // Storage: Aura Authorities (r:1 w:0) // Proof: Aura Authorities (max_values: Some(1), max_size: Some(3200004), added: 3200499, mode: MaxEncodedLen) // Storage: ParachainStaking SelectedCandidates (r:0 w:1) // Proof Skipped: ParachainStaking SelectedCandidates (max_values: Some(1), max_size: None, mode: Measured) - // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:26) + // Storage: ParachainStaking RoundCollatorRewardInfo (r:0 w:51) // Proof Skipped: ParachainStaking RoundCollatorRewardInfo (max_values: None, max_size: None, mode: Measured) // Storage: Session Validators (r:0 w:1) // Proof Skipped: Session Validators (max_values: Some(1), max_size: None, mode: Measured) fn active_session_change(x: u32, y: u32, z: u32, ) -> Weight { - (Weight::from_parts(962_696_231, 0)) - // Standard Error: 23_712 - .saturating_add((Weight::from_parts(18_001_066, 0)).saturating_mul(x as u64)) - // Standard Error: 102_677 - .saturating_add((Weight::from_parts(5_760_381, 0)).saturating_mul(y as u64)) - // Standard Error: 242_115 - .saturating_add((Weight::from_parts(29_808_290, 0)).saturating_mul(z as u64)) - .saturating_add(RocksDbWeight::get().reads(124 as u64)) + (Weight::from_parts(1_634_783_507, 0)) + // Standard Error: 32_199 + .saturating_add((Weight::from_parts(18_829_187, 0)).saturating_mul(x as u64)) + // Standard Error: 66_033 + .saturating_add((Weight::from_parts(7_604_897, 0)).saturating_mul(y as u64)) + // Standard Error: 114_378 + .saturating_add((Weight::from_parts(47_173_573, 0)).saturating_mul(z as u64)) + .saturating_add(RocksDbWeight::get().reads(226 as u64)) .saturating_add(RocksDbWeight::get().reads((4 as u64).saturating_mul(x as u64))) - .saturating_add(RocksDbWeight::get().writes(119 as u64)) + .saturating_add(RocksDbWeight::get().writes(220 as u64)) } } From b0bb7c641d3a91299b3815e9ae813e8193a3d5a3 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 2 Oct 2023 22:47:29 +0200 Subject: [PATCH 35/83] apply formatting --- runtime/mangata-kusama/src/weights/block_weights.rs | 1 - runtime/mangata-kusama/src/weights/extrinsic_weights.rs | 1 - runtime/mangata-rococo/src/weights/block_weights.rs | 1 - runtime/mangata-rococo/src/weights/extrinsic_weights.rs | 1 - 4 files changed, 4 deletions(-) diff --git a/runtime/mangata-kusama/src/weights/block_weights.rs b/runtime/mangata-kusama/src/weights/block_weights.rs index e190a4a858..6d27c66767 100644 --- a/runtime/mangata-kusama/src/weights/block_weights.rs +++ b/runtime/mangata-kusama/src/weights/block_weights.rs @@ -1,4 +1,3 @@ - //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-02 (Y/M/D) //! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` diff --git a/runtime/mangata-kusama/src/weights/extrinsic_weights.rs b/runtime/mangata-kusama/src/weights/extrinsic_weights.rs index 033bf75d8f..ddceb8ee70 100644 --- a/runtime/mangata-kusama/src/weights/extrinsic_weights.rs +++ b/runtime/mangata-kusama/src/weights/extrinsic_weights.rs @@ -1,4 +1,3 @@ - //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-02 (Y/M/D) //! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` diff --git a/runtime/mangata-rococo/src/weights/block_weights.rs b/runtime/mangata-rococo/src/weights/block_weights.rs index e190a4a858..6d27c66767 100644 --- a/runtime/mangata-rococo/src/weights/block_weights.rs +++ b/runtime/mangata-rococo/src/weights/block_weights.rs @@ -1,4 +1,3 @@ - //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-02 (Y/M/D) //! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` diff --git a/runtime/mangata-rococo/src/weights/extrinsic_weights.rs b/runtime/mangata-rococo/src/weights/extrinsic_weights.rs index 033bf75d8f..ddceb8ee70 100644 --- a/runtime/mangata-rococo/src/weights/extrinsic_weights.rs +++ b/runtime/mangata-rococo/src/weights/extrinsic_weights.rs @@ -1,4 +1,3 @@ - //! THIS FILE WAS AUTO-GENERATED USING THE SUBSTRATE BENCHMARK CLI VERSION 4.0.0-dev //! DATE: 2023-10-02 (Y/M/D) //! HOSTNAME: `4f854f261503`, CPU: `AMD EPYC 7B13` From 17c1d75dff6ac7e5cf49f99f8162638d8c9fe310 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 11 Oct 2023 19:45:46 +0000 Subject: [PATCH 36/83] fwip --- Cargo.lock | 277 +-- Cargo.toml | 2202 +++++++++++---------- devops/parachain-launch/config.yml | 2 +- pallets/proof-of-stake/Cargo.toml | 5 +- pallets/proof-of-stake/src/lib.rs | 488 +++-- pallets/proof-of-stake/src/mock.rs | 5 + pallets/proof-of-stake/src/reward_info.rs | 15 +- pallets/proof-of-stake/src/tests.rs | 221 ++- pallets/xyk/src/lib.rs | 13 + pallets/xyk/src/tests.rs | 46 + runtime/common/src/lib.rs | 2 +- 11 files changed, 1782 insertions(+), 1494 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7f3ac00573..1102437ef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,7 +554,6 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "hash-db 0.16.0", "log", @@ -1100,7 +1099,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -2612,7 +2611,6 @@ dependencies = [ [[package]] name = "extrinsic-shuffler" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "derive_more", "log", @@ -2781,7 +2779,6 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", ] @@ -2804,7 +2801,6 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-support-procedural", @@ -2830,7 +2826,6 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "Inflector", "array-bytes 4.2.0", @@ -2883,7 +2878,6 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2894,7 +2888,6 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2911,7 +2904,6 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "aquamarine", "extrinsic-shuffler", @@ -2945,7 +2937,6 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "log", @@ -2961,7 +2952,6 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "bitflags", "environmental", @@ -2995,7 +2985,6 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "Inflector", "cfg-expr", @@ -3010,7 +2999,6 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -3022,7 +3010,6 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro2", "quote", @@ -3032,7 +3019,6 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "extrinsic-shuffler", "frame-support", @@ -3052,22 +3038,6 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" -dependencies = [ - "frame-benchmarking", - "frame-support", - "frame-system", - "parity-scale-codec", - "scale-info", - "sp-core", - "sp-runtime", - "sp-std", -] - -[[package]] -name = "frame-system-benchmarking" -version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "frame-benchmarking", "frame-support", @@ -3082,7 +3052,6 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "sp-api", @@ -3091,7 +3060,6 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "parity-scale-codec", @@ -4144,7 +4112,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -4988,7 +4956,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -5112,7 +5080,7 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-aura", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-executor", "sc-keystore", "sc-network", @@ -5178,7 +5146,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -5272,7 +5240,6 @@ dependencies = [ [[package]] name = "mangata-support" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "mangata-types", @@ -5285,7 +5252,6 @@ dependencies = [ [[package]] name = "mangata-types" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -5453,7 +5419,6 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "log", @@ -5473,7 +5438,6 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "anyhow", "jsonrpsee", @@ -6111,7 +6075,6 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6127,7 +6090,6 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6143,7 +6105,6 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6157,7 +6118,6 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6181,7 +6141,6 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6201,7 +6160,6 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6216,7 +6174,6 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6235,10 +6192,9 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", - "binary-merkle-tree 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "binary-merkle-tree 4.0.0-dev", "frame-support", "frame-system", "log", @@ -6291,7 +6247,6 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6309,7 +6264,6 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6328,7 +6282,6 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6345,7 +6298,6 @@ dependencies = [ [[package]] name = "pallet-collective-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6362,7 +6314,6 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6403,7 +6354,6 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6421,14 +6371,13 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", - "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "pallet-election-provider-support-benchmarking 4.0.0-dev", "parity-scale-codec", "rand 0.8.5", "scale-info", @@ -6444,7 +6393,6 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6470,7 +6418,6 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6488,7 +6435,6 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6535,7 +6481,6 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6558,7 +6503,6 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6574,7 +6518,6 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6594,7 +6537,6 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6663,7 +6605,6 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6680,7 +6621,6 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6727,7 +6667,6 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6743,7 +6682,6 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6759,7 +6697,6 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6796,7 +6733,6 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6807,7 +6743,6 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -6848,7 +6783,6 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6902,7 +6836,6 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6917,7 +6850,6 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6935,7 +6867,6 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -6950,7 +6881,6 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6969,7 +6899,6 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "1.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" dependencies = [ "frame-support", "frame-system", @@ -6984,7 +6913,6 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7001,7 +6929,6 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7038,7 +6965,6 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7052,7 +6978,6 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -7075,7 +7000,6 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7086,7 +7010,6 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "log", "sp-arithmetic", @@ -7104,7 +7027,6 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7121,7 +7043,6 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7135,7 +7056,6 @@ dependencies = [ [[package]] name = "pallet-sudo-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7167,7 +7087,6 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7185,7 +7104,6 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7204,7 +7122,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7220,7 +7137,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-support", "frame-system", @@ -7236,7 +7152,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "jsonrpsee", "pallet-transaction-payment-mangata-rpc-runtime-api", @@ -7252,7 +7167,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "pallet-transaction-payment-mangata", "parity-scale-codec", @@ -7264,7 +7178,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7280,7 +7193,6 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7292,7 +7204,6 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7309,7 +7220,6 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7325,7 +7235,6 @@ dependencies = [ [[package]] name = "pallet-utility-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7341,7 +7250,6 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7356,7 +7264,6 @@ dependencies = [ [[package]] name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7372,7 +7279,6 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-benchmarking", "frame-support", @@ -7475,7 +7381,6 @@ dependencies = [ [[package]] name = "parachain-staking" version = "3.0.0" -source = "git+https://github.com/mangata-finance//moonbeam?branch=mangata-dev#2ac7a339be795ee58603e3cb68e65fedc1b1c295" dependencies = [ "aquamarine", "frame-benchmarking", @@ -8593,7 +8498,7 @@ dependencies = [ "sc-consensus-beefy", "sc-consensus-beefy-rpc", "sc-consensus-epochs", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-consensus-grandpa-rpc", "sc-rpc", "sc-sync-state-rpc", @@ -8620,7 +8525,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -8884,7 +8789,7 @@ dependencies = [ "sc-consensus", "sc-consensus-babe", "sc-consensus-beefy", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-consensus-slots", "sc-executor", "sc-keystore", @@ -9047,7 +8952,7 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-babe", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-executor", "sc-network", "sc-service", @@ -9752,7 +9657,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -10102,7 +10007,6 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "log", "sp-core", @@ -10113,7 +10017,6 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -10141,7 +10044,6 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "futures-timer", @@ -10164,7 +10066,6 @@ dependencies = [ [[package]] name = "sc-basic-authorship-ver" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "aquamarine", "futures", @@ -10190,7 +10091,6 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -10205,7 +10105,6 @@ dependencies = [ [[package]] name = "sc-block-builder-ver" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "aquamarine", "extrinsic-shuffler", @@ -10226,7 +10125,6 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -10245,7 +10143,6 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10256,7 +10153,6 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "chrono", @@ -10296,7 +10192,6 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "fnv", "futures", @@ -10322,7 +10217,6 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "hash-db 0.16.0", "kvdb", @@ -10348,7 +10242,6 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -10373,7 +10266,6 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -10402,7 +10294,6 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "fork-tree", @@ -10443,7 +10334,6 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "jsonrpsee", @@ -10465,7 +10355,6 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10519,7 +10408,6 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "fork-tree", "parity-scale-codec", @@ -10532,47 +10420,6 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" -dependencies = [ - "ahash 0.8.3", - "array-bytes 4.2.0", - "async-trait", - "dyn-clone", - "finality-grandpa", - "fork-tree", - "futures", - "futures-timer", - "log", - "parity-scale-codec", - "parking_lot 0.12.1", - "rand 0.8.5", - "sc-block-builder", - "sc-chain-spec", - "sc-client-api", - "sc-consensus", - "sc-network", - "sc-network-common", - "sc-network-gossip", - "sc-telemetry", - "sc-utils", - "serde_json", - "sp-api", - "sp-application-crypto", - "sp-arithmetic", - "sp-blockchain", - "sp-consensus", - "sp-consensus-grandpa", - "sp-core", - "sp-keystore", - "sp-runtime", - "substrate-prometheus-endpoint", - "thiserror", -] - -[[package]] -name = "sc-consensus-grandpa" -version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" dependencies = [ "ahash 0.8.3", "array-bytes 4.2.0", @@ -10620,7 +10467,7 @@ dependencies = [ "log", "parity-scale-codec", "sc-client-api", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "sc-rpc", "serde", "sp-blockchain", @@ -10632,7 +10479,6 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -10657,7 +10503,6 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "lru 0.8.1", "parity-scale-codec", @@ -10681,7 +10526,6 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -10694,7 +10538,6 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "log", "sc-allocator", @@ -10707,7 +10550,6 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "anyhow", "cfg-if", @@ -10725,7 +10567,6 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ansi_term", "futures", @@ -10741,7 +10582,6 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10756,7 +10596,6 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -10800,7 +10639,6 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "cid", "futures", @@ -10820,7 +10658,6 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10848,7 +10685,6 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ahash 0.8.3", "futures", @@ -10867,7 +10703,6 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10889,7 +10724,6 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10923,7 +10757,6 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10943,7 +10776,6 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -10974,7 +10806,6 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "libp2p", @@ -10987,7 +10818,6 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10996,7 +10826,6 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "hash-db 0.15.2", @@ -11027,7 +10856,6 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11047,7 +10875,6 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "http", @@ -11063,7 +10890,6 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "futures", @@ -11089,7 +10915,6 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "directories", @@ -11121,7 +10946,7 @@ dependencies = [ "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", - "sc-storage-monitor 0.1.0 (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-storage-monitor 0.1.0", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -11161,7 +10986,6 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "log", "parity-scale-codec", @@ -11172,7 +10996,6 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "clap", "fs4", @@ -11204,7 +11027,6 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11212,7 +11034,7 @@ dependencies = [ "sc-client-api", "sc-consensus-babe", "sc-consensus-epochs", - "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=mangata-dev)", + "sc-consensus-grandpa", "serde", "serde_json", "sp-blockchain", @@ -11223,7 +11045,6 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "libc", @@ -11242,7 +11063,6 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "chrono", "futures", @@ -11261,7 +11081,6 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ansi_term", "atty", @@ -11292,7 +11111,6 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11303,7 +11121,6 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -11330,7 +11147,6 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -11344,7 +11160,6 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-channel", "futures", @@ -11857,7 +11672,6 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "hash-db 0.16.0", "log", @@ -11875,7 +11689,6 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "Inflector", "blake2", @@ -11889,7 +11702,6 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -11902,7 +11714,6 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "integer-sqrt", "num-traits", @@ -11916,7 +11727,6 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -11929,7 +11739,6 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "sp-api", @@ -11941,7 +11750,6 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "futures", "log", @@ -11959,7 +11767,6 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -11974,7 +11781,6 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "parity-scale-codec", @@ -11992,7 +11798,6 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "merlin", @@ -12015,7 +11820,6 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "lazy_static", "parity-scale-codec", @@ -12034,7 +11838,6 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "finality-grandpa", "log", @@ -12052,7 +11855,6 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12066,7 +11868,6 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12079,7 +11880,6 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "base58", @@ -12123,7 +11923,6 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "blake2b_simd", "byteorder", @@ -12137,7 +11936,6 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro2", "quote", @@ -12148,7 +11946,6 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -12157,7 +11954,6 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "proc-macro2", "quote", @@ -12167,7 +11963,6 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "environmental", "parity-scale-codec", @@ -12178,7 +11973,6 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -12193,7 +11987,6 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "bytes", "ed25519", @@ -12218,7 +12011,6 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "lazy_static", "sp-core", @@ -12229,7 +12021,6 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures", @@ -12246,7 +12037,6 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "thiserror", "zstd", @@ -12255,7 +12045,6 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -12273,7 +12062,6 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12287,7 +12075,6 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "sp-api", "sp-core", @@ -12297,7 +12084,6 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "backtrace", "lazy_static", @@ -12307,7 +12093,6 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "rustc-hash", "serde", @@ -12317,7 +12102,6 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "either", "hash256-std-hasher", @@ -12340,7 +12124,6 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12358,7 +12141,6 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "Inflector", "proc-macro-crate", @@ -12370,7 +12152,6 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12384,7 +12165,6 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12396,7 +12176,6 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "hash-db 0.16.0", "log", @@ -12416,12 +12195,10 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" [[package]] name = "sp-storage" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12434,7 +12211,6 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "futures-timer", @@ -12449,7 +12225,6 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "sp-std", @@ -12461,7 +12236,6 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "sp-api", "sp-runtime", @@ -12470,7 +12244,6 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "log", @@ -12486,7 +12259,6 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -12509,7 +12281,6 @@ dependencies = [ [[package]] name = "sp-ver" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "log", @@ -12527,7 +12298,6 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12544,7 +12314,6 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -12555,7 +12324,6 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -12569,7 +12337,6 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "parity-scale-codec", "scale-info", @@ -12748,7 +12515,6 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "platforms 2.0.0", ] @@ -12756,7 +12522,6 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -12775,7 +12540,6 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "hyper", "log", @@ -12787,7 +12551,6 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "jsonrpsee", @@ -12800,7 +12563,6 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "jsonrpsee", "log", @@ -12819,7 +12581,6 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -12845,7 +12606,6 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "ansi_term", "build-helper", @@ -13489,7 +13249,6 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "async-trait", "clap", @@ -13702,7 +13461,6 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "ver-api" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" dependencies = [ "derive_more", "futures", @@ -14395,7 +14153,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", + "frame-system-benchmarking", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -15034,14 +14792,11 @@ dependencies = [ [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=mangata-dev#462977d15a851a441fe542f68e06b286f059dbfe" diff --git a/Cargo.toml b/Cargo.toml index aeae1a639f..80d3a23727 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,8 +55,8 @@ orml-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-l # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/mangata-finance/moonbeam"] # parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/update-staking-benchmarks" } -parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } -# parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } +# parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } +parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } [patch."https://github.com/mangata-finance/crowdloan-rewards"] pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "mangata-dev" } @@ -370,1100 +370,1120 @@ xcm-procedural = { git = "https://github.com/mangata-finance//polkadot", branch # xcm = { path = "../polkadot/xcm" } # xcm-procedural = { path = "../polkadot/xcm/procedural" } - # patch generated by ./scripts/dev-0.9.29_manifest.sh +# # patch generated by ./scripts/dev-0.9.29_manifest.sh +# [patch."https://github.com/mangata-finance/substrate"] +# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# +# # patch generated by ./scripts/dev-0.9.29_manifest.sh +# [patch."https://github.com/paritytech/substrate"] +# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# +# # patch generated by ./scripts/dev-0.9.29_manifest.sh +# [patch."https://github.com/PureStake/substrate"] +# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +# sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } + +[patch."https://github.com/mangata-finance//substrate"] +pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } + +# patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/mangata-finance/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +sc-offchain = { path = "../substrate/client/offchain" } +sc-keystore = { path = "../substrate/client/keystore" } +mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +sc-informant = { path = "../substrate/client/informant" } +sc-client-db = { path = "../substrate/client/db" } +sc-rpc-api = { path = "../substrate/client/rpc-api" } +sc-client-api = { path = "../substrate/client/api" } +sc-block-builder = { path = "../substrate/client/block-builder" } +sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +sc-utils = { path = "../substrate/client/utils" } +sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +sc-tracing = { path = "../substrate/client/tracing" } +sc-state-db = { path = "../substrate/client/state-db" } +sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +sc-consensus = { path = "../substrate/client/consensus/common" } +sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +sc-executor = { path = "../substrate/client/executor" } +sc-executor-common = { path = "../substrate/client/executor/common" } +sc-cli = { path = "../substrate/client/cli" } +sc-peerset = { path = "../substrate/client/peerset" } +sc-telemetry = { path = "../substrate/client/telemetry" } +sc-allocator = { path = "../substrate/client/allocator" } +sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +sc-network-gossip = { path = "../substrate/client/network-gossip" } +sc-sysinfo = { path = "../substrate/client/sysinfo" } +sc-rpc-server = { path = "../substrate/client/rpc-servers" } +sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +sc-rpc = { path = "../substrate/client/rpc" } +sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +sc-chain-spec = { path = "../substrate/client/chain-spec" } +sc-network-sync = { path = "../substrate/client/network/sync" } +sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +sc-network-light = { path = "../substrate/client/network/light" } +sc-network-transactions = { path = "../substrate/client/network/transactions" } +sc-network = { path = "../substrate/client/network" } +sc-network-common = { path = "../substrate/client/network/common" } +sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +sc-service = { path = "../substrate/client/service" } +substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +fork-tree = { path = "../substrate/utils/fork-tree" } +frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +pallet-referenda = { path = "../substrate/frame/referenda" } +pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +pallet-utility = { path = "../substrate/frame/utility" } +pallet-session = { path = "../substrate/frame/session" } +pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +pallet-treasury = { path = "../substrate/frame/treasury" } +pallet-sudo = { path = "../substrate/frame/sudo" } +pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +pallet-membership = { path = "../substrate/frame/membership" } +pallet-recovery = { path = "../substrate/frame/recovery" } +pallet-tips = { path = "../substrate/frame/tips" } +pallet-balances = { path = "../substrate/frame/balances" } +pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +frame-executive = { path = "../substrate/frame/executive" } +pallet-timestamp = { path = "../substrate/frame/timestamp" } +pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +pallet-preimage = { path = "../substrate/frame/preimage" } +frame-try-runtime = { path = "../substrate/frame/try-runtime" } +pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +pallet-society = { path = "../substrate/frame/society" } +pallet-identity = { path = "../substrate/frame/identity" } +pallet-babe = { path = "../substrate/frame/babe" } +pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +pallet-vesting = { path = "../substrate/frame/vesting" } +pallet-bounties = { path = "../substrate/frame/bounties" } +frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +pallet-indices = { path = "../substrate/frame/indices" } +pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +pallet-collective = { path = "../substrate/frame/collective" } +pallet-multisig = { path = "../substrate/frame/multisig" } +pallet-offences = { path = "../substrate/frame/offences" } +pallet-scheduler = { path = "../substrate/frame/scheduler" } +pallet-nis = { path = "../substrate/frame/nis" } +frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +frame-system = { path = "../substrate/frame/system" } +frame-benchmarking = { path = "../substrate/frame/benchmarking" } +pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +pallet-proxy = { path = "../substrate/frame/proxy" } +pallet-whitelist = { path = "../substrate/frame/whitelist" } +pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +pallet-bags-list = { path = "../substrate/frame/bags-list" } +pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +frame-support = { path = "../substrate/frame/support" } +frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +frame-support-procedural = { path = "../substrate/frame/support/procedural" } +pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +pallet-staking = { path = "../substrate/frame/staking" } +pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +pallet-grandpa = { path = "../substrate/frame/grandpa" } +pallet-democracy = { path = "../substrate/frame/democracy" } +pallet-beefy = { path = "../substrate/frame/beefy" } +pallet-aura = { path = "../substrate/frame/aura" } +pallet-authorship = { path = "../substrate/frame/authorship" } +pallet-im-online = { path = "../substrate/frame/im-online" } +mangata-support = { path = "../substrate/frame/mangata-support" } +substrate-test-client = { path = "../substrate/test-utils/client" } +sp-offchain = { path = "../substrate/primitives/offchain" } +sp-keystore = { path = "../substrate/primitives/keystore" } +sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +sp-keyring = { path = "../substrate/primitives/keyring" } +sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +sp-state-machine = { path = "../substrate/primitives/state-machine" } +sp-session = { path = "../substrate/primitives/session" } +sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +ver-api = { path = "../substrate/primitives/ver-api" } +sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +sp-api = { path = "../substrate/primitives/api" } +sp-externalities = { path = "../substrate/primitives/externalities" } +sp-std = { path = "../substrate/primitives/std" } +sp-trie = { path = "../substrate/primitives/trie" } +sp-block-builder = { path = "../substrate/primitives/block-builder" } +sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +sp-tracing = { path = "../substrate/primitives/tracing" } +sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +sp-consensus = { path = "../substrate/primitives/consensus/common" } +sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +sp-io = { path = "../substrate/primitives/io" } +sp-timestamp = { path = "../substrate/primitives/timestamp" } +sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +sp-core = { path = "../substrate/primitives/core" } +sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +sp-database = { path = "../substrate/primitives/database" } +sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +sp-version = { path = "../substrate/primitives/version" } +extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +mangata-types = { path = "../substrate/primitives/mangata-types" } +sp-rpc = { path = "../substrate/primitives/rpc" } +sp-ver = { path = "../substrate/primitives/ver" } +sp-blockchain = { path = "../substrate/primitives/blockchain" } +sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +sp-runtime = { path = "../substrate/primitives/runtime" } +sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +sp-staking = { path = "../substrate/primitives/staking" } +sp-weights = { path = "../substrate/primitives/weights" } +sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +sp-authorship = { path = "../substrate/primitives/authorship" } +sp-storage = { path = "../substrate/primitives/storage" } +sp-inherents = { path = "../substrate/primitives/inherents" } +frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } +sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } +sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } +sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } +sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } +pallet-root-testing = { path = "../substrate/frame/root-testing" } -# patch generated by ./scripts/dev-0.9.29_manifest.sh +# patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/paritytech/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } +sc-offchain = { path = "../substrate/client/offchain" } +sc-keystore = { path = "../substrate/client/keystore" } +mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +sc-informant = { path = "../substrate/client/informant" } +sc-client-db = { path = "../substrate/client/db" } +sc-rpc-api = { path = "../substrate/client/rpc-api" } +sc-client-api = { path = "../substrate/client/api" } +sc-block-builder = { path = "../substrate/client/block-builder" } +sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +sc-utils = { path = "../substrate/client/utils" } +sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +sc-tracing = { path = "../substrate/client/tracing" } +sc-state-db = { path = "../substrate/client/state-db" } +sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +sc-consensus = { path = "../substrate/client/consensus/common" } +sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +sc-executor = { path = "../substrate/client/executor" } +sc-executor-common = { path = "../substrate/client/executor/common" } +sc-cli = { path = "../substrate/client/cli" } +sc-peerset = { path = "../substrate/client/peerset" } +sc-telemetry = { path = "../substrate/client/telemetry" } +sc-allocator = { path = "../substrate/client/allocator" } +sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +sc-network-gossip = { path = "../substrate/client/network-gossip" } +sc-sysinfo = { path = "../substrate/client/sysinfo" } +sc-rpc-server = { path = "../substrate/client/rpc-servers" } +sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +sc-rpc = { path = "../substrate/client/rpc" } +sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +sc-chain-spec = { path = "../substrate/client/chain-spec" } +sc-network-sync = { path = "../substrate/client/network/sync" } +sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +sc-network-light = { path = "../substrate/client/network/light" } +sc-network-transactions = { path = "../substrate/client/network/transactions" } +sc-network = { path = "../substrate/client/network" } +sc-network-common = { path = "../substrate/client/network/common" } +sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +sc-service = { path = "../substrate/client/service" } +substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +fork-tree = { path = "../substrate/utils/fork-tree" } +frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +pallet-referenda = { path = "../substrate/frame/referenda" } +pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +pallet-utility = { path = "../substrate/frame/utility" } +pallet-session = { path = "../substrate/frame/session" } +pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +pallet-treasury = { path = "../substrate/frame/treasury" } +pallet-sudo = { path = "../substrate/frame/sudo" } +pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +pallet-membership = { path = "../substrate/frame/membership" } +pallet-recovery = { path = "../substrate/frame/recovery" } +pallet-tips = { path = "../substrate/frame/tips" } +pallet-balances = { path = "../substrate/frame/balances" } +pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +frame-executive = { path = "../substrate/frame/executive" } +pallet-timestamp = { path = "../substrate/frame/timestamp" } +pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +pallet-preimage = { path = "../substrate/frame/preimage" } +frame-try-runtime = { path = "../substrate/frame/try-runtime" } +pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +pallet-society = { path = "../substrate/frame/society" } +pallet-identity = { path = "../substrate/frame/identity" } +pallet-babe = { path = "../substrate/frame/babe" } +pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +pallet-vesting = { path = "../substrate/frame/vesting" } +pallet-bounties = { path = "../substrate/frame/bounties" } +frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +pallet-indices = { path = "../substrate/frame/indices" } +pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +pallet-collective = { path = "../substrate/frame/collective" } +pallet-multisig = { path = "../substrate/frame/multisig" } +pallet-offences = { path = "../substrate/frame/offences" } +pallet-scheduler = { path = "../substrate/frame/scheduler" } +pallet-nis = { path = "../substrate/frame/nis" } +frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +frame-system = { path = "../substrate/frame/system" } +frame-benchmarking = { path = "../substrate/frame/benchmarking" } +pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +pallet-proxy = { path = "../substrate/frame/proxy" } +pallet-whitelist = { path = "../substrate/frame/whitelist" } +pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +pallet-bags-list = { path = "../substrate/frame/bags-list" } +pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +frame-support = { path = "../substrate/frame/support" } +frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +frame-support-procedural = { path = "../substrate/frame/support/procedural" } +pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +pallet-staking = { path = "../substrate/frame/staking" } +pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +pallet-grandpa = { path = "../substrate/frame/grandpa" } +pallet-democracy = { path = "../substrate/frame/democracy" } +pallet-beefy = { path = "../substrate/frame/beefy" } +pallet-aura = { path = "../substrate/frame/aura" } +pallet-authorship = { path = "../substrate/frame/authorship" } +pallet-im-online = { path = "../substrate/frame/im-online" } +mangata-support = { path = "../substrate/frame/mangata-support" } +substrate-test-client = { path = "../substrate/test-utils/client" } +sp-offchain = { path = "../substrate/primitives/offchain" } +sp-keystore = { path = "../substrate/primitives/keystore" } +sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +sp-keyring = { path = "../substrate/primitives/keyring" } +sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +sp-state-machine = { path = "../substrate/primitives/state-machine" } +sp-session = { path = "../substrate/primitives/session" } +sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +ver-api = { path = "../substrate/primitives/ver-api" } +sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +sp-api = { path = "../substrate/primitives/api" } +sp-externalities = { path = "../substrate/primitives/externalities" } +sp-std = { path = "../substrate/primitives/std" } +sp-trie = { path = "../substrate/primitives/trie" } +sp-block-builder = { path = "../substrate/primitives/block-builder" } +sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +sp-tracing = { path = "../substrate/primitives/tracing" } +sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +sp-consensus = { path = "../substrate/primitives/consensus/common" } +sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +sp-io = { path = "../substrate/primitives/io" } +sp-timestamp = { path = "../substrate/primitives/timestamp" } +sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +sp-core = { path = "../substrate/primitives/core" } +sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +sp-database = { path = "../substrate/primitives/database" } +sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +sp-version = { path = "../substrate/primitives/version" } +extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +mangata-types = { path = "../substrate/primitives/mangata-types" } +sp-rpc = { path = "../substrate/primitives/rpc" } +sp-ver = { path = "../substrate/primitives/ver" } +sp-blockchain = { path = "../substrate/primitives/blockchain" } +sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +sp-runtime = { path = "../substrate/primitives/runtime" } +sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +sp-staking = { path = "../substrate/primitives/staking" } +sp-weights = { path = "../substrate/primitives/weights" } +sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +sp-authorship = { path = "../substrate/primitives/authorship" } +sp-storage = { path = "../substrate/primitives/storage" } +sp-inherents = { path = "../substrate/primitives/inherents" } +frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } +sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } +sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } +sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } +sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } +pallet-root-testing = { path = "../substrate/frame/root-testing" } -# patch generated by ./scripts/dev-0.9.29_manifest.sh +# patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/PureStake/substrate"] -sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/mangata-finance/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } - -# # # patch generated by ./scripts/dev_manifest.sh -# # [patch."https://github.com/paritytech/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } - -# # patch generated by ./scripts/dev_manifest.sh -# [patch."https://github.com/PureStake/substrate"] -# sc-offchain = { path = "../substrate/client/offchain" } -# sc-keystore = { path = "../substrate/client/keystore" } -# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -# sc-informant = { path = "../substrate/client/informant" } -# sc-client-db = { path = "../substrate/client/db" } -# sc-rpc-api = { path = "../substrate/client/rpc-api" } -# sc-client-api = { path = "../substrate/client/api" } -# sc-block-builder = { path = "../substrate/client/block-builder" } -# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -# sc-utils = { path = "../substrate/client/utils" } -# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -# sc-tracing = { path = "../substrate/client/tracing" } -# sc-state-db = { path = "../substrate/client/state-db" } -# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -# sc-consensus = { path = "../substrate/client/consensus/common" } -# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -# sc-executor = { path = "../substrate/client/executor" } -# sc-executor-common = { path = "../substrate/client/executor/common" } -# sc-cli = { path = "../substrate/client/cli" } -# sc-peerset = { path = "../substrate/client/peerset" } -# sc-telemetry = { path = "../substrate/client/telemetry" } -# sc-allocator = { path = "../substrate/client/allocator" } -# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -# sc-network-gossip = { path = "../substrate/client/network-gossip" } -# sc-sysinfo = { path = "../substrate/client/sysinfo" } -# sc-rpc-server = { path = "../substrate/client/rpc-servers" } -# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -# sc-rpc = { path = "../substrate/client/rpc" } -# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -# sc-chain-spec = { path = "../substrate/client/chain-spec" } -# sc-network-sync = { path = "../substrate/client/network/sync" } -# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -# sc-network-light = { path = "../substrate/client/network/light" } -# sc-network-transactions = { path = "../substrate/client/network/transactions" } -# sc-network = { path = "../substrate/client/network" } -# sc-network-common = { path = "../substrate/client/network/common" } -# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -# sc-service = { path = "../substrate/client/service" } -# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -# fork-tree = { path = "../substrate/utils/fork-tree" } -# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -# pallet-referenda = { path = "../substrate/frame/referenda" } -# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -# pallet-utility = { path = "../substrate/frame/utility" } -# pallet-session = { path = "../substrate/frame/session" } -# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -# pallet-treasury = { path = "../substrate/frame/treasury" } -# pallet-sudo = { path = "../substrate/frame/sudo" } -# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -# pallet-membership = { path = "../substrate/frame/membership" } -# pallet-recovery = { path = "../substrate/frame/recovery" } -# pallet-tips = { path = "../substrate/frame/tips" } -# pallet-balances = { path = "../substrate/frame/balances" } -# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -# frame-executive = { path = "../substrate/frame/executive" } -# pallet-timestamp = { path = "../substrate/frame/timestamp" } -# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -# pallet-preimage = { path = "../substrate/frame/preimage" } -# frame-try-runtime = { path = "../substrate/frame/try-runtime" } -# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -# pallet-society = { path = "../substrate/frame/society" } -# pallet-identity = { path = "../substrate/frame/identity" } -# pallet-babe = { path = "../substrate/frame/babe" } -# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -# pallet-vesting = { path = "../substrate/frame/vesting" } -# pallet-bounties = { path = "../substrate/frame/bounties" } -# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -# pallet-indices = { path = "../substrate/frame/indices" } -# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -# pallet-collective = { path = "../substrate/frame/collective" } -# pallet-multisig = { path = "../substrate/frame/multisig" } -# pallet-offences = { path = "../substrate/frame/offences" } -# pallet-scheduler = { path = "../substrate/frame/scheduler" } -# pallet-nis = { path = "../substrate/frame/nis" } -# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -# frame-system = { path = "../substrate/frame/system" } -# frame-benchmarking = { path = "../substrate/frame/benchmarking" } -# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -# pallet-proxy = { path = "../substrate/frame/proxy" } -# pallet-whitelist = { path = "../substrate/frame/whitelist" } -# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -# pallet-bags-list = { path = "../substrate/frame/bags-list" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -# frame-support = { path = "../substrate/frame/support" } -# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -# frame-support-procedural = { path = "../substrate/frame/support/procedural" } -# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -# pallet-staking = { path = "../substrate/frame/staking" } -# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -# pallet-grandpa = { path = "../substrate/frame/grandpa" } -# pallet-democracy = { path = "../substrate/frame/democracy" } -# pallet-beefy = { path = "../substrate/frame/beefy" } -# pallet-aura = { path = "../substrate/frame/aura" } -# pallet-authorship = { path = "../substrate/frame/authorship" } -# pallet-im-online = { path = "../substrate/frame/im-online" } -# mangata-support = { path = "../substrate/frame/mangata-support" } -# substrate-test-client = { path = "../substrate/test-utils/client" } -# sp-offchain = { path = "../substrate/primitives/offchain" } -# sp-keystore = { path = "../substrate/primitives/keystore" } -# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -# sp-keyring = { path = "../substrate/primitives/keyring" } -# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -# sp-state-machine = { path = "../substrate/primitives/state-machine" } -# sp-session = { path = "../substrate/primitives/session" } -# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -# ver-api = { path = "../substrate/primitives/ver-api" } -# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -# sp-api = { path = "../substrate/primitives/api" } -# sp-externalities = { path = "../substrate/primitives/externalities" } -# sp-std = { path = "../substrate/primitives/std" } -# sp-trie = { path = "../substrate/primitives/trie" } -# sp-block-builder = { path = "../substrate/primitives/block-builder" } -# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -# sp-tracing = { path = "../substrate/primitives/tracing" } -# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -# sp-consensus = { path = "../substrate/primitives/consensus/common" } -# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -# sp-io = { path = "../substrate/primitives/io" } -# sp-timestamp = { path = "../substrate/primitives/timestamp" } -# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -# sp-core = { path = "../substrate/primitives/core" } -# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -# sp-database = { path = "../substrate/primitives/database" } -# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -# sp-version = { path = "../substrate/primitives/version" } -# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -# mangata-types = { path = "../substrate/primitives/mangata-types" } -# sp-rpc = { path = "../substrate/primitives/rpc" } -# sp-ver = { path = "../substrate/primitives/ver" } -# sp-blockchain = { path = "../substrate/primitives/blockchain" } -# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -# sp-runtime = { path = "../substrate/primitives/runtime" } -# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -# sp-staking = { path = "../substrate/primitives/staking" } -# sp-weights = { path = "../substrate/primitives/weights" } -# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -# sp-authorship = { path = "../substrate/primitives/authorship" } -# sp-storage = { path = "../substrate/primitives/storage" } -# sp-inherents = { path = "../substrate/primitives/inherents" } +sc-offchain = { path = "../substrate/client/offchain" } +sc-keystore = { path = "../substrate/client/keystore" } +mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +sc-informant = { path = "../substrate/client/informant" } +sc-client-db = { path = "../substrate/client/db" } +sc-rpc-api = { path = "../substrate/client/rpc-api" } +sc-client-api = { path = "../substrate/client/api" } +sc-block-builder = { path = "../substrate/client/block-builder" } +sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +sc-utils = { path = "../substrate/client/utils" } +sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +sc-tracing = { path = "../substrate/client/tracing" } +sc-state-db = { path = "../substrate/client/state-db" } +sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +sc-consensus = { path = "../substrate/client/consensus/common" } +sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +sc-executor = { path = "../substrate/client/executor" } +sc-executor-common = { path = "../substrate/client/executor/common" } +sc-cli = { path = "../substrate/client/cli" } +sc-peerset = { path = "../substrate/client/peerset" } +sc-telemetry = { path = "../substrate/client/telemetry" } +sc-allocator = { path = "../substrate/client/allocator" } +sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +sc-network-gossip = { path = "../substrate/client/network-gossip" } +sc-sysinfo = { path = "../substrate/client/sysinfo" } +sc-rpc-server = { path = "../substrate/client/rpc-servers" } +sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +sc-rpc = { path = "../substrate/client/rpc" } +sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +sc-chain-spec = { path = "../substrate/client/chain-spec" } +sc-network-sync = { path = "../substrate/client/network/sync" } +sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +sc-network-light = { path = "../substrate/client/network/light" } +sc-network-transactions = { path = "../substrate/client/network/transactions" } +sc-network = { path = "../substrate/client/network" } +sc-network-common = { path = "../substrate/client/network/common" } +sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +sc-service = { path = "../substrate/client/service" } +substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +fork-tree = { path = "../substrate/utils/fork-tree" } +frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +pallet-referenda = { path = "../substrate/frame/referenda" } +pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +pallet-utility = { path = "../substrate/frame/utility" } +pallet-session = { path = "../substrate/frame/session" } +pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +pallet-treasury = { path = "../substrate/frame/treasury" } +pallet-sudo = { path = "../substrate/frame/sudo" } +pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +pallet-membership = { path = "../substrate/frame/membership" } +pallet-recovery = { path = "../substrate/frame/recovery" } +pallet-tips = { path = "../substrate/frame/tips" } +pallet-balances = { path = "../substrate/frame/balances" } +pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +frame-executive = { path = "../substrate/frame/executive" } +pallet-timestamp = { path = "../substrate/frame/timestamp" } +pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +pallet-preimage = { path = "../substrate/frame/preimage" } +frame-try-runtime = { path = "../substrate/frame/try-runtime" } +pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +pallet-society = { path = "../substrate/frame/society" } +pallet-identity = { path = "../substrate/frame/identity" } +pallet-babe = { path = "../substrate/frame/babe" } +pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +pallet-vesting = { path = "../substrate/frame/vesting" } +pallet-bounties = { path = "../substrate/frame/bounties" } +frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +pallet-indices = { path = "../substrate/frame/indices" } +pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +pallet-collective = { path = "../substrate/frame/collective" } +pallet-multisig = { path = "../substrate/frame/multisig" } +pallet-offences = { path = "../substrate/frame/offences" } +pallet-scheduler = { path = "../substrate/frame/scheduler" } +pallet-nis = { path = "../substrate/frame/nis" } +frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +frame-system = { path = "../substrate/frame/system" } +frame-benchmarking = { path = "../substrate/frame/benchmarking" } +pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +pallet-proxy = { path = "../substrate/frame/proxy" } +pallet-whitelist = { path = "../substrate/frame/whitelist" } +pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +pallet-bags-list = { path = "../substrate/frame/bags-list" } +pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +frame-support = { path = "../substrate/frame/support" } +frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +frame-support-procedural = { path = "../substrate/frame/support/procedural" } +pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +pallet-staking = { path = "../substrate/frame/staking" } +pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +pallet-grandpa = { path = "../substrate/frame/grandpa" } +pallet-democracy = { path = "../substrate/frame/democracy" } +pallet-beefy = { path = "../substrate/frame/beefy" } +pallet-aura = { path = "../substrate/frame/aura" } +pallet-authorship = { path = "../substrate/frame/authorship" } +pallet-im-online = { path = "../substrate/frame/im-online" } +mangata-support = { path = "../substrate/frame/mangata-support" } +substrate-test-client = { path = "../substrate/test-utils/client" } +sp-offchain = { path = "../substrate/primitives/offchain" } +sp-keystore = { path = "../substrate/primitives/keystore" } +sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +sp-keyring = { path = "../substrate/primitives/keyring" } +sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +sp-state-machine = { path = "../substrate/primitives/state-machine" } +sp-session = { path = "../substrate/primitives/session" } +sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +ver-api = { path = "../substrate/primitives/ver-api" } +sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +sp-api = { path = "../substrate/primitives/api" } +sp-externalities = { path = "../substrate/primitives/externalities" } +sp-std = { path = "../substrate/primitives/std" } +sp-trie = { path = "../substrate/primitives/trie" } +sp-block-builder = { path = "../substrate/primitives/block-builder" } +sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +sp-tracing = { path = "../substrate/primitives/tracing" } +sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +sp-consensus = { path = "../substrate/primitives/consensus/common" } +sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +sp-io = { path = "../substrate/primitives/io" } +sp-timestamp = { path = "../substrate/primitives/timestamp" } +sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +sp-core = { path = "../substrate/primitives/core" } +sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +sp-database = { path = "../substrate/primitives/database" } +sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +sp-version = { path = "../substrate/primitives/version" } +extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +mangata-types = { path = "../substrate/primitives/mangata-types" } +sp-rpc = { path = "../substrate/primitives/rpc" } +sp-ver = { path = "../substrate/primitives/ver" } +sp-blockchain = { path = "../substrate/primitives/blockchain" } +sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +sp-runtime = { path = "../substrate/primitives/runtime" } +sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +sp-staking = { path = "../substrate/primitives/staking" } +sp-weights = { path = "../substrate/primitives/weights" } +sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +sp-authorship = { path = "../substrate/primitives/authorship" } +sp-storage = { path = "../substrate/primitives/storage" } +sp-inherents = { path = "../substrate/primitives/inherents" } +frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } +sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } +sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } +sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } +sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } +pallet-root-testing = { path = "../substrate/frame/root-testing" } # # patch generated by ./scripts/dev_manifest.sh # [patch."https://github.com/mangata-finance/cumulus"] diff --git a/devops/parachain-launch/config.yml b/devops/parachain-launch/config.yml index 5f733fcd56..388bee31c5 100644 --- a/devops/parachain-launch/config.yml +++ b/devops/parachain-launch/config.yml @@ -17,7 +17,7 @@ relaychain: - name: bob parachains: -- image: mangatasolutions/mangata-node:develop +- image: mangatasolutions/mangata-node:dev chain: base: rococo-local collators: diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index c222722179..c6aedfa0ad 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -62,7 +62,10 @@ std = [ "scale-info/std", ] -runtime-benchmarks = ["frame-benchmarking/runtime-benchmarks"] +runtime-benchmarks = [ + "frame-benchmarking/runtime-benchmarks", + "mangata-support/runtime-benchmarks", +] try-runtime = [ "frame-support/try-runtime", diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index aeae157e53..68e43e3a7e 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -93,9 +93,19 @@ use frame_support::pallet_prelude::*; +pub type ScheduleId = u64; + +#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] +pub struct Schedule{ + last_session: u64, + liq_token: TokenId, + reward_token: TokenId, + amount_per_session: Balance, +} + use frame_benchmarking::Zero; use frame_support::{ - dispatch::{DispatchError, DispatchResult}, + dispatch::{DispatchError, DispatchErrorWithPostInfo, PostDispatchInfo, DispatchResult}, ensure, storage::bounded_btree_map::BoundedBTreeMap, traits::Nothing, @@ -176,7 +186,107 @@ pub mod pallet { pub struct Pallet(PhantomData); #[pallet::hooks] - impl Hooks for Pallet {} + impl Hooks for Pallet { + fn on_initialize(n: T::BlockNumber) -> Weight { + const AMOUNT_PER_BLOCK: u64 = 5; + + // NOTE: 3R + let mut prev = None; + let mut pos = match ( + ScheduleListPos::::get(), + ScheduleListHead::::get(), + ScheduleListTail::::get(), + ){ + (None, None, None) => { + None + }, + (Some(pos), Some(head), Some(tail)) if pos == tail => { + None + }, + (None, Some(head), Some(_tail)) => { + Some(head) + }, + (Some(pos), Some(_head), Some(_tail)) => { + Some(pos + 1) + }, + }; + + // 1R 1W 15RW + + //NOTE: 5 transfers => 15R 15W + + // TODO: make configurable + // NOTE: 3R + 1R + let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5u64; + + for _ in 0..AMOUNT_PER_BLOCK { + match (prev.as_mut(),pos.as_mut()) { + (Some(prev_val), Some(pos_val)) => { + if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ + + ScheduleRewardsTotal::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ + if schedule.last_session < session_id{ + *val += schedule.amount_per_session; + *pos = Some(next); + *prev = Some(pos_val); + }else{ + // NOTE: consider removing elements from list + RewardsSchedulesList::::mutate(prev_val, |data|{ + if let Some((schedule, prev_next)) = data{ + *prev_next = next; + } + }); + ScheduleListTail::::put(prev_val); + } + }); + + }else{ + break; + } + }, + (None, Some(pos_val)) => { + if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ + ScheduleRewardsTotal::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ + if schedule.last_session < session_id{ + *val += schedule.amount_per_session; + *pos = Some(next); + *prev = Some(pos_val); + }else{ + // NOTE: consider removing elements from list + ScheduleListHead::::kill(); + ScheduleListTail::::kill(); + } + }); + }else{ + break; + } + }, + (Some(pos), None) => { + break; + }, + (None, None) => { + break; + } + + } + } + Default::default() + // if let Some((schedule, next)) = RewardsSchedulesList::::get(pos){ + // ScheduleRewardsTotal::mutate_exists((schedule.liq_token, schedudle.reward_token, session_id), |val|{ + // if schedudle.last_session <= session_id{ + // *val += schedule.amount_per_session; + // pos = next; + // }else{ + // None + // } + // }) + // }else{ + // break; + // + // } + // + } + } #[cfg(feature = "runtime-benchmarks")] pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} @@ -267,8 +377,8 @@ pub mod pallet { TooManySchedules, /// Too little rewards per session TooLittleRewards, - /// Reward token not paired with native token - RewardTokenNotPairdWithNativeToken, + // Liquidity is reused for 3rdparty rewards + LiquidityLockedIn3rdpartyRewards, } #[pallet::event] @@ -336,7 +446,12 @@ pub mod pallet { /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] pub type ScheduleRewardsPerSingleLiquidity = - StorageValue<_, BTreeMap<(TokenId, TokenId), U256>, ValueQuery>; + StorageValue<_, BTreeMap<(TokenId, TokenId), u128>, ValueQuery>; + + /// How much scheduled rewards per single liquidty_token should be distribute_rewards + /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic + #[pallet::storage] + pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat ,(TokenId, TokenId, u64), u128, ValueQuery>; /// List of activated schedules sorted by expiry date #[pallet::storage] @@ -351,9 +466,17 @@ pub mod pallet { ValueQuery, >; - /// Unique id of the schedule #[pallet::storage] - pub type ScheduleId = StorageValue<_, u64, ValueQuery>; + pub type ScheduleListPos = StorageValue<_, ScheduleId, OptionQuery>; + + #[pallet::storage] + pub type ScheduleListHead = StorageValue<_, ScheduleId, OptionQuery>; + + #[pallet::storage] + pub type ScheduleListTail = StorageValue<_, ScheduleId, OptionQuery>; + + #[pallet::storage] + pub type RewardsSchedulesList = StorageMap<_, Twox64Concat, ScheduleId, (Schedule, Option), OptionQuery>; /// Maps liquidity token to list of tokens that it ever was rewarded with #[pallet::storage] @@ -363,7 +486,11 @@ pub mod pallet { /// Total amount of activated liquidity for each schedule #[pallet::storage] pub type TotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u64, u128), ValueQuery>; + + #[pallet::storage] + pub type PrevTotalActivatedLiquidityForSchedules = + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u64, u128), ValueQuery>; /// Tracks how much liquidity user activated for particular (liq token, reward token) pair /// StorageNMap was used because it only require single read to know if user deactivated all @@ -388,6 +515,13 @@ pub mod pallet { pub type ActivatedLockedLiquidityForSchedules = StorageDoubleMap<_, Twox64Concat, AccountIdOf, Twox64Concat, TokenId, u128, ValueQuery>; + /// Tracks how much of the liquidity was activated for schedule rewards and not yet + /// liquidity mining rewards. That information is essential to properly handle token unlcocks + /// when liquidity is deactivated. + #[pallet::storage] + pub type ActivatedNativeRewardsLiq = + StorageDoubleMap<_, Twox64Concat, AccountIdOf, Twox64Concat, TokenId, u128, ValueQuery>; + #[pallet::call] impl Pallet { /// Claims liquidity mining rewards @@ -476,6 +610,7 @@ pub mod pallet { /// - amount - amount of the token /// - schedule_end - id of the last rewarded seession. Rewards will be distributedd equally between sessions in range (now .. /// schedule_end). Distribution starts from the *next* session till `schedule_end`. + // TODO: delays schedule by 1 session #[transactional] #[pallet::call_index(4)] #[pallet::weight(<::WeightInfo>::reward_pool())] @@ -487,71 +622,7 @@ pub mod pallet { schedule_end: T::BlockNumber, ) -> DispatchResult { let sender = ensure_signed(origin)?; - - let liquidity_token_id = - ::ValuationApi::get_liquidity_asset(pool.0, pool.1) - .map_err(|_| Error::::PoolDoesNotExist)?; - - let current_session = Self::session_index(); - ensure!( - schedule_end.saturated_into::() > current_session, - Error::::CannotScheduleRewardsInPast - ); - - let amount_per_session = schedule_end - .saturated_into::() - .checked_sub(current_session) - .and_then(|v| amount.checked_div(v.into())) - .ok_or(Error::::MathOverflow)?; - - ensure!( - pool.0 == Self::native_token_id() || pool.1 == Self::native_token_id(), - Error::::RewardTokenNotPairdWithNativeToken - ); - - let valutation = - ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount); - - ensure!( - ::ValuationApi::valuate_liquidity_token(liquidity_token_id, amount) >= - T::Min3rdPartyRewards::get() || - ((token_id == Into::::into(Self::native_token_id())) && - amount_per_session >= T::Min3rdPartyRewards::get()), - Error::::TooLittleRewards - ); - - RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); - - T::Currency::transfer( - token_id.into(), - &sender, - &Self::pallet_account(), - amount.into(), - ExistenceRequirement::KeepAlive, - )?; - - let current_session = Self::session_index(); - let schedule_id = ScheduleId::::get(); - - RewardsSchedules::::try_mutate(|map| { - let key: Option<(_, _, _, _, _)> = map.first_key_value().map(|(x, y)| x.clone()); - - if let Some(val) = key { - if current_session > val.0.saturated_into::() { - map.remove_entry(&val); - } - } - - map.try_insert( - (schedule_end, liquidity_token_id, token_id, amount_per_session, schedule_id), - (), - ) - }) - .or(Err(Error::::TooManySchedules))?; - - ScheduleId::::mutate(|v| *v += 1); - - Ok(()) + Self::reward_pool_impl(sender, pool, token_id, amount, schedule_end) } /// Increases number of tokens used for liquidity mining purposes. @@ -570,7 +641,7 @@ pub mod pallet { amount: Balance, reward_token: TokenId, use_balance_from: Option, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; Self::activate_liquidity_for_3rdparty_rewards_impl( @@ -580,6 +651,14 @@ pub mod pallet { use_balance_from.unwrap_or(ThirdPartyActivationKind::ActivateKind(None)), reward_token, ) + .map_err(|err| DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(<::WeightInfo>::activate_liquidity_for_3rdparty_rewards()), + pays_fee: Pays::Yes, + }, + error: err, + })?; + Ok(Pays::No.into()) } /// Decreases number of tokens used for liquidity mining purposes. @@ -596,7 +675,7 @@ pub mod pallet { liquidity_token_id: TokenId, amount: Balance, reward_token: TokenId, - ) -> DispatchResult { + ) -> DispatchResultWithPostInfo { let sender = ensure_signed(origin)?; Self::deactivate_liquidity_for_3rdparty_rewards_impl( @@ -605,6 +684,14 @@ pub mod pallet { amount, reward_token, ) + .map_err(|err| DispatchErrorWithPostInfo { + post_info: PostDispatchInfo { + actual_weight: Some(<::WeightInfo>::activate_liquidity_for_3rdparty_rewards()), + pays_fee: Pays::Yes, + }, + error: err, + })?; + Ok(Pays::No.into()) } /// Claims liquidity mining rewards @@ -685,6 +772,33 @@ pub mod pallet { } impl Pallet { + + fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ + let (idx, amount) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); + if idx == (frame_system::Pallet::::block_number().saturated_into::() / 5){ + amount + }else{ + PrevTotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward).1 + } + } + + fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { + // TODO: make configurable + let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5; + if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ + let new_amount = if change{ + amount + diff + }else{ + amount - diff + }; + + if session_id > idx { + PrevTotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (idx, amount)); + } + TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, new_amount)); + } + } + fn activate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -744,6 +858,12 @@ impl Pallet { liquidity_asset_id: TokenId, amount: Balance, ) -> DispatchResult { + + ensure!( + ActivatedNativeRewardsLiq::::get(user.clone(), liquidity_asset_id) == 0, + Error::::LiquidityLockedIn3rdpartyRewards + ); + if amount > 0 { Self::set_liquidity_burning_checkpoint(user.clone(), liquidity_asset_id, amount)?; Pallet::::deposit_event(Event::LiquidityDeactivated( @@ -811,6 +931,11 @@ impl Pallet { already_activated_amount + amount <= available_amount, Error::::NotEnoughAssets ); + ActivatedNativeRewardsLiq::::mutate( + user.clone(), + liquidity_asset_id, + |val| *val += amount, + ); }, } @@ -1020,15 +1145,17 @@ impl Pallet { }, )?; - TotalActivatedLiquidityForSchedules::::mutate( - liquidity_asset_id, - liquidity_assets_reward, - |amount| -> DispatchResult { - *amount = - amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; - Ok(()) - }, - )?; + Self::update_total_activated_liqudity(liquidity_asset_id, liquidity_assets_reward, liquidity_assets_added, true); + + // TotalActivatedLiquidityForSchedules::::mutate( + // liquidity_asset_id, + // liquidity_assets_reward, + // |amount| -> DispatchResult { + // *amount = + // amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; + // Ok(()) + // }, + // )?; Ok(()) } @@ -1099,15 +1226,17 @@ impl Pallet { rewards_info, ); - TotalActivatedLiquidityForSchedules::::try_mutate( - liquidity_asset_id, - reward_token, - |amount| -> DispatchResult { - *amount = - amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; - Ok(()) - }, - )?; + + Self::update_total_activated_liqudity(liquidity_asset_id, reward_token, liquidity_assets_burned, false); + // TotalActivatedLiquidityForSchedules::::try_mutate( + // liquidity_asset_id, + // reward_token, + // |amount| -> DispatchResult { + // *amount = + // amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; + // Ok(()) + // }, + // )?; ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), @@ -1147,6 +1276,17 @@ impl Pallet { &user, amount, ); + + let amount = ActivatedNativeRewardsLiq::::mutate( + user.clone(), + liquidity_asset_id, + |val| { + let prev = *val; + *val = 0; + prev + }, + ); + } Ok(()) @@ -1189,6 +1329,80 @@ impl Pallet { Ok(total_available_rewards) } + + pub (crate) fn reward_pool_impl( + sender: T::AccountId, + pool: (TokenId, TokenId), + token_id: TokenId, + amount: Balance, + schedule_end: T::BlockNumber, + ) -> DispatchResult { + + let liquidity_token_id = + ::ValuationApi::get_liquidity_asset(pool.0, pool.1) + .map_err(|_| Error::::PoolDoesNotExist)?; + + let current_session = Self::session_index(); + ensure!( + schedule_end.saturated_into::() > current_session, + Error::::CannotScheduleRewardsInPast + ); + + let amount_per_session = schedule_end + .saturated_into::() + .checked_sub(current_session) + .and_then(|v| amount.checked_div(v.into())) + .ok_or(Error::::MathOverflow)?; + + ensure!( + ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewards::get() || + ((token_id == Into::::into(Self::native_token_id())) && amount_per_session >= T::Min3rdPartyRewards::get()) || + ::ValuationApi::valuate_non_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewards::get() + , + Error::::TooLittleRewards + ); + + RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); + + T::Currency::transfer( + token_id.into(), + &sender, + &Self::pallet_account(), + amount.into(), + ExistenceRequirement::KeepAlive, + )?; + + let current_session = Self::session_index(); + + let head = ScheduleListHead::::get(); + let tail = ScheduleListTail::::get(); + let schedule = Schedule{ + last_session: schedule_end.saturated_into::(), + liq_token: liquidity_token_id, + reward_token: token_id, + amount_per_session: amount_per_session + }; + + match (head, tail){ + (None, None) => { // first schedule + RewardsSchedulesList::::insert(0, (schedule, None::)); + ScheduleListHead::::put(0); + ScheduleListTail::::put(0); + }, + (Some(_head), Some(tail)) => { + RewardsSchedulesList::::mutate(tail, |info| { + if let Some((_schedule, next)) = info.as_mut(){ + *next = Some(tail + 1u64) + } + }); + RewardsSchedulesList::::insert(tail + 1, (schedule, None::)); + ScheduleListHead::::put(tail + 1); + }, + _ => {} // invariant assures this will never happen + } + + Ok(()) + } } impl ProofOfStakeRewardsApi for Pallet { @@ -1196,6 +1410,18 @@ impl ProofOfStakeRewardsApi for Pallet { type CurrencyId = TokenId; + #[cfg(feature = "runtime-benchmarks")] + fn enable_3rdparty_rewards(account: T::AccountId, pool: (Self::CurrencyId,Self::CurrencyId), reward_token_id: Self::CurrencyId, last_session: u32, amount: Self::Balance){ + let liquidity_token_id = ::ValuationApi::get_liquidity_asset(pool.0, pool.1).expect("pool exist"); + log!(info, "XXXX {}", liquidity_token_id); + Pallet::::reward_pool_impl(account.clone(), pool, reward_token_id, amount, last_session.into()).expect("call should pass"); + } + + #[cfg(feature = "runtime-benchmarks")] + fn activate_liquidity_for_3rdparty_rewards(account: T::AccountId, liquidity_token: Self::CurrencyId, amount: Self::Balance, reward_token_id: Self::CurrencyId){ + Pallet::::activate_liquidity_for_3rdparty_rewards_impl(account, liquidity_token, amount, ThirdPartyActivationKind::ActivateKind(None), reward_token_id).expect("call should pass") + } + fn enable(liquidity_token_id: TokenId, weight: u8) { PromotedPoolRewards::::mutate(|promoted_pools| { promoted_pools @@ -1282,44 +1508,44 @@ impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { // R:1 W:0 - let schedules = RewardsSchedules::::get(); - - // R:1 W:0 - let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); - - let it = - schedules - .iter() - .filter_map(|((session, rewarded_token, tokenid, amount, _), ())| { - if (*session).saturated_into::() >= Self::session_index() { - Some((rewarded_token, tokenid, amount)) - } else { - None - } - }); - - for (staked_token, rewarded_token, amount) in it { - // R: T::RewardsSchedulesLimit - in most pesimistic case - match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { - 0 => {}, - activated_amount => { - let activated_amount = U256::from(activated_amount); - let rewards = - pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); - let rewards_for_liquidity = U256::from(*amount) - .checked_mul(U256::from(u128::MAX)) - .and_then(|x| x.checked_div(activated_amount)) - .and_then(|x| x.checked_add(rewards)); - - if let Some(val) = rewards_for_liquidity { - pools.insert((*staked_token, *rewarded_token), val); - } - }, - } - } - - ScheduleRewardsPerSingleLiquidity::::put(pools); - + // let schedules = RewardsSchedules::::get(); + // + // // R:1 W:0 + // let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); + // + // let it = + // schedules + // .iter() + // .filter_map(|((session, rewarded_token, tokenid, amount, _), ())| { + // if (*session).saturated_into::() >= Self::session_index() { + // Some((rewarded_token, tokenid, amount)) + // } else { + // None + // } + // }); + // + // for (staked_token, rewarded_token, amount) in it { + // // R: T::RewardsSchedulesLimit - in most pesimistic case + // match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { + // 0 => {}, + // activated_amount => { + // let activated_amount = U256::from(activated_amount); + // let rewards = + // pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); + // let rewards_for_liquidity = U256::from(*amount) + // .checked_mul(U256::from(u128::MAX)) + // .and_then(|x| x.checked_div(activated_amount)) + // .and_then(|x| x.checked_add(rewards)); + // + // if let Some(val) = rewards_for_liquidity { + // pools.insert((*staked_token, *rewarded_token), val); + // } + // }, + // } + // } + // + // ScheduleRewardsPerSingleLiquidity::::put(pools); + // let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { // benchmark with max of X prom pools let activated_pools: Vec<_> = promoted_pools diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index e87d04afd3..ebaddba9d0 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -217,6 +217,11 @@ mockall::mock! { liquidity_token_amount: Balance, ) -> Balance; + fn valuate_non_liquidity_token( + liquidity_token_id: TokenId, + liquidity_token_amount: Balance, + ) -> Balance; + fn scale_liquidity_by_mga_valuation( mga_valuation: Balance, liquidity_token_amount: Balance, diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index b4ba8c7e85..f70b201653 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -86,17 +86,22 @@ impl RewardsCalculator { crate::Error::::NotAPromotedPool ); - let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); + // NOTE: take into acout previous rewards (prev + rewards/activated) + let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); + let total_rewards = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); + let pool_ratio_current = total_rewards/total_activated; - let pool_ratio_current = - pool_map.get(&(asset_id, reward_asset_id)).cloned().unwrap_or(U256::from(0)); + // let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); + + // let pool_ratio_current = + // pool_map.get(&(asset_id, reward_asset_id)).cloned().unwrap_or(U256::from(0)); let default_rewards = RewardInfo { activated_amount: 0_u128, rewards_not_yet_claimed: 0_u128, rewards_already_claimed: 0_u128, last_checkpoint: current_time, - pool_ratio_at_last_checkpoint: pool_ratio_current, + pool_ratio_at_last_checkpoint: pool_ratio_current.into(), missing_at_last_checkpoint: U256::from(0u128), }; @@ -109,7 +114,7 @@ impl RewardsCalculator { Ok(Self { rewards_context: RewardsContext { current_time: Pallet::::get_current_rewards_time()?, - pool_ratio_current, + pool_ratio_current: pool_ratio_current.into(), }, rewards_info, _curve: PhantomData::, diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 021cb35605..e2a62f5f65 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -4,7 +4,7 @@ use super::*; use crate::mock::*; -use frame_support::{assert_err, assert_ok}; +use frame_support::{assert_err, assert_err_ignore_postinfo,assert_ok}; use mockall::predicate::eq; use serial_test::serial; @@ -1218,6 +1218,7 @@ const SECOND_REWARD_TOKEN: u32 = 6u32; const LIQUIDITY_TOKEN: u32 = 10; const FIRST_LIQUIDITY_TOKEN: u32 = 10; const SECOND_LIQUIDITY_TOKEN: u32 = 11; +const TOKEN_PAIRED_WITH_MGX: u32 = 15; const ALICE: u128 = 2; const BOB: u128 = 3; const CHARLIE: u128 = 4; @@ -1490,6 +1491,9 @@ fn reject_schedule_with_too_little_rewards_per_session() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(1u128); + let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + valuate_non_liquidity_token_mock.expect().return_const(0u128); + roll_to_session(4); assert_err!( @@ -1516,7 +1520,7 @@ fn accept_schedule_valuated_in_native_token() { let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(10u32)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(1u128); + valuate_liquidity_token_mock.expect().return_const(0u128); roll_to_session(4); @@ -1530,6 +1534,37 @@ fn accept_schedule_valuated_in_native_token() { }); } +#[test] +#[serial] +fn accept_schedule_valuated_in_token_paired_with_native_token() { + ExtBuilder::new() + .issue(ALICE, ProofOfStake::native_token_id(), REWARD_AMOUNT) + .issue(ALICE, TOKEN_PAIRED_WITH_MGX, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(0u128); + + let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + valuate_non_liquidity_token_mock.expect().return_const(10u128); + + roll_to_session(4); + + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + TOKEN_PAIRED_WITH_MGX, + REWARD_AMOUNT, + 5u32.into() + ),); + }); +} + + #[test] #[serial] fn user_can_claim_3rdparty_rewards() { @@ -1853,6 +1888,7 @@ fn deactivate_3rdparty_rewards() { }); } + #[test] #[serial] fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() { @@ -2158,6 +2194,99 @@ fn liquidity_minting_liquidity_can_be_resused() { }); } +#[test] +#[serial] +fn fail_to_transfer_tokens_that_has_been_partially_deactivated() { + // 1. activate tokens for native rewards + // 2. re-activate tokens for 3rdparty rewards + // 4. deactivate tokens for 3rdparty rewards + // 5. fail to transfer assets as they are still locked + // 6. deactivate tokens for native rewards + // 7. successfully transfer unlocked tokens + ExtBuilder::new() + .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) + .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) + .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + FIRST_REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ).unwrap(); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + Some(ThirdPartyActivationKind::LiquidityMining), + ) + .unwrap(); + + assert_err!( + ProofOfStake::deactivate_liquidity_for_native_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + ), + Error::::LiquidityLockedIn3rdpartyRewards + ); + + assert_err!( + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ), + orml_tokens::Error::::BalanceTooLow + ); + + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + FIRST_REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_native_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + ) + .unwrap(); + + assert_ok!( + TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + ) + ); + + }); +} + #[test] #[serial] fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { @@ -2464,7 +2593,7 @@ fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_li ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); - assert_err!( + assert_err_ignore_postinfo!( ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2512,3 +2641,89 @@ fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_sche ); }); } + +use frame_support::dispatch::{GetDispatchInfo, Pays}; +use sp_runtime::{traits::Dispatchable, Permill}; + +#[test] +#[serial] +fn activate_deactivate_calls_are_free_of_charge() { + ExtBuilder::new() + .build() + .execute_with(|| { + System::set_block_number(1); + + let activate_call = mock::RuntimeCall::ProofOfStake( + Call::activate_liquidity_for_3rdparty_rewards{ + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + use_balance_from: None, + } + ); + + let deactivate_call = mock::RuntimeCall::ProofOfStake( + Call::deactivate_liquidity_for_3rdparty_rewards{ + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + } + ); + + assert_eq!( + activate_call.get_dispatch_info().pays_fee, + Pays::No + ); + + assert_eq!( + deactivate_call.get_dispatch_info().pays_fee, + Pays::No + ); + + }); +} + +#[test] +#[serial] +fn unsuccessul_activate_deactivate_calls_charges_fees() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let activate_call = mock::RuntimeCall::ProofOfStake( + Call::activate_liquidity_for_3rdparty_rewards{ + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + use_balance_from: None, + } + ); + + let deactivate_call = mock::RuntimeCall::ProofOfStake( + Call::deactivate_liquidity_for_3rdparty_rewards{ + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + } + ); + + + assert_eq!( + activate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap_err().post_info.pays_fee, + Pays::Yes + ); + + assert_eq!( + deactivate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap_err().post_info.pays_fee, + Pays::Yes + ); + }); +} diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 79db4e5682..4b79ea5018 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -3427,6 +3427,19 @@ impl Valuate for Pallet { .unwrap_or(Balance::max_value()) } + fn valuate_non_liquidity_token( + non_liquidity_token_id: Self::CurrencyId, + amount: Self::Balance, + ) -> Self::Balance { + let native_token_id = Pallet::::native_token_id(); + + let (native_reserves, token_reserves) = match Pallet::::get_reserves(native_token_id, non_liquidity_token_id) { + Ok(reserves) => reserves, + Err(_) => return Default::default(), + }; + Pallet::::calculate_sell_price_no_fee(token_reserves, native_reserves, amount).unwrap_or_default() + } + fn scale_liquidity_by_mga_valuation( mga_valuation: Self::Balance, liquidity_token_amount: Self::Balance, diff --git a/pallets/xyk/src/tests.rs b/pallets/xyk/src/tests.rs index 47861dc9ea..4d224f0cf5 100644 --- a/pallets/xyk/src/tests.rs +++ b/pallets/xyk/src/tests.rs @@ -2581,3 +2581,49 @@ fn buy_W_maintenance_mode() { ); }); } + +#[test] +#[serial] +fn valuate_token_paired_with_mgx() { + new_test_ext().execute_with(|| { + System::set_block_number(1); + let native_token_id = XykStorage::create_new_token(&DUMMY_USER_ID, 2_000_000_u128); + assert_eq!(native_token_id, XykStorage::native_token_id()); + + + let first_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); + let second_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); + let first_token_pool = second_token + 1; + let second_token_pool = second_token + 2; + + + XykStorage::create_pool( + RuntimeOrigin::signed(DUMMY_USER_ID), + native_token_id, + 1_000_000_u128, + first_token, + 500_000_u128, + ) + .unwrap(); + + XykStorage::create_pool( + RuntimeOrigin::signed(DUMMY_USER_ID), + second_token, + 1_000_000_u128, + native_token_id, + 500_000_u128, + ) + .unwrap(); + + + assert_eq!( + as Valuate>::valuate_non_liquidity_token(first_token, 100), + 199 + ); + + assert_eq!( + as Valuate>::valuate_non_liquidity_token(second_token, 100), + 49 + ); + }); +} diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index 7bdff2fdac..b08a94149d 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1371,7 +1371,7 @@ where use super::*; parameter_types! { - pub const RewardsSchedulesLimit: u32 = 150; + pub const RewardsSchedulesLimit: u32 = 200; // TODO: allign properly pub const Min3rdPartyRewards: u128 = 100 * 30_000 * currency::DOLLARS; } From e3521d7cd5e21ac6964cc517ba8a2faa9eb33959 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 13 Oct 2023 10:49:03 +0000 Subject: [PATCH 37/83] basic list operation works --- pallets/proof-of-stake/src/lib.rs | 73 ++++++++++--- pallets/proof-of-stake/src/tests.rs | 163 +++++++++++++++++++++++++++- 2 files changed, 217 insertions(+), 19 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 68e43e3a7e..75e25cda3c 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -188,8 +188,11 @@ pub mod pallet { #[pallet::hooks] impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { + + println!("on_initialize {}", n); const AMOUNT_PER_BLOCK: u64 = 5; + // NOTE: 3R let mut prev = None; let mut pos = match ( @@ -209,8 +212,15 @@ pub mod pallet { (Some(pos), Some(_head), Some(_tail)) => { Some(pos + 1) }, + _ => { + None + }, }; + println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); + println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); + println!("ScheduleListTail : {:?}", ScheduleListTail::::get()); + // 1R 1W 15RW //NOTE: 5 transfers => 15R 15W @@ -219,16 +229,26 @@ pub mod pallet { // NOTE: 3R + 1R let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5u64; - for _ in 0..AMOUNT_PER_BLOCK { - match (prev.as_mut(),pos.as_mut()) { + if frame_system::Pallet::::block_number().saturated_into::() % 5u64 == 0 { + ScheduleListPos::::kill(); + return Default::default(); + } + + for idx in 0..AMOUNT_PER_BLOCK { + println!("iter {}:{}", n, idx); + println!("session_id : {:?}", session_id); + println!("prev : {:?}", prev); + println!("pos : {:?}", pos); + match (prev.clone(), pos.clone()) { (Some(prev_val), Some(pos_val)) => { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - ScheduleRewardsTotal::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ - if schedule.last_session < session_id{ + ScheduleListPos::::put(pos_val); + ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ + if schedule.last_session >= session_id{ *val += schedule.amount_per_session; - *pos = Some(next); - *prev = Some(pos_val); + pos = next; + prev = Some(pos_val); }else{ // NOTE: consider removing elements from list RewardsSchedulesList::::mutate(prev_val, |data|{ @@ -236,25 +256,50 @@ pub mod pallet { *prev_next = next; } }); - ScheduleListTail::::put(prev_val); + pos = next; + if ScheduleListHead::::get().unwrap() == pos_val{ + if let Some(next) = next{ + ScheduleListHead::::put(next); + }else{ + ScheduleListHead::::kill(); + ScheduleListTail::::kill(); + ScheduleListPos::::kill(); + } + } } }); + }else{ break; } }, (None, Some(pos_val)) => { + println!("hello 0"); if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - ScheduleRewardsTotal::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ - if schedule.last_session < session_id{ + println!("hello 1"); + ScheduleListPos::::put(pos_val); + ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ + if schedule.last_session >= session_id{ + println!("hello 2"); *val += schedule.amount_per_session; - *pos = Some(next); - *prev = Some(pos_val); + pos = next; + prev = Some(pos_val); }else{ + println!("hello 3"); // NOTE: consider removing elements from list - ScheduleListHead::::kill(); - ScheduleListTail::::kill(); + if ScheduleListHead::::get().unwrap() == pos_val{ + if let Some(next) = next{ + println!("hello 4"); + ScheduleListHead::::put(next); + }else{ + println!("hello 5"); + ScheduleListHead::::kill(); + ScheduleListTail::::kill(); + ScheduleListPos::::kill(); + } + } + pos = next; } }); }else{ @@ -1396,7 +1441,7 @@ impl Pallet { } }); RewardsSchedulesList::::insert(tail + 1, (schedule, None::)); - ScheduleListHead::::put(tail + 1); + ScheduleListTail::::put(tail + 1); }, _ => {} // invariant assures this will never happen } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index e2a62f5f65..b2c738e15f 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -58,9 +58,11 @@ fn forward_to_block(n: u32) { fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { while System::block_number().saturated_into::() <= n { + ProofOfStake::on_initialize(System::block_number().saturated_into::()); if System::block_number().saturated_into::() % ProofOfStake::rewards_period() == 0 { ProofOfStake::distribute_rewards(rewards); } + ProofOfStake::on_finalize(n as u64); System::set_block_number(System::block_number().saturated_into::() + 1); } } @@ -1390,12 +1392,163 @@ fn rewards_schedule_is_stored() { let rewards_per_session = REWARD_AMOUNT / 5; assert_eq!( - ProofOfStake::schedules().into_inner(), - BTreeMap::from([( - (5u64, LIQUIDITY_TOKEN, REWARD_TOKEN, rewards_per_session, 0), - () - )]) + RewardsSchedulesList::::get(0).unwrap(), + (Schedule{ + last_session: 5u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: rewards_per_session, + }, None) + ); + assert_eq!( + ScheduleListTail::::get(), + Some(0u64) ); + assert_eq!( + ScheduleListHead::::get(), + Some(0u64) + ); + }); +} + + +#[test] +#[serial] +fn rewards_linked_list_insert_multiple_schedules() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 1u32.into() + ),); + + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 2u32.into() + ),); + + + assert_eq!( + RewardsSchedulesList::::get(0).unwrap(), + (Schedule{ + last_session: 1u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: REWARD_AMOUNT / 1, + }, Some(1)) + ); + + assert_eq!( + RewardsSchedulesList::::get(1).unwrap(), + (Schedule{ + last_session: 2u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: REWARD_AMOUNT / 2, + }, None) + ); + + assert_eq!( + ScheduleListHead::::get(), + Some(0u64) + ); + + assert_eq!( + ScheduleListTail::::get(), + Some(1u64) + ); + }); +} + + +#[test] +#[serial] +fn rewards_linked_list_removes_outdated_schedule_automatically() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 1u32.into() + ),); + + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 2u32.into() + ),); + + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + + forward_to_block(2); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( ScheduleListPos::::get(), Some(1u64)); + + forward_to_block(5); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( ScheduleListPos::::get(), None,); + + forward_to_block(10); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( ScheduleListPos::::get(), None,); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(1u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( ScheduleListPos::::get(), Some(1u64),); + + forward_to_block(15); + + assert_eq!( ScheduleListHead::::get(), Some(1u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( ScheduleListPos::::get(), None); + + forward_to_block(16); + + assert_eq!( ScheduleListHead::::get(), None); + assert_eq!( ScheduleListTail::::get(), None); + assert_eq!( ScheduleListPos::::get(), None); + + }); } From 09e8b6ee73226bd3cd64ca64e2bc9e19e20b8d97 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 13 Oct 2023 11:39:50 +0000 Subject: [PATCH 38/83] simplified version of list --- pallets/proof-of-stake/src/lib.rs | 105 +++++++++++++----------------- 1 file changed, 46 insertions(+), 59 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 75e25cda3c..119be37ad2 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -189,6 +189,11 @@ pub mod pallet { impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { + if frame_system::Pallet::::block_number().saturated_into::() % 5u64 == 0 { + ScheduleListPos::::kill(); + return Default::default(); + } + println!("on_initialize {}", n); const AMOUNT_PER_BLOCK: u64 = 5; @@ -229,10 +234,6 @@ pub mod pallet { // NOTE: 3R + 1R let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5u64; - if frame_system::Pallet::::block_number().saturated_into::() % 5u64 == 0 { - ScheduleListPos::::kill(); - return Default::default(); - } for idx in 0..AMOUNT_PER_BLOCK { println!("iter {}:{}", n, idx); @@ -240,68 +241,51 @@ pub mod pallet { println!("prev : {:?}", prev); println!("pos : {:?}", pos); match (prev.clone(), pos.clone()) { - (Some(prev_val), Some(pos_val)) => { + (prev_val, Some(pos_val)) => { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - ScheduleListPos::::put(pos_val); - ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ - if schedule.last_session >= session_id{ - *val += schedule.amount_per_session; - pos = next; - prev = Some(pos_val); - }else{ - // NOTE: consider removing elements from list - RewardsSchedulesList::::mutate(prev_val, |data|{ - if let Some((schedule, prev_next)) = data{ - *prev_next = next; - } - }); - pos = next; - if ScheduleListHead::::get().unwrap() == pos_val{ - if let Some(next) = next{ - ScheduleListHead::::put(next); - }else{ - ScheduleListHead::::kill(); - ScheduleListTail::::kill(); - ScheduleListPos::::kill(); - } - } - } - }); - - }else{ - break; - } - }, - (None, Some(pos_val)) => { - println!("hello 0"); - if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - println!("hello 1"); - ScheduleListPos::::put(pos_val); - ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ - if schedule.last_session >= session_id{ - println!("hello 2"); - *val += schedule.amount_per_session; - pos = next; - prev = Some(pos_val); - }else{ - println!("hello 3"); - // NOTE: consider removing elements from list - if ScheduleListHead::::get().unwrap() == pos_val{ + if schedule.last_session >= session_id{ + ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ + *val += schedule.amount_per_session + }); + pos = next; + prev = Some(pos_val); + }else{ + // NOTE: consider removing elements from list + // RewardsSchedulesList::::mutate(prev_val, |data|{ + // if let Some((schedule, prev_next)) = data{ + // *prev_next = next; + // } + // }); + + match(Self::head(), Self::tail()){ + (Some(head), Some(tail)) if head == pos_val && head != tail=> { + // move head to next if let Some(next) = next{ - println!("hello 4"); ScheduleListHead::::put(next); - }else{ - println!("hello 5"); - ScheduleListHead::::kill(); - ScheduleListTail::::kill(); - ScheduleListPos::::kill(); } - } - pos = next; + }, + (Some(head), Some(tail)) if tail == pos_val && head != tail=> { + if let Some(prev) = prev_val{ + ScheduleListTail::::put(prev); + RewardsSchedulesList::::mutate(prev, |data|{ + if let Some((schedule, next)) = data.as_mut() { + *next = Some(prev) + } + }); + } + }, + (Some(head), Some(tail)) if tail == pos_val && head == tail=> { + ScheduleListTail::::kill(); + ScheduleListHead::::kill(); + ScheduleListPos::::kill(); + }, + _ => {} + } - }); + pos = next; + } }else{ break; } @@ -512,12 +496,15 @@ pub mod pallet { >; #[pallet::storage] + #[pallet::getter(fn pos)] pub type ScheduleListPos = StorageValue<_, ScheduleId, OptionQuery>; #[pallet::storage] + #[pallet::getter(fn head)] pub type ScheduleListHead = StorageValue<_, ScheduleId, OptionQuery>; #[pallet::storage] + #[pallet::getter(fn tail)] pub type ScheduleListTail = StorageValue<_, ScheduleId, OptionQuery>; #[pallet::storage] From 2dacdc54298637dde80b7f48bbc0d0e76e834a56 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 13 Oct 2023 14:40:32 +0000 Subject: [PATCH 39/83] almost works --- pallets/proof-of-stake/src/lib.rs | 26 ++- pallets/proof-of-stake/src/tests.rs | 312 ++++++++++++++++++++++++++++ 2 files changed, 331 insertions(+), 7 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 119be37ad2..86df3e2b7d 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -252,26 +252,24 @@ pub mod pallet { pos = next; prev = Some(pos_val); }else{ - // NOTE: consider removing elements from list - // RewardsSchedulesList::::mutate(prev_val, |data|{ - // if let Some((schedule, prev_next)) = data{ - // *prev_next = next; - // } - // }); match(Self::head(), Self::tail()){ (Some(head), Some(tail)) if head == pos_val && head != tail=> { + //remove first elem + println!("remove first list elem"); // move head to next if let Some(next) = next{ ScheduleListHead::::put(next); } }, (Some(head), Some(tail)) if tail == pos_val && head != tail=> { + println!("remove last list elem"); if let Some(prev) = prev_val{ ScheduleListTail::::put(prev); + ScheduleListPos::::put(prev); RewardsSchedulesList::::mutate(prev, |data|{ if let Some((schedule, next)) = data.as_mut() { - *next = Some(prev) + *next = None } }); } @@ -281,6 +279,20 @@ pub mod pallet { ScheduleListHead::::kill(); ScheduleListPos::::kill(); }, + (Some(head), Some(tail)) => { + println!("remove middle elem {}", pos_val); + if let Some(prev) = prev_val{ + RewardsSchedulesList::::mutate(prev, |data|{ + if let Some((schedule, prev_next)) = data.as_mut() { + *prev_next = next + } + }); + } + if let Some(prev) = prev_val{ + ScheduleListPos::::put(prev); + } + //remove middle elem + }, _ => {} } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index b2c738e15f..2309e46ccc 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1552,6 +1552,318 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { }); } +// rewards_first_schedule_from_linked_list +// rewards_last_schedule_from_linked_list +// rewards_middle_schedule_from_linked_list +// rewards_multipleall_schedule_from_linked_list + +fn insert_schedule_ending_at_session(n: u32){ + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + n.into(), + ),); + +} + +#[test] +#[serial] +fn rewards_first_schedule_from_linked_list_of_four() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(1u64)); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); + assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + }); +} + +#[test] +#[serial] +fn remove_last_schedule_from_linked_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(2u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); + assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, None); + + + }); +} + +#[test] +#[serial] +fn remove_middle_schedule_from_linked_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); + assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + }); +} + + +#[test] +#[serial] +fn remove_first_few_elems_at_once_from_linked_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(2u64)); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + }); +} + +#[test] +#[serial] +fn remove_few_last_elems_at_once_from_linked_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(1); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, None); + }); +} + +#[test] +#[serial] +fn remove_few_middle_elements_from_linkedd_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + }); +} + +#[test] +#[serial] +fn remove_random_elements_from_linked_list() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 5 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + insert_schedule_ending_at_session(1); + insert_schedule_ending_at_session(2); + + assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); + assert_ok!(RewardsSchedulesList::::get(4).ok_or(())); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(4u64)); + + forward_to_block(11); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(4u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); + assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(4u64)); + assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, None); + }); +} + +#[test] +#[serial] +fn remove_random_elements_from_linked_list_over_time() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 7 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + insert_schedule_ending_at_session(3); // 0 + insert_schedule_ending_at_session(2); // 1 + insert_schedule_ending_at_session(1); // 2 + insert_schedule_ending_at_session(2); // 3 + insert_schedule_ending_at_session(2); // 4 + insert_schedule_ending_at_session(1); // 5 + insert_schedule_ending_at_session(3); // 6 + + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(6u64)); + + forward_to_block(14); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(6u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(3u64)); + assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, Some(4u64)); + assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); + assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); + + }); +} + + + + + #[test] #[serial] fn number_of_active_schedules_is_limited() { From 5beb9882e12fbbf025ab5841ab5dfc7d2dada52a Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 13 Oct 2023 16:34:55 +0000 Subject: [PATCH 40/83] linked list working --- pallets/proof-of-stake/src/lib.rs | 118 ++++++++++-------------------- pallets/xyk/src/lib.rs | 12 +-- pallets/xyk/src/tests.rs | 61 +++++++-------- 3 files changed, 73 insertions(+), 118 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 86df3e2b7d..a993815ac6 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -199,29 +199,6 @@ pub mod pallet { // NOTE: 3R - let mut prev = None; - let mut pos = match ( - ScheduleListPos::::get(), - ScheduleListHead::::get(), - ScheduleListTail::::get(), - ){ - (None, None, None) => { - None - }, - (Some(pos), Some(head), Some(tail)) if pos == tail => { - None - }, - (None, Some(head), Some(_tail)) => { - Some(head) - }, - (Some(pos), Some(_head), Some(_tail)) => { - Some(pos + 1) - }, - _ => { - None - }, - }; - println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); println!("ScheduleListTail : {:?}", ScheduleListTail::::get()); @@ -238,96 +215,78 @@ pub mod pallet { for idx in 0..AMOUNT_PER_BLOCK { println!("iter {}:{}", n, idx); println!("session_id : {:?}", session_id); - println!("prev : {:?}", prev); + + let last_valid = ScheduleListPos::::get(); + let pos = match ( last_valid, ScheduleListHead::::get() ){ + (Some(pos), _) => { + if let Some ((schedule, next)) = RewardsSchedulesList::::get(pos) { + next + }else{ + None + } + }, + (None, Some(head)) => { + Some(head) + }, + _ => { None }, + }; + println!("last_valid : {:?}", last_valid); println!("pos : {:?}", pos); - match (prev.clone(), pos.clone()) { - (prev_val, Some(pos_val)) => { - if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - ScheduleListPos::::put(pos_val); + if let Some(pos_val) = pos { + if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ if schedule.last_session >= session_id{ ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ *val += schedule.amount_per_session }); - pos = next; - prev = Some(pos_val); + ScheduleListPos::::put(pos_val); }else{ - match(Self::head(), Self::tail()){ (Some(head), Some(tail)) if head == pos_val && head != tail=> { - //remove first elem println!("remove first list elem"); - // move head to next if let Some(next) = next{ ScheduleListHead::::put(next); } }, + (Some(head), Some(tail)) if tail == pos_val && head == tail=> { + ScheduleListTail::::kill(); + ScheduleListHead::::kill(); + ScheduleListPos::::kill(); + }, (Some(head), Some(tail)) if tail == pos_val && head != tail=> { println!("remove last list elem"); - if let Some(prev) = prev_val{ - ScheduleListTail::::put(prev); - ScheduleListPos::::put(prev); - RewardsSchedulesList::::mutate(prev, |data|{ + if let Some(last_valid) = last_valid{ + ScheduleListTail::::put(last_valid); + RewardsSchedulesList::::mutate(last_valid, |data|{ if let Some((schedule, next)) = data.as_mut() { *next = None } }); } }, - (Some(head), Some(tail)) if tail == pos_val && head == tail=> { - ScheduleListTail::::kill(); - ScheduleListHead::::kill(); - ScheduleListPos::::kill(); - }, (Some(head), Some(tail)) => { println!("remove middle elem {}", pos_val); - if let Some(prev) = prev_val{ - RewardsSchedulesList::::mutate(prev, |data|{ + if let Some(last_valid) = last_valid{ + RewardsSchedulesList::::mutate(last_valid, |data|{ if let Some((schedule, prev_next)) = data.as_mut() { *prev_next = next } }); } - if let Some(prev) = prev_val{ - ScheduleListPos::::put(prev); - } - //remove middle elem }, _ => {} } - pos = next; } - }else{ - break; - } - }, - (Some(pos), None) => { - break; - }, - (None, None) => { - break; - } - } - } - Default::default() - // if let Some((schedule, next)) = RewardsSchedulesList::::get(pos){ - // ScheduleRewardsTotal::mutate_exists((schedule.liq_token, schedudle.reward_token, session_id), |val|{ - // if schedudle.last_session <= session_id{ - // *val += schedule.amount_per_session; - // pos = next; - // }else{ - // None - // } - // }) - // }else{ - // break; - // - // } - // - } - } + } + } else{ + break; + } + } + Default::default() + } + } #[cfg(feature = "runtime-benchmarks")] pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} @@ -511,6 +470,9 @@ pub mod pallet { #[pallet::getter(fn pos)] pub type ScheduleListPos = StorageValue<_, ScheduleId, OptionQuery>; + #[pallet::storage] + pub type ScheduleListPosPrev = StorageValue<_, ScheduleId, OptionQuery>; + #[pallet::storage] #[pallet::getter(fn head)] pub type ScheduleListHead = StorageValue<_, ScheduleId, OptionQuery>; diff --git a/pallets/xyk/src/lib.rs b/pallets/xyk/src/lib.rs index 4b79ea5018..9bb92742da 100644 --- a/pallets/xyk/src/lib.rs +++ b/pallets/xyk/src/lib.rs @@ -3433,11 +3433,13 @@ impl Valuate for Pallet { ) -> Self::Balance { let native_token_id = Pallet::::native_token_id(); - let (native_reserves, token_reserves) = match Pallet::::get_reserves(native_token_id, non_liquidity_token_id) { - Ok(reserves) => reserves, - Err(_) => return Default::default(), - }; - Pallet::::calculate_sell_price_no_fee(token_reserves, native_reserves, amount).unwrap_or_default() + let (native_reserves, token_reserves) = + match Pallet::::get_reserves(native_token_id, non_liquidity_token_id) { + Ok(reserves) => reserves, + Err(_) => return Default::default(), + }; + Pallet::::calculate_sell_price_no_fee(token_reserves, native_reserves, amount) + .unwrap_or_default() } fn scale_liquidity_by_mga_valuation( diff --git a/pallets/xyk/src/tests.rs b/pallets/xyk/src/tests.rs index 4d224f0cf5..d330d5957c 100644 --- a/pallets/xyk/src/tests.rs +++ b/pallets/xyk/src/tests.rs @@ -2586,44 +2586,35 @@ fn buy_W_maintenance_mode() { #[serial] fn valuate_token_paired_with_mgx() { new_test_ext().execute_with(|| { - System::set_block_number(1); - let native_token_id = XykStorage::create_new_token(&DUMMY_USER_ID, 2_000_000_u128); - assert_eq!(native_token_id, XykStorage::native_token_id()); - - - let first_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); - let second_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); - let first_token_pool = second_token + 1; - let second_token_pool = second_token + 2; - + System::set_block_number(1); + let native_token_id = XykStorage::create_new_token(&DUMMY_USER_ID, 2_000_000_u128); + assert_eq!(native_token_id, XykStorage::native_token_id()); - XykStorage::create_pool( - RuntimeOrigin::signed(DUMMY_USER_ID), - native_token_id, - 1_000_000_u128, - first_token, - 500_000_u128, - ) - .unwrap(); + let first_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); + let second_token = XykStorage::create_new_token(&DUMMY_USER_ID, 1_000_000_u128); + let first_token_pool = second_token + 1; + let second_token_pool = second_token + 2; - XykStorage::create_pool( - RuntimeOrigin::signed(DUMMY_USER_ID), - second_token, - 1_000_000_u128, - native_token_id, - 500_000_u128, - ) - .unwrap(); + XykStorage::create_pool( + RuntimeOrigin::signed(DUMMY_USER_ID), + native_token_id, + 1_000_000_u128, + first_token, + 500_000_u128, + ) + .unwrap(); + XykStorage::create_pool( + RuntimeOrigin::signed(DUMMY_USER_ID), + second_token, + 1_000_000_u128, + native_token_id, + 500_000_u128, + ) + .unwrap(); - assert_eq!( - as Valuate>::valuate_non_liquidity_token(first_token, 100), - 199 - ); + assert_eq!( as Valuate>::valuate_non_liquidity_token(first_token, 100), 199); - assert_eq!( - as Valuate>::valuate_non_liquidity_token(second_token, 100), - 49 - ); - }); + assert_eq!( as Valuate>::valuate_non_liquidity_token(second_token, 100), 49); + }); } From 710526c38b15c2bb4c459cffb78408e4c6ea62d3 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 13 Oct 2023 16:40:53 +0000 Subject: [PATCH 41/83] add scenario for conrner case conditions where all processed schedules are invalid --- pallets/proof-of-stake/src/tests.rs | 45 +++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 2309e46ccc..1c06fa14dc 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1857,12 +1857,57 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); + forward_to_block(19); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(6u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(6u64)); + assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); + + }); } +#[test] +#[serial] +fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 10 * REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + insert_schedule_ending_at_session(3); // 0 + insert_schedule_ending_at_session(1); // 1 + insert_schedule_ending_at_session(1); // 1 + insert_schedule_ending_at_session(1); // 1 + insert_schedule_ending_at_session(1); // 2 + insert_schedule_ending_at_session(1); // 3 + insert_schedule_ending_at_session(1); // 4 + insert_schedule_ending_at_session(1); // 5 + insert_schedule_ending_at_session(3); // 6 + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(8u64)); + + forward_to_block(14); + + assert_eq!( ScheduleListHead::::get(), Some(0u64)); + assert_eq!( ScheduleListTail::::get(), Some(8u64)); + assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(8u64)); + assert_eq!( RewardsSchedulesList::::get(8u64).unwrap().1, None); + + forward_to_block(100); + assert_eq!( ScheduleListHead::::get(), None); + assert_eq!( ScheduleListTail::::get(), None); + }); +} #[test] #[serial] From cd4dc078d74086f6e297eb023a09dfa8a7ab5843 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 14 Oct 2023 11:36:53 +0000 Subject: [PATCH 42/83] before session id unification --- pallets/proof-of-stake/src/lib.rs | 27 +++++-- pallets/proof-of-stake/src/reward_info.rs | 7 +- pallets/proof-of-stake/src/tests.rs | 85 +++++++++++++++++++++++ 3 files changed, 110 insertions(+), 9 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index a993815ac6..a58f06aabb 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -236,10 +236,16 @@ pub mod pallet { if let Some(pos_val) = pos { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ if schedule.last_session >= session_id{ - ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token, session_id), |val|{ - *val += schedule.amount_per_session + ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)|{ + if *idx >= session_id { + *pending += schedule.amount_per_session + }else{ + *cumulative += *pending; + *pending = schedule.amount_per_session; + *idx = session_id; + } }); - ScheduleListPos::::put(pos_val); + ScheduleListPos::::put(pos_val); }else{ match(Self::head(), Self::tail()){ (Some(head), Some(tail)) if head == pos_val && head != tail=> { @@ -451,7 +457,12 @@ pub mod pallet { /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] - pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat ,(TokenId, TokenId, u64), u128, ValueQuery>; + pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat ,(TokenId, TokenId), (u128, u64, u128), ValueQuery>; + + /// How much scheduled rewards per single liquidty_token should be distribute_rewards + /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic + // #[pallet::storage] + // pub type ScheduleRewardsCumulative = StorageMap<_, Twox64Concat ,(TokenId, TokenId, u64), u128, ValueQuery>; /// List of activated schedules sorted by expiry date #[pallet::storage] @@ -496,7 +507,7 @@ pub mod pallet { #[pallet::storage] pub type PrevTotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u64, u128), ValueQuery>; + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; /// Tracks how much liquidity user activated for particular (liq token, reward token) pair /// StorageNMap was used because it only require single read to know if user deactivated all @@ -781,16 +792,18 @@ impl Pallet { fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (idx, amount) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); + println!("total_activated_liquidity idx: {} amount: {}", idx, amount); if idx == (frame_system::Pallet::::block_number().saturated_into::() / 5){ amount }else{ - PrevTotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward).1 + PrevTotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward) } } fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { // TODO: make configurable let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5; + println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ let new_amount = if change{ amount + diff @@ -799,7 +812,7 @@ impl Pallet { }; if session_id > idx { - PrevTotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (idx, amount)); + PrevTotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |val| *val += amount); } TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, new_amount)); } diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index f70b201653..0110ba03fe 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -88,8 +88,11 @@ impl RewardsCalculator { // NOTE: take into acout previous rewards (prev + rewards/activated) let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); - let total_rewards = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); - let pool_ratio_current = total_rewards/total_activated; + let total_rewards = crate::ScheduleRewardsTotal::::get((asset_id, reward_asset_id)).2; + println!("REWARDS CALCULATOR at {} for {}", current_time, user); + println!("total_activated : {}", total_activated); + println!("total_rewards : {}", total_rewards); + let pool_ratio_current = total_rewards.checked_div(total_activated).unwrap_or_default(); // let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 1c06fa14dc..0feaf42496 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3237,3 +3237,88 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { ); }); } + +#[test] +#[serial] +fn mat() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .issue(EVE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + roll_to_session(1); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(0) + ); + + roll_to_session(2); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(0) + ); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1000) + ); + // + // roll_to_session(3); + // assert_eq!( + // ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + // Ok(1500) + // ); + // assert_eq!( + // ProofOfStake::calculate_3rdparty_rewards_amount( + // CHARLIE, + // LIQUIDITY_TOKEN, + // REWARD_TOKEN + // ), + // Ok(500) + // ); + }); +} From 545627243758389fe35b5839ffb50de6afad5667 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 14 Oct 2023 12:12:11 +0000 Subject: [PATCH 43/83] progress on schedudle rewards calculation --- pallets/proof-of-stake/src/lib.rs | 75 ++++++++++++++++------- pallets/proof-of-stake/src/reward_info.rs | 2 +- 2 files changed, 53 insertions(+), 24 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index a58f06aabb..f1a36e8cae 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -189,7 +189,7 @@ pub mod pallet { impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - if frame_system::Pallet::::block_number().saturated_into::() % 5u64 == 0 { + if Self::session_index() == 0 { ScheduleListPos::::kill(); return Default::default(); } @@ -209,7 +209,7 @@ pub mod pallet { // TODO: make configurable // NOTE: 3R + 1R - let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5u64; + let session_id = Self::session_index() as u64; for idx in 0..AMOUNT_PER_BLOCK { @@ -503,11 +503,11 @@ pub mod pallet { /// Total amount of activated liquidity for each schedule #[pallet::storage] pub type TotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u64, u128), ValueQuery>; + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u128, u64, u128), ValueQuery>; - #[pallet::storage] - pub type PrevTotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; + // #[pallet::storage] + // pub type PrevTotalActivatedLiquidityForSchedules = + // StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; /// Tracks how much liquidity user activated for particular (liq token, reward token) pair /// StorageNMap was used because it only require single read to know if user deactivated all @@ -791,31 +791,60 @@ pub mod pallet { impl Pallet { fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ - let (idx, amount) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); - println!("total_activated_liquidity idx: {} amount: {}", idx, amount); - if idx == (frame_system::Pallet::::block_number().saturated_into::() / 5){ - amount + let (pending, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); + if idx == (Self::session_index() as u64){ + println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative); + cumulative }else{ - PrevTotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward) + println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative + pending); + cumulative + pending } } + fn total_schedule_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ + let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64){ + println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative); + cumulative + }else{ + println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative + pending); + cumulative + pending + } + } + + fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { // TODO: make configurable - let session_id = frame_system::Pallet::::block_number().saturated_into::() / 5; - println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); - if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ - let new_amount = if change{ - amount + diff + let session_id = Self::session_index() as u64; + + TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(pending, idx, cumulative)|{ + if *idx == session_id { + let new_amount = if change{ + *pending + diff + }else{ + *pending - diff + }; + *pending = new_amount; }else{ - amount - diff - }; - - if session_id > idx { - PrevTotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |val| *val += amount); + // NOTE: handle burn so negative diff + *cumulative += *pending; + *pending = diff; } - TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, new_amount)); - } + }); + + + // println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); + // if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ + // + // if session_id > idx { + // PrevTotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |val| *val += amount); + // TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, 0)); + // }else{ + // TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(session_id, new_amount)| amount += kkj); + // } + // }else{ + // TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, new_amount)); + // } } fn activate_liquidity_for_native_rewards_impl( diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 0110ba03fe..13725512f9 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -88,7 +88,7 @@ impl RewardsCalculator { // NOTE: take into acout previous rewards (prev + rewards/activated) let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); - let total_rewards = crate::ScheduleRewardsTotal::::get((asset_id, reward_asset_id)).2; + let total_rewards = Pallet::::total_schedule_rewards(asset_id, reward_asset_id); println!("REWARDS CALCULATOR at {} for {}", current_time, user); println!("total_activated : {}", total_activated); println!("total_rewards : {}", total_rewards); From 6e6746c5e31d72c9cdbdd2f91230f09735e4b696 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 14 Oct 2023 12:40:04 +0000 Subject: [PATCH 44/83] simple scenario still fails --- pallets/proof-of-stake/src/lib.rs | 12 ++++++---- pallets/proof-of-stake/src/reward_info.rs | 2 +- pallets/proof-of-stake/src/tests.rs | 28 +++++++++++------------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index f1a36e8cae..100db25281 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -793,10 +793,10 @@ impl Pallet { fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (pending, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); if idx == (Self::session_index() as u64){ - println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative); + println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative }else{ - println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative + pending); + println!("total_activated_liquidity cumulative +pending idx: {} amount: {}", idx, cumulative + pending); cumulative + pending } } @@ -804,10 +804,10 @@ impl Pallet { fn total_schedule_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64){ - println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative); + println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative }else{ - println!("total_activated_liquidity idx: {} amount: {}", idx, cumulative + pending); + println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending); cumulative + pending } } @@ -817,6 +817,7 @@ impl Pallet { // TODO: make configurable let session_id = Self::session_index() as u64; + println!("update_total_activated_liqudity before {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(pending, idx, cumulative)|{ if *idx == session_id { let new_amount = if change{ @@ -826,11 +827,14 @@ impl Pallet { }; *pending = new_amount; }else{ + println!("update_total_activated_liqudity swithc {}", diff); // NOTE: handle burn so negative diff *cumulative += *pending; *pending = diff; + *idx = session_id; } }); + println!("update_total_activated_liqudity after {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); // println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 13725512f9..848430c858 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -92,7 +92,7 @@ impl RewardsCalculator { println!("REWARDS CALCULATOR at {} for {}", current_time, user); println!("total_activated : {}", total_activated); println!("total_rewards : {}", total_rewards); - let pool_ratio_current = total_rewards.checked_div(total_activated).unwrap_or_default(); + let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); // let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 0feaf42496..cd970c5acc 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3306,19 +3306,19 @@ fn mat() { ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1000) ); - // - // roll_to_session(3); - // assert_eq!( - // ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), - // Ok(1500) - // ); - // assert_eq!( - // ProofOfStake::calculate_3rdparty_rewards_amount( - // CHARLIE, - // LIQUIDITY_TOKEN, - // REWARD_TOKEN - // ), - // Ok(500) - // ); + + roll_to_session(3); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1500) + ); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), + Ok(500) + ); }); } From f7d5964e68bdb3973f96b4c6994378112990df78 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 23 Oct 2023 16:21:00 +0000 Subject: [PATCH 45/83] cumulative calculations --- pallets/proof-of-stake/src/lib.rs | 69 ++++++++++++++++++----- pallets/proof-of-stake/src/reward_info.rs | 18 +++--- pallets/proof-of-stake/src/tests.rs | 5 +- 3 files changed, 67 insertions(+), 25 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 100db25281..2a5dd37f92 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -97,6 +97,7 @@ pub type ScheduleId = u64; #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] pub struct Schedule{ + scheduled_at: u64, last_session: u64, liq_token: TokenId, reward_token: TokenId, @@ -189,7 +190,8 @@ pub mod pallet { impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - if Self::session_index() == 0 { + + if frame_system::Pallet::::block_number().saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 { ScheduleListPos::::kill(); return Default::default(); } @@ -236,15 +238,19 @@ pub mod pallet { if let Some(pos_val) = pos { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ if schedule.last_session >= session_id{ - ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)|{ - if *idx >= session_id { - *pending += schedule.amount_per_session - }else{ - *cumulative += *pending; - *pending = schedule.amount_per_session; - *idx = session_id; - } - }); + + if schedule.scheduled_at < session_id{ + ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)|{ + if *idx >= session_id { + *pending += schedule.amount_per_session + }else{ + *cumulative += *pending; + *pending = schedule.amount_per_session; + *idx = session_id; + } + println!("=====> SCHEDULEREWARDSTOTAL : cumulative: {} pending: {}", *cumulative, *pending); + }); + } ScheduleListPos::::put(pos_val); }else{ match(Self::head(), Self::tail()){ @@ -287,6 +293,7 @@ pub mod pallet { } } else{ + println!("###############################################"); break; } } @@ -459,6 +466,9 @@ pub mod pallet { #[pallet::storage] pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat ,(TokenId, TokenId), (u128, u64, u128), ValueQuery>; + #[pallet::storage] + pub type ScheduleRewardsPerLiquidity = StorageMap<_, Twox64Concat ,(TokenId, TokenId), (U256, u64), ValueQuery>; + /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic // #[pallet::storage] @@ -790,13 +800,44 @@ pub mod pallet { impl Pallet { + fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> U256{ + let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64){ + println!("update_cumulative_rewards cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); + cumulative + }else{ + let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); + println!("update_cumulative_rewards cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); + ScheduleRewardsPerLiquidity::::insert((liquidity_asset_id, liquidity_assets_reward), (cumulative + pending, (Self::session_index() as u64))); + cumulative + pending + } + } + + + fn total_rewards_for_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> U256{ + let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64){ + println!("total_rewards_for_liquidity cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); + cumulative + }else{ + let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); + println!("total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); + cumulative + pending + } + } + + fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (pending, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); if idx == (Self::session_index() as u64){ println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative }else{ - println!("total_activated_liquidity cumulative +pending idx: {} amount: {}", idx, cumulative + pending); + println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending); cumulative + pending } } @@ -804,10 +845,10 @@ impl Pallet { fn total_schedule_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64){ - println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); + println!("total_schedule_rewards cumulative idx: {} amount: {}", idx, cumulative); cumulative }else{ - println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending); + println!("total_schedule_rewards cumulative + pending idx: {} amount: {}", idx, cumulative + pending); cumulative + pending } } @@ -1166,6 +1207,7 @@ impl Pallet { ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; + Self::update_cumulative_rewards(liquidity_asset_id, liquidity_assets_reward); { let calc = RewardsCalculator::schedule_rewards::( user.clone(), @@ -1429,6 +1471,7 @@ impl Pallet { let head = ScheduleListHead::::get(); let tail = ScheduleListTail::::get(); let schedule = Schedule{ + scheduled_at: Self::session_index() as u64, last_session: schedule_end.saturated_into::(), liq_token: liquidity_token_id, reward_token: token_id, diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 848430c858..ef979c1009 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -87,17 +87,13 @@ impl RewardsCalculator { ); // NOTE: take into acout previous rewards (prev + rewards/activated) - let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); - let total_rewards = Pallet::::total_schedule_rewards(asset_id, reward_asset_id); - println!("REWARDS CALCULATOR at {} for {}", current_time, user); - println!("total_activated : {}", total_activated); - println!("total_rewards : {}", total_rewards); - let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); - - // let pool_map = crate::ScheduleRewardsPerSingleLiquidity::::get(); - - // let pool_ratio_current = - // pool_map.get(&(asset_id, reward_asset_id)).cloned().unwrap_or(U256::from(0)); + // let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); + // let total_rewards = Pallet::::total_schedule_rewards(asset_id, reward_asset_id); + // println!("REWARDS CALCULATOR at {} for {}", current_time, user); + // println!("total_activated : {}", total_activated); + // println!("total_rewards : {}", total_rewards); + // let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); + let pool_ratio_current = Pallet::::total_rewards_for_liquidity(asset_id, reward_asset_id); let default_rewards = RewardInfo { activated_amount: 0_u128, diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index cd970c5acc..6b2c359eb2 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1394,6 +1394,7 @@ fn rewards_schedule_is_stored() { assert_eq!( RewardsSchedulesList::::get(0).unwrap(), (Schedule{ + scheduled_at: 0u64, last_session: 5u64, liq_token: LIQUIDITY_TOKEN, reward_token: REWARD_TOKEN, @@ -1445,6 +1446,7 @@ fn rewards_linked_list_insert_multiple_schedules() { assert_eq!( RewardsSchedulesList::::get(0).unwrap(), (Schedule{ + scheduled_at: 0u64, last_session: 1u64, liq_token: LIQUIDITY_TOKEN, reward_token: REWARD_TOKEN, @@ -1455,6 +1457,7 @@ fn rewards_linked_list_insert_multiple_schedules() { assert_eq!( RewardsSchedulesList::::get(1).unwrap(), (Schedule{ + scheduled_at: 0u64, last_session: 2u64, liq_token: LIQUIDITY_TOKEN, reward_token: REWARD_TOKEN, @@ -3240,7 +3243,7 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { #[test] #[serial] -fn mat() { +fn matt() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) From c849265143392c4de91fdef9e1d0c30ead998a53 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 24 Oct 2023 04:46:29 +0000 Subject: [PATCH 46/83] align tests for linked list --- pallets/proof-of-stake/src/lib.rs | 13 +++++++-- pallets/proof-of-stake/src/tests.rs | 44 ++++++++++++++--------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 2a5dd37f92..84cd51bf13 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -823,14 +823,13 @@ impl Pallet { cumulative }else{ let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); println!("total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); cumulative + pending } } - fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ let (pending, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); if idx == (Self::session_index() as u64){ @@ -853,6 +852,16 @@ impl Pallet { } } + fn total_schedule_rewards_parts(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> (Balance, Balance){ + let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64){ + println!("total_schedule_rewards_parts at {} (cumulative , pending) idx: ({}, {})", idx, cumulative , pending); + (cumulative, pending) + }else{ + println!("total_schedule_rewards_parts at {} (cumulative , pending) idx: ({}, {})", idx, cumulative , pending); + (cumulative, pending) + } + } fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { // TODO: make configurable diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 6b2c359eb2..822c996083 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1525,33 +1525,31 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), None,); - - forward_to_block(10); + assert_eq!( ScheduleListPos::::get(), Some(1u64)); + forward_to_block(11); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), None,); - - forward_to_block(11); + assert_eq!( ScheduleListPos::::get(), Some(1u64)); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(1u64)); assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64),); - - forward_to_block(15); + assert_eq!( ScheduleListPos::::get(), Some(1u64)); + forward_to_block(25); assert_eq!( ScheduleListHead::::get(), Some(1u64)); assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), None); + assert_eq!( ScheduleListPos::::get(), Some(1u64)); - forward_to_block(16); + forward_to_block(30); + assert_eq!( ScheduleListHead::::get(), Some(1u64)); + assert_eq!( ScheduleListTail::::get(), Some(1u64)); + forward_to_block(31); assert_eq!( ScheduleListHead::::get(), None); assert_eq!( ScheduleListTail::::get(), None); assert_eq!( ScheduleListPos::::get(), None); - - }); } @@ -1597,7 +1595,7 @@ fn rewards_first_schedule_from_linked_list_of_four() { assert_eq!( ScheduleListPos::::get(), None); assert_eq!( ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(1u64)); assert_eq!( ScheduleListTail::::get(), Some(3u64)); @@ -1633,7 +1631,7 @@ fn remove_last_schedule_from_linked_list() { assert_eq!( ScheduleListPos::::get(), None); assert_eq!( ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(2u64)); @@ -1671,7 +1669,7 @@ fn remove_middle_schedule_from_linked_list() { assert_eq!( ScheduleListPos::::get(), None); assert_eq!( ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(3u64)); @@ -1708,7 +1706,7 @@ fn remove_first_few_elems_at_once_from_linked_list() { assert_eq!( ScheduleListPos::::get(), None); assert_eq!( ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(2u64)); assert_eq!( ScheduleListTail::::get(), Some(3u64)); @@ -1743,7 +1741,7 @@ fn remove_few_last_elems_at_once_from_linked_list() { assert_eq!( ScheduleListPos::::get(), None); assert_eq!( ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(1u64)); @@ -1778,7 +1776,7 @@ fn remove_few_middle_elements_from_linkedd_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(3u64)); @@ -1815,7 +1813,7 @@ fn remove_random_elements_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(4u64)); - forward_to_block(11); + forward_to_block(21); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(4u64)); @@ -1850,7 +1848,7 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(6u64)); - forward_to_block(14); + forward_to_block(24); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(6u64)); @@ -1860,7 +1858,7 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); - forward_to_block(19); + forward_to_block(40); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(6u64)); @@ -1899,7 +1897,7 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(8u64)); - forward_to_block(14); + forward_to_block(24); assert_eq!( ScheduleListHead::::get(), Some(0u64)); assert_eq!( ScheduleListTail::::get(), Some(8u64)); From a18d08783394eb8eed9974fa87d241bc2f4aa079 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 24 Oct 2023 15:49:31 +0000 Subject: [PATCH 47/83] almost working --- pallets/proof-of-stake/src/lib.rs | 53 ++-- pallets/proof-of-stake/src/reward_info.rs | 4 + pallets/proof-of-stake/src/tests.rs | 307 ++++++++++++++++++---- 3 files changed, 289 insertions(+), 75 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 84cd51bf13..542d68e503 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -190,33 +190,34 @@ pub mod pallet { impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { + let session_id = Self::session_index() as u64; + + + println!("=================> ON_INITIALIZE {} : {}", n, session_id); if frame_system::Pallet::::block_number().saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 { ScheduleListPos::::kill(); return Default::default(); } - println!("on_initialize {}", n); + // println!("on_initialize {}", n); const AMOUNT_PER_BLOCK: u64 = 5; - // NOTE: 3R - println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); - println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); - println!("ScheduleListTail : {:?}", ScheduleListTail::::get()); + // // NOTE: 3R + // println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); + // println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); + // println!("ScheduleListTail : {:?}", ScheduleListTail::::get()); // 1R 1W 15RW //NOTE: 5 transfers => 15R 15W - // TODO: make configurable // NOTE: 3R + 1R - let session_id = Self::session_index() as u64; - - + // TODO: make configurable for idx in 0..AMOUNT_PER_BLOCK { - println!("iter {}:{}", n, idx); - println!("session_id : {:?}", session_id); + // println!("iter {}:{}", n, idx); + // println!("session_id : {:?}", session_id); let last_valid = ScheduleListPos::::get(); let pos = match ( last_valid, ScheduleListHead::::get() ){ @@ -232,8 +233,8 @@ pub mod pallet { }, _ => { None }, }; - println!("last_valid : {:?}", last_valid); - println!("pos : {:?}", pos); + // println!("last_valid : {:?}", last_valid); + // println!("pos : {:?}", pos); if let Some(pos_val) = pos { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ @@ -248,7 +249,7 @@ pub mod pallet { *pending = schedule.amount_per_session; *idx = session_id; } - println!("=====> SCHEDULEREWARDSTOTAL : cumulative: {} pending: {}", *cumulative, *pending); + println!("=====> SCHEDULEREWARDSTOTAL : ({}:{}) cumulative: {} pending: {}", schedule.liq_token, schedule.reward_token ,*cumulative, *pending); }); } ScheduleListPos::::put(pos_val); @@ -293,7 +294,7 @@ pub mod pallet { } } else{ - println!("###############################################"); + // println!("###############################################"); break; } } @@ -735,6 +736,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; + Self::update_cumulative_rewards(liquidity_token_id, reward_token); Self::claim_schedule_rewards_all_impl(sender, liquidity_token_id, reward_token)?; Ok(()) } @@ -800,18 +802,23 @@ pub mod pallet { impl Pallet { - fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> U256{ + fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) { let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64){ println!("update_cumulative_rewards cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); - cumulative }else{ let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + // let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); - println!("update_cumulative_rewards cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); - ScheduleRewardsPerLiquidity::::insert((liquidity_asset_id, liquidity_assets_reward), (cumulative + pending, (Self::session_index() as u64))); - cumulative + pending + if total_activated_liquidity > 0 { + ScheduleRewardsTotal::::mutate((liquidity_asset_id, liquidity_assets_reward), |(cumulative, _, _)|{ + *cumulative = 0; + }); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); + println!("update_cumulative_rewards cumulative + pending idx: {} RAW amount: {}", idx, cumulative + pending); + println!("update_cumulative_rewards cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); + ScheduleRewardsPerLiquidity::::insert((liquidity_asset_id, liquidity_assets_reward), (cumulative + pending, (Self::session_index() as u64))); + } } } @@ -819,11 +826,13 @@ impl Pallet { fn total_rewards_for_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> U256{ let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64){ + println!("total_rewards_for_liquidity cumulative idx: {} RAW amount: {}", idx, cumulative); println!("total_rewards_for_liquidity cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); cumulative }else{ let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); + // let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); println!("total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); cumulative + pending diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index ef979c1009..7e016ba7c6 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -94,6 +94,7 @@ impl RewardsCalculator { // println!("total_rewards : {}", total_rewards); // let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); let pool_ratio_current = Pallet::::total_rewards_for_liquidity(asset_id, reward_asset_id); + println!("SCHEDULE REWARDS RATIO: {}", pool_ratio_current); let default_rewards = RewardInfo { activated_amount: 0_u128, @@ -195,6 +196,7 @@ impl CurveRewards for ConstCurveRewards { let rewards_base: U256 = U256::from(user_info.activated_amount) .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 + println!("REWARDS : {}", rewards_base); rewards_base.try_into().ok() } @@ -288,6 +290,7 @@ impl RewardsCalculator { pub fn claim_rewards(self) -> sp_std::result::Result<(RewardInfo, Balance), RewardsCalcError> { let current_rewards = self.calculate_rewards_impl()?; + println!("TOTAL AVAILABLE: {:?}", current_rewards); let total_available_rewards = current_rewards .checked_add(self.rewards_info.rewards_not_yet_claimed) .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) @@ -301,6 +304,7 @@ impl RewardsCalculator { } pub fn calculate_rewards(self) -> sp_std::result::Result { + println!("calculate_rewards !!!!!"); self.calculate_rewards_impl() } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 822c996083..5b42307a7d 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1911,6 +1911,7 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { } #[test] +#[ignore] #[serial] fn number_of_active_schedules_is_limited() { ExtBuilder::new().issue(ALICE, REWARD_TOKEN, MILLION).build().execute_with(|| { @@ -1968,6 +1969,15 @@ fn duplicated_schedules_works() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); + assert_eq!( + ScheduleListHead::::get(), + None + ); + assert_eq!( + ScheduleListTail::::get(), + None + ); + assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1976,7 +1986,14 @@ fn duplicated_schedules_works() { 5u32.into() )); - assert_eq!(1, ProofOfStake::schedules().len()); + assert_eq!( + ScheduleListHead::::get(), + Some(0u64) + ); + assert_eq!( + ScheduleListTail::::get(), + Some(0u64) + ); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1985,7 +2002,15 @@ fn duplicated_schedules_works() { REWARD_AMOUNT / 2, 5u32.into() )); - assert_eq!(2, ProofOfStake::schedules().len()); + + assert_eq!( + ScheduleListHead::::get(), + Some(0u64) + ); + assert_eq!( + ScheduleListTail::::get(), + Some(1u64) + ); }); } @@ -2123,6 +2148,7 @@ fn user_can_claim_3rdparty_rewards() { ); roll_to_session(2); + println!("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, @@ -2145,6 +2171,7 @@ fn user_can_claim_3rdparty_rewards() { ); roll_to_session(3); + println!("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) @@ -2190,56 +2217,29 @@ fn overlapping_3rdparty_rewards_works() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - first_reward_token, - None, - ) - .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None,) .unwrap(); roll_to_session(5); let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - pair, - second_reward_token_id, - 100_000, - 15u32.into(), - ) - .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - second_reward_token_id, - None, - ) - .unwrap(); + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into(),) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, None,) .unwrap(); - roll_to_session(6); + roll_to_session(7); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - second_reward_token_id - ), + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, second_reward_token_id), Ok(10000) ); + println!("############################## ##############################"); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - BOB, - LIQUIDITY_TOKEN, - first_reward_token - ), - Ok(5000) + ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, first_reward_token), + Ok(6000) ); }); } + #[test] #[serial] fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { @@ -3029,6 +3029,8 @@ fn can_claim_schedule_rewards() { 10u32.into(), ) .unwrap(); + + println!(">>>>>>>>>>>>>>>>>>>>>> ACTIVATE"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3037,6 +3039,7 @@ fn can_claim_schedule_rewards() { None, ) .unwrap(); + println!(">>>>>>>>>>>>>>>>>>>>>> ACTIVATE"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3046,27 +3049,26 @@ fn can_claim_schedule_rewards() { ) .unwrap(); - roll_to_session(1); + forward_to_block(20); assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 0,); assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 0,); - ProofOfStake::claim_3rdparty_rewards( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - FIRST_REWARD_TOKEN, - ) - .unwrap(); + assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 1000); + assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 1000); - ProofOfStake::claim_3rdparty_rewards( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - SECOND_REWARD_TOKEN, - ) - .unwrap(); + ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(); + + assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 0); + assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 1000); + + ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(); - assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 1000,); - assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 1000,); + assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 0); + assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 0); + + assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 1000); + assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 1000); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( @@ -3157,6 +3159,7 @@ use frame_support::dispatch::{GetDispatchInfo, Pays}; use sp_runtime::{traits::Dispatchable, Permill}; #[test] +#[ignore] #[serial] fn activate_deactivate_calls_are_free_of_charge() { ExtBuilder::new() @@ -3239,6 +3242,67 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { }); } + +#[test] +#[serial] +fn claim_rewards_from_multiple_sessions_at_once() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .issue(EVE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); + TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + roll_to_session(1); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(0) + ); + + roll_to_session(2); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(1000) + ); + + roll_to_session(5); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(4000) + ); + }); +} + #[test] #[serial] fn matt() { @@ -3323,3 +3387,140 @@ fn matt() { ); }); } + +#[test] +#[serial] +fn test_all_scheduled_rewards_are_distributed_when_activated_instantly() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + roll_to_session(12); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(REWARD_AMOUNT) + ); + }); +} + +#[test] +#[serial] +fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + + roll_to_session(7); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + roll_to_session(15); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(REWARD_AMOUNT) + ); + }); +} + +#[test] +#[serial] +fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finished() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + + + roll_to_session(15); + + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + roll_to_session(16); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(REWARD_AMOUNT) + ); + }); +} From 7e209c8c9e211d8dfd1aa071319f042ba136d4f4 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 24 Oct 2023 16:30:12 +0000 Subject: [PATCH 48/83] missing I256 --- Cargo.lock | 1 + pallets/proof-of-stake/Cargo.toml | 1 + pallets/proof-of-stake/src/lib.rs | 7 ++- pallets/proof-of-stake/src/tests.rs | 74 +++++++++++++++++++++++++---- 4 files changed, 73 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1102437ef3..1705c86419 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6820,6 +6820,7 @@ dependencies = [ "pallet-vesting-mangata", "pallet-xyk", "parity-scale-codec", + "primitive-types", "rustc-hex", "scale-info", "serde", diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index c6aedfa0ad..9c23e8e6f6 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -29,6 +29,7 @@ pallet-bootstrap = { default-features = false, path = "../bootstrap" } sp-arithmetic = { default-features = false, version = '6.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } libm = { default-features = false, git = "https://github.com/rust-lang/libm", rev="2f3fc968f43d345f9b449938d050a9ea46a04c83"} orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } +primitive-types = "0.12.0" pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 542d68e503..23bd5b30c1 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -889,7 +889,11 @@ impl Pallet { println!("update_total_activated_liqudity swithc {}", diff); // NOTE: handle burn so negative diff *cumulative += *pending; - *pending = diff; + if change { + *pending = diff; + }else{ + *pending = -diff; + } *idx = session_id; } }); @@ -1321,6 +1325,7 @@ impl Pallet { reward_token: TokenId, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; + Self::update_cumulative_rewards(liquidity_asset_id, reward_token); let calc = RewardsCalculator::schedule_rewards::( user.clone(), diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 5b42307a7d..51e3d5b706 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -2366,11 +2366,7 @@ fn deactivate_3rdparty_rewards() { ); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( - CHARLIE, - LIQUIDITY_TOKEN, - REWARD_TOKEN - ), + ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(500) ); ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( @@ -2441,7 +2437,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(1); + roll_to_session(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![(FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 1 * 1000u128),] @@ -2463,7 +2459,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(2); + roll_to_session(3); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -2488,7 +2484,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(3); + roll_to_session(4); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -2514,7 +2510,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(4); + roll_to_session(5); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -3524,3 +3520,63 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ); }); } + + +#[test] +#[serial] +fn test_multiple_activations_in_same_block() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + let amount = 10_000u128; + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + + + + roll_to_session(1); + + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + + + roll_to_session(2); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), + Ok(REWARD_AMOUNT/10/2) + ); + }); +} From f09582b47d6425b7db12c5b070fe7573750ecaaf Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 25 Oct 2023 07:24:59 +0000 Subject: [PATCH 49/83] all tests passig --- pallets/proof-of-stake/src/lib.rs | 50 ++++++++----------- pallets/proof-of-stake/src/reward_info.rs | 2 - pallets/proof-of-stake/src/tests.rs | 61 +++++++++++------------ 3 files changed, 50 insertions(+), 63 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 23bd5b30c1..eac9a273e9 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -240,6 +240,7 @@ pub mod pallet { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ if schedule.last_session >= session_id{ + println!("=====> SCHEDULEREWARDSTOTAL BEFORE : ({}:{}) : {:?}", schedule.liq_token, schedule.reward_token, schedule); if schedule.scheduled_at < session_id{ ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)|{ if *idx >= session_id { @@ -252,6 +253,7 @@ pub mod pallet { println!("=====> SCHEDULEREWARDSTOTAL : ({}:{}) cumulative: {} pending: {}", schedule.liq_token, schedule.reward_token ,*cumulative, *pending); }); } + println!("=====> SCHEDULEREWARDSTOTAL AFTER : ({}:{}) : {:?}", schedule.liq_token, schedule.reward_token, schedule); ScheduleListPos::::put(pos_val); }else{ match(Self::head(), Self::tail()){ @@ -514,7 +516,7 @@ pub mod pallet { /// Total amount of activated liquidity for each schedule #[pallet::storage] pub type TotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u128, u64, u128), ValueQuery>; + StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u128, u128, u64, u128), ValueQuery>; // #[pallet::storage] // pub type PrevTotalActivatedLiquidityForSchedules = @@ -808,7 +810,6 @@ impl Pallet { println!("update_cumulative_rewards cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); }else{ let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - // let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); if total_activated_liquidity > 0 { ScheduleRewardsTotal::::mutate((liquidity_asset_id, liquidity_assets_reward), |(cumulative, _, _)|{ @@ -831,7 +832,6 @@ impl Pallet { cumulative }else{ let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - // let (_, total_schedule_rewards) = Self::total_schedule_rewards_parts(liquidity_asset_id, liquidity_assets_reward); let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); println!("total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); @@ -840,13 +840,13 @@ impl Pallet { } fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ - let (pending, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); + let (pending_negative, pending_positive, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); if idx == (Self::session_index() as u64){ println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative }else{ - println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending); - cumulative + pending + println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending_positive - pending_negative); + cumulative + pending_positive - pending_negative } } @@ -861,43 +861,33 @@ impl Pallet { } } - fn total_schedule_rewards_parts(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> (Balance, Balance){ - let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64){ - println!("total_schedule_rewards_parts at {} (cumulative , pending) idx: ({}, {})", idx, cumulative , pending); - (cumulative, pending) - }else{ - println!("total_schedule_rewards_parts at {} (cumulative , pending) idx: ({}, {})", idx, cumulative , pending); - (cumulative, pending) - } - } - fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { // TODO: make configurable let session_id = Self::session_index() as u64; - println!("update_total_activated_liqudity before {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); - TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(pending, idx, cumulative)|{ + println!("update_total_activated_liqudity BEFORE {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); + TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(pending_negative, pending_positive, idx, cumulative)|{ if *idx == session_id { - let new_amount = if change{ - *pending + diff + if change{ + *pending_positive += diff; }else{ - *pending - diff + *pending_negative += diff; }; - *pending = new_amount; }else{ - println!("update_total_activated_liqudity swithc {}", diff); + println!("update_total_activated_liqudity SWITCH {}", diff); // NOTE: handle burn so negative diff - *cumulative += *pending; - if change { - *pending = diff; + *cumulative = *cumulative + *pending_positive - *pending_negative; + if change{ + *pending_positive = diff; + *pending_negative = 0u128; }else{ - *pending = -diff; - } + *pending_positive = 0u128; + *pending_negative = diff; + }; *idx = session_id; } }); - println!("update_total_activated_liqudity after {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); + println!("update_total_activated_liqudity AFTER {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); // println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 7e016ba7c6..22708df840 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -290,7 +290,6 @@ impl RewardsCalculator { pub fn claim_rewards(self) -> sp_std::result::Result<(RewardInfo, Balance), RewardsCalcError> { let current_rewards = self.calculate_rewards_impl()?; - println!("TOTAL AVAILABLE: {:?}", current_rewards); let total_available_rewards = current_rewards .checked_add(self.rewards_info.rewards_not_yet_claimed) .and_then(|v| v.checked_sub(self.rewards_info.rewards_already_claimed)) @@ -304,7 +303,6 @@ impl RewardsCalculator { } pub fn calculate_rewards(self) -> sp_std::result::Result { - println!("calculate_rewards !!!!!"); self.calculate_rewards_impl() } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 51e3d5b706..01c237ce11 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -2293,7 +2293,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ) .unwrap(); - roll_to_session(6); + roll_to_session(7); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( @@ -2310,7 +2310,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN ), - Ok(5000) + Ok(6000) ); }); } @@ -2447,7 +2447,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() FIRST_REWARDED_PAIR, SECOND_REWARD_TOKEN, 2 * REWARD_AMOUNT, - 11u32.into(), + 12u32.into(), ) .unwrap(); ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -2464,6 +2464,16 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 0 * 2000u128), + ] + ); + + roll_to_session(4); + + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), + vec![ + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 3 * 1000u128), (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), ] ); @@ -2472,7 +2482,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() SECOND_REWARDED_PAIR, FIRST_REWARD_TOKEN, REWARD_AMOUNT, - 12u32.into(), + 14u32.into(), ) .unwrap(); ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -2484,13 +2494,13 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(4); + roll_to_session(5); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ - (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 3 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 4 * 1000u128), (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 2 * 2000u128), - (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 1 * 1000u128), + (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0 * 1000u128), ] ); ProofOfStake::reward_pool( @@ -2498,7 +2508,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() SECOND_REWARDED_PAIR, SECOND_REWARD_TOKEN, 2 * REWARD_AMOUNT, - 13u32.into(), + 15u32.into(), ) .unwrap(); ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -2510,12 +2520,12 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(5); + roll_to_session(7); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ - (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 4 * 1000u128), - (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), + (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 6 * 1000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 4 * 2000u128), (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), ] @@ -2532,16 +2542,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), - (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), - (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), - (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), - ] - ); - assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), - vec![ - (FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 0u128), - (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 3 * 2000u128), + (FIRST_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 4 * 2000u128), (SECOND_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 2 * 1000u128), (SECOND_LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN, 1 * 2000u128), ] @@ -2596,6 +2597,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ] ); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), FIRST_LIQUIDITY_TOKEN, @@ -2662,14 +2664,6 @@ fn liquidity_minting_liquidity_can_be_resused() { 10u32.into(), ) .unwrap(); - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - SECOND_REWARD_TOKEN, - 2 * REWARD_AMOUNT, - 10u32.into(), - ) - .unwrap(); ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(BOB), @@ -2687,9 +2681,8 @@ fn liquidity_minting_liquidity_can_be_resused() { ) .unwrap(); - roll_to_session(1); + roll_to_session(2); - assert_eq!(ProofOfStake::calculate_rewards_amount(BOB, LIQUIDITY_TOKEN), Ok(200)); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, @@ -3580,3 +3573,9 @@ fn test_multiple_activations_in_same_block() { ); }); } + + + +// how many blocks after activations rewards are avialabe +// deactivation in same & different blocks +// activation time does not matter From 5d95d4cc2d11bbe96d8248201e5b13fbf7b5fd17 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 25 Oct 2023 07:48:31 +0000 Subject: [PATCH 50/83] rewards_are_available_in_next_session_after_rewards_are_provided test addedd --- pallets/proof-of-stake/src/tests.rs | 59 ++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 01c237ce11..1f889009ab 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3294,7 +3294,7 @@ fn claim_rewards_from_multiple_sessions_at_once() { #[test] #[serial] -fn matt() { +fn multi_user_rewards_distributeion_scenario() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) @@ -3575,7 +3575,62 @@ fn test_multiple_activations_in_same_block() { } +#[test] +#[serial] +fn rewards_are_available_in_next_session_after_rewards_are_provided() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 10*3*REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .issue(EVE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT, 10u32.into(),) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + + + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + roll_to_session(1); + + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + roll_to_session(2); + + assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + roll_to_session(3); + + assert_eq!(15_000u128 + 10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(15_000u128 + 10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + }); +} + + + -// how many blocks after activations rewards are avialabe +// multiple activates in same & different blocks // deactivation in same & different blocks // activation time does not matter From 67805d10f785cfaf3cd7945faefa5044980fd841 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 25 Oct 2023 11:08:27 +0000 Subject: [PATCH 51/83] add test multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedule --- pallets/proof-of-stake/src/tests.rs | 75 +++++++++++++++++++++++++++-- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 1f889009ab..cca1a3b826 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3628,9 +3628,78 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { }); } +#[test] +#[serial] +fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedule() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 10*3*REWARD_AMOUNT) + .issue(ALICE, LIQUIDITY_TOKEN, 100) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .issue(CHARLIE, LIQUIDITY_TOKEN, 100) + .issue(EVE, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + + /// 1000 rewards per session + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, REWARD_TOKEN, REWARD_AMOUNT, 10u32.into(),) .unwrap(); + + + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + + + roll_to_session(2); + + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN,) .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN,) .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN,) .unwrap(); + + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + roll_to_session(3); + + assert_eq!(1000u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + + assert_eq!(1000u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + + + roll_to_session(4); + + assert_eq!(1249u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(749u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(749u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!(249u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + }); +} -// multiple activates in same & different blocks -// deactivation in same & different blocks -// activation time does not matter From 605ac828256c8e42b74cac11708645cbfed12cd2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 25 Oct 2023 11:09:07 +0000 Subject: [PATCH 52/83] fix formatting --- pallets/proof-of-stake/src/lib.rs | 486 +++++++---- pallets/proof-of-stake/src/reward_info.rs | 3 +- pallets/proof-of-stake/src/tests.rs | 979 +++++++++++++++------- 3 files changed, 979 insertions(+), 489 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index eac9a273e9..bbd89cc196 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -96,7 +96,7 @@ use frame_support::pallet_prelude::*; pub type ScheduleId = u64; #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo, MaxEncodedLen)] -pub struct Schedule{ +pub struct Schedule { scheduled_at: u64, last_session: u64, liq_token: TokenId, @@ -106,7 +106,7 @@ pub struct Schedule{ use frame_benchmarking::Zero; use frame_support::{ - dispatch::{DispatchError, DispatchErrorWithPostInfo, PostDispatchInfo, DispatchResult}, + dispatch::{DispatchError, DispatchErrorWithPostInfo, DispatchResult, PostDispatchInfo}, ensure, storage::bounded_btree_map::BoundedBTreeMap, traits::Nothing, @@ -189,21 +189,21 @@ pub mod pallet { #[pallet::hooks] impl Hooks for Pallet { fn on_initialize(n: T::BlockNumber) -> Weight { - let session_id = Self::session_index() as u64; - println!("=================> ON_INITIALIZE {} : {}", n, session_id); - if frame_system::Pallet::::block_number().saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 { + if frame_system::Pallet::::block_number().saturated_into::() % + T::RewardsDistributionPeriod::get() == + 0u32 + { ScheduleListPos::::kill(); - return Default::default(); + return Default::default() } // println!("on_initialize {}", n); const AMOUNT_PER_BLOCK: u64 = 5; - // // NOTE: 3R // println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); // println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); @@ -219,90 +219,94 @@ pub mod pallet { // println!("iter {}:{}", n, idx); // println!("session_id : {:?}", session_id); - let last_valid = ScheduleListPos::::get(); - let pos = match ( last_valid, ScheduleListHead::::get() ){ - (Some(pos), _) => { - if let Some ((schedule, next)) = RewardsSchedulesList::::get(pos) { - next - }else{ - None - } - }, - (None, Some(head)) => { - Some(head) - }, - _ => { None }, - }; + let last_valid = ScheduleListPos::::get(); + let pos = match (last_valid, ScheduleListHead::::get()) { + (Some(pos), _) => { + if let Some((schedule, next)) = RewardsSchedulesList::::get(pos) { + next + } else { + None + } + }, + (None, Some(head)) => Some(head), + _ => None, + }; // println!("last_valid : {:?}", last_valid); // println!("pos : {:?}", pos); - if let Some(pos_val) = pos { - if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val){ - if schedule.last_session >= session_id{ - - println!("=====> SCHEDULEREWARDSTOTAL BEFORE : ({}:{}) : {:?}", schedule.liq_token, schedule.reward_token, schedule); - if schedule.scheduled_at < session_id{ - ScheduleRewardsTotal::::mutate((schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)|{ + if let Some(pos_val) = pos { + if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val) { + if schedule.last_session >= session_id { + println!( + "=====> SCHEDULEREWARDSTOTAL BEFORE : ({}:{}) : {:?}", + schedule.liq_token, schedule.reward_token, schedule + ); + if schedule.scheduled_at < session_id { + ScheduleRewardsTotal::::mutate( + (schedule.liq_token, schedule.reward_token), + |(pending, idx, cumulative)| { if *idx >= session_id { *pending += schedule.amount_per_session - }else{ + } else { *cumulative += *pending; *pending = schedule.amount_per_session; *idx = session_id; } println!("=====> SCHEDULEREWARDSTOTAL : ({}:{}) cumulative: {} pending: {}", schedule.liq_token, schedule.reward_token ,*cumulative, *pending); - }); - } - println!("=====> SCHEDULEREWARDSTOTAL AFTER : ({}:{}) : {:?}", schedule.liq_token, schedule.reward_token, schedule); - ScheduleListPos::::put(pos_val); - }else{ - match(Self::head(), Self::tail()){ - (Some(head), Some(tail)) if head == pos_val && head != tail=> { - println!("remove first list elem"); - if let Some(next) = next{ - ScheduleListHead::::put(next); - } - }, - (Some(head), Some(tail)) if tail == pos_val && head == tail=> { - ScheduleListTail::::kill(); - ScheduleListHead::::kill(); - ScheduleListPos::::kill(); }, - (Some(head), Some(tail)) if tail == pos_val && head != tail=> { - println!("remove last list elem"); - if let Some(last_valid) = last_valid{ - ScheduleListTail::::put(last_valid); - RewardsSchedulesList::::mutate(last_valid, |data|{ - if let Some((schedule, next)) = data.as_mut() { - *next = None - } - }); - } - }, - (Some(head), Some(tail)) => { - println!("remove middle elem {}", pos_val); - if let Some(last_valid) = last_valid{ - RewardsSchedulesList::::mutate(last_valid, |data|{ - if let Some((schedule, prev_next)) = data.as_mut() { - *prev_next = next - } - }); - } - }, - _ => {} - - } + ); + } + println!( + "=====> SCHEDULEREWARDSTOTAL AFTER : ({}:{}) : {:?}", + schedule.liq_token, schedule.reward_token, schedule + ); + ScheduleListPos::::put(pos_val); + } else { + match (Self::head(), Self::tail()) { + (Some(head), Some(tail)) if head == pos_val && head != tail => { + println!("remove first list elem"); + if let Some(next) = next { + ScheduleListHead::::put(next); + } + }, + (Some(head), Some(tail)) if tail == pos_val && head == tail => { + ScheduleListTail::::kill(); + ScheduleListHead::::kill(); + ScheduleListPos::::kill(); + }, + (Some(head), Some(tail)) if tail == pos_val && head != tail => { + println!("remove last list elem"); + if let Some(last_valid) = last_valid { + ScheduleListTail::::put(last_valid); + RewardsSchedulesList::::mutate(last_valid, |data| { + if let Some((schedule, next)) = data.as_mut() { + *next = None + } + }); + } + }, + (Some(head), Some(tail)) => { + println!("remove middle elem {}", pos_val); + if let Some(last_valid) = last_valid { + RewardsSchedulesList::::mutate(last_valid, |data| { + if let Some((schedule, prev_next)) = data.as_mut() { + *prev_next = next + } + }); + } + }, + _ => {}, } - } - } else{ + } + } else { // println!("###############################################"); - break; - } - } - Default::default() - } - } + break + } + } + Default::default() + } + } #[cfg(feature = "runtime-benchmarks")] pub trait PoSBenchmarkingConfig: pallet_issuance::Config {} @@ -467,10 +471,12 @@ pub mod pallet { /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] - pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat ,(TokenId, TokenId), (u128, u64, u128), ValueQuery>; + pub type ScheduleRewardsTotal = + StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; #[pallet::storage] - pub type ScheduleRewardsPerLiquidity = StorageMap<_, Twox64Concat ,(TokenId, TokenId), (U256, u64), ValueQuery>; + pub type ScheduleRewardsPerLiquidity = + StorageMap<_, Twox64Concat, (TokenId, TokenId), (U256, u64), ValueQuery>; /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic @@ -506,7 +512,8 @@ pub mod pallet { pub type ScheduleListTail = StorageValue<_, ScheduleId, OptionQuery>; #[pallet::storage] - pub type RewardsSchedulesList = StorageMap<_, Twox64Concat, ScheduleId, (Schedule, Option), OptionQuery>; + pub type RewardsSchedulesList = + StorageMap<_, Twox64Concat, ScheduleId, (Schedule, Option), OptionQuery>; /// Maps liquidity token to list of tokens that it ever was rewarded with #[pallet::storage] @@ -515,8 +522,15 @@ pub mod pallet { /// Total amount of activated liquidity for each schedule #[pallet::storage] - pub type TotalActivatedLiquidityForSchedules = - StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (u128, u128, u64, u128), ValueQuery>; + pub type TotalActivatedLiquidityForSchedules = StorageDoubleMap< + _, + Twox64Concat, + TokenId, + Twox64Concat, + TokenId, + (u128, u128, u64, u128), + ValueQuery, + >; // #[pallet::storage] // pub type PrevTotalActivatedLiquidityForSchedules = @@ -683,7 +697,9 @@ pub mod pallet { ) .map_err(|err| DispatchErrorWithPostInfo { post_info: PostDispatchInfo { - actual_weight: Some(<::WeightInfo>::activate_liquidity_for_3rdparty_rewards()), + actual_weight: Some( + <::WeightInfo>::activate_liquidity_for_3rdparty_rewards(), + ), pays_fee: Pays::Yes, }, error: err, @@ -716,7 +732,9 @@ pub mod pallet { ) .map_err(|err| DispatchErrorWithPostInfo { post_info: PostDispatchInfo { - actual_weight: Some(<::WeightInfo>::activate_liquidity_for_3rdparty_rewards()), + actual_weight: Some( + <::WeightInfo>::activate_liquidity_for_3rdparty_rewards(), + ), pays_fee: Pays::Yes, }, error: err, @@ -803,92 +821,171 @@ pub mod pallet { } impl Pallet { - fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) { - let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64){ - println!("update_cumulative_rewards cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); - }else{ - let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let (cumulative, idx) = + ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64) { + println!( + "update_cumulative_rewards cumulative idx: {} amount: {}", + idx, + cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default() + ); + } else { + let total_activated_liquidity = + Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = + Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); if total_activated_liquidity > 0 { - ScheduleRewardsTotal::::mutate((liquidity_asset_id, liquidity_assets_reward), |(cumulative, _, _)|{ - *cumulative = 0; - }); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); - println!("update_cumulative_rewards cumulative + pending idx: {} RAW amount: {}", idx, cumulative + pending); - println!("update_cumulative_rewards cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); - ScheduleRewardsPerLiquidity::::insert((liquidity_asset_id, liquidity_assets_reward), (cumulative + pending, (Self::session_index() as u64))); + ScheduleRewardsTotal::::mutate( + (liquidity_asset_id, liquidity_assets_reward), + |(cumulative, _, _)| { + *cumulative = 0; + }, + ); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) + .checked_div(U256::from(total_activated_liquidity)) + .unwrap_or_default(); + println!( + "update_cumulative_rewards cumulative + pending idx: {} RAW amount: {}", + idx, + cumulative + pending + ); + println!( + "update_cumulative_rewards cumulative + pending idx: {} amount: {}", + idx, + (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default() + ); + ScheduleRewardsPerLiquidity::::insert( + (liquidity_asset_id, liquidity_assets_reward), + (cumulative + pending, (Self::session_index() as u64)), + ); } } } - - fn total_rewards_for_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> U256{ - let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64){ - println!("total_rewards_for_liquidity cumulative idx: {} RAW amount: {}", idx, cumulative); - println!("total_rewards_for_liquidity cumulative idx: {} amount: {}", idx, cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default()); + fn total_rewards_for_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> U256 { + let (cumulative, idx) = + ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64) { + println!( + "total_rewards_for_liquidity cumulative idx: {} RAW amount: {}", + idx, cumulative + ); + println!( + "total_rewards_for_liquidity cumulative idx: {} amount: {}", + idx, + cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default() + ); cumulative - }else{ - let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)).checked_div(U256::from(total_activated_liquidity)).unwrap_or_default(); - println!("total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", idx, (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default()); + } else { + let total_activated_liquidity = + Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = + Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) + .checked_div(U256::from(total_activated_liquidity)) + .unwrap_or_default(); + println!( + "total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", + idx, + (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default() + ); cumulative + pending } } - fn total_activated_liquidity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ - let (pending_negative, pending_positive, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward); - if idx == (Self::session_index() as u64){ + fn total_activated_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending_negative, pending_positive, idx, cumulative) = + TotalActivatedLiquidityForSchedules::::get( + liquidity_asset_id, + liquidity_assets_reward, + ); + if idx == (Self::session_index() as u64) { println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative - }else{ - println!("total_activated_liquidity cumulative + pending idx: {} amount: {}", idx, cumulative + pending_positive - pending_negative); + } else { + println!( + "total_activated_liquidity cumulative + pending idx: {} amount: {}", + idx, + cumulative + pending_positive - pending_negative + ); cumulative + pending_positive - pending_negative } } - fn total_schedule_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) -> Balance{ - let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64){ + fn total_schedule_rewards( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending, idx, cumulative) = + ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Self::session_index() as u64) { println!("total_schedule_rewards cumulative idx: {} amount: {}", idx, cumulative); cumulative - }else{ - println!("total_schedule_rewards cumulative + pending idx: {} amount: {}", idx, cumulative + pending); + } else { + println!( + "total_schedule_rewards cumulative + pending idx: {} amount: {}", + idx, + cumulative + pending + ); cumulative + pending } } - fn update_total_activated_liqudity(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool) { + fn update_total_activated_liqudity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + diff: Balance, + change: bool, + ) { // TODO: make configurable let session_id = Self::session_index() as u64; - println!("update_total_activated_liqudity BEFORE {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); - TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(pending_negative, pending_positive, idx, cumulative)|{ - if *idx == session_id { - if change{ - *pending_positive += diff; - }else{ - *pending_negative += diff; - }; - }else{ - println!("update_total_activated_liqudity SWITCH {}", diff); - // NOTE: handle burn so negative diff - *cumulative = *cumulative + *pending_positive - *pending_negative; - if change{ - *pending_positive = diff; - *pending_negative = 0u128; - }else{ - *pending_positive = 0u128; - *pending_negative = diff; - }; - *idx = session_id; - } - }); - println!("update_total_activated_liqudity AFTER {:?}", TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward)); - + println!( + "update_total_activated_liqudity BEFORE {:?}", + TotalActivatedLiquidityForSchedules::::get( + liquidity_asset_id, + liquidity_assets_reward + ) + ); + TotalActivatedLiquidityForSchedules::::mutate( + liquidity_asset_id, + liquidity_assets_reward, + |(pending_negative, pending_positive, idx, cumulative)| { + if *idx == session_id { + if change { + *pending_positive += diff; + } else { + *pending_negative += diff; + }; + } else { + println!("update_total_activated_liqudity SWITCH {}", diff); + // NOTE: handle burn so negative diff + *cumulative = *cumulative + *pending_positive - *pending_negative; + if change { + *pending_positive = diff; + *pending_negative = 0u128; + } else { + *pending_positive = 0u128; + *pending_negative = diff; + }; + *idx = session_id; + } + }, + ); + println!( + "update_total_activated_liqudity AFTER {:?}", + TotalActivatedLiquidityForSchedules::::get( + liquidity_asset_id, + liquidity_assets_reward + ) + ); // println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); // if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ @@ -963,7 +1060,6 @@ impl Pallet { liquidity_asset_id: TokenId, amount: Balance, ) -> DispatchResult { - ensure!( ActivatedNativeRewardsLiq::::get(user.clone(), liquidity_asset_id) == 0, Error::::LiquidityLockedIn3rdpartyRewards @@ -1036,11 +1132,9 @@ impl Pallet { already_activated_amount + amount <= available_amount, Error::::NotEnoughAssets ); - ActivatedNativeRewardsLiq::::mutate( - user.clone(), - liquidity_asset_id, - |val| *val += amount, - ); + ActivatedNativeRewardsLiq::::mutate(user.clone(), liquidity_asset_id, |val| { + *val += amount + }); }, } @@ -1251,7 +1345,12 @@ impl Pallet { }, )?; - Self::update_total_activated_liqudity(liquidity_asset_id, liquidity_assets_reward, liquidity_assets_added, true); + Self::update_total_activated_liqudity( + liquidity_asset_id, + liquidity_assets_reward, + liquidity_assets_added, + true, + ); // TotalActivatedLiquidityForSchedules::::mutate( // liquidity_asset_id, @@ -1333,8 +1432,12 @@ impl Pallet { rewards_info, ); - - Self::update_total_activated_liqudity(liquidity_asset_id, reward_token, liquidity_assets_burned, false); + Self::update_total_activated_liqudity( + liquidity_asset_id, + reward_token, + liquidity_assets_burned, + false, + ); // TotalActivatedLiquidityForSchedules::::try_mutate( // liquidity_asset_id, // reward_token, @@ -1384,16 +1487,12 @@ impl Pallet { amount, ); - let amount = ActivatedNativeRewardsLiq::::mutate( - user.clone(), - liquidity_asset_id, - |val| { + let amount = + ActivatedNativeRewardsLiq::::mutate(user.clone(), liquidity_asset_id, |val| { let prev = *val; *val = 0; prev - }, - ); - + }); } Ok(()) @@ -1437,16 +1536,14 @@ impl Pallet { Ok(total_available_rewards) } - pub (crate) fn reward_pool_impl( + pub(crate) fn reward_pool_impl( sender: T::AccountId, pool: (TokenId, TokenId), token_id: TokenId, amount: Balance, schedule_end: T::BlockNumber, ) -> DispatchResult { - - let liquidity_token_id = - ::ValuationApi::get_liquidity_asset(pool.0, pool.1) + let liquidity_token_id = ::ValuationApi::get_liquidity_asset(pool.0, pool.1) .map_err(|_| Error::::PoolDoesNotExist)?; let current_session = Self::session_index(); @@ -1462,10 +1559,14 @@ impl Pallet { .ok_or(Error::::MathOverflow)?; ensure!( - ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewards::get() || - ((token_id == Into::::into(Self::native_token_id())) && amount_per_session >= T::Min3rdPartyRewards::get()) || - ::ValuationApi::valuate_non_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewards::get() - , + ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= + T::Min3rdPartyRewards::get() || + ((token_id == Into::::into(Self::native_token_id())) && + amount_per_session >= T::Min3rdPartyRewards::get()) || + ::ValuationApi::valuate_non_liquidity_token( + token_id, + amount_per_session + ) >= T::Min3rdPartyRewards::get(), Error::::TooLittleRewards ); @@ -1483,30 +1584,31 @@ impl Pallet { let head = ScheduleListHead::::get(); let tail = ScheduleListTail::::get(); - let schedule = Schedule{ + let schedule = Schedule { scheduled_at: Self::session_index() as u64, last_session: schedule_end.saturated_into::(), liq_token: liquidity_token_id, reward_token: token_id, - amount_per_session: amount_per_session + amount_per_session, }; - match (head, tail){ - (None, None) => { // first schedule + match (head, tail) { + (None, None) => { + // first schedule RewardsSchedulesList::::insert(0, (schedule, None::)); ScheduleListHead::::put(0); ScheduleListTail::::put(0); }, (Some(_head), Some(tail)) => { RewardsSchedulesList::::mutate(tail, |info| { - if let Some((_schedule, next)) = info.as_mut(){ + if let Some((_schedule, next)) = info.as_mut() { *next = Some(tail + 1u64) } }); RewardsSchedulesList::::insert(tail + 1, (schedule, None::)); ScheduleListTail::::put(tail + 1); }, - _ => {} // invariant assures this will never happen + _ => {}, // invariant assures this will never happen } Ok(()) @@ -1519,15 +1621,41 @@ impl ProofOfStakeRewardsApi for Pallet { type CurrencyId = TokenId; #[cfg(feature = "runtime-benchmarks")] - fn enable_3rdparty_rewards(account: T::AccountId, pool: (Self::CurrencyId,Self::CurrencyId), reward_token_id: Self::CurrencyId, last_session: u32, amount: Self::Balance){ - let liquidity_token_id = ::ValuationApi::get_liquidity_asset(pool.0, pool.1).expect("pool exist"); + fn enable_3rdparty_rewards( + account: T::AccountId, + pool: (Self::CurrencyId, Self::CurrencyId), + reward_token_id: Self::CurrencyId, + last_session: u32, + amount: Self::Balance, + ) { + let liquidity_token_id = + ::ValuationApi::get_liquidity_asset(pool.0, pool.1).expect("pool exist"); log!(info, "XXXX {}", liquidity_token_id); - Pallet::::reward_pool_impl(account.clone(), pool, reward_token_id, amount, last_session.into()).expect("call should pass"); + Pallet::::reward_pool_impl( + account.clone(), + pool, + reward_token_id, + amount, + last_session.into(), + ) + .expect("call should pass"); } #[cfg(feature = "runtime-benchmarks")] - fn activate_liquidity_for_3rdparty_rewards(account: T::AccountId, liquidity_token: Self::CurrencyId, amount: Self::Balance, reward_token_id: Self::CurrencyId){ - Pallet::::activate_liquidity_for_3rdparty_rewards_impl(account, liquidity_token, amount, ThirdPartyActivationKind::ActivateKind(None), reward_token_id).expect("call should pass") + fn activate_liquidity_for_3rdparty_rewards( + account: T::AccountId, + liquidity_token: Self::CurrencyId, + amount: Self::Balance, + reward_token_id: Self::CurrencyId, + ) { + Pallet::::activate_liquidity_for_3rdparty_rewards_impl( + account, + liquidity_token, + amount, + ThirdPartyActivationKind::ActivateKind(None), + reward_token_id, + ) + .expect("call should pass") } fn enable(liquidity_token_id: TokenId, weight: u8) { diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 22708df840..ece914f5a3 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -93,7 +93,8 @@ impl RewardsCalculator { // println!("total_activated : {}", total_activated); // println!("total_rewards : {}", total_rewards); // let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); - let pool_ratio_current = Pallet::::total_rewards_for_liquidity(asset_id, reward_asset_id); + let pool_ratio_current = + Pallet::::total_rewards_for_liquidity(asset_id, reward_asset_id); println!("SCHEDULE REWARDS RATIO: {}", pool_ratio_current); let default_rewards = RewardInfo { diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index cca1a3b826..1000a312ae 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -4,7 +4,7 @@ use super::*; use crate::mock::*; -use frame_support::{assert_err, assert_err_ignore_postinfo,assert_ok}; +use frame_support::{assert_err, assert_err_ignore_postinfo, assert_ok}; use mockall::predicate::eq; use serial_test::serial; @@ -1393,26 +1393,22 @@ fn rewards_schedule_is_stored() { let rewards_per_session = REWARD_AMOUNT / 5; assert_eq!( RewardsSchedulesList::::get(0).unwrap(), - (Schedule{ - scheduled_at: 0u64, - last_session: 5u64, - liq_token: LIQUIDITY_TOKEN, - reward_token: REWARD_TOKEN, - amount_per_session: rewards_per_session, - }, None) - ); - assert_eq!( - ScheduleListTail::::get(), - Some(0u64) - ); - assert_eq!( - ScheduleListHead::::get(), - Some(0u64) + ( + Schedule { + scheduled_at: 0u64, + last_session: 5u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: rewards_per_session, + }, + None + ) ); + assert_eq!(ScheduleListTail::::get(), Some(0u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); }); } - #[test] #[serial] fn rewards_linked_list_insert_multiple_schedules() { @@ -1442,42 +1438,40 @@ fn rewards_linked_list_insert_multiple_schedules() { 2u32.into() ),); - assert_eq!( RewardsSchedulesList::::get(0).unwrap(), - (Schedule{ - scheduled_at: 0u64, - last_session: 1u64, - liq_token: LIQUIDITY_TOKEN, - reward_token: REWARD_TOKEN, - amount_per_session: REWARD_AMOUNT / 1, - }, Some(1)) + ( + Schedule { + scheduled_at: 0u64, + last_session: 1u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: REWARD_AMOUNT / 1, + }, + Some(1) + ) ); assert_eq!( RewardsSchedulesList::::get(1).unwrap(), - (Schedule{ - scheduled_at: 0u64, - last_session: 2u64, - liq_token: LIQUIDITY_TOKEN, - reward_token: REWARD_TOKEN, - amount_per_session: REWARD_AMOUNT / 2, - }, None) + ( + Schedule { + scheduled_at: 0u64, + last_session: 2u64, + liq_token: LIQUIDITY_TOKEN, + reward_token: REWARD_TOKEN, + amount_per_session: REWARD_AMOUNT / 2, + }, + None + ) ); - assert_eq!( - ScheduleListHead::::get(), - Some(0u64) - ); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); - assert_eq!( - ScheduleListTail::::get(), - Some(1u64) - ); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); }); } - #[test] #[serial] fn rewards_linked_list_removes_outdated_schedule_automatically() { @@ -1507,49 +1501,48 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { 2u32.into() ),); - assert_ok!(RewardsSchedulesList::::get(0).ok_or(())); assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); forward_to_block(2); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListPos::::get(), Some(1u64)); forward_to_block(5); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListPos::::get(), Some(1u64)); forward_to_block(11); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListPos::::get(), Some(1u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(1u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(1u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListPos::::get(), Some(1u64)); forward_to_block(25); - assert_eq!( ScheduleListHead::::get(), Some(1u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( ScheduleListPos::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(1u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListPos::::get(), Some(1u64)); forward_to_block(30); - assert_eq!( ScheduleListHead::::get(), Some(1u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); + assert_eq!(ScheduleListHead::::get(), Some(1u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); forward_to_block(31); - assert_eq!( ScheduleListHead::::get(), None); - assert_eq!( ScheduleListTail::::get(), None); - assert_eq!( ScheduleListPos::::get(), None); + assert_eq!(ScheduleListHead::::get(), None); + assert_eq!(ScheduleListTail::::get(), None); + assert_eq!(ScheduleListPos::::get(), None); }); } @@ -1558,7 +1551,7 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { // rewards_middle_schedule_from_linked_list // rewards_multipleall_schedule_from_linked_list -fn insert_schedule_ending_at_session(n: u32){ +fn insert_schedule_ending_at_session(n: u32) { assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1566,7 +1559,6 @@ fn insert_schedule_ending_at_session(n: u32){ REWARD_AMOUNT, n.into(), ),); - } #[test] @@ -1591,17 +1583,17 @@ fn rewards_first_schedule_from_linked_list_of_four() { assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(1u64)); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); - assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(1u64)); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); + assert_eq!(RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(3u64).unwrap().1, None); }); } @@ -1627,19 +1619,17 @@ fn remove_last_schedule_from_linked_list() { assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(2u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); - assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); - assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, None); - - + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(2u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!(RewardsSchedulesList::::get(1u64).unwrap().1, Some(2u64)); + assert_eq!(RewardsSchedulesList::::get(2u64).unwrap().1, None); }); } @@ -1665,21 +1655,20 @@ fn remove_middle_schedule_from_linked_list() { assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); - assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); + assert_eq!(RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(3u64).unwrap().1, None); }); } - #[test] #[serial] fn remove_first_few_elems_at_once_from_linked_list() { @@ -1702,16 +1691,16 @@ fn remove_first_few_elems_at_once_from_linked_list() { assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(2u64)); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(2u64)); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(2u64).unwrap().1, Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(3u64).unwrap().1, None); }); } @@ -1737,16 +1726,16 @@ fn remove_few_last_elems_at_once_from_linked_list() { assert_ok!(RewardsSchedulesList::::get(1).ok_or(())); assert_ok!(RewardsSchedulesList::::get(2).ok_or(())); assert_ok!(RewardsSchedulesList::::get(3).ok_or(())); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListPos::::get(), None); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListPos::::get(), None); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(1u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); - assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!(RewardsSchedulesList::::get(1u64).unwrap().1, None); }); } @@ -1778,10 +1767,10 @@ fn remove_few_middle_elements_from_linkedd_list() { forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(3u64).unwrap().1, None); }); } @@ -1815,11 +1804,11 @@ fn remove_random_elements_from_linked_list() { forward_to_block(21); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(4u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); - assert_eq!( RewardsSchedulesList::::get(2u64).unwrap().1, Some(4u64)); - assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(4u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(2u64)); + assert_eq!(RewardsSchedulesList::::get(2u64).unwrap().1, Some(4u64)); + assert_eq!(RewardsSchedulesList::::get(4u64).unwrap().1, None); }); } @@ -1850,26 +1839,23 @@ fn remove_random_elements_from_linked_list_over_time() { forward_to_block(24); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(6u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); - assert_eq!( RewardsSchedulesList::::get(1u64).unwrap().1, Some(3u64)); - assert_eq!( RewardsSchedulesList::::get(3u64).unwrap().1, Some(4u64)); - assert_eq!( RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); - assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(6u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); + assert_eq!(RewardsSchedulesList::::get(1u64).unwrap().1, Some(3u64)); + assert_eq!(RewardsSchedulesList::::get(3u64).unwrap().1, Some(4u64)); + assert_eq!(RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); + assert_eq!(RewardsSchedulesList::::get(6u64).unwrap().1, None); forward_to_block(40); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(6u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(6u64)); - assert_eq!( RewardsSchedulesList::::get(6u64).unwrap().1, None); - - + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(6u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(6u64)); + assert_eq!(RewardsSchedulesList::::get(6u64).unwrap().1, None); }); } - #[test] #[serial] fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { @@ -1899,14 +1885,14 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { forward_to_block(24); - assert_eq!( ScheduleListHead::::get(), Some(0u64)); - assert_eq!( ScheduleListTail::::get(), Some(8u64)); - assert_eq!( RewardsSchedulesList::::get(0u64).unwrap().1, Some(8u64)); - assert_eq!( RewardsSchedulesList::::get(8u64).unwrap().1, None); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(8u64)); + assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(8u64)); + assert_eq!(RewardsSchedulesList::::get(8u64).unwrap().1, None); forward_to_block(100); - assert_eq!( ScheduleListHead::::get(), None); - assert_eq!( ScheduleListTail::::get(), None); + assert_eq!(ScheduleListHead::::get(), None); + assert_eq!(ScheduleListTail::::get(), None); }); } @@ -1969,14 +1955,8 @@ fn duplicated_schedules_works() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - assert_eq!( - ScheduleListHead::::get(), - None - ); - assert_eq!( - ScheduleListTail::::get(), - None - ); + assert_eq!(ScheduleListHead::::get(), None); + assert_eq!(ScheduleListTail::::get(), None); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1986,14 +1966,8 @@ fn duplicated_schedules_works() { 5u32.into() )); - assert_eq!( - ScheduleListHead::::get(), - Some(0u64) - ); - assert_eq!( - ScheduleListTail::::get(), - Some(0u64) - ); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(0u64)); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2003,14 +1977,8 @@ fn duplicated_schedules_works() { 5u32.into() )); - assert_eq!( - ScheduleListHead::::get(), - Some(0u64) - ); - assert_eq!( - ScheduleListTail::::get(), - Some(1u64) - ); + assert_eq!(ScheduleListHead::::get(), Some(0u64)); + assert_eq!(ScheduleListTail::::get(), Some(1u64)); }); } @@ -2027,7 +1995,8 @@ fn reject_schedule_with_too_little_rewards_per_session() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(1u128); - let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + let valuate_non_liquidity_token_mock = + MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(0u128); roll_to_session(4); @@ -2085,7 +2054,8 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); - let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + let valuate_non_liquidity_token_mock = + MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); roll_to_session(4); @@ -2100,7 +2070,6 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { }); } - #[test] #[serial] fn user_can_claim_3rdparty_rewards() { @@ -2217,29 +2186,57 @@ fn overlapping_3rdparty_rewards_works() { .unwrap(); roll_to_session(1); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, first_reward_token, None,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + first_reward_token, + None, + ) + .unwrap(); roll_to_session(5); let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), pair, second_reward_token_id, 100_000, 15u32.into(),) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, second_reward_token_id, None,) .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + pair, + second_reward_token_id, + 100_000, + 15u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + second_reward_token_id, + None, + ) + .unwrap(); roll_to_session(7); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, second_reward_token_id), + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + second_reward_token_id + ), Ok(10000) ); println!("############################## ##############################"); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, first_reward_token), + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + first_reward_token + ), Ok(6000) ); }); } - #[test] #[serial] fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { @@ -2366,7 +2363,11 @@ fn deactivate_3rdparty_rewards() { ); assert_eq!( - ProofOfStake::calculate_3rdparty_rewards_amount( CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN), + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ), Ok(500) ); ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( @@ -2395,7 +2396,6 @@ fn deactivate_3rdparty_rewards() { }); } - #[test] #[serial] fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() { @@ -2597,7 +2597,6 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ] ); - ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), FIRST_LIQUIDITY_TOKEN, @@ -2723,7 +2722,8 @@ fn fail_to_transfer_tokens_that_has_been_partially_deactivated() { FIRST_REWARD_TOKEN, REWARD_AMOUNT, 10u32.into(), - ).unwrap(); + ) + .unwrap(); ProofOfStake::activate_liquidity_for_native_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2774,16 +2774,13 @@ fn fail_to_transfer_tokens_that_has_been_partially_deactivated() { ) .unwrap(); - assert_ok!( - TokensOf::::transfer( - LIQUIDITY_TOKEN, - &BOB, - &CHARLIE, - 100, - ExistenceRequirement::AllowDeath - ) - ); - + assert_ok!(TokensOf::::transfer( + LIQUIDITY_TOKEN, + &BOB, + &CHARLIE, + 100, + ExistenceRequirement::AllowDeath + )); }); } @@ -3043,18 +3040,76 @@ fn can_claim_schedule_rewards() { assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 0,); assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 0,); - assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 1000); - assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 1000); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(), + 1000 + ); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(), + 1000 + ); - ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(); + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(); - assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 0); - assert_eq!(ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 1000); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(), + 0 + ); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(), + 1000 + ); - ProofOfStake::claim_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(); + ProofOfStake::claim_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(); - assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN,) .unwrap(), 0); - assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, LIQUIDITY_TOKEN, SECOND_REWARD_TOKEN,) .unwrap(), 0); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + FIRST_REWARD_TOKEN, + ) + .unwrap(), + 0 + ); + assert_eq!( + ProofOfStake::calculate_3rdparty_rewards_amount( + BOB, + LIQUIDITY_TOKEN, + SECOND_REWARD_TOKEN, + ) + .unwrap(), + 0 + ); assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 1000); assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 1000); @@ -3151,39 +3206,28 @@ use sp_runtime::{traits::Dispatchable, Permill}; #[ignore] #[serial] fn activate_deactivate_calls_are_free_of_charge() { - ExtBuilder::new() - .build() - .execute_with(|| { - System::set_block_number(1); - - let activate_call = mock::RuntimeCall::ProofOfStake( - Call::activate_liquidity_for_3rdparty_rewards{ - liquidity_token_id: LIQUIDITY_TOKEN, - amount: 100, - reward_token: REWARD_TOKEN, - use_balance_from: None, - } - ); + ExtBuilder::new().build().execute_with(|| { + System::set_block_number(1); - let deactivate_call = mock::RuntimeCall::ProofOfStake( - Call::deactivate_liquidity_for_3rdparty_rewards{ - liquidity_token_id: LIQUIDITY_TOKEN, - amount: 100, - reward_token: REWARD_TOKEN, - } - ); + let activate_call = + mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + use_balance_from: None, + }); - assert_eq!( - activate_call.get_dispatch_info().pays_fee, - Pays::No - ); + let deactivate_call = + mock::RuntimeCall::ProofOfStake(Call::deactivate_liquidity_for_3rdparty_rewards { + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + }); - assert_eq!( - deactivate_call.get_dispatch_info().pays_fee, - Pays::No - ); + assert_eq!(activate_call.get_dispatch_info().pays_fee, Pays::No); - }); + assert_eq!(deactivate_call.get_dispatch_info().pays_fee, Pays::No); + }); } #[test] @@ -3201,37 +3245,41 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - let activate_call = mock::RuntimeCall::ProofOfStake( - Call::activate_liquidity_for_3rdparty_rewards{ + let activate_call = + mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { liquidity_token_id: LIQUIDITY_TOKEN, amount: 100, reward_token: REWARD_TOKEN, use_balance_from: None, - } - ); + }); - let deactivate_call = mock::RuntimeCall::ProofOfStake( - Call::deactivate_liquidity_for_3rdparty_rewards{ + let deactivate_call = + mock::RuntimeCall::ProofOfStake(Call::deactivate_liquidity_for_3rdparty_rewards { liquidity_token_id: LIQUIDITY_TOKEN, amount: 100, reward_token: REWARD_TOKEN, - } - ); - + }); assert_eq!( - activate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap_err().post_info.pays_fee, + activate_call + .dispatch(RuntimeOrigin::signed(BOB)) + .unwrap_err() + .post_info + .pays_fee, Pays::Yes ); assert_eq!( - deactivate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap_err().post_info.pays_fee, + deactivate_call + .dispatch(RuntimeOrigin::signed(BOB)) + .unwrap_err() + .post_info + .pays_fee, Pays::Yes ); }); } - #[test] #[serial] fn claim_rewards_from_multiple_sessions_at_once() { @@ -3446,7 +3494,6 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions( ) .unwrap(); - roll_to_session(7); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), @@ -3492,8 +3539,6 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ) .unwrap(); - - roll_to_session(15); ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -3514,7 +3559,6 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe }); } - #[test] #[serial] fn test_multiple_activations_in_same_block() { @@ -3542,8 +3586,6 @@ fn test_multiple_activations_in_same_block() { ) .unwrap(); - - roll_to_session(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -3564,22 +3606,20 @@ fn test_multiple_activations_in_same_block() { ) .unwrap(); - roll_to_session(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), - Ok(REWARD_AMOUNT/10/2) + Ok(REWARD_AMOUNT / 10 / 2) ); }); } - #[test] #[serial] fn rewards_are_available_in_next_session_after_rewards_are_provided() { ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, 10*3*REWARD_AMOUNT) + .issue(ALICE, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) @@ -3591,40 +3631,162 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10 * 3 * REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT, 10u32.into(),) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - - - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); roll_to_session(1); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); roll_to_session(2); - assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(15_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 15_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 15_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(EVE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + 15_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 15_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); roll_to_session(3); - assert_eq!(15_000u128 + 10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(15_000u128 + 10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(10_000u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 15_000u128 + 10_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 15_000u128 + 10_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 10_000u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); }); } @@ -3632,7 +3794,7 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { #[serial] fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedule() { ExtBuilder::new() - .issue(ALICE, REWARD_TOKEN, 10*3*REWARD_AMOUNT) + .issue(ALICE, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT) .issue(ALICE, LIQUIDITY_TOKEN, 100) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) @@ -3645,61 +3807,260 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); - /// 1000 rewards per session - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, REWARD_TOKEN, REWARD_AMOUNT, 10u32.into(),) .unwrap(); - - - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(ALICE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); roll_to_session(2); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + ALICE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN,) .unwrap(); - ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN,) .unwrap(); - ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN,) .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 50, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(EVE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(ALICE), + LIQUIDITY_TOKEN, + 50, + REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(EVE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + ) + .unwrap(); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + ALICE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); roll_to_session(3); - assert_eq!(1000u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - - ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(ALICE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, 50, REWARD_TOKEN, None,) .unwrap(); - ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(EVE), LIQUIDITY_TOKEN, 100, REWARD_TOKEN, None,) .unwrap(); + assert_eq!( + 1000u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + ALICE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); - assert_eq!(1000u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(500u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(0u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + ProofOfStake::deactivate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(ALICE), + LIQUIDITY_TOKEN, + 50, + REWARD_TOKEN, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(ALICE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(CHARLIE), + LIQUIDITY_TOKEN, + 50, + REWARD_TOKEN, + None, + ) + .unwrap(); + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(EVE), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + .unwrap(); + assert_eq!( + 1000u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + ALICE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 500u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 0u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); roll_to_session(4); - assert_eq!(1249u128, ProofOfStake::calculate_3rdparty_rewards_amount(ALICE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(749u128, ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(749u128, ProofOfStake::calculate_3rdparty_rewards_amount(CHARLIE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); - assert_eq!(249u128, ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN).unwrap()); + assert_eq!( + 1249u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + ALICE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 749u128, + ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); + assert_eq!( + 749u128, + ProofOfStake::calculate_3rdparty_rewards_amount( + CHARLIE, + LIQUIDITY_TOKEN, + REWARD_TOKEN + ) + .unwrap() + ); + assert_eq!( + 249u128, + ProofOfStake::calculate_3rdparty_rewards_amount(EVE, LIQUIDITY_TOKEN, REWARD_TOKEN) + .unwrap() + ); }); } - - - From 85ad4fb59f48221af2d787db2c46429c887460ca Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 25 Oct 2023 11:23:48 +0000 Subject: [PATCH 53/83] remove prints --- pallets/proof-of-stake/src/lib.rs | 175 +--------------------------- pallets/proof-of-stake/src/tests.rs | 5 - 2 files changed, 6 insertions(+), 174 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index bbd89cc196..2239393e01 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -191,8 +191,6 @@ pub mod pallet { fn on_initialize(n: T::BlockNumber) -> Weight { let session_id = Self::session_index() as u64; - println!("=================> ON_INITIALIZE {} : {}", n, session_id); - if frame_system::Pallet::::block_number().saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 @@ -201,24 +199,11 @@ pub mod pallet { return Default::default() } - // println!("on_initialize {}", n); const AMOUNT_PER_BLOCK: u64 = 5; - // // NOTE: 3R - // println!("ScheduleListPos : {:?}", ScheduleListPos::::get()); - // println!("ScheduleListHead : {:?}", ScheduleListHead::::get()); - // println!("ScheduleListTail : {:?}", ScheduleListTail::::get()); - - // 1R 1W 15RW - - //NOTE: 5 transfers => 15R 15W - // NOTE: 3R + 1R // TODO: make configurable for idx in 0..AMOUNT_PER_BLOCK { - // println!("iter {}:{}", n, idx); - // println!("session_id : {:?}", session_id); - let last_valid = ScheduleListPos::::get(); let pos = match (last_valid, ScheduleListHead::::get()) { (Some(pos), _) => { @@ -231,16 +216,10 @@ pub mod pallet { (None, Some(head)) => Some(head), _ => None, }; - // println!("last_valid : {:?}", last_valid); - // println!("pos : {:?}", pos); if let Some(pos_val) = pos { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val) { if schedule.last_session >= session_id { - println!( - "=====> SCHEDULEREWARDSTOTAL BEFORE : ({}:{}) : {:?}", - schedule.liq_token, schedule.reward_token, schedule - ); if schedule.scheduled_at < session_id { ScheduleRewardsTotal::::mutate( (schedule.liq_token, schedule.reward_token), @@ -252,30 +231,22 @@ pub mod pallet { *pending = schedule.amount_per_session; *idx = session_id; } - println!("=====> SCHEDULEREWARDSTOTAL : ({}:{}) cumulative: {} pending: {}", schedule.liq_token, schedule.reward_token ,*cumulative, *pending); }, ); } - println!( - "=====> SCHEDULEREWARDSTOTAL AFTER : ({}:{}) : {:?}", - schedule.liq_token, schedule.reward_token, schedule - ); ScheduleListPos::::put(pos_val); } else { match (Self::head(), Self::tail()) { - (Some(head), Some(tail)) if head == pos_val && head != tail => { - println!("remove first list elem"); + (Some(head), Some(tail)) if head == pos_val && head != tail => if let Some(next) = next { ScheduleListHead::::put(next); - } - }, + }, (Some(head), Some(tail)) if tail == pos_val && head == tail => { ScheduleListTail::::kill(); ScheduleListHead::::kill(); ScheduleListPos::::kill(); }, - (Some(head), Some(tail)) if tail == pos_val && head != tail => { - println!("remove last list elem"); + (Some(head), Some(tail)) if tail == pos_val && head != tail => if let Some(last_valid) = last_valid { ScheduleListTail::::put(last_valid); RewardsSchedulesList::::mutate(last_valid, |data| { @@ -283,24 +254,20 @@ pub mod pallet { *next = None } }); - } - }, - (Some(head), Some(tail)) => { - println!("remove middle elem {}", pos_val); + }, + (Some(head), Some(tail)) => if let Some(last_valid) = last_valid { RewardsSchedulesList::::mutate(last_valid, |data| { if let Some((schedule, prev_next)) = data.as_mut() { *prev_next = next } }); - } - }, + }, _ => {}, } } } } else { - // println!("###############################################"); break } } @@ -825,11 +792,6 @@ impl Pallet { let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64) { - println!( - "update_cumulative_rewards cumulative idx: {} amount: {}", - idx, - cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default() - ); } else { let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); @@ -845,16 +807,6 @@ impl Pallet { let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) .checked_div(U256::from(total_activated_liquidity)) .unwrap_or_default(); - println!( - "update_cumulative_rewards cumulative + pending idx: {} RAW amount: {}", - idx, - cumulative + pending - ); - println!( - "update_cumulative_rewards cumulative + pending idx: {} amount: {}", - idx, - (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default() - ); ScheduleRewardsPerLiquidity::::insert( (liquidity_asset_id, liquidity_assets_reward), (cumulative + pending, (Self::session_index() as u64)), @@ -870,15 +822,6 @@ impl Pallet { let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64) { - println!( - "total_rewards_for_liquidity cumulative idx: {} RAW amount: {}", - idx, cumulative - ); - println!( - "total_rewards_for_liquidity cumulative idx: {} amount: {}", - idx, - cumulative.checked_div(U256::from(u128::MAX)).unwrap_or_default() - ); cumulative } else { let total_activated_liquidity = @@ -888,11 +831,6 @@ impl Pallet { let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) .checked_div(U256::from(total_activated_liquidity)) .unwrap_or_default(); - println!( - "total_rewards_for_liquidity cumulative + pending idx: {} amount: {}", - idx, - (cumulative + pending).checked_div(U256::from(u128::MAX)).unwrap_or_default() - ); cumulative + pending } } @@ -907,14 +845,8 @@ impl Pallet { liquidity_assets_reward, ); if idx == (Self::session_index() as u64) { - println!("total_activated_liquidity cumulative idx: {} amount: {}", idx, cumulative); cumulative } else { - println!( - "total_activated_liquidity cumulative + pending idx: {} amount: {}", - idx, - cumulative + pending_positive - pending_negative - ); cumulative + pending_positive - pending_negative } } @@ -926,14 +858,8 @@ impl Pallet { let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Self::session_index() as u64) { - println!("total_schedule_rewards cumulative idx: {} amount: {}", idx, cumulative); cumulative } else { - println!( - "total_schedule_rewards cumulative + pending idx: {} amount: {}", - idx, - cumulative + pending - ); cumulative + pending } } @@ -947,13 +873,6 @@ impl Pallet { // TODO: make configurable let session_id = Self::session_index() as u64; - println!( - "update_total_activated_liqudity BEFORE {:?}", - TotalActivatedLiquidityForSchedules::::get( - liquidity_asset_id, - liquidity_assets_reward - ) - ); TotalActivatedLiquidityForSchedules::::mutate( liquidity_asset_id, liquidity_assets_reward, @@ -965,7 +884,6 @@ impl Pallet { *pending_negative += diff; }; } else { - println!("update_total_activated_liqudity SWITCH {}", diff); // NOTE: handle burn so negative diff *cumulative = *cumulative + *pending_positive - *pending_negative; if change { @@ -979,26 +897,6 @@ impl Pallet { } }, ); - println!( - "update_total_activated_liqudity AFTER {:?}", - TotalActivatedLiquidityForSchedules::::get( - liquidity_asset_id, - liquidity_assets_reward - ) - ); - - // println!("UPDATE_TOTAL_ACTIVATED_LIQUDITY liq: {} reward:{} amount:{}", liquidity_asset_id, liquidity_assets_reward, diff); - // if let Ok((idx, amount)) = TotalActivatedLiquidityForSchedules::::try_get(liquidity_asset_id, liquidity_assets_reward){ - // - // if session_id > idx { - // PrevTotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |val| *val += amount); - // TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, 0)); - // }else{ - // TotalActivatedLiquidityForSchedules::::mutate(liquidity_asset_id, liquidity_assets_reward, |(session_id, new_amount)| amount += kkj); - // } - // }else{ - // TotalActivatedLiquidityForSchedules::::insert(liquidity_asset_id, liquidity_assets_reward, (session_id, new_amount)); - // } } fn activate_liquidity_for_native_rewards_impl( @@ -1352,16 +1250,6 @@ impl Pallet { true, ); - // TotalActivatedLiquidityForSchedules::::mutate( - // liquidity_asset_id, - // liquidity_assets_reward, - // |amount| -> DispatchResult { - // *amount = - // amount.checked_add(liquidity_assets_added).ok_or(Error::::MathOverflow)?; - // Ok(()) - // }, - // )?; - Ok(()) } @@ -1438,15 +1326,6 @@ impl Pallet { liquidity_assets_burned, false, ); - // TotalActivatedLiquidityForSchedules::::try_mutate( - // liquidity_asset_id, - // reward_token, - // |amount| -> DispatchResult { - // *amount = - // amount.checked_sub(liquidity_assets_burned).ok_or(Error::::MathOverflow)?; - // Ok(()) - // }, - // )?; ActivatedLiquidityForSchedules::::try_mutate_exists( (user.clone(), liquidity_asset_id, reward_token), @@ -1630,7 +1509,6 @@ impl ProofOfStakeRewardsApi for Pallet { ) { let liquidity_token_id = ::ValuationApi::get_liquidity_asset(pool.0, pool.1).expect("pool exist"); - log!(info, "XXXX {}", liquidity_token_id); Pallet::::reward_pool_impl( account.clone(), pool, @@ -1743,45 +1621,6 @@ impl ProofOfStakeRewardsApi for Pallet { impl LiquidityMiningApi for Pallet { /// Distributs liquidity mining rewards between all the activated tokens based on their weight fn distribute_rewards(liquidity_mining_rewards: Balance) { - // R:1 W:0 - // let schedules = RewardsSchedules::::get(); - // - // // R:1 W:0 - // let mut pools = ScheduleRewardsPerSingleLiquidity::::get(); - // - // let it = - // schedules - // .iter() - // .filter_map(|((session, rewarded_token, tokenid, amount, _), ())| { - // if (*session).saturated_into::() >= Self::session_index() { - // Some((rewarded_token, tokenid, amount)) - // } else { - // None - // } - // }); - // - // for (staked_token, rewarded_token, amount) in it { - // // R: T::RewardsSchedulesLimit - in most pesimistic case - // match TotalActivatedLiquidityForSchedules::::get(staked_token, rewarded_token) { - // 0 => {}, - // activated_amount => { - // let activated_amount = U256::from(activated_amount); - // let rewards = - // pools.get(&(*staked_token, *rewarded_token)).cloned().unwrap_or_default(); - // let rewards_for_liquidity = U256::from(*amount) - // .checked_mul(U256::from(u128::MAX)) - // .and_then(|x| x.checked_div(activated_amount)) - // .and_then(|x| x.checked_add(rewards)); - // - // if let Some(val) = rewards_for_liquidity { - // pools.insert((*staked_token, *rewarded_token), val); - // } - // }, - // } - // } - // - // ScheduleRewardsPerSingleLiquidity::::put(pools); - // let _ = PromotedPoolRewards::::try_mutate(|promoted_pools| -> DispatchResult { // benchmark with max of X prom pools let activated_pools: Vec<_> = promoted_pools @@ -1826,5 +1665,3 @@ impl LiquidityMiningApi for Pallet { }); } } - -// test for calculate_3rdparty_rewards_all diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 1000a312ae..2b63cdcd64 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -2117,7 +2117,6 @@ fn user_can_claim_3rdparty_rewards() { ); roll_to_session(2); - println!("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, @@ -2140,7 +2139,6 @@ fn user_can_claim_3rdparty_rewards() { ); roll_to_session(3); - println!("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB"); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) @@ -2225,7 +2223,6 @@ fn overlapping_3rdparty_rewards_works() { Ok(10000) ); - println!("############################## ##############################"); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( BOB, @@ -3016,7 +3013,6 @@ fn can_claim_schedule_rewards() { ) .unwrap(); - println!(">>>>>>>>>>>>>>>>>>>>>> ACTIVATE"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3025,7 +3021,6 @@ fn can_claim_schedule_rewards() { None, ) .unwrap(); - println!(">>>>>>>>>>>>>>>>>>>>>> ACTIVATE"); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, From 4defde868748920496bab69cfe5164a92df5ae17 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 26 Oct 2023 09:35:41 +0000 Subject: [PATCH 54/83] annotate storage reads & writes --- pallets/proof-of-stake/src/lib.rs | 38 +++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 2239393e01..b2f83d986a 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -191,20 +191,35 @@ pub mod pallet { fn on_initialize(n: T::BlockNumber) -> Weight { let session_id = Self::session_index() as u64; - if frame_system::Pallet::::block_number().saturated_into::() % - T::RewardsDistributionPeriod::get() == - 0u32 - { + // NOTE: 1R + if n.saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 { ScheduleListPos::::kill(); return Default::default() } - const AMOUNT_PER_BLOCK: u64 = 5; - // NOTE: 3R + 1R - // TODO: make configurable for idx in 0..AMOUNT_PER_BLOCK { + // READS PER ITERTION + // + // ON VALID SCHEDULE (AVERAGE) ====> 3R + 1 W + N*R + N*W + // 3 x READ HEAD,TAIL,POS : ALWAYS + // 1 x WRITE ScheduleListPos : ALWAYS (pesimistic) + // PER ITER: + // - READ RewardsSchedulesList : ALWAYS + // - WRITE ScheduleRewardsTotal : ALWAYS (pesemisitic) + + // ON OUTDATED SCHEDULE (PESIMITIC) =====> 3R + 1W + (N-1)*W + 2W + // 3 x READ HEAD,TAIL,POS : ALWAYS + // 1 x WRITE ScheduleListPos `next` : ONCE (pesemisitic) + // REMOVE N-1 SCHEDULES IN THE MIDDDLE + // - 1 x WRITE update previous schedudle `next` : ALWAYS (pesemisitic) + // REMOVE LAST ELEM: + // - 1 x WRITE update list tail + // - 1 x WRITE update elem before last : ALWAYS (pesemisitic) + + // NOTE: 1R let last_valid = ScheduleListPos::::get(); + // NOTE: 1R let pos = match (last_valid, ScheduleListHead::::get()) { (Some(pos), _) => { if let Some((schedule, next)) = RewardsSchedulesList::::get(pos) { @@ -218,9 +233,11 @@ pub mod pallet { }; if let Some(pos_val) = pos { + // NOTE: 1R if let Some((schedule, next)) = RewardsSchedulesList::::get(pos_val) { if schedule.last_session >= session_id { if schedule.scheduled_at < session_id { + // NOTE: 1R 1W ScheduleRewardsTotal::::mutate( (schedule.liq_token, schedule.reward_token), |(pending, idx, cumulative)| { @@ -234,21 +251,27 @@ pub mod pallet { }, ); } + // NOTE: 1W ScheduleListPos::::put(pos_val); } else { + // NOTE: 2R match (Self::head(), Self::tail()) { (Some(head), Some(tail)) if head == pos_val && head != tail => if let Some(next) = next { + // NOTE: 1W ScheduleListHead::::put(next); }, (Some(head), Some(tail)) if tail == pos_val && head == tail => { + // NOTE: 3W ScheduleListTail::::kill(); ScheduleListHead::::kill(); ScheduleListPos::::kill(); }, (Some(head), Some(tail)) if tail == pos_val && head != tail => if let Some(last_valid) = last_valid { + // NOTE: 1W ScheduleListTail::::put(last_valid); + // NOTE: 1R 1W RewardsSchedulesList::::mutate(last_valid, |data| { if let Some((schedule, next)) = data.as_mut() { *next = None @@ -257,6 +280,7 @@ pub mod pallet { }, (Some(head), Some(tail)) => if let Some(last_valid) = last_valid { + // NOTE: 1R 1W RewardsSchedulesList::::mutate(last_valid, |data| { if let Some((schedule, prev_next)) = data.as_mut() { *prev_next = next From 41d198a95d3b8f446ce8bd62056b4b2d3dace8c0 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Fri, 27 Oct 2023 09:51:16 +0000 Subject: [PATCH 55/83] remove unused param --- pallets/proof-of-stake/src/tests.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 2b63cdcd64..00adf2d878 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1067,7 +1067,7 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { }); } -pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option) { +pub(crate) fn roll_to_while_minting(n: u64) { let mut session_number: u32; let mut session_issuance: (Balance, Balance); let mut block_issuance: Balance; @@ -1081,10 +1081,6 @@ pub(crate) fn roll_to_while_minting(n: u64, expected_amount_minted: Option()); - if let Some(x) = expected_amount_minted { - assert_eq!(x, block_issuance); - } - // Compute issuance for the next session only after all issuance has been issued is current session // To avoid overestimating the missing issuance and overshooting the cap if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { @@ -1122,12 +1118,12 @@ fn test_migrated_from_pallet_issuance() { ) .unwrap(); - roll_to_while_minting(4, None); + roll_to_while_minting(4); assert_eq!( U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); - roll_to_while_minting(9, None); + roll_to_while_minting(9); assert_eq!( U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() @@ -1142,7 +1138,7 @@ fn test_migrated_from_pallet_issuance() { None, ) .unwrap(); - roll_to_while_minting(14, None); + roll_to_while_minting(14); assert_eq!( U256::from_dec_str("191427546923208537313638702283778366195067525").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() @@ -1152,7 +1148,7 @@ fn test_migrated_from_pallet_issuance() { ProofOfStake::get_pool_rewards(2).unwrap() ); - roll_to_while_minting(19, None); + roll_to_while_minting(19); assert_eq!( U256::from_dec_str("229713056307850244776366442740534039434081030").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() From 29e305aab9e816b337df3c1513913c1362396fbf Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sat, 28 Oct 2023 15:19:04 +0000 Subject: [PATCH 56/83] align issuance & pos rewards period --- pallets/proof-of-stake/src/lib.rs | 15 +-- pallets/proof-of-stake/src/mock.rs | 2 +- pallets/proof-of-stake/src/tests.rs | 142 ++++++++++++++++++---------- 3 files changed, 104 insertions(+), 55 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index b2f83d986a..831b74b6c1 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -192,10 +192,11 @@ pub mod pallet { let session_id = Self::session_index() as u64; // NOTE: 1R - if n.saturated_into::() % T::RewardsDistributionPeriod::get() == 0u32 { + if Self::is_new_session() { ScheduleListPos::::kill(); return Default::default() } + const AMOUNT_PER_BLOCK: u64 = 5; for idx in 0..AMOUNT_PER_BLOCK { @@ -1156,14 +1157,16 @@ impl Pallet { } pub fn session_index() -> u32 { - frame_system::Pallet::::block_number() - .saturated_into::() - .checked_div(T::RewardsDistributionPeriod::get()) - .unwrap_or(0) + Self::get_current_rewards_time().unwrap_or_default() } pub fn rewards_period() -> u32 { - ::RewardsDistributionPeriod::get() + T::RewardsDistributionPeriod::get() + } + + pub fn is_new_session() -> bool { + let block_nr = frame_system::Pallet::::block_number().saturated_into::(); + (block_nr + 1) % Self::rewards_period() == 0u32 } fn native_token_id() -> TokenId { diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index ebaddba9d0..877f0af460 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -170,7 +170,7 @@ parameter_types! { pub const ImmediateTGEReleasePercent: Percent = Percent::from_percent(20); pub const TGEReleasePeriod: u32 = 100u32; // 2 years pub const TGEReleaseBegin: u32 = 10u32; // Two weeks into chain start - pub const BlocksPerRound: u32 = 5u32; + pub const BlocksPerRound: u32 = 10u32; pub const HistoryLimit: u32 = 10u32; } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 00adf2d878..4616176584 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -43,13 +43,33 @@ fn initialize_liquidity_rewards() { .unwrap(); } -pub(crate) fn roll_to_session(n: u32) { - let block = n * Pallet::::rewards_period(); +fn process_all_schedules_in_current_session() { + let session = ProofOfStake::session_index(); + loop { + if ProofOfStake::session_index() > session { + panic!("couldnt process all schedules within the session"); + } + + if !ProofOfStake::is_new_session() && ProofOfStake::pos() == ProofOfStake::tail() { + break + } + roll_to_next_block(); + } +} + +fn roll_to_next_block() { + forward_to_block((System::block_number() + 1).saturated_into::()); +} + +fn roll_to_next_session() { + let current_session = ProofOfStake::session_index(); + roll_to_session(current_session + 1); +} - if block < System::block_number().saturated_into::() { - panic!("cannot roll to past block"); +pub fn roll_to_session(n: u32) { + while ProofOfStake::session_index() < n { + roll_to_next_block(); } - forward_to_block(block); } fn forward_to_block(n: u32) { @@ -57,13 +77,60 @@ fn forward_to_block(n: u32) { } fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { - while System::block_number().saturated_into::() <= n { + while System::block_number().saturated_into::() < n { + System::set_block_number(System::block_number().saturated_into::() + 1); ProofOfStake::on_initialize(System::block_number().saturated_into::()); - if System::block_number().saturated_into::() % ProofOfStake::rewards_period() == 0 { + if ProofOfStake::is_new_session() { ProofOfStake::distribute_rewards(rewards); } ProofOfStake::on_finalize(n as u64); - System::set_block_number(System::block_number().saturated_into::() + 1); + } +} +// +// pub fn roll_to_while_minting(n: u64) { +// let mut session_number: u32; +// let mut session_issuance: (Balance, Balance); +// let mut block_issuance: Balance; +// while System::block_number() < n { +// System::on_finalize(System::block_number()); +// +// System::set_block_number(System::block_number() + 1); +// +// System::on_initialize(System::block_number()); +// session_number = ProofOfStake::session_index(); +// session_issuance = ::get_all_issuance(session_number) +// .expect("session issuance is always populated in advance"); +// block_issuance = (session_issuance.0 + session_issuance.1) / +// (BlocksPerRound::get().saturated_into::()); +// +// // Compute issuance for the next session only after all issuance has been issued is current session +// // To avoid overestimating the missing issuance and overshooting the cap +// if ProofOfStake::is_new_session() { +// ::compute_issuance(session_number + 1u32); +// } +// } +// } + +pub(crate) fn roll_to_while_minting(n: u64) { + let mut session_number: u32; + let mut session_issuance: (Balance, Balance); + let mut block_issuance: Balance; + while System::block_number() < n { + System::on_finalize(System::block_number()); + System::set_block_number(System::block_number() + 1); + System::on_initialize(System::block_number()); + session_number = System::block_number().saturated_into::() / BlocksPerRound::get(); + session_issuance = ::get_all_issuance(session_number) + .expect("session issuance is always populated in advance"); + block_issuance = (session_issuance.0 + session_issuance.1) / (BlocksPerRound::get().saturated_into::()); + + // Compute issuance for the next session only after all issuance has been issued is current session + // To avoid overestimating the missing issuance and overshooting the cap + // if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { + // if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { + if ProofOfStake::is_new_session(){ + ::compute_issuance(session_number + 1u32); + } } } @@ -630,7 +697,7 @@ fn rewards_rounding_during_often_mint() { let mut higher_rewards_cumulative = 0; for n in 1..10000 { System::set_block_number(n); - if (n + 1) % (ProofOfStake::rewards_period() as u64) == 0 { + if ProofOfStake::is_new_session() { ProofOfStake::distribute_rewards(10000); mint_and_activate_tokens( @@ -1067,28 +1134,6 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { }); } -pub(crate) fn roll_to_while_minting(n: u64) { - let mut session_number: u32; - let mut session_issuance: (Balance, Balance); - let mut block_issuance: Balance; - while System::block_number() < n { - System::on_finalize(System::block_number()); - System::set_block_number(System::block_number() + 1); - System::on_initialize(System::block_number()); - session_number = System::block_number().saturated_into::() / BlocksPerRound::get(); - session_issuance = ::get_all_issuance(session_number) - .expect("session issuance is always populated in advance"); - block_issuance = (session_issuance.0 + session_issuance.1) / - (BlocksPerRound::get().saturated_into::()); - - // Compute issuance for the next session only after all issuance has been issued is current session - // To avoid overestimating the missing issuance and overshooting the cap - if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { - ::compute_issuance(session_number + 1u32); - } - } -} - #[test] fn test_migrated_from_pallet_issuance() { new_test_ext().execute_with(|| { @@ -1118,14 +1163,14 @@ fn test_migrated_from_pallet_issuance() { ) .unwrap(); - roll_to_while_minting(4); + roll_to_while_minting(9); assert_eq!( - U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), + U256::from_dec_str("153142377820933750789374425201630124724265475").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); - roll_to_while_minting(9); + roll_to_while_minting(19); assert_eq!( - U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), + U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); @@ -1138,23 +1183,23 @@ fn test_migrated_from_pallet_issuance() { None, ) .unwrap(); - roll_to_while_minting(14); + roll_to_while_minting(29); assert_eq!( - U256::from_dec_str("191427546923208537313638702283778366195067525").unwrap(), + U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); assert_eq!( - U256::from_dec_str("38285509384641707462727740456755673239013505").unwrap(), + U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), ProofOfStake::get_pool_rewards(2).unwrap() ); - - roll_to_while_minting(19); + // + roll_to_while_minting(39); assert_eq!( - U256::from_dec_str("229713056307850244776366442740534039434081030").unwrap(), + U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); assert_eq!( - U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), + U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), ProofOfStake::get_pool_rewards(2).unwrap() ); }); @@ -1531,11 +1576,11 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(30); + forward_to_block(29); assert_eq!(ScheduleListHead::::get(), Some(1u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); - forward_to_block(31); + forward_to_block(30); assert_eq!(ScheduleListHead::::get(), None); assert_eq!(ScheduleListTail::::get(), None); assert_eq!(ScheduleListPos::::get(), None); @@ -1691,7 +1736,7 @@ fn remove_first_few_elems_at_once_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block(20); assert_eq!(ScheduleListHead::::get(), Some(2u64)); assert_eq!(ScheduleListTail::::get(), Some(3u64)); @@ -1833,8 +1878,8 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(6u64)); - forward_to_block(24); - + roll_to_session(2); + process_all_schedules_in_current_session(); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(6u64)); assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(1u64)); @@ -1843,7 +1888,8 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!(RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); assert_eq!(RewardsSchedulesList::::get(6u64).unwrap().1, None); - forward_to_block(40); + roll_to_session(3); + process_all_schedules_in_current_session(); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(6u64)); From 35983739cbd20335988edb88cef440e81597b2f9 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Sun, 29 Oct 2023 20:10:52 +0000 Subject: [PATCH 57/83] wip does not work --- pallets/proof-of-stake/src/tests.rs | 110 ++++++++++++---------------- 1 file changed, 48 insertions(+), 62 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 4616176584..a2ca124d5e 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -77,39 +77,25 @@ fn forward_to_block(n: u32) { } fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { + while System::block_number().saturated_into::() < n { - System::set_block_number(System::block_number().saturated_into::() + 1); - ProofOfStake::on_initialize(System::block_number().saturated_into::()); + + let new_block_number = System::block_number().saturated_into::() + 1; + System::set_block_number(new_block_number); + + System::on_initialize(new_block_number); + ProofOfStake::on_initialize(new_block_number); + if ProofOfStake::is_new_session() { ProofOfStake::distribute_rewards(rewards); + ::compute_issuance(ProofOfStake::session_index() + 1); } - ProofOfStake::on_finalize(n as u64); + + ProofOfStake::on_finalize(new_block_number); + System::on_finalize(new_block_number); } } -// -// pub fn roll_to_while_minting(n: u64) { -// let mut session_number: u32; -// let mut session_issuance: (Balance, Balance); -// let mut block_issuance: Balance; -// while System::block_number() < n { -// System::on_finalize(System::block_number()); -// -// System::set_block_number(System::block_number() + 1); -// -// System::on_initialize(System::block_number()); -// session_number = ProofOfStake::session_index(); -// session_issuance = ::get_all_issuance(session_number) -// .expect("session issuance is always populated in advance"); -// block_issuance = (session_issuance.0 + session_issuance.1) / -// (BlocksPerRound::get().saturated_into::()); -// -// // Compute issuance for the next session only after all issuance has been issued is current session -// // To avoid overestimating the missing issuance and overshooting the cap -// if ProofOfStake::is_new_session() { -// ::compute_issuance(session_number + 1u32); -// } -// } -// } + pub(crate) fn roll_to_while_minting(n: u64) { let mut session_number: u32; @@ -122,7 +108,7 @@ pub(crate) fn roll_to_while_minting(n: u64) { session_number = System::block_number().saturated_into::() / BlocksPerRound::get(); session_issuance = ::get_all_issuance(session_number) .expect("session issuance is always populated in advance"); - block_issuance = (session_issuance.0 + session_issuance.1) / (BlocksPerRound::get().saturated_into::()); + block_issuance = (session_issuance.0 + session_issuance.1) / ProofOfStake::rewards_period() as u128; // Compute issuance for the next session only after all issuance has been issued is current session // To avoid overestimating the missing issuance and overshooting the cap @@ -1163,45 +1149,45 @@ fn test_migrated_from_pallet_issuance() { ) .unwrap(); - roll_to_while_minting(9); + forward_to_block(9); assert_eq!( U256::from_dec_str("153142377820933750789374425201630124724265475").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); - roll_to_while_minting(19); - assert_eq!( - U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), - ProofOfStake::get_pool_rewards(1).unwrap() - ); - - assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); - ProofOfStake::enable(2, 1u8); - ProofOfStake::activate_liquidity_for_native_rewards( - RuntimeOrigin::signed(99999), - 2, - 1, - None, - ) - .unwrap(); - roll_to_while_minting(29); - assert_eq!( - U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), - ProofOfStake::get_pool_rewards(1).unwrap() - ); - assert_eq!( - U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), - ProofOfStake::get_pool_rewards(2).unwrap() - ); + // roll_to_while_minting(19); + // assert_eq!( + // U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), + // ProofOfStake::get_pool_rewards(1).unwrap() + // ); // - roll_to_while_minting(39); - assert_eq!( - U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), - ProofOfStake::get_pool_rewards(1).unwrap() - ); - assert_eq!( - U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), - ProofOfStake::get_pool_rewards(2).unwrap() - ); + // assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); + // ProofOfStake::enable(2, 1u8); + // ProofOfStake::activate_liquidity_for_native_rewards( + // RuntimeOrigin::signed(99999), + // 2, + // 1, + // None, + // ) + // .unwrap(); + // roll_to_while_minting(29); + // assert_eq!( + // U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), + // ProofOfStake::get_pool_rewards(1).unwrap() + // ); + // assert_eq!( + // U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), + // ProofOfStake::get_pool_rewards(2).unwrap() + // ); + // // + // roll_to_while_minting(39); + // assert_eq!( + // U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), + // ProofOfStake::get_pool_rewards(1).unwrap() + // ); + // assert_eq!( + // U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), + // ProofOfStake::get_pool_rewards(2).unwrap() + // ); }); } From 776e60ac2c9a21860f735241133d3cc0d1dbbd86 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 07:02:25 +0100 Subject: [PATCH 58/83] removed custom block progression method --- pallets/proof-of-stake/src/tests.rs | 95 +++++++++++------------------ 1 file changed, 36 insertions(+), 59 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index a2ca124d5e..9479d9f1b0 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -88,7 +88,6 @@ fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { if ProofOfStake::is_new_session() { ProofOfStake::distribute_rewards(rewards); - ::compute_issuance(ProofOfStake::session_index() + 1); } ProofOfStake::on_finalize(new_block_number); @@ -97,29 +96,6 @@ fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { } -pub(crate) fn roll_to_while_minting(n: u64) { - let mut session_number: u32; - let mut session_issuance: (Balance, Balance); - let mut block_issuance: Balance; - while System::block_number() < n { - System::on_finalize(System::block_number()); - System::set_block_number(System::block_number() + 1); - System::on_initialize(System::block_number()); - session_number = System::block_number().saturated_into::() / BlocksPerRound::get(); - session_issuance = ::get_all_issuance(session_number) - .expect("session issuance is always populated in advance"); - block_issuance = (session_issuance.0 + session_issuance.1) / ProofOfStake::rewards_period() as u128; - - // Compute issuance for the next session only after all issuance has been issued is current session - // To avoid overestimating the missing issuance and overshooting the cap - // if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { - // if ((System::block_number().saturated_into::() + 1u32) % BlocksPerRound::get()) == 0 { - if ProofOfStake::is_new_session(){ - ::compute_issuance(session_number + 1u32); - } - } -} - #[test] fn liquidity_rewards_single_user_mint_W() { new_test_ext().execute_with(|| { @@ -1125,6 +1101,7 @@ fn test_migrated_from_pallet_issuance() { new_test_ext().execute_with(|| { env_logger::try_init(); System::set_block_number(1); + const LIQUIDITY_ISSUANCE: Balance = 450045; let token_id = TokensOf::::create(&99999, 2000_000_000).unwrap(); assert_eq!(token_id, 0); @@ -1149,45 +1126,45 @@ fn test_migrated_from_pallet_issuance() { ) .unwrap(); - forward_to_block(9); + forward_to_block_with_custom_rewards(9, LIQUIDITY_ISSUANCE); assert_eq!( U256::from_dec_str("153142377820933750789374425201630124724265475").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); - // roll_to_while_minting(19); - // assert_eq!( - // U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), - // ProofOfStake::get_pool_rewards(1).unwrap() - // ); - // - // assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); - // ProofOfStake::enable(2, 1u8); - // ProofOfStake::activate_liquidity_for_native_rewards( - // RuntimeOrigin::signed(99999), - // 2, - // 1, - // None, - // ) - // .unwrap(); - // roll_to_while_minting(29); - // assert_eq!( - // U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), - // ProofOfStake::get_pool_rewards(1).unwrap() - // ); - // assert_eq!( - // U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), - // ProofOfStake::get_pool_rewards(2).unwrap() - // ); - // // - // roll_to_while_minting(39); - // assert_eq!( - // U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), - // ProofOfStake::get_pool_rewards(1).unwrap() - // ); - // assert_eq!( - // U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), - // ProofOfStake::get_pool_rewards(2).unwrap() - // ); + forward_to_block_with_custom_rewards(19, LIQUIDITY_ISSUANCE); + assert_eq!( + U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), + ProofOfStake::get_pool_rewards(1).unwrap() + ); + + assert_eq!(2, TokensOf::::create(&99999, 1_000_000u128).unwrap()); + ProofOfStake::enable(2, 1u8); + ProofOfStake::activate_liquidity_for_native_rewards( + RuntimeOrigin::signed(99999), + 2, + 1, + None, + ) + .unwrap(); + forward_to_block_with_custom_rewards(29, LIQUIDITY_ISSUANCE); + assert_eq!( + U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), + ProofOfStake::get_pool_rewards(1).unwrap() + ); + assert_eq!( + U256::from_dec_str("76571018769283414925455480913511346478027010").unwrap(), + ProofOfStake::get_pool_rewards(2).unwrap() + ); + + forward_to_block_with_custom_rewards(39, LIQUIDITY_ISSUANCE); + assert_eq!( + U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), + ProofOfStake::get_pool_rewards(1).unwrap() + ); + assert_eq!( + U256::from_dec_str("153142037538566829850910961827022692956054020").unwrap(), + ProofOfStake::get_pool_rewards(2).unwrap() + ); }); } From 50f5e34a769804cf699b1ca3c75e5bda2d9a723f Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 08:16:41 +0100 Subject: [PATCH 59/83] add test for preventing activation on unpromoted pool --- pallets/proof-of-stake/src/tests.rs | 63 +++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 9479d9f1b0..9db8e83b4a 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -4064,3 +4064,66 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu ); }); } + + +#[test] +#[serial] +fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_for_the_first_time() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .build() + .execute_with(|| { + System::set_block_number(1); + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + + assert_err_ignore_postinfo!( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ), + Error::::NotAPromotedPool + ); + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 2u8).unwrap(); + + assert_err_ignore_postinfo!( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ), + Error::::NotAPromotedPool + ); + + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT / 2, + 10u32.into(), + ) + .unwrap(); + + + assert_ok!( + ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + ) + ); + + }); +} From 8ce3cb122f366c763e59d7a6888ac336c29419cc Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 08:17:03 +0100 Subject: [PATCH 60/83] move cumulative distributed calculations to dedicated class --- pallets/fee-lock/src/mock.rs | 2 +- pallets/proof-of-stake/src/lib.rs | 143 +++--------------- pallets/proof-of-stake/src/reward_info.rs | 3 +- .../src/schedule_rewards_calculator.rs | 128 ++++++++++++++++ 4 files changed, 149 insertions(+), 127 deletions(-) create mode 100644 pallets/proof-of-stake/src/schedule_rewards_calculator.rs diff --git a/pallets/fee-lock/src/mock.rs b/pallets/fee-lock/src/mock.rs index 0e3dbab812..40052e6332 100644 --- a/pallets/fee-lock/src/mock.rs +++ b/pallets/fee-lock/src/mock.rs @@ -14,8 +14,8 @@ use crate as pallet_fee_lock; use frame_support::{ construct_runtime, parameter_types, traits::{ConstU32, Contains, Everything}, - weights::{constants::RocksDbWeight, Weight}, PalletId, + weights::{constants::RocksDbWeight}, }; use frame_system as system; use mangata_types::Amount; diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 831b74b6c1..f29ab0b271 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -133,7 +133,11 @@ use sp_runtime::{traits::SaturatedConversion, Perbill}; use sp_std::{convert::TryInto, prelude::*}; mod reward_info; -use reward_info::{AsymptoticCurveRewards, ConstCurveRewards, RewardInfo, RewardsCalculator}; +use reward_info::{RewardInfo, RewardsCalculator}; + +mod schedule_rewards_calculator; +use schedule_rewards_calculator::ScheduleRewardsCalculator; + mod benchmarking; #[cfg(test)] @@ -178,7 +182,6 @@ const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!") #[frame_support::pallet] pub mod pallet { use frame_support::traits::Currency; - use mangata_support::traits::PoolCreateApi; use super::*; @@ -186,9 +189,10 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(PhantomData); + #[pallet::hooks] impl Hooks for Pallet { - fn on_initialize(n: T::BlockNumber) -> Weight { + fn on_initialize(_n: T::BlockNumber) -> Weight { let session_id = Self::session_index() as u64; // NOTE: 1R @@ -199,7 +203,7 @@ pub mod pallet { const AMOUNT_PER_BLOCK: u64 = 5; - for idx in 0..AMOUNT_PER_BLOCK { + for _ in 0..AMOUNT_PER_BLOCK { // READS PER ITERTION // // ON VALID SCHEDULE (AVERAGE) ====> 3R + 1 W + N*R + N*W @@ -223,7 +227,7 @@ pub mod pallet { // NOTE: 1R let pos = match (last_valid, ScheduleListHead::::get()) { (Some(pos), _) => { - if let Some((schedule, next)) = RewardsSchedulesList::::get(pos) { + if let Some((_schedule, next)) = RewardsSchedulesList::::get(pos) { next } else { None @@ -274,16 +278,16 @@ pub mod pallet { ScheduleListTail::::put(last_valid); // NOTE: 1R 1W RewardsSchedulesList::::mutate(last_valid, |data| { - if let Some((schedule, next)) = data.as_mut() { + if let Some((_schedule, next)) = data.as_mut() { *next = None } }); }, - (Some(head), Some(tail)) => + (Some(_head), Some(_tail)) => if let Some(last_valid) = last_valid { // NOTE: 1R 1W RewardsSchedulesList::::mutate(last_valid, |data| { - if let Some((schedule, prev_next)) = data.as_mut() { + if let Some((_schedule, prev_next)) = data.as_mut() { *prev_next = next } }); @@ -466,6 +470,7 @@ pub mod pallet { pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; + #[pallet::storage] pub type ScheduleRewardsPerLiquidity = StorageMap<_, Twox64Concat, (TokenId, TokenId), (U256, u64), ValueQuery>; @@ -646,7 +651,6 @@ pub mod pallet { /// - amount - amount of the token /// - schedule_end - id of the last rewarded seession. Rewards will be distributedd equally between sessions in range (now .. /// schedule_end). Distribution starts from the *next* session till `schedule_end`. - // TODO: delays schedule by 1 session #[transactional] #[pallet::call_index(4)] #[pallet::weight(<::WeightInfo>::reward_pool())] @@ -748,7 +752,7 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - Self::update_cumulative_rewards(liquidity_token_id, reward_token); + ScheduleRewardsCalculator::::update_cumulative_rewards(liquidity_token_id, reward_token); Self::claim_schedule_rewards_all_impl(sender, liquidity_token_id, reward_token)?; Ok(()) } @@ -813,116 +817,6 @@ pub mod pallet { } impl Pallet { - fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) { - let (cumulative, idx) = - ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64) { - } else { - let total_activated_liquidity = - Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = - Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); - if total_activated_liquidity > 0 { - ScheduleRewardsTotal::::mutate( - (liquidity_asset_id, liquidity_assets_reward), - |(cumulative, _, _)| { - *cumulative = 0; - }, - ); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) - .checked_div(U256::from(total_activated_liquidity)) - .unwrap_or_default(); - ScheduleRewardsPerLiquidity::::insert( - (liquidity_asset_id, liquidity_assets_reward), - (cumulative + pending, (Self::session_index() as u64)), - ); - } - } - } - - fn total_rewards_for_liquidity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> U256 { - let (cumulative, idx) = - ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64) { - cumulative - } else { - let total_activated_liquidity = - Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = - Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) - .checked_div(U256::from(total_activated_liquidity)) - .unwrap_or_default(); - cumulative + pending - } - } - - fn total_activated_liquidity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> Balance { - let (pending_negative, pending_positive, idx, cumulative) = - TotalActivatedLiquidityForSchedules::::get( - liquidity_asset_id, - liquidity_assets_reward, - ); - if idx == (Self::session_index() as u64) { - cumulative - } else { - cumulative + pending_positive - pending_negative - } - } - - fn total_schedule_rewards( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> Balance { - let (pending, idx, cumulative) = - ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Self::session_index() as u64) { - cumulative - } else { - cumulative + pending - } - } - - fn update_total_activated_liqudity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - diff: Balance, - change: bool, - ) { - // TODO: make configurable - let session_id = Self::session_index() as u64; - - TotalActivatedLiquidityForSchedules::::mutate( - liquidity_asset_id, - liquidity_assets_reward, - |(pending_negative, pending_positive, idx, cumulative)| { - if *idx == session_id { - if change { - *pending_positive += diff; - } else { - *pending_negative += diff; - }; - } else { - // NOTE: handle burn so negative diff - *cumulative = *cumulative + *pending_positive - *pending_negative; - if change { - *pending_positive = diff; - *pending_negative = 0u128; - } else { - *pending_positive = 0u128; - *pending_negative = diff; - }; - *idx = session_id; - } - }, - ); - } fn activate_liquidity_for_native_rewards_impl( user: AccountIdOf, @@ -1189,7 +1083,6 @@ impl Pallet { } fn ensure_is_promoted_pool(liquidity_asset_id: TokenId) -> Result<(), DispatchError> { - //NOTE: 2 separate functions for separate rewards if Self::get_pool_rewards(liquidity_asset_id).is_ok() || RewardTokensPerPool::::iter_prefix_values(liquidity_asset_id) .next() @@ -1238,7 +1131,7 @@ impl Pallet { ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - Self::update_cumulative_rewards(liquidity_asset_id, liquidity_assets_reward); + ScheduleRewardsCalculator::::update_cumulative_rewards(liquidity_asset_id, liquidity_assets_reward); { let calc = RewardsCalculator::schedule_rewards::( user.clone(), @@ -1270,7 +1163,7 @@ impl Pallet { }, )?; - Self::update_total_activated_liqudity( + ScheduleRewardsCalculator::::update_total_activated_liqudity( liquidity_asset_id, liquidity_assets_reward, liquidity_assets_added, @@ -1329,7 +1222,7 @@ impl Pallet { reward_token: TokenId, ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - Self::update_cumulative_rewards(liquidity_asset_id, reward_token); + ScheduleRewardsCalculator::::update_cumulative_rewards(liquidity_asset_id, reward_token); let calc = RewardsCalculator::schedule_rewards::( user.clone(), @@ -1347,7 +1240,7 @@ impl Pallet { rewards_info, ); - Self::update_total_activated_liqudity( + ScheduleRewardsCalculator::::update_total_activated_liqudity( liquidity_asset_id, reward_token, liquidity_assets_burned, diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index ece914f5a3..9c0b14f74c 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -1,6 +1,7 @@ use frame_support::dispatch::DispatchResult; use crate::{Config, Error, Pallet}; +use crate::schedule_rewards_calculator::ScheduleRewardsCalculator; use frame_support::pallet_prelude::*; use mangata_types::{Balance, TokenId}; use sp_core::U256; @@ -94,7 +95,7 @@ impl RewardsCalculator { // println!("total_rewards : {}", total_rewards); // let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); let pool_ratio_current = - Pallet::::total_rewards_for_liquidity(asset_id, reward_asset_id); + ScheduleRewardsCalculator::::total_rewards_for_liquidity(asset_id, reward_asset_id); println!("SCHEDULE REWARDS RATIO: {}", pool_ratio_current); let default_rewards = RewardInfo { diff --git a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs new file mode 100644 index 0000000000..fb9c5da382 --- /dev/null +++ b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs @@ -0,0 +1,128 @@ + +use core::marker::PhantomData; +use crate::Config; +use crate::Pallet; +use crate::ScheduleRewardsPerLiquidity; +use crate::TotalActivatedLiquidityForSchedules; +use crate::ScheduleRewardsTotal; +use mangata_types::{Balance, TokenId}; +use sp_core::U256; + + pub struct ScheduleRewardsCalculator { + data: PhantomData + } + + impl ScheduleRewardsCalculator { + + pub fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) { + let (cumulative, idx) = + ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Pallet::::session_index() as u64) { + } else { + let total_activated_liquidity = + Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = + Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + if total_activated_liquidity > 0 { + ScheduleRewardsTotal::::mutate( + (liquidity_asset_id, liquidity_assets_reward), + |(cumulative, _, _)| { + *cumulative = 0; + }, + ); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) + .checked_div(U256::from(total_activated_liquidity)) + .unwrap_or_default(); + ScheduleRewardsPerLiquidity::::insert( + + (liquidity_asset_id, liquidity_assets_reward), + (cumulative + pending, (Pallet::::session_index() as u64)), + ); + } + } + } + + pub fn total_rewards_for_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> U256 { + let (cumulative, idx) = + ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + let total_activated_liquidity = + Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = + Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) + .checked_div(U256::from(total_activated_liquidity)) + .unwrap_or_default(); + cumulative + pending + } + } + + pub fn total_activated_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending_negative, pending_positive, idx, cumulative) = + TotalActivatedLiquidityForSchedules::::get( + liquidity_asset_id, + liquidity_assets_reward, + ); + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + cumulative + pending_positive - pending_negative + } + } + + pub fn total_schedule_rewards( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending, idx, cumulative) = + ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + cumulative + pending + } + } + + pub fn update_total_activated_liqudity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + diff: Balance, + change: bool, + ) { + // TODO: make configurable + let session_id = Pallet::::session_index() as u64; + + TotalActivatedLiquidityForSchedules::::mutate( + liquidity_asset_id, + liquidity_assets_reward, + |(pending_negative, pending_positive, idx, cumulative)| { + if *idx == session_id { + if change { + *pending_positive += diff; + } else { + *pending_negative += diff; + }; + } else { + // NOTE: handle burn so negative diff + *cumulative = *cumulative + *pending_positive - *pending_negative; + if change { + *pending_positive = diff; + *pending_negative = 0u128; + } else { + *pending_positive = 0u128; + *pending_negative = diff; + }; + *idx = session_id; + } + }, + ); + } + } From d4a94cd302973b854ed8181e995db555a8fbbd49 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 09:07:26 +0100 Subject: [PATCH 61/83] refactor: create ScheduleRewardsCalculator --- pallets/fee-lock/src/mock.rs | 2 +- pallets/proof-of-stake/src/lib.rs | 13 +- pallets/proof-of-stake/src/reward_info.rs | 3 +- .../src/schedule_rewards_calculator.rs | 203 +++++++++--------- pallets/proof-of-stake/src/tests.rs | 26 +-- 5 files changed, 120 insertions(+), 127 deletions(-) diff --git a/pallets/fee-lock/src/mock.rs b/pallets/fee-lock/src/mock.rs index 40052e6332..aa39313d10 100644 --- a/pallets/fee-lock/src/mock.rs +++ b/pallets/fee-lock/src/mock.rs @@ -14,8 +14,8 @@ use crate as pallet_fee_lock; use frame_support::{ construct_runtime, parameter_types, traits::{ConstU32, Contains, Everything}, + weights::constants::RocksDbWeight, PalletId, - weights::{constants::RocksDbWeight}, }; use frame_system as system; use mangata_types::Amount; diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index f29ab0b271..131a771eb2 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -189,7 +189,6 @@ pub mod pallet { #[pallet::without_storage_info] pub struct Pallet(PhantomData); - #[pallet::hooks] impl Hooks for Pallet { fn on_initialize(_n: T::BlockNumber) -> Weight { @@ -470,7 +469,6 @@ pub mod pallet { pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; - #[pallet::storage] pub type ScheduleRewardsPerLiquidity = StorageMap<_, Twox64Concat, (TokenId, TokenId), (U256, u64), ValueQuery>; @@ -752,7 +750,10 @@ pub mod pallet { ) -> DispatchResult { let sender = ensure_signed(origin)?; - ScheduleRewardsCalculator::::update_cumulative_rewards(liquidity_token_id, reward_token); + ScheduleRewardsCalculator::::update_cumulative_rewards( + liquidity_token_id, + reward_token, + ); Self::claim_schedule_rewards_all_impl(sender, liquidity_token_id, reward_token)?; Ok(()) } @@ -817,7 +818,6 @@ pub mod pallet { } impl Pallet { - fn activate_liquidity_for_native_rewards_impl( user: AccountIdOf, liquidity_asset_id: TokenId, @@ -1131,7 +1131,10 @@ impl Pallet { ) -> DispatchResult { Self::ensure_is_promoted_pool(liquidity_asset_id)?; - ScheduleRewardsCalculator::::update_cumulative_rewards(liquidity_asset_id, liquidity_assets_reward); + ScheduleRewardsCalculator::::update_cumulative_rewards( + liquidity_asset_id, + liquidity_assets_reward, + ); { let calc = RewardsCalculator::schedule_rewards::( user.clone(), diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 9c0b14f74c..8abb74214d 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -1,7 +1,6 @@ use frame_support::dispatch::DispatchResult; -use crate::{Config, Error, Pallet}; -use crate::schedule_rewards_calculator::ScheduleRewardsCalculator; +use crate::{schedule_rewards_calculator::ScheduleRewardsCalculator, Config, Error, Pallet}; use frame_support::pallet_prelude::*; use mangata_types::{Balance, TokenId}; use sp_core::U256; diff --git a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs index fb9c5da382..55e2d9e72d 100644 --- a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs +++ b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs @@ -1,128 +1,127 @@ - +use crate::{ + Config, Pallet, ScheduleRewardsPerLiquidity, ScheduleRewardsTotal, + TotalActivatedLiquidityForSchedules, +}; use core::marker::PhantomData; -use crate::Config; -use crate::Pallet; -use crate::ScheduleRewardsPerLiquidity; -use crate::TotalActivatedLiquidityForSchedules; -use crate::ScheduleRewardsTotal; use mangata_types::{Balance, TokenId}; use sp_core::U256; - pub struct ScheduleRewardsCalculator { - data: PhantomData - } - - impl ScheduleRewardsCalculator { - - pub fn update_cumulative_rewards(liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId) { - let (cumulative, idx) = - ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Pallet::::session_index() as u64) { - } else { - let total_activated_liquidity = - Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = - Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); - if total_activated_liquidity > 0 { - ScheduleRewardsTotal::::mutate( - (liquidity_asset_id, liquidity_assets_reward), - |(cumulative, _, _)| { - *cumulative = 0; - }, - ); - let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) - .checked_div(U256::from(total_activated_liquidity)) - .unwrap_or_default(); - ScheduleRewardsPerLiquidity::::insert( +pub struct ScheduleRewardsCalculator { + data: PhantomData, +} - (liquidity_asset_id, liquidity_assets_reward), - (cumulative + pending, (Pallet::::session_index() as u64)), - ); - } - } - } - - pub fn total_rewards_for_liquidity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> U256 { - let (cumulative, idx) = +impl ScheduleRewardsCalculator { + pub fn update_cumulative_rewards( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) { + let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Pallet::::session_index() as u64) { - cumulative - } else { - let total_activated_liquidity = + if idx == (Pallet::::session_index() as u64) { + } else { + let total_activated_liquidity = Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); - let total_schedule_rewards = + let total_schedule_rewards = Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + if total_activated_liquidity > 0 { + ScheduleRewardsTotal::::mutate( + (liquidity_asset_id, liquidity_assets_reward), + |(cumulative, _, _)| { + *cumulative = 0; + }, + ); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) .checked_div(U256::from(total_activated_liquidity)) .unwrap_or_default(); - cumulative + pending + ScheduleRewardsPerLiquidity::::insert( + (liquidity_asset_id, liquidity_assets_reward), + (cumulative + pending, (Pallet::::session_index() as u64)), + ); } } + } - pub fn total_activated_liquidity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> Balance { - let (pending_negative, pending_positive, idx, cumulative) = + pub fn total_rewards_for_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> U256 { + let (cumulative, idx) = + ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + let total_activated_liquidity = + Self::total_activated_liquidity(liquidity_asset_id, liquidity_assets_reward); + let total_schedule_rewards = + Self::total_schedule_rewards(liquidity_asset_id, liquidity_assets_reward); + let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) + .checked_div(U256::from(total_activated_liquidity)) + .unwrap_or_default(); + cumulative + pending + } + } + + pub fn total_activated_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending_negative, pending_positive, idx, cumulative) = TotalActivatedLiquidityForSchedules::::get( liquidity_asset_id, liquidity_assets_reward, ); - if idx == (Pallet::::session_index() as u64) { - cumulative - } else { - cumulative + pending_positive - pending_negative - } + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + cumulative + pending_positive - pending_negative } + } - pub fn total_schedule_rewards( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> Balance { - let (pending, idx, cumulative) = + pub fn total_schedule_rewards( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let (pending, idx, cumulative) = ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Pallet::::session_index() as u64) { - cumulative - } else { - cumulative + pending - } + if idx == (Pallet::::session_index() as u64) { + cumulative + } else { + cumulative + pending } + } - pub fn update_total_activated_liqudity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - diff: Balance, - change: bool, - ) { - // TODO: make configurable - let session_id = Pallet::::session_index() as u64; + pub fn update_total_activated_liqudity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + diff: Balance, + change: bool, + ) { + // TODO: make configurable + let session_id = Pallet::::session_index() as u64; - TotalActivatedLiquidityForSchedules::::mutate( - liquidity_asset_id, - liquidity_assets_reward, - |(pending_negative, pending_positive, idx, cumulative)| { - if *idx == session_id { - if change { - *pending_positive += diff; - } else { - *pending_negative += diff; - }; + TotalActivatedLiquidityForSchedules::::mutate( + liquidity_asset_id, + liquidity_assets_reward, + |(pending_negative, pending_positive, idx, cumulative)| { + if *idx == session_id { + if change { + *pending_positive += diff; } else { - // NOTE: handle burn so negative diff - *cumulative = *cumulative + *pending_positive - *pending_negative; - if change { - *pending_positive = diff; - *pending_negative = 0u128; - } else { - *pending_positive = 0u128; - *pending_negative = diff; - }; - *idx = session_id; - } - }, - ); - } + *pending_negative += diff; + }; + } else { + // NOTE: handle burn so negative diff + *cumulative = *cumulative + *pending_positive - *pending_negative; + if change { + *pending_positive = diff; + *pending_negative = 0u128; + } else { + *pending_positive = 0u128; + *pending_negative = diff; + }; + *idx = session_id; + } + }, + ); } +} diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 9db8e83b4a..7bb711e02f 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -77,9 +77,7 @@ fn forward_to_block(n: u32) { } fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { - while System::block_number().saturated_into::() < n { - let new_block_number = System::block_number().saturated_into::() + 1; System::set_block_number(new_block_number); @@ -95,7 +93,6 @@ fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { } } - #[test] fn liquidity_rewards_single_user_mint_W() { new_test_ext().execute_with(|| { @@ -4065,7 +4062,6 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu }); } - #[test] #[serial] fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_for_the_first_time() { @@ -4091,7 +4087,8 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo Error::::NotAPromotedPool ); - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 2u8).unwrap(); + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 2u8) + .unwrap(); assert_err_ignore_postinfo!( ProofOfStake::activate_liquidity_for_3rdparty_rewards( @@ -4104,7 +4101,6 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo Error::::NotAPromotedPool ); - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -4114,16 +4110,12 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo ) .unwrap(); - - assert_ok!( - ProofOfStake::activate_liquidity_for_3rdparty_rewards( - RuntimeOrigin::signed(BOB), - LIQUIDITY_TOKEN, - 100, - REWARD_TOKEN, - None, - ) - ); - + assert_ok!(ProofOfStake::activate_liquidity_for_3rdparty_rewards( + RuntimeOrigin::signed(BOB), + LIQUIDITY_TOKEN, + 100, + REWARD_TOKEN, + None, + )); }); } From 868de07806ed4601a998e18a790865ece6a50149 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 10:27:43 +0100 Subject: [PATCH 62/83] refactor: extract ScheduleRewards struct --- pallets/proof-of-stake/src/lib.rs | 22 ++---- .../src/schedule_rewards_calculator.rs | 78 ++++++++++++++++--- 2 files changed, 72 insertions(+), 28 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 131a771eb2..ad2628f77b 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -136,7 +136,7 @@ mod reward_info; use reward_info::{RewardInfo, RewardsCalculator}; mod schedule_rewards_calculator; -use schedule_rewards_calculator::ScheduleRewardsCalculator; +use schedule_rewards_calculator::{ScheduleRewardsCalculator, ScheduleRewards}; mod benchmarking; @@ -178,6 +178,7 @@ pub enum ThirdPartyActivationKind { } const PALLET_ID: frame_support::PalletId = frame_support::PalletId(*b"rewards!"); +pub type SessionId = u64; #[frame_support::pallet] pub mod pallet { @@ -244,15 +245,7 @@ pub mod pallet { // NOTE: 1R 1W ScheduleRewardsTotal::::mutate( (schedule.liq_token, schedule.reward_token), - |(pending, idx, cumulative)| { - if *idx >= session_id { - *pending += schedule.amount_per_session - } else { - *cumulative += *pending; - *pending = schedule.amount_per_session; - *idx = session_id; - } - }, + |s| s.provide_rewards(session_id, schedule.amount_per_session) ); } // NOTE: 1W @@ -457,17 +450,12 @@ pub mod pallet { ValueQuery, >; - /// How much scheduled rewards per single liquidty_token should be distribute_rewards - /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic - #[pallet::storage] - pub type ScheduleRewardsPerSingleLiquidity = - StorageValue<_, BTreeMap<(TokenId, TokenId), u128>, ValueQuery>; /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] - pub type ScheduleRewardsTotal = - StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; + // pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; + pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), ScheduleRewards, ValueQuery>; #[pallet::storage] pub type ScheduleRewardsPerLiquidity = diff --git a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs index 55e2d9e72d..9a11f1d841 100644 --- a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs +++ b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs @@ -1,20 +1,80 @@ use crate::{ Config, Pallet, ScheduleRewardsPerLiquidity, ScheduleRewardsTotal, - TotalActivatedLiquidityForSchedules, + TotalActivatedLiquidityForSchedules, SessionId }; use core::marker::PhantomData; use mangata_types::{Balance, TokenId}; use sp_core::U256; +use frame_support::pallet_prelude::*; + + +#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] +/// Information about single token rewards. Automatically accumulates new rewards into `pending` +/// and once `pending_session_id < current_session` they are moved to `total` and become ready for +/// distribution to end users +pub struct ScheduleRewards { + // Accumulated rewards in current or past session. Once `now > pending_session_id` they + // should be moved to total + pending: u128, + + // id of the session when pending_rewards were recently updated + pending_session_id: SessionId, + + // total amount of rewards ready for distribution + total: u128, +} + + +impl ScheduleRewards { + pub fn provide_rewards(&mut self, now: SessionId, amount: u128) { + if now <= self.pending_session_id { + self.pending += amount; + } else { + self.total += self.pending; + self.pending = amount; + self.pending_session_id = now; + } + } + + pub fn total_rewards(&self, now: SessionId) -> u128 { + if now <= self.pending_session_id { + self.total + } else { + self.total + self.pending + } + } + + pub fn transfer_pending(&mut self, now: SessionId) { + if now > self.pending_session_id { + self.total += self.pending; + self.pending = 0; + self.pending_session_id = now; + } + } + + pub fn clear(&mut self, now: SessionId) { + self.total = 0; + self.pending = 0; + self.pending_session_id = now; + } +} + pub struct ScheduleRewardsCalculator { data: PhantomData, } +/// Class responsible for maintaining and periodically updating cumulative +/// calculations required for 3rdparty rewards impl ScheduleRewardsCalculator { pub fn update_cumulative_rewards( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, ) { + + let session_id = Pallet::::session_index() as u64; + + let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); if idx == (Pallet::::session_index() as u64) { @@ -26,9 +86,10 @@ impl ScheduleRewardsCalculator { if total_activated_liquidity > 0 { ScheduleRewardsTotal::::mutate( (liquidity_asset_id, liquidity_assets_reward), - |(cumulative, _, _)| { - *cumulative = 0; - }, + |schedule| { + schedule.transfer_pending(session_id); + schedule.clear(session_id); + } ); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) .checked_div(U256::from(total_activated_liquidity)) @@ -81,15 +142,10 @@ impl ScheduleRewardsCalculator { liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, ) -> Balance { - let (pending, idx, cumulative) = - ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)); - if idx == (Pallet::::session_index() as u64) { - cumulative - } else { - cumulative + pending - } + ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)).total_rewards(Pallet::::session_index() as u64) } + pub fn update_total_activated_liqudity( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, From 111b0cd0b2aa201f4b2f6c5ff7ffde1d423bbdf8 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 12:07:49 +0100 Subject: [PATCH 63/83] apply formatting --- pallets/proof-of-stake/src/lib.rs | 29 +-- .../src/schedule_rewards_calculator.rs | 193 ++++++++++-------- 2 files changed, 113 insertions(+), 109 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index ad2628f77b..fad8932b60 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -136,7 +136,9 @@ mod reward_info; use reward_info::{RewardInfo, RewardsCalculator}; mod schedule_rewards_calculator; -use schedule_rewards_calculator::{ScheduleRewardsCalculator, ScheduleRewards}; +use schedule_rewards_calculator::{ + ActivatedLiquidityPerSchedule, ScheduleRewards, ScheduleRewardsCalculator, +}; mod benchmarking; @@ -245,7 +247,7 @@ pub mod pallet { // NOTE: 1R 1W ScheduleRewardsTotal::::mutate( (schedule.liq_token, schedule.reward_token), - |s| s.provide_rewards(session_id, schedule.amount_per_session) + |s| s.provide_rewards(session_id, schedule.amount_per_session), ); } // NOTE: 1W @@ -450,22 +452,16 @@ pub mod pallet { ValueQuery, >; - /// How much scheduled rewards per single liquidty_token should be distribute_rewards /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic #[pallet::storage] - // pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), (u128, u64, u128), ValueQuery>; - pub type ScheduleRewardsTotal = StorageMap<_, Twox64Concat, (TokenId, TokenId), ScheduleRewards, ValueQuery>; + pub type ScheduleRewardsTotal = + StorageMap<_, Twox64Concat, (TokenId, TokenId), ScheduleRewards, ValueQuery>; #[pallet::storage] pub type ScheduleRewardsPerLiquidity = StorageMap<_, Twox64Concat, (TokenId, TokenId), (U256, u64), ValueQuery>; - /// How much scheduled rewards per single liquidty_token should be distribute_rewards - /// the **value is multiplied by u128::MAX** to avoid floating point arithmetic - // #[pallet::storage] - // pub type ScheduleRewardsCumulative = StorageMap<_, Twox64Concat ,(TokenId, TokenId, u64), u128, ValueQuery>; - /// List of activated schedules sorted by expiry date #[pallet::storage] #[pallet::getter(fn schedules)] @@ -483,9 +479,6 @@ pub mod pallet { #[pallet::getter(fn pos)] pub type ScheduleListPos = StorageValue<_, ScheduleId, OptionQuery>; - #[pallet::storage] - pub type ScheduleListPosPrev = StorageValue<_, ScheduleId, OptionQuery>; - #[pallet::storage] #[pallet::getter(fn head)] pub type ScheduleListHead = StorageValue<_, ScheduleId, OptionQuery>; @@ -503,7 +496,9 @@ pub mod pallet { pub type RewardTokensPerPool = StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, (), ValueQuery>; - /// Total amount of activated liquidity for each schedule + /// Tracks number of activated liquidity per schedule. It is used for calculation of + /// "cumulative rewrds amount" per 1 liquidity token. Therefore activation/deactivation needs + /// to be deffered same way as schedule rewards are delayed. #[pallet::storage] pub type TotalActivatedLiquidityForSchedules = StorageDoubleMap< _, @@ -511,14 +506,10 @@ pub mod pallet { TokenId, Twox64Concat, TokenId, - (u128, u128, u64, u128), + ActivatedLiquidityPerSchedule, ValueQuery, >; - // #[pallet::storage] - // pub type PrevTotalActivatedLiquidityForSchedules = - // StorageDoubleMap<_, Twox64Concat, TokenId, Twox64Concat, TokenId, u128, ValueQuery>; - /// Tracks how much liquidity user activated for particular (liq token, reward token) pair /// StorageNMap was used because it only require single read to know if user deactivated all /// liquidity associated with particular liquidity_token that is rewarded. If so part of the diff --git a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs index 9a11f1d841..5be33a0a00 100644 --- a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs +++ b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs @@ -1,64 +1,105 @@ use crate::{ - Config, Pallet, ScheduleRewardsPerLiquidity, ScheduleRewardsTotal, - TotalActivatedLiquidityForSchedules, SessionId + Config, Pallet, ScheduleRewardsPerLiquidity, ScheduleRewardsTotal, SessionId, + TotalActivatedLiquidityForSchedules, }; use core::marker::PhantomData; +use frame_support::pallet_prelude::*; use mangata_types::{Balance, TokenId}; use sp_core::U256; -use frame_support::pallet_prelude::*; - #[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub struct ActivatedLiquidityPerSchedule { + pending_positive: u128, + pending_negative: u128, + pending_session_id: SessionId, + total: u128, +} + +#[derive(Encode, Decode, Clone, RuntimeDebug, PartialEq, Eq, TypeInfo)] +pub enum LiquidityModification { + Increase, + Decrease, +} + +impl ActivatedLiquidityPerSchedule { + fn total(&self, now: SessionId) -> u128 { + if now <= self.pending_session_id { + self.total + } else { + self.total + self.pending_positive - self.pending_negative + } + } + + fn update(&mut self, now: SessionId, amount: u128, kind: LiquidityModification) { + if now <= self.pending_session_id { + if kind == LiquidityModification::Increase { + self.pending_positive += amount; + } else { + self.pending_negative += amount; + } + } else { + self.total = self.total + self.pending_positive - self.pending_negative; + if kind == LiquidityModification::Increase { + self.pending_positive = amount; + self.pending_negative = 0u128; + } else { + self.pending_positive = 0u128; + self.pending_negative = amount; + }; + self.pending_session_id = now; + } + } +} + /// Information about single token rewards. Automatically accumulates new rewards into `pending` /// and once `pending_session_id < current_session` they are moved to `total` and become ready for /// distribution to end users +#[derive(Encode, Decode, Clone, Default, RuntimeDebug, PartialEq, Eq, TypeInfo)] pub struct ScheduleRewards { - // Accumulated rewards in current or past session. Once `now > pending_session_id` they - // should be moved to total - pending: u128, + // Accumulated rewards in current or past session. Once `now > pending_session_id` they + // should be moved to total + pending: u128, - // id of the session when pending_rewards were recently updated - pending_session_id: SessionId, + // id of the session when pending_rewards were recently updated + pending_session_id: SessionId, - // total amount of rewards ready for distribution - total: u128, + // total amount of rewards ready for distribution + total: u128, } - impl ScheduleRewards { - pub fn provide_rewards(&mut self, now: SessionId, amount: u128) { - if now <= self.pending_session_id { - self.pending += amount; - } else { - self.total += self.pending; - self.pending = amount; - self.pending_session_id = now; - } - } - - pub fn total_rewards(&self, now: SessionId) -> u128 { - if now <= self.pending_session_id { - self.total - } else { - self.total + self.pending - } - } - - pub fn transfer_pending(&mut self, now: SessionId) { - if now > self.pending_session_id { - self.total += self.pending; - self.pending = 0; - self.pending_session_id = now; - } - } - - pub fn clear(&mut self, now: SessionId) { - self.total = 0; - self.pending = 0; - self.pending_session_id = now; - } -} + pub fn provide_rewards(&mut self, now: SessionId, amount: u128) { + if now <= self.pending_session_id { + self.pending += amount; + } else { + self.total += self.pending; + self.pending = amount; + self.pending_session_id = now; + } + } + + pub fn total_rewards(&self, now: SessionId) -> u128 { + if now <= self.pending_session_id { + self.total + } else { + self.total + self.pending + } + } + pub fn transfer_pending(&mut self, now: SessionId) { + if now > self.pending_session_id { + self.total += self.pending; + self.pending = 0; + self.pending_session_id = now; + } + } + + pub fn clear(&mut self, now: SessionId) { + self.total = 0; + self.pending = 0; + self.pending_session_id = now; + } +} pub struct ScheduleRewardsCalculator { data: PhantomData, @@ -71,9 +112,7 @@ impl ScheduleRewardsCalculator { liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, ) { - - let session_id = Pallet::::session_index() as u64; - + let session_id = Pallet::::session_index() as u64; let (cumulative, idx) = ScheduleRewardsPerLiquidity::::get((liquidity_asset_id, liquidity_assets_reward)); @@ -87,9 +126,9 @@ impl ScheduleRewardsCalculator { ScheduleRewardsTotal::::mutate( (liquidity_asset_id, liquidity_assets_reward), |schedule| { - schedule.transfer_pending(session_id); - schedule.clear(session_id); - } + schedule.transfer_pending(session_id); + schedule.clear(session_id); + }, ); let pending = (U256::from(total_schedule_rewards) * U256::from(u128::MAX)) .checked_div(U256::from(total_activated_liquidity)) @@ -122,62 +161,36 @@ impl ScheduleRewardsCalculator { } } - pub fn total_activated_liquidity( - liquidity_asset_id: TokenId, - liquidity_assets_reward: TokenId, - ) -> Balance { - let (pending_negative, pending_positive, idx, cumulative) = - TotalActivatedLiquidityForSchedules::::get( - liquidity_asset_id, - liquidity_assets_reward, - ); - if idx == (Pallet::::session_index() as u64) { - cumulative - } else { - cumulative + pending_positive - pending_negative - } - } - pub fn total_schedule_rewards( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, ) -> Balance { - ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)).total_rewards(Pallet::::session_index() as u64) + ScheduleRewardsTotal::::get((liquidity_asset_id, liquidity_assets_reward)) + .total_rewards(Pallet::::session_index() as u64) } - pub fn update_total_activated_liqudity( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, diff: Balance, change: bool, ) { - // TODO: make configurable let session_id = Pallet::::session_index() as u64; - + let kind = + if change { LiquidityModification::Increase } else { LiquidityModification::Decrease }; TotalActivatedLiquidityForSchedules::::mutate( liquidity_asset_id, liquidity_assets_reward, - |(pending_negative, pending_positive, idx, cumulative)| { - if *idx == session_id { - if change { - *pending_positive += diff; - } else { - *pending_negative += diff; - }; - } else { - // NOTE: handle burn so negative diff - *cumulative = *cumulative + *pending_positive - *pending_negative; - if change { - *pending_positive = diff; - *pending_negative = 0u128; - } else { - *pending_positive = 0u128; - *pending_negative = diff; - }; - *idx = session_id; - } - }, + |s| s.update(session_id, diff, kind), ); } + + pub fn total_activated_liquidity( + liquidity_asset_id: TokenId, + liquidity_assets_reward: TokenId, + ) -> Balance { + let session_id = Pallet::::session_index() as u64; + TotalActivatedLiquidityForSchedules::::get(liquidity_asset_id, liquidity_assets_reward) + .total(session_id) + } } From 5b849e9ac330a09450981c93804e5ea4dd100354 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 12:14:42 +0100 Subject: [PATCH 64/83] adding docs to rewards_calculator module --- pallets/proof-of-stake/src/reward_info.rs | 10 ---------- .../proof-of-stake/src/schedule_rewards_calculator.rs | 9 +++++++++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/pallets/proof-of-stake/src/reward_info.rs b/pallets/proof-of-stake/src/reward_info.rs index 8abb74214d..b8c0b46837 100644 --- a/pallets/proof-of-stake/src/reward_info.rs +++ b/pallets/proof-of-stake/src/reward_info.rs @@ -85,17 +85,8 @@ impl RewardsCalculator { crate::RewardTokensPerPool::::try_get(asset_id, reward_asset_id).is_ok(), crate::Error::::NotAPromotedPool ); - - // NOTE: take into acout previous rewards (prev + rewards/activated) - // let total_activated = Pallet::::total_activated_liquidity(asset_id, reward_asset_id); - // let total_rewards = Pallet::::total_schedule_rewards(asset_id, reward_asset_id); - // println!("REWARDS CALCULATOR at {} for {}", current_time, user); - // println!("total_activated : {}", total_activated); - // println!("total_rewards : {}", total_rewards); - // let pool_ratio_current = U256::from(total_rewards.checked_div(total_activated).unwrap_or_default()) * U256::from(u128::MAX); let pool_ratio_current = ScheduleRewardsCalculator::::total_rewards_for_liquidity(asset_id, reward_asset_id); - println!("SCHEDULE REWARDS RATIO: {}", pool_ratio_current); let default_rewards = RewardInfo { activated_amount: 0_u128, @@ -197,7 +188,6 @@ impl CurveRewards for ConstCurveRewards { let rewards_base: U256 = U256::from(user_info.activated_amount) .checked_mul(pool_rewards_ratio_new)? .checked_div(U256::from(u128::MAX))?; // always fit into u128 - println!("REWARDS : {}", rewards_base); rewards_base.try_into().ok() } diff --git a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs index 5be33a0a00..3922e74c0f 100644 --- a/pallets/proof-of-stake/src/schedule_rewards_calculator.rs +++ b/pallets/proof-of-stake/src/schedule_rewards_calculator.rs @@ -108,6 +108,8 @@ pub struct ScheduleRewardsCalculator { /// Class responsible for maintaining and periodically updating cumulative /// calculations required for 3rdparty rewards impl ScheduleRewardsCalculator { + /// updates cumulative number of rewards per 1 liquidity (mulipliedd by u128::MAX) because of + /// precision. pub fn update_cumulative_rewards( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, @@ -141,6 +143,8 @@ impl ScheduleRewardsCalculator { } } + /// returns cumulative number of rewards per 1 liquidity (mulipliedd by u128::MAX) because of + /// precision. pub fn total_rewards_for_liquidity( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, @@ -161,6 +165,8 @@ impl ScheduleRewardsCalculator { } } + /// returns amount of schedule rewards that has been accumulated since last update of `ScheduleRewardsPerLiquidity` + /// its beeing tracked only for purpose of `ScheduleRewardsPerLiquidity` calculations pub fn total_schedule_rewards( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, @@ -169,6 +175,8 @@ impl ScheduleRewardsCalculator { .total_rewards(Pallet::::session_index() as u64) } + /// returns amount of schedule rewards that has been accumulated since last update of `ScheduleRewardsPerLiquidity` + /// its beeing tracked only for purpose of `ScheduleRewardsPerLiquidity` calculations pub fn update_total_activated_liqudity( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, @@ -185,6 +193,7 @@ impl ScheduleRewardsCalculator { ); } + /// returns info about total activated liquidity per schedule pub fn total_activated_liquidity( liquidity_asset_id: TokenId, liquidity_assets_reward: TokenId, From e6d3d209d08de41d05af03209464633fd9a88f2b Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Mon, 30 Oct 2023 19:49:25 +0100 Subject: [PATCH 65/83] fix wasm32 compilation --- Cargo.lock | 1 - pallets/proof-of-stake/Cargo.toml | 1 - 2 files changed, 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1705c86419..1102437ef3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6820,7 +6820,6 @@ dependencies = [ "pallet-vesting-mangata", "pallet-xyk", "parity-scale-codec", - "primitive-types", "rustc-hex", "scale-info", "serde", diff --git a/pallets/proof-of-stake/Cargo.toml b/pallets/proof-of-stake/Cargo.toml index 9c23e8e6f6..c6aedfa0ad 100644 --- a/pallets/proof-of-stake/Cargo.toml +++ b/pallets/proof-of-stake/Cargo.toml @@ -29,7 +29,6 @@ pallet-bootstrap = { default-features = false, path = "../bootstrap" } sp-arithmetic = { default-features = false, version = '6.0.0' , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } libm = { default-features = false, git = "https://github.com/rust-lang/libm", rev="2f3fc968f43d345f9b449938d050a9ea46a04c83"} orml-tokens = { default-features = false, version = '0.4.1-dev' , git = "https://github.com/mangata-finance/open-runtime-module-library", branch = "mangata-dev" } -primitive-types = "0.12.0" pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", default-features = false, branch = "mangata-dev" } mangata-support = { default-features = false , git = "https://github.com/mangata-finance/substrate", branch = "mangata-dev" } From bb516edc20884f695ed7158fe12daafb26fb7b22 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 31 Oct 2023 11:14:56 +0100 Subject: [PATCH 66/83] introduce pool volume valuation and align ut --- pallets/bootstrap/src/mock.rs | 3 +- pallets/proof-of-stake/src/benchmarking.rs | 8 +- pallets/proof-of-stake/src/lib.rs | 49 +- pallets/proof-of-stake/src/mock.rs | 22 +- pallets/proof-of-stake/src/tests.rs | 513 +++++++++++---------- pallets/xyk/src/mock.rs | 6 +- runtime/common/src/lib.rs | 5 +- runtime/mangata-kusama/src/lib.rs | 3 +- runtime/mangata-rococo/src/lib.rs | 3 +- 9 files changed, 344 insertions(+), 268 deletions(-) diff --git a/pallets/bootstrap/src/mock.rs b/pallets/bootstrap/src/mock.rs index d748fdeedf..115f68e478 100644 --- a/pallets/bootstrap/src/mock.rs +++ b/pallets/bootstrap/src/mock.rs @@ -166,7 +166,8 @@ impl pallet_proof_of_stake::Config for Test { type RewardsDistributionPeriod = ConstU32<10000>; type WeightInfo = (); type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<10>; + type Min3rdPartyRewardValutationPerSession = ConstU128<10>; + type Min3rdPartyRewardVolume = ConstU128<10>; type ValuationApi = Xyk; } diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 986cff9cf3..0008589e1d 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -220,7 +220,7 @@ benchmarks! { } } - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit + 1); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); @@ -284,7 +284,7 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); @@ -333,7 +333,7 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); @@ -413,7 +413,7 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewards::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index fad8932b60..3aafedac2f 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -355,7 +355,8 @@ pub mod pallet { /// The maximum number of schedules that can be active at one moment type RewardsSchedulesLimit: Get; /// The minimum number of rewards per session for schedule rewards - type Min3rdPartyRewards: Get; + type Min3rdPartyRewardValutationPerSession: Get; + type Min3rdPartyRewardVolume : Get; type WeightInfo: WeightInfo; type ValuationApi: ValutationApiTrait; } @@ -387,6 +388,8 @@ pub mod pallet { TooManySchedules, /// Too little rewards per session TooLittleRewards, + /// Too little rewards per session + TooLittlePoolValuation, // Liquidity is reused for 3rdparty rewards LiquidityLockedIn3rdpartyRewards, } @@ -1340,17 +1343,15 @@ impl Pallet { .ok_or(Error::::MathOverflow)?; ensure!( - ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= - T::Min3rdPartyRewards::get() || - ((token_id == Into::::into(Self::native_token_id())) && - amount_per_session >= T::Min3rdPartyRewards::get()) || - ::ValuationApi::valuate_non_liquidity_token( - token_id, - amount_per_session - ) >= T::Min3rdPartyRewards::get(), + Self::verify_rewards_min_amount(token_id, amount_per_session), Error::::TooLittleRewards ); + ensure!( + Self::verify_rewards_min_volume(token_id), + Error::::TooLittlePoolValuation + ); + RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); T::Currency::transfer( @@ -1361,8 +1362,6 @@ impl Pallet { ExistenceRequirement::KeepAlive, )?; - let current_session = Self::session_index(); - let head = ScheduleListHead::::get(); let tail = ScheduleListTail::::get(); let schedule = Schedule { @@ -1394,6 +1393,34 @@ impl Pallet { Ok(()) } + + fn verify_rewards_min_amount(token_id: TokenId, amount_per_session: Balance) -> bool { + if ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { + return true; + } + + if token_id == Into::::into(Self::native_token_id()) && amount_per_session >= T::Min3rdPartyRewardValutationPerSession::get() { + return true; + } + + if ::ValuationApi::valuate_non_liquidity_token( token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { + return true; + } + + return false; + } + + fn verify_rewards_min_volume(token_id: TokenId) -> bool { + if token_id == Into::::into(Self::native_token_id()) { + return true; + } + + if let Some((mga_reserves, _)) = ::ValuationApi::get_pool_state(token_id) { + return mga_reserves >= T::Min3rdPartyRewardValutationPerSession::get(); + } + + return false; + } } impl ProofOfStakeRewardsApi for Pallet { diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 877f0af460..b103723b58 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -290,7 +290,8 @@ impl pos::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<10>; + type Min3rdPartyRewardValutationPerSession = ConstU128<10>; + type Min3rdPartyRewardVolume = ConstU128<10>; type WeightInfo = (); type ValuationApi = MockValuationApi; } @@ -304,7 +305,8 @@ impl pos::Config for Test { type LiquidityMiningIssuanceVault = FakeLiquidityMiningIssuanceVault; type RewardsDistributionPeriod = ConstU32<10>; type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<100_000>; + type Min3rdPartyRewardValutationPerSession = ConstU128<100_000>; + type Min3rdPartyRewardVolume = ConstU128<10>; type WeightInfo = (); type ValuationApi = Xyk; } @@ -401,6 +403,10 @@ pub struct ExtBuilder { ext: sp_io::TestExternalities, } +fn min_req_valutation() -> u128 { + <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() +} + impl ExtBuilder { pub fn new() -> Self { let t = frame_system::GenesisConfig::default() @@ -429,6 +435,18 @@ impl ExtBuilder { pub fn build(self) -> sp_io::TestExternalities { self.ext } + + pub fn execute_with_default_mocks(mut self, f: impl FnOnce() -> R) -> R { + self.ext.execute_with(|| { + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(10u32)); + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(11u128); + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + f() + }) + } } /// Compares the system events with passed in events diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 7bb711e02f..57f3524f1f 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -94,8 +94,9 @@ fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { } #[test] +#[serial] fn liquidity_rewards_single_user_mint_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -164,8 +165,9 @@ fn liquidity_rewards_single_user_mint_W() { } #[test] +#[serial] fn liquidity_rewards_three_users_burn_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -213,8 +215,9 @@ fn liquidity_rewards_three_users_burn_W() { } #[test] +#[serial] fn liquidity_rewards_claim_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -256,8 +259,9 @@ fn liquidity_rewards_claim_W() { } #[test] +#[serial] fn liquidity_rewards_promote_pool_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -273,8 +277,9 @@ fn liquidity_rewards_promote_pool_W() { } #[test] +#[serial] fn liquidity_rewards_promote_pool_already_promoted_NW() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -292,8 +297,9 @@ fn liquidity_rewards_promote_pool_already_promoted_NW() { } #[test] +#[serial] fn liquidity_rewards_work_after_burn_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -342,8 +348,9 @@ fn liquidity_rewards_work_after_burn_W() { } #[test] +#[serial] fn liquidity_rewards_deactivate_transfer_controled_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -386,8 +393,9 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { } #[test] +#[serial] fn liquidity_rewards_deactivate_more_NW() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -421,8 +429,9 @@ fn liquidity_rewards_deactivate_more_NW() { } #[test] +#[serial] fn liquidity_rewards_activate_more_NW() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -450,8 +459,9 @@ fn liquidity_rewards_activate_more_NW() { } #[test] +#[serial] fn liquidity_rewards_calculate_rewards_pool_not_promoted() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -468,8 +478,9 @@ fn liquidity_rewards_calculate_rewards_pool_not_promoted() { } #[test] +#[serial] fn liquidity_rewards_claim_pool_not_promoted() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -488,8 +499,9 @@ fn liquidity_rewards_claim_pool_not_promoted() { } #[test] +#[serial] fn liquidity_rewards_transfer_not_working() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { initialize_liquidity_rewards(); assert_err!( @@ -500,8 +512,9 @@ fn liquidity_rewards_transfer_not_working() { } #[test] +#[serial] fn liquidity_rewards_not_yet_claimed_already_claimed_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -564,8 +577,9 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { } #[test] +#[serial] fn extreme_case_pool_ratio() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -595,8 +609,9 @@ fn extreme_case_pool_ratio() { } #[test] +#[serial] fn rewards_rounding_during_often_mint() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -685,8 +700,9 @@ fn rewards_rounding_during_often_mint() { } #[test] +#[serial] fn rewards_storage_right_amounts_start1() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -829,8 +845,9 @@ fn rewards_storage_right_amounts_start1() { // starting point, user burned some rewards, then new rewards were generated (yellow) #[test] +#[serial] fn rewards_storage_right_amounts_start2() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -965,8 +982,9 @@ fn rewards_storage_right_amounts_start2() { // starting point, just new rewards were generated (green) #[test] +#[serial] fn rewards_storage_right_amounts_start3() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -1043,8 +1061,9 @@ fn rewards_storage_right_amounts_start3() { } #[test] +#[serial] fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -1094,8 +1113,9 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { } #[test] +#[serial] fn test_migrated_from_pallet_issuance() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { env_logger::try_init(); System::set_block_number(1); const LIQUIDITY_ISSUANCE: Balance = 450045; @@ -1166,8 +1186,9 @@ fn test_migrated_from_pallet_issuance() { } #[test] +#[serial] fn claim_rewards_from_pool_that_has_been_disabled() { - new_test_ext().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; @@ -1227,18 +1248,18 @@ const BOB: u128 = 3; const CHARLIE: u128 = 4; const EVE: u128 = 5; + +fn min_req_valutation() -> u128 { + <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() +} + + #[test] #[serial] fn user_can_provide_3rdparty_rewards() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); - + .execute_with_default_mocks(|| { System::set_block_number(1); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1266,13 +1287,13 @@ fn user_can_provide_3rdparty_rewards() { fn cant_schedule_rewards_in_past() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + roll_to_session(5); assert_err!( @@ -1340,13 +1361,13 @@ fn cannot_reward_unexisting_pool() { fn rewards_are_stored_in_pallet_account() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + assert_eq!( TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), @@ -1375,13 +1396,13 @@ fn rewards_are_stored_in_pallet_account() { fn rewards_schedule_is_stored() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1415,13 +1436,13 @@ fn rewards_schedule_is_stored() { fn rewards_linked_list_insert_multiple_schedules() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1478,13 +1499,13 @@ fn rewards_linked_list_insert_multiple_schedules() { fn rewards_linked_list_removes_outdated_schedule_automatically() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1567,13 +1588,13 @@ fn insert_schedule_ending_at_session(n: u32) { fn rewards_first_schedule_from_linked_list_of_four() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(2); @@ -1603,13 +1624,13 @@ fn rewards_first_schedule_from_linked_list_of_four() { fn remove_last_schedule_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); @@ -1639,13 +1660,13 @@ fn remove_last_schedule_from_linked_list() { fn remove_middle_schedule_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); @@ -1675,13 +1696,13 @@ fn remove_middle_schedule_from_linked_list() { fn remove_first_few_elems_at_once_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(1); @@ -1710,13 +1731,13 @@ fn remove_first_few_elems_at_once_from_linked_list() { fn remove_few_last_elems_at_once_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); @@ -1745,13 +1766,13 @@ fn remove_few_last_elems_at_once_from_linked_list() { fn remove_few_middle_elements_from_linkedd_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); @@ -1780,13 +1801,13 @@ fn remove_few_middle_elements_from_linkedd_list() { fn remove_random_elements_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 5 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); @@ -1818,13 +1839,13 @@ fn remove_random_elements_from_linked_list() { fn remove_random_elements_from_linked_list_over_time() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 7 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(3); // 0 insert_schedule_ending_at_session(2); // 1 @@ -1863,13 +1884,13 @@ fn remove_random_elements_from_linked_list_over_time() { fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 10 * REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + insert_schedule_ending_at_session(3); // 0 insert_schedule_ending_at_session(1); // 1 @@ -1902,12 +1923,12 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { #[ignore] #[serial] fn number_of_active_schedules_is_limited() { - ExtBuilder::new().issue(ALICE, REWARD_TOKEN, MILLION).build().execute_with(|| { + ExtBuilder::new().issue(ALICE, REWARD_TOKEN, MILLION).execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let max_schedules: u32 = <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); @@ -1949,13 +1970,13 @@ fn number_of_active_schedules_is_limited() { fn duplicated_schedules_works() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(10u32)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + assert_eq!(ScheduleListHead::::get(), None); assert_eq!(ScheduleListTail::::get(), None); @@ -2028,6 +2049,8 @@ fn accept_schedule_valuated_in_native_token() { get_liquidity_asset_mock.expect().return_const(Ok(10u32)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); roll_to_session(4); @@ -2059,6 +2082,8 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); roll_to_session(4); @@ -2080,14 +2105,14 @@ fn user_can_claim_3rdparty_rewards() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); @@ -2169,6 +2194,8 @@ fn overlapping_3rdparty_rewards_works() { get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); @@ -2243,13 +2270,13 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 200) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2318,13 +2345,13 @@ fn deactivate_3rdparty_rewards() { .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2418,6 +2445,9 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + System::set_block_number(1); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2644,13 +2674,13 @@ fn liquidity_minting_liquidity_can_be_resused() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); @@ -2705,13 +2735,13 @@ fn fail_to_transfer_tokens_that_has_been_partially_deactivated() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); @@ -2790,13 +2820,13 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); @@ -2889,13 +2919,13 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); @@ -2987,12 +3017,12 @@ fn can_claim_schedule_rewards() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + .execute_with_default_mocks(|| { + + + + System::set_block_number(1); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) @@ -3136,12 +3166,12 @@ fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_li ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + .execute_with_default_mocks(|| { + + + + System::set_block_number(1); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) @@ -3166,14 +3196,14 @@ fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_sche ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -3203,7 +3233,7 @@ use sp_runtime::{traits::Dispatchable, Permill}; #[ignore] #[serial] fn activate_deactivate_calls_are_free_of_charge() { - ExtBuilder::new().build().execute_with(|| { + ExtBuilder::new().execute_with_default_mocks(|| { System::set_block_number(1); let activate_call = @@ -3233,14 +3263,14 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let activate_call = mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { @@ -3285,14 +3315,14 @@ fn claim_rewards_from_multiple_sessions_at_once() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); @@ -3345,14 +3375,14 @@ fn multi_user_rewards_distributeion_scenario() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); @@ -3428,14 +3458,14 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_instantly() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let amount = 10_000u128; @@ -3471,14 +3501,14 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions( ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let amount = 10_000u128; @@ -3516,14 +3546,14 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let amount = 10_000u128; @@ -3563,14 +3593,14 @@ fn test_multiple_activations_in_same_block() { .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + let amount = 10_000u128; @@ -3620,13 +3650,13 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -3796,13 +3826,13 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); + + + + /// 1000 rewards per session ProofOfStake::reward_pool( @@ -4068,13 +4098,8 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 10 * 3 * REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .build() - .execute_with(|| { + .execute_with_default_mocks(|| { System::set_block_number(1); - let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); - get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); - let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); - valuate_liquidity_token_mock.expect().return_const(11u128); assert_err_ignore_postinfo!( ProofOfStake::activate_liquidity_for_3rdparty_rewards( diff --git a/pallets/xyk/src/mock.rs b/pallets/xyk/src/mock.rs index 84be772aed..ed70bc8179 100644 --- a/pallets/xyk/src/mock.rs +++ b/pallets/xyk/src/mock.rs @@ -330,7 +330,8 @@ impl pallet_proof_of_stake::Config for Test { type RewardsDistributionPeriod = ConstU32<10>; type WeightInfo = (); type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<10>; + type Min3rdPartyRewardValutationPerSession = ConstU128<10>; + type Min3rdPartyRewardVolume = ConstU128<10>; type ValuationApi = XykStorage; } @@ -344,7 +345,8 @@ impl pallet_proof_of_stake::Config for Test { type RewardsDistributionPeriod = ConstU32<1200>; type WeightInfo = (); type RewardsSchedulesLimit = ConstU32<10>; - type Min3rdPartyRewards = ConstU128<10>; + type Min3rdPartyRewardValutationPerSession = ConstU128<10>; + type Min3rdPartyRewardVolume = ConstU128<10>; type ValuationApi = XykStorage; } diff --git a/runtime/common/src/lib.rs b/runtime/common/src/lib.rs index b08a94149d..2ad77371eb 100644 --- a/runtime/common/src/lib.rs +++ b/runtime/common/src/lib.rs @@ -1371,9 +1371,10 @@ where use super::*; parameter_types! { - pub const RewardsSchedulesLimit: u32 = 200; + pub const RewardsSchedulesLimit: u32 = 100_000u32; // TODO: allign properly - pub const Min3rdPartyRewards: u128 = 100 * 30_000 * currency::DOLLARS; + pub const Min3rdPartyRewardValutationPerSession: u128 = 100 * 30_000 * currency::DOLLARS; + pub const Min3rdPartyRewardVolume: u128 = 100 * 30_000 * currency::DOLLARS; } } } diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 04a18a4b14..cbd2ee430b 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -277,7 +277,8 @@ impl pallet_proof_of_stake::Config for Runtime { type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; - type Min3rdPartyRewards = cfg::pallet_proof_of_stake::Min3rdPartyRewards; + type Min3rdPartyRewardValutationPerSession = cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; + type Min3rdPartyRewardVolume = cfg::pallet_proof_of_stake::Min3rdPartyRewardVolume; type ValuationApi = Xyk; } diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index 3920a8016d..e7178cfc5a 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -277,7 +277,8 @@ impl pallet_proof_of_stake::Config for Runtime { type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; - type Min3rdPartyRewards = cfg::pallet_proof_of_stake::Min3rdPartyRewards; + type Min3rdPartyRewardValutationPerSession = cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; + type Min3rdPartyRewardVolume = cfg::pallet_proof_of_stake::Min3rdPartyRewardVolume; type ValuationApi = Xyk; } From 357cb9ffc5a53dd93be5802a7412c290d4e520b1 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 31 Oct 2023 12:53:20 +0100 Subject: [PATCH 67/83] verify volume of rewarded token --- pallets/proof-of-stake/src/lib.rs | 13 ++- pallets/proof-of-stake/src/mock.rs | 4 +- pallets/proof-of-stake/src/tests.rs | 157 +++++++++++++++++++++++++++- 3 files changed, 163 insertions(+), 11 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 3aafedac2f..7d8438f8e3 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -388,8 +388,8 @@ pub mod pallet { TooManySchedules, /// Too little rewards per session TooLittleRewards, - /// Too little rewards per session - TooLittlePoolValuation, + /// Too small volume of the pool + TooSmallVolume, // Liquidity is reused for 3rdparty rewards LiquidityLockedIn3rdpartyRewards, } @@ -1349,7 +1349,7 @@ impl Pallet { ensure!( Self::verify_rewards_min_volume(token_id), - Error::::TooLittlePoolValuation + Error::::TooSmallVolume ); RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); @@ -1411,14 +1411,19 @@ impl Pallet { } fn verify_rewards_min_volume(token_id: TokenId) -> bool { + if token_id == Into::::into(Self::native_token_id()) { return true; } if let Some((mga_reserves, _)) = ::ValuationApi::get_pool_state(token_id) { - return mga_reserves >= T::Min3rdPartyRewardValutationPerSession::get(); + return mga_reserves >= T::Min3rdPartyRewardVolume::get(); } + if let Ok((mga_reserves, _)) = ::ValuationApi::get_reserves(Self::native_token_id(), token_id){ + return mga_reserves >= T::Min3rdPartyRewardVolume::get(); + } + return false; } } diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index b103723b58..9e19d4986c 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -403,7 +403,7 @@ pub struct ExtBuilder { ext: sp_io::TestExternalities, } -fn min_req_valutation() -> u128 { +fn min_req_volume() -> u128 { <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() } @@ -443,7 +443,7 @@ impl ExtBuilder { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); f() }) } diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 57f3524f1f..2a9eca7794 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1249,7 +1249,7 @@ const CHARLIE: u128 = 4; const EVE: u128 = 5; -fn min_req_valutation() -> u128 { +fn min_req_volume() -> u128 { <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() } @@ -2050,7 +2050,7 @@ fn accept_schedule_valuated_in_native_token() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); roll_to_session(4); @@ -2083,7 +2083,7 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); roll_to_session(4); @@ -2195,7 +2195,7 @@ fn overlapping_3rdparty_rewards_works() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); @@ -2446,7 +2446,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_valutation(),min_req_valutation()))); + get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); System::set_block_number(1); ProofOfStake::reward_pool( @@ -4144,3 +4144,150 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo )); }); } + + +#[test] +#[serial] +fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let too_small_volume = Some((min_req_volume()-1,min_req_volume()-1)); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(0u128); + + let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + valuate_non_liquidity_token_mock.expect().return_const(10u128); + + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(too_small_volume); + + roll_to_session(4); + + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + Error::::TooSmallVolume + ); + }); +} + +#[test] +#[serial] +fn accept_3rdparty_rewards_with_non_liq_token_and_proper_valuation() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let min_volume = Some((min_req_volume(),min_req_volume())); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(0u128); + + let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + valuate_non_liquidity_token_mock.expect().return_const(10u128); + + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(min_volume); + + roll_to_session(4); + + assert_ok!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + ); + }); +} + + +#[test] +#[serial] +fn reject_3rdparty_rewards_with_liq_token_and_too_small_volume() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + let too_small_volume = Some((min_req_volume()-1,min_req_volume()-1)); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(10u128); + + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(None); + + let get_reserves_mock = MockValuationApi::get_reserves_context(); + get_reserves_mock.expect().return_const(Ok((9u128, 0u128))); + + roll_to_session(4); + + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + Error::::TooSmallVolume + ); + }); +} + +#[test] +#[serial] +fn accept_3rdparty_rewards_with_liq_token_and_min_volume() { + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .build() + .execute_with(|| { + System::set_block_number(1); + + let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); + get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); + + let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); + valuate_liquidity_token_mock.expect().return_const(10u128); + + let get_pool_state_mock = MockValuationApi::get_pool_state_context(); + get_pool_state_mock.expect().return_const(None); + + let get_reserves_mock = MockValuationApi::get_reserves_context(); + get_reserves_mock.expect().return_const(Ok((min_req_volume(), 0u128))); + + roll_to_session(4); + + assert_ok!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + ); + }); +} From ec8e4d7395af58258de362e22ab427a2b009f053 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Tue, 31 Oct 2023 16:45:00 +0100 Subject: [PATCH 68/83] fixing some of the benchmarks --- pallets/proof-of-stake/src/benchmarking.rs | 18 +++++------ pallets/proof-of-stake/src/lib.rs | 6 +++- pallets/proof-of-stake/src/mock.rs | 36 ++++++++++++++++++++++ 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 0008589e1d..70fb8fd2c8 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -209,7 +209,7 @@ benchmarks! { init::(); - let schedules_limit = ::RewardsSchedulesLimit::get(); + let schedules_limit = 10u32; let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); @@ -220,7 +220,7 @@ benchmarks! { } } - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get() * 10u128; let native_asset_amount: u128 = REWARDS_AMOUNT * Into::::into(schedules_limit + 1); TokensOf::::mint(native_asset_id.into(), &caller, native_asset_amount.into()).unwrap(); @@ -235,7 +235,7 @@ benchmarks! { RawOrigin::Signed(caller.clone().into()).into(), (native_asset_id, token_id), reward_token.into(), - REWARDS_AMOUNT, + (REWARDS_AMOUNT).into(), 10u32.into(), ).unwrap(); } @@ -260,16 +260,16 @@ benchmarks! { let reward_token = token_id + 1; assert_eq!( - RewardsSchedules::::get().len() as u32, - schedules_limit + PoS::::tail().unwrap(), + (schedules_limit - 1 ) as u64 ); }: reward_pool(RawOrigin::Signed(caller.clone().into()), (native_asset_id,token_id), reward_token.into(), REWARDS_AMOUNT, 10u32.into()) verify { assert_eq!( - RewardsSchedules::::get().len() as u32, - schedules_limit + PoS::::tail().unwrap(), + schedules_limit as u64 ); } @@ -281,10 +281,10 @@ benchmarks! { init::(); - let schedules_limit = ::RewardsSchedulesLimit::get(); + let schedules_limit = 10u32; let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); + let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get() * (schedules_limit as u128); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 7d8438f8e3..8e3c54d003 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -148,7 +148,7 @@ mod mock; #[cfg(test)] mod tests; -pub(crate) const LOG_TARGET: &str = "proof-of-stake"; +pub(crate) const LOG_TARGET: &str = "pos"; // syntactic sugar for logging. #[macro_export] @@ -1395,15 +1395,19 @@ impl Pallet { } fn verify_rewards_min_amount(token_id: TokenId, amount_per_session: Balance) -> bool { + log!(info, "blah 1 "); if ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { + log!(info, "blah 2 "); return true; } if token_id == Into::::into(Self::native_token_id()) && amount_per_session >= T::Min3rdPartyRewardValutationPerSession::get() { + log!(info, "blah 3 "); return true; } if ::ValuationApi::valuate_non_liquidity_token( token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { + log!(info, "blah 4 "); return true; } diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 9e19d4986c..da5b30947b 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -476,3 +476,39 @@ macro_rules! assert_event_emitted { } }; } + +fn roll_to_next_block() { + forward_to_block((System::block_number() + 1).saturated_into::()); +} + +pub fn roll_to_next_session() { + let current_session = ProofOfStake::session_index(); + roll_to_session(current_session + 1); +} + +pub fn roll_to_session(n: u32) { + while ProofOfStake::session_index() < n { + roll_to_next_block(); + } +} + +pub fn forward_to_block(n: u32) { + forward_to_block_with_custom_rewards(n, 10000); +} + +pub fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { + while System::block_number().saturated_into::() < n { + let new_block_number = System::block_number().saturated_into::() + 1; + System::set_block_number(new_block_number); + + System::on_initialize(new_block_number); + ProofOfStake::on_initialize(new_block_number); + + if ProofOfStake::is_new_session() { + ProofOfStake::distribute_rewards(rewards); + } + + ProofOfStake::on_finalize(new_block_number); + System::on_finalize(new_block_number); + } +} From 6ebec8d7f9926acc0904cca419824e0daed73d0d Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 07:21:58 +0100 Subject: [PATCH 69/83] compiles --- pallets/proof-of-stake/src/mock.rs | 55 ++++++++++++++++++++++++++++- pallets/proof-of-stake/src/tests.rs | 37 +------------------ 2 files changed, 55 insertions(+), 37 deletions(-) diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index da5b30947b..6db24cd096 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -24,6 +24,7 @@ use mangata_types::{assets::CustomMetadata, Amount, Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyAdapter, MultiTokenCurrencyExtended}; use orml_traits::{asset_registry::AssetMetadata, parameter_type_with_key}; use sp_runtime::{Perbill, Percent}; +use sp_runtime::Saturating; use std::{collections::HashMap, sync::Mutex}; pub const NATIVE_CURRENCY_ID: u32 = 0; @@ -477,25 +478,57 @@ macro_rules! assert_event_emitted { }; } -fn roll_to_next_block() { +pub fn roll_to_next_block() { forward_to_block((System::block_number() + 1).saturated_into::()); } +pub fn roll_to_next_block2() where + T: pos::Config, + T: frame_system::Config +{ + let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + forward_to_block2::(new_block_number); +} + pub fn roll_to_next_session() { let current_session = ProofOfStake::session_index(); roll_to_session(current_session + 1); } +pub fn roll_to_next_session2() where + T: pos::Config, + T: frame_system::Config +{ + let current_session = ProofOfStake::session_index(); + roll_to_session2::(current_session + 1); +} + pub fn roll_to_session(n: u32) { while ProofOfStake::session_index() < n { roll_to_next_block(); } } +pub fn roll_to_session2(n: u32) where + T: pos::Config, + T: frame_system::Config +{ + while ProofOfStake::session_index() < n { + roll_to_next_block2::(); + } +} + pub fn forward_to_block(n: u32) { forward_to_block_with_custom_rewards(n, 10000); } +pub fn forward_to_block2(n: T::BlockNumber) where + T: pos::Config, + T: frame_system::Config +{ + forward_to_block_with_custom_rewards2::(n, 10000); +} + pub fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { while System::block_number().saturated_into::() < n { let new_block_number = System::block_number().saturated_into::() + 1; @@ -512,3 +545,23 @@ pub fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { System::on_finalize(new_block_number); } } + +pub fn forward_to_block_with_custom_rewards2(n: T::BlockNumber, rewards: u128) where + T: pos::Config, + T: frame_system::Config +{ + while frame_system::Pallet::::block_number() < n { + let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + frame_system::Pallet::::set_block_number(new_block_number); + + frame_system::Pallet::::on_initialize(new_block_number); + pos::Pallet::::on_initialize(new_block_number); + + if pos::Pallet::::is_new_session() { + pos::Pallet::::distribute_rewards(rewards); + } + + pos::Pallet::::on_finalize(new_block_number); + frame_system::Pallet::::on_finalize(new_block_number); + } +} diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 2a9eca7794..4f3550f096 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -53,45 +53,10 @@ fn process_all_schedules_in_current_session() { if !ProofOfStake::is_new_session() && ProofOfStake::pos() == ProofOfStake::tail() { break } - roll_to_next_block(); + roll_to_next_block2::(); } } -fn roll_to_next_block() { - forward_to_block((System::block_number() + 1).saturated_into::()); -} - -fn roll_to_next_session() { - let current_session = ProofOfStake::session_index(); - roll_to_session(current_session + 1); -} - -pub fn roll_to_session(n: u32) { - while ProofOfStake::session_index() < n { - roll_to_next_block(); - } -} - -fn forward_to_block(n: u32) { - forward_to_block_with_custom_rewards(n, 10000); -} - -fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { - while System::block_number().saturated_into::() < n { - let new_block_number = System::block_number().saturated_into::() + 1; - System::set_block_number(new_block_number); - - System::on_initialize(new_block_number); - ProofOfStake::on_initialize(new_block_number); - - if ProofOfStake::is_new_session() { - ProofOfStake::distribute_rewards(rewards); - } - - ProofOfStake::on_finalize(new_block_number); - System::on_finalize(new_block_number); - } -} #[test] #[serial] From 2f62b22f0a54ed252308dba6571a8bec7b5902ca Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 08:21:52 +0100 Subject: [PATCH 70/83] refactor method names --- pallets/proof-of-stake/src/mock.rs | 54 ++------ pallets/proof-of-stake/src/tests.rs | 186 ++++++++++++++-------------- 2 files changed, 102 insertions(+), 138 deletions(-) diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 6db24cd096..0977165361 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -478,75 +478,39 @@ macro_rules! assert_event_emitted { }; } -pub fn roll_to_next_block() { - forward_to_block((System::block_number() + 1).saturated_into::()); -} - -pub fn roll_to_next_block2() where +pub fn roll_to_next_block() where T: pos::Config, T: frame_system::Config { let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); - forward_to_block2::(new_block_number); -} - -pub fn roll_to_next_session() { - let current_session = ProofOfStake::session_index(); - roll_to_session(current_session + 1); + forward_to_block::(new_block_number); } -pub fn roll_to_next_session2() where +pub fn roll_to_next_session() where T: pos::Config, T: frame_system::Config { let current_session = ProofOfStake::session_index(); - roll_to_session2::(current_session + 1); -} - -pub fn roll_to_session(n: u32) { - while ProofOfStake::session_index() < n { - roll_to_next_block(); - } + roll_to_session::(current_session + 1); } -pub fn roll_to_session2(n: u32) where +pub fn roll_to_session(n: u32) where T: pos::Config, T: frame_system::Config { while ProofOfStake::session_index() < n { - roll_to_next_block2::(); + roll_to_next_block::(); } } -pub fn forward_to_block(n: u32) { - forward_to_block_with_custom_rewards(n, 10000); -} - -pub fn forward_to_block2(n: T::BlockNumber) where +pub fn forward_to_block(n: T::BlockNumber) where T: pos::Config, T: frame_system::Config { - forward_to_block_with_custom_rewards2::(n, 10000); -} - -pub fn forward_to_block_with_custom_rewards(n: u32, rewards: u128) { - while System::block_number().saturated_into::() < n { - let new_block_number = System::block_number().saturated_into::() + 1; - System::set_block_number(new_block_number); - - System::on_initialize(new_block_number); - ProofOfStake::on_initialize(new_block_number); - - if ProofOfStake::is_new_session() { - ProofOfStake::distribute_rewards(rewards); - } - - ProofOfStake::on_finalize(new_block_number); - System::on_finalize(new_block_number); - } + forward_to_block_with_custom_rewards::(n, 10000); } -pub fn forward_to_block_with_custom_rewards2(n: T::BlockNumber, rewards: u128) where +pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) where T: pos::Config, T: frame_system::Config { diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 4f3550f096..681131f448 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -53,7 +53,7 @@ fn process_all_schedules_in_current_session() { if !ProofOfStake::is_new_session() && ProofOfStake::pos() == ProofOfStake::tail() { break } - roll_to_next_block2::(); + roll_to_next_block::(); } } @@ -160,18 +160,18 @@ fn liquidity_rewards_three_users_burn_W() { ) .unwrap(); - forward_to_block(100); + forward_to_block::(100); mint_and_activate_tokens(3, 4, 10000); - forward_to_block(200); + forward_to_block::(200); mint_and_activate_tokens(4, 4, 10000); - forward_to_block(240); + forward_to_block::(240); ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 5000) .unwrap(); - forward_to_block(400); + forward_to_block::(400); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 95965); assert_eq!(ProofOfStake::calculate_rewards_amount(3, 4).unwrap(), 44142); @@ -212,13 +212,13 @@ fn liquidity_rewards_claim_W() { ) .unwrap(); - forward_to_block(10); - forward_to_block(90); + forward_to_block::(10); + forward_to_block::(90); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 12142); ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 2562); }); } @@ -291,23 +291,23 @@ fn liquidity_rewards_work_after_burn_W() { ) .unwrap(); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); mint_and_activate_tokens(3, 4, 10000); - forward_to_block(200); + forward_to_block::(200); mint_and_activate_tokens(4, 4, 10000); - forward_to_block(240); + forward_to_block::(240); ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(4), 4, 10000) .unwrap(); - forward_to_block(400); + forward_to_block::(400); assert_eq!(ProofOfStake::calculate_rewards_amount(4, 4).unwrap(), 948); mint_and_activate_tokens(4, 4, 20000); - forward_to_block(500); + forward_to_block::(500); assert_eq!(ProofOfStake::calculate_rewards_amount(4, 4).unwrap(), 8299); }); } @@ -343,7 +343,7 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { orml_tokens::Error::::BalanceTooLow, ); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 14704); ProofOfStake::deactivate_liquidity_for_native_rewards( @@ -510,7 +510,7 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { ) .unwrap(); - forward_to_block(10); + forward_to_block::(10); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 291); ProofOfStake::deactivate_liquidity_for_native_rewards( @@ -531,7 +531,7 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { ) .unwrap(); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 12433); ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(2), 4).unwrap(); @@ -710,7 +710,7 @@ fn rewards_storage_right_amounts_start1() { mint_and_activate_tokens(5, 4, 10000); mint_and_activate_tokens(6, 4, 10000); - forward_to_block_with_custom_rewards(100, 50000); // No clue why we considr 50k rewards per + forward_to_block_with_custom_rewards::(100, 50000); // No clue why we considr 50k rewards per assert_eq!( U256::from(u128::MAX) * U256::from(10), PromotedPoolRewards::::get().get(&4).unwrap().rewards @@ -738,7 +738,7 @@ fn rewards_storage_right_amounts_start1() { assert_eq!(rewards_info.rewards_not_yet_claimed, 0); assert_eq!(rewards_info.rewards_already_claimed, 14704); - forward_to_block_with_custom_rewards(200, 50000); + forward_to_block_with_custom_rewards::(200, 50000); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 36530); assert_eq!(ProofOfStake::calculate_rewards_amount(3, 4).unwrap(), 36530); @@ -855,7 +855,7 @@ fn rewards_storage_right_amounts_start2() { mint_and_activate_tokens(4, 4, 10000); mint_and_activate_tokens(5, 4, 10000); - forward_to_block_with_custom_rewards(100, 40000); + forward_to_block_with_custom_rewards::(100, 40000); assert_eq!( U256::from(u128::MAX) * U256::from(10), PromotedPoolRewards::::get().get(&4).unwrap().rewards @@ -870,7 +870,7 @@ fn rewards_storage_right_amounts_start2() { ProofOfStake::deactivate_liquidity_for_native_rewards(RuntimeOrigin::signed(5), 4, 5000) .unwrap(); - forward_to_block_with_custom_rewards(200, 20000); //its really weird that rewards are + forward_to_block_with_custom_rewards::(200, 20000); //its really weird that rewards are //decreased from 40k to 20k in single assert_eq!( U256::from(u128::MAX) * U256::from(20), @@ -987,7 +987,7 @@ fn rewards_storage_right_amounts_start3() { .unwrap(); mint_and_activate_tokens(3, 4, 10000); - forward_to_block_with_custom_rewards(100, 20000); + forward_to_block_with_custom_rewards::(100, 20000); let mut rewards_info = ProofOfStake::get_rewards_info(2, 4); assert_eq!(rewards_info.rewards_not_yet_claimed, 0); @@ -1070,7 +1070,7 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { ) .unwrap(); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ProofOfStake::calculate_rewards_amount(3, 4).unwrap(), 14704); ProofOfStake::claim_native_rewards(RuntimeOrigin::signed(3), 4).unwrap(); @@ -1108,12 +1108,12 @@ fn test_migrated_from_pallet_issuance() { ) .unwrap(); - forward_to_block_with_custom_rewards(9, LIQUIDITY_ISSUANCE); + forward_to_block_with_custom_rewards::(9, LIQUIDITY_ISSUANCE); assert_eq!( U256::from_dec_str("153142377820933750789374425201630124724265475").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() ); - forward_to_block_with_custom_rewards(19, LIQUIDITY_ISSUANCE); + forward_to_block_with_custom_rewards::(19, LIQUIDITY_ISSUANCE); assert_eq!( U256::from_dec_str("306284755641867501578748850403260249448530950").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() @@ -1128,7 +1128,7 @@ fn test_migrated_from_pallet_issuance() { None, ) .unwrap(); - forward_to_block_with_custom_rewards(29, LIQUIDITY_ISSUANCE); + forward_to_block_with_custom_rewards::(29, LIQUIDITY_ISSUANCE); assert_eq!( U256::from_dec_str("382855774411150916504204331316771595926557960").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() @@ -1138,7 +1138,7 @@ fn test_migrated_from_pallet_issuance() { ProofOfStake::get_pool_rewards(2).unwrap() ); - forward_to_block_with_custom_rewards(39, LIQUIDITY_ISSUANCE); + forward_to_block_with_custom_rewards::(39, LIQUIDITY_ISSUANCE); assert_eq!( U256::from_dec_str("459426793180434331429659812230282942404584970").unwrap(), ProofOfStake::get_pool_rewards(1).unwrap() @@ -1184,7 +1184,7 @@ fn claim_rewards_from_pool_that_has_been_disabled() { ) .unwrap(); - forward_to_block(10); + forward_to_block::(10); assert_eq!(ProofOfStake::calculate_rewards_amount(2, 4).unwrap(), 291); @@ -1235,7 +1235,7 @@ fn user_can_provide_3rdparty_rewards() { ) .unwrap(); - roll_to_session(5); + roll_to_session::(5); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1260,7 +1260,7 @@ fn cant_schedule_rewards_in_past() { - roll_to_session(5); + roll_to_session::(5); assert_err!( ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1495,38 +1495,38 @@ fn rewards_linked_list_removes_outdated_schedule_automatically() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(1u64)); - forward_to_block(2); + forward_to_block::(2); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(5); + forward_to_block::(5); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(11); + forward_to_block::(11); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(1u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(25); + forward_to_block::(25); assert_eq!(ScheduleListHead::::get(), Some(1u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); assert_eq!(ScheduleListPos::::get(), Some(1u64)); - forward_to_block(29); + forward_to_block::(29); assert_eq!(ScheduleListHead::::get(), Some(1u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); - forward_to_block(30); + forward_to_block::(30); assert_eq!(ScheduleListHead::::get(), None); assert_eq!(ScheduleListTail::::get(), None); assert_eq!(ScheduleListPos::::get(), None); @@ -1574,7 +1574,7 @@ fn rewards_first_schedule_from_linked_list_of_four() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(1u64)); assert_eq!(ScheduleListTail::::get(), Some(3u64)); @@ -1610,7 +1610,7 @@ fn remove_last_schedule_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(2u64)); @@ -1646,7 +1646,7 @@ fn remove_middle_schedule_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(3u64)); @@ -1682,7 +1682,7 @@ fn remove_first_few_elems_at_once_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(20); + forward_to_block::(20); assert_eq!(ScheduleListHead::::get(), Some(2u64)); assert_eq!(ScheduleListTail::::get(), Some(3u64)); @@ -1717,7 +1717,7 @@ fn remove_few_last_elems_at_once_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(1u64)); @@ -1752,7 +1752,7 @@ fn remove_few_middle_elements_from_linkedd_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(3u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(3u64)); @@ -1789,7 +1789,7 @@ fn remove_random_elements_from_linked_list() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(4u64)); - forward_to_block(21); + forward_to_block::(21); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(4u64)); @@ -1824,7 +1824,7 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(6u64)); - roll_to_session(2); + roll_to_session::(2); process_all_schedules_in_current_session(); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(6u64)); @@ -1834,7 +1834,7 @@ fn remove_random_elements_from_linked_list_over_time() { assert_eq!(RewardsSchedulesList::::get(4u64).unwrap().1, Some(6u64)); assert_eq!(RewardsSchedulesList::::get(6u64).unwrap().1, None); - roll_to_session(3); + roll_to_session::(3); process_all_schedules_in_current_session(); assert_eq!(ScheduleListHead::::get(), Some(0u64)); @@ -1871,14 +1871,14 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { assert_eq!(ScheduleListPos::::get(), None); assert_eq!(ScheduleListTail::::get(), Some(8u64)); - forward_to_block(24); + forward_to_block::(24); assert_eq!(ScheduleListHead::::get(), Some(0u64)); assert_eq!(ScheduleListTail::::get(), Some(8u64)); assert_eq!(RewardsSchedulesList::::get(0u64).unwrap().1, Some(8u64)); assert_eq!(RewardsSchedulesList::::get(8u64).unwrap().1, None); - forward_to_block(100); + forward_to_block::(100); assert_eq!(ScheduleListHead::::get(), None); assert_eq!(ScheduleListTail::::get(), None); }); @@ -1918,7 +1918,7 @@ fn number_of_active_schedules_is_limited() { Error::::TooManySchedules ); - roll_to_session(10); + roll_to_session::(10); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -1987,7 +1987,7 @@ fn reject_schedule_with_too_little_rewards_per_session() { MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(0u128); - roll_to_session(4); + roll_to_session::(4); assert_err!( ProofOfStake::reward_pool( @@ -2017,7 +2017,7 @@ fn accept_schedule_valuated_in_native_token() { let get_pool_state_mock = MockValuationApi::get_pool_state_context(); get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); - roll_to_session(4); + roll_to_session::(4); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2050,7 +2050,7 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { let get_pool_state_mock = MockValuationApi::get_pool_state_context(); get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); - roll_to_session(4); + roll_to_session::(4); assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2094,7 +2094,7 @@ fn user_can_claim_3rdparty_rewards() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2108,7 +2108,7 @@ fn user_can_claim_3rdparty_rewards() { Ok(0) ); - roll_to_session(2); + roll_to_session::(2); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, @@ -2130,7 +2130,7 @@ fn user_can_claim_3rdparty_rewards() { Ok(1000) ); - roll_to_session(3); + roll_to_session::(3); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) @@ -2177,7 +2177,7 @@ fn overlapping_3rdparty_rewards_works() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2187,7 +2187,7 @@ fn overlapping_3rdparty_rewards_works() { ) .unwrap(); - roll_to_session(5); + roll_to_session::(5); let second_reward_token_id = TokensOf::::create(&ALICE, MILLION).unwrap(); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -2206,7 +2206,7 @@ fn overlapping_3rdparty_rewards_works() { ) .unwrap(); - roll_to_session(7); + roll_to_session::(7); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( @@ -2252,7 +2252,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2262,7 +2262,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ) .unwrap(); - roll_to_session(5); + roll_to_session::(5); ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -2281,7 +2281,7 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { ) .unwrap(); - roll_to_session(7); + roll_to_session::(7); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( @@ -2327,7 +2327,7 @@ fn deactivate_3rdparty_rewards() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -2346,7 +2346,7 @@ fn deactivate_3rdparty_rewards() { ) .unwrap(); - roll_to_session(2); + roll_to_session::(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -2369,7 +2369,7 @@ fn deactivate_3rdparty_rewards() { ) .unwrap(); - roll_to_session(3); + roll_to_session::(3); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -2431,7 +2431,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(2); + roll_to_session::(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![(FIRST_LIQUIDITY_TOKEN, FIRST_REWARD_TOKEN, 1 * 1000u128),] @@ -2453,7 +2453,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(3); + roll_to_session::(3); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -2462,7 +2462,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ] ); - roll_to_session(4); + roll_to_session::(4); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), @@ -2488,7 +2488,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(5); + roll_to_session::(5); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -2514,7 +2514,7 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() ) .unwrap(); - roll_to_session(7); + roll_to_session::(7); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_all(BOB).unwrap(), vec![ @@ -2674,7 +2674,7 @@ fn liquidity_minting_liquidity_can_be_resused() { ) .unwrap(); - roll_to_session(2); + roll_to_session::(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount( @@ -3027,7 +3027,7 @@ fn can_claim_schedule_rewards() { ) .unwrap(); - forward_to_block(20); + forward_to_block::(20); assert_eq!(TokensOf::::free_balance(FIRST_REWARD_TOKEN, &BOB), 0,); assert_eq!(TokensOf::::free_balance(SECOND_REWARD_TOKEN, &BOB), 0,); @@ -3304,7 +3304,7 @@ fn claim_rewards_from_multiple_sessions_at_once() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3318,13 +3318,13 @@ fn claim_rewards_from_multiple_sessions_at_once() { Ok(0) ); - roll_to_session(2); + roll_to_session::(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1000) ); - roll_to_session(5); + roll_to_session::(5); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(4000) @@ -3364,7 +3364,7 @@ fn multi_user_rewards_distributeion_scenario() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3378,7 +3378,7 @@ fn multi_user_rewards_distributeion_scenario() { Ok(0) ); - roll_to_session(2); + roll_to_session::(2); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(CHARLIE), LIQUIDITY_TOKEN, @@ -3401,7 +3401,7 @@ fn multi_user_rewards_distributeion_scenario() { Ok(1000) ); - roll_to_session(3); + roll_to_session::(3); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), Ok(1500) @@ -3451,7 +3451,7 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_instantly() { ) .unwrap(); - roll_to_session(12); + roll_to_session::(12); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -3486,7 +3486,7 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions( ) .unwrap(); - roll_to_session(7); + roll_to_session::(7); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), LIQUIDITY_TOKEN, @@ -3496,7 +3496,7 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions( ) .unwrap(); - roll_to_session(15); + roll_to_session::(15); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -3531,7 +3531,7 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ) .unwrap(); - roll_to_session(15); + roll_to_session::(15); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), @@ -3542,7 +3542,7 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ) .unwrap(); - roll_to_session(16); + roll_to_session::(16); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -3578,7 +3578,7 @@ fn test_multiple_activations_in_same_block() { ) .unwrap(); - roll_to_session(1); + roll_to_session::(1); ProofOfStake::activate_liquidity_for_3rdparty_rewards( RuntimeOrigin::signed(BOB), @@ -3598,7 +3598,7 @@ fn test_multiple_activations_in_same_block() { ) .unwrap(); - roll_to_session(2); + roll_to_session::(2); assert_eq!( ProofOfStake::calculate_3rdparty_rewards_amount(BOB, LIQUIDITY_TOKEN, REWARD_TOKEN), @@ -3660,7 +3660,7 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { .unwrap() ); - roll_to_session(1); + roll_to_session::(1); assert_eq!( 0u128, @@ -3709,7 +3709,7 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { .unwrap() ); - roll_to_session(2); + roll_to_session::(2); assert_eq!( 15_000u128, @@ -3758,7 +3758,7 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { .unwrap() ); - roll_to_session(3); + roll_to_session::(3); assert_eq!( 15_000u128 + 10_000u128, @@ -3826,7 +3826,7 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu ) .unwrap(); - roll_to_session(2); + roll_to_session::(2); assert_eq!( 500u128, @@ -3924,7 +3924,7 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu .unwrap() ); - roll_to_session(3); + roll_to_session::(3); assert_eq!( 1000u128, @@ -4024,7 +4024,7 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu .unwrap() ); - roll_to_session(4); + roll_to_session::(4); assert_eq!( 1249u128, @@ -4133,7 +4133,7 @@ fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { let get_pool_state_mock = MockValuationApi::get_pool_state_context(); get_pool_state_mock.expect().return_const(too_small_volume); - roll_to_session(4); + roll_to_session::(4); assert_err!( ProofOfStake::reward_pool( @@ -4170,7 +4170,7 @@ fn accept_3rdparty_rewards_with_non_liq_token_and_proper_valuation() { let get_pool_state_mock = MockValuationApi::get_pool_state_context(); get_pool_state_mock.expect().return_const(min_volume); - roll_to_session(4); + roll_to_session::(4); assert_ok!( ProofOfStake::reward_pool( @@ -4207,7 +4207,7 @@ fn reject_3rdparty_rewards_with_liq_token_and_too_small_volume() { let get_reserves_mock = MockValuationApi::get_reserves_context(); get_reserves_mock.expect().return_const(Ok((9u128, 0u128))); - roll_to_session(4); + roll_to_session::(4); assert_err!( ProofOfStake::reward_pool( @@ -4243,7 +4243,7 @@ fn accept_3rdparty_rewards_with_liq_token_and_min_volume() { let get_reserves_mock = MockValuationApi::get_reserves_context(); get_reserves_mock.expect().return_const(Ok((min_req_volume(), 0u128))); - roll_to_session(4); + roll_to_session::(4); assert_ok!( ProofOfStake::reward_pool( From 7ebc15dbc7f5a64c8e57d63d157a80d5664cd8eb Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 08:26:33 +0100 Subject: [PATCH 71/83] move utils to dedicated file --- pallets/proof-of-stake/src/lib.rs | 2 + pallets/proof-of-stake/src/mock.rs | 51 -------------------------- pallets/proof-of-stake/src/tests.rs | 1 + pallets/proof-of-stake/src/utils.rs | 57 +++++++++++++++++++++++++++++ 4 files changed, 60 insertions(+), 51 deletions(-) create mode 100644 pallets/proof-of-stake/src/utils.rs diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 8e3c54d003..b76ca44555 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -148,6 +148,8 @@ mod mock; #[cfg(test)] mod tests; +mod utils; + pub(crate) const LOG_TARGET: &str = "pos"; // syntactic sugar for logging. diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 0977165361..772330b55b 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -478,54 +478,3 @@ macro_rules! assert_event_emitted { }; } -pub fn roll_to_next_block() where - T: pos::Config, - T: frame_system::Config -{ - let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); - forward_to_block::(new_block_number); -} - -pub fn roll_to_next_session() where - T: pos::Config, - T: frame_system::Config -{ - let current_session = ProofOfStake::session_index(); - roll_to_session::(current_session + 1); -} - -pub fn roll_to_session(n: u32) where - T: pos::Config, - T: frame_system::Config -{ - while ProofOfStake::session_index() < n { - roll_to_next_block::(); - } -} - -pub fn forward_to_block(n: T::BlockNumber) where - T: pos::Config, - T: frame_system::Config -{ - forward_to_block_with_custom_rewards::(n, 10000); -} - -pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) where - T: pos::Config, - T: frame_system::Config -{ - while frame_system::Pallet::::block_number() < n { - let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); - frame_system::Pallet::::set_block_number(new_block_number); - - frame_system::Pallet::::on_initialize(new_block_number); - pos::Pallet::::on_initialize(new_block_number); - - if pos::Pallet::::is_new_session() { - pos::Pallet::::distribute_rewards(rewards); - } - - pos::Pallet::::on_finalize(new_block_number); - frame_system::Pallet::::on_finalize(new_block_number); - } -} diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 681131f448..92afa8a525 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -7,6 +7,7 @@ use crate::mock::*; use frame_support::{assert_err, assert_err_ignore_postinfo, assert_ok}; use mockall::predicate::eq; use serial_test::serial; +use crate::utils::*; use mangata_support::traits::{ComputeIssuance, GetIssuance}; diff --git a/pallets/proof-of-stake/src/utils.rs b/pallets/proof-of-stake/src/utils.rs new file mode 100644 index 0000000000..3a151cefb9 --- /dev/null +++ b/pallets/proof-of-stake/src/utils.rs @@ -0,0 +1,57 @@ +use crate as pos; +use sp_runtime::Saturating; +use frame_system::{Config, Pallet}; +use frame_support::traits::Hooks; +use mangata_support::traits::LiquidityMiningApi; + +pub fn roll_to_next_block() where + T: pos::Config, + T: frame_system::Config +{ + let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + forward_to_block::(new_block_number); +} + +pub fn roll_to_next_session() where + T: pos::Config, + T: frame_system::Config +{ + let current_session = pos::Pallet::::session_index(); + roll_to_session::(current_session + 1); +} + +pub fn roll_to_session(n: u32) where + T: pos::Config, + T: frame_system::Config +{ + while pos::Pallet::::session_index() < n { + roll_to_next_block::(); + } +} + +pub fn forward_to_block(n: T::BlockNumber) where + T: pos::Config, + T: frame_system::Config +{ + forward_to_block_with_custom_rewards::(n, 10000); +} + +pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) where + T: pos::Config, + T: frame_system::Config +{ + while frame_system::Pallet::::block_number() < n { + let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + frame_system::Pallet::::set_block_number(new_block_number); + + frame_system::Pallet::::on_initialize(new_block_number); + pos::Pallet::::on_initialize(new_block_number); + + if pos::Pallet::::is_new_session() { + pos::Pallet::::distribute_rewards(rewards); + } + + pos::Pallet::::on_finalize(new_block_number); + frame_system::Pallet::::on_finalize(new_block_number); + } +} From 8ee013fe488564cb755db10719969c2f64f87715 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 18:07:55 +0100 Subject: [PATCH 72/83] few remaining failing tests --- pallets/proof-of-stake/src/benchmarking.rs | 41 +++++++++++----------- pallets/proof-of-stake/src/lib.rs | 2 ++ pallets/proof-of-stake/src/tests.rs | 1 - pallets/proof-of-stake/src/utils.rs | 11 ++++++ 4 files changed, 34 insertions(+), 21 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index 70fb8fd2c8..e7a1bdda93 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -29,27 +29,28 @@ type XykOf = ::ValuationApi; fn forward_to_next_session() where T: frame_system::Config, - T: pallet_issuance::Config, + // T: pallet_issuance::Config, T: Config, { - let current_block: u32 = frame_system::Pallet::::block_number().saturated_into::(); - - let blocks_per_session: u32 = PoS::::rewards_period(); - let target_block_nr: u32; - let target_session_nr: u32; - - if current_block == 0_u32 || current_block == 1_u32 { - target_session_nr = 1_u32; - target_block_nr = blocks_per_session; - } else { - // to fail on user trying to manage block nr on its own - assert!(current_block % blocks_per_session == 0); - target_session_nr = (current_block / blocks_per_session) + 1_u32; - target_block_nr = target_session_nr * blocks_per_session; - } - - frame_system::Pallet::::set_block_number(target_block_nr.into()); - pallet_issuance::Pallet::::compute_issuance(target_session_nr); + crate::utils::roll_to_next_session::(); + // let current_block: u32 = frame_system::Pallet::::block_number().saturated_into::(); + // + // let blocks_per_session: u32 = PoS::::rewards_period(); + // let target_block_nr: u32; + // let target_session_nr: u32; + // + // if current_block == 0_u32 || current_block == 1_u32 { + // target_session_nr = 1_u32; + // target_block_nr = blocks_per_session; + // } else { + // // to fail on user trying to manage block nr on its own + // assert!(current_block % blocks_per_session == 0); + // target_session_nr = (current_block / blocks_per_session) + 1_u32; + // target_block_nr = target_session_nr * blocks_per_session; + // } + // + // frame_system::Pallet::::set_block_number(target_block_nr.into()); + // pallet_issuance::Pallet::::compute_issuance(target_session_nr); } benchmarks! { @@ -69,7 +70,7 @@ benchmarks! { let non_native_asset_id2 : TokenId= ::Currency::create(&caller, initial_amount.into()).unwrap().into(); let liquidity_asset_id : TokenId= ::Currency::create(&caller, ((40000000000000000000_u128/2_u128) + (60000000000000000000_u128/2_u128)).into()).unwrap().into(); - PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); + PoS::::update_pool_promotion(RawOrigin::Root.into(), liquidity_asset_id, 1u8).unwrap(); assert_eq!( ::Currency::total_issuance(liquidity_asset_id.into()), diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index b76ca44555..072e99e78f 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1509,6 +1509,8 @@ impl ProofOfStakeRewardsApi for Pallet { let (rewards_info, total_available_rewards) = calc.claim_rewards().map_err(|err| Into::>::into(err))?; + // TODO: mint rewards while rolling to next session + println!( "REWARDS : {}", total_available_rewards); ::Currency::transfer( Self::native_token_id().into(), &::LiquidityMiningIssuanceVault::get(), diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 92afa8a525..9318fabc92 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -11,7 +11,6 @@ use crate::utils::*; use mangata_support::traits::{ComputeIssuance, GetIssuance}; -type TokensOf = ::Currency; fn mint_and_activate_tokens(who: AccountId, token_id: TokenId, amount: Balance) { TokensOf::::mint(token_id, &who, amount).unwrap(); diff --git a/pallets/proof-of-stake/src/utils.rs b/pallets/proof-of-stake/src/utils.rs index 3a151cefb9..f28b69b98e 100644 --- a/pallets/proof-of-stake/src/utils.rs +++ b/pallets/proof-of-stake/src/utils.rs @@ -1,9 +1,14 @@ use crate as pos; use sp_runtime::Saturating; +use sp_core::Get; use frame_system::{Config, Pallet}; use frame_support::traits::Hooks; use mangata_support::traits::LiquidityMiningApi; +type TokensOf = ::Currency; +use orml_tokens::MultiTokenCurrencyExtended; + + pub fn roll_to_next_block() where T: pos::Config, T: frame_system::Config @@ -48,6 +53,12 @@ pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) pos::Pallet::::on_initialize(new_block_number); if pos::Pallet::::is_new_session() { + TokensOf::::mint( + pos::Pallet::::native_token_id().into(), + &::LiquidityMiningIssuanceVault::get().into(), + rewards.into() + ).unwrap(); + pos::Pallet::::distribute_rewards(rewards); } From cd882ffd6fd9fa826baad789a79680a3b2b1b3fb Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 18:23:21 +0100 Subject: [PATCH 73/83] all benchmarks work --- pallets/proof-of-stake/src/benchmarking.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pallets/proof-of-stake/src/benchmarking.rs b/pallets/proof-of-stake/src/benchmarking.rs index e7a1bdda93..cc80f637a3 100644 --- a/pallets/proof-of-stake/src/benchmarking.rs +++ b/pallets/proof-of-stake/src/benchmarking.rs @@ -316,6 +316,7 @@ benchmarks! { }: activate_liquidity_for_3rdparty_rewards(RawOrigin::Signed(caller.clone().into()), liquidity_asset_id, 10_000u128, reward_token_id, None) verify { + forward_to_next_session::(); forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller, liquidity_asset_id, reward_token_id).unwrap(), @@ -334,7 +335,7 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); + let REWARDS_AMOUNT: u128 = 2u128 * ::Min3rdPartyRewardValutationPerSession::get(); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); @@ -414,7 +415,7 @@ benchmarks! { let schedules_limit = ::RewardsSchedulesLimit::get(); let caller: ::AccountId = whitelisted_caller(); let native_asset_id = ::NativeCurrencyId::get(); - let REWARDS_AMOUNT: u128 = ::Min3rdPartyRewardValutationPerSession::get(); + let REWARDS_AMOUNT: u128 = 2u128 * ::Min3rdPartyRewardValutationPerSession::get(); loop { let token_id = TokensOf::::create(&caller, REWARDS_AMOUNT.into()).unwrap().into(); @@ -450,6 +451,7 @@ benchmarks! { None ).unwrap(); + forward_to_next_session::(); forward_to_next_session::(); assert_eq!( PoS::::calculate_3rdparty_rewards_amount(caller.clone(), liquidity_asset_id, reward_token_id).unwrap(), From 817503907ed142ab6af6f48fe2b9b28c7e2cfbeb Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 1 Nov 2023 18:58:02 +0100 Subject: [PATCH 74/83] kusama-runtime benchmarks fix --- pallets/proof-of-stake/src/lib.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 072e99e78f..e4270a7e91 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -1397,19 +1397,15 @@ impl Pallet { } fn verify_rewards_min_amount(token_id: TokenId, amount_per_session: Balance) -> bool { - log!(info, "blah 1 "); if ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { - log!(info, "blah 2 "); return true; } if token_id == Into::::into(Self::native_token_id()) && amount_per_session >= T::Min3rdPartyRewardValutationPerSession::get() { - log!(info, "blah 3 "); return true; } if ::ValuationApi::valuate_non_liquidity_token( token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { - log!(info, "blah 4 "); return true; } @@ -1509,8 +1505,6 @@ impl ProofOfStakeRewardsApi for Pallet { let (rewards_info, total_available_rewards) = calc.claim_rewards().map_err(|err| Into::>::into(err))?; - // TODO: mint rewards while rolling to next session - println!( "REWARDS : {}", total_available_rewards); ::Currency::transfer( Self::native_token_id().into(), &::LiquidityMiningIssuanceVault::get(), From f5f756c88acf76e85f46f93694a000b7459b3d71 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 09:02:55 +0100 Subject: [PATCH 75/83] fix features so tests are imported correctly --- pallets/proof-of-stake/src/lib.rs | 4 ++- pallets/proof-of-stake/src/tests.rs | 39 ++++++++++++++--------------- pallets/proof-of-stake/src/utils.rs | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index e4270a7e91..492cee85d9 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -142,12 +142,14 @@ use schedule_rewards_calculator::{ mod benchmarking; + #[cfg(test)] mod mock; -#[cfg(test)] +#[cfg(all(test, not(feature="runtime-benchmarks")))] mod tests; +#[cfg(any(feature = "runtime-benchmarks", test))] mod utils; pub(crate) const LOG_TARGET: &str = "pos"; diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 9318fabc92..01d1b6f268 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -1,5 +1,4 @@ // Copyright (C) 2020 Mangata team -#![cfg(not(feature = "runtime-benchmarks"))] #![allow(non_snake_case)] use super::*; @@ -65,7 +64,7 @@ fn liquidity_rewards_single_user_mint_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -136,7 +135,7 @@ fn liquidity_rewards_three_users_burn_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -186,7 +185,7 @@ fn liquidity_rewards_claim_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -230,7 +229,7 @@ fn liquidity_rewards_promote_pool_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -248,7 +247,7 @@ fn liquidity_rewards_promote_pool_already_promoted_NW() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -268,7 +267,7 @@ fn liquidity_rewards_work_after_burn_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -319,7 +318,7 @@ fn liquidity_rewards_deactivate_transfer_controled_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -364,7 +363,7 @@ fn liquidity_rewards_deactivate_more_NW() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -400,7 +399,7 @@ fn liquidity_rewards_activate_more_NW() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -430,7 +429,7 @@ fn liquidity_rewards_calculate_rewards_pool_not_promoted() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -449,7 +448,7 @@ fn liquidity_rewards_claim_pool_not_promoted() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -483,7 +482,7 @@ fn liquidity_rewards_not_yet_claimed_already_claimed_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -548,7 +547,7 @@ fn extreme_case_pool_ratio() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -580,7 +579,7 @@ fn rewards_rounding_during_often_mint() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -671,7 +670,7 @@ fn rewards_storage_right_amounts_start1() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -816,7 +815,7 @@ fn rewards_storage_right_amounts_start2() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -953,7 +952,7 @@ fn rewards_storage_right_amounts_start3() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = 100_000_000_000_000u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -1032,7 +1031,7 @@ fn liquidity_rewards_transfered_liq_tokens_produce_rewards_W() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); @@ -1157,7 +1156,7 @@ fn claim_rewards_from_pool_that_has_been_disabled() { let max = std::u128::MAX; System::set_block_number(1); let acc_id: u128 = 2; - let amount: u128 = max; + let amount: u128 = max / 2u128; TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); TokensOf::::create(&acc_id, amount).unwrap(); diff --git a/pallets/proof-of-stake/src/utils.rs b/pallets/proof-of-stake/src/utils.rs index f28b69b98e..7c658785cc 100644 --- a/pallets/proof-of-stake/src/utils.rs +++ b/pallets/proof-of-stake/src/utils.rs @@ -5,7 +5,7 @@ use frame_system::{Config, Pallet}; use frame_support::traits::Hooks; use mangata_support::traits::LiquidityMiningApi; -type TokensOf = ::Currency; +pub type TokensOf = ::Currency; use orml_tokens::MultiTokenCurrencyExtended; From 2841e8c890af95395df1afc2e58bfa701e3260a2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 09:43:41 +0100 Subject: [PATCH 76/83] apply formatting --- pallets/proof-of-stake/src/lib.rs | 45 ++-- pallets/proof-of-stake/src/mock.rs | 10 +- pallets/proof-of-stake/src/tests.rs | 346 +++++++--------------------- pallets/proof-of-stake/src/utils.rs | 42 ++-- runtime/mangata-kusama/src/lib.rs | 3 +- runtime/mangata-rococo/src/lib.rs | 3 +- 6 files changed, 139 insertions(+), 310 deletions(-) diff --git a/pallets/proof-of-stake/src/lib.rs b/pallets/proof-of-stake/src/lib.rs index 492cee85d9..dbed364c27 100644 --- a/pallets/proof-of-stake/src/lib.rs +++ b/pallets/proof-of-stake/src/lib.rs @@ -142,11 +142,10 @@ use schedule_rewards_calculator::{ mod benchmarking; - #[cfg(test)] mod mock; -#[cfg(all(test, not(feature="runtime-benchmarks")))] +#[cfg(all(test, not(feature = "runtime-benchmarks")))] mod tests; #[cfg(any(feature = "runtime-benchmarks", test))] @@ -360,7 +359,7 @@ pub mod pallet { type RewardsSchedulesLimit: Get; /// The minimum number of rewards per session for schedule rewards type Min3rdPartyRewardValutationPerSession: Get; - type Min3rdPartyRewardVolume : Get; + type Min3rdPartyRewardVolume: Get; type WeightInfo: WeightInfo; type ValuationApi: ValutationApiTrait; } @@ -1351,10 +1350,7 @@ impl Pallet { Error::::TooLittleRewards ); - ensure!( - Self::verify_rewards_min_volume(token_id), - Error::::TooSmallVolume - ); + ensure!(Self::verify_rewards_min_volume(token_id), Error::::TooSmallVolume); RewardTokensPerPool::::insert(liquidity_token_id, token_id, ()); @@ -1399,36 +1395,43 @@ impl Pallet { } fn verify_rewards_min_amount(token_id: TokenId, amount_per_session: Balance) -> bool { - if ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { - return true; + if ::ValuationApi::valuate_liquidity_token(token_id, amount_per_session) >= + T::Min3rdPartyRewardValutationPerSession::get() + { + return true } - if token_id == Into::::into(Self::native_token_id()) && amount_per_session >= T::Min3rdPartyRewardValutationPerSession::get() { - return true; + if token_id == Into::::into(Self::native_token_id()) && + amount_per_session >= T::Min3rdPartyRewardValutationPerSession::get() + { + return true } - if ::ValuationApi::valuate_non_liquidity_token( token_id, amount_per_session) >= T::Min3rdPartyRewardValutationPerSession::get() { - return true; + if ::ValuationApi::valuate_non_liquidity_token(token_id, amount_per_session) >= + T::Min3rdPartyRewardValutationPerSession::get() + { + return true } - return false; + return false } fn verify_rewards_min_volume(token_id: TokenId) -> bool { - if token_id == Into::::into(Self::native_token_id()) { - return true; + return true } if let Some((mga_reserves, _)) = ::ValuationApi::get_pool_state(token_id) { - return mga_reserves >= T::Min3rdPartyRewardVolume::get(); + return mga_reserves >= T::Min3rdPartyRewardVolume::get() } - if let Ok((mga_reserves, _)) = ::ValuationApi::get_reserves(Self::native_token_id(), token_id){ - return mga_reserves >= T::Min3rdPartyRewardVolume::get(); - } + if let Ok((mga_reserves, _)) = + ::ValuationApi::get_reserves(Self::native_token_id(), token_id) + { + return mga_reserves >= T::Min3rdPartyRewardVolume::get() + } - return false; + return false } } diff --git a/pallets/proof-of-stake/src/mock.rs b/pallets/proof-of-stake/src/mock.rs index 772330b55b..1d542db89b 100644 --- a/pallets/proof-of-stake/src/mock.rs +++ b/pallets/proof-of-stake/src/mock.rs @@ -23,8 +23,7 @@ pub use mangata_support::traits::ProofOfStakeRewardsApi; use mangata_types::{assets::CustomMetadata, Amount, Balance, TokenId}; use orml_tokens::{MultiTokenCurrencyAdapter, MultiTokenCurrencyExtended}; use orml_traits::{asset_registry::AssetMetadata, parameter_type_with_key}; -use sp_runtime::{Perbill, Percent}; -use sp_runtime::Saturating; +use sp_runtime::{Perbill, Percent, Saturating}; use std::{collections::HashMap, sync::Mutex}; pub const NATIVE_CURRENCY_ID: u32 = 0; @@ -405,7 +404,7 @@ pub struct ExtBuilder { } fn min_req_volume() -> u128 { - <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() + <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() } impl ExtBuilder { @@ -444,7 +443,9 @@ impl ExtBuilder { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); + get_pool_state_mock + .expect() + .return_const(Some((min_req_volume(), min_req_volume()))); f() }) } @@ -477,4 +478,3 @@ macro_rules! assert_event_emitted { } }; } - diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 01d1b6f268..43720734e9 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -2,15 +2,13 @@ #![allow(non_snake_case)] use super::*; -use crate::mock::*; +use crate::{mock::*, utils::*}; use frame_support::{assert_err, assert_err_ignore_postinfo, assert_ok}; use mockall::predicate::eq; use serial_test::serial; -use crate::utils::*; use mangata_support::traits::{ComputeIssuance, GetIssuance}; - fn mint_and_activate_tokens(who: AccountId, token_id: TokenId, amount: Balance) { TokensOf::::mint(token_id, &who, amount).unwrap(); ProofOfStake::activate_liquidity_for_native_rewards( @@ -56,7 +54,6 @@ fn process_all_schedules_in_current_session() { } } - #[test] #[serial] fn liquidity_rewards_single_user_mint_W() { @@ -870,7 +867,7 @@ fn rewards_storage_right_amounts_start2() { .unwrap(); forward_to_block_with_custom_rewards::(200, 20000); //its really weird that rewards are - //decreased from 40k to 20k in single + //decreased from 40k to 20k in single assert_eq!( U256::from(u128::MAX) * U256::from(20), PromotedPoolRewards::::get().get(&4).unwrap().rewards @@ -1212,12 +1209,10 @@ const BOB: u128 = 3; const CHARLIE: u128 = 4; const EVE: u128 = 5; - fn min_req_volume() -> u128 { - <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() + <::Min3rdPartyRewardValutationPerSession as sp_core::Get>::get() } - #[test] #[serial] fn user_can_provide_3rdparty_rewards() { @@ -1251,14 +1246,9 @@ fn user_can_provide_3rdparty_rewards() { fn cant_schedule_rewards_in_past() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - roll_to_session::(5); assert_err!( ProofOfStake::reward_pool( @@ -1325,14 +1315,9 @@ fn cannot_reward_unexisting_pool() { fn rewards_are_stored_in_pallet_account() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - assert_eq!( TokensOf::::free_balance(REWARD_TOKEN, &Pallet::::pallet_account()), 0 @@ -1360,14 +1345,9 @@ fn rewards_are_stored_in_pallet_account() { fn rewards_schedule_is_stored() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1400,14 +1380,9 @@ fn rewards_schedule_is_stored() { fn rewards_linked_list_insert_multiple_schedules() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1463,14 +1438,9 @@ fn rewards_linked_list_insert_multiple_schedules() { fn rewards_linked_list_removes_outdated_schedule_automatically() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 2 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - assert_ok!(ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -1552,14 +1522,9 @@ fn insert_schedule_ending_at_session(n: u32) { fn rewards_first_schedule_from_linked_list_of_four() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); @@ -1588,14 +1553,9 @@ fn rewards_first_schedule_from_linked_list_of_four() { fn remove_last_schedule_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); @@ -1624,14 +1584,9 @@ fn remove_last_schedule_from_linked_list() { fn remove_middle_schedule_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(2); @@ -1660,14 +1615,9 @@ fn remove_middle_schedule_from_linked_list() { fn remove_first_few_elems_at_once_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(2); @@ -1695,14 +1645,9 @@ fn remove_first_few_elems_at_once_from_linked_list() { fn remove_few_last_elems_at_once_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); @@ -1730,14 +1675,9 @@ fn remove_few_last_elems_at_once_from_linked_list() { fn remove_few_middle_elements_from_linkedd_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 4 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(1); @@ -1765,14 +1705,9 @@ fn remove_few_middle_elements_from_linkedd_list() { fn remove_random_elements_from_linked_list() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 5 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(2); insert_schedule_ending_at_session(1); insert_schedule_ending_at_session(2); @@ -1803,14 +1738,9 @@ fn remove_random_elements_from_linked_list() { fn remove_random_elements_from_linked_list_over_time() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 7 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(3); // 0 insert_schedule_ending_at_session(2); // 1 insert_schedule_ending_at_session(1); // 2 @@ -1848,14 +1778,9 @@ fn remove_random_elements_from_linked_list_over_time() { fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, 10 * REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - insert_schedule_ending_at_session(3); // 0 insert_schedule_ending_at_session(1); // 1 insert_schedule_ending_at_session(1); // 1 @@ -1887,46 +1812,44 @@ fn remove_lot_of_schedules_from_linked_list_in_single_iteration() { #[ignore] #[serial] fn number_of_active_schedules_is_limited() { - ExtBuilder::new().issue(ALICE, REWARD_TOKEN, MILLION).execute_with_default_mocks(|| { - System::set_block_number(1); - + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, MILLION) + .execute_with_default_mocks(|| { + System::set_block_number(1); + let max_schedules: u32 = + <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); + for i in 0..(max_schedules) { + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + (5u32 + i).into() + )); + } + assert_err!( + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 100u32.into() + ), + Error::::TooManySchedules + ); + roll_to_session::(10); - let max_schedules: u32 = - <::RewardsSchedulesLimit as sp_core::Get<_>>::get(); - for i in 0..(max_schedules) { assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - (5u32 + i).into() - )); - } - - assert_err!( - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, REWARD_TOKEN, REWARD_AMOUNT, 100u32.into() - ), - Error::::TooManySchedules - ); - - roll_to_session::(10); - - assert_ok!(ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - REWARD_AMOUNT, - 100u32.into() - )); - }); + )); + }); } #[test] @@ -1934,14 +1857,9 @@ fn number_of_active_schedules_is_limited() { fn duplicated_schedules_works() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - assert_eq!(ScheduleListHead::::get(), None); assert_eq!(ScheduleListTail::::get(), None); @@ -2014,7 +1932,9 @@ fn accept_schedule_valuated_in_native_token() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); + get_pool_state_mock + .expect() + .return_const(Some((min_req_volume(), min_req_volume()))); roll_to_session::(4); @@ -2047,7 +1967,9 @@ fn accept_schedule_valuated_in_token_paired_with_native_token() { MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); + get_pool_state_mock + .expect() + .return_const(Some((min_req_volume(), min_req_volume()))); roll_to_session::(4); @@ -2069,15 +1991,9 @@ fn user_can_claim_3rdparty_rewards() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); @@ -2159,7 +2075,9 @@ fn overlapping_3rdparty_rewards_works() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); + get_pool_state_mock + .expect() + .return_const(Some((min_req_volume(), min_req_volume()))); let first_reward_token = TokensOf::::create(&ALICE, MILLION).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 200).unwrap(); @@ -2234,14 +2152,9 @@ fn reuse_activated_liquiddity_tokens_for_multiple_3rdparty_schedules() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 200) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -2309,14 +2222,9 @@ fn deactivate_3rdparty_rewards() { .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -2410,7 +2318,9 @@ fn calculate_and_claim_rewards_from_multiple_schedules_using_single_liquidity() valuate_liquidity_token_mock.expect().return_const(11u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); - get_pool_state_mock.expect().return_const(Some((min_req_volume(),min_req_volume()))); + get_pool_state_mock + .expect() + .return_const(Some((min_req_volume(), min_req_volume()))); System::set_block_number(1); ProofOfStake::reward_pool( @@ -2638,14 +2548,9 @@ fn liquidity_minting_liquidity_can_be_resused() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); ProofOfStake::reward_pool( @@ -2699,14 +2604,9 @@ fn fail_to_transfer_tokens_that_has_been_partially_deactivated() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); ProofOfStake::reward_pool( @@ -2784,14 +2684,9 @@ fn when_liquidity_mining_is_reused_it_is_unlocked_properly() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); ProofOfStake::reward_pool( @@ -2883,14 +2778,9 @@ fn liquidity_can_be_deactivated_when_all_reward_participation_were_deactivated() .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) .unwrap(); ProofOfStake::reward_pool( @@ -2981,12 +2871,7 @@ fn can_claim_schedule_rewards() { .issue(ALICE, FIRST_REWARD_TOKEN, REWARD_AMOUNT) .issue(ALICE, SECOND_REWARD_TOKEN, 100_000u128) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { - - - - System::set_block_number(1); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) @@ -3130,12 +3015,7 @@ fn can_not_provide_liquidity_for_schedule_rewards_when_its_only_activated_for_li ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { - - - - System::set_block_number(1); ProofOfStake::update_pool_promotion(RuntimeOrigin::root(), LIQUIDITY_TOKEN, 1u8) @@ -3160,15 +3040,9 @@ fn can_not_provide_liquidity_for_mining_rewards_when_its_only_activated_for_sche ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -3227,15 +3101,9 @@ fn unsuccessul_activate_deactivate_calls_charges_fees() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - let activate_call = mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { liquidity_token_id: LIQUIDITY_TOKEN, @@ -3279,15 +3147,9 @@ fn claim_rewards_from_multiple_sessions_at_once() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); @@ -3339,15 +3201,9 @@ fn multi_user_rewards_distributeion_scenario() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - TokensOf::::mint(LIQUIDITY_TOKEN, &BOB, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &CHARLIE, 100).unwrap(); TokensOf::::mint(LIQUIDITY_TOKEN, &EVE, 100).unwrap(); @@ -3422,15 +3278,9 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_instantly() { ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - let amount = 10_000u128; ProofOfStake::reward_pool( @@ -3465,15 +3315,9 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_after_few_sessions( ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - let amount = 10_000u128; ProofOfStake::reward_pool( @@ -3510,15 +3354,9 @@ fn test_all_scheduled_rewards_are_distributed_when_activated_schedule_is_finishe ExtBuilder::new() .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - let amount = 10_000u128; ProofOfStake::reward_pool( @@ -3557,15 +3395,9 @@ fn test_multiple_activations_in_same_block() { .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - - let amount = 10_000u128; ProofOfStake::reward_pool( @@ -3614,14 +3446,9 @@ fn rewards_are_available_in_next_session_after_rewards_are_provided() { .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), REWARDED_PAIR, @@ -3790,14 +3617,9 @@ fn multiple_activations_and_deactivations_from_multiple_users_on_the_same_schedu .issue(BOB, LIQUIDITY_TOKEN, 100) .issue(CHARLIE, LIQUIDITY_TOKEN, 100) .issue(EVE, LIQUIDITY_TOKEN, 100) - .execute_with_default_mocks(|| { System::set_block_number(1); - - - - /// 1000 rewards per session ProofOfStake::reward_pool( RuntimeOrigin::signed(ALICE), @@ -4109,7 +3931,6 @@ fn activity_for_schedule_rewards_can_be_activated_only_after_pool_is_rewarded_fo }); } - #[test] #[serial] fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { @@ -4118,7 +3939,7 @@ fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { .build() .execute_with(|| { System::set_block_number(1); - let too_small_volume = Some((min_req_volume()-1,min_req_volume()-1)); + let too_small_volume = Some((min_req_volume() - 1, min_req_volume() - 1)); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -4126,7 +3947,8 @@ fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); - let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + let valuate_non_liquidity_token_mock = + MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); @@ -4135,15 +3957,15 @@ fn reject_3rdparty_rewards_with_non_liq_token_and_too_small_volume() { roll_to_session::(4); assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - 10, - 5u32.into() - ), - Error::::TooSmallVolume - ); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + Error::::TooSmallVolume + ); }); } @@ -4155,7 +3977,7 @@ fn accept_3rdparty_rewards_with_non_liq_token_and_proper_valuation() { .build() .execute_with(|| { System::set_block_number(1); - let min_volume = Some((min_req_volume(),min_req_volume())); + let min_volume = Some((min_req_volume(), min_req_volume())); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -4163,7 +3985,8 @@ fn accept_3rdparty_rewards_with_non_liq_token_and_proper_valuation() { let valuate_liquidity_token_mock = MockValuationApi::valuate_liquidity_token_context(); valuate_liquidity_token_mock.expect().return_const(0u128); - let valuate_non_liquidity_token_mock = MockValuationApi::valuate_non_liquidity_token_context(); + let valuate_non_liquidity_token_mock = + MockValuationApi::valuate_non_liquidity_token_context(); valuate_non_liquidity_token_mock.expect().return_const(10u128); let get_pool_state_mock = MockValuationApi::get_pool_state_context(); @@ -4171,19 +3994,16 @@ fn accept_3rdparty_rewards_with_non_liq_token_and_proper_valuation() { roll_to_session::(4); - assert_ok!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - 10, - 5u32.into() - ), - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ),); }); } - #[test] #[serial] fn reject_3rdparty_rewards_with_liq_token_and_too_small_volume() { @@ -4192,7 +4012,7 @@ fn reject_3rdparty_rewards_with_liq_token_and_too_small_volume() { .build() .execute_with(|| { System::set_block_number(1); - let too_small_volume = Some((min_req_volume()-1,min_req_volume()-1)); + let too_small_volume = Some((min_req_volume() - 1, min_req_volume() - 1)); let get_liquidity_asset_mock = MockValuationApi::get_liquidity_asset_context(); get_liquidity_asset_mock.expect().return_const(Ok(LIQUIDITY_TOKEN)); @@ -4209,15 +4029,15 @@ fn reject_3rdparty_rewards_with_liq_token_and_too_small_volume() { roll_to_session::(4); assert_err!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - 10, - 5u32.into() - ), - Error::::TooSmallVolume - ); + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ), + Error::::TooSmallVolume + ); }); } @@ -4244,14 +4064,12 @@ fn accept_3rdparty_rewards_with_liq_token_and_min_volume() { roll_to_session::(4); - assert_ok!( - ProofOfStake::reward_pool( - RuntimeOrigin::signed(ALICE), - REWARDED_PAIR, - REWARD_TOKEN, - 10, - 5u32.into() - ), - ); + assert_ok!(ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + 10, + 5u32.into() + ),); }); } diff --git a/pallets/proof-of-stake/src/utils.rs b/pallets/proof-of-stake/src/utils.rs index 7c658785cc..552618d632 100644 --- a/pallets/proof-of-stake/src/utils.rs +++ b/pallets/proof-of-stake/src/utils.rs @@ -1,52 +1,57 @@ use crate as pos; -use sp_runtime::Saturating; -use sp_core::Get; -use frame_system::{Config, Pallet}; use frame_support::traits::Hooks; +use frame_system::{Config, Pallet}; use mangata_support::traits::LiquidityMiningApi; +use sp_core::Get; +use sp_runtime::Saturating; pub type TokensOf = ::Currency; use orml_tokens::MultiTokenCurrencyExtended; - -pub fn roll_to_next_block() where +pub fn roll_to_next_block() +where T: pos::Config, - T: frame_system::Config + T: frame_system::Config, { - let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); forward_to_block::(new_block_number); } -pub fn roll_to_next_session() where +pub fn roll_to_next_session() +where T: pos::Config, - T: frame_system::Config + T: frame_system::Config, { let current_session = pos::Pallet::::session_index(); roll_to_session::(current_session + 1); } -pub fn roll_to_session(n: u32) where +pub fn roll_to_session(n: u32) +where T: pos::Config, - T: frame_system::Config + T: frame_system::Config, { while pos::Pallet::::session_index() < n { roll_to_next_block::(); } } -pub fn forward_to_block(n: T::BlockNumber) where +pub fn forward_to_block(n: T::BlockNumber) +where T: pos::Config, - T: frame_system::Config + T: frame_system::Config, { forward_to_block_with_custom_rewards::(n, 10000); } -pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) where +pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) +where T: pos::Config, - T: frame_system::Config + T: frame_system::Config, { while frame_system::Pallet::::block_number() < n { - let new_block_number = frame_system::Pallet::::block_number().saturating_add(1u32.into()); + let new_block_number = + frame_system::Pallet::::block_number().saturating_add(1u32.into()); frame_system::Pallet::::set_block_number(new_block_number); frame_system::Pallet::::on_initialize(new_block_number); @@ -56,8 +61,9 @@ pub fn forward_to_block_with_custom_rewards(n: T::BlockNumber, rewards: u128) TokensOf::::mint( pos::Pallet::::native_token_id().into(), &::LiquidityMiningIssuanceVault::get().into(), - rewards.into() - ).unwrap(); + rewards.into(), + ) + .unwrap(); pos::Pallet::::distribute_rewards(rewards); } diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index cbd2ee430b..35d91d2965 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -277,7 +277,8 @@ impl pallet_proof_of_stake::Config for Runtime { type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; - type Min3rdPartyRewardValutationPerSession = cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; + type Min3rdPartyRewardValutationPerSession = + cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; type Min3rdPartyRewardVolume = cfg::pallet_proof_of_stake::Min3rdPartyRewardVolume; type ValuationApi = Xyk; } diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index e7178cfc5a..37c7ddd39d 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -277,7 +277,8 @@ impl pallet_proof_of_stake::Config for Runtime { type RewardsDistributionPeriod = cfg::SessionLenghtOf; type WeightInfo = weights::pallet_proof_of_stake_weights::ModuleWeight; type RewardsSchedulesLimit = cfg::pallet_proof_of_stake::RewardsSchedulesLimit; - type Min3rdPartyRewardValutationPerSession = cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; + type Min3rdPartyRewardValutationPerSession = + cfg::pallet_proof_of_stake::Min3rdPartyRewardValutationPerSession; type Min3rdPartyRewardVolume = cfg::pallet_proof_of_stake::Min3rdPartyRewardVolume; type ValuationApi = Xyk; } From 03be574ad197de5a8d08dac1ac2e12b93bf593bf Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 10:48:02 +0100 Subject: [PATCH 77/83] fix test for that verifies that fees are not charged on successful activations/deactivations --- pallets/proof-of-stake/src/tests.rs | 55 +++++++++++++++++++---------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/pallets/proof-of-stake/src/tests.rs b/pallets/proof-of-stake/src/tests.rs index 43720734e9..0f5c0fe6d0 100644 --- a/pallets/proof-of-stake/src/tests.rs +++ b/pallets/proof-of-stake/src/tests.rs @@ -3068,31 +3068,48 @@ use frame_support::dispatch::{GetDispatchInfo, Pays}; use sp_runtime::{traits::Dispatchable, Permill}; #[test] -#[ignore] #[serial] fn activate_deactivate_calls_are_free_of_charge() { - ExtBuilder::new().execute_with_default_mocks(|| { - System::set_block_number(1); + ExtBuilder::new() + .issue(ALICE, REWARD_TOKEN, REWARD_AMOUNT) + .issue(BOB, LIQUIDITY_TOKEN, 100) + .execute_with_default_mocks(|| { + System::set_block_number(1); + + ProofOfStake::reward_pool( + RuntimeOrigin::signed(ALICE), + REWARDED_PAIR, + REWARD_TOKEN, + REWARD_AMOUNT, + 10u32.into(), + ) + .unwrap(); - let activate_call = - mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { - liquidity_token_id: LIQUIDITY_TOKEN, - amount: 100, - reward_token: REWARD_TOKEN, - use_balance_from: None, - }); + let activate_call = + mock::RuntimeCall::ProofOfStake(Call::activate_liquidity_for_3rdparty_rewards { + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + use_balance_from: None, + }); - let deactivate_call = - mock::RuntimeCall::ProofOfStake(Call::deactivate_liquidity_for_3rdparty_rewards { - liquidity_token_id: LIQUIDITY_TOKEN, - amount: 100, - reward_token: REWARD_TOKEN, - }); + let deactivate_call = + mock::RuntimeCall::ProofOfStake(Call::deactivate_liquidity_for_3rdparty_rewards { + liquidity_token_id: LIQUIDITY_TOKEN, + amount: 100, + reward_token: REWARD_TOKEN, + }); - assert_eq!(activate_call.get_dispatch_info().pays_fee, Pays::No); + assert_eq!( + activate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap().pays_fee, + Pays::No + ); - assert_eq!(deactivate_call.get_dispatch_info().pays_fee, Pays::No); - }); + assert_eq!( + deactivate_call.dispatch(RuntimeOrigin::signed(BOB)).unwrap().pays_fee, + Pays::No + ); + }); } #[test] From 0c378676d2dcaa6ee8ea63a3f37d3ecfa607d8cd Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 12:26:34 +0100 Subject: [PATCH 78/83] align --- Cargo.lock | 283 ++++++- Cargo.toml | 2205 ++++++++++++++++++++++++++-------------------------- 2 files changed, 1360 insertions(+), 1128 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1102437ef3..ef57fb35bb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -554,6 +554,7 @@ dependencies = [ [[package]] name = "binary-merkle-tree" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "hash-db 0.16.0", "log", @@ -1099,7 +1100,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -2611,6 +2612,7 @@ dependencies = [ [[package]] name = "extrinsic-shuffler" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "derive_more", "log", @@ -2779,6 +2781,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "fork-tree" version = "3.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", ] @@ -2801,6 +2804,7 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "frame-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-support-procedural", @@ -2826,6 +2830,7 @@ dependencies = [ [[package]] name = "frame-benchmarking-cli" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "Inflector", "array-bytes 4.2.0", @@ -2878,6 +2883,7 @@ dependencies = [ [[package]] name = "frame-election-provider-solution-type" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2888,6 +2894,7 @@ dependencies = [ [[package]] name = "frame-election-provider-support" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-election-provider-solution-type", "frame-support", @@ -2904,6 +2911,7 @@ dependencies = [ [[package]] name = "frame-executive" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "aquamarine", "extrinsic-shuffler", @@ -2937,6 +2945,7 @@ dependencies = [ [[package]] name = "frame-remote-externalities" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "log", @@ -2952,6 +2961,7 @@ dependencies = [ [[package]] name = "frame-support" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "bitflags", "environmental", @@ -2985,6 +2995,7 @@ dependencies = [ [[package]] name = "frame-support-procedural" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "Inflector", "cfg-expr", @@ -2999,6 +3010,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support-procedural-tools-derive", "proc-macro-crate", @@ -3010,6 +3022,7 @@ dependencies = [ [[package]] name = "frame-support-procedural-tools-derive" version = "3.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro2", "quote", @@ -3019,6 +3032,7 @@ dependencies = [ [[package]] name = "frame-system" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "extrinsic-shuffler", "frame-support", @@ -3038,6 +3052,22 @@ dependencies = [ [[package]] name = "frame-system-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" +dependencies = [ + "frame-benchmarking", + "frame-support", + "frame-system", + "parity-scale-codec", + "scale-info", + "sp-core", + "sp-runtime", + "sp-std", +] + +[[package]] +name = "frame-system-benchmarking" +version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "frame-benchmarking", "frame-support", @@ -3052,6 +3082,7 @@ dependencies = [ [[package]] name = "frame-system-rpc-runtime-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "sp-api", @@ -3060,6 +3091,7 @@ dependencies = [ [[package]] name = "frame-try-runtime" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "parity-scale-codec", @@ -4112,7 +4144,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -4956,7 +4988,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -5080,7 +5112,7 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-aura", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", "sc-executor", "sc-keystore", "sc-network", @@ -5146,7 +5178,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance/substrate?branch=mangata-dev)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -5240,6 +5272,7 @@ dependencies = [ [[package]] name = "mangata-support" version = "0.1.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "mangata-types", @@ -5252,6 +5285,7 @@ dependencies = [ [[package]] name = "mangata-types" version = "0.1.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -5419,6 +5453,7 @@ dependencies = [ [[package]] name = "mmr-gadget" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "log", @@ -5438,6 +5473,7 @@ dependencies = [ [[package]] name = "mmr-rpc" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "anyhow", "jsonrpsee", @@ -6075,6 +6111,7 @@ dependencies = [ [[package]] name = "pallet-aura" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6090,6 +6127,7 @@ dependencies = [ [[package]] name = "pallet-authority-discovery" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6105,6 +6143,7 @@ dependencies = [ [[package]] name = "pallet-authorship" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6118,6 +6157,7 @@ dependencies = [ [[package]] name = "pallet-babe" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6141,6 +6181,7 @@ dependencies = [ [[package]] name = "pallet-bags-list" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6160,6 +6201,7 @@ dependencies = [ [[package]] name = "pallet-balances" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6174,6 +6216,7 @@ dependencies = [ [[package]] name = "pallet-beefy" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6192,9 +6235,10 @@ dependencies = [ [[package]] name = "pallet-beefy-mmr" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", - "binary-merkle-tree 4.0.0-dev", + "binary-merkle-tree 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "frame-support", "frame-system", "log", @@ -6247,6 +6291,7 @@ dependencies = [ [[package]] name = "pallet-bounties" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6264,6 +6309,7 @@ dependencies = [ [[package]] name = "pallet-child-bounties" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6282,6 +6328,7 @@ dependencies = [ [[package]] name = "pallet-collective" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6298,6 +6345,7 @@ dependencies = [ [[package]] name = "pallet-collective-mangata" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6314,6 +6362,7 @@ dependencies = [ [[package]] name = "pallet-conviction-voting" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6330,7 +6379,6 @@ dependencies = [ [[package]] name = "pallet-crowdloan-rewards" version = "0.6.0" -source = "git+https://github.com/mangata-finance//crowdloan-rewards?branch=mangata-dev#93f22908087bf475bf1021bc9c3337fefd00fb39" dependencies = [ "ed25519-dalek", "frame-benchmarking", @@ -6354,6 +6402,7 @@ dependencies = [ [[package]] name = "pallet-democracy" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6371,13 +6420,14 @@ dependencies = [ [[package]] name = "pallet-election-provider-multi-phase" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", "frame-support", "frame-system", "log", - "pallet-election-provider-support-benchmarking 4.0.0-dev", + "pallet-election-provider-support-benchmarking 4.0.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "parity-scale-codec", "rand 0.8.5", "scale-info", @@ -6393,6 +6443,7 @@ dependencies = [ [[package]] name = "pallet-election-provider-support-benchmarking" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6418,6 +6469,7 @@ dependencies = [ [[package]] name = "pallet-elections-phragmen" version = "5.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6435,6 +6487,7 @@ dependencies = [ [[package]] name = "pallet-fast-unstake" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -6481,6 +6534,7 @@ dependencies = [ [[package]] name = "pallet-grandpa" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6503,6 +6557,7 @@ dependencies = [ [[package]] name = "pallet-identity" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "enumflags2", "frame-benchmarking", @@ -6518,6 +6573,7 @@ dependencies = [ [[package]] name = "pallet-im-online" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6537,6 +6593,7 @@ dependencies = [ [[package]] name = "pallet-indices" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6605,6 +6662,7 @@ dependencies = [ [[package]] name = "pallet-membership" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6621,6 +6679,7 @@ dependencies = [ [[package]] name = "pallet-mmr" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6667,6 +6726,7 @@ dependencies = [ [[package]] name = "pallet-multisig" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6682,6 +6742,7 @@ dependencies = [ [[package]] name = "pallet-nis" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6697,6 +6758,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools" version = "1.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6733,6 +6795,7 @@ dependencies = [ [[package]] name = "pallet-nomination-pools-runtime-api" version = "1.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "pallet-nomination-pools", "parity-scale-codec", @@ -6743,6 +6806,7 @@ dependencies = [ [[package]] name = "pallet-offences" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6783,6 +6847,7 @@ dependencies = [ [[package]] name = "pallet-preimage" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6836,6 +6901,7 @@ dependencies = [ [[package]] name = "pallet-proxy" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6850,6 +6916,7 @@ dependencies = [ [[package]] name = "pallet-ranked-collective" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6867,6 +6934,7 @@ dependencies = [ [[package]] name = "pallet-recovery" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6881,6 +6949,7 @@ dependencies = [ [[package]] name = "pallet-referenda" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "assert_matches", "frame-benchmarking", @@ -6899,6 +6968,7 @@ dependencies = [ [[package]] name = "pallet-root-testing" version = "1.0.0-dev" +source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" dependencies = [ "frame-support", "frame-system", @@ -6913,6 +6983,7 @@ dependencies = [ [[package]] name = "pallet-scheduler" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -6929,6 +7000,7 @@ dependencies = [ [[package]] name = "pallet-session" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6965,6 +7037,7 @@ dependencies = [ [[package]] name = "pallet-society" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -6978,6 +7051,7 @@ dependencies = [ [[package]] name = "pallet-staking" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-election-provider-support", @@ -7000,6 +7074,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-curve" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -7010,6 +7085,7 @@ dependencies = [ [[package]] name = "pallet-staking-reward-fn" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "log", "sp-arithmetic", @@ -7027,6 +7103,7 @@ dependencies = [ [[package]] name = "pallet-state-trie-migration" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7043,6 +7120,7 @@ dependencies = [ [[package]] name = "pallet-sudo" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -7056,6 +7134,7 @@ dependencies = [ [[package]] name = "pallet-sudo-mangata" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -7087,6 +7166,7 @@ dependencies = [ [[package]] name = "pallet-timestamp" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7104,6 +7184,7 @@ dependencies = [ [[package]] name = "pallet-tips" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7122,6 +7203,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -7137,6 +7219,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-support", "frame-system", @@ -7152,6 +7235,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "jsonrpsee", "pallet-transaction-payment-mangata-rpc-runtime-api", @@ -7167,6 +7251,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-mangata-rpc-runtime-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "pallet-transaction-payment-mangata", "parity-scale-codec", @@ -7178,6 +7263,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "jsonrpsee", "pallet-transaction-payment-rpc-runtime-api", @@ -7193,6 +7279,7 @@ dependencies = [ [[package]] name = "pallet-transaction-payment-rpc-runtime-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "pallet-transaction-payment", "parity-scale-codec", @@ -7204,6 +7291,7 @@ dependencies = [ [[package]] name = "pallet-treasury" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7220,6 +7308,7 @@ dependencies = [ [[package]] name = "pallet-utility" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7235,6 +7324,7 @@ dependencies = [ [[package]] name = "pallet-utility-mangata" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7250,6 +7340,7 @@ dependencies = [ [[package]] name = "pallet-vesting" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7264,6 +7355,7 @@ dependencies = [ [[package]] name = "pallet-vesting-mangata" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7279,6 +7371,7 @@ dependencies = [ [[package]] name = "pallet-whitelist" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-benchmarking", "frame-support", @@ -7381,6 +7474,7 @@ dependencies = [ [[package]] name = "parachain-staking" version = "3.0.0" +source = "git+https://github.com/mangata-finance//moonbeam?branch=feature/3rdparty-rewards#508b9d4bf3940fdb6e984d84d07da8367baea915" dependencies = [ "aquamarine", "frame-benchmarking", @@ -8498,7 +8592,7 @@ dependencies = [ "sc-consensus-beefy", "sc-consensus-beefy-rpc", "sc-consensus-epochs", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "sc-consensus-grandpa-rpc", "sc-rpc", "sc-sync-state-rpc", @@ -8525,7 +8619,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -8789,7 +8883,7 @@ dependencies = [ "sc-consensus", "sc-consensus-babe", "sc-consensus-beefy", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "sc-consensus-slots", "sc-executor", "sc-keystore", @@ -8952,7 +9046,7 @@ dependencies = [ "sc-client-api", "sc-consensus", "sc-consensus-babe", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "sc-executor", "sc-network", "sc-service", @@ -9657,7 +9751,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -10007,6 +10101,7 @@ dependencies = [ [[package]] name = "sc-allocator" version = "4.1.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "log", "sp-core", @@ -10017,6 +10112,7 @@ dependencies = [ [[package]] name = "sc-authority-discovery" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -10044,6 +10140,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "futures-timer", @@ -10066,6 +10163,7 @@ dependencies = [ [[package]] name = "sc-basic-authorship-ver" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "aquamarine", "futures", @@ -10091,6 +10189,7 @@ dependencies = [ [[package]] name = "sc-block-builder" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "sc-client-api", @@ -10105,6 +10204,7 @@ dependencies = [ [[package]] name = "sc-block-builder-ver" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "aquamarine", "extrinsic-shuffler", @@ -10125,6 +10225,7 @@ dependencies = [ [[package]] name = "sc-chain-spec" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "memmap2", "sc-chain-spec-derive", @@ -10143,6 +10244,7 @@ dependencies = [ [[package]] name = "sc-chain-spec-derive" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -10153,6 +10255,7 @@ dependencies = [ [[package]] name = "sc-cli" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "chrono", @@ -10192,6 +10295,7 @@ dependencies = [ [[package]] name = "sc-client-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "fnv", "futures", @@ -10217,6 +10321,7 @@ dependencies = [ [[package]] name = "sc-client-db" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "hash-db 0.16.0", "kvdb", @@ -10242,6 +10347,7 @@ dependencies = [ [[package]] name = "sc-consensus" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -10266,6 +10372,7 @@ dependencies = [ [[package]] name = "sc-consensus-aura" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -10294,6 +10401,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "fork-tree", @@ -10334,6 +10442,7 @@ dependencies = [ [[package]] name = "sc-consensus-babe-rpc" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "jsonrpsee", @@ -10355,6 +10464,7 @@ dependencies = [ [[package]] name = "sc-consensus-beefy" version = "4.0.0-dev" +source = "git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40#98f2e3451c9143278ec53c6718940aeabcd3b68a" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10408,6 +10518,7 @@ dependencies = [ [[package]] name = "sc-consensus-epochs" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "fork-tree", "parity-scale-codec", @@ -10420,6 +10531,47 @@ dependencies = [ [[package]] name = "sc-consensus-grandpa" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" +dependencies = [ + "ahash 0.8.3", + "array-bytes 4.2.0", + "async-trait", + "dyn-clone", + "finality-grandpa", + "fork-tree", + "futures", + "futures-timer", + "log", + "parity-scale-codec", + "parking_lot 0.12.1", + "rand 0.8.5", + "sc-block-builder", + "sc-chain-spec", + "sc-client-api", + "sc-consensus", + "sc-network", + "sc-network-common", + "sc-network-gossip", + "sc-telemetry", + "sc-utils", + "serde_json", + "sp-api", + "sp-application-crypto", + "sp-arithmetic", + "sp-blockchain", + "sp-consensus", + "sp-consensus-grandpa", + "sp-core", + "sp-keystore", + "sp-runtime", + "substrate-prometheus-endpoint", + "thiserror", +] + +[[package]] +name = "sc-consensus-grandpa" +version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance/substrate?branch=mangata-dev#afd05d5ed525572ed1b6d6a19aeac2465f552e1f" dependencies = [ "ahash 0.8.3", "array-bytes 4.2.0", @@ -10467,7 +10619,7 @@ dependencies = [ "log", "parity-scale-codec", "sc-client-api", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "sc-rpc", "serde", "sp-blockchain", @@ -10479,6 +10631,7 @@ dependencies = [ [[package]] name = "sc-consensus-slots" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -10503,6 +10656,7 @@ dependencies = [ [[package]] name = "sc-executor" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "lru 0.8.1", "parity-scale-codec", @@ -10526,6 +10680,7 @@ dependencies = [ [[package]] name = "sc-executor-common" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "sc-allocator", "sp-maybe-compressed-blob", @@ -10538,6 +10693,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmi" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "log", "sc-allocator", @@ -10550,6 +10706,7 @@ dependencies = [ [[package]] name = "sc-executor-wasmtime" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "anyhow", "cfg-if", @@ -10567,6 +10724,7 @@ dependencies = [ [[package]] name = "sc-informant" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ansi_term", "futures", @@ -10582,6 +10740,7 @@ dependencies = [ [[package]] name = "sc-keystore" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10596,6 +10755,7 @@ dependencies = [ [[package]] name = "sc-network" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "async-channel", @@ -10639,6 +10799,7 @@ dependencies = [ [[package]] name = "sc-network-bitswap" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "cid", "futures", @@ -10658,6 +10819,7 @@ dependencies = [ [[package]] name = "sc-network-common" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10685,6 +10847,7 @@ dependencies = [ [[package]] name = "sc-network-gossip" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ahash 0.8.3", "futures", @@ -10703,6 +10866,7 @@ dependencies = [ [[package]] name = "sc-network-light" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10724,6 +10888,7 @@ dependencies = [ [[package]] name = "sc-network-sync" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -10757,6 +10922,7 @@ dependencies = [ [[package]] name = "sc-network-transactions" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10776,6 +10942,7 @@ dependencies = [ [[package]] name = "sc-offchain" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "bytes", @@ -10806,6 +10973,7 @@ dependencies = [ [[package]] name = "sc-peerset" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "libp2p", @@ -10818,6 +10986,7 @@ dependencies = [ [[package]] name = "sc-proposer-metrics" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "log", "substrate-prometheus-endpoint", @@ -10826,6 +10995,7 @@ dependencies = [ [[package]] name = "sc-rpc" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "hash-db 0.15.2", @@ -10856,6 +11026,7 @@ dependencies = [ [[package]] name = "sc-rpc-api" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -10875,6 +11046,7 @@ dependencies = [ [[package]] name = "sc-rpc-server" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "http", @@ -10890,6 +11062,7 @@ dependencies = [ [[package]] name = "sc-rpc-spec-v2" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "futures", @@ -10915,6 +11088,7 @@ dependencies = [ [[package]] name = "sc-service" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "directories", @@ -10946,7 +11120,7 @@ dependencies = [ "sc-rpc", "sc-rpc-server", "sc-rpc-spec-v2", - "sc-storage-monitor 0.1.0", + "sc-storage-monitor 0.1.0 (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "sc-sysinfo", "sc-telemetry", "sc-tracing", @@ -10986,6 +11160,7 @@ dependencies = [ [[package]] name = "sc-state-db" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "log", "parity-scale-codec", @@ -10996,6 +11171,7 @@ dependencies = [ [[package]] name = "sc-storage-monitor" version = "0.1.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "clap", "fs4", @@ -11027,6 +11203,7 @@ dependencies = [ [[package]] name = "sc-sync-state-rpc" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "jsonrpsee", "parity-scale-codec", @@ -11034,7 +11211,7 @@ dependencies = [ "sc-client-api", "sc-consensus-babe", "sc-consensus-epochs", - "sc-consensus-grandpa", + "sc-consensus-grandpa 0.10.0-dev (git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards)", "serde", "serde_json", "sp-blockchain", @@ -11045,6 +11222,7 @@ dependencies = [ [[package]] name = "sc-sysinfo" version = "6.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "libc", @@ -11063,6 +11241,7 @@ dependencies = [ [[package]] name = "sc-telemetry" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "chrono", "futures", @@ -11081,6 +11260,7 @@ dependencies = [ [[package]] name = "sc-tracing" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ansi_term", "atty", @@ -11111,6 +11291,7 @@ dependencies = [ [[package]] name = "sc-tracing-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -11121,6 +11302,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -11147,6 +11329,7 @@ dependencies = [ [[package]] name = "sc-transaction-pool-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -11160,6 +11343,7 @@ dependencies = [ [[package]] name = "sc-utils" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-channel", "futures", @@ -11672,6 +11856,7 @@ dependencies = [ [[package]] name = "sp-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "hash-db 0.16.0", "log", @@ -11689,6 +11874,7 @@ dependencies = [ [[package]] name = "sp-api-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "Inflector", "blake2", @@ -11702,6 +11888,7 @@ dependencies = [ [[package]] name = "sp-application-crypto" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -11714,6 +11901,7 @@ dependencies = [ [[package]] name = "sp-arithmetic" version = "6.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "integer-sqrt", "num-traits", @@ -11727,6 +11915,7 @@ dependencies = [ [[package]] name = "sp-authority-discovery" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -11739,6 +11928,7 @@ dependencies = [ [[package]] name = "sp-block-builder" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "sp-api", @@ -11750,6 +11940,7 @@ dependencies = [ [[package]] name = "sp-blockchain" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "futures", "log", @@ -11767,6 +11958,7 @@ dependencies = [ [[package]] name = "sp-consensus" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -11781,6 +11973,7 @@ dependencies = [ [[package]] name = "sp-consensus-aura" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "parity-scale-codec", @@ -11798,6 +11991,7 @@ dependencies = [ [[package]] name = "sp-consensus-babe" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "merlin", @@ -11820,6 +12014,7 @@ dependencies = [ [[package]] name = "sp-consensus-beefy" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "lazy_static", "parity-scale-codec", @@ -11838,6 +12033,7 @@ dependencies = [ [[package]] name = "sp-consensus-grandpa" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "finality-grandpa", "log", @@ -11855,6 +12051,7 @@ dependencies = [ [[package]] name = "sp-consensus-slots" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -11868,6 +12065,7 @@ dependencies = [ [[package]] name = "sp-consensus-vrf" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -11880,6 +12078,7 @@ dependencies = [ [[package]] name = "sp-core" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "base58", @@ -11923,6 +12122,7 @@ dependencies = [ [[package]] name = "sp-core-hashing" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "blake2b_simd", "byteorder", @@ -11936,6 +12136,7 @@ dependencies = [ [[package]] name = "sp-core-hashing-proc-macro" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro2", "quote", @@ -11946,6 +12147,7 @@ dependencies = [ [[package]] name = "sp-database" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "kvdb", "parking_lot 0.12.1", @@ -11954,6 +12156,7 @@ dependencies = [ [[package]] name = "sp-debug-derive" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "proc-macro2", "quote", @@ -11963,6 +12166,7 @@ dependencies = [ [[package]] name = "sp-externalities" version = "0.13.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "environmental", "parity-scale-codec", @@ -11973,6 +12177,7 @@ dependencies = [ [[package]] name = "sp-inherents" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "impl-trait-for-tuples", @@ -11987,6 +12192,7 @@ dependencies = [ [[package]] name = "sp-io" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "bytes", "ed25519", @@ -12011,6 +12217,7 @@ dependencies = [ [[package]] name = "sp-keyring" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "lazy_static", "sp-core", @@ -12021,6 +12228,7 @@ dependencies = [ [[package]] name = "sp-keystore" version = "0.13.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures", @@ -12037,6 +12245,7 @@ dependencies = [ [[package]] name = "sp-maybe-compressed-blob" version = "4.1.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "thiserror", "zstd", @@ -12045,6 +12254,7 @@ dependencies = [ [[package]] name = "sp-mmr-primitives" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ckb-merkle-mountain-range", "log", @@ -12062,6 +12272,7 @@ dependencies = [ [[package]] name = "sp-npos-elections" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -12075,6 +12286,7 @@ dependencies = [ [[package]] name = "sp-offchain" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "sp-api", "sp-core", @@ -12084,6 +12296,7 @@ dependencies = [ [[package]] name = "sp-panic-handler" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "backtrace", "lazy_static", @@ -12093,6 +12306,7 @@ dependencies = [ [[package]] name = "sp-rpc" version = "6.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "rustc-hash", "serde", @@ -12102,6 +12316,7 @@ dependencies = [ [[package]] name = "sp-runtime" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "either", "hash256-std-hasher", @@ -12124,6 +12339,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "bytes", "impl-trait-for-tuples", @@ -12141,6 +12357,7 @@ dependencies = [ [[package]] name = "sp-runtime-interface-proc-macro" version = "6.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "Inflector", "proc-macro-crate", @@ -12152,6 +12369,7 @@ dependencies = [ [[package]] name = "sp-session" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -12165,6 +12383,7 @@ dependencies = [ [[package]] name = "sp-staking" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -12176,6 +12395,7 @@ dependencies = [ [[package]] name = "sp-state-machine" version = "0.13.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "hash-db 0.16.0", "log", @@ -12195,10 +12415,12 @@ dependencies = [ [[package]] name = "sp-std" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[package]] name = "sp-storage" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12211,6 +12433,7 @@ dependencies = [ [[package]] name = "sp-timestamp" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "futures-timer", @@ -12225,6 +12448,7 @@ dependencies = [ [[package]] name = "sp-tracing" version = "6.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "sp-std", @@ -12236,6 +12460,7 @@ dependencies = [ [[package]] name = "sp-transaction-pool" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "sp-api", "sp-runtime", @@ -12244,6 +12469,7 @@ dependencies = [ [[package]] name = "sp-transaction-storage-proof" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "log", @@ -12259,6 +12485,7 @@ dependencies = [ [[package]] name = "sp-trie" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ahash 0.8.3", "hash-db 0.16.0", @@ -12281,6 +12508,7 @@ dependencies = [ [[package]] name = "sp-ver" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "log", @@ -12298,6 +12526,7 @@ dependencies = [ [[package]] name = "sp-version" version = "5.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "impl-serde", "parity-scale-codec", @@ -12314,6 +12543,7 @@ dependencies = [ [[package]] name = "sp-version-proc-macro" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "proc-macro2", @@ -12324,6 +12554,7 @@ dependencies = [ [[package]] name = "sp-wasm-interface" version = "7.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "anyhow", "impl-trait-for-tuples", @@ -12337,6 +12568,7 @@ dependencies = [ [[package]] name = "sp-weights" version = "4.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "parity-scale-codec", "scale-info", @@ -12515,6 +12747,7 @@ dependencies = [ [[package]] name = "substrate-build-script-utils" version = "3.0.0" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "platforms 2.0.0", ] @@ -12522,6 +12755,7 @@ dependencies = [ [[package]] name = "substrate-frame-rpc-system" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "frame-system-rpc-runtime-api", "futures", @@ -12540,6 +12774,7 @@ dependencies = [ [[package]] name = "substrate-prometheus-endpoint" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "hyper", "log", @@ -12551,6 +12786,7 @@ dependencies = [ [[package]] name = "substrate-rpc-client" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "jsonrpsee", @@ -12563,6 +12799,7 @@ dependencies = [ [[package]] name = "substrate-state-trie-migration-rpc" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "jsonrpsee", "log", @@ -12581,6 +12818,7 @@ dependencies = [ [[package]] name = "substrate-test-client" version = "2.0.1" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "array-bytes 4.2.0", "async-trait", @@ -12606,6 +12844,7 @@ dependencies = [ [[package]] name = "substrate-wasm-builder" version = "5.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "ansi_term", "build-helper", @@ -13249,6 +13488,7 @@ checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" [[package]] name = "try-runtime-cli" version = "0.10.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "async-trait", "clap", @@ -13461,6 +13701,7 @@ checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" [[package]] name = "ver-api" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" dependencies = [ "derive_more", "futures", @@ -14153,7 +14394,7 @@ dependencies = [ "frame-executive", "frame-support", "frame-system", - "frame-system-benchmarking", + "frame-system-benchmarking 4.0.0-dev (git+https://github.com/paritytech/substrate?branch=polkadot-v0.9.40)", "frame-system-rpc-runtime-api", "frame-try-runtime", "hex-literal", @@ -14789,14 +15030,22 @@ dependencies = [ "pkg-config", ] +[[patch.unused]] +name = "pallet-vesting-mangata" +version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance/substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" + [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] name = "sp-authorship" version = "4.0.0-dev" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" diff --git a/Cargo.toml b/Cargo.toml index 80d3a23727..e79c889cdc 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,12 +55,12 @@ orml-tokens = { git = "https://github.com/mangata-finance//open-runtime-module-l # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/mangata-finance/moonbeam"] # parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/update-staking-benchmarks" } -# parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "mangata-dev" } -parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } +parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", branch = "feature/3rdparty-rewards" } +# parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } [patch."https://github.com/mangata-finance/crowdloan-rewards"] -pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "mangata-dev" } -# pallet-crowdloan-rewards = { path = "../crowdloan-rewards" } +# pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "fr-dev" } +pallet-crowdloan-rewards = { path = "../crowdloan-rewards" } # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/paritytech/cumulus"] @@ -370,1120 +370,1103 @@ xcm-procedural = { git = "https://github.com/mangata-finance//polkadot", branch # xcm = { path = "../polkadot/xcm" } # xcm-procedural = { path = "../polkadot/xcm/procedural" } -# # patch generated by ./scripts/dev-0.9.29_manifest.sh -# [patch."https://github.com/mangata-finance/substrate"] -# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# -# # patch generated by ./scripts/dev-0.9.29_manifest.sh -# [patch."https://github.com/paritytech/substrate"] -# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# -# # patch generated by ./scripts/dev-0.9.29_manifest.sh -# [patch."https://github.com/PureStake/substrate"] -# sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } -# sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "mangata-dev" } - [patch."https://github.com/mangata-finance//substrate"] -pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance/substrate", branch = "feature/3rdparty-rewards" } -# patch generated by ./scripts/dev_manifest.sh + # patch generated by ./scripts/dev-0.9.29_manifest.sh [patch."https://github.com/mangata-finance/substrate"] -sc-offchain = { path = "../substrate/client/offchain" } -sc-keystore = { path = "../substrate/client/keystore" } -mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -sc-informant = { path = "../substrate/client/informant" } -sc-client-db = { path = "../substrate/client/db" } -sc-rpc-api = { path = "../substrate/client/rpc-api" } -sc-client-api = { path = "../substrate/client/api" } -sc-block-builder = { path = "../substrate/client/block-builder" } -sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -sc-utils = { path = "../substrate/client/utils" } -sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -sc-tracing = { path = "../substrate/client/tracing" } -sc-state-db = { path = "../substrate/client/state-db" } -sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -sc-consensus = { path = "../substrate/client/consensus/common" } -sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -sc-executor = { path = "../substrate/client/executor" } -sc-executor-common = { path = "../substrate/client/executor/common" } -sc-cli = { path = "../substrate/client/cli" } -sc-peerset = { path = "../substrate/client/peerset" } -sc-telemetry = { path = "../substrate/client/telemetry" } -sc-allocator = { path = "../substrate/client/allocator" } -sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -sc-network-gossip = { path = "../substrate/client/network-gossip" } -sc-sysinfo = { path = "../substrate/client/sysinfo" } -sc-rpc-server = { path = "../substrate/client/rpc-servers" } -sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -sc-rpc = { path = "../substrate/client/rpc" } -sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -sc-chain-spec = { path = "../substrate/client/chain-spec" } -sc-network-sync = { path = "../substrate/client/network/sync" } -sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -sc-network-light = { path = "../substrate/client/network/light" } -sc-network-transactions = { path = "../substrate/client/network/transactions" } -sc-network = { path = "../substrate/client/network" } -sc-network-common = { path = "../substrate/client/network/common" } -sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -sc-service = { path = "../substrate/client/service" } -substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -fork-tree = { path = "../substrate/utils/fork-tree" } -frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -pallet-referenda = { path = "../substrate/frame/referenda" } -pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -pallet-utility = { path = "../substrate/frame/utility" } -pallet-session = { path = "../substrate/frame/session" } -pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -pallet-treasury = { path = "../substrate/frame/treasury" } -pallet-sudo = { path = "../substrate/frame/sudo" } -pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -pallet-membership = { path = "../substrate/frame/membership" } -pallet-recovery = { path = "../substrate/frame/recovery" } -pallet-tips = { path = "../substrate/frame/tips" } -pallet-balances = { path = "../substrate/frame/balances" } -pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -frame-executive = { path = "../substrate/frame/executive" } -pallet-timestamp = { path = "../substrate/frame/timestamp" } -pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -pallet-preimage = { path = "../substrate/frame/preimage" } -frame-try-runtime = { path = "../substrate/frame/try-runtime" } -pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -pallet-society = { path = "../substrate/frame/society" } -pallet-identity = { path = "../substrate/frame/identity" } -pallet-babe = { path = "../substrate/frame/babe" } -pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -pallet-vesting = { path = "../substrate/frame/vesting" } -pallet-bounties = { path = "../substrate/frame/bounties" } -frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -pallet-indices = { path = "../substrate/frame/indices" } -pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -pallet-collective = { path = "../substrate/frame/collective" } -pallet-multisig = { path = "../substrate/frame/multisig" } -pallet-offences = { path = "../substrate/frame/offences" } -pallet-scheduler = { path = "../substrate/frame/scheduler" } -pallet-nis = { path = "../substrate/frame/nis" } -frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -frame-system = { path = "../substrate/frame/system" } -frame-benchmarking = { path = "../substrate/frame/benchmarking" } -pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -pallet-proxy = { path = "../substrate/frame/proxy" } -pallet-whitelist = { path = "../substrate/frame/whitelist" } -pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -pallet-bags-list = { path = "../substrate/frame/bags-list" } -pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -frame-support = { path = "../substrate/frame/support" } -frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -frame-support-procedural = { path = "../substrate/frame/support/procedural" } -pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -pallet-staking = { path = "../substrate/frame/staking" } -pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -pallet-grandpa = { path = "../substrate/frame/grandpa" } -pallet-democracy = { path = "../substrate/frame/democracy" } -pallet-beefy = { path = "../substrate/frame/beefy" } -pallet-aura = { path = "../substrate/frame/aura" } -pallet-authorship = { path = "../substrate/frame/authorship" } -pallet-im-online = { path = "../substrate/frame/im-online" } -mangata-support = { path = "../substrate/frame/mangata-support" } -substrate-test-client = { path = "../substrate/test-utils/client" } -sp-offchain = { path = "../substrate/primitives/offchain" } -sp-keystore = { path = "../substrate/primitives/keystore" } -sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -sp-keyring = { path = "../substrate/primitives/keyring" } -sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -sp-state-machine = { path = "../substrate/primitives/state-machine" } -sp-session = { path = "../substrate/primitives/session" } -sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -ver-api = { path = "../substrate/primitives/ver-api" } -sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -sp-api = { path = "../substrate/primitives/api" } -sp-externalities = { path = "../substrate/primitives/externalities" } -sp-std = { path = "../substrate/primitives/std" } -sp-trie = { path = "../substrate/primitives/trie" } -sp-block-builder = { path = "../substrate/primitives/block-builder" } -sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -sp-tracing = { path = "../substrate/primitives/tracing" } -sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -sp-consensus = { path = "../substrate/primitives/consensus/common" } -sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -sp-io = { path = "../substrate/primitives/io" } -sp-timestamp = { path = "../substrate/primitives/timestamp" } -sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -sp-core = { path = "../substrate/primitives/core" } -sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -sp-database = { path = "../substrate/primitives/database" } -sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -sp-version = { path = "../substrate/primitives/version" } -extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -mangata-types = { path = "../substrate/primitives/mangata-types" } -sp-rpc = { path = "../substrate/primitives/rpc" } -sp-ver = { path = "../substrate/primitives/ver" } -sp-blockchain = { path = "../substrate/primitives/blockchain" } -sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -sp-runtime = { path = "../substrate/primitives/runtime" } -sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -sp-staking = { path = "../substrate/primitives/staking" } -sp-weights = { path = "../substrate/primitives/weights" } -sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -sp-authorship = { path = "../substrate/primitives/authorship" } -sp-storage = { path = "../substrate/primitives/storage" } -sp-inherents = { path = "../substrate/primitives/inherents" } -frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } -sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } -sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } -sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } -sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } -pallet-root-testing = { path = "../substrate/frame/root-testing" } +sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } -# patch generated by ./scripts/dev_manifest.sh +# patch generated by ./scripts/dev-0.9.29_manifest.sh [patch."https://github.com/paritytech/substrate"] -sc-offchain = { path = "../substrate/client/offchain" } -sc-keystore = { path = "../substrate/client/keystore" } -mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -sc-informant = { path = "../substrate/client/informant" } -sc-client-db = { path = "../substrate/client/db" } -sc-rpc-api = { path = "../substrate/client/rpc-api" } -sc-client-api = { path = "../substrate/client/api" } -sc-block-builder = { path = "../substrate/client/block-builder" } -sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -sc-utils = { path = "../substrate/client/utils" } -sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -sc-tracing = { path = "../substrate/client/tracing" } -sc-state-db = { path = "../substrate/client/state-db" } -sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -sc-consensus = { path = "../substrate/client/consensus/common" } -sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -sc-executor = { path = "../substrate/client/executor" } -sc-executor-common = { path = "../substrate/client/executor/common" } -sc-cli = { path = "../substrate/client/cli" } -sc-peerset = { path = "../substrate/client/peerset" } -sc-telemetry = { path = "../substrate/client/telemetry" } -sc-allocator = { path = "../substrate/client/allocator" } -sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -sc-network-gossip = { path = "../substrate/client/network-gossip" } -sc-sysinfo = { path = "../substrate/client/sysinfo" } -sc-rpc-server = { path = "../substrate/client/rpc-servers" } -sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -sc-rpc = { path = "../substrate/client/rpc" } -sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -sc-chain-spec = { path = "../substrate/client/chain-spec" } -sc-network-sync = { path = "../substrate/client/network/sync" } -sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -sc-network-light = { path = "../substrate/client/network/light" } -sc-network-transactions = { path = "../substrate/client/network/transactions" } -sc-network = { path = "../substrate/client/network" } -sc-network-common = { path = "../substrate/client/network/common" } -sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -sc-service = { path = "../substrate/client/service" } -substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -fork-tree = { path = "../substrate/utils/fork-tree" } -frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -pallet-referenda = { path = "../substrate/frame/referenda" } -pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -pallet-utility = { path = "../substrate/frame/utility" } -pallet-session = { path = "../substrate/frame/session" } -pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -pallet-treasury = { path = "../substrate/frame/treasury" } -pallet-sudo = { path = "../substrate/frame/sudo" } -pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -pallet-membership = { path = "../substrate/frame/membership" } -pallet-recovery = { path = "../substrate/frame/recovery" } -pallet-tips = { path = "../substrate/frame/tips" } -pallet-balances = { path = "../substrate/frame/balances" } -pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -frame-executive = { path = "../substrate/frame/executive" } -pallet-timestamp = { path = "../substrate/frame/timestamp" } -pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -pallet-preimage = { path = "../substrate/frame/preimage" } -frame-try-runtime = { path = "../substrate/frame/try-runtime" } -pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -pallet-society = { path = "../substrate/frame/society" } -pallet-identity = { path = "../substrate/frame/identity" } -pallet-babe = { path = "../substrate/frame/babe" } -pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -pallet-vesting = { path = "../substrate/frame/vesting" } -pallet-bounties = { path = "../substrate/frame/bounties" } -frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -pallet-indices = { path = "../substrate/frame/indices" } -pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -pallet-collective = { path = "../substrate/frame/collective" } -pallet-multisig = { path = "../substrate/frame/multisig" } -pallet-offences = { path = "../substrate/frame/offences" } -pallet-scheduler = { path = "../substrate/frame/scheduler" } -pallet-nis = { path = "../substrate/frame/nis" } -frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -frame-system = { path = "../substrate/frame/system" } -frame-benchmarking = { path = "../substrate/frame/benchmarking" } -pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -pallet-proxy = { path = "../substrate/frame/proxy" } -pallet-whitelist = { path = "../substrate/frame/whitelist" } -pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -pallet-bags-list = { path = "../substrate/frame/bags-list" } -pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -frame-support = { path = "../substrate/frame/support" } -frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -frame-support-procedural = { path = "../substrate/frame/support/procedural" } -pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -pallet-staking = { path = "../substrate/frame/staking" } -pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -pallet-grandpa = { path = "../substrate/frame/grandpa" } -pallet-democracy = { path = "../substrate/frame/democracy" } -pallet-beefy = { path = "../substrate/frame/beefy" } -pallet-aura = { path = "../substrate/frame/aura" } -pallet-authorship = { path = "../substrate/frame/authorship" } -pallet-im-online = { path = "../substrate/frame/im-online" } -mangata-support = { path = "../substrate/frame/mangata-support" } -substrate-test-client = { path = "../substrate/test-utils/client" } -sp-offchain = { path = "../substrate/primitives/offchain" } -sp-keystore = { path = "../substrate/primitives/keystore" } -sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -sp-keyring = { path = "../substrate/primitives/keyring" } -sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -sp-state-machine = { path = "../substrate/primitives/state-machine" } -sp-session = { path = "../substrate/primitives/session" } -sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -ver-api = { path = "../substrate/primitives/ver-api" } -sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -sp-api = { path = "../substrate/primitives/api" } -sp-externalities = { path = "../substrate/primitives/externalities" } -sp-std = { path = "../substrate/primitives/std" } -sp-trie = { path = "../substrate/primitives/trie" } -sp-block-builder = { path = "../substrate/primitives/block-builder" } -sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -sp-tracing = { path = "../substrate/primitives/tracing" } -sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -sp-consensus = { path = "../substrate/primitives/consensus/common" } -sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -sp-io = { path = "../substrate/primitives/io" } -sp-timestamp = { path = "../substrate/primitives/timestamp" } -sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -sp-core = { path = "../substrate/primitives/core" } -sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -sp-database = { path = "../substrate/primitives/database" } -sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -sp-version = { path = "../substrate/primitives/version" } -extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -mangata-types = { path = "../substrate/primitives/mangata-types" } -sp-rpc = { path = "../substrate/primitives/rpc" } -sp-ver = { path = "../substrate/primitives/ver" } -sp-blockchain = { path = "../substrate/primitives/blockchain" } -sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -sp-runtime = { path = "../substrate/primitives/runtime" } -sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -sp-staking = { path = "../substrate/primitives/staking" } -sp-weights = { path = "../substrate/primitives/weights" } -sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -sp-authorship = { path = "../substrate/primitives/authorship" } -sp-storage = { path = "../substrate/primitives/storage" } -sp-inherents = { path = "../substrate/primitives/inherents" } -frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } -sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } -sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } -sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } -sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } -pallet-root-testing = { path = "../substrate/frame/root-testing" } +sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } + sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } -# patch generated by ./scripts/dev_manifest.sh +# patch generated by ./scripts/dev-0.9.29_manifest.sh [patch."https://github.com/PureStake/substrate"] -sc-offchain = { path = "../substrate/client/offchain" } -sc-keystore = { path = "../substrate/client/keystore" } -mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } -mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } -sc-informant = { path = "../substrate/client/informant" } -sc-client-db = { path = "../substrate/client/db" } -sc-rpc-api = { path = "../substrate/client/rpc-api" } -sc-client-api = { path = "../substrate/client/api" } -sc-block-builder = { path = "../substrate/client/block-builder" } -sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } -sc-transaction-pool = { path = "../substrate/client/transaction-pool" } -sc-utils = { path = "../substrate/client/utils" } -sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } -sc-tracing = { path = "../substrate/client/tracing" } -sc-state-db = { path = "../substrate/client/state-db" } -sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } -sc-authority-discovery = { path = "../substrate/client/authority-discovery" } -sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } -sc-consensus-babe = { path = "../substrate/client/consensus/babe" } -sc-consensus-slots = { path = "../substrate/client/consensus/slots" } -sc-consensus = { path = "../substrate/client/consensus/common" } -sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } -sc-consensus-aura = { path = "../substrate/client/consensus/aura" } -sc-basic-authorship = { path = "../substrate/client/basic-authorship" } -sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } -sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } -sc-executor = { path = "../substrate/client/executor" } -sc-executor-common = { path = "../substrate/client/executor/common" } -sc-cli = { path = "../substrate/client/cli" } -sc-peerset = { path = "../substrate/client/peerset" } -sc-telemetry = { path = "../substrate/client/telemetry" } -sc-allocator = { path = "../substrate/client/allocator" } -sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } -sc-network-gossip = { path = "../substrate/client/network-gossip" } -sc-sysinfo = { path = "../substrate/client/sysinfo" } -sc-rpc-server = { path = "../substrate/client/rpc-servers" } -sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } -sc-rpc = { path = "../substrate/client/rpc" } -sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } -sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } -sc-chain-spec = { path = "../substrate/client/chain-spec" } -sc-network-sync = { path = "../substrate/client/network/sync" } -sc-network-bitswap = { path = "../substrate/client/network/bitswap" } -sc-network-light = { path = "../substrate/client/network/light" } -sc-network-transactions = { path = "../substrate/client/network/transactions" } -sc-network = { path = "../substrate/client/network" } -sc-network-common = { path = "../substrate/client/network/common" } -sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } -sc-service = { path = "../substrate/client/service" } -substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } -fork-tree = { path = "../substrate/utils/fork-tree" } -frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } -try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } -frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } -substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } -substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } -substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } -substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } -substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } -pallet-referenda = { path = "../substrate/frame/referenda" } -pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } -pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } -pallet-utility = { path = "../substrate/frame/utility" } -pallet-session = { path = "../substrate/frame/session" } -pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } -pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } -pallet-treasury = { path = "../substrate/frame/treasury" } -pallet-sudo = { path = "../substrate/frame/sudo" } -pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } -pallet-membership = { path = "../substrate/frame/membership" } -pallet-recovery = { path = "../substrate/frame/recovery" } -pallet-tips = { path = "../substrate/frame/tips" } -pallet-balances = { path = "../substrate/frame/balances" } -pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } -frame-executive = { path = "../substrate/frame/executive" } -pallet-timestamp = { path = "../substrate/frame/timestamp" } -pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } -pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } -pallet-preimage = { path = "../substrate/frame/preimage" } -frame-try-runtime = { path = "../substrate/frame/try-runtime" } -pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } -pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } -pallet-society = { path = "../substrate/frame/society" } -pallet-identity = { path = "../substrate/frame/identity" } -pallet-babe = { path = "../substrate/frame/babe" } -pallet-child-bounties = { path = "../substrate/frame/child-bounties" } -pallet-vesting = { path = "../substrate/frame/vesting" } -pallet-bounties = { path = "../substrate/frame/bounties" } -frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } -frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } -pallet-indices = { path = "../substrate/frame/indices" } -pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } -pallet-collective = { path = "../substrate/frame/collective" } -pallet-multisig = { path = "../substrate/frame/multisig" } -pallet-offences = { path = "../substrate/frame/offences" } -pallet-scheduler = { path = "../substrate/frame/scheduler" } -pallet-nis = { path = "../substrate/frame/nis" } -frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } -frame-system = { path = "../substrate/frame/system" } -frame-benchmarking = { path = "../substrate/frame/benchmarking" } -pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } -pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } -pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } -pallet-proxy = { path = "../substrate/frame/proxy" } -pallet-whitelist = { path = "../substrate/frame/whitelist" } -pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } -pallet-bags-list = { path = "../substrate/frame/bags-list" } -pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } -pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } -pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } -pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } -frame-support = { path = "../substrate/frame/support" } -frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } -frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } -frame-support-procedural = { path = "../substrate/frame/support/procedural" } -pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } -pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } -pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } -pallet-staking = { path = "../substrate/frame/staking" } -pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } -pallet-grandpa = { path = "../substrate/frame/grandpa" } -pallet-democracy = { path = "../substrate/frame/democracy" } -pallet-beefy = { path = "../substrate/frame/beefy" } -pallet-aura = { path = "../substrate/frame/aura" } -pallet-authorship = { path = "../substrate/frame/authorship" } -pallet-im-online = { path = "../substrate/frame/im-online" } -mangata-support = { path = "../substrate/frame/mangata-support" } -substrate-test-client = { path = "../substrate/test-utils/client" } -sp-offchain = { path = "../substrate/primitives/offchain" } -sp-keystore = { path = "../substrate/primitives/keystore" } -sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } -sp-keyring = { path = "../substrate/primitives/keyring" } -sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } -sp-state-machine = { path = "../substrate/primitives/state-machine" } -sp-session = { path = "../substrate/primitives/session" } -sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } -ver-api = { path = "../substrate/primitives/ver-api" } -sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } -sp-api = { path = "../substrate/primitives/api" } -sp-externalities = { path = "../substrate/primitives/externalities" } -sp-std = { path = "../substrate/primitives/std" } -sp-trie = { path = "../substrate/primitives/trie" } -sp-block-builder = { path = "../substrate/primitives/block-builder" } -sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } -sp-tracing = { path = "../substrate/primitives/tracing" } -sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } -sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } -sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } -sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } -sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } -sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } -sp-consensus = { path = "../substrate/primitives/consensus/common" } -sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } -sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } -sp-io = { path = "../substrate/primitives/io" } -sp-timestamp = { path = "../substrate/primitives/timestamp" } -sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } -sp-core-hashing = { path = "../substrate/primitives/core/hashing" } -sp-core = { path = "../substrate/primitives/core" } -sp-panic-handler = { path = "../substrate/primitives/panic-handler" } -sp-database = { path = "../substrate/primitives/database" } -sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } -sp-version = { path = "../substrate/primitives/version" } -extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } -mangata-types = { path = "../substrate/primitives/mangata-types" } -sp-rpc = { path = "../substrate/primitives/rpc" } -sp-ver = { path = "../substrate/primitives/ver" } -sp-blockchain = { path = "../substrate/primitives/blockchain" } -sp-application-crypto = { path = "../substrate/primitives/application-crypto" } -sp-runtime = { path = "../substrate/primitives/runtime" } -sp-debug-derive = { path = "../substrate/primitives/debug-derive" } -sp-staking = { path = "../substrate/primitives/staking" } -sp-weights = { path = "../substrate/primitives/weights" } -sp-arithmetic = { path = "../substrate/primitives/arithmetic" } -sp-npos-elections = { path = "../substrate/primitives/npos-elections" } -sp-authorship = { path = "../substrate/primitives/authorship" } -sp-storage = { path = "../substrate/primitives/storage" } -sp-inherents = { path = "../substrate/primitives/inherents" } -frame-system-benchmarking = { path = "../substrate/frame/system/benchmarking" } -sc-consensus-beefy = { path = "../substrate/client/consensus/beefy" } -sp-consensus-beefy = { path = "../substrate/primitives/consensus/beefy" } -sp-consensus-grandpa = { path = "../substrate/primitives/consensus/grandpa" } -sc-consensus-grandpa = { path = "../substrate/client/consensus/grandpa" } -pallet-root-testing = { path = "../substrate/frame/root-testing" } +sc-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mmr-gadget = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-informant = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-client-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-state-db = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-epochs = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-basic-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmi = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-wasmtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-executor-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-peerset = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-telemetry = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-allocator = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-proposer-metrics = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-gossip = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sysinfo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-server = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc-spec-v2 = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-block-builder-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-chain-spec = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-sync = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-bitswap = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-light = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-transactions = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-network-common = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-sync-state-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-service = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-wasm-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +fork-tree = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-remote-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +try-runtime-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking-cli = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-state-trie-migration-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-rpc-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-frame-rpc-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-prometheus-endpoint = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-build-script-utils = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-referenda = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-fast-unstake = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-ranked-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-treasury = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-election-provider-multi-phase = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-membership = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-recovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-tips = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-balances = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-executive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-elections-phragmen = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy-mmr = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-preimage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-try-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nomination-pools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-society = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-identity = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-child-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bounties = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-solution-type = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-election-provider-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-indices = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-sudo-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-collective = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-multisig = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-offences = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-scheduler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-nis = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-system = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-benchmarking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-proxy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-whitelist = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-state-trie-migration = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-bags-list = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc-runtime-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-transaction-payment-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-utility-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural-tools = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +frame-support-procedural = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-vesting-mangata = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-curve = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking-reward-fn = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-conviction-voting = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-democracy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +pallet-im-online = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-support = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +substrate-test-client = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-offchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keystore = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-maybe-compressed-blob = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-keyring = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-mmr-primitives = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-state-machine = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-session = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-storage-proof = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +ver-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-api = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-externalities = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-std = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-trie = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-block-builder = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-transaction-pool = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-tracing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-wasm-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authority-discovery = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime-interface = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-babe = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-slots = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-vrf = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-aura = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-beefy = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-io = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-timestamp = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core-hashing = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-core = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-panic-handler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-database = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version-proc-macro = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-version = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +extrinsic-shuffler = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +mangata-types = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-rpc = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-ver = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-blockchain = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-application-crypto = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-runtime = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-debug-derive = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } + + +# # patch generated by ./scripts/dev_manifest.sh +# [patch."https://github.com/mangata-finance/substrate"] +# sc-offchain = { path = "../substrate/client/offchain" } +# sc-keystore = { path = "../substrate/client/keystore" } +# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +# sc-informant = { path = "../substrate/client/informant" } +# sc-client-db = { path = "../substrate/client/db" } +# sc-rpc-api = { path = "../substrate/client/rpc-api" } +# sc-client-api = { path = "../substrate/client/api" } +# sc-block-builder = { path = "../substrate/client/block-builder" } +# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +# sc-utils = { path = "../substrate/client/utils" } +# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +# sc-tracing = { path = "../substrate/client/tracing" } +# sc-state-db = { path = "../substrate/client/state-db" } +# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +# sc-consensus = { path = "../substrate/client/consensus/common" } +# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +# sc-executor = { path = "../substrate/client/executor" } +# sc-executor-common = { path = "../substrate/client/executor/common" } +# sc-cli = { path = "../substrate/client/cli" } +# sc-peerset = { path = "../substrate/client/peerset" } +# sc-telemetry = { path = "../substrate/client/telemetry" } +# sc-allocator = { path = "../substrate/client/allocator" } +# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +# sc-network-gossip = { path = "../substrate/client/network-gossip" } +# sc-sysinfo = { path = "../substrate/client/sysinfo" } +# sc-rpc-server = { path = "../substrate/client/rpc-servers" } +# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +# sc-rpc = { path = "../substrate/client/rpc" } +# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +# sc-chain-spec = { path = "../substrate/client/chain-spec" } +# sc-network-sync = { path = "../substrate/client/network/sync" } +# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +# sc-network-light = { path = "../substrate/client/network/light" } +# sc-network-transactions = { path = "../substrate/client/network/transactions" } +# sc-network = { path = "../substrate/client/network" } +# sc-network-common = { path = "../substrate/client/network/common" } +# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +# sc-service = { path = "../substrate/client/service" } +# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +# fork-tree = { path = "../substrate/utils/fork-tree" } +# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +# pallet-referenda = { path = "../substrate/frame/referenda" } +# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +# pallet-utility = { path = "../substrate/frame/utility" } +# pallet-session = { path = "../substrate/frame/session" } +# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +# pallet-treasury = { path = "../substrate/frame/treasury" } +# pallet-sudo = { path = "../substrate/frame/sudo" } +# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +# pallet-membership = { path = "../substrate/frame/membership" } +# pallet-recovery = { path = "../substrate/frame/recovery" } +# pallet-tips = { path = "../substrate/frame/tips" } +# pallet-balances = { path = "../substrate/frame/balances" } +# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +# frame-executive = { path = "../substrate/frame/executive" } +# pallet-timestamp = { path = "../substrate/frame/timestamp" } +# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +# pallet-preimage = { path = "../substrate/frame/preimage" } +# frame-try-runtime = { path = "../substrate/frame/try-runtime" } +# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +# pallet-society = { path = "../substrate/frame/society" } +# pallet-identity = { path = "../substrate/frame/identity" } +# pallet-babe = { path = "../substrate/frame/babe" } +# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +# pallet-vesting = { path = "../substrate/frame/vesting" } +# pallet-bounties = { path = "../substrate/frame/bounties" } +# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +# pallet-indices = { path = "../substrate/frame/indices" } +# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +# pallet-collective = { path = "../substrate/frame/collective" } +# pallet-multisig = { path = "../substrate/frame/multisig" } +# pallet-offences = { path = "../substrate/frame/offences" } +# pallet-scheduler = { path = "../substrate/frame/scheduler" } +# pallet-nis = { path = "../substrate/frame/nis" } +# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +# frame-system = { path = "../substrate/frame/system" } +# frame-benchmarking = { path = "../substrate/frame/benchmarking" } +# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +# pallet-proxy = { path = "../substrate/frame/proxy" } +# pallet-whitelist = { path = "../substrate/frame/whitelist" } +# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +# pallet-bags-list = { path = "../substrate/frame/bags-list" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +# frame-support = { path = "../substrate/frame/support" } +# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +# frame-support-procedural = { path = "../substrate/frame/support/procedural" } +# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +# pallet-staking = { path = "../substrate/frame/staking" } +# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +# pallet-grandpa = { path = "../substrate/frame/grandpa" } +# pallet-democracy = { path = "../substrate/frame/democracy" } +# pallet-beefy = { path = "../substrate/frame/beefy" } +# pallet-aura = { path = "../substrate/frame/aura" } +# pallet-authorship = { path = "../substrate/frame/authorship" } +# pallet-im-online = { path = "../substrate/frame/im-online" } +# mangata-support = { path = "../substrate/frame/mangata-support" } +# substrate-test-client = { path = "../substrate/test-utils/client" } +# sp-offchain = { path = "../substrate/primitives/offchain" } +# sp-keystore = { path = "../substrate/primitives/keystore" } +# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +# sp-keyring = { path = "../substrate/primitives/keyring" } +# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +# sp-state-machine = { path = "../substrate/primitives/state-machine" } +# sp-session = { path = "../substrate/primitives/session" } +# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +# ver-api = { path = "../substrate/primitives/ver-api" } +# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +# sp-api = { path = "../substrate/primitives/api" } +# sp-externalities = { path = "../substrate/primitives/externalities" } +# sp-std = { path = "../substrate/primitives/std" } +# sp-trie = { path = "../substrate/primitives/trie" } +# sp-block-builder = { path = "../substrate/primitives/block-builder" } +# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +# sp-tracing = { path = "../substrate/primitives/tracing" } +# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +# sp-consensus = { path = "../substrate/primitives/consensus/common" } +# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +# sp-io = { path = "../substrate/primitives/io" } +# sp-timestamp = { path = "../substrate/primitives/timestamp" } +# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +# sp-core = { path = "../substrate/primitives/core" } +# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +# sp-database = { path = "../substrate/primitives/database" } +# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +# sp-version = { path = "../substrate/primitives/version" } +# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +# mangata-types = { path = "../substrate/primitives/mangata-types" } +# sp-rpc = { path = "../substrate/primitives/rpc" } +# sp-ver = { path = "../substrate/primitives/ver" } +# sp-blockchain = { path = "../substrate/primitives/blockchain" } +# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +# sp-runtime = { path = "../substrate/primitives/runtime" } +# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +# sp-staking = { path = "../substrate/primitives/staking" } +# sp-weights = { path = "../substrate/primitives/weights" } +# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +# sp-authorship = { path = "../substrate/primitives/authorship" } +# sp-storage = { path = "../substrate/primitives/storage" } +# sp-inherents = { path = "../substrate/primitives/inherents" } + +# # # patch generated by ./scripts/dev_manifest.sh +# # [patch."https://github.com/paritytech/substrate"] +# sc-offchain = { path = "../substrate/client/offchain" } +# sc-keystore = { path = "../substrate/client/keystore" } +# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +# sc-informant = { path = "../substrate/client/informant" } +# sc-client-db = { path = "../substrate/client/db" } +# sc-rpc-api = { path = "../substrate/client/rpc-api" } +# sc-client-api = { path = "../substrate/client/api" } +# sc-block-builder = { path = "../substrate/client/block-builder" } +# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +# sc-utils = { path = "../substrate/client/utils" } +# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +# sc-tracing = { path = "../substrate/client/tracing" } +# sc-state-db = { path = "../substrate/client/state-db" } +# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +# sc-consensus = { path = "../substrate/client/consensus/common" } +# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +# sc-executor = { path = "../substrate/client/executor" } +# sc-executor-common = { path = "../substrate/client/executor/common" } +# sc-cli = { path = "../substrate/client/cli" } +# sc-peerset = { path = "../substrate/client/peerset" } +# sc-telemetry = { path = "../substrate/client/telemetry" } +# sc-allocator = { path = "../substrate/client/allocator" } +# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +# sc-network-gossip = { path = "../substrate/client/network-gossip" } +# sc-sysinfo = { path = "../substrate/client/sysinfo" } +# sc-rpc-server = { path = "../substrate/client/rpc-servers" } +# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +# sc-rpc = { path = "../substrate/client/rpc" } +# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +# sc-chain-spec = { path = "../substrate/client/chain-spec" } +# sc-network-sync = { path = "../substrate/client/network/sync" } +# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +# sc-network-light = { path = "../substrate/client/network/light" } +# sc-network-transactions = { path = "../substrate/client/network/transactions" } +# sc-network = { path = "../substrate/client/network" } +# sc-network-common = { path = "../substrate/client/network/common" } +# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +# sc-service = { path = "../substrate/client/service" } +# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +# fork-tree = { path = "../substrate/utils/fork-tree" } +# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +# pallet-referenda = { path = "../substrate/frame/referenda" } +# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +# pallet-utility = { path = "../substrate/frame/utility" } +# pallet-session = { path = "../substrate/frame/session" } +# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +# pallet-treasury = { path = "../substrate/frame/treasury" } +# pallet-sudo = { path = "../substrate/frame/sudo" } +# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +# pallet-membership = { path = "../substrate/frame/membership" } +# pallet-recovery = { path = "../substrate/frame/recovery" } +# pallet-tips = { path = "../substrate/frame/tips" } +# pallet-balances = { path = "../substrate/frame/balances" } +# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +# frame-executive = { path = "../substrate/frame/executive" } +# pallet-timestamp = { path = "../substrate/frame/timestamp" } +# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +# pallet-preimage = { path = "../substrate/frame/preimage" } +# frame-try-runtime = { path = "../substrate/frame/try-runtime" } +# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +# pallet-society = { path = "../substrate/frame/society" } +# pallet-identity = { path = "../substrate/frame/identity" } +# pallet-babe = { path = "../substrate/frame/babe" } +# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +# pallet-vesting = { path = "../substrate/frame/vesting" } +# pallet-bounties = { path = "../substrate/frame/bounties" } +# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +# pallet-indices = { path = "../substrate/frame/indices" } +# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +# pallet-collective = { path = "../substrate/frame/collective" } +# pallet-multisig = { path = "../substrate/frame/multisig" } +# pallet-offences = { path = "../substrate/frame/offences" } +# pallet-scheduler = { path = "../substrate/frame/scheduler" } +# pallet-nis = { path = "../substrate/frame/nis" } +# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +# frame-system = { path = "../substrate/frame/system" } +# frame-benchmarking = { path = "../substrate/frame/benchmarking" } +# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +# pallet-proxy = { path = "../substrate/frame/proxy" } +# pallet-whitelist = { path = "../substrate/frame/whitelist" } +# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +# pallet-bags-list = { path = "../substrate/frame/bags-list" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +# frame-support = { path = "../substrate/frame/support" } +# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +# frame-support-procedural = { path = "../substrate/frame/support/procedural" } +# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +# pallet-staking = { path = "../substrate/frame/staking" } +# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +# pallet-grandpa = { path = "../substrate/frame/grandpa" } +# pallet-democracy = { path = "../substrate/frame/democracy" } +# pallet-beefy = { path = "../substrate/frame/beefy" } +# pallet-aura = { path = "../substrate/frame/aura" } +# pallet-authorship = { path = "../substrate/frame/authorship" } +# pallet-im-online = { path = "../substrate/frame/im-online" } +# mangata-support = { path = "../substrate/frame/mangata-support" } +# substrate-test-client = { path = "../substrate/test-utils/client" } +# sp-offchain = { path = "../substrate/primitives/offchain" } +# sp-keystore = { path = "../substrate/primitives/keystore" } +# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +# sp-keyring = { path = "../substrate/primitives/keyring" } +# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +# sp-state-machine = { path = "../substrate/primitives/state-machine" } +# sp-session = { path = "../substrate/primitives/session" } +# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +# ver-api = { path = "../substrate/primitives/ver-api" } +# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +# sp-api = { path = "../substrate/primitives/api" } +# sp-externalities = { path = "../substrate/primitives/externalities" } +# sp-std = { path = "../substrate/primitives/std" } +# sp-trie = { path = "../substrate/primitives/trie" } +# sp-block-builder = { path = "../substrate/primitives/block-builder" } +# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +# sp-tracing = { path = "../substrate/primitives/tracing" } +# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +# sp-consensus = { path = "../substrate/primitives/consensus/common" } +# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +# sp-io = { path = "../substrate/primitives/io" } +# sp-timestamp = { path = "../substrate/primitives/timestamp" } +# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +# sp-core = { path = "../substrate/primitives/core" } +# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +# sp-database = { path = "../substrate/primitives/database" } +# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +# sp-version = { path = "../substrate/primitives/version" } +# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +# mangata-types = { path = "../substrate/primitives/mangata-types" } +# sp-rpc = { path = "../substrate/primitives/rpc" } +# sp-ver = { path = "../substrate/primitives/ver" } +# sp-blockchain = { path = "../substrate/primitives/blockchain" } +# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +# sp-runtime = { path = "../substrate/primitives/runtime" } +# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +# sp-staking = { path = "../substrate/primitives/staking" } +# sp-weights = { path = "../substrate/primitives/weights" } +# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +# sp-authorship = { path = "../substrate/primitives/authorship" } +# sp-storage = { path = "../substrate/primitives/storage" } +# sp-inherents = { path = "../substrate/primitives/inherents" } + +# # patch generated by ./scripts/dev_manifest.sh +# [patch."https://github.com/PureStake/substrate"] +# sc-offchain = { path = "../substrate/client/offchain" } +# sc-keystore = { path = "../substrate/client/keystore" } +# mmr-rpc = { path = "../substrate/client/merkle-mountain-range/rpc" } +# mmr-gadget = { path = "../substrate/client/merkle-mountain-range" } +# sc-informant = { path = "../substrate/client/informant" } +# sc-client-db = { path = "../substrate/client/db" } +# sc-rpc-api = { path = "../substrate/client/rpc-api" } +# sc-client-api = { path = "../substrate/client/api" } +# sc-block-builder = { path = "../substrate/client/block-builder" } +# sc-transaction-pool-api = { path = "../substrate/client/transaction-pool/api" } +# sc-transaction-pool = { path = "../substrate/client/transaction-pool" } +# sc-utils = { path = "../substrate/client/utils" } +# sc-tracing-proc-macro = { path = "../substrate/client/tracing/proc-macro" } +# sc-tracing = { path = "../substrate/client/tracing" } +# sc-state-db = { path = "../substrate/client/state-db" } +# sc-basic-authorship-ver = { path = "../substrate/client/basic-authorship-ver" } +# sc-authority-discovery = { path = "../substrate/client/authority-discovery" } +# sc-consensus-babe-rpc = { path = "../substrate/client/consensus/babe/rpc" } +# sc-consensus-babe = { path = "../substrate/client/consensus/babe" } +# sc-consensus-slots = { path = "../substrate/client/consensus/slots" } +# sc-consensus = { path = "../substrate/client/consensus/common" } +# sc-consensus-epochs = { path = "../substrate/client/consensus/epochs" } +# sc-consensus-aura = { path = "../substrate/client/consensus/aura" } +# sc-basic-authorship = { path = "../substrate/client/basic-authorship" } +# sc-executor-wasmi = { path = "../substrate/client/executor/wasmi" } +# sc-executor-wasmtime = { path = "../substrate/client/executor/wasmtime" } +# sc-executor = { path = "../substrate/client/executor" } +# sc-executor-common = { path = "../substrate/client/executor/common" } +# sc-cli = { path = "../substrate/client/cli" } +# sc-peerset = { path = "../substrate/client/peerset" } +# sc-telemetry = { path = "../substrate/client/telemetry" } +# sc-allocator = { path = "../substrate/client/allocator" } +# sc-proposer-metrics = { path = "../substrate/client/proposer-metrics" } +# sc-network-gossip = { path = "../substrate/client/network-gossip" } +# sc-sysinfo = { path = "../substrate/client/sysinfo" } +# sc-rpc-server = { path = "../substrate/client/rpc-servers" } +# sc-rpc-spec-v2 = { path = "../substrate/client/rpc-spec-v2" } +# sc-rpc = { path = "../substrate/client/rpc" } +# sc-block-builder-ver = { path = "../substrate/client/block-builder-ver" } +# sc-chain-spec-derive = { path = "../substrate/client/chain-spec/derive" } +# sc-chain-spec = { path = "../substrate/client/chain-spec" } +# sc-network-sync = { path = "../substrate/client/network/sync" } +# sc-network-bitswap = { path = "../substrate/client/network/bitswap" } +# sc-network-light = { path = "../substrate/client/network/light" } +# sc-network-transactions = { path = "../substrate/client/network/transactions" } +# sc-network = { path = "../substrate/client/network" } +# sc-network-common = { path = "../substrate/client/network/common" } +# sc-sync-state-rpc = { path = "../substrate/client/sync-state-rpc" } +# sc-service = { path = "../substrate/client/service" } +# substrate-wasm-builder = { path = "../substrate/utils/wasm-builder" } +# fork-tree = { path = "../substrate/utils/fork-tree" } +# frame-remote-externalities = { path = "../substrate/utils/frame/remote-externalities" } +# try-runtime-cli = { path = "../substrate/utils/frame/try-runtime/cli" } +# frame-benchmarking-cli = { path = "../substrate/utils/frame/benchmarking-cli" } +# substrate-state-trie-migration-rpc = { path = "../substrate/utils/frame/rpc/state-trie-migration-rpc" } +# substrate-rpc-client = { path = "../substrate/utils/frame/rpc/client" } +# substrate-frame-rpc-system = { path = "../substrate/utils/frame/rpc/system" } +# substrate-prometheus-endpoint = { path = "../substrate/utils/prometheus" } +# substrate-build-script-utils = { path = "../substrate/utils/build-script-utils" } +# pallet-referenda = { path = "../substrate/frame/referenda" } +# pallet-fast-unstake = { path = "../substrate/frame/fast-unstake" } +# pallet-mmr = { path = "../substrate/frame/merkle-mountain-range" } +# pallet-utility = { path = "../substrate/frame/utility" } +# pallet-session = { path = "../substrate/frame/session" } +# pallet-ranked-collective = { path = "../substrate/frame/ranked-collective" } +# pallet-collective-mangata = { path = "../substrate/frame/collective-mangata" } +# pallet-treasury = { path = "../substrate/frame/treasury" } +# pallet-sudo = { path = "../substrate/frame/sudo" } +# pallet-election-provider-multi-phase = { path = "../substrate/frame/election-provider-multi-phase" } +# pallet-membership = { path = "../substrate/frame/membership" } +# pallet-recovery = { path = "../substrate/frame/recovery" } +# pallet-tips = { path = "../substrate/frame/tips" } +# pallet-balances = { path = "../substrate/frame/balances" } +# pallet-authority-discovery = { path = "../substrate/frame/authority-discovery" } +# frame-executive = { path = "../substrate/frame/executive" } +# pallet-timestamp = { path = "../substrate/frame/timestamp" } +# pallet-elections-phragmen = { path = "../substrate/frame/elections-phragmen" } +# pallet-beefy-mmr = { path = "../substrate/frame/beefy-mmr" } +# pallet-preimage = { path = "../substrate/frame/preimage" } +# frame-try-runtime = { path = "../substrate/frame/try-runtime" } +# pallet-nomination-pools-runtime-api = { path = "../substrate/frame/nomination-pools/runtime-api" } +# pallet-nomination-pools = { path = "../substrate/frame/nomination-pools" } +# pallet-society = { path = "../substrate/frame/society" } +# pallet-identity = { path = "../substrate/frame/identity" } +# pallet-babe = { path = "../substrate/frame/babe" } +# pallet-child-bounties = { path = "../substrate/frame/child-bounties" } +# pallet-vesting = { path = "../substrate/frame/vesting" } +# pallet-bounties = { path = "../substrate/frame/bounties" } +# frame-election-provider-solution-type = { path = "../substrate/frame/election-provider-support/solution-type" } +# frame-election-provider-support = { path = "../substrate/frame/election-provider-support" } +# pallet-indices = { path = "../substrate/frame/indices" } +# pallet-sudo-mangata = { path = "../substrate/frame/sudo-mangata" } +# pallet-collective = { path = "../substrate/frame/collective" } +# pallet-multisig = { path = "../substrate/frame/multisig" } +# pallet-offences = { path = "../substrate/frame/offences" } +# pallet-scheduler = { path = "../substrate/frame/scheduler" } +# pallet-nis = { path = "../substrate/frame/nis" } +# frame-system-rpc-runtime-api = { path = "../substrate/frame/system/rpc/runtime-api" } +# frame-system = { path = "../substrate/frame/system" } +# frame-benchmarking = { path = "../substrate/frame/benchmarking" } +# pallet-transaction-payment-rpc-runtime-api = { path = "../substrate/frame/transaction-payment/rpc/runtime-api" } +# pallet-transaction-payment-rpc = { path = "../substrate/frame/transaction-payment/rpc" } +# pallet-transaction-payment = { path = "../substrate/frame/transaction-payment" } +# pallet-proxy = { path = "../substrate/frame/proxy" } +# pallet-whitelist = { path = "../substrate/frame/whitelist" } +# pallet-state-trie-migration = { path = "../substrate/frame/state-trie-migration" } +# pallet-bags-list = { path = "../substrate/frame/bags-list" } +# pallet-transaction-payment-mangata-rpc-runtime-api = { path = "../substrate/frame/transaction-payment-mangata/rpc/runtime-api" } +# pallet-transaction-payment-mangata-rpc = { path = "../substrate/frame/transaction-payment-mangata/rpc" } +# pallet-transaction-payment-mangata = { path = "../substrate/frame/transaction-payment-mangata" } +# pallet-utility-mangata = { path = "../substrate/frame/utility-mangata" } +# frame-support = { path = "../substrate/frame/support" } +# frame-support-procedural-tools-derive = { path = "../substrate/frame/support/procedural/tools/derive" } +# frame-support-procedural-tools = { path = "../substrate/frame/support/procedural/tools" } +# frame-support-procedural = { path = "../substrate/frame/support/procedural" } +# pallet-vesting-mangata = { path = "../substrate/frame/vesting-mangata" } +# pallet-staking-reward-curve = { path = "../substrate/frame/staking/reward-curve" } +# pallet-staking-reward-fn = { path = "../substrate/frame/staking/reward-fn" } +# pallet-staking = { path = "../substrate/frame/staking" } +# pallet-conviction-voting = { path = "../substrate/frame/conviction-voting" } +# pallet-grandpa = { path = "../substrate/frame/grandpa" } +# pallet-democracy = { path = "../substrate/frame/democracy" } +# pallet-beefy = { path = "../substrate/frame/beefy" } +# pallet-aura = { path = "../substrate/frame/aura" } +# pallet-authorship = { path = "../substrate/frame/authorship" } +# pallet-im-online = { path = "../substrate/frame/im-online" } +# mangata-support = { path = "../substrate/frame/mangata-support" } +# substrate-test-client = { path = "../substrate/test-utils/client" } +# sp-offchain = { path = "../substrate/primitives/offchain" } +# sp-keystore = { path = "../substrate/primitives/keystore" } +# sp-maybe-compressed-blob = { path = "../substrate/primitives/maybe-compressed-blob" } +# sp-keyring = { path = "../substrate/primitives/keyring" } +# sp-mmr-primitives = { path = "../substrate/primitives/merkle-mountain-range" } +# sp-state-machine = { path = "../substrate/primitives/state-machine" } +# sp-session = { path = "../substrate/primitives/session" } +# sp-transaction-storage-proof = { path = "../substrate/primitives/transaction-storage-proof" } +# ver-api = { path = "../substrate/primitives/ver-api" } +# sp-api-proc-macro = { path = "../substrate/primitives/api/proc-macro" } +# sp-api = { path = "../substrate/primitives/api" } +# sp-externalities = { path = "../substrate/primitives/externalities" } +# sp-std = { path = "../substrate/primitives/std" } +# sp-trie = { path = "../substrate/primitives/trie" } +# sp-block-builder = { path = "../substrate/primitives/block-builder" } +# sp-transaction-pool = { path = "../substrate/primitives/transaction-pool" } +# sp-tracing = { path = "../substrate/primitives/tracing" } +# sp-wasm-interface = { path = "../substrate/primitives/wasm-interface" } +# sp-authority-discovery = { path = "../substrate/primitives/authority-discovery" } +# sp-runtime-interface-proc-macro = { path = "../substrate/primitives/runtime-interface/proc-macro" } +# sp-runtime-interface = { path = "../substrate/primitives/runtime-interface" } +# sp-consensus-babe = { path = "../substrate/primitives/consensus/babe" } +# sp-consensus-slots = { path = "../substrate/primitives/consensus/slots" } +# sp-consensus = { path = "../substrate/primitives/consensus/common" } +# sp-consensus-vrf = { path = "../substrate/primitives/consensus/vrf" } +# sp-consensus-aura = { path = "../substrate/primitives/consensus/aura" } +# sp-io = { path = "../substrate/primitives/io" } +# sp-timestamp = { path = "../substrate/primitives/timestamp" } +# sp-core-hashing-proc-macro = { path = "../substrate/primitives/core/hashing/proc-macro" } +# sp-core-hashing = { path = "../substrate/primitives/core/hashing" } +# sp-core = { path = "../substrate/primitives/core" } +# sp-panic-handler = { path = "../substrate/primitives/panic-handler" } +# sp-database = { path = "../substrate/primitives/database" } +# sp-version-proc-macro = { path = "../substrate/primitives/version/proc-macro" } +# sp-version = { path = "../substrate/primitives/version" } +# extrinsic-shuffler = { path = "../substrate/primitives/shuffler" } +# mangata-types = { path = "../substrate/primitives/mangata-types" } +# sp-rpc = { path = "../substrate/primitives/rpc" } +# sp-ver = { path = "../substrate/primitives/ver" } +# sp-blockchain = { path = "../substrate/primitives/blockchain" } +# sp-application-crypto = { path = "../substrate/primitives/application-crypto" } +# sp-runtime = { path = "../substrate/primitives/runtime" } +# sp-debug-derive = { path = "../substrate/primitives/debug-derive" } +# sp-staking = { path = "../substrate/primitives/staking" } +# sp-weights = { path = "../substrate/primitives/weights" } +# sp-arithmetic = { path = "../substrate/primitives/arithmetic" } +# sp-npos-elections = { path = "../substrate/primitives/npos-elections" } +# sp-authorship = { path = "../substrate/primitives/authorship" } +# sp-storage = { path = "../substrate/primitives/storage" } +# sp-inherents = { path = "../substrate/primitives/inherents" } # # patch generated by ./scripts/dev_manifest.sh # [patch."https://github.com/mangata-finance/cumulus"] From a51e09a9beccaef1a5c52af5a1a2e85a5106a8d2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 12:57:56 +0100 Subject: [PATCH 79/83] compiles --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c7d642702b..c8cbae16cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15041,11 +15041,11 @@ version = "4.0.0-dev" source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] -name = "sp-authorship" +name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" +source = "git+https://github.com/mangata-finance/substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] -name = "pallet-vesting-mangata" +name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" From d0ff567b46a2be35ad06c6ff4c03dff93bdc8ec2 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 20:43:51 +0100 Subject: [PATCH 80/83] fix manifest --- Cargo.lock | 9 +++++---- Cargo.toml | 4 ++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 2375f05164..29613b05cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6379,6 +6379,7 @@ dependencies = [ [[package]] name = "pallet-crowdloan-rewards" version = "0.6.0" +source = "git+https://github.com/mangata-finance//crowdloan-rewards?branch=feature/3rdparty-rewards#0ad74b0080bc823cb488eca35d72718e9406c5a8" dependencies = [ "ed25519-dalek", "frame-benchmarking", @@ -15044,11 +15045,11 @@ version = "4.0.0-dev" source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] -name = "pallet-vesting-mangata" +name = "sp-authorship" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance/substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" +source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" [[patch.unused]] -name = "sp-authorship" +name = "pallet-vesting-mangata" version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" +source = "git+https://github.com/mangata-finance/substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" diff --git a/Cargo.toml b/Cargo.toml index e79c889cdc..6e39801bfe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,8 +59,8 @@ parachain-staking = { git = "https://github.com/mangata-finance//moonbeam", bran # parachain-staking = { path = "../moonbeam/pallets/parachain-staking" } [patch."https://github.com/mangata-finance/crowdloan-rewards"] -# pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "fr-dev" } -pallet-crowdloan-rewards = { path = "../crowdloan-rewards" } +pallet-crowdloan-rewards = { git = "https://github.com/mangata-finance//crowdloan-rewards", branch = "feature/3rdparty-rewards" } +# pallet-crowdloan-rewards = { path = "../crowdloan-rewards" } # patch generated by ./scripts/dev_manifest.sh [patch."https://github.com/paritytech/cumulus"] From be10ab43e7a1f7aeff227bf4339c5c74d0341866 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 21:22:03 +0100 Subject: [PATCH 81/83] remove unused patches --- Cargo.lock | 15 --------------- Cargo.toml | 6 +++--- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 29613b05cd..7a1974e40c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15034,21 +15034,6 @@ dependencies = [ "pkg-config", ] -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" - -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" - -[[patch.unused]] -name = "sp-authorship" -version = "4.0.0-dev" -source = "git+https://github.com/mangata-finance//substrate?branch=feature/3rdparty-rewards#deb4623a00fa59f6cbbd0114bc0c0485ca500eae" - [[patch.unused]] name = "pallet-vesting-mangata" version = "4.0.0-dev" diff --git a/Cargo.toml b/Cargo.toml index 6e39801bfe..594fb89de6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -552,7 +552,7 @@ sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = " sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } @@ -735,7 +735,7 @@ sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = " sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } @@ -919,7 +919,7 @@ sp-staking = { git = "https://github.com/mangata-finance//substrate", branch = " sp-weights = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-arithmetic = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-npos-elections = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } -sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } +# sp-authorship = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-storage = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sp-inherents = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } sc-consensus-grandpa = { git = "https://github.com/mangata-finance//substrate", branch = "feature/3rdparty-rewards" } From 810e34f6454b2fbda71a04b7979d9df38cc0825b Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Thu, 2 Nov 2023 21:59:04 +0100 Subject: [PATCH 82/83] impl missing fn --- pallets/fee-lock/src/mock.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pallets/fee-lock/src/mock.rs b/pallets/fee-lock/src/mock.rs index aa39313d10..22632c8737 100644 --- a/pallets/fee-lock/src/mock.rs +++ b/pallets/fee-lock/src/mock.rs @@ -163,6 +163,13 @@ impl Valuate for MockPoolReservesProvider { _ => Err(pallet_fee_lock::Error::::UnexpectedFailure.into()), } } + + fn valuate_non_liquidity_token( + liquidity_token_id: Self::CurrencyId, + liquidity_token_amount: Self::Balance, + ) -> Self::Balance { + unimplemented!() + } } parameter_types! { From 5f47e65b55297669496edb9b8c3345e9bfc99d09 Mon Sep 17 00:00:00 2001 From: Mateusz Nowakowski Date: Wed, 8 Nov 2023 20:29:28 +0100 Subject: [PATCH 83/83] fix RPC 'calculate_3rdparty_rewards_all' --- pallets/proof-of-stake/rpc/src/lib.rs | 18 +++++++++--------- pallets/proof-of-stake/runtime-api/src/lib.rs | 1 - runtime/mangata-kusama/src/lib.rs | 1 - runtime/mangata-rococo/src/lib.rs | 1 - 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/pallets/proof-of-stake/rpc/src/lib.rs b/pallets/proof-of-stake/rpc/src/lib.rs index 2e3798352a..a3832a91d1 100644 --- a/pallets/proof-of-stake/rpc/src/lib.rs +++ b/pallets/proof-of-stake/rpc/src/lib.rs @@ -120,14 +120,14 @@ where let api = self.client.runtime_api(); let at = self.client.info().best_hash; - todo!(); - // api.calculate_3rdparty_rewards_all(at, account) - // .map_err(|e| { - // JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( - // 1, - // "Unable to serve the request", - // Some(format!("{:?}", e)), - // ))) - // }) + api.calculate_3rdparty_rewards_all(at, account) + .map(|vec| vec.into_iter().map(|(token1, token2, balance)| (token1, token2, Into::::into(balance))).collect()) + .map_err(|e| { + JsonRpseeError::Call(CallError::Custom(ErrorObject::owned( + 1, + "Unable to serve the request", + Some(format!("{:?}", e)), + ))) + }) } } diff --git a/pallets/proof-of-stake/runtime-api/src/lib.rs b/pallets/proof-of-stake/runtime-api/src/lib.rs index a81e86b9c2..217cd6e479 100644 --- a/pallets/proof-of-stake/runtime-api/src/lib.rs +++ b/pallets/proof-of-stake/runtime-api/src/lib.rs @@ -23,7 +23,6 @@ sp_api::decl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, - liquidity_asset_id: TokenId, ) -> Vec<(TokenId, TokenId, Balance)>; } } diff --git a/runtime/mangata-kusama/src/lib.rs b/runtime/mangata-kusama/src/lib.rs index 256ac26ff7..142e7c38f4 100644 --- a/runtime/mangata-kusama/src/lib.rs +++ b/runtime/mangata-kusama/src/lib.rs @@ -790,7 +790,6 @@ impl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, - liquidity_asset_id: TokenId, ) -> Vec<(TokenId, TokenId, Balance)>{ pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_all(user) .unwrap_or_default() diff --git a/runtime/mangata-rococo/src/lib.rs b/runtime/mangata-rococo/src/lib.rs index ed87cc5c95..e31a12b60c 100644 --- a/runtime/mangata-rococo/src/lib.rs +++ b/runtime/mangata-rococo/src/lib.rs @@ -806,7 +806,6 @@ impl_runtime_apis! { fn calculate_3rdparty_rewards_all( user: AccountId, - liquidity_asset_id: TokenId, ) -> Vec<(TokenId, TokenId, Balance)>{ pallet_proof_of_stake::Pallet::::calculate_3rdparty_rewards_all(user) .unwrap_or_default()