A Solidity smart contract backend for a lightweight order-book decentralized exchange. Combines ERC-20 token custody, market pair registration, EIP-712 signed orders, and single or batched trade settlement through a matching engine contract.
The repository also includes a market data UDF service under binanceudf/ for serving TradingView-compatible chart data during frontend development.
contracts/MatchingEngine.sol- verifies signed buy and sell orders, tracks filled quantities, and settles matched trades.contracts/Wallets.sol- handles token deposits, withdrawals, and internal balances.contracts/Markets.sol- registers active tokens and base/market pairs.contracts/Tokens.sol- local ERC-20 test tokens.scripts/- Brownie deployment and EIP-712 helper scripts.tests/- Brownie tests for signatures, deposits, single trades, and batched trades.binanceudf/- optional TradingView UDF data source backed by market data.
- Python 3 with Brownie
- Node.js and npm
- Python packages:
eip712-structseth_abi
Install Solidity dependencies:
npm installInstall Python dependencies:
pip install eth-brownie eip712-structs eth_abiRun the Brownie test suite from the repository root:
brownie testThe tests use local Brownie accounts and exercise deposit, signature verification, and trade settlement flows.
Deploy to a local development chain:
export BROWNIE_ACCOUNT="your-brownie-account"
brownie run scripts/deploy.py --network developmentDeploy to a testnet:
export BROWNIE_ACCOUNT="your-brownie-account"
export BOT_ACCOUNT="0x0000000000000000000000000000000000000000"
brownie run scripts/deploy.py --network <network-name>BROWNIE_ACCOUNT is required. BOT_ACCOUNT is optional and defaults to the deployer address when not set.
The optional market data UDF service lives in binanceudf/.
cd binanceudf
npm install
npm startDefault port is 80. See binanceudf/README.md for Docker setup details.
- Orders are signed using EIP-712 with domain name
OrderBookand version1.0.0. tradeMultibatches paired buy and sell orders to reduce settlement overhead.- Pair ID
1is assumed by the current batched trade path; update before generalizing to multiple markets.
This code is experimental and has not been audited. Do not deploy with real funds until the contracts, signing flow, and settlement logic have been reviewed and tested for production use.