diff --git a/monitor.py b/monitor.py index 0abc81e..45334fe 100644 --- a/monitor.py +++ b/monitor.py @@ -2,7 +2,7 @@ import time from queue import Queue from loguru import logger from web3 import Web3 -from util import fetch_abi +from util import fetch_abi, format_matrix_alert from db import Token, Pair, get_session @@ -122,7 +122,8 @@ class EventMonitor: # Add alert to queue logger.info(f"New pair: {token0_address} + {token1_address}") - self.queue.put( - f"New Uniswap pair: [{token0_info['name']}](https://etherscan.io/address/{token0_address}) +" - f"[{token1_info['name']}](https://etherscan.io/address/{token1_address})" + formatted_alert = format_matrix_alert( + token0={'name': token0_info['name'], 'address': token0_address}, + token1={'name': token1_info['name'], 'address': token1_address} ) + self.queue.put(formatted_alert) diff --git a/util.py b/util.py index 0e199f0..9ee33f0 100644 --- a/util.py +++ b/util.py @@ -23,3 +23,11 @@ def fetch_abi(address: ChecksumAddress, headers: Optional[Dict[str, Any]] = None def load_config(path: str) -> dict: with open(path, 'r', encoding='utf-8') as f: 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 +""" \ No newline at end of file