Skip to content
This repository was archived by the owner on May 21, 2024. It is now read-only.

Commit 1867ab3

Browse files
Include new traders from PR #221
1 parent 40f0005 commit 1867ab3

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

runtime/trappist/src/constants.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub mod currency {
3434
/// Fee-related.
3535
pub mod fee {
3636
use frame_support::weights::{
37-
constants::ExtrinsicBaseWeight, Weight, WeightToFeeCoefficient, WeightToFeeCoefficients,
38-
WeightToFeePolynomial,
37+
constants::{ExtrinsicBaseWeight, WEIGHT_REF_TIME_PER_SECOND},
38+
Weight, WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
3939
};
4040
use polkadot_core_primitives::Balance;
4141
use smallvec::smallvec;
@@ -45,6 +45,8 @@ pub mod fee {
4545

4646
use crate::impls::WeightCoefficientCalc;
4747

48+
use super::currency::CENTS;
49+
4850
/// The block saturation level. Fees will be updates based on this value.
4951
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25);
5052

@@ -122,4 +124,14 @@ pub mod fee {
122124
}]
123125
}
124126
}
127+
128+
pub fn base_tx_fee() -> Balance {
129+
CENTS / 10
130+
}
131+
132+
pub fn default_fee_per_second() -> u128 {
133+
let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time());
134+
let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight;
135+
base_tx_per_second * base_tx_fee()
136+
}
125137
}

runtime/trappist/src/xcm_config.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
// limitations under the License.
1515

1616
use crate::{
17-
constants::fee::WeightToFee, impls::ToAuthor, weights::TrappistDropAssetsWeigher,
17+
constants::fee::{default_fee_per_second, WeightToFee},
18+
impls::ToAuthor,
19+
weights::TrappistDropAssetsWeigher,
1820
AllPalletsWithSystem,
1921
};
2022

@@ -46,10 +48,10 @@ use xcm::latest::{prelude::*, Fungibility::Fungible, MultiAsset, MultiLocation};
4648
use xcm_builder::{
4749
AccountId32Aliases, AllowKnownQueryResponses, AllowSubscriptionsFrom,
4850
AllowTopLevelPaidExecutionFrom, AllowUnpaidExecutionFrom, CurrencyAdapter, EnsureXcmOrigin,
49-
FungiblesAdapter, IsConcrete, MintLocation, NativeAsset, NoChecking, ParentAsSuperuser,
50-
ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative, SiblingParachainConvertsVia,
51-
SignedAccountId32AsNative, SignedToAccountId32, SovereignSignedViaLocation, TakeWeightCredit,
52-
UsingComponents, WeightInfoBounds,
51+
FixedRateOfFungible, FungiblesAdapter, IsConcrete, MintLocation, NativeAsset, NoChecking,
52+
ParentAsSuperuser, ParentIsPreset, RelayChainAsNative, SiblingParachainAsNative,
53+
SiblingParachainConvertsVia, SignedAccountId32AsNative, SignedToAccountId32,
54+
SovereignSignedViaLocation, TakeWeightCredit, UsingComponents, WeightInfoBounds,
5355
};
5456
use xcm_executor::XcmExecutor;
5557

@@ -218,6 +220,14 @@ parameter_types! {
218220
// Rockmine's Assets pallet index
219221
pub RockmineAssetsPalletLocation: MultiLocation =
220222
MultiLocation::new(1, X2(Parachain(1000), PalletInstance(50)));
223+
224+
pub RUsdPerSecond: (xcm::v3::AssetId, u128, u128) = (
225+
MultiLocation::new(1, X3(Parachain(1000), PalletInstance(50), GeneralIndex(1984))).into(),
226+
default_fee_per_second() * 10,
227+
0u128
228+
);
229+
/// Roc = 7 RUSD
230+
pub RocPerSecond: (xcm::v3::AssetId, u128,u128) = (MultiLocation::parent().into(), default_fee_per_second() * 70, 0u128);
221231
}
222232

223233
//- From PR https://github.com/paritytech/cumulus/pull/936
@@ -244,7 +254,14 @@ impl<T: Get<MultiLocation>> ContainsPair<MultiAsset, MultiLocation> for ReserveA
244254
}
245255
}
246256

247-
//--
257+
pub type Traders = (
258+
// RUSD
259+
FixedRateOfFungible<RUsdPerSecond, ()>,
260+
// Roc
261+
FixedRateOfFungible<RocPerSecond, ()>,
262+
// Everything else
263+
UsingComponents<WeightToFee, SelfReserve, AccountId, Balances, ToAuthor<Runtime>>,
264+
);
248265

249266
pub type Reserves = (NativeAsset, ReserveAssetsFrom<RockmineLocation>);
250267

@@ -262,8 +279,7 @@ impl xcm_executor::Config for XcmConfig {
262279
RuntimeCall,
263280
MaxInstructions,
264281
>;
265-
type Trader = UsingComponents<WeightToFee, SelfReserve, AccountId, Balances, ToAuthor<Runtime>>;
266-
282+
type Trader = Traders;
267283
type ResponseHandler = PolkadotXcm;
268284
type AssetTrap = TrappistDropAssets<
269285
AssetIdForTrustBackedAssets,

0 commit comments

Comments
 (0)