-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot_main.py
More file actions
72 lines (59 loc) · 2.39 KB
/
bot_main.py
File metadata and controls
72 lines (59 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import asyncio
import aiohttp
import json
import logging
from core.dex_analyzer import DexAnalyzer
from core.solscan_client import SolscanClient
from core.alert_manager import AlertManager
from core.health_check import HealthMonitor
from config import settings
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
class MemeTracker:
def __init__(self):
self.dex = DexAnalyzer()
self.solscan = SolscanClient()
self.alerter = AlertManager()
self.processed_tokens = self._load_processed_tokens()
def _load_processed_tokens(self):
try:
with open('data/processed_tokens.json', 'r') as f:
return set(json.load(f))
except FileNotFoundError:
return set()
def _save_processed_tokens(self):
with open('data/processed_tokens.json', 'w') as f:
json.dump(list(self.processed_tokens), f)
async def check_new_listings(self):
tokens = await self.dex.fetch_new_tokens()
for token in tokens:
if token['address'] in self.processed_tokens:
continue
solscan_data = await self.solscan.get_token_data(token['address'])
if self._check_conditions(token, solscan_data):
await self.alerter.send_alert(token, "no", "no")
self.processed_tokens.add(token['address'])
self._save_processed_tokens()
def _check_conditions(self, token, solscan_data):
return all([
token['marketCap'] >= settings.FILTERS['min_mcap'],
token['liquidity'] >= settings.FILTERS['min_liquidity'],
token['holders'] >= settings.FILTERS['min_holders'],
solscan_data['top10Holders'] <= settings.FILTERS['max_top10_holding'] * 100,
not solscan_data['dev_transfers']
])
import traceback # <-- Ligne ajoutée ici
async def main():
tracker = MemeTracker()
while True:
try: # <-- Début ajouté
await tracker.check_new_listings()
except Exception as e:
logging.error(f"ERREUR: {traceback.format_exc()}")
await tracker.alerter.send_error_alert(traceback.format_exc())
await asyncio.sleep(60)
await asyncio.sleep(settings.CHECK_INTERVAL) # <-- Fin ajouté
if __name__ == "__main__":
asyncio.run(main())