=== ANALYZING POOL-STRATEGIST.PHP FILE === File: /home/nvdaxcom/core.galliumhash.com/metaminer/transmutations/pool-strategist.php Size: 41535 bytes Last modified: 2025-12-08 21:29:19 === FILE CONTENT ANALYSIS === Classes found in file: - PoolStrategist Methods found in file: - __construct - rankPoolsByEV - calculatePoolEV - calculateEVConfidence - identifyPoolRisks - getHardwareProfitability - predictHashrateMigration - getSwitchRecommendation - getHardwareUpgradeAnalysis - projectDifficultyAdjustment - getCompositeStrategy - getCurrentBTCPrice - getNetworkHashrate - getCurrentDifficulty - getCurrentBlockHeight - fetchRecentBlockTimes - fetchPoolHashrateHistory - fetchPriceHistory - getCurrentPool - getHardwareModels - calculateOrphanRisk - getPaymentMethodMultiplier - calculateMinerProfitability - calculateBreakevenPrice - planHashrateSwitch - getCurrentHardware - assessOverallRisk - generateActionableInsights - generateUpgradeRecommendation - generateRiskRecommendations - generateIntelligence ✓ generateIntelligence METHOD FOUND in file Line 921: public function generateIntelligence() { Line 985: "message" => "generateIntelligence failed: " . $e->getMessage(), Line 992: "message" => "generateIntelligence fatal error: " . $e->getMessage(), === FIRST 100 LINES === 1: class PoolStrategist { 2: private $db; 3: private $config; 4: 5: // Bitcoin constants 6: private const BLOCK_REWARD = 3.125; // Current BTC per block (post-2024 halving) 7: private const BLOCKS_PER_DAY = 144; 8: private const DIFFICULTY_ADJUSTMENT_BLOCKS = 2016; 9: 10: public function __construct($database, $config = []) { 11: $this->db = $database; 12: $this->config = array_merge([ 13: 'profitability_window' => 30, // Days for profitability calculation 14: 'pool_comparison_period' => 7, // Days for pool comparison 15: 'ev_confidence_threshold' => 0.70, 16: 'switching_cost_threshold' => 0.02 // Minimum 2% advantage to switch 17: ], $config); 18: } 19: 20: /** 21: * POOL EXPECTED VALUE RANKINGS 22: * Calculates EV for 1 TH/s over next 24 hours for each pool 23: */ 24: private function rankPoolsByEV(): array { 25: $pools = $this->fetchPoolData(); 26: $networkHashrate = $this->getNetworkHashrate(); 27: $btcPrice = $this->getCurrentBTCPrice(); 28: 29: if (empty($pools)) { 30: return ['rankings' => [], 'status' => 'no_data']; 31: } 32: 33: $rankings = []; 34: foreach ($pools as $pool) { 35: $ev = $this->calculatePoolEV($pool, $networkHashrate, $btcPrice); 36: 37: $poolHashrate = ($pool['hash_rate_ehs'] ?? 0) * 1e18; 38: $hashrateShare = $networkHashrate > 0 ? ($poolHashrate / $networkHashrate * 100) : 0; 39: 40: $rankings[] = [ 41: 'pool_name' => $pool['pool_name'] ?? 'Unknown Pool', 42: 'hash_rate_ehs' => $pool['hash_rate_ehs'] ?? 0, 43: 'hashrate_share_percent' => round($hashrateShare, 3), 44: 'ev_24h_usd' => $ev['ev_24h_usd'], 45: 'score' => $ev['score'], 46: 'confidence' => $ev['confidence'], 47: 'risk_factors' => $ev['risk_factors'] 48: ]; 49: } 50: 51: // Sort by EV (highest first) 52: usort($rankings, function($a, $b) { 53: return $b['ev_24h_usd'] <=> $a['ev_24h_usd']; 54: }); 55: 56: // Add rankings 57: foreach ($rankings as $i => &$pool) { 58: $pool['rank'] = $i + 1; 59: } 60: 61: return ['rankings' => $rankings, 'status' => 'success']; 62: } 63: 64: private function calculatePoolEV(array $pool, float $networkHashrate, float $btcPrice): array { 65: // Base calculation: proportion of network hashrate 66: $dailyBTCReward = self::BLOCK_REWARD * self::BLOCKS_PER_DAY; 67: 68: // Convert pool hashrate from EH/s to H/s (if it exists) 69: $poolHashrate = ($pool['hash_rate_ehs'] ?? 0) * 1e18; 70: 71: // Prevent division by zero 72: if ($poolHashrate <= 0 || $networkHashrate <= 0) { 73: return [ 74: 'ev_24h_usd' => 0, 75: 'score' => 0, 76: 'confidence' => 0, 77: 'risk_factors' => ['insufficient_data'] 78: ]; 79: } 80: 81: $poolShare = $networkHashrate > 0 ? $poolHashrate / $networkHashrate : 0; 82: 83: // Expected BTC per TH/s per day (before adjustments) 84: // 🔧 FIXED: Added division by zero protection 85: $baseBTCPerTH = $poolHashrate > 0 ? ($poolShare * $dailyBTCReward) / ($poolHashrate / 1e12) : 0; // Convert to TH 86: 87: // Adjustment 1: Pool fee 88: $poolFee = $pool['pool_fee'] ?? $pool['fee'] ?? 2.0; // Default 2% if not specified 89: $afterFee = $baseBTCPerTH * (1 - $poolFee / 100); 90: 91: // Adjustment 2: Payment method variance 92: $paymentMethod = $pool['payment_method'] ?? 'PPLNS'; 93: $luck = $pool['luck_percentage'] ?? $pool['luck'] ?? 100; 94: $paymentMultiplier = $this->getPaymentMethodMultiplier($paymentMethod, $luck); 95: $afterPaymentMethod = $afterFee * $paymentMultiplier; 96: 97: // Adjustment 3: Orphan risk (blocks that don't get included) 98: $orphanRate = $this->calculateOrphanRisk($pool); 99: $afterOrphanRisk = $afterPaymentMethod * (1 - $orphanRate / 100); 100: