ZELVEX is a Rust workspace that implements the initial scaffolding for a DeFi arbitrage bot stack: config loading, SQLite persistence/migrations, an API server (REST + WebSocket), and core math and subscription primitives.
This repository enforces a strict quality gate: no warnings, no unused code, formatting checked, tests required.
zelvex-types: shared domain typeszelvex-config:config.tomlloader +ZELVEX_*env overrideszelvex-db: SQLite migrations + query helperszelvex-core: AMM math + websocket subscription scaffolding (new heads, Uniswap V2 Sync logs)zelvex-gas: gas oracle (ring buffer + p90 priority fee)zelvex-sim: profit decision engine (evaluate)zelvex-exec: execution helpers (key loading)zelvex-api: REST + WebSocket API server, JWT auth, static web UI servingzelvex-bin: binary wiring everything togetherweb-ui: minimal UI served by the API
Install the latest stable Rust toolchain (includes cargo and rustfmt).
Create a config.toml (example below). Do not commit secrets.
[node]
ws_url = "ws://127.0.0.1:8546"
[flashbots]
relay_url = "https://relay.flashbots.net"
[bot]
min_profit_usd = 5.0
max_gas_gwei = 50
paper_trade = true
[server]
bind_addr = "127.0.0.1:8080"
web_ui_path = "./web-ui"
[database]
path = "./zelvex.sqlite"
[auth]
jwt_secret = "CHANGE_ME"
jwt_expiry_seconds = 86400
[keys]
signer_key_path = "./keys/signer.key"
flashbots_key_path = "./keys/flashbots.key"
contract_address = "0x0000000000000000000000000000000000000000"
aave_pool_provider = "0x2f39d218133AFaB8F2B819B1066c7E434Ad94E9e"cargo run -p zelvex-bin -- --config ./config.tomlThis will:
- open/create the SQLite database
- run migrations
- start the HTTP server on
server.bind_addr - serve the UI from
server.web_ui_path
POST /api/auth/register- one-time bootstrap: once a user exists, registration is disabled
POST /api/auth/login- returns JWT
Send JWT in:
Authorization: Bearer <token>
GET /ws- first message must be
{"type":"auth","token":"<jwt>"}within 5 seconds - server replies with
{"type":"auth_ok"}or{"type":"auth_fail","reason":"invalid"}
- first message must be
POST /api/bot/startPOST /api/bot/stopGET /api/bot/status
GET /api/stats/pnlGET /api/stats/gasGET /api/stats/opportunitiesGET /api/trades?limit=50&offset=0GET /api/wallet/balance- uses
node.ws_urlforeth_getBalance - uses Chainlink ETH/USD feed on mainnet to return USD estimates
- uses
Any config key can be overridden via environment variables:
ZELVEX_NODE_WS_URLZELVEX_SERVER_BIND_ADDRZELVEX_DATABASE_PATHZELVEX_AUTH_JWT_SECRETZELVEX_KEYS_SIGNER_KEY_PATHZELVEX_KEYS_CONTRACT_ADDRESS
Pattern:
ZELVEX_<SECTION>_<KEY> (uppercased).
These commands must pass cleanly:
cargo clippy --all-targets --all-features -- -D warnings
cargo fmt --check
cargo test --workspace