Skip to content

Commit

Permalink
enable LCDOT (#1818)
Browse files Browse the repository at this point in the history
  • Loading branch information
xlc authored Jan 26, 2022
1 parent 90b2772 commit 0c49594
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 25 deletions.
26 changes: 10 additions & 16 deletions modules/asset-registry/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ pub mod module {
/// Currency type for withdraw and balance storage.
type Currency: Currency<Self::AccountId>;

/// The Currency ID for the Liquid Crowdloan asset
/// The Currency ID for the staking currency
#[pallet::constant]
type LiquidCrowdloanCurrencyId: Get<CurrencyId>;
type StakingCurrencyId: Get<CurrencyId>;

/// Evm Bridge for getting info of contracts from the EVM.
type EVMBridge: EVMBridge<Self::AccountId, BalanceOf<Self>>;
Expand Down Expand Up @@ -623,9 +623,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
DexShare::LiquidCrowdloan(lease) => Some(
format!(
"LiquidCrowdloan-{}-{}",
T::LiquidCrowdloanCurrencyId::get()
.name()
.expect("constant never failed; qed"),
T::StakingCurrencyId::get().name().expect("constant never failed; qed"),
lease
)
.into_bytes(),
Expand All @@ -640,9 +638,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
DexShare::LiquidCrowdloan(lease) => Some(
format!(
"LiquidCrowdloan-{}-{}",
T::LiquidCrowdloanCurrencyId::get()
.name()
.expect("constant never failed; qed"),
T::StakingCurrencyId::get().name().expect("constant never failed; qed"),
lease
)
.into_bytes(),
Expand All @@ -666,9 +662,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
CurrencyId::LiquidCrowdloan(lease) => Some(
format!(
"LiquidCrowdloan-{}-{}",
T::LiquidCrowdloanCurrencyId::get()
.name()
.expect("constant never failed; qed"),
T::StakingCurrencyId::get().name().expect("constant never failed; qed"),
lease
)
.into_bytes(),
Expand Down Expand Up @@ -699,7 +693,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
DexShare::LiquidCrowdloan(lease) => Some(
format!(
"LC{}-{}",
T::LiquidCrowdloanCurrencyId::get()
T::StakingCurrencyId::get()
.symbol()
.expect("constant never failed; qed"),
lease
Expand All @@ -716,7 +710,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
DexShare::LiquidCrowdloan(lease) => Some(
format!(
"LC{}-{}",
T::LiquidCrowdloanCurrencyId::get()
T::StakingCurrencyId::get()
.symbol()
.expect("constant never failed; qed"),
lease
Expand All @@ -742,7 +736,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
CurrencyId::LiquidCrowdloan(lease) => Some(
format!(
"LC{}-{}",
T::LiquidCrowdloanCurrencyId::get()
T::StakingCurrencyId::get()
.symbol()
.expect("constant never failed; qed"),
lease
Expand Down Expand Up @@ -774,7 +768,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
match symbol_0 {
DexShare::Token(symbol) => CurrencyId::Token(symbol).decimals(),
DexShare::Erc20(address) => AssetMetadatas::<T>::get(AssetIds::Erc20(address)).map(|v| v.decimals),
DexShare::LiquidCrowdloan(_) => T::LiquidCrowdloanCurrencyId::get().decimals(),
DexShare::LiquidCrowdloan(_) => T::StakingCurrencyId::get().decimals(),
DexShare::ForeignAsset(foreign_asset_id) => {
AssetMetadatas::<T>::get(AssetIds::ForeignAssetId(foreign_asset_id)).map(|v| v.decimals)
}
Expand All @@ -784,7 +778,7 @@ impl<T: Config> Erc20InfoMapping for EvmErc20InfoMapping<T> {
CurrencyId::StableAssetPoolToken(stable_asset_id) => {
AssetMetadatas::<T>::get(AssetIds::StableAssetId(stable_asset_id)).map(|v| v.decimals)
}
CurrencyId::LiquidCrowdloan(_) => T::LiquidCrowdloanCurrencyId::get().decimals(),
CurrencyId::LiquidCrowdloan(_) => T::StakingCurrencyId::get().decimals(),
CurrencyId::ForeignAsset(foreign_asset_id) => {
AssetMetadatas::<T>::get(AssetIds::ForeignAssetId(foreign_asset_id)).map(|v| v.decimals)
}
Expand Down
2 changes: 1 addition & 1 deletion modules/asset-registry/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ parameter_types! {
impl asset_registry::Config for Runtime {
type Event = Event;
type Currency = Balances;
type LiquidCrowdloanCurrencyId = KSMCurrencyId;
type StakingCurrencyId = KSMCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type RegisterOrigin = EnsureSignedBy<CouncilAccount, AccountId>;
type WeightInfo = ();
Expand Down
3 changes: 3 additions & 0 deletions primitives/src/currency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,6 @@ impl Into<DexShareType> for DexShare {
}
}
}

/// The first batch of lcDOT that expires at end of least 13
pub const LCDOT: CurrencyId = CurrencyId::LiquidCrowdloan(13);
13 changes: 9 additions & 4 deletions runtime/acala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub use runtime_common::{
OperationalFeeMultiplier, OperatorMembershipInstanceAcala, Price, ProxyType, Rate, Ratio,
RelayChainBlockNumberProvider, RelayChainSubAccountId, RuntimeBlockLength, RuntimeBlockWeights,
SystemContractsFilter, TechnicalCommitteeInstance, TechnicalCommitteeMembershipInstance, TimeStampedPrice,
TipPerWeightStep, ACA, AUSD, DOT, LDOT, RENBTC,
TipPerWeightStep, ACA, AUSD, DOT, LCDOT, LDOT, RENBTC,
};

mod authority;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ where
}

parameter_types! {
pub CollateralCurrencyIds: Vec<CurrencyId> = vec![DOT, LDOT];
pub CollateralCurrencyIds: Vec<CurrencyId> = vec![DOT, LDOT, LCDOT];
pub DefaultLiquidationRatio: Ratio = Ratio::saturating_from_rational(150, 100);
pub DefaultDebitExchangeRate: ExchangeRate = ExchangeRate::saturating_from_rational(1, 10);
pub DefaultLiquidationPenalty: Rate = Rate::saturating_from_rational(8, 100);
Expand Down Expand Up @@ -1101,6 +1101,7 @@ parameter_types! {
pub const MaxAuctionsCount: u32 = 50;
pub HonzonTreasuryAccount: AccountId = HonzonTreasuryPalletId::get().into_account();
pub AlternativeSwapPathJointList: Vec<Vec<CurrencyId>> = vec![
vec![LCDOT],
vec![DOT],
vec![LDOT],
];
Expand Down Expand Up @@ -1128,7 +1129,11 @@ impl module_transaction_pause::Config for Runtime {

parameter_types! {
// Sort by fee charge order
pub DefaultFeeSwapPathList: Vec<Vec<CurrencyId>> = vec![vec![AUSD, DOT, ACA], vec![DOT, ACA], vec![LDOT, DOT, ACA]];
pub DefaultFeeSwapPathList: Vec<Vec<CurrencyId>> = vec![
vec![AUSD, ACA],
vec![LCDOT, AUSD, ACA],
vec![DOT, LCDOT, AUSD, ACA]
];
}

type NegativeImbalance = <Balances as PalletCurrency<AccountId>>::NegativeImbalance;
Expand Down Expand Up @@ -1181,7 +1186,7 @@ impl module_evm_accounts::Config for Runtime {
impl module_asset_registry::Config for Runtime {
type Event = Event;
type Currency = Balances;
type LiquidCrowdloanCurrencyId = GetStakingCurrencyId;
type StakingCurrencyId = GetStakingCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type RegisterOrigin = EnsureRootOrHalfGeneralCouncil;
type WeightInfo = weights::module_asset_registry::WeightInfo<Runtime>;
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub use precompile::{
StateRentPrecompile,
};
pub use primitives::{
currency::{TokenInfo, ACA, AUSD, BNC, DOT, KAR, KBTC, KINT, KSM, KUSD, LDOT, LKSM, PHA, RENBTC, VSKSM},
currency::{TokenInfo, ACA, AUSD, BNC, DOT, KAR, KBTC, KINT, KSM, KUSD, LCDOT, LDOT, LKSM, PHA, RENBTC, VSKSM},
AccountId,
};
use sp_std::{marker::PhantomData, prelude::*};
Expand Down
2 changes: 1 addition & 1 deletion runtime/common/src/precompile/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ impl module_evm_bridge::Config for Test {
impl module_asset_registry::Config for Test {
type Event = Event;
type Currency = Balances;
type LiquidCrowdloanCurrencyId = GetStakingCurrencyId;
type StakingCurrencyId = GetStakingCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Test>;
type RegisterOrigin = EnsureSignedBy<CouncilAccount, AccountId>;
type WeightInfo = ();
Expand Down
2 changes: 1 addition & 1 deletion runtime/karura/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ impl module_evm_accounts::Config for Runtime {
impl module_asset_registry::Config for Runtime {
type Event = Event;
type Currency = Balances;
type LiquidCrowdloanCurrencyId = GetStakingCurrencyId;
type StakingCurrencyId = GetStakingCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type RegisterOrigin = EnsureRootOrHalfGeneralCouncil;
type WeightInfo = weights::module_asset_registry::WeightInfo<Runtime>;
Expand Down
2 changes: 1 addition & 1 deletion runtime/mandala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@ impl module_evm_accounts::Config for Runtime {
impl module_asset_registry::Config for Runtime {
type Event = Event;
type Currency = Balances;
type LiquidCrowdloanCurrencyId = GetStakingCurrencyId;
type StakingCurrencyId = GetStakingCurrencyId;
type EVMBridge = module_evm_bridge::EVMBridge<Runtime>;
type RegisterOrigin = EnsureRootOrHalfGeneralCouncil;
type WeightInfo = weights::module_asset_registry::WeightInfo<Runtime>;
Expand Down

0 comments on commit 0c49594

Please sign in to comment.