← Back to all products
$13
MEV Monitoring Agent
Real-time dashboard for monitoring mempool activity, profitable opportunities, and bot status.
TOMLPythonMarkdown
📁 File Structure 18 files
mev-monitoring-agent/
├── LICENSE
├── README.md
├── pyproject.toml
├── security-notes.md
├── src/
│ └── mev_monitoring_agent/
│ ├── __init__.py
│ ├── agent.py
│ ├── alerts/
│ │ ├── __init__.py
│ │ ├── channels.py
│ │ └── manager.py
│ ├── config.py
│ ├── detectors/
│ │ ├── __init__.py
│ │ ├── backrun.py
│ │ ├── base.py
│ │ ├── frontrun.py
│ │ └── sandwich.py
│ └── types.py
└── tests/
├── __init__.py
└── test_agent.py
📖 Documentation Preview README excerpt
MEV Monitoring Agent
Background service alerting when your contracts are being MEV'd.
Price: $12.99 | License: MIT | Python: 3.10+
What It Does
The MEV Monitoring Agent watches on-chain transactions interacting with your smart contracts and detects common MEV extraction patterns in real time:
- Sandwich attacks — Front-run + victim + back-run swap patterns
- Frontrunning — Priority gas auctions and transaction displacement
- Backrunning — Arbitrage or liquidation immediately after your transactions
When MEV is detected, alerts are dispatched to your configured channels: Slack, Telegram, webhooks, email, or a log file.
Quick Start
# Install
pip install -e .
# Set environment variables
export RPC_URL="https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
export MONITOR_CONTRACTS="0xYourVault,0xYourDEX"
export SLACK_WEBHOOK_URL="https://hooks.slack.com/services/YOUR/WEBHOOK"
# Run
mev-monitor
Features
| Feature | Description |
|---|---|
| Sandwich detector | Identifies A-B-A patterns in consecutive transactions |
| Frontrun detector | Flags high-gas transactions preceding your users' txs |
| Backrun detector | Detects immediate follow-up arbitrage after monitored txs |
| Multi-channel alerts | Slack, Telegram, webhook, email, log file |
| Configurable thresholds | Min profit, gas multiplier, time window |
| Graceful shutdown | SIGINT/SIGTERM handling with summary stats |
| Extensible | Add custom detectors via BaseDetector |
Configuration
Environment Variables
| Variable | Default | Description |
|---|---|---|
RPC_URL | http://localhost:8545 | HTTP RPC endpoint |
WS_RPC_URL | ws://localhost:8546 | WebSocket RPC endpoint |
POLL_INTERVAL | 2 | Seconds between block polls |
MONITOR_CONTRACTS | — | Comma-separated contract addresses |
MIN_PROFIT_ALERT_WEI | 10^15 (0.001 ETH) | Minimum profit to trigger alert |
LOG_LEVEL | info | Logging level |
Alert Channels
... continues with setup instructions, usage examples, and more.
📄 Code Sample .py preview
src/mev_monitoring_agent/agent.py
# ═══════════════════════════════════════════════════════════════════════
# MEV Monitoring Agent — Core Agent
# Background service that monitors contracts for MEV extraction
# ═══════════════════════════════════════════════════════════════════════
from __future__ import annotations
import asyncio
import logging
import signal
import time
from typing import Optional
from web3 import Web3
from .config import MonitorConfig
from .types import MEVEvent, MEVType, AlertSeverity
from .detectors.base import BaseDetector
from .detectors.sandwich import SandwichDetector
from .detectors.frontrun import FrontrunDetector
from .detectors.backrun import BackrunDetector
from .alerts.manager import AlertManager
logger = logging.getLogger(__name__)
class MEVMonitoringAgent:
"""
Background MEV monitoring service.
Watches on-chain transactions interacting with monitored contracts
and runs detection heuristics for various MEV types. When MEV is
detected, alerts are dispatched via the configured channels.
Usage:
config = MonitorConfig.from_env()
agent = MEVMonitoringAgent(config)
agent.run()
"""
def __init__(self, config: MonitorConfig) -> None:
self.config = config
self.w3 = Web3(Web3.HTTPProvider(config.rpc_url))
self.alert_manager = AlertManager(config)
self.detectors: list[BaseDetector] = []
self._running = False
self._events: list[MEVEvent] = []
self._blocks_processed = 0
self._start_time: Optional[float] = None
# ... 159 more lines ...