From f283b534295244d53221c597148193bc082331f1 Mon Sep 17 00:00:00 2001 From: Muhammad-Jibril Date: Fri, 3 Sep 2021 02:04:50 +0800 Subject: [PATCH] Update Runtime and mocks with EFE --- lib-serml/serp/serp-treasury/src/mock.rs | 45 +++++++------- lib-serml/setmint/setmint-engine/src/mock.rs | 47 ++++++++------- lib-serml/setmint/setmint-gateway/src/mock.rs | 47 ++++++++------- lib-serml/setmint/setmint-manager/src/mock.rs | 47 ++++++++------- lib-serml/tokens/currencies/src/mock.rs | 60 +++++++------------ lib-serml/transaction-payment/src/mock.rs | 6 ++ runtime/common/src/precompile/mock.rs | 11 ++++ runtime/newrome/src/lib.rs | 7 ++- runtime/setheum/src/lib.rs | 7 ++- 9 files changed, 147 insertions(+), 130 deletions(-) diff --git a/lib-serml/serp/serp-treasury/src/mock.rs b/lib-serml/serp/serp-treasury/src/mock.rs index de4162cfe..a93800e99 100644 --- a/lib-serml/serp/serp-treasury/src/mock.rs +++ b/lib-serml/serp/serp-treasury/src/mock.rs @@ -136,8 +136,30 @@ impl orml_currencies::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; + pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ + pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ + pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ + + pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); + pub const CharityFundAccountId: AccountId = CHARITY_FUND; + pub const SettPayTreasuryAccountId: AccountId = SETRPAY; + pub const CashDropVaultAccountId: AccountId = VAULT; + + pub CashDropPeriod: BlockNumber = 120; +} + parameter_types! { pub const GetExchangeFee: (u32, u32) = (1, 100); + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 200); // 0.5% pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ @@ -158,7 +180,9 @@ parameter_types! { impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = (); @@ -195,27 +219,6 @@ ord_parameter_types! { pub const One: AccountId = 1; } -parameter_types! { - pub StableCurrencyIds: Vec = vec![ - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ - pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ - pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ - - pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); - pub const CharityFundAccountId: AccountId = CHARITY_FUND; - pub const SettPayTreasuryAccountId: AccountId = SETRPAY; - pub const CashDropVaultAccountId: AccountId = VAULT; - - pub CashDropPeriod: BlockNumber = 120; -} - parameter_type_with_key! { pub MinimumClaimableTransferAmounts: |currency_id: CurrencyId| -> Balance { match currency_id { diff --git a/lib-serml/setmint/setmint-engine/src/mock.rs b/lib-serml/setmint/setmint-engine/src/mock.rs index f9723735d..3be304f35 100644 --- a/lib-serml/setmint/setmint-engine/src/mock.rs +++ b/lib-serml/setmint/setmint-engine/src/mock.rs @@ -180,9 +180,32 @@ impl PriceProvider for MockPriceSource { fn unlock_price(_currency_id: CurrencyId) {} } +parameter_types! { + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; + pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ + pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ + pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ + + pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); + pub const CharityFundAccountId: AccountId = CHARITY_FUND; + pub const SettPayTreasuryAccountId: AccountId = SETRPAY; + pub const CashDropVaultAccountId: AccountId = VAULT; + + pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks + pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); +} + parameter_types! { pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const GetExchangeFee: (u32, u32) = (1, 1000); // 0.1% + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 2000); // 0.05% pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ TradingPair::from_currency_ids(DNAR, SETR).unwrap(), @@ -202,7 +225,9 @@ parameter_types! { impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = (); @@ -210,28 +235,6 @@ impl setheum_dex::Config for Runtime { type ListingOrigin = EnsureSignedBy; } -parameter_types! { - pub StableCurrencyIds: Vec = vec![ - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ - pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ - pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ - - pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); - pub const CharityFundAccountId: AccountId = CHARITY_FUND; - pub const SettPayTreasuryAccountId: AccountId = SETRPAY; - pub const CashDropVaultAccountId: AccountId = VAULT; - - pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks - pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); -} - parameter_type_with_key! { pub MinimumClaimableTransferAmounts: |currency_id: CurrencyId| -> Balance { match currency_id { diff --git a/lib-serml/setmint/setmint-gateway/src/mock.rs b/lib-serml/setmint/setmint-gateway/src/mock.rs index 347fca055..80f9de609 100644 --- a/lib-serml/setmint/setmint-gateway/src/mock.rs +++ b/lib-serml/setmint/setmint-gateway/src/mock.rs @@ -155,9 +155,32 @@ ord_parameter_types! { pub const One: AccountId = 1; } +parameter_types! { + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; + pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ + pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ + pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ + + pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); + pub const CharityFundAccountId: AccountId = CHARITY_FUND; + pub const SettPayTreasuryAccountId: AccountId = SETRPAY; + pub const CashDropVaultAccountId: AccountId = VAULT; + + pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks + pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); +} + parameter_types! { pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const GetExchangeFee: (u32, u32) = (1, 1000); // 0.1% + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 2000); // 0.05% pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ TradingPair::from_currency_ids(DNAR, SETR).unwrap(), @@ -177,7 +200,9 @@ parameter_types! { impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = (); @@ -185,28 +210,6 @@ impl setheum_dex::Config for Runtime { type ListingOrigin = EnsureSignedBy; } -parameter_types! { - pub StableCurrencyIds: Vec = vec![ - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ - pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ - pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ - - pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); - pub const CharityFundAccountId: AccountId = CHARITY_FUND; - pub const SettPayTreasuryAccountId: AccountId = SETRPAY; - pub const CashDropVaultAccountId: AccountId = VAULT; - - pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks - pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); -} - parameter_type_with_key! { pub MinimumClaimableTransferAmounts: |currency_id: CurrencyId| -> Balance { match currency_id { diff --git a/lib-serml/setmint/setmint-manager/src/mock.rs b/lib-serml/setmint/setmint-manager/src/mock.rs index fba221408..01f492d0d 100644 --- a/lib-serml/setmint/setmint-manager/src/mock.rs +++ b/lib-serml/setmint/setmint-manager/src/mock.rs @@ -136,8 +136,31 @@ impl orml_currencies::Config for Runtime { } pub type AdaptedBasicCurrency = orml_currencies::BasicCurrencyAdapter; +parameter_types! { + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; + pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ + pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ + pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ + + pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); + pub const CharityFundAccountId: AccountId = CHARITY_FUND; + pub const SettPayTreasuryAccountId: AccountId = SETRPAY; + pub const CashDropVaultAccountId: AccountId = VAULT; + + pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks + pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); +} + parameter_types! { pub const GetExchangeFee: (u32, u32) = (1, 100); + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 200); pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ @@ -158,7 +181,9 @@ parameter_types! { impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = (); @@ -195,28 +220,6 @@ ord_parameter_types! { pub const One: AccountId = 1; } -parameter_types! { - pub StableCurrencyIds: Vec = vec![ - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ - pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ - pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ - - pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); - pub const CharityFundAccountId: AccountId = CHARITY_FUND; - pub const SettPayTreasuryAccountId: AccountId = SETRPAY; - pub const CashDropVaultAccountId: AccountId = VAULT; - - pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks - pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); -} - parameter_type_with_key! { pub MinimumClaimableTransferAmounts: |currency_id: CurrencyId| -> Balance { match currency_id { diff --git a/lib-serml/tokens/currencies/src/mock.rs b/lib-serml/tokens/currencies/src/mock.rs index 115aff30d..c1968ab59 100644 --- a/lib-serml/tokens/currencies/src/mock.rs +++ b/lib-serml/tokens/currencies/src/mock.rs @@ -203,8 +203,27 @@ impl orml_currencies::Config for Runtime { type WeightInfo = (); } +parameter_types! { + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; + pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ + pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ + pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ + + pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); + + pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks +} + parameter_types! { pub const GetExchangeFee: (u32, u32) = (1, 100); + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 200); pub const DexPalletId: PalletId = PalletId(*b"set/sdex"); pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ @@ -225,7 +244,9 @@ parameter_types! { impl setheum_dex::Config for Runtime { type Event = Event; type Currency = OrmlCurrencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = (); @@ -262,45 +283,6 @@ ord_parameter_types! { pub const One: AccountId32 = AccountId32::from([11u8; 32]); } -parameter_types! { - pub StableCurrencyIds: Vec = vec![ - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub const SetterCurrencyId: CurrencyId = SETR; // Setter currency ticker is SETR/ - pub const GetSetUSDCurrencyId: CurrencyId = SETUSD; // Setter currency ticker is SETUSD/ - pub const DirhamCurrencyId: CurrencyId = DRAM; // SettinDEX currency ticker is DRAM/ - - pub const SerpTreasuryPalletId: PalletId = PalletId(*b"set/serp"); - - pub SerpTesSchedule: BlockNumber = 60; // Triggers SERP-TES for serping after Every 60 blocks - pub CashDropPeriod: BlockNumber = 120; // Triggers SERP-TES for serping after Every 60 blocks - pub MaxSlippageSwapWithDEX: Ratio = Ratio::one(); - - pub RewardableCurrencyIds: Vec = vec![ - DNAR, - DRAM, - SETR, - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; - pub NonStableDropCurrencyIds: Vec = vec![DNAR, DRAM]; - pub SetCurrencyDropCurrencyIds: Vec = vec![ - SETCHF, - SETEUR, - SETGBP, - SETSAR, - SETUSD, - ]; -} - parameter_type_with_key! { pub MinimumClaimableTransferAmounts: |currency_id: CurrencyId| -> Balance { match currency_id { diff --git a/lib-serml/transaction-payment/src/mock.rs b/lib-serml/transaction-payment/src/mock.rs index 46b929a2d..d08e31779 100644 --- a/lib-serml/transaction-payment/src/mock.rs +++ b/lib-serml/transaction-payment/src/mock.rs @@ -262,17 +262,23 @@ ord_parameter_types! { parameter_types! { pub const DEXPalletId: PalletId = PalletId(*b"set/sdex"); pub const GetExchangeFee: (u32, u32) = (0, 100); + pub const GetStableCurrencyExchangeFee: (u32, u32) = (0, 100); pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ TradingPair::from_currency_ids(SETR, DNAR).unwrap(), TradingPair::from_currency_ids(SETR, DRAM).unwrap(), ]; + pub StableCurrencyIds: Vec = vec![ + SETR, + ]; } impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DEXPalletId; type CurrencyIdMapping = (); diff --git a/runtime/common/src/precompile/mock.rs b/runtime/common/src/precompile/mock.rs index caa237d70..d5f904a18 100644 --- a/runtime/common/src/precompile/mock.rs +++ b/runtime/common/src/precompile/mock.rs @@ -434,14 +434,25 @@ ord_parameter_types! { parameter_types! { pub const GetExchangeFee: (u32, u32) = (1, 100); + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 200); pub const TradingPathLimit: u32 = 3; pub const DEXPalletId: PalletId = PalletId(*b"set/sdex"); + pub StableCurrencyIds: Vec = vec![ + SETR, + SETCHF, + SETEUR, + SETGBP, + SETSAR, + SETUSD, + ]; } impl setheum_dex::Config for Test { type Event = Event; type Currency = Tokens; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DEXPalletId; type CurrencyIdMapping = EvmCurrencyIdMapping; diff --git a/runtime/newrome/src/lib.rs b/runtime/newrome/src/lib.rs index 8ebed3114..6d15653db 100644 --- a/runtime/newrome/src/lib.rs +++ b/runtime/newrome/src/lib.rs @@ -1053,7 +1053,8 @@ impl setmint_gateway::Config for Runtime { } parameter_types! { - pub const GetExchangeFee: (u32, u32) = (1, 1000); // 0.1% + pub const GetExchangeFee: (u32, u32) = (3, 1000); // 0.3% + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 1000); // 0.1% pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ TradingPair::new(SETR, DNAR), @@ -1065,12 +1066,15 @@ parameter_types! { TradingPair::new(SETR, SETSAR), TradingPair::new(SETR, RENBTC), ]; + pub StableCurrencyIds: Vec = vec![SETR, SETUSD, SETEUR, SETGBP, SETCHF, SETSAR]; } impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = EvmCurrencyIdMapping; @@ -1119,7 +1123,6 @@ parameter_type_with_key! { parameter_types! { pub MaxSwapSlippageCompareToOracle: Ratio = Ratio::saturating_from_rational(1, 2); - pub StableCurrencyIds: Vec = vec![SETR, SETUSD, SETEUR, SETGBP, SETCHF, SETSAR]; pub DefaultFeeSwapPathList: Vec> = vec![ vec![SETR, DNAR], vec![SETUSD, SETR, DRAM] diff --git a/runtime/setheum/src/lib.rs b/runtime/setheum/src/lib.rs index 179568262..3419fc8cb 100644 --- a/runtime/setheum/src/lib.rs +++ b/runtime/setheum/src/lib.rs @@ -1069,7 +1069,8 @@ impl setmint_gateway::Config for Runtime { } parameter_types! { - pub const GetExchangeFee: (u32, u32) = (1, 1000); // 0.1% + pub const GetExchangeFee: (u32, u32) = (3, 1000); // 0.3% + pub const GetStableCurrencyExchangeFee: (u32, u32) = (1, 1000); // 0.1% pub const TradingPathLimit: u32 = 3; pub EnabledTradingPairs: Vec = vec![ TradingPair::new(SETR, DNAR), @@ -1081,12 +1082,15 @@ parameter_types! { TradingPair::new(SETR, SETSAR), TradingPair::new(SETR, RENBTC), ]; + pub StableCurrencyIds: Vec = vec![SETR, SETUSD, SETEUR, SETGBP, SETCHF, SETSAR]; } impl setheum_dex::Config for Runtime { type Event = Event; type Currency = Currencies; + type StableCurrencyIds = StableCurrencyIds; type GetExchangeFee = GetExchangeFee; + type GetStableCurrencyExchangeFee = GetStableCurrencyExchangeFee; type TradingPathLimit = TradingPathLimit; type PalletId = DexPalletId; type CurrencyIdMapping = EvmCurrencyIdMapping; @@ -1134,7 +1138,6 @@ parameter_type_with_key! { parameter_types! { pub MaxSwapSlippageCompareToOracle: Ratio = Ratio::saturating_from_rational(1, 2); - pub StableCurrencyIds: Vec = vec![SETR, SETUSD, SETEUR, SETGBP, SETCHF, SETSAR]; pub DefaultFeeSwapPathList: Vec> = vec![ vec![SETR, DNAR], vec![SETUSD, SETR, DRAM]