Architecture Overview
TrenchTools is a monorepo with two primary packages: a TypeScript core library and a React dashboard UI.
High-Level Architecture
┌─────────────────────────────────────────────────┐
│ Browser (UI) │
│ │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Sniper │ │ Volume │ │ Bots │ ... │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ ┌────▼──────────────▼──────────────▼────┐ │
│ │ Context Providers │ │
│ │ Wallet │ TxHistory │ PnL │ Network │ │
│ └────┬──────────────┬──────────────┬────┘ │
│ │ │ │ │
│ ┌────▼──────┐ ┌────▼──────┐ ┌───▼─────┐ │
│ │ Wallet │ │ DEX │ │ Price │ │
│ │ Manager │ │ Layer │ │ Feeds │ │
│ └────┬──────┘ └────┬──────┘ └───┬─────┘ │
│ │ │ │ │
└───────┼──────────────┼──────────────┼───────────┘
│ │ │
localStorage Jupiter API DexScreener
PumpPortal API Solana RPCPackage Responsibilities
@trenchtools/core
Server-side / headless TypeScript library. Provides:
- Wallet generation, encryption, key management
- Trading infrastructure and types
- P&L calculation engine
- Honeypot detection (Shield)
- Manipulation detection (Allium integration)
- Bot orchestration primitives
- Volume estimation
Built with tsup for Node.js consumption.
@trenchtools/ui
The main product — a React 18 SPA that runs entirely in the browser. Provides:
- Full dashboard with sidebar navigation
- All trading features (sniper, volume, bots)
- Wallet management with browser encryption
- Real-time P&L and position tracking
- Charts and analytics
Built with Vite + TypeScript + Tailwind CSS.
Data Flow
User Action → Component → Hook/Context → DEX Layer → Solana RPC
↓
addTrade()
↓
TxHistoryContext
↓
PnLContext
↓
localStorage- User initiates an action (snipe, start bot, etc.)
- Component calls the appropriate hook or context method
- Hook interacts with the DEX layer for on-chain operations
- Trade result is recorded via
addTrade() - P&L auto-recalculates from trade history
- State persists to localStorage