Fast dual-server price feed simulator for testing MEV bots and liquidation strategies. Includes interactive visualizer + starter (AI) testing scripts.
ETH-sim simulates two different price feeds for Ethereum:
- DEX Feed: High frequency noisy market data (10-100ms updates)
- Oracle Feed: Chainlink deviation/heartbeat updates (triggers on ≥0.05% price change or 1 hr heartbeat)
Made for testing arbitrage bots, liquidation systems, and oracle-dependent DeFi strategies in a controlled environment.
Tune feed parameters in /configs as desired.
- macOS
- homebrew
# 1. Install dependencies (one-time setup)
./INSTALL_DEPS.sh
# 2. Build the project
./build.shmanual build:
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
# DEX
./build/src/dex_sim/dex-sim
# oracle
./build/src/oracle_sim/oracle-sim
# visualizer
open http://localhost:9101/dual.html- ✅ Dual WebSocket Feeds: DEX (10-100ms) + Oracle (deviation/heartbeat)
- ✅ Geometric Brownian Motion: Realistic price simulation (200% volatility)
- ✅ Deviation Triggers: Chainlink-like updates on ≥N bps price change
- ✅ Heartbeat Triggers: Guaranteed updates every N seconds
- ✅ Real-time Visualizer: Beautiful dual-feed chart in browser
- ✅ Deterministic RNG: Reproducible simulations
- ✅ Fault Injection: Packet loss/duplication for stress testing
- ✅ Prometheus Metrics: Production-ready monitoring
- ✅ 100% Feature Parity: Identical to Rust version
DEX Simulator (9101) Oracle Simulator (9102)
├── GBM Price Engine ├── GBM Price Engine
├── High Frequency (10-100ms) ├── Deviation Check (±N bps)
├── Burst Mode Support ├── Heartbeat (N seconds)
├── Fault Injection ├── Fault Injection
└── WebSocket /ws/ticks └── WebSocket /ws/prices
│ │
└─────────┬───────────────────┘
│
Browser Visualizer
(dual.html)
GET /healthz- Health checkGET /metrics- Prometheus metricsGET /prices/snapshot- Latest price (JSON)WebSocket /ws/ticks- Real-time streamGET /dual.html- Visualizer
GET /healthz- Health checkGET /metrics- Prometheus metricsGET /oracle/snapshot- Latest oracle price (JSON)WebSocket /ws/prices- Real-time stream
price_start: 3500.0 # Must match Oracle
gbm_sigma: 2.0 # 200% volatility (demo)
dex_tick_ms:
min: 10 # High frequency
max: 100
dex_burst_mode: true # Alternates fast/slow
dex_p_drop: 0.02 # 2% packet lossprice_start: 3500.0 # Must match DEX
gbm_sigma: 2.0 # Same as DEX
oracle_tick_ms:
min: 1000 # Check every 1-3.6s
max: 3600
oracle_deviation_bps: 1 # 0.01% trigger (demo)
# Use 10-50 for realistic
oracle_heartbeat_ms: 3600000 # 1 hour# Run all tests (unit + integration)
./run_all_tests.sh
# Unit tests only (19 tests)
./build/tests/test_core
# Integration tests only
./tests/integration_test.sh{
"type": "price",
"ts": 1699123456789,
"pair": "ETH/USD",
"price": 3500.50,
"source": "dex",
"src_seq": 42,
"delay_ms": 10,
"stale": false
}MEV Bot Testing: Test frontrunning against realistic DEX/Oracle spreads Liquidation Bots: Validate triggers with Oracle price updates Oracle Integration: Test Chainlink-dependent logic offline Stress Testing: Fault injection for network reliability testing
CMake cache errors: Delete build/ directory and run ./build.sh again
rm -rf build && ./build.shBuild fails: Run ./INSTALL_DEPS.sh to install dependencies
./INSTALL_DEPS.shPort already in use: Kill existing instances
pkill -f dex-sim; pkill -f oracle-simVisualizer disconnected: Check servers are running
curl http://localhost:9101/healthz
curl http://localhost:9102/healthzNo Oracle updates: Lower oracle_deviation_bps to 1-10 bps in configs/oracle.yaml
Check logs: If using ./run.sh, logs are in /tmp/dex-sim.log and /tmp/oracle-sim.log