#!/bin/bash # Phase 2 Installation Script # Installs dependencies and validates setup echo "🚀 Trading Bot v4 - Phase 2 Installation" echo "==========================================" echo "" # Check if in correct directory if [ ! -d "v4" ]; then echo "❌ Error: Must run from project root directory" echo " Expected to see v4/ folder" exit 1 fi echo "📦 Step 1: Installing dependencies..." echo "" # Install main dependencies npm install @pythnetwork/price-service-client echo "" echo "✅ Dependencies installed" echo "" echo "📝 Step 2: Checking environment configuration..." echo "" # Check for .env.local if [ ! -f ".env.local" ]; then echo "⚠️ Warning: .env.local not found" echo " Creating from example..." if [ -f "v4/.env.example" ]; then cp v4/.env.example .env.local echo "✅ Created .env.local from v4/.env.example" echo " Please edit .env.local with your credentials" else echo "❌ Error: v4/.env.example not found" exit 1 fi else echo "✅ .env.local exists" fi # Check required variables echo "" echo "Checking required environment variables..." required_vars=("DRIFT_WALLET_PRIVATE_KEY" "SOLANA_RPC_URL" "API_KEY") missing_vars=() for var in "${required_vars[@]}"; do if ! grep -q "^${var}=" .env.local || grep -q "^${var}=$" .env.local || grep -q "^${var}=your_" .env.local; then missing_vars+=("$var") echo "❌ $var not configured" else echo "✅ $var configured" fi done if [ ${#missing_vars[@]} -gt 0 ]; then echo "" echo "⚠️ Missing configuration for:" for var in "${missing_vars[@]}"; do echo " - $var" done echo "" echo "Please edit .env.local and set these variables" echo "" fi echo "" echo "📝 Step 3: Validating TypeScript setup..." echo "" # Check tsconfig.json if [ ! -f "tsconfig.json" ]; then echo "❌ Error: tsconfig.json not found" exit 1 fi echo "✅ TypeScript configuration found" echo "" echo "📝 Step 4: Checking test scripts..." echo "" # Check test files exist test_files=("v4/test-price-monitor.ts" "v4/test-position-manager.ts" "v4/test-full-flow.ts") for file in "${test_files[@]}"; do if [ -f "$file" ]; then echo "✅ $file exists" else echo "❌ $file missing" fi done echo "" echo "==========================================" echo "🎉 Phase 2 Installation Complete!" echo "==========================================" echo "" if [ ${#missing_vars[@]} -eq 0 ]; then echo "✅ Ready to test! Run:" echo "" echo " cd v4" echo " npx tsx test-price-monitor.ts" echo "" echo "See TESTING.md for full testing guide" else echo "⚠️ Almost ready! Next steps:" echo "" echo "1. Edit .env.local and set:" for var in "${missing_vars[@]}"; do echo " - $var" done echo "" echo "2. Then run tests:" echo " cd v4" echo " npx tsx test-price-monitor.ts" echo "" echo "See SETUP.md for configuration help" fi echo "" echo "📚 Documentation:" echo " - v4/PHASE_2_COMPLETE.md - Feature overview" echo " - v4/TESTING.md - Testing guide" echo " - v4/SETUP.md - Setup instructions" echo ""