MCPcopy Index your code
hub / github.com/alexxuyang/substrate-dex

github.com/alexxuyang/substrate-dex @substrate1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release substrate1.0 ↗ · + Follow
83 symbols 125 edges 13 files 11 documented · 13%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Dex demo build by substrate

This is a decentralized exchange (DEX) build by substrate.

WARNING This project is just for demo/poc/self-learning. The author does not guarantee any availability or stability. And we DO NOT suggest use it in any production environment.

Any questions, feel free to post an issue.

Please refer to the wiki for the detail information. (Continuously updated)

Build

Install Rust:

curl https://sh.rustup.rs -sSf | sh

Install required tools:

./scripts/init.sh

Build Wasm and native code:

cargo build

Run

Single node development chain

You can start a development chain with:

cargo run -- --dev

Detailed logs may be shown by running the node with the following environment variables set: RUST_LOG=debug RUST_BACKTRACE=1 cargo run -- --dev.

Play with the dex

Please refer the client/transactions-api to see how to play with the dex chain. You can:

  • issue the token
  • transfer the token
  • create the trade pair
  • create the limit order
  • cancel the limit order

Also, you can play with it by polkadotjs wallet frontend with:

git clone https://github.com/polkadot-js/apps
cd apps
yarn
yarn start

Then open the link http://localhost:3000/#/?rpc=ws://127.0.0.1:9944

How to test

Test all the test cases by:

cargo test -p substrate-dex-runtime -- --test-threads=1 --nocapture

Or you can just run one of the test cases by:

cargo test [TEST_CASE_NAME] -p substrate-dex-runtime -- --test-threads=1 --nocapture

About next step

  • Will provide a full-feature dex front-end build with polkadotjs
  • Will upgrade to substrate 2.0 whenever it released

Extension points exported contracts — how you extend this code

Trait (Interface)
(no doc) [14 implementers]
runtime/src/trade.rs
Trait (Interface)
(no doc) [3 implementers]
runtime/src/token.rs

Core symbols most depended-on inside this repo

output_order
called by 13
runtime/src/trade.rs
new_test_ext
called by 9
runtime/src/trade.rs
run_to_block
called by 6
runtime/src/trade.rs
run_until_exit
called by 2
src/cli.rs
main
called by 1
client/transactions-api/index.js
new_full
called by 1
src/service.rs
new_light
called by 1
src/service.rs
run
called by 1
src/cli.rs

Shape

Method 41
Function 28
Class 9
Enum 3
Interface 2

Languages

Rust99%
TypeScript1%

Modules by API surface

runtime/src/trade.rs40 symbols
runtime/src/types.rs14 symbols
runtime/src/token.rs10 symbols
src/chain_spec.rs7 symbols
src/cli.rs5 symbols
src/service.rs2 symbols
src/main.rs1 symbols
runtime/src/lib.rs1 symbols
runtime/build.rs1 symbols
client/transactions-api/index.js1 symbols
build.rs1 symbols

For agents

$ claude mcp add substrate-dex \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact