Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions runtime/asgard/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ pub mod currency {
items as Balance * 15 * CENTS + (bytes as Balance) * 6 * CENTS
}

pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
pub struct KsmWeightToFee;
impl WeightToFeePolynomial for KsmWeightToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
let p = super::currency::RELAY_CENTS;
Expand All @@ -56,8 +56,24 @@ pub mod currency {
}
}

pub struct WeightToFee;
impl WeightToFeePolynomial for WeightToFee {
type Balance = Balance;
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> {
// extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT:
let p = base_tx_fee();
let q = Balance::from(ExtrinsicBaseWeight::get());
smallvec![WeightToFeeCoefficient {
degree: 1,
negative: false,
coeff_frac: Perbill::from_rational(p % q, q),
coeff_integer: p / q,
}]
}
}

fn base_tx_fee() -> Balance {
CENTS / 10
CENTS / 5
}

pub fn ksm_per_second() -> u128 {
Expand Down
7 changes: 4 additions & 3 deletions runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,8 @@ impl pallet_transaction_payment::Config for Runtime {
type OnChargeTransaction = FlexibleFee;
type TransactionByteFee = TransactionByteFee;
type OperationalFeeMultiplier = OperationalFeeMultiplier;
type WeightToFee = IdentityFee<Balance>;
// type WeightToFee = IdentityFee<Balance>;
type WeightToFee = WeightToFee;
}

impl pallet_sudo::Config for Runtime {
Expand Down Expand Up @@ -1255,7 +1256,7 @@ impl bifrost_flexible_fee::Config for Runtime {
type MiscFeeHandler = MiscFeeHandler<
Runtime,
RelayCurrencyId,
WeightToFee,
KsmWeightToFee,
SalpWeightHolder,
ContributeFeeFilter,
>;
Expand Down Expand Up @@ -1335,7 +1336,7 @@ parameter_types! {

impl bifrost_salp::Config for Runtime {
type BancorPool = Bancor;
type BifrostXcmExecutor = BifrostXcmAdaptor<XcmRouter, XcmWeight, WeightToFee, SelfParaId>;
type BifrostXcmExecutor = BifrostXcmAdaptor<XcmRouter, XcmWeight, KsmWeightToFee, SelfParaId>;
type Event = Event;
type LeasePeriod = LeasePeriod;
type MinContribution = MinContribution;
Expand Down
10 changes: 7 additions & 3 deletions runtime/bifrost/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

/// Money matters.
pub mod currency {
use bifrost_runtime_common::{cent, dollar};
use bifrost_runtime_common::{cent, dollar, milli};
use frame_support::weights::{
constants::{ExtrinsicBaseWeight, WEIGHT_PER_SECOND},
WeightToFeeCoefficient, WeightToFeeCoefficients, WeightToFeePolynomial,
Expand Down Expand Up @@ -70,13 +70,17 @@ pub mod currency {
}

fn base_tx_fee() -> Balance {
cent(CurrencyId::Native(TokenSymbol::BNC)) / 5
milli(CurrencyId::Native(TokenSymbol::BNC)) / 3
}

fn xcm_base_tx_fee() -> Balance {
cent(CurrencyId::Native(TokenSymbol::BNC)) / 10
}

pub fn ksm_per_second() -> u128 {
let base_weight = Balance::from(ExtrinsicBaseWeight::get());
let base_tx_per_second = (WEIGHT_PER_SECOND as u128) / base_weight;
let fee_per_second = base_tx_per_second * base_tx_fee();
let fee_per_second = base_tx_per_second * xcm_base_tx_fee();
fee_per_second / 100
}
}
Expand Down