|
|
3 주 전 | |
|---|---|---|
| .claude | 3 주 전 | |
| docs | 3 주 전 | |
| prisma | 3 주 전 | |
| public | 3 주 전 | |
| src | 3 주 전 | |
| .dockerignore | 3 주 전 | |
| .gitignore | 3 주 전 | |
| .prettierignore | 3 주 전 | |
| .prettierrc.json | 3 주 전 | |
| AGENTS.md | 3 주 전 | |
| Dockerfile | 3 주 전 | |
| README.md | 3 주 전 | |
| docker-compose.yml | 3 주 전 | |
| eslint.config.mjs | 3 주 전 | |
| next.config.ts | 3 주 전 | |
| package.json | 3 주 전 | |
| pnpm-lock.yaml | 3 주 전 | |
| postcss.config.mjs | 3 주 전 | |
| prisma.config.ts | 3 주 전 | |
| tsconfig.json | 3 주 전 |
A copy trading bot for Meteora DLMM (Dynamic Liquidity Market Maker) on Solana. Monitors leader wallets in real-time via WebSocket and automatically mirrors their DLMM liquidity operations with proportional scaling.
onLogs)src/
├── app/
│ ├── api/
│ │ ├── health/ # Health check endpoint
│ │ ├── positions/ # Leader/follower position queries
│ │ ├── settings/ # Worker settings (copy ratio, slippage, etc.)
│ │ ├── trades/ # Copy trade history
│ │ └── wallets/ # CRUD for monitored wallets
│ ├── layout.tsx # Root layout with Toaster
│ ├── page.tsx # Wallet management dashboard
│ └── globals.css
├── lib/
│ ├── db/
│ │ ├── prisma.ts # Prisma client singleton
│ │ └── queries.ts # Database query helpers
│ ├── meteora/
│ │ ├── dlmm-client.ts # DLMM SDK wrapper (open, remove, close, rebalance)
│ │ └── types.ts # Shared types (ParsedDlmmOperation, etc.)
│ ├── solana/
│ │ ├── connection.ts # RPC connection + follower keypair
│ │ └── transaction-parser.ts # Decode DLMM instructions from transactions
│ ├── constants.ts # Program IDs, discriminators, defaults
│ ├── utils.ts # Helpers (sleep, getEnvOrThrow, etc.)
│ └── validation.ts # Zod schemas for API input validation
└── worker/
├── index.ts # Worker entry point
├── monitor.ts # WebSocket transaction monitor
├── executor.ts # Copy trade executor
├── position-tracker.ts # Leader/follower position state tracking
└── heartbeat.ts # WebSocket keepalive + reconnect
# Install dependencies
pnpm install
# Create environment file
cp .env.example .env.local
Create .env.local with:
# Solana RPC (must support WebSocket)
RPC_ENDPOINT=https://your-rpc-endpoint.com
WS_ENDPOINT=wss://your-ws-endpoint.com
# Follower wallet private key (base58)
FOLLOWER_PRIVATE_KEY=your_base58_private_key
# Database
DATABASE_URL=file:./dev.db
# Optional settings
COPY_RATIO=1.0 # Scale factor (1.0 = same size as leader)
MAX_POSITION_SIZE_SOL=10 # Max SOL per position
SLIPPAGE_BPS=100 # Slippage tolerance in basis points
AUTO_COPY_ENABLED=true # Enable/disable auto copy
# Push database schema
pnpm db:push
# Start Next.js dev server (dashboard + API)
pnpm dev
# Start the copy trading worker (separate terminal)
pnpm worker
# Open Prisma Studio (database browser)
pnpm db:studio
Open http://localhost:3000 to access the wallet management dashboard.
# Create production environment file
cp .env.example .env.production
# Build and start
docker compose up -d
# View logs
docker compose logs -f
The Docker setup runs two containers:
Both share a SQLite database via a Docker volume.
Monitor: The worker subscribes to Solana WebSocket onLogs for each monitored wallet. When a transaction mentions the DLMM program, it fetches the full transaction data.
Parse: The transaction parser decodes DLMM instructions using Anchor's BorshInstructionCoder, extracting operation type, position/pair addresses, bin ranges, and amounts.
Track: The position tracker maintains leader position state in the database (open, bin range, strategy).
Execute: The executor mirrors the operation on the follower wallet using the DLMM SDK, scaling amounts by the configured copy ratio.
| Method | Path | Description |
|---|---|---|
| GET | /api/wallets |
List all monitored wallets |
| POST | /api/wallets |
Add a wallet {address, label?} |
| PATCH | /api/wallets |
Toggle active {id, isActive} |
| DELETE | /api/wallets?id=xxx |
Remove a wallet |
| GET | /api/positions |
List leader/follower positions |
| GET | /api/trades |
List copy trade history |
| GET/PATCH | /api/settings |
Get/update worker settings |
| GET | /api/health |
Health check |
MIT