- Rust 2024 workspace; run
make fmtandmake lint(Clippy) before commits; use the feature-based module layout (api,core,storage) and wire new modules inmod.rs.
- Startup flow initializes tracing, metrics, RocksDB, dedupe warmup, relay pool, optional Postgres subscription service, settlement worker, event router, and Axum HTTP server with optional WebSocket fanout streaming relayer/src/main.rs.
- Dedup engine warms from RocksDB to avoid resend on restart relayer/src/main.rs; event router batches with max-latency cap and optional fanout relayer/src/main.rs.
- Settlement worker polls Hyperliquid explorer and applies credit config when Postgres is enabled relayer/src/main.rs.
- Setup:
cp relayer/config.template.toml relayer/config.toml && make setup-envin relayer root relayer/README.md. - Common commands:
make build,make run,make dev,make test,make bench,make fmt,make lint, Docker targets (make docker-build,make docker-run) relayer/README.md. - Direct run:
cargo run --release -- --config config.toml; set logs viaRUST_LOG=moltrade_relayer=debugrelayer/README.md.
- REST routes are centralized in the router builder relayer/src/api/rest_api.rs; prefer adding endpoints there with shared
AppState. - Trade insert/update handlers treat duplicate
tx_hashas idempotent OK and map FK violations to 400 relayer/src/api/rest_api.rs. - Daily subscription throttling enforced per bot ETH address; set
subscriptions.daily_limitto zero to disable relayer/src/api/rest_api.rs. - ETH addresses validated on bot registration relayer/src/api/rest_api.rs.
- Postgres DSN/config gates subscriptions, trades, credits, and fanout relayer/config.template.toml.
- Settlement/admin endpoints require
X-Settlement-Tokenwhen configured; missing token means no auth relayer/src/api/rest_api.rs and set via relayer/config.template.toml. - Nostr secret key read from config; invalid/empty keys trigger auto-generation and persistence when config path is known relayer/src/main.rs.
- Replace the sample
nostr.secret_keybefore running production relayer/config.template.toml; keep config files out of VCS. - Always set
settlement.tokento protect relay admin and settlement update routes relayer/src/api/rest_api.rs. - Subscription/bot endpoints validate ETH format and enforce daily limits; keep
subscriptions.daily_limitconsistent with abuse expectations relayer/src/api/rest_api.rs.