refactor: Streamline .env.example to essentials only
- Removed unnecessary variables (Discord, Email, Database, Monitoring) - Kept only required trading variables (Drift, Solana RPC, Pyth) - Removed DRIFT_PROGRAM_ID (uses default) - Removed advanced monitoring (DataDog, Grafana, New Relic) - Removed database config (not needed for Phase 2) - Removed n8n webhook URL (n8n calls v4, not vice versa) - Simplified notes section with clear setup checklist - Emphasized API_SECRET_KEY must match between v4 and n8n - Total: 155 lines (down from 320)
This commit is contained in:
257
v4/.env.example
257
v4/.env.example
@@ -17,12 +17,9 @@ DRIFT_WALLET_PRIVATE_KEY=your_base58_private_key_here
|
|||||||
# Options: mainnet-beta (production), devnet (testing)
|
# Options: mainnet-beta (production), devnet (testing)
|
||||||
DRIFT_ENV=mainnet-beta
|
DRIFT_ENV=mainnet-beta
|
||||||
|
|
||||||
# Drift Program ID (default - don't change unless using custom program)
|
|
||||||
DRIFT_PROGRAM_ID=dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH
|
|
||||||
|
|
||||||
# API secret key for authenticating n8n webhook requests
|
# API secret key for authenticating n8n webhook requests
|
||||||
# Generate with: openssl rand -hex 32
|
# Generate with: openssl rand -hex 32
|
||||||
# Or: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
|
# ⚠️ MUST match API_SECRET_KEY in n8n environment variables
|
||||||
API_SECRET_KEY=your_random_secret_key_here
|
API_SECRET_KEY=your_random_secret_key_here
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
@@ -35,12 +32,10 @@ API_SECRET_KEY=your_random_secret_key_here
|
|||||||
# Get free API key at: https://helius.dev
|
# Get free API key at: https://helius.dev
|
||||||
SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_API_KEY
|
SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_API_KEY
|
||||||
|
|
||||||
# Alternative RPC providers (if not using Helius):
|
# Alternative RPC providers:
|
||||||
#
|
|
||||||
# QuickNode: https://solana-mainnet.quiknode.pro/YOUR_ENDPOINT/
|
# QuickNode: https://solana-mainnet.quiknode.pro/YOUR_ENDPOINT/
|
||||||
# Alchemy: https://solana-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
|
# Alchemy: https://solana-mainnet.g.alchemy.com/v2/YOUR_ALCHEMY_KEY
|
||||||
# Ankr: https://rpc.ankr.com/solana
|
# Ankr: https://rpc.ankr.com/solana
|
||||||
# Public (not recommended): https://api.mainnet-beta.solana.com
|
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# REQUIRED - PYTH NETWORK (Price Feeds)
|
# REQUIRED - PYTH NETWORK (Price Feeds)
|
||||||
@@ -50,12 +45,8 @@ SOLANA_RPC_URL=https://mainnet.helius-rpc.com/?api-key=YOUR_HELIUS_API_KEY
|
|||||||
# Default: https://hermes.pyth.network (no API key needed)
|
# Default: https://hermes.pyth.network (no API key needed)
|
||||||
PYTH_HERMES_URL=https://hermes.pyth.network
|
PYTH_HERMES_URL=https://hermes.pyth.network
|
||||||
|
|
||||||
# Alternative Pyth endpoints:
|
|
||||||
# Stable: https://hermes-beta.pyth.network
|
|
||||||
# Devnet: https://hermes-dev.pyth.network
|
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# TRADING CONFIGURATION (Optional - Override defaults)
|
# TRADING CONFIGURATION
|
||||||
# ================================
|
# ================================
|
||||||
|
|
||||||
# Position sizing
|
# Position sizing
|
||||||
@@ -64,169 +55,55 @@ PYTH_HERMES_URL=https://hermes.pyth.network
|
|||||||
MAX_POSITION_SIZE_USD=50
|
MAX_POSITION_SIZE_USD=50
|
||||||
|
|
||||||
# Leverage multiplier (1-20, default: 10)
|
# Leverage multiplier (1-20, default: 10)
|
||||||
# Higher leverage = bigger gains AND bigger losses
|
|
||||||
LEVERAGE=10
|
LEVERAGE=10
|
||||||
|
|
||||||
# Risk parameters (as percentages)
|
# Risk parameters (as percentages)
|
||||||
# Stop Loss: Close 100% of position when price drops this much
|
# Stop Loss: Close 100% of position when price drops this much
|
||||||
# Example: -1.5% on 10x = -15% account loss
|
|
||||||
STOP_LOSS_PERCENT=-1.5
|
STOP_LOSS_PERCENT=-1.5
|
||||||
|
|
||||||
# Take Profit 1: Close 50% of position at this profit level
|
# Take Profit 1: Close 50% of position (default: +0.7%)
|
||||||
# Example: +0.7% on 10x = +7% account gain
|
|
||||||
TAKE_PROFIT_1_PERCENT=0.7
|
TAKE_PROFIT_1_PERCENT=0.7
|
||||||
|
|
||||||
# Take Profit 2: Close remaining 50% at this profit level
|
# Take Profit 2: Close remaining 50% (default: +1.5%)
|
||||||
# Example: +1.5% on 10x = +15% account gain
|
|
||||||
TAKE_PROFIT_2_PERCENT=1.5
|
TAKE_PROFIT_2_PERCENT=1.5
|
||||||
|
|
||||||
# Emergency Stop: Hard stop if this level is breached
|
|
||||||
# Example: -2.0% on 10x = -20% account loss (rare but protects from flash crashes)
|
|
||||||
EMERGENCY_STOP_PERCENT=-2.0
|
|
||||||
|
|
||||||
# Dynamic stop-loss adjustments
|
|
||||||
# Move SL to breakeven when profit reaches this level
|
# Move SL to breakeven when profit reaches this level
|
||||||
BREAKEVEN_TRIGGER_PERCENT=0.4
|
BREAKEVEN_TRIGGER_PERCENT=0.4
|
||||||
|
|
||||||
# Lock in profit when price reaches this level
|
|
||||||
PROFIT_LOCK_TRIGGER_PERCENT=1.0
|
|
||||||
|
|
||||||
# How much profit to lock (move SL to this profit level)
|
|
||||||
PROFIT_LOCK_PERCENT=0.4
|
|
||||||
|
|
||||||
# Risk limits
|
# Risk limits
|
||||||
# Stop trading if daily loss exceeds this amount (USD)
|
# Stop trading if daily loss exceeds this amount (USD)
|
||||||
# Example: -150 = stop trading after losing $150 in a day
|
|
||||||
MAX_DAILY_DRAWDOWN=-150
|
MAX_DAILY_DRAWDOWN=-150
|
||||||
|
|
||||||
# Maximum number of trades allowed per hour (prevents overtrading)
|
# Maximum trades per hour (prevents overtrading)
|
||||||
MAX_TRADES_PER_HOUR=6
|
MAX_TRADES_PER_HOUR=6
|
||||||
|
|
||||||
# Minimum time between trades in seconds (cooldown period)
|
# Minimum seconds between trades (cooldown period)
|
||||||
# Example: 600 = 10 minutes between trades
|
|
||||||
MIN_TIME_BETWEEN_TRADES=600
|
MIN_TIME_BETWEEN_TRADES=600
|
||||||
|
|
||||||
# DEX execution settings
|
# Maximum acceptable slippage (percentage)
|
||||||
# Maximum acceptable slippage on market orders (percentage)
|
|
||||||
# Example: 1.0 = accept up to 1% slippage
|
|
||||||
SLIPPAGE_TOLERANCE=1.0
|
SLIPPAGE_TOLERANCE=1.0
|
||||||
|
|
||||||
# How often to check prices (milliseconds)
|
|
||||||
# Example: 2000 = check every 2 seconds
|
|
||||||
PRICE_CHECK_INTERVAL_MS=2000
|
|
||||||
|
|
||||||
# Order confirmation timeout (milliseconds)
|
|
||||||
# Example: 30000 = wait up to 30 seconds for order confirmation
|
|
||||||
CONFIRMATION_TIMEOUT_MS=30000
|
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# N8N WORKFLOW INTEGRATION (Optional but recommended)
|
# TELEGRAM NOTIFICATIONS (Recommended)
|
||||||
# ================================
|
# ================================
|
||||||
|
|
||||||
# n8n instance URL (for workflow automation)
|
# Telegram Bot for trade alerts
|
||||||
# Get from: https://n8n.io (cloud) or self-hosted
|
|
||||||
# Example: https://your-username.app.n8n.cloud
|
|
||||||
N8N_WEBHOOK_URL=https://your-n8n-instance.com
|
|
||||||
|
|
||||||
# n8n API key (if using n8n API directly)
|
|
||||||
N8N_API_KEY=your_n8n_api_key
|
|
||||||
|
|
||||||
# TradingView webhook secret (for validating incoming alerts)
|
|
||||||
# Must match the secret in your TradingView alert URL
|
|
||||||
# Generate with: openssl rand -hex 16
|
|
||||||
TRADINGVIEW_WEBHOOK_SECRET=your_tradingview_webhook_secret
|
|
||||||
|
|
||||||
# ================================
|
|
||||||
# NOTIFICATIONS (Optional - for trade alerts)
|
|
||||||
# ================================
|
|
||||||
|
|
||||||
# Telegram Bot (recommended for mobile alerts)
|
|
||||||
# 1. Create bot: Message @BotFather on Telegram, send /newbot
|
# 1. Create bot: Message @BotFather on Telegram, send /newbot
|
||||||
# 2. Get token from BotFather
|
# 2. Get token from BotFather
|
||||||
# 3. Get chat ID: Message @userinfobot or your bot, it will show your chat ID
|
# 3. Get chat ID: Message @userinfobot or your bot
|
||||||
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
|
TELEGRAM_BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
|
||||||
TELEGRAM_CHAT_ID=123456789
|
TELEGRAM_CHAT_ID=123456789
|
||||||
|
|
||||||
# Discord Webhook (good for team channels)
|
|
||||||
# 1. Go to Discord channel settings
|
|
||||||
# 2. Integrations → Webhooks → New Webhook
|
|
||||||
# 3. Copy webhook URL
|
|
||||||
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/YOUR_WEBHOOK_ID/YOUR_WEBHOOK_TOKEN
|
|
||||||
|
|
||||||
# Email (SMTP) - for important alerts
|
|
||||||
# Gmail setup:
|
|
||||||
# 1. Enable 2FA on your Google account
|
|
||||||
# 2. Generate App Password: https://myaccount.google.com/apppasswords
|
|
||||||
# 3. Use the 16-character app password below
|
|
||||||
EMAIL_SMTP_HOST=smtp.gmail.com
|
|
||||||
EMAIL_SMTP_PORT=587
|
|
||||||
EMAIL_SMTP_SECURE=false
|
|
||||||
EMAIL_FROM=your-email@gmail.com
|
|
||||||
EMAIL_TO=notification-email@gmail.com
|
|
||||||
EMAIL_USER=your-email@gmail.com
|
|
||||||
EMAIL_PASSWORD=your_16_character_app_password
|
|
||||||
|
|
||||||
# Other SMTP providers:
|
|
||||||
# Outlook: smtp-mail.outlook.com:587
|
|
||||||
# Yahoo: smtp.mail.yahoo.com:587
|
|
||||||
# SendGrid: smtp.sendgrid.net:587
|
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# DATABASE (Optional - Phase 3 feature)
|
# OPTIONAL - ADVANCED SETTINGS
|
||||||
# ================================
|
# ================================
|
||||||
|
|
||||||
# PostgreSQL connection string
|
# Node environment
|
||||||
# Format: postgresql://username:password@host:port/database
|
|
||||||
#
|
|
||||||
# Local setup:
|
|
||||||
# 1. Install PostgreSQL: https://www.postgresql.org/download/
|
|
||||||
# 2. Create database: createdb trading_bot_v4
|
|
||||||
# 3. Update connection string below
|
|
||||||
DATABASE_URL=postgresql://postgres:password@localhost:5432/trading_bot_v4
|
|
||||||
|
|
||||||
# Cloud PostgreSQL providers:
|
|
||||||
# - Supabase: https://supabase.com (free tier available)
|
|
||||||
# - Neon: https://neon.tech (serverless, free tier)
|
|
||||||
# - Railway: https://railway.app
|
|
||||||
# - Heroku Postgres
|
|
||||||
|
|
||||||
# Database connection pool settings (optional)
|
|
||||||
DATABASE_POOL_MIN=2
|
|
||||||
DATABASE_POOL_MAX=10
|
|
||||||
|
|
||||||
# ================================
|
|
||||||
# SECURITY & ACCESS CONTROL
|
|
||||||
# ================================
|
|
||||||
|
|
||||||
# JWT secret for API authentication (if implementing auth)
|
|
||||||
# Generate with: openssl rand -hex 64
|
|
||||||
JWT_SECRET=your_jwt_secret_here
|
|
||||||
|
|
||||||
# Allowed origins for CORS (comma-separated)
|
|
||||||
# Example: http://localhost:3000,https://yourdomain.com
|
|
||||||
ALLOWED_ORIGINS=http://localhost:3000
|
|
||||||
|
|
||||||
# Rate limiting (requests per minute)
|
|
||||||
RATE_LIMIT_PER_MINUTE=60
|
|
||||||
|
|
||||||
# IP whitelist (comma-separated, leave empty to allow all)
|
|
||||||
# Example: 192.168.1.100,10.0.0.5
|
|
||||||
IP_WHITELIST=
|
|
||||||
|
|
||||||
# ================================
|
|
||||||
# DEVELOPMENT & DEBUGGING
|
|
||||||
# ================================
|
|
||||||
|
|
||||||
# Node environment (development, production, test)
|
|
||||||
NODE_ENV=production
|
NODE_ENV=production
|
||||||
|
|
||||||
# Log level (debug, info, warn, error)
|
# Log level (debug, info, warn, error)
|
||||||
# Use 'debug' for detailed logs during development
|
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
|
|
||||||
# Enable detailed logging for specific modules
|
|
||||||
DEBUG=drift:*,pyth:*,trading:*
|
|
||||||
|
|
||||||
# Enable dry run mode (simulate trades without executing)
|
# Enable dry run mode (simulate trades without executing)
|
||||||
# Set to 'true' for testing without real money
|
# Set to 'true' for testing without real money
|
||||||
DRY_RUN=false
|
DRY_RUN=false
|
||||||
@@ -234,86 +111,50 @@ DRY_RUN=false
|
|||||||
# API server port (default: 3000)
|
# API server port (default: 3000)
|
||||||
PORT=3000
|
PORT=3000
|
||||||
|
|
||||||
# Enable performance monitoring
|
|
||||||
ENABLE_METRICS=false
|
|
||||||
|
|
||||||
# Sentry DSN (for error tracking in production)
|
|
||||||
SENTRY_DSN=
|
|
||||||
|
|
||||||
# ================================
|
|
||||||
# MONITORING & ANALYTICS (Optional)
|
|
||||||
# ================================
|
|
||||||
|
|
||||||
# DataDog API key (for metrics and logs)
|
|
||||||
DATADOG_API_KEY=
|
|
||||||
|
|
||||||
# Grafana Cloud endpoint
|
|
||||||
GRAFANA_ENDPOINT=
|
|
||||||
|
|
||||||
# New Relic license key
|
|
||||||
NEW_RELIC_LICENSE_KEY=
|
|
||||||
|
|
||||||
# ================================
|
# ================================
|
||||||
# NOTES & QUICK REFERENCE
|
# NOTES & QUICK REFERENCE
|
||||||
# ================================
|
# ================================
|
||||||
|
|
||||||
# Typical Production Setup:
|
# Setup Checklist:
|
||||||
# - MAX_POSITION_SIZE_USD=1000 (start with $1k)
|
# [ ] 1. Copy this file to .env.local
|
||||||
# - LEVERAGE=10 (10x multiplier)
|
# [ ] 2. Fill in DRIFT_WALLET_PRIVATE_KEY (from Phantom)
|
||||||
# - Helius RPC (best performance)
|
# [ ] 3. Fill in SOLANA_RPC_URL (get free Helius key)
|
||||||
# - Telegram notifications enabled
|
# [ ] 4. Generate API_SECRET_KEY: openssl rand -hex 32
|
||||||
# - DRY_RUN=false
|
# [ ] 5. Set same API_SECRET_KEY in n8n environment
|
||||||
# - LOG_LEVEL=info
|
# [ ] 6. Fill in TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID
|
||||||
#
|
# [ ] 7. Set MAX_POSITION_SIZE_USD=50 for testing
|
||||||
# Safe Testing Setup:
|
# [ ] 8. Start bot: npm run dev
|
||||||
# - MAX_POSITION_SIZE_USD=50 (only $50 per trade)
|
# [ ] 9. Import n8n-workflow-simple.json to n8n
|
||||||
# - LEVERAGE=10 (still test with leverage)
|
# [ ] 10. Configure TradingView alert webhook
|
||||||
# - DRY_RUN=false (test with real tiny amounts)
|
|
||||||
# - LOG_LEVEL=debug (see everything)
|
|
||||||
#
|
|
||||||
# Recommended Daily Limits:
|
|
||||||
# - MAX_DAILY_DRAWDOWN=-150 (stop at -15% loss)
|
|
||||||
# - MAX_TRADES_PER_HOUR=6 (prevent overtrading)
|
|
||||||
# - MIN_TIME_BETWEEN_TRADES=600 (10min cooldown)
|
|
||||||
#
|
#
|
||||||
# Expected Risk Per Trade (with defaults):
|
# Expected Risk Per Trade (with defaults):
|
||||||
# - Max Loss: $7.50 (50 * 10 * 0.015)
|
# - Position Size: $50
|
||||||
# - TP1 Gain: $3.50 (50 * 10 * 0.007)
|
# - Leverage: 10x
|
||||||
# - TP2 Gain: $7.50 (50 * 10 * 0.015)
|
# - Notional Value: $500
|
||||||
# - Full Win: $11.00 (TP1 + TP2)
|
# - Max Loss (SL): $7.50 (-1.5% on 10x)
|
||||||
#
|
# - TP1 Gain: $3.50 (+0.7% on 10x, 50% position)
|
||||||
# Getting API Keys:
|
# - TP2 Gain: $7.50 (+1.5% on 10x, remaining 50%)
|
||||||
# - Helius: https://helius.dev (free tier: 100k requests/day)
|
# - Full Win: $11.00 total profit
|
||||||
# - Telegram: @BotFather on Telegram
|
|
||||||
# - Discord: Channel Settings → Integrations → Webhooks
|
|
||||||
# - Gmail: myaccount.google.com/apppasswords (need 2FA enabled)
|
|
||||||
#
|
|
||||||
# Testing Checklist:
|
|
||||||
# [ ] Copy this file to .env.local
|
|
||||||
# [ ] Fill in DRIFT_WALLET_PRIVATE_KEY
|
|
||||||
# [ ] Fill in SOLANA_RPC_URL (Helius recommended)
|
|
||||||
# [ ] Fill in API_SECRET_KEY (random 32-byte hex)
|
|
||||||
# [ ] Set MAX_POSITION_SIZE_USD=50 for testing
|
|
||||||
# [ ] Run: npx tsx v4/test-price-monitor.ts
|
|
||||||
# [ ] Run: npx tsx v4/test-position-manager.ts
|
|
||||||
# [ ] Run: npx tsx v4/test-full-flow.ts (careful: real trade!)
|
|
||||||
# [ ] Configure TradingView alerts
|
|
||||||
# [ ] Import n8n-workflow-v4.json
|
|
||||||
# [ ] Test with manual TradingView alert
|
|
||||||
#
|
#
|
||||||
# Security Reminders:
|
# Security Reminders:
|
||||||
# ⚠️ Never commit .env.local to git
|
# ⚠️ Never commit .env.local to git
|
||||||
# ⚠️ Use a dedicated trading wallet
|
# ⚠️ Use a dedicated trading wallet with limited funds
|
||||||
# ⚠️ Start with small position sizes
|
# ⚠️ Start with small position sizes ($50-100)
|
||||||
# ⚠️ Keep private keys secure
|
# ⚠️ Keep private keys secure
|
||||||
# ⚠️ Use hardware wallet for large amounts
|
# ⚠️ Rotate API_SECRET_KEY regularly
|
||||||
# ⚠️ Rotate API keys regularly
|
|
||||||
# ⚠️ Monitor for suspicious activity
|
|
||||||
#
|
#
|
||||||
# Support & Documentation:
|
# n8n Environment Variables Required:
|
||||||
# - v4/README.md - Project overview
|
# - TRADING_BOT_API_URL=http://your-server:3000
|
||||||
# - v4/SETUP.md - Detailed setup guide
|
# - API_SECRET_KEY=same_as_above
|
||||||
# - v4/TESTING.md - Testing procedures
|
# - TELEGRAM_CHAT_ID=same_as_above
|
||||||
# - v4/QUICKREF_PHASE2.md - Quick reference
|
#
|
||||||
# - TRADING_BOT_V4_MANUAL.md - Complete manual
|
# Getting API Keys:
|
||||||
# - PHASE_2_COMPLETE_REPORT.md - Feature summary
|
# - Helius RPC: https://helius.dev (free: 100k requests/day)
|
||||||
|
# - Telegram Bot: @BotFather on Telegram
|
||||||
|
# - Random secret: openssl rand -hex 32
|
||||||
|
|
||||||
|
|
||||||
|
# Getting API Keys:
|
||||||
|
# - Helius RPC: https://helius.dev (free: 100k requests/day)
|
||||||
|
# - Telegram Bot: @BotFather on Telegram
|
||||||
|
# - Random secret: openssl rand -hex 32
|
||||||
|
|||||||
Reference in New Issue
Block a user