A simple market maker bot for 01 Exchange. Be the liquidity you wish to see in the market.
Thanks to @c1ted.
- Node.js v25+ - Required for
Uint8Array.prototype.toHex()(TC39 proposal) used by the SDK
Use at your own risk. The author is not responsible for any losses incurred when using this code.
This code is intended for educational purposes ONLY - do not use this code for real trades unless you fully understand what it does.
This is not a sophisticated market making program. It is intended to demonstrate how to connect to 01 Exchange using the SDK. Test with a fresh account.
Note: Only tested with BTC and ETH markets.
# Install
npm i
# Setup
cp .env.example .env
# Edit .env and set PRIVATE_KEY
# Run BTC bot
npm run bot -- btc
# Run ETH bot
npm run bot -- eth
# Market monitor
npm run monitor -- btcsrc/
βββ bots/mm/ # Market Maker bot
β βββ index.ts # MarketMaker class
β βββ config.ts # Configuration
β βββ position.ts # Position tracking
β βββ quoter.ts # Quote generation
βββ cli/ # Entry points
β βββ bot.ts # Bot CLI
β βββ monitor.ts # Market monitor TUI
βββ pricing/ # Price feeds (shared)
β βββ binance.ts # Binance WebSocket
β βββ fair-price.ts # Fair price calculation
βββ sdk/ # 01 Exchange SDK (shared)
β βββ account.ts # Account stream
β βββ client.ts # SDK client wrapper
β βββ orderbook.ts # Orderbook stream
β βββ orders.ts # Order operations
βββ utils/ # Utilities (shared)
β βββ logger.ts # Logging
βββ types.ts # Shared types
Bot connects to 01 Exchange via official SDK (@n1xyz/nord-ts).
flowchart LR
Binance["Binance WS"]
Exchange["01 Exchange"]
subgraph Bot
SDK["SDK"]
Pricing["Pricing"]
Strategy["Strategy"]
end
Binance -->|"mid price"| Pricing
SDK <--> Exchange
SDK -->|"mid price"| Pricing
Pricing -->|"fair price"| Strategy
Strategy -->|"order requests"| SDK
SDK -.->|"positions, orders"| Strategy
Buy low, sell high.
|------- 10bps -------|------- 10bps -------|
Buy Order Fair Price Sell Order
$99,900 $100,000 $100,100
- Fair Price: Based on Binance mid
- Buy/Sell: Fair Β± spread
- Filled = bought low / sold high β profit
When position gets too big, switch to close mode:
- Normal: Quote both sides (10bps)
- Close: One side only, tighter spread (5bps)
Edit src/bots/mm/config.ts:
export const DEFAULT_CONFIG = {
spreadBps: 10, // Spread from fair price (10 bps = 0.1%)
takeProfitBps: 5, // Spread in close mode
orderSizeUsd: 100, // Order size in USD
closeThresholdUsd: 10, // Trigger close mode when position >= this
warmupSeconds: 10, // Seconds to warm up before quoting
updateThrottleMs: 100, // Min interval between quote updates
orderSyncIntervalMs: 3000, // Interval for syncing orders from API
statusIntervalMs: 1000, // Interval for status display
fairPriceWindowMs: 300000, // Window for fair price calculation (5 min)
positionSyncIntervalMs: 5000, // Interval for position sync
}npm run bot -- BTC
npm run bot -- ETH# Run market maker
npm run bot -- btc
# Market monitor
npm run monitor -- btc
# Build
npm run build
# Run benchmarks (watch mode)
npm run bench
# Run benchmarks (single run, CI-friendly)
npm run bench:run
# Or via make
make benchBenchmarks cover the tick-to-trade hot path β see docs/t2t-hot-path.md for details.
# Setup
cp .env.example .env
# Edit .env and set PRIVATE_KEY
# Run with docker compose
docker compose up -d
# View logs
docker compose logs -f
# Stop
docker compose down
# Rebuild after code changes
docker compose up -d --buildEdit docker-compose.yml to change the symbol or add more bots:
services:
mm-btc:
build: .
command: ["BTC"]
restart: unless-stopped
env_file:
- .env
mm-eth:
build: .
command: ["ETH"]
restart: unless-stopped
env_file:
- .env| Variable | Description | Required |
|---|---|---|
PRIVATE_KEY |
Base58 Solana private key | Yes |
RPC_URL |
Solana RPC endpoint (for monitor) | No |
LOG_LEVEL |
Log level: debug, info, warn, error | No |
npm run monitor -- btcMIT

