format_matrix_alert

This commit is contained in:
agatha 2024-06-08 16:31:07 -04:00
parent 315ff32422
commit 8bd83a28c8
2 changed files with 13 additions and 4 deletions

View File

@ -2,7 +2,7 @@ import time
from queue import Queue from queue import Queue
from loguru import logger from loguru import logger
from web3 import Web3 from web3 import Web3
from util import fetch_abi from util import fetch_abi, format_matrix_alert
from db import Token, Pair, get_session from db import Token, Pair, get_session
@ -122,7 +122,8 @@ class EventMonitor:
# Add alert to queue # Add alert to queue
logger.info(f"New pair: {token0_address} + {token1_address}") logger.info(f"New pair: {token0_address} + {token1_address}")
self.queue.put( formatted_alert = format_matrix_alert(
f"New Uniswap pair: [{token0_info['name']}](https://etherscan.io/address/{token0_address}) +" token0={'name': token0_info['name'], 'address': token0_address},
f"[{token1_info['name']}](https://etherscan.io/address/{token1_address})" token1={'name': token1_info['name'], 'address': token1_address}
) )
self.queue.put(formatted_alert)

View File

@ -23,3 +23,11 @@ def fetch_abi(address: ChecksumAddress, headers: Optional[Dict[str, Any]] = None
def load_config(path: str) -> dict: def load_config(path: str) -> dict:
with open(path, 'r', encoding='utf-8') as f: with open(path, 'r', encoding='utf-8') as f:
return json.loads(f.read()) return json.loads(f.read())
def format_matrix_alert(token0: dict, token1: dict) -> str:
return f"""
🚨 New Uniswap Pair Alert 🚨\n
🌐 **Asset Pair:** [{token0['name']}](https://etherscan.io/token/{token0['address']}) + [{token1['name']}](https://etherscan.io/token/{token1['address']})\n
🏠 **Network:** ETH
"""