diff --git a/Cargo.lock b/Cargo.lock index 1c8401ccfb..043f9b48f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1110,15 +1110,19 @@ dependencies = [ "bifrost-slp", "bifrost-vtoken-minting", "cumulus-primitives-core", + "env_logger", "frame-benchmarking", "frame-support", "frame-system", "hex-literal 0.4.1", "log", + "orml-oracle", "orml-tokens", "orml-traits", "orml-xtokens", "pallet-balances", + "pallet-prices", + "pallet-traits", "pallet-xcm", "parity-scale-codec", "scale-info", diff --git a/pallets/fee-share/Cargo.toml b/pallets/fee-share/Cargo.toml index 6c26a6710e..3cc8b8f6b4 100644 --- a/pallets/fee-share/Cargo.toml +++ b/pallets/fee-share/Cargo.toml @@ -26,6 +26,7 @@ bifrost-vtoken-minting = { workspace = true } zenlink-protocol = { workspace = true } bifrost-slp = { workspace = true } cumulus-primitives-core = { workspace = true } +pallet-traits = { workspace = true } [dev-dependencies] orml-tokens = { workspace = true } @@ -39,6 +40,9 @@ sp-io = { workspace = true } sp-core = { workspace = true } sp-runtime = { workspace = true } bifrost-asset-registry = { workspace = true } +pallet-prices = { workspace = true } +orml-oracle = { workspace = true } +env_logger = { workspace = true } [features] default = ["std"] @@ -55,6 +59,8 @@ std = [ "zenlink-protocol/std", "bifrost-slp/std", "bifrost-asset-registry/std", + "pallet-traits/std", + "pallet-prices/std", ] runtime-benchmarks = [ diff --git a/pallets/fee-share/src/benchmarking.rs b/pallets/fee-share/src/benchmarking.rs index e7f3a75a27..b86182f3e2 100644 --- a/pallets/fee-share/src/benchmarking.rs +++ b/pallets/fee-share/src/benchmarking.rs @@ -81,4 +81,20 @@ benchmarks! { true, )); }: _(RawOrigin::Root,0) + set_usd_config { + let caller: T::AccountId = whitelisted_caller(); + let tokens_proportion = vec![(caller.clone(), Perbill::from_percent(100))]; + const KSM: CurrencyId = CurrencyId::Token(TokenSymbol::KSM); + let token_type = vec![KSM]; + assert_ok!(FeeShare::::create_distribution( + RawOrigin::Root.into(), + vec![KSM], + tokens_proportion.clone(), + true, + )); + }: _(RawOrigin::Root, + 0, + 100u128, + 10u32.into(), + caller) } diff --git a/pallets/fee-share/src/lib.rs b/pallets/fee-share/src/lib.rs index 6fe7dda62f..0584562130 100644 --- a/pallets/fee-share/src/lib.rs +++ b/pallets/fee-share/src/lib.rs @@ -30,19 +30,22 @@ mod benchmarking; pub mod weights; -use bifrost_primitives::{CurrencyId, DistributionId}; +use bifrost_primitives::{CurrencyId, DistributionId, Price}; use frame_support::{ pallet_prelude::*, sp_runtime::{ - traits::{AccountIdConversion, CheckedAdd, Saturating}, - ArithmeticError, Perbill, + traits::{ + AccountIdConversion, CheckedAdd, CheckedMul, SaturatedConversion, Saturating, Zero, + }, + ArithmeticError, FixedU128, Perbill, }, PalletId, }; use frame_system::pallet_prelude::*; use orml_traits::MultiCurrency; pub use pallet::*; -use sp_std::{collections::btree_map::BTreeMap, vec::Vec}; +use pallet_traits::PriceFeeder; +use sp_std::{cmp::Ordering, collections::btree_map::BTreeMap, vec::Vec}; pub use weights::WeightInfo; pub type AccountIdOf = ::AccountId; @@ -51,6 +54,8 @@ pub type CurrencyIdOf = <::MultiCurrency as MultiCurrency< ::AccountId, >>::CurrencyId; +type BalanceOf = <::MultiCurrency as MultiCurrency>>::Balance; + #[frame_support::pallet] pub mod pallet { use super::*; @@ -71,41 +76,53 @@ pub mod pallet { #[pallet::constant] type FeeSharePalletId: Get; + + /// The oracle price feeder + type PriceFeeder: PriceFeeder; } #[pallet::event] #[pallet::generate_deposit(pub(super) fn deposit_event)] pub enum Event { - Created { - info: Info>, - }, - Edited { - info: Info>, - }, - EraLengthSet { - era_length: BlockNumberFor, - next_era: BlockNumberFor, - }, - Executed { - distribution_id: DistributionId, - }, - Deleted { - distribution_id: DistributionId, - }, + /// A successful call of the `CreateDistribution` extrinsic will create this event. + Created { distribution_id: DistributionId, info: Info> }, + /// A successful call of the `EditDistribution` extrinsic will create this event. + Edited { distribution_id: DistributionId, info: Info> }, + /// A successful call of the `SetEraLength` extrinsic will create this event. + EraLengthSet { era_length: BlockNumberFor, next_era: BlockNumberFor }, + /// A successful call of the `ExecuteDistribute` extrinsic will create this event. + Executed { distribution_id: DistributionId }, + /// A successful call of the `DeleteDistribution` extrinsic will create this event. + Deleted { distribution_id: DistributionId }, + /// A failed call of the `ExecuteDistribute` extrinsic will create this event. ExecuteFailed { distribution_id: DistributionId, info: Info>, next_era: BlockNumberFor, }, + /// A successful call of the `SetUSDConfig` extrinsic will create this event. + USDConfigSet { + distribution_id: DistributionId, + info: DollarStandardInfo, AccountIdOf>, + }, } #[pallet::error] pub enum Error { - NotEnoughBalance, + /// Not support proportion NotSupportProportion, - CalculationOverflow, + /// Existential deposit ExistentialDeposit, + /// Distribution not exist DistributionNotExist, + /// Price oracle not ready + PriceOracleNotReady, + /// Price is zero + PriceIsZero, + /// Interval is zero + IntervalIsZero, + /// Value is zero + ValueIsZero, } #[pallet::storage] @@ -114,12 +131,38 @@ pub mod pallet { #[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)] pub struct Info { + /// The receiving address of the distribution pub receiving_address: AccountIdOf, + /// The token type of the distribution pub token_type: Vec, + /// The tokens proportion of the distribution pub tokens_proportion: BTreeMap, + /// If the distribution is auto pub if_auto: bool, } + #[pallet::storage] + pub type DollarStandardInfos = StorageMap< + _, + Twox64Concat, + DistributionId, + DollarStandardInfo, AccountIdOf>, + >; + + #[derive(Clone, Encode, Decode, PartialEq, Eq, RuntimeDebug, TypeInfo)] + pub struct DollarStandardInfo { + /// The target value of the USD standard + pub target_value: u128, + /// The cumulative value of the USD standard + pub cumulative: u128, + /// The target address of the USD standard + pub target_address: AccountIdOf, + /// Target block to perform accumulation clear operation + pub target_block: BlockNumberFor, + /// Cumulative clearing operation interval + pub interval: BlockNumberFor, + } + #[pallet::storage] pub type DistributionNextId = StorageValue<_, DistributionId, ValueQuery>; @@ -130,11 +173,20 @@ pub mod pallet { #[pallet::hooks] impl Hooks> for Pallet { fn on_idle(bn: BlockNumberFor, _remaining_weight: Weight) -> Weight { + DollarStandardInfos::::iter().for_each(|(distribution_id, mut info)| { + if bn == info.target_block { + info.target_block = info.target_block.saturating_add(info.interval); + info.cumulative = Zero::zero(); + DollarStandardInfos::::insert(distribution_id, info); + } + }); let (era_length, next_era) = AutoEra::::get(); if bn.eq(&next_era) { for (distribution_id, info) in DistributionInfos::::iter() { if info.if_auto { - if let Some(e) = Self::execute_distribute_inner(&info).err() { + if let Some(e) = + Self::execute_distribute_inner(distribution_id, &info).err() + { Self::deposit_event(Event::ExecuteFailed { distribution_id, info, @@ -142,10 +194,12 @@ pub mod pallet { }); log::error!( - target: "runtime::fee-share", + target: "fee-share::execute_distribute", "Received invalid justification for {:?}", e, ); + } else { + Self::deposit_event(Event::Executed { distribution_id }); } } } @@ -158,6 +212,11 @@ pub mod pallet { #[pallet::call] impl Pallet { + /// Create a distribution + /// + /// - `token_type`: The token types involved in this distribution + /// - `tokens_proportion`: The proportion of the token distribution + /// - `if_auto`: Whether the distribution is automatic #[pallet::call_index(0)] #[pallet::weight(T::WeightInfo::create_distribution())] pub fn create_distribution( @@ -193,10 +252,16 @@ pub mod pallet { Ok(()) })?; - Self::deposit_event(Event::Created { info }); + Self::deposit_event(Event::Created { distribution_id, info }); Ok(()) } + /// Edit the distribution + /// + /// - `distribution_id`: Distribution ID + /// - `token_type`: The token types involved in this distribution + /// - `tokens_proportion`: The proportion of the token distribution + /// - `if_auto`: Whether the distribution is automatic #[pallet::call_index(1)] #[pallet::weight(T::WeightInfo::edit_distribution())] pub fn edit_distribution( @@ -232,10 +297,13 @@ pub mod pallet { } DistributionInfos::::insert(distribution_id, info.clone()); - Self::deposit_event(Event::Edited { info }); + Self::deposit_event(Event::Edited { distribution_id, info }); Ok(()) } + /// Set the era length + /// + /// - `era_length`: The interval between distribution executions #[pallet::call_index(2)] #[pallet::weight(T::WeightInfo::set_era_length())] pub fn set_era_length( @@ -253,6 +321,9 @@ pub mod pallet { Ok(()) } + /// Execute the distribution + /// + /// - `distribution_id`: Distribution ID #[pallet::call_index(3)] #[pallet::weight(T::WeightInfo::execute_distribute())] pub fn execute_distribute( @@ -261,14 +332,17 @@ pub mod pallet { ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; - if let Some(info) = DistributionInfos::::get(distribution_id) { - Self::execute_distribute_inner(&info)?; - } + let info = DistributionInfos::::get(distribution_id) + .ok_or(Error::::DistributionNotExist)?; + Self::execute_distribute_inner(distribution_id, &info)?; Self::deposit_event(Event::Executed { distribution_id }); Ok(()) } + /// Delete the distribution + /// + /// - `distribution_id`: Distribution ID #[pallet::call_index(4)] #[pallet::weight(T::WeightInfo::delete_distribution())] pub fn delete_distribution( @@ -277,18 +351,86 @@ pub mod pallet { ) -> DispatchResult { T::ControlOrigin::ensure_origin(origin)?; - if let Some(info) = DistributionInfos::::get(distribution_id) { - Self::execute_distribute_inner(&info)?; - DistributionInfos::::remove(distribution_id); - } + let info = DistributionInfos::::get(distribution_id) + .ok_or(Error::::DistributionNotExist)?; + Self::execute_distribute_inner(distribution_id, &info)?; + DistributionInfos::::remove(distribution_id); Self::deposit_event(Event::Deleted { distribution_id }); Ok(()) } + + /// USD Standard Accumulation Logic Configuration, can be overridden by the governance + /// + /// - `distribution_id`: Distribution ID + /// - `target_value`: Target's USD based value + /// - `interval`: The interval of the cumulative clearing operation + /// - `target_address`: When the cumulative dollar value falls below the target_value, the + /// funds will be transferred to the target_address + #[pallet::call_index(5)] + #[pallet::weight(T::WeightInfo::set_usd_config())] + pub fn set_usd_config( + origin: OriginFor, + distribution_id: DistributionId, + target_value: u128, + interval: BlockNumberFor, + target_address: AccountIdOf, + ) -> DispatchResult { + T::ControlOrigin::ensure_origin(origin)?; + + ensure!( + DistributionInfos::::contains_key(distribution_id), + Error::::DistributionNotExist + ); + ensure!(interval > Zero::zero(), Error::::IntervalIsZero); + ensure!(target_value > 0, Error::::ValueIsZero); + + let now = frame_system::Pallet::::block_number(); + let info = DollarStandardInfo { + target_value, + cumulative: Zero::zero(), + target_address, + target_block: now + interval, + interval, + }; + DollarStandardInfos::::insert(distribution_id, info.clone()); + + Self::deposit_event(Event::USDConfigSet { distribution_id, info }); + Ok(()) + } } impl Pallet { - fn execute_distribute_inner(infos: &Info>) -> DispatchResult { + fn execute_distribute_inner( + distribution_id: DistributionId, + infos: &Info>, + ) -> DispatchResult { + let mut usd_value: FixedU128 = Zero::zero(); + // Calculate the total value based on the US dollar standard + infos.token_type.iter().try_for_each(|¤cy_id| -> DispatchResult { + let amount = T::MultiCurrency::free_balance(currency_id, &infos.receiving_address); + let value = Self::get_asset_value(currency_id, amount)?; + usd_value = usd_value.checked_add(&value).ok_or(ArithmeticError::Overflow)?; + Ok(()) + })?; + if let Some(mut usd_infos) = DollarStandardInfos::::get(distribution_id) { + match usd_infos.cumulative.cmp(&usd_infos.target_value) { + // If the cumulative value is greater than or equal to the target value, the + // distribution is triggered + Ordering::Equal | Ordering::Greater => (), + // If the cumulative value is less than the target value, the cumulative value + // is added, and the distribution is not triggered + Ordering::Less => { + usd_infos.cumulative = usd_infos + .cumulative + .checked_add(usd_value.into_inner()) + .ok_or(ArithmeticError::Overflow)?; + DollarStandardInfos::::insert(distribution_id, &usd_infos); + return Self::transfer_all(infos, usd_infos.target_address); + }, + } + } + infos.token_type.iter().try_for_each(|¤cy_id| -> DispatchResult { let ed = T::MultiCurrency::minimum_balance(currency_id); let amount = T::MultiCurrency::free_balance(currency_id, &infos.receiving_address); @@ -316,5 +458,44 @@ pub mod pallet { ) }) } + + pub fn get_price(currency_id: CurrencyIdOf) -> Result { + let (price, _) = + T::PriceFeeder::get_price(¤cy_id).ok_or(Error::::PriceOracleNotReady)?; + if price.is_zero() { + return Err(Error::::PriceIsZero.into()); + } + log::trace!( + target: "fee-share::get_price", "price: {:?}", price.into_inner() + ); + + Ok(price) + } + + pub fn get_asset_value( + currency_id: CurrencyIdOf, + amount: BalanceOf, + ) -> Result { + let value = Self::get_price(currency_id)? + .checked_mul(&FixedU128::from_inner(amount.saturated_into())) + .ok_or(ArithmeticError::Overflow)?; + + Ok(value) + } + + fn transfer_all( + infos: &Info>, + target_address: AccountIdOf, + ) -> DispatchResult { + infos.token_type.iter().try_for_each(|¤cy_id| -> DispatchResult { + let amount = T::MultiCurrency::free_balance(currency_id, &infos.receiving_address); + T::MultiCurrency::transfer( + currency_id, + &infos.receiving_address, + &target_address, + amount, + ) + }) + } } } diff --git a/pallets/fee-share/src/mock.rs b/pallets/fee-share/src/mock.rs index ece282274d..367ea0933f 100644 --- a/pallets/fee-share/src/mock.rs +++ b/pallets/fee-share/src/mock.rs @@ -20,28 +20,39 @@ #![cfg(test)] #![allow(non_upper_case_globals)] +pub use super::*; use bifrost_asset_registry::AssetIdMaps; -pub use bifrost_primitives::{currency::*, CurrencyId, SlpxOperator, TokenSymbol}; +use bifrost_primitives::PriceDetail; +pub use bifrost_primitives::{currency::*, CurrencyId, Moment, SlpxOperator, TokenSymbol}; use bifrost_slp::{QueryId, QueryResponseManager}; pub use cumulus_primitives_core::ParaId; use frame_support::{ derive_impl, ord_parameter_types, pallet_prelude::Get, parameter_types, - sp_runtime::{DispatchError, DispatchResult}, + sp_runtime::{DispatchError, DispatchResult, FixedPointNumber}, traits::{Everything, Nothing}, PalletId, }; use frame_system::{EnsureRoot, EnsureSignedBy}; use hex_literal::hex; -use orml_traits::{location::RelativeReserveProvider, parameter_type_with_key, MultiCurrency}; +use orml_traits::{ + location::RelativeReserveProvider, parameter_type_with_key, DataFeeder, DataProvider, + DataProviderExtended, MultiCurrency, +}; +use pallet_traits::PriceFeeder; use sp_core::ConstU32; use sp_runtime::{ traits::{AccountIdConversion, IdentityLookup, UniqueSaturatedInto}, AccountId32, BuildStorage, SaturatedConversion, }; use sp_std::marker::PhantomData; +use std::{ + cell::RefCell, + collections::HashMap, + hash::{Hash, Hasher}, +}; use xcm::{prelude::*, v3::Weight}; use xcm_builder::{FixedWeightBounds, FrameTransactionalProcessor}; use xcm_executor::XcmExecutor; @@ -74,6 +85,7 @@ frame_support::construct_runtime!( ZenlinkProtocol: zenlink_protocol, AssetRegistry: bifrost_asset_registry, PolkadotXcm: pallet_xcm, + Prices: pallet_prices::{Pallet, Storage, Call, Event}, } ); @@ -171,6 +183,101 @@ impl bifrost_fee_share::Config for Runtime { type ControlOrigin = EnsureSignedBy; type WeightInfo = (); type FeeSharePalletId = FeeSharePalletId; + type PriceFeeder = MockPriceFeeder; +} + +impl pallet_prices::Config for Runtime { + type RuntimeEvent = RuntimeEvent; + type Source = MockDataProvider; + type FeederOrigin = EnsureRoot; + type UpdateOrigin = EnsureRoot; + type RelayCurrency = RelayCurrencyId; + type Assets = Currencies; + type CurrencyIdConvert = AssetIdMaps; + type WeightInfo = (); +} + +// pallet-price is using for benchmark compilation +pub type TimeStampedPrice = orml_oracle::TimestampedValue; +pub struct MockDataProvider; +impl DataProvider for MockDataProvider { + fn get(_asset_id: &CurrencyId) -> Option { + Some(TimeStampedPrice { value: Price::saturating_from_integer(100), timestamp: 0 }) + } +} + +impl DataProviderExtended for MockDataProvider { + fn get_no_op(_key: &CurrencyId) -> Option { + None + } + + fn get_all_values() -> Vec<(CurrencyId, Option)> { + vec![] + } +} + +impl DataFeeder for MockDataProvider { + fn feed_value( + _: Option, + _: CurrencyId, + _: TimeStampedPrice, + ) -> sp_runtime::DispatchResult { + Ok(()) + } +} +pub struct MockPriceFeeder; +#[derive(Encode, Decode, Clone, Copy, RuntimeDebug)] +pub struct CurrencyIdWrap(CurrencyId); + +impl Hash for CurrencyIdWrap { + fn hash(&self, state: &mut H) { + state.write_u8(1); + } +} + +impl PartialEq for CurrencyIdWrap { + fn eq(&self, other: &Self) -> bool { + self.0 == other.0 + } +} + +impl Eq for CurrencyIdWrap {} + +impl MockPriceFeeder { + thread_local! { + pub static PRICES: RefCell>> = { + RefCell::new( + vec![BNC, DOT, KSM, DOT_U, VKSM, VDOT, PHA] + .iter() + .map(|&x| (CurrencyIdWrap(x), Some((Price::saturating_from_integer(1), 1)))) + .collect() + ) + }; + } + + pub fn set_price(asset_id: CurrencyId, price: Price) { + Self::PRICES.with(|prices| { + prices.borrow_mut().insert(CurrencyIdWrap(asset_id), Some((price, 1u64))); + }); + } + + pub fn reset() { + Self::PRICES.with(|prices| { + for (_, val) in prices.borrow_mut().iter_mut() { + *val = Some((Price::saturating_from_integer(1), 1u64)); + } + }) + } +} + +impl PriceFeeder for MockPriceFeeder { + fn get_price(asset_id: &CurrencyId) -> Option { + Self::PRICES.with(|prices| *prices.borrow().get(&CurrencyIdWrap(*asset_id)).unwrap()) + } + + fn get_normal_price(_asset_id: &CurrencyId) -> Option { + todo!() + } } pub struct ParaInfo; @@ -489,6 +596,7 @@ impl ExtBuilder { } pub fn build(self) -> sp_io::TestExternalities { + env_logger::try_init().unwrap_or(()); let mut t = frame_system::GenesisConfig::::default().build_storage().unwrap(); pallet_balances::GenesisConfig:: { diff --git a/pallets/fee-share/src/tests.rs b/pallets/fee-share/src/tests.rs index 5a7f8e07d3..4b08089df0 100644 --- a/pallets/fee-share/src/tests.rs +++ b/pallets/fee-share/src/tests.rs @@ -21,7 +21,7 @@ #![cfg(test)] use crate::{mock::*, *}; -use frame_support::assert_ok; +use frame_support::{assert_err, assert_ok}; use sp_arithmetic::per_things::Perbill; #[test] @@ -82,3 +82,92 @@ fn edit_delete_distribution() { assert_eq!(DistributionInfos::::get(0), None); }); } + +#[test] +fn set_usd_config_should_work() { + ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| { + let tokens_proportion = vec![(ALICE, Perbill::from_percent(100))]; + + assert_ok!(FeeShare::create_distribution( + RuntimeOrigin::signed(ALICE), + vec![KSM], + tokens_proportion, + true, + )); + + let distribution_id = 0; + let target_value = 100; + let interval = 10; + assert_ok!(FeeShare::set_usd_config( + RuntimeOrigin::signed(ALICE), + distribution_id, + target_value, + interval, + BOB, + )); + + let keeper: AccountId = + ::FeeSharePalletId::get().into_sub_account_truncating(0); + + assert_ok!(FeeShare::set_era_length(RuntimeOrigin::signed(ALICE), 1)); + assert_eq!(Tokens::free_balance(KSM, &BOB), 100); + FeeShare::on_idle(>::block_number() + 1, Weight::zero()); + assert_ok!(>::transfer(KSM, &ALICE, &keeper, 100,)); + assert_eq!(Tokens::free_balance(KSM, &BOB), 10100); + assert_eq!(DollarStandardInfos::::get(0).unwrap().cumulative, 10000); + FeeShare::on_idle(>::block_number() + 2, Weight::zero()); + assert_eq!(Tokens::free_balance(KSM, &keeper), 0); + assert_eq!(Tokens::free_balance(KSM, &BOB), 10100); + assert_eq!(DollarStandardInfos::::get(0).unwrap().cumulative, 10000); + assert_ok!(>::transfer(KSM, &ALICE, &keeper, 100,)); + FeeShare::on_idle(>::block_number() + 10, Weight::zero()); + assert_eq!(DollarStandardInfos::::get(0).unwrap().cumulative, 0); + }); +} + +#[test] +fn set_usd_config_should_not_work() { + ExtBuilder::default().one_hundred_for_alice_n_bob().build().execute_with(|| { + let tokens_proportion = vec![(ALICE, Perbill::from_percent(100))]; + let distribution_id = 0; + let target_value = 100; + let interval = 10; + + assert_err!( + FeeShare::set_usd_config( + RuntimeOrigin::signed(ALICE), + distribution_id, + target_value, + interval, + BOB, + ), + Error::::DistributionNotExist + ); + assert_ok!(FeeShare::create_distribution( + RuntimeOrigin::signed(ALICE), + vec![KSM], + tokens_proportion, + true, + )); + assert_err!( + FeeShare::set_usd_config( + RuntimeOrigin::signed(ALICE), + distribution_id, + target_value, + 0, + BOB, + ), + Error::::IntervalIsZero + ); + assert_err!( + FeeShare::set_usd_config( + RuntimeOrigin::signed(ALICE), + distribution_id, + 0, + interval, + BOB, + ), + Error::::ValueIsZero + ); + }); +} diff --git a/pallets/fee-share/src/weights.rs b/pallets/fee-share/src/weights.rs index 1d4a4a9ed3..6e081da5f4 100644 --- a/pallets/fee-share/src/weights.rs +++ b/pallets/fee-share/src/weights.rs @@ -59,6 +59,7 @@ pub trait WeightInfo { fn set_era_length() -> Weight; fn execute_distribute() -> Weight; fn delete_distribution() -> Weight; + fn set_usd_config() -> Weight; } // For backwards compatibility and tests @@ -136,4 +137,18 @@ impl WeightInfo for () { .saturating_add(RocksDbWeight::get().reads(4_u64)) .saturating_add(RocksDbWeight::get().writes(1_u64)) } + /// Storage: `FeeShare::DistributionInfos` (r:1 w:0) + /// Proof: `FeeShare::DistributionInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `FeeShare::DollarStandardInfos` (r:0 w:1) + /// Proof: `FeeShare::DollarStandardInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn set_usd_config() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3559` + // Minimum execution time: 9_077_000 picoseconds. + Weight::from_parts(9_408_000, 0) + .saturating_add(Weight::from_parts(0, 3559)) + .saturating_add(RocksDbWeight::get().reads(1)) + .saturating_add(RocksDbWeight::get().writes(1)) + } } diff --git a/runtime/bifrost-kusama/src/lib.rs b/runtime/bifrost-kusama/src/lib.rs index 1145b8f694..62c00a3cdc 100644 --- a/runtime/bifrost-kusama/src/lib.rs +++ b/runtime/bifrost-kusama/src/lib.rs @@ -1375,6 +1375,7 @@ impl bifrost_fee_share::Config for Runtime { type ControlOrigin = CoreAdminOrCouncil; type WeightInfo = weights::bifrost_fee_share::BifrostWeight; type FeeSharePalletId = FeeSharePalletId; + type PriceFeeder = Prices; } impl bifrost_cross_in_out::Config for Runtime { diff --git a/runtime/bifrost-kusama/src/weights/bifrost_fee_share.rs b/runtime/bifrost-kusama/src/weights/bifrost_fee_share.rs index 2050da409e..1e2478564b 100644 --- a/runtime/bifrost-kusama/src/weights/bifrost_fee_share.rs +++ b/runtime/bifrost-kusama/src/weights/bifrost_fee_share.rs @@ -127,4 +127,18 @@ impl bifrost_fee_share::WeightInfo for BifrostWeight .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `FeeShare::DistributionInfos` (r:1 w:0) + /// Proof: `FeeShare::DistributionInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `FeeShare::DollarStandardInfos` (r:0 w:1) + /// Proof: `FeeShare::DollarStandardInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn set_usd_config() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3559` + // Minimum execution time: 9_077_000 picoseconds. + Weight::from_parts(9_408_000, 0) + .saturating_add(Weight::from_parts(0, 3559)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } } diff --git a/runtime/bifrost-polkadot/src/lib.rs b/runtime/bifrost-polkadot/src/lib.rs index f76e26a8cc..8605a0d994 100644 --- a/runtime/bifrost-polkadot/src/lib.rs +++ b/runtime/bifrost-polkadot/src/lib.rs @@ -1248,6 +1248,7 @@ impl bifrost_fee_share::Config for Runtime { type ControlOrigin = CoreAdminOrCouncil; type WeightInfo = weights::bifrost_fee_share::BifrostWeight; type FeeSharePalletId = FeeSharePalletId; + type PriceFeeder = Prices; } impl bifrost_cross_in_out::Config for Runtime { diff --git a/runtime/bifrost-polkadot/src/weights/bifrost_fee_share.rs b/runtime/bifrost-polkadot/src/weights/bifrost_fee_share.rs index 2050da409e..1e2478564b 100644 --- a/runtime/bifrost-polkadot/src/weights/bifrost_fee_share.rs +++ b/runtime/bifrost-polkadot/src/weights/bifrost_fee_share.rs @@ -127,4 +127,18 @@ impl bifrost_fee_share::WeightInfo for BifrostWeight .saturating_add(T::DbWeight::get().reads(4)) .saturating_add(T::DbWeight::get().writes(1)) } + /// Storage: `FeeShare::DistributionInfos` (r:1 w:0) + /// Proof: `FeeShare::DistributionInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + /// Storage: `FeeShare::DollarStandardInfos` (r:0 w:1) + /// Proof: `FeeShare::DollarStandardInfos` (`max_values`: None, `max_size`: None, mode: `Measured`) + fn set_usd_config() -> Weight { + // Proof Size summary in bytes: + // Measured: `94` + // Estimated: `3559` + // Minimum execution time: 9_077_000 picoseconds. + Weight::from_parts(9_408_000, 0) + .saturating_add(Weight::from_parts(0, 3559)) + .saturating_add(T::DbWeight::get().reads(1)) + .saturating_add(T::DbWeight::get().writes(1)) + } }