TypeScript Hyperliquid DCA bot built for perpetuals first, with dry-run as the default operating mode and explicit risk controls before live execution.
- Connects to Hyperliquid for perp market data, account state, and order execution.
- Applies a configurable DCA strategy with ladder sizing, cooldowns, dip-based scaling, and entry guards.
- Enforces live-safety controls such as account-value checks, drawdown caps, daily loss limits, slippage checks, and a kill-switch.
- Persists strategy state and order history in a local SQLite database so restarts do not blindly duplicate DCA legs.
npm install
cp .env.example .env
npm run build
npm run testValidate configuration:
npm run dev -- validate-configInspect the latest persisted status:
npm run dev -- statusRun the bot:
npm run devLIVE_TRADING=falsekeeps the bot indry-runmode. No real orders are sent in this mode.- For live trading, use a dedicated Hyperliquid API wallet instead of a primary wallet.
- Keep
ENABLE_DEAD_MAN_SWITCH=truein live mode so the bot regularly refreshes a cancel-all timer. - Start with small sizing and verify
statusoutput before enabling live trading.
src/hyperliquid/: exchange client, websocket feed, and response mapperssrc/strategy/: DCA strategy and signal calculationssrc/risk/: limit checks and kill-switch handlingsrc/execution/: order planning and submissionsrc/state/: SQLite-backed persistencesrc/app/bot.ts: orchestration loop
SYMBOL,SIDE,BASE_ORDER_USD,MAX_TOTAL_BUDGET_USD: define the DCA ladderDIP_INTERVAL_PCT,SIZE_SCALE,COOLDOWN_SECONDS: define step spacing and cadenceMAX_SPREAD_BPS,MAX_VOLATILITY_PCT,MAX_FUNDING_RATE: market-entry filtersMAX_NOTIONAL_USD,MAX_DAILY_LOSS_USD,MAX_DRAWDOWN_PCT,MIN_ACCOUNT_VALUE_USD: hard risk guards
npm run devruns the loop in TypeScriptnpm run buildcompiles todist/npm run lintruns ESLintnpm run testruns focused unit tests