Skip to content

TradingBot — Documentation

Multi-chain automated DEX liquidity-removal bot. Watches Uniswap V2/V3, PancakeSwap V2/V3, and Raydium positions via WebSocket and fires removal transactions when configured triggers match.

Status: Pre-production. Test coverage at ~87% branch; manual dry-run validation required before going live. Last updated: 2026-05-13


Section Purpose
Getting Started Install, configure .env, generate keystore, first dry run
Usage npm scripts, Docker, Telegram bot commands, position config
Architecture System diagrams, module breakdown, data flow, invariants
Testing Unit tests, coverage, manual dry-run validation procedure
Safety Risk knobs, emergency wallet, gas cap, MEV, blacklist
Extending Add a new DEX, chain, or trigger
Changelog Doc + project change history

TL;DR — what this bot does

Position you own (LP token / V3 NFT / Raydium LP)
WebSocket monitors price + events on-chain
Trigger engine: price drop? rise? volume spike? emergency?
Executor: removeLiquidity → wallet
Alert sent to Telegram + Discord

Configurable triggers per position. Slippage, gas cap, and rate limits all enforced before broadcast. Dry-run mode lets you validate everything against live market data with zero on-chain risk.


Project layout

TradingBot/
├── src/
│   ├── index.js              # entry point — glues everything together
│   ├── config.js             # zod-validated env loader (SINGLE source of truth)
│   ├── logger.js             # pino, with redaction list
│   ├── chains/               # RPC providers (EVM + Solana)
│   ├── monitors/             # price + event WebSocket subscribers
│   ├── triggers/             # trigger evaluation engine
│   ├── executors/            # per-DEX removal logic
│   ├── alerts/               # Telegram + Discord fan-out
│   ├── security/             # keystore, rate limiter
│   └── utils/                # gas, slippage, pnl
├── abis/                     # minimal ABIs + chain → dex → address map
├── tests/                    # vitest unit tests
├── scripts/encryptKey.js     # generate keystore.json from raw key
├── docs/                     # ← you are here
└── .env.example              # all configurable env vars

Reading order for a new contributor

  1. Getting Started — get a local dry run working
  2. Architecture — understand the data flow before editing
  3. Safety — internalize the invariants (you will lose money if you break them)
  4. Testing — run the suite, add coverage for your change
  5. Extending — only after the above

Conventions used in these docs

  • 📁 path/to/file.js:LN — clickable reference to a specific source line
  • mermaid blocks — diagrams render on GitHub natively; for local preview install the Markdown Preview Mermaid extension in VS Code
  • > ⚠️ callouts — irreversible / financial-risk warnings; always read before acting
  • bash blocks — copy-pasteable shell commands; assume pwd = repo root unless stated