Skip to content

Commit 041b9df

Browse files
Merge pull request #34 from paritytech/fix/adjust-fees-to-testnet
Fix: Adapt fixed rate trader to relay native token decimals
2 parents b8af2a0 + 8d0ce10 commit 041b9df

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

runtime/mainnet/src/lib.rs

+7-4
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub type Executive = frame_executive::Executive<
110110
>;
111111

112112
pub mod fee {
113-
use super::{Balance, ExtrinsicBaseWeight, MILLI_MYTH};
113+
use super::{Balance, ExtrinsicBaseWeight, MILLI_DOT, MILLI_MYTH};
114114
use frame_support::weights::{
115115
constants::WEIGHT_REF_TIME_PER_SECOND, FeePolynomial, Weight, WeightToFeeCoefficient,
116116
WeightToFeeCoefficients, WeightToFeePolynomial,
@@ -183,14 +183,14 @@ pub mod fee {
183183
}
184184
}
185185

186-
pub fn base_tx_fee() -> Balance {
187-
MILLI_MYTH
186+
pub fn base_relay_tx_fee() -> Balance {
187+
MILLI_DOT
188188
}
189189

190190
pub fn default_fee_per_second() -> u128 {
191191
let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time());
192192
let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight;
193-
base_tx_per_second * base_tx_fee()
193+
base_tx_per_second * base_relay_tx_fee()
194194
}
195195
}
196196
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
@@ -233,6 +233,9 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
233233
pub const MICRO_MYTH: Balance = 1_000_000_000_000;
234234
pub const MILLI_MYTH: Balance = 1_000 * MICRO_MYTH;
235235
pub const MYTH: Balance = 1_000 * MILLI_MYTH;
236+
// DOT has 10 decimal places
237+
pub const MICRO_DOT: Balance = 10_000;
238+
pub const MILLI_DOT: Balance = 1_000 * MICRO_DOT;
236239

237240
pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_MYTH;
238241

runtime/mainnet/src/xcm_config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ parameter_types! {
225225
pub const NativeAssetId: AssetId = AssetId(SelfReserve::get());
226226
pub const NativeAssetFilter: AssetFilter = Wild(AllOf { fun: WildFungible, id: NativeAssetId::get() });
227227
pub AssetHubTrustedTeleporter: (AssetFilter, Location) = (NativeAssetFilter::get(), AssetHubLocation::get());
228-
pub RelayPerSecond: (AssetId, u128,u128) = (Location::new(1,Here).into(), default_fee_per_second() * 10, 1024);
228+
pub RelayPerSecondAndByte: (AssetId, u128,u128) = (Location::new(1,Here).into(), default_fee_per_second() * 1, 1024);
229229
}
230230

231231
pub struct OnlyAssetHubPrefix;
@@ -264,7 +264,7 @@ impl Contains<(Location, Vec<Asset>)> for OnlyTeleportNative {
264264

265265
pub type Traders = (
266266
//Relay token.
267-
FixedRateOfFungible<RelayPerSecond, ()>,
267+
FixedRateOfFungible<RelayPerSecondAndByte, ()>,
268268
//Native asset.
269269
UsingComponents<WeightToFee, SelfReserve, AccountId, Balances, DealWithFees<Runtime>>,
270270
);

runtime/testnet/src/lib.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ pub type Executive = frame_executive::Executive<
111111
>;
112112

113113
pub mod fee {
114-
use super::{Balance, ExtrinsicBaseWeight, MILLI_MUSE};
114+
115+
use super::{Balance, ExtrinsicBaseWeight, MILLI_MUSE, MILLI_ROC};
115116
use frame_support::weights::{
116117
constants::WEIGHT_REF_TIME_PER_SECOND, FeePolynomial, Weight, WeightToFeeCoefficient,
117118
WeightToFeeCoefficients, WeightToFeePolynomial,
@@ -184,14 +185,14 @@ pub mod fee {
184185
}
185186
}
186187

187-
pub fn base_tx_fee() -> Balance {
188-
MILLI_MUSE
188+
pub fn base_relay_tx_fee() -> Balance {
189+
MILLI_ROC
189190
}
190191

191192
pub fn default_fee_per_second() -> u128 {
192193
let base_weight = Balance::from(ExtrinsicBaseWeight::get().ref_time());
193194
let base_tx_per_second = (WEIGHT_REF_TIME_PER_SECOND as u128) / base_weight;
194-
base_tx_per_second * base_tx_fee()
195+
base_tx_per_second * base_relay_tx_fee()
195196
}
196197
}
197198
/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know
@@ -234,6 +235,9 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
234235
pub const MICRO_MUSE: Balance = 1_000_000_000_000;
235236
pub const MILLI_MUSE: Balance = 1_000 * MICRO_MUSE;
236237
pub const MUSE: Balance = 1_000 * MILLI_MUSE;
238+
//ROC has 12 decimal places
239+
pub const MICRO_ROC: Balance = 1_000_000;
240+
pub const MILLI_ROC: Balance = 1_000 * MICRO_ROC;
237241

238242
pub const EXISTENTIAL_DEPOSIT: Balance = MILLI_MUSE;
239243

runtime/testnet/src/xcm_config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ parameter_types! {
229229
pub const NativeAssetId: AssetId = AssetId(SelfReserve::get());
230230
pub const NativeAssetFilter: AssetFilter = Wild(AllOf { fun: WildFungible, id: NativeAssetId::get() });
231231
pub AssetHubTrustedTeleporter: (AssetFilter, Location) = (NativeAssetFilter::get(), AssetHubLocation::get());
232-
pub RelayPerSecond: (AssetId, u128,u128) = (Location::new(1,Here).into(), default_fee_per_second() * 10, 1024);
232+
pub RelayPerSecondAndByte: (AssetId, u128,u128) = (Location::new(1,Here).into(), default_fee_per_second() * 1, 1024);
233233
}
234234

235235
pub struct OnlyAssetHubPrefix;
@@ -268,7 +268,7 @@ impl Contains<(Location, Vec<Asset>)> for OnlyTeleportNative {
268268

269269
pub type Traders = (
270270
//Relay token.
271-
FixedRateOfFungible<RelayPerSecond, ()>,
271+
FixedRateOfFungible<RelayPerSecondAndByte, ()>,
272272
//Native asset.
273273
UsingComponents<WeightToFee, SelfReserve, AccountId, Balances, DealWithFees<Runtime>>,
274274
);

0 commit comments

Comments
 (0)