Skip to content

0xFantomMenace/MEV-Tools

Repository files navigation

MEV-Tools

A collection of TypeScript utilities for MEV (Maximal Extractable Value) research and DeFi protocol monitoring on EVM-compatible blockchains.

Overview

This toolkit provides real-time monitoring capabilities for blockchain events critical to MEV research, including:

  • Price feed updates from Chainlink-style oracle aggregators
  • Liquidation events from lending protocols (Aave-fork compatible)
  • Mempool analysis for pending transactions
  • Historical event querying for protocol research

Modules

1. Aggregator AnswerUpdated Listener

Monitors AnswerUpdated events from Chainlink-compatible price feed aggregators in real-time.

Use Case: Track when oracle prices are updated on-chain to identify potential MEV opportunities or validate price feed behavior.

cd "Aggregator AnswerUpdated Listener"
npm install
npm start

2. Event Listener

Multi-chain liquidation event monitor supporting Fantom, Metis, and Optimism networks. Listens for LiquidationCall events from Aave-fork lending pools (Granary Finance, Geist, etc.).

Use Case: Real-time monitoring of liquidation activity across multiple DeFi protocols for research or alerting purposes.

cd "Event Listener"
npm install
npm start

3. Mempool Listener

Monitors pending transactions in the mempool targeting specific aggregator contracts. Decodes transaction data to extract price updates before they are confirmed.

Use Case: Analyze pending oracle updates to understand MEV searcher behavior and front-running dynamics.

cd "Mempool listener"
npm install
npm start

4. Historical Event Logger

Queries historical LiquidationCall events from lending pool contracts using batch block queries.

Use Case: Research historical liquidation patterns, analyze protocol health, or backtest MEV strategies.

cd "Historical Event Logger"
npm install
npm start

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • RPC endpoints for target networks (e.g., QuikNode, Alchemy, Infura)

Configuration

Each module uses environment variables for configuration. Create a .env file in the root of each module or export variables in your shell:

# Fantom Network
export FANTOM_RPC_URL="https://your-fantom-rpc-endpoint"
export FANTOM_WS_RPC_URL="wss://your-fantom-websocket-endpoint"

# Optimism Network
export OPTIMISM_RPC_URL="https://your-optimism-rpc-endpoint"

# Metis Network (public endpoint available)
export METIS_RPC_URL="https://andromeda.metis.io/?owner=1088"

# Contract Addresses (optional - defaults provided)
export AGGREGATOR_ADDRESS="0x..."
export LENDING_POOL_ADDRESS="0x..."
export START_BLOCK="53000000"

Project Structure

MEV-Tools/
├── Aggregator AnswerUpdated Listener/
│   ├── src/
│   │   └── listen.ts          # Price feed event listener
│   ├── contracts/abis/        # Chainlink aggregator ABIs
│   └── package.json
├── Event Listener/
│   ├── src/
│   │   └── listen.ts          # Multi-chain liquidation monitor
│   ├── contracts/abis/        # Lending pool ABIs
│   └── package.json
├── Mempool listener/
│   ├── src/
│   │   └── listen.ts          # Pending transaction analyzer
│   ├── contracts/abis/        # Aggregator ABIs
│   └── package.json
├── Historical Event Logger/
│   ├── src/
│   │   └── logEvents.ts       # Historical event query tool
│   ├── contracts/abis/        # Lending pool ABIs
│   └── package.json
└── README.md

Technical Details

Dependencies

  • ethers.js (v5.5.4) - Ethereum library for blockchain interaction
  • ts-node - TypeScript execution environment
  • TypeScript - Type-safe JavaScript

Supported Protocols

Protocol Network Contract Type
Chainlink Aggregators Fantom Price Feeds
Granary Finance Fantom, Metis, Optimism Lending Pool
Geist Finance Fantom Lending Pool

Event Types Monitored

  • AnswerUpdated(int256 current, uint256 roundId, uint256 updatedAt) - Oracle price updates
  • LiquidationCall(address collateralAsset, address debtAsset, address user, uint256 debtToCover, uint256 liquidatedCollateralAmount, address liquidator, bool receiveAToken) - Lending liquidations

License

This project is for educational and research purposes.

Author

Built for MEV research and DeFi protocol analysis.

About

Tools for MEV research/protocol validation

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published