diff --git a/runtime/trappist/src/constants.rs b/runtime/trappist/src/constants.rs index 72a86a45..4c5bd1e3 100644 --- a/runtime/trappist/src/constants.rs +++ b/runtime/trappist/src/constants.rs @@ -34,8 +34,8 @@ pub mod currency { /// Fee-related. pub mod fee { use frame_support::weights::{ - constants::ExtrinsicBaseWeight, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, - WeightToFeePolynomial, + constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND}, + Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial, }; use polkadot_core_primitives::Balance; use smallvec::smallvec; @@ -45,6 +45,8 @@ pub mod fee { use crate::impls::WeightCoefficientCalc; + use super::currency::CENTS; + /// The block saturation level. Fees will be updates based on this value. pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); @@ -122,4 +124,14 @@ pub mod fee { }] } } + + pub fn base_tx_fee() -> Balance { + CENTS / 10 + } + + pub fn default_fee_per_second() -> u128 { + let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time()); + let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight; + base_tx_per_second * base_tx_fee() + } } diff --git a/runtime/trappist/src/xcm_config.rs b/runtime/trappist/src/xcm_config.rs index 151418f9..b912faf8 100644 --- a/runtime/trappist/src/xcm_config.rs +++ b/runtime/trappist/src/xcm_config.rs @@ -14,7 +14,9 @@ // limitations under the License. use crate::{ - constants::fee::WeightToFee, impls::ToAuthor, weights::TrappistDropAssetsWeigher, + constants::fee::{default_fee_per_second, WeightToFee}, + impls::ToAuthor, + weights::TrappistDropAssetsWeigher, AllPalletsWithSystem, }; @@ -46,10 +48,10 @@ use xcm::latest::{prelude::*, Fungibility::Fungible, MultiAsset, MultiLocation}; use xcm_builder::{ AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom, AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin, - FungiblesAdapter, IsConcrete, MintLocation, NativeAsset, NoChecking, ParentAsSuperuser, - ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia, - SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit, - UsingComponents, WeightInfoBounds, + FixedRateOfFungible, FungiblesAdapter, IsConcrete, MintLocation, NativeAsset, NoChecking, + ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, + SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32, + SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds, }; use xcm_executor::XcmExecutor; @@ -218,6 +220,14 @@ parameter_types! { // Rockmine's Assets pallet index pub RockmineAssetsPalletLocation: MultiLocation = MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50))); + + pub RUsdPerSecond: (xcm::v3::AssetId, u128, u128) = ( + MultiLocation::new(1, X3(Parachain(1000), PalletInstance(50), GeneralIndex(1984))).into(), + default_fee_per_second() * 10, + 0u128 + ); + /// Roc = 7 RUSD + pub RocPerSecond: (xcm::v3::AssetId, u128,u128) = (MultiLocation::parent().into(), default_fee_per_second() * 70, 0u128); } //- From PR https://github.com/paritytech/cumulus/pull/936 @@ -244,7 +254,14 @@ impl> ContainsPair for ReserveA } } -//-- +pub type Traders = ( + // RUSD + FixedRateOfFungible, + // Roc + FixedRateOfFungible, + // Everything else + UsingComponents>, +); pub type Reserves = (NativeAsset, ReserveAssetsFrom); @@ -262,8 +279,7 @@ impl xcm_executor::Config for XcmConfig { RuntimeCall, MaxInstructions, >; - type Trader = UsingComponents>; - + type Trader = Traders; type ResponseHandler = PolkadotXcm; type AssetTrap = TrappistDropAssets< AssetIdForTrustBackedAssets,