Skip to content

Commit

Permalink
Feature/spot (paritytech#193)
Browse files Browse the repository at this point in the history
support xdex/spot
  • Loading branch information
toxotguo authored Jan 10, 2019
1 parent 006115d commit f60266d
Show file tree
Hide file tree
Showing 19 changed files with 1,387 additions and 3,291 deletions.
33 changes: 6 additions & 27 deletions Cargo.lock

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

5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,11 @@ members = [
"xrml/xfee/manager",
# xrml/assets
"xrml/xassets/assets",
"xrml/xdex/spot/xpendingorders",
"xrml/xdex/spot/xmatchorder",
"xrml/xdex/spot",
"xrml/xassets/records",
"xrml/xassets/process",
# xrml/mining
"xrml/xmining/staking",
"xrml/xmining/tokens",
"xrml/xbridge/bitcoin",
]
]
23 changes: 9 additions & 14 deletions cli/src/genesis_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ extern crate substrate_primitives;

use self::base58::FromBase58;
use chainx_runtime::GrandpaConfig;
use chainx_runtime::xassets;

use chainx_runtime::{
xassets::{Asset, Chain, ChainT},
xbitcoin, Runtime,
};
use chainx_runtime::{
BalancesConfig, ConsensusConfig, GenesisConfig, Params, Perbill, Permill, SessionConfig,
TimestampConfig, XAccountsConfig, XAssetsConfig, XBridgeOfBTCConfig, XFeeManagerConfig,
XMatchOrderConfig, XPendingOrdersConfig, XStakingConfig, XSystemConfig,
XSpotConfig, XStakingConfig, XSystemConfig,
};

use ed25519;
Expand Down Expand Up @@ -73,7 +75,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
transfer_fee: 0,
creation_fee: 0,
reclaim_rebate: 0,
balances: vec![(Keyring::Alice.to_raw_public().into(), 1_000_000)],
balances: vec![(Keyring::Alice.to_raw_public().into(), 1_000_000_000),(Keyring::Bob.to_raw_public().into(), 1_000_000_000)],
};
//let balances_config_copy = BalancesConfigCopy::create_from_src(&balances_config).src();

Expand Down Expand Up @@ -129,7 +131,7 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
// asset, is_psedu_intention, init for account
// Vec<(Asset, bool, Vec<(T::AccountId, u64)>)>;
asset_list: vec![
(btc_asset, true, vec![])
(btc_asset, true, vec![(Keyring::Alice.to_raw_public().into(), 1_000_000_000),(Keyring::Bob.to_raw_public().into(), 1_000_000_000)])
],
}),
xstaking: Some(XStakingConfig {
Expand All @@ -148,18 +150,11 @@ pub fn testnet_genesis(genesis_spec: GenesisSpec) -> GenesisConfig {
.map(|i| i.0.into())
.collect(),
}),
xpendingorders: Some(XPendingOrdersConfig {
order_fee: 10,
pair_list: vec![],
xspot: Some(XSpotConfig {
pair_list: vec![(<xassets::Module<Runtime> as ChainT>::TOKEN.to_vec(),<xbitcoin::Module<Runtime> as ChainT>::TOKEN.to_vec(),5,true)],
// (OrderPair { first: Runtime::CHAINX_SYMBOL.to_vec(), second: BridgeOfBTC::SYMBOL.to_vec() }, 8)
max_command_id: 0,
average_price_len: 10000,
}),
xmatchorder: Some(XMatchOrderConfig {
match_fee: 10,
fee_precision: 100000,
maker_match_fee: 50,
taker_match_fee: 100,
price_volatility: 10,
_genesis_phantom_data: Default::default(),
}),
xbitcoin: Some(XBridgeOfBTCConfig {
// start genesis block: (genesis, blocknumber)
Expand Down
6 changes: 2 additions & 4 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ xrml-mining-tokens = { path = "../xrml/xmining/tokens", default-features = false
# bridge
xrml-xbridge-bitcoin = {path = "../xrml/xbridge/bitcoin", default-features = false }
# dex
xrml-xdex-spot-xmatchorder = { path = "../xrml/xdex/spot/xmatchorder", default-features = false }
xrml-xdex-spot-xpendingorders = { path = "../xrml/xdex/spot/xpendingorders", default-features = false }
xrml-xdex-spot = { path = "../xrml/xdex/spot", default-features = false }

[features]
default = ["std"]
Expand Down Expand Up @@ -110,6 +109,5 @@ std = [
# bridge
"xrml-xbridge-bitcoin/std",
# dex
"xrml-xdex-spot-xmatchorder/std",
"xrml-xdex-spot-xpendingorders/std",
"xrml-xdex-spot/std",
]
6 changes: 6 additions & 0 deletions runtime/src/fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use xassets::Call as XAssetsCall;
use xbitcoin::Call as XbitcoinCall;
use xprocess::Call as XAssetsProcessCall;
use xstaking::Call as XStakingCall;
use xspot::Call as XSpotCall;

use Acceleration;
use Call;
Expand Down Expand Up @@ -48,6 +49,11 @@ impl CheckFee for Call {
XStakingCall::claim(_) => Some(3),
_ => None,
},
Call::XSpot(call)=>match call{
XSpotCall::put_order(_,_,_,_,_) =>Some(8),
XSpotCall::cancel_order(_,_)=>Some(2),
_ => None,
},
_ => None,
};

Expand Down
14 changes: 4 additions & 10 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ pub extern crate xrml_mining_staking as xstaking;
pub extern crate xrml_mining_tokens as xtokens;

// dex
pub extern crate xrml_xdex_spot_xmatchorder as xmatchorder;
pub extern crate xrml_xdex_spot_xpendingorders as xpendingorders;
pub extern crate xrml_xdex_spot as xspot;

mod fee;
mod xexecutive;
Expand Down Expand Up @@ -271,15 +270,11 @@ impl xstaking::Trait for Runtime {
type Event = Event;
}

impl xpendingorders::Trait for Runtime {
impl xspot::Trait for Runtime {
type Event = Event;
type Amount = u128;
type Price = u128;
type Price = Balance;
}

impl xmatchorder::Trait for Runtime {
type Event = Event;
}

construct_runtime!(
pub enum Runtime with Log(InternalLog: DigestItem<Hash, SessionKey>) where
Expand Down Expand Up @@ -307,8 +302,7 @@ construct_runtime!(
// mining
XStaking: xstaking,
// dex
XPendingOrders: xpendingorders,
XMatchOrder: xmatchorder,
XSpot: xspot,
// bridge
XBridgeOfBTC: xbitcoin::{Module, Call, Storage, Config<T>, Event<T>},
}
Expand Down
33 changes: 6 additions & 27 deletions runtime/wasm/Cargo.lock

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

Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "xrml-xdex-spot-xpendingorders"
name = "xrml-xdex-spot"
version = "0.4.0"
authors = ["Chainpool <https://www.chainx.org>"]

Expand All @@ -16,14 +16,19 @@ sr-primitives = { git = "https://github.com/chainpool/substrate", default_featur
srml-support = { git = "https://github.com/chainpool/substrate", default_features = false }
srml-system = { git = "https://github.com/chainpool/substrate", default_features = false }
srml-balances = { git = "https://github.com/chainpool/substrate", default_features = false }
srml-consensus = { git = "https://github.com/chainpool/substrate", default_features = false }

srml-timestamp = { git = "https://github.com/chainpool/substrate", default_features = false }

log = "0.4"

# cxrml module
xrml-xsystem = { path = "../../../xsystem", default-features = false }
xrml-xaccounts = { path = "../../../xaccounts", default-features = false }
xrml-xsupport = { path = "../../../xsupport", default_features = false }
xrml-xassets-assets = { path = "../../../xassets/assets", default_features = false }
xrml-xsystem = { path = "../../xsystem", default-features = false }
xrml-xaccounts = { path = "../../xaccounts", default-features = false }
xrml-xsupport = { path = "../../xsupport", default_features = false }
xrml-xassets-assets = { path = "../../xassets/assets", default_features = false }
xrml-xbridge-bitcoin = {path = "../../xbridge/bitcoin", default-features = false }
xrml-xassets-records = { path = "../../xassets/records", default-features = false }

[features]
default = ["std"]
Expand Down
Loading

0 comments on commit f60266d

Please sign in to comment.