const fs = require('fs'); console.log('🔧 Merging position sections...'); // Read the current file let content = fs.readFileSync('/app/app/automation-v2/page.js', 'utf8'); // Remove the separate positions section const positionsStart = content.indexOf(' {/* Positions */}'); const positionsEnd = content.indexOf(' )}', positionsStart + 1) + 12; // Include the closing if (positionsStart > -1 && positionsEnd > positionsStart) { content = content.slice(0, positionsStart) + content.slice(positionsEnd); console.log('✅ Removed separate positions section'); } // Find and update the position monitor section const monitorStart = content.indexOf(' {/* Position Monitor */}'); const monitorEnd = content.indexOf(' )}', monitorStart + 1) + 12; if (monitorStart > -1 && monitorEnd > monitorStart) { const newMonitorSection = ` {/* Merged Position Status & Monitor */}

📊 Position Status & Monitor

{/* Monitor Status Section */} {monitorData && (

📈 Monitor Overview

Has Position: {monitorData.hasPosition ? '✅ YES' : '❌ NO'}
Risk Level: {monitorData.riskLevel}
{monitorData.details && (

{monitorData.details}

)} {monitorData.orphanedOrderCleanup && (
{monitorData.orphanedOrderCleanup.success ? '✅ Cleanup Success' : '❌ Cleanup Failed'}
{monitorData.orphanedOrderCleanup.message}
)}
)} {/* Open Positions Section */} {positions.length > 0 ? (

📈 Active Positions ({positions.length})

{positions.map((position, index) => (
{position.symbol} {position.side}
Size: \${position.size}
{position.entryPrice && (
Entry: \${position.entryPrice}
)} {position.markPrice && (
Mark: \${position.markPrice}
)} {position.pnl !== undefined && (
PnL: = 0 ? 'text-green-400' : 'text-red-400' }\`}> \${position.pnl >= 0 ? '+' : ''}\${position.pnl}
)}
))}
) : (
📊

No Active Positions

Start automation to begin trading

)}
`; content = content.slice(0, monitorStart) + newMonitorSection + content.slice(monitorEnd); console.log('✅ Updated position monitor section with merged content'); } // Write the updated content back fs.writeFileSync('/app/app/automation-v2/page.js', content); console.log('🎉 Positions merged successfully!');