=== Comprehensive PoolStrategist Syntax Repair === Time: 2025-12-08 21:29:19 1. Creating emergency backup... ✓ Backup created: pool-strategist.php.syntax_repair_backup_1765229359 2. Reading current file state... ✓ Read 1006 lines 3. Examining problematic area around line 549... Lines around 549: 540: foreach ($pools as $pool) { 541: if (!in_array($poolId, $seenPoolIds)) { 542: } 543: } 544: 545: // If still no pools found, return empty array 546: return $uniquePools ?: []; 547: 548: } catch (Exception $e) { >>> 549: // Log the error for debugging 550: error_log("PoolStrategist::fetchPoolData error: " . $e->getMessage()); 551: // Fallback: return empty array if query fails 552: return []; 553: } 554: } 555: 556: private function getCurrentBTCPrice(): float { 557: try { 558: $stmt = $this->db->prepare(" 559: SELECT price_usd FROM market_data 4. Analyzing class structure... ✓ Class starts at line 1 ✓ Class likely ends at line 553 ✓ Found 11 method definitions 5. Identifying structural issues... ⚠ Found 161 structural issues: Line 12: $this->config = array_merge([ (variable_outside_method) Line 26: $networkHashrate = $this->getNetworkHashrate(); (variable_outside_method) Line 27: $btcPrice = $this->getCurrentBTCPrice(); (variable_outside_method) Line 33: $rankings = []; (variable_outside_method) Line 35: $ev = $this->calculatePoolEV($pool, $networkHashrate, $btcPrice); (variable_outside_method) Line 37: $poolHashrate = ($pool['hash_rate_ehs'] ?? 0) * 1e18; (variable_outside_method) Line 38: $hashrateShare = $networkHashrate > 0 ? ($poolHashrate / $networkHashrate * 100) : 0; (variable_outside_method) Line 40: $rankings[] = [ (variable_outside_method) Line 58: $pool['rank'] = $i + 1; (variable_outside_method) Line 66: $dailyBTCReward = self::BLOCK_REWARD * self::BLOCKS_PER_DAY; (variable_outside_method) Line 69: $poolHashrate = ($pool['hash_rate_ehs'] ?? 0) * 1e18; (variable_outside_method) Line 81: $poolShare = $networkHashrate > 0 ? $poolHashrate / $networkHashrate : 0; (variable_outside_method) Line 85: $baseBTCPerTH = $poolHashrate > 0 ? ($poolShare * $dailyBTCReward) / ($poolHashrate / 1e12) : 0; // Convert to TH (variable_outside_method) Line 88: $poolFee = $pool['pool_fee'] ?? $pool['fee'] ?? 2.0; // Default 2% if not specified (variable_outside_method) Line 89: $afterFee = $baseBTCPerTH * (1 - $poolFee / 100); (variable_outside_method) Line 92: $paymentMethod = $pool['payment_method'] ?? 'PPLNS'; (variable_outside_method) Line 93: $luck = $pool['luck_percentage'] ?? $pool['luck'] ?? 100; (variable_outside_method) Line 94: $paymentMultiplier = $this->getPaymentMethodMultiplier($paymentMethod, $luck); (variable_outside_method) Line 95: $afterPaymentMethod = $afterFee * $paymentMultiplier; (variable_outside_method) Line 98: $orphanRate = $this->calculateOrphanRisk($pool); (variable_outside_method) Line 99: $afterOrphanRisk = $afterPaymentMethod * (1 - $orphanRate / 100); (variable_outside_method) Line 102: $btcPer24h = $afterOrphanRisk / 24; (variable_outside_method) Line 103: $usdPer24h = $btcPer24h * $btcPrice; (variable_outside_method) Line 107: $score = $baseBTCPerTH > 0 ? ($usdPer24h / $baseBTCPerTH) * 100 : 0; (variable_outside_method) Line 129: $confidence += 20; (variable_outside_method) Line 133: $hashrate = $pool['hash_rate_ehs'] ?? 0; (variable_outside_method) Line 139: $confidence += 5; (variable_outside_method) Line 150: $risks[] = 'high_orphan_risk'; (variable_outside_method) Line 154: $fee = $pool['pool_fee'] ?? $pool['fee'] ?? 2.0; (variable_outside_method) Line 156: $risks[] = 'high_pool_fee'; (variable_outside_method) Line 161: $risks[] = 'payment_variance'; (variable_outside_method) Line 172: $btcPrice = $this->getCurrentBTCPrice(); (variable_outside_method) Line 173: $powerCost = $this->config['power_cost_kwh'] ?? 0.10; // $/kWh (variable_outside_method) Line 176: $difficultyForecast = $this->projectDifficultyAdjustment(); (variable_outside_method) Line 184: $nextDifficulty = $difficultyForecast['predicted_difficulty'] ?? $difficulty; (variable_outside_method) Line 187: $hardwareModels = $this->getHardwareModels(); (variable_outside_method) Line 188: $profitabilityByModel = []; (variable_outside_method) Line 191: $current = $this->calculateMinerProfitability($model, $difficulty, $btcPrice, $powerCost); (variable_outside_method) Line 192: $next = $this->calculateMinerProfitability($model, $nextDifficulty, $btcPrice, $powerCost); (variable_outside_method) Line 194: $profitabilityByModel[] = [ (variable_outside_method) Line 211: $effA = ($a['power_w'] ?? 0) > 0 ? $a['next_epoch_profit_daily'] / $a['power_w'] : 0; (variable_outside_method) Line 212: $effB = ($b['power_w'] ?? 0) > 0 ? $b['next_epoch_profit_daily'] / $b['power_w'] : 0; (variable_outside_method) Line 218: $model['efficiency_rank'] = $i + 1; (variable_outside_method) Line 238: $predictions = []; (variable_outside_method) Line 242: $poolHistory = $this->fetchPoolHashrateHistory($pool, 14); (variable_outside_method) Line 247: $x = range(0, count($poolHistory) - 1); (variable_outside_method) Line 248: $regression = Quant::linearRegression($x, $poolHistory); (variable_outside_method) Line 253: $forecast7d = $regression['predict'](count($poolHistory) + 7); (variable_outside_method) Line 254: $currentHashrate = end($poolHistory); (variable_outside_method) Line 260: $predictedChange = ($forecast7d - $currentHashrate) / $currentHashrate * 100; (variable_outside_method) Line 263: $confidence = $regression['r_squared'] * 100; (variable_outside_method) Line 266: $migration = 'stable'; (variable_outside_method) Line 270: $predictions[] = [ (variable_outside_method) Line 294: $currentPool = $this->getCurrentPool(); (variable_outside_method) Line 301: $currentPoolRanking = null; (variable_outside_method) Line 304: $currentPoolRanking = array_merge($pool, ['rank' => $i + 1]); (variable_outside_method) Line 318: $bestPool = $rankings['rankings'][0]; (variable_outside_method) Line 321: $evAdvantage = $bestPool['ev_24h_usd'] - $currentPoolRanking['ev_24h_usd']; (variable_outside_method) Line 323: $evAdvantagePercent = ($currentPoolRanking['ev_24h_usd'] ?? 0) > 0 ? ($evAdvantage / $currentPoolRanking['ev_24h_usd']) * 100 : 0; (variable_outside_method) Line 339: $minerHashrate = $this->config['miner_hashrate_th'] ?? 100; // TH/s (variable_outside_method) Line 340: $dailyGain = $evAdvantage * $minerHashrate; (variable_outside_method) Line 341: $monthlyGain = $dailyGain * 30; (variable_outside_method) Line 366: $allHardware = $this->getHardwareModels(); (variable_outside_method) Line 367: $difficulty = $this->getCurrentDifficulty(); (variable_outside_method) Line 368: $btcPrice = $this->getCurrentBTCPrice(); (variable_outside_method) Line 369: $powerCost = $this->config['power_cost_kwh'] ?? 0.10; (variable_outside_method) Line 372: $current = $this->calculateMinerProfitability($currentHardware, $difficulty, $btcPrice, $powerCost); (variable_outside_method) Line 375: $alternatives = []; (variable_outside_method) Line 380: $alt = $this->calculateMinerProfitability($hw, $difficulty, $btcPrice, $powerCost); (variable_outside_method) Line 382: $roiMonths = ($hw['price'] ?? 0) > 0 && ($alt['profit_daily'] - $current['profit_daily']) > 0 (variable_outside_method) Line 386: $alternatives[] = [ (variable_outside_method) Line 429: $avgBlockTime = Quant::mean($recentBlocks); (variable_outside_method) Line 430: $targetBlockTime = 600; // 10 minutes in seconds (variable_outside_method) Line 433: $predictedChange = (($targetBlockTime / $avgBlockTime) - 1) * 100; (variable_outside_method) Line 436: $currentBlockHeight = $this->getCurrentBlockHeight(); (variable_outside_method) Line 437: $blocksUntilAdjustment = self::DIFFICULTY_ADJUSTMENT_BLOCKS - ($currentBlockHeight % self::DIFFICULTY_ADJUSTMENT_BLOCKS); (variable_outside_method) Line 438: $hoursUntilAdjustment = ($blocksUntilAdjustment * $avgBlockTime) / 3600; (variable_outside_method) Line 441: $blockTimeStdDev = Quant::standardDeviation($recentBlocks, true); (variable_outside_method) Line 442: $coefficientOfVariation = $blockTimeStdDev / $avgBlockTime; (variable_outside_method) Line 443: $confidence = max(50, 100 - ($coefficientOfVariation * 100)); (variable_outside_method) Line 446: $currentDifficulty = $this->getCurrentDifficulty(); (variable_outside_method) Line 447: $predictedDifficulty = $currentDifficulty * (1 + $predictedChange / 100); (variable_outside_method) Line 468: $btcPrice = $this->getCurrentBTCPrice(); (variable_outside_method) Line 469: $difficulty = $this->getCurrentDifficulty(); (variable_outside_method) Line 472: $btcPrice = is_numeric($btcPrice) ? floatval($btcPrice) : 100000; (variable_outside_method) Line 473: $difficulty = is_numeric($difficulty) ? floatval($difficulty) : 146716052770110; (variable_outside_method) Line 476: $profitabilityScore = 0; (variable_outside_method) Line 477: $riskScore = 5; (variable_outside_method) Line 478: $recommendation = 'MAINTAIN'; (variable_outside_method) Line 481: $profitabilityScore = 8; (variable_outside_method) Line 482: $recommendation = 'EXPAND_MINING'; (variable_outside_method) Line 484: $profitabilityScore = 7; (variable_outside_method) Line 485: $recommendation = 'MAINTAIN'; (variable_outside_method) Line 487: $profitabilityScore = 5; (variable_outside_method) Line 488: $recommendation = 'MONITOR_CLOSELY'; (variable_outside_method) Line 490: $profitabilityScore = 3; (variable_outside_method) Line 491: $recommendation = 'CONSERVE'; (variable_outside_method) Line 496: $riskScore = 8; (variable_outside_method) Line 498: $riskScore = 6; (variable_outside_method) Line 500: $riskScore = 4; (variable_outside_method) Line 558: $stmt = $this->db->prepare(" (variable_outside_method) Line 565: $result = $stmt->fetch(PDO::FETCH_ASSOC); (variable_outside_method) Line 574: $stmt = $this->db->query(" (variable_outside_method) Line 580: $result = $stmt->fetch(PDO::FETCH_ASSOC); (variable_outside_method) Line 589: $stmt = $this->db->query(" (variable_outside_method) Line 595: $result = $stmt->fetch(PDO::FETCH_ASSOC); (variable_outside_method) Line 604: $stmt = $this->db->query(" (variable_outside_method) Line 610: $result = $stmt->fetch(PDO::FETCH_ASSOC); (variable_outside_method) Line 619: $stmt = $this->db->prepare(" (variable_outside_method) Line 627: $blocks = $stmt->fetchAll(PDO::FETCH_ASSOC); (variable_outside_method) Line 628: $times = []; (variable_outside_method) Line 631: $timeDiff = $blocks[$i-1]['timestamp'] - $blocks[$i]['timestamp']; (variable_outside_method) Line 632: $times[] = $timeDiff; (variable_outside_method) Line 643: $stmt = $this->db->prepare(" (variable_outside_method) Line 659: $stmt = $this->db->prepare(" (variable_outside_method) Line 666: $prices = array_column($stmt->fetchAll(PDO::FETCH_ASSOC), 'price_usd'); (variable_outside_method) Line 692: $networkHashrate = $this->getNetworkHashrate(); (variable_outside_method) Line 693: $poolHashrate = ($pool['hash_rate_ehs'] ?? 0) * 1e18; (variable_outside_method) Line 699: $poolShare = $networkHashrate > 0 ? $poolHashrate / $networkHashrate : 0; (variable_outside_method) Line 735: $hashratePercentage = $miner['hashrate_th'] * 1e12 / ($difficulty * (2**32) / 600); (variable_outside_method) Line 736: $dailyBTC = $hashratePercentage * self::BLOCK_REWARD * self::BLOCKS_PER_DAY; (variable_outside_method) Line 737: $dailyRevenue = $dailyBTC * $btcPrice; (variable_outside_method) Line 740: $dailyPowerCost = ($miner['power_w'] / 1000) * 24 * $powerCost; (variable_outside_method) Line 743: $dailyProfit = $dailyRevenue - $dailyPowerCost; (variable_outside_method) Line 760: $hashratePercentage = $miner['hashrate_th'] * 1e12 / ($difficulty * (2**32) / 600); (variable_outside_method) Line 761: $dailyBTC = $hashratePercentage * self::BLOCK_REWARD * self::BLOCKS_PER_DAY; (variable_outside_method) Line 762: $dailyPowerCost = ($miner['power_w'] / 1000) * 24 * $powerCost; (variable_outside_method) Line 785: $risks = []; (variable_outside_method) Line 786: $compositeRisk = 0; (variable_outside_method) Line 790: $risks[] = [ (variable_outside_method) Line 796: $compositeRisk += 30; (variable_outside_method) Line 800: $priceHistory = $this->fetchPriceHistory(7); (variable_outside_method) Line 801: $priceVolatility = Quant::historicalVolatility($priceHistory, 7, 24); (variable_outside_method) Line 804: $risks[] = [ (variable_outside_method) Line 810: $compositeRisk += 20; (variable_outside_method) Line 814: $pools = $this->fetchPoolData(); (variable_outside_method) Line 815: $poolHashrates = array_column($pools, 'hash_rate_ehs'); (variable_outside_method) Line 818: $networkHashrate = $this->getNetworkHashrate(); (variable_outside_method) Line 820: $maxPoolShare = max($poolHashrates) / ($networkHashrate / 1e18); // Network hashrate is in H/s, convert to EH/s (variable_outside_method) Line 823: $risks[] = [ (variable_outside_method) Line 829: $compositeRisk += 15; (variable_outside_method) Line 843: $insights = []; (variable_outside_method) Line 847: $topPool = $rankings['rankings'][0]; (variable_outside_method) Line 848: $insights[] = [ (variable_outside_method) Line 859: $insights[] = [ (variable_outside_method) Line 870: $mostEfficient = $hardware['models'][0]; (variable_outside_method) Line 871: $insights[] = [ (variable_outside_method) Line 888: $bestAlt = $alternatives[0]; (variable_outside_method) Line 902: $recommendations = []; (variable_outside_method) Line 907: $recommendations[] = 'Monitor difficulty changes closely and adjust pool selection accordingly'; (variable_outside_method) Line 910: $recommendations[] = 'Consider implementing price hedging or adjust transaction timing'; (variable_outside_method) Line 913: $recommendations[] = 'Diversify mining across multiple pools to reduce centralization risk'; (variable_outside_method) Line 924: $intelligence = [ (variable_outside_method) Line 934: $methodsToCall = [ (variable_outside_method) Line 944: $result = $this->$methodName(); (variable_outside_method) Line 948: $intelligence[$outputKey] = $result; (variable_outside_method) Line 951: $intelligence[$outputKey] = [ (variable_outside_method) Line 958: $intelligence[$outputKey] = ["error" => "Method $methodName not found"]; (variable_outside_method) Line 961: $intelligence[$outputKey] = [ (variable_outside_method) Line 966: $intelligence[$outputKey] = [ (variable_outside_method) Line 974: $intelligence["metadata"] = [ (variable_outside_method) 6. Building clean class structure... ✓ Built clean structure, 41535 bytes 7. Adding missing generateIntelligence method if needed... 8. Writing repaired file... ✓ File written successfully 9. Testing PHP syntax...