| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- import { SniperEngine } from '../core/index.js';
- import { logger, formatUsd } from '../utils/index.js';
- import { CONFIG } from '../config/index.js';
- import { PositionCache } from '../utils/index.js';
- export function showStatus() {
- const copiedCache = new PositionCache('.copied-positions.json', CONFIG.DATA_DIR);
- const closedCache = new PositionCache('.closed-positions.json', CONFIG.DATA_DIR);
- console.log('═══════════════════════════════════════════');
- console.log('📊 Byreal Sniper Status');
- console.log('═══════════════════════════════════════════\n');
- const copied = copiedCache.getAll();
- const closed = closedCache.getAll();
- console.log(`🎯 Active Copied Positions: ${copied.positions.length}`);
- if (copied.positions.length > 0) {
- console.log('\nActive Positions:');
- copied.positions.forEach((pos, i) => {
- const data = copied.data[pos] || {};
- console.log(` ${i + 1}. ${pos}`);
- console.log(` Pool: ${data.poolAddress || 'N/A'}`);
- console.log(` Target Value: ${data.targetUsdValue ? formatUsd(data.targetUsdValue) : 'N/A'}`);
- console.log(` Copied At: ${data.copiedAt || 'N/A'}`);
- });
- }
- console.log(`\n🚪 Closed Positions: ${closed.positions.length}`);
- if (closed.positions.length > 0) {
- console.log('\nClosed Positions:');
- closed.positions.forEach((pos, i) => {
- const data = closed.data[pos] || {};
- console.log(` ${i + 1}. ${pos}`);
- console.log(` Reason: ${data.reason || 'N/A'}`);
- console.log(` Closed At: ${data.closedAt || 'N/A'}`);
- });
- }
- console.log('\n═══════════════════════════════════════════');
- }
- export async function startSniper() {
- const sniper = new SniperEngine();
-
- // Handle graceful shutdown
- process.on('SIGINT', () => {
- logger.info('\nShutting down sniper bot...');
- sniper.stop();
- process.exit(0);
- });
- process.on('SIGTERM', () => {
- logger.info('\nShutting down sniper bot...');
- sniper.stop();
- process.exit(0);
- });
- await sniper.start();
- }
- export function clearCache() {
- const copiedCache = new PositionCache('.copied-positions.json', CONFIG.DATA_DIR);
- const closedCache = new PositionCache('.closed-positions.json', CONFIG.DATA_DIR);
-
- console.log('Clearing all position caches...');
- copiedCache.clear();
- closedCache.clear();
- console.log('✅ Caches cleared successfully');
- }
- export default { showStatus, startSniper, clearCache };
|