-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Split KMA and MA currency * Add CHANGELOG line
- Loading branch information
tommyjk21
committed
Oct 21, 2021
1 parent
0e4524b
commit 13b60c9
Showing
12 changed files
with
131 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use manta_primitives::Balance; | ||
|
||
pub const KMA: Balance = 1_000_000_000_000; // 12 decimal | ||
pub const cKMA: Balance = KMA / 100; // 10 decimal, cent-MA | ||
pub const mKMA: Balance = KMA / 1_000; // 9 decimal, milli-MA | ||
pub const uKMA: Balance = KMA / 1_000_000; // 6 decimal, micro-MA | ||
|
||
pub const fn deposit(items: u32, bytes: u32) -> Balance { | ||
items as Balance * 15 * mKMA + (bytes as Balance) * 6 * mKMA // TODO: revisit the storage cost here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::currency; | ||
use frame_support::weights::{ | ||
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, | ||
WeightToFeePolynomial, | ||
}; | ||
use manta_primitives::Balance; | ||
use smallvec::smallvec; | ||
pub use sp_runtime::Perbill; | ||
|
||
/// The block saturation level. Fees will be updates based on this value. | ||
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); | ||
|
||
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the | ||
/// node's balance type. | ||
/// | ||
/// This should typically create a mapping between the following ranges: | ||
/// - [0, MAXIMUM_BLOCK_WEIGHT] | ||
/// - [Balance::min, Balance::max] | ||
/// | ||
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being: | ||
/// - Setting it to `0` will essentially disable the weight fee. | ||
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. | ||
pub struct WeightToFee; | ||
impl WeightToFeePolynomial for WeightToFee { | ||
type Balance = Balance; | ||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> { | ||
// in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: | ||
// in Manta Parachain, we map to 1/10 of that, or 1/100 CENT | ||
// TODO, revisit here to figure out why use this polynomial | ||
let p = currency::cKMA; | ||
let q = 100 * Balance::from(ExtrinsicBaseWeight::get()); | ||
smallvec![WeightToFeeCoefficient { | ||
degree: 1, | ||
negative: false, | ||
coeff_frac: Perbill::from_rational(p % q, q), | ||
coeff_integer: p / q, | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use manta_primitives::Balance; | ||
|
||
pub const MA: Balance = 1_000_000_000_000_000_000; // 18 decimal | ||
pub const cMA: Balance = MA / 100; // 16 decimal, cent-MA | ||
pub const mMA: Balance = MA / 1_000; // 15 decimal, milli-MA | ||
pub const uMA: Balance = MA / 1_000_000; // 12 decimal, micro-MA | ||
|
||
pub const fn deposit(items: u32, bytes: u32) -> Balance { | ||
items as Balance * 15 * mMA + (bytes as Balance) * 6 * mMA // TODO: revisit the storage cost here | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
use crate::currency; | ||
use frame_support::weights::{ | ||
constants::ExtrinsicBaseWeight, WeightToFeeCoefficient, WeightToFeeCoefficients, | ||
WeightToFeePolynomial, | ||
}; | ||
use manta_primitives::Balance; | ||
use smallvec::smallvec; | ||
pub use sp_runtime::Perbill; | ||
|
||
/// The block saturation level. Fees will be updates based on this value. | ||
pub const TARGET_BLOCK_FULLNESS: Perbill = Perbill::from_percent(25); | ||
|
||
/// Handles converting a weight scalar to a fee value, based on the scale and granularity of the | ||
/// node's balance type. | ||
/// | ||
/// This should typically create a mapping between the following ranges: | ||
/// - [0, MAXIMUM_BLOCK_WEIGHT] | ||
/// - [Balance::min, Balance::max] | ||
/// | ||
/// Yet, it can be used for any other sort of change to weight-fee. Some examples being: | ||
/// - Setting it to `0` will essentially disable the weight fee. | ||
/// - Setting it to `1` will cause the literal `#[weight = x]` values to be charged. | ||
pub struct WeightToFee; | ||
impl WeightToFeePolynomial for WeightToFee { | ||
type Balance = Balance; | ||
fn polynomial() -> WeightToFeeCoefficients<Self::Balance> { | ||
// in Polkadot, extrinsic base weight (smallest non-zero weight) is mapped to 1/10 CENT: | ||
// in Manta Parachain, we map to 1/10 of that, or 1/100 CENT | ||
// TODO, revisit here to figure out why use this polynomial | ||
let p = currency::cMA; | ||
let q = 100 * Balance::from(ExtrinsicBaseWeight::get()); | ||
smallvec![WeightToFeeCoefficient { | ||
degree: 1, | ||
negative: false, | ||
coeff_frac: Perbill::from_rational(p % q, q), | ||
coeff_integer: p / q, | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters