How screamonei2/drift-copy-trader works
Project type and purpose
• This is a backend-focused, Node.js / TypeScript “copy-trader” service for the Drift protocol on Solana.
• It provides an automated, real-time copy-trading engine (DriftCopyTrader), risk management, monitoring, and CLI/SDK interfaces.
File structure
• Top-level entry points and config:
• src/index.ts – the main service bootstrap
• src/config/index.ts – environment/config loader
• Core logic:
• src/trailing-stop.ts & src/managers/TrailingStopManagerAtomic.ts – position-risk modules
• src/utils/TransactionManager.ts – trade execution and confirmation
• src/utils/RateLimitManager.ts – API rate-limiting
• src/utils/SoundNotifier.ts – audio notifications (for on-premises monitoring)
• Types and interfaces:
• src/types/index.ts
• Examples & debug scripts:
• examples/*.ts – basic and advanced usage samples
• debug*.ts & test-sound*.ts – local testing and debugging harnesses
• Docker & deployment:
• Dockerfile, docker-compose.yml, SOUND_SYSTEM_DOCKER.md, DOCKER.md – containerization and orchestration
README for additional insights
• Technologies: Node.js 18+, TypeScript, Drift SDK, Solana RPC (HTTP & WebSocket), dotenv
• Features: automatic trade replication, dynamic filters, risk management, real-time monitoring, dry-run mode
• Patterns: event-driven (listeners for “tradeCopied”, “tradeError”), modular managers, environment-based config
Elements
• Clear labels: e.g., “DriftCopyTrader Core”, “RateLimitManager”, “Solana RPC Node”
• RPC → EventListener → Core
• Core → TransactionManager → RPC
• Core → SoundNotifier → Audio Output
• Orange parallelograms for CLI / example clients
Detailed capture of essential elements
• Config injection at startup
• Denote dry-run path as a distinct conditional branch
• Advanced-monitoring features (WebSocket vs. polling, concurrency limits) in a sub-domain