Skip to content

Commit

Permalink
Rmrk integration
Browse files Browse the repository at this point in the history
  • Loading branch information
yrong committed Dec 29, 2021
1 parent 4cc8116 commit 5ee13c1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node/primitives/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ create_currency_id! {
ZLK("Zenlink Network Token", 18) = 7,
PHA("Phala Native Token", 12) = 8,
USDT("Tether",6) = 9,
RMRK("RMRK Token",10) = 10,
}
}

Expand Down
14 changes: 12 additions & 2 deletions runtime/asgard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ use bifrost_flexible_fee::{
use bifrost_runtime_common::{
cent,
constants::{parachains, time::*},
dollar, micro, milli, millicent,
dollar, micro, microcent, milli, millicent,
r#impl::{
BifrostAccountIdToMultiLocation, BifrostAssetMatcher, BifrostCurrencyIdConvert,
BifrostFilteredAssets,
Expand Down Expand Up @@ -962,6 +962,14 @@ parameter_types! {
// PHA:KSM = 400:1
ksm_per_second() * 400
);
pub RmrkPerSecond: (AssetId, u128) = (
MultiLocation::new(
1,
X2(Parachain(parachains::Statemine::ID), GeneralIndex(parachains::Statemine::RMRK_ID.into()))
).into(),
// usdt:KSM = 10:1
ksm_per_second() * 10 / 100 //rmrk currency decimal as 10
);
}

pub struct ToTreasury;
Expand All @@ -985,6 +993,7 @@ pub type Trader = (
FixedRateOfFungible<KusdPerSecond, ToTreasury>,
FixedRateOfFungible<UsdtPerSecond, ToTreasury>,
FixedRateOfFungible<PhaPerSecond, ToTreasury>,
FixedRateOfFungible<RmrkPerSecond, ToTreasury>,
);

pub struct XcmConfig;
Expand Down Expand Up @@ -1152,7 +1161,8 @@ orml_traits::parameter_type_with_key! {
&CurrencyId::VSBond(TokenSymbol::KSM, ..) => 10 * millicent(RelayCurrencyId::get()),
&CurrencyId::VSBond(TokenSymbol::DOT, ..) => 1 * cent(PolkadotCurrencyId::get()),
&CurrencyId::LPToken(..) => 10 * millicent(NativeCurrencyId::get()),
&CurrencyId::Stable(TokenSymbol::USDT) => 10 * millicent(CurrencyId::Token(TokenSymbol::USDT)),
&CurrencyId::Stable(TokenSymbol::USDT) => 1 * microcent(CurrencyId::Stable(TokenSymbol::USDT)),
&CurrencyId::Token(TokenSymbol::RMRK) => 1 * micro(CurrencyId::Token(TokenSymbol::RMRK)),
_ => Balance::max_value(), // unsupported
}
};
Expand Down
16 changes: 13 additions & 3 deletions runtime/bifrost/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ use bifrost_flexible_fee::{
use bifrost_runtime_common::{
cent,
constants::{parachains, time::*},
dollar, micro, milli, millicent,
dollar, micro, microcent, milli, millicent,
r#impl::{
BifrostAccountIdToMultiLocation, BifrostAssetMatcher, BifrostCurrencyIdConvert,
BifrostFilteredAssets,
Expand Down Expand Up @@ -943,7 +943,7 @@ parameter_types! {
X2(Parachain(parachains::Statemine::ID), GeneralIndex(parachains::Statemine::USDT_ID.into()))
).into(),
// usdt:KSM = 400:1
ksm_per_second() * 400 / 1_000_000
ksm_per_second() * 400 / 1_000_000 //usdt currency decimal as 6
);
pub PhaPerSecond: (AssetId, u128) = (
MultiLocation::new(
Expand All @@ -953,6 +953,14 @@ parameter_types! {
// PHA:KSM = 400:1
ksm_per_second() * 400
);
pub RmrkPerSecond: (AssetId, u128) = (
MultiLocation::new(
1,
X2(Parachain(parachains::Statemine::ID), GeneralIndex(parachains::Statemine::RMRK_ID.into()))
).into(),
// usdt:KSM = 10:1
ksm_per_second() * 10 / 100 //rmrk currency decimal as 10
);
}

pub struct ToTreasury;
Expand All @@ -976,6 +984,7 @@ pub type Trader = (
FixedRateOfFungible<KusdPerSecond, ToTreasury>,
FixedRateOfFungible<UsdtPerSecond, ToTreasury>,
FixedRateOfFungible<PhaPerSecond, ToTreasury>,
FixedRateOfFungible<RmrkPerSecond, ToTreasury>,
);

pub struct XcmConfig;
Expand Down Expand Up @@ -1143,7 +1152,8 @@ orml_traits::parameter_type_with_key! {
&CurrencyId::VSBond(TokenSymbol::KSM, ..) => 10 * millicent(RelayCurrencyId::get()),
&CurrencyId::VSBond(TokenSymbol::DOT, ..) => 1 * cent(PolkadotCurrencyId::get()),
&CurrencyId::LPToken(..) => 10 * millicent(NativeCurrencyId::get()),
&CurrencyId::Stable(TokenSymbol::USDT) => 10 * millicent(CurrencyId::Token(TokenSymbol::USDT)),
&CurrencyId::Stable(TokenSymbol::USDT) => 1 * microcent(CurrencyId::Stable(TokenSymbol::USDT)),
&CurrencyId::Token(TokenSymbol::RMRK) => 1 * micro(CurrencyId::Token(TokenSymbol::RMRK)),
_ => Balance::max_value(), // unsupported
}
};
Expand Down
1 change: 1 addition & 0 deletions runtime/common/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod parachains {
pub mod Statemine {
pub const ID: u32 = 1000;
pub const USDT_ID: u32 = 11;
pub const RMRK_ID: u32 = 8;
}
pub mod phala {
pub const ID: u32 = 2004;
Expand Down
9 changes: 9 additions & 0 deletions runtime/common/src/impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,13 @@ impl<T: Get<ParaId>> Convert<CurrencyId, Option<MultiLocation>> for BifrostCurre
GeneralIndex(parachains::Statemine::USDT_ID as u128),
),
)),
Token(TokenSymbol::RMRK) => Some(MultiLocation::new(
1,
X2(
Parachain(parachains::Statemine::ID),
GeneralIndex(parachains::Statemine::RMRK_ID as u128),
),
)),
// Phala Native token
Token(TokenSymbol::PHA) =>
Some(MultiLocation::new(1, X1(Parachain(parachains::phala::ID)))),
Expand Down Expand Up @@ -182,6 +189,8 @@ impl<T: Get<ParaId>> Convert<MultiLocation, Option<CurrencyId>> for BifrostCurre
X2(Parachain(id), GeneralIndex(key)) if id == parachains::Statemine::ID => {
if key == parachains::Statemine::USDT_ID.into() {
Some(Stable(TokenSymbol::USDT))
} else if key == parachains::Statemine::RMRK_ID.into() {
Some(Token(TokenSymbol::RMRK))
} else {
None
}
Expand Down

0 comments on commit 5ee13c1

Please sign in to comment.