Skip to content

Commit

Permalink
Merge pull request #277 from huang-lei1/transfer
Browse files Browse the repository at this point in the history
DEX
  • Loading branch information
balqaasem authored Jun 14, 2021
2 parents a31afa2 + ca04f6a commit 63a4edf
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib-serml/dex/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ support = { package = "setheum-support", path = "../support", default-features =
primitives = { package = "setheum-primitives", path = "../../primitives", default-features = false }

[dev-dependencies]
orml-tokens = { path = "../../lib-openrml/tokens", default-features = false }
orml-tokens = { git = "https://github.com/open-web3-stack/open-runtime-module-library", branch = "master" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.4" }
sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.4" }
pallet-balances = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.4" }
Expand Down
4 changes: 2 additions & 2 deletions lib-serml/dex/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ ord_parameter_types! {
parameter_types! {
pub const GetExchangeFee: (u32, u32) = (1, 100);
pub const TradingPathLimit: u32 = 3;
pub const SetheumDexPalletId: PalletId = PalletId(*b"dnr/sdex");
pub const DexPalletId: PalletId = PalletId(*b"dnr/sdex");
}

impl Config for Runtime {
type Event = Event;
type Currency = Tokens;
type GetExchangeFee = GetExchangeFee;
type TradingPathLimit = TradingPathLimit;
type PalletId = SetheumDexPalletId;
type PalletId = DexPalletId;
type WeightInfo = ();
type DexIncentives = MockDexIncentives;
type ListingOrigin = EnsureSignedBy<ListingOrigin, AccountId>;
Expand Down
4 changes: 2 additions & 2 deletions lib-serml/incentives/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ impl SerpTreasury<AccountId> for MockSerpTreasury {
}
}

pub struct MockSetheumDex;
impl DexManager<AccountId, CurrencyId, Balance> for MockSetheumDex {
pub struct MockDex;
impl DexManager<AccountId, CurrencyId, Balance> for MockDex {
fn get_liquidity_pool(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance) {
match (currency_id_a, currency_id_b) {
(SETT, CHFJ) => (500, 100),
Expand Down
6 changes: 3 additions & 3 deletions lib-serml/prices/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ impl DataFeeder<CurrencyId, Price, AccountId> for MockDataProvider {
}
}

pub struct MockSetheumDex;
impl DexManager<AccountId, CurrencyId, Balance> for MockSetheumDex {
pub struct MockDex;
impl DexManager<AccountId, CurrencyId, Balance> for MockDex {
fn get_liquidity_pool(currency_id_a: CurrencyId, currency_id_b: CurrencyId) -> (Balance, Balance) {
match (currency_id_a, currency_id_b) {
(USDJ, DNAR) => (10000, 200),
Expand Down Expand Up @@ -268,7 +268,7 @@ impl Config for Runtime {
type StableCurrencyIds = StableCurrencyIds;
type FiatCurrencyIds = FiatCurrencyIds;
type LockOrigin = EnsureSignedBy<One, AccountId>;
type Dex = MockSetheumDex;
type Dex = MockDex;
type Currency = Tokens;
type WeightInfo = ();
}
Expand Down
4 changes: 2 additions & 2 deletions lib-serml/prices/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn get_price_of_stable_currency_id() {
#[test]
fn get_price_of_lp_token_currency_id() {
ExtBuilder::default().build().execute_with(|| {
assert_eq!(MockSetheumDex::get_liquidity_pool(USDJ, DNAR), (10000, 200));
assert_eq!(MockDex::get_liquidity_pool(USDJ, DNAR), (10000, 200));
assert_eq!(
PricesModule::get_price(LP_USDJ_DNAR),
None
Expand All @@ -65,7 +65,7 @@ fn get_price_of_lp_token_currency_id() {
Some(Price::saturating_from_rational(200000000u128, 1)) // 10000/100 * Price::saturating_from_rational(1000000u128, 1) * 2
);

assert_eq!(MockSetheumDex::get_liquidity_pool(JCHF, USDJ), (0, 0));
assert_eq!(MockDex::get_liquidity_pool(JCHF, USDJ), (0, 0));
assert_eq!(
PricesModule::get_price(LP_JCHF_USDJ),
None
Expand Down
2 changes: 1 addition & 1 deletion lib-serml/transaction-payment/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ impl setheum_dex::Config for Runtime {
type Currency = Currencies;
type GetExchangeFee = GetExchangeFee;
type TradingPathLimit = TradingPathLimit;
type PalletId = SetheumDexPalletId;
type PalletId = DexPalletId;
type DexIncentives = ();
type WeightInfo = ();
type ListingOrigin = frame_system::EnsureSignedBy<Zero, AccountId>;
Expand Down
4 changes: 3 additions & 1 deletion primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ pub type Block = generic::Block<Header, UncheckedExtrinsic>;
/// Block ID.
pub type BlockId = generic::BlockId<Block>;

pub type NFTBalance = u128;

/// Opaque, encoded, unchecked extrinsic.
pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;

Expand All @@ -96,7 +98,7 @@ pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;
pub enum AuthoritysOriginId {
Root,
SetheumTreasury,
SettwayTreasury,
SerpTreasury,
SIF,
}

Expand Down

0 comments on commit 63a4edf

Please sign in to comment.