Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mempool-analyzer

Ethereum mempool analyzer — detect whale transfers, gas price spikes, and MEV sandwich attacks in real-time from public blockchain data.

Zero API keys required. Uses public Ethereum RPC endpoints with automatic failover.

Install

pip install mempool-analyzer

Or clone and run directly:

git clone https://github.com/technicalanalysis00005-cell/mempool-analyzer.git
cd mempool-analyzer
python -m mempool_analyzer --blocks 5

Usage

Quick scan (10 blocks, 100 ETH whale threshold)

mempool-analyzer

Lower whale threshold to detect smaller moves

mempool-analyzer --whale 10 --blocks 20

Analyze a specific block

mempool-analyzer --block 19000000

JSON output for scripting

mempool-analyzer --json | jq '.whale_transfers'

Continuous monitoring

mempool-analyzer --watch --whale 50

Custom RPC endpoint

mempool-analyzer --rpc https://mainnet.infura.io/v3/YOUR_KEY

Output Example

============================================================
  MEMPOOL ANALYZER — ETHEREUM
============================================================
  Scanned at 2024-12-15 14:30:22 UTC

▸ Network Overview
──────────────────────────────────────────────────
  Block:         #19,456,789
  Base Fee:      28.5 gwei
  Gas Price:     31.2 gwei
  Pending Txs:   N/A (node doesn't expose txpool)
  Blocks Scanned: 10
  Avg Block Time: 12.1s
  Avg Txs/Block: 142
  Avg Gas Used:  52.3%

▸ Whale Transfers (2 detected)
  500.0 ETH  0x1234...5678 → 0xabcd...ef01  block #19456785
    tx: 0xdef456... | gas: 35.0 gwei
  150.0 ETH  0x9876...5432 → 0x1111...2222  block #19456783
    tx: 0xabc123... | gas: 28.0 gwei

▸ Gas Spikes
  No abnormal gas prices detected

▸ MEV Sandwich Detection
  No sandwich patterns detected in scanned blocks

Detection Algorithms

Whale Transfers

Scans all transactions in recent blocks for ETH transfers above the configured threshold. Reports sender, receiver, value, and gas price.

Gas Spike Detection

Compares each block's maximum gas price against the rolling average. Flags blocks where max gas exceeds average * spike_multiplier. Default multiplier is 2.0x.

MEV Sandwich Detection

Heuristic pattern matching:

  1. Groups transactions by block
  2. Filters for known DEX router interactions (Uniswap V2/V3, SushiSwap, 1inch, 0x)
  3. Looks for 3-transaction patterns where the same address appears before and after a different address's swap
  4. Known routers: Uniswap V2, V3, SushiSwap, 1inch V4/V5, 0x Exchange

Features

  • Zero dependencies — pure Python 3.8+ stdlib
  • Public RPCs — no API key needed (Cloudflare, Ankr, LlamaNodes, 1RPC, dRPC)
  • Automatic failover — tries multiple endpoints on failure
  • Colored output — auto-disables when piped
  • JSON output — for piping into jq or other tools
  • Watch mode — continuous monitoring with ~12s refresh
  • Configurable thresholds — whale amount, gas spike multiplier, block count

As Library

from mempool_analyzer.rpc import EthereumRPC
from mempool_analyzer.detector import MempoolAnalyzer

rpc = EthereumRPC()  # Uses public endpoints
analyzer = MempoolAnalyzer(rpc, whale_threshold_eth=50)

snapshot = analyzer.scan_recent_blocks(count=15)

for whale in snapshot.whale_transfers:
    print(f"{whale.value_eth} ETH: {whale.from_addr} -> {whale.to_addr}")

for spike in snapshot.gas_spikes:
    print(f"Block #{spike.block}: max {spike.max_gas_price_gwei} gwei")

CLI Reference

Flag Short Default Description
--rpc -r auto Ethereum RPC endpoint URL
--blocks -b 10 Number of recent blocks to scan
--whale -w 100.0 Whale threshold in ETH
--spike-mult -s 2.0 Gas spike multiplier vs average
--block -B - Analyze specific block number
--json -j false JSON output
--watch -W false Continuous monitoring
--no-color - false Disable colored output

License

MIT

About

Ethereum mempool analyzer — whale tracker, gas spike detector, MEV sandwich finder. Zero API keys, public RPCs.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages