@intentsolutionsio/mempool-analyzer 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/.claude-plugin/plugin.json +22 -0
  2. package/LICENSE +21 -0
  3. package/README.md +97 -0
  4. package/agents/mempool-agent.md +158 -0
  5. package/package.json +43 -0
  6. package/skills/analyzing-mempool/ARD.md +146 -0
  7. package/skills/analyzing-mempool/PRD.md +71 -0
  8. package/skills/analyzing-mempool/SKILL.md +110 -0
  9. package/skills/analyzing-mempool/config/settings.yaml +43 -0
  10. package/skills/analyzing-mempool/references/errors.md +122 -0
  11. package/skills/analyzing-mempool/references/examples.md +189 -0
  12. package/skills/analyzing-mempool/references/implementation.md +67 -0
  13. package/skills/analyzing-mempool/scripts/formatters.py +244 -0
  14. package/skills/analyzing-mempool/scripts/gas_analyzer.py +299 -0
  15. package/skills/analyzing-mempool/scripts/mempool_analyzer.py +320 -0
  16. package/skills/analyzing-mempool/scripts/mev_detector.py +387 -0
  17. package/skills/analyzing-mempool/scripts/rpc_client.py +311 -0
  18. package/skills/analyzing-mempool/scripts/tx_decoder.py +273 -0
  19. package/skills/skill-adapter/assets/README.md +6 -0
  20. package/skills/skill-adapter/assets/config-template.json +32 -0
  21. package/skills/skill-adapter/assets/skill-schema.json +28 -0
  22. package/skills/skill-adapter/assets/test-data.json +27 -0
  23. package/skills/skill-adapter/references/README.md +4 -0
  24. package/skills/skill-adapter/references/best-practices.md +69 -0
  25. package/skills/skill-adapter/references/examples.md +73 -0
  26. package/skills/skill-adapter/scripts/README.md +8 -0
  27. package/skills/skill-adapter/scripts/helper-template.sh +42 -0
  28. package/skills/skill-adapter/scripts/validation.sh +32 -0
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "mempool-analyzer",
3
+ "version": "1.0.0",
4
+ "description": "Advanced mempool analysis for MEV opportunities, pending transaction monitoring, and gas price optimization",
5
+ "author": {
6
+ "name": "Intent Solutions IO",
7
+ "email": "jeremy@intentsolutions.ai",
8
+ "url": "https://intentsolutions.ai"
9
+ },
10
+ "repository": "https://github.com/jeremylongshore/claude-code-plugins",
11
+ "license": "MIT",
12
+ "keywords": [
13
+ "crypto",
14
+ "mempool",
15
+ "mev",
16
+ "ethereum",
17
+ "blockchain",
18
+ "gas",
19
+ "pending-transactions",
20
+ "arbitrage"
21
+ ]
22
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024-2026 Jeremy Longshore & Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,97 @@
1
+ # Mempool Analyzer Plugin
2
+
3
+ Advanced mempool analysis for MEV opportunities, pending transaction monitoring, and gas price optimization.
4
+
5
+ ## Features
6
+
7
+ - **Real-time mempool monitoring** across Ethereum, BSC, Polygon, and Arbitrum
8
+ - **MEV opportunity detection** including sandwich attacks, arbitrage, and liquidations
9
+ - **Gas price optimization** with EIP-1559 base fee prediction
10
+ - **Transaction analysis** with calldata decoding and simulation
11
+ - **Block builder monitoring** to understand validator MEV extraction
12
+ - **Risk assessment** for detected opportunities
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ /plugin install mempool-analyzer@claude-code-plugins-plus
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ The mempool agent automatically activates when you discuss:
23
+ - Mempool analysis and pending transactions
24
+ - MEV opportunities and extraction strategies
25
+ - Gas price optimization
26
+ - Front-running and sandwich attack detection
27
+ - Large transaction monitoring
28
+
29
+ ### Example Queries
30
+
31
+ ```
32
+ What MEV opportunities are currently in the mempool?
33
+
34
+ Show me all pending large ETH transfers over $1M
35
+
36
+ What's the optimal gas price for the next block?
37
+
38
+ Analyze pending Uniswap swaps for arbitrage opportunities
39
+
40
+ Monitor address 0x... for incoming mempool transactions
41
+ ```
42
+
43
+ ## Configuration
44
+
45
+ Create a `.mempool-config.json` file:
46
+
47
+ ```json
48
+ {
49
+ "networks": ["ethereum", "bsc", "polygon", "arbitrum"],
50
+ "rpcEndpoints": {
51
+ "ethereum": "wss://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"
52
+ },
53
+ "mevDetection": {
54
+ "minProfitUSD": 100,
55
+ "maxGasPrice": 200,
56
+ "sandwichDetection": true,
57
+ "arbitrageDetection": true,
58
+ "liquidationMonitoring": true
59
+ },
60
+ "alerts": {
61
+ "largeTransferThreshold": 1000000,
62
+ "highGasWarning": 150,
63
+ "mevOpportunityFound": true
64
+ }
65
+ }
66
+ ```
67
+
68
+ ## Data Sources
69
+
70
+ - Flashbots Protect RPC
71
+ - Blocknative Mempool Explorer
72
+ - Eden Network
73
+ - MEV-Blocker
74
+ - Public RPC nodes
75
+ - Block explorer APIs
76
+
77
+ ## Risk Warnings
78
+
79
+ ️ **Important Considerations**:
80
+ - MEV extraction is highly competitive with sophisticated bots
81
+ - Gas wars can eliminate profits quickly
82
+ - Smart contract interactions carry inherent risks
83
+ - Some MEV strategies have regulatory implications
84
+ - This tool is for **educational and defensive purposes**
85
+
86
+ ## License
87
+
88
+ MIT License - See LICENSE file for details
89
+
90
+ ## Support
91
+
92
+ - GitHub Issues: [Report bugs](https://github.com/jeremylongshore/claude-code-plugins/issues)
93
+ - Documentation: [Full docs](https://docs.claude-code-plugins.com)
94
+
95
+ ---
96
+
97
+ *Built with ️ for blockchain researchers by Intent Solutions IO*
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: mempool-agent
3
+ description: "Mempool analysis specialist for MEV detection and transaction monitoring"
4
+ ---
5
+ # Mempool Analysis Agent
6
+
7
+ You are a specialized agent for analyzing blockchain mempools, detecting MEV (Maximal Extractable Value) opportunities, and monitoring pending transactions.
8
+
9
+ ## Your Capabilities
10
+
11
+ ### Mempool Monitoring
12
+ - Real-time monitoring of pending transactions across Ethereum, BSC, Polygon, and Arbitrum
13
+ - Transaction classification (swaps, transfers, contract interactions)
14
+ - Priority fee analysis and gas price trends
15
+ - Block builder analysis and validator behavior
16
+ - Mempool congestion metrics
17
+
18
+ ### MEV Detection
19
+ - **Sandwich attacks**: Detect front-running and back-running opportunities
20
+ - **Arbitrage opportunities**: Multi-DEX price discrepancies in pending trades
21
+ - **Liquidation monitoring**: Track undercollateralized positions
22
+ - **NFT sniping**: Identify underpriced NFT listings
23
+ - **Just-in-time (JIT) liquidity**: Uniswap v3 position optimization
24
+
25
+ ### Transaction Analysis
26
+ - Decode transaction calldata and extract parameters
27
+ - Estimate profit/loss for detected MEV opportunities
28
+ - Calculate optimal gas prices for transaction inclusion
29
+ - Simulate transaction outcomes before execution
30
+ - Track transaction replacement (RBF) patterns
31
+
32
+ ### Gas Optimization
33
+ - EIP-1559 base fee prediction
34
+ - Priority fee recommendation engine
35
+ - Gas auction analysis
36
+ - Block space market dynamics
37
+ - Optimal transaction timing
38
+
39
+ ## When to Activate
40
+
41
+ Activate this agent when users need to:
42
+ - Monitor the mempool for trading opportunities
43
+ - Detect MEV opportunities in real-time
44
+ - Analyze pending transactions for a specific address or contract
45
+ - Optimize gas prices for transaction submission
46
+ - Research front-running or sandwich attack patterns
47
+ - Track large pending transfers ("whale watching")
48
+ - Study block builder behavior and validator MEV extraction
49
+ - Build MEV protection strategies
50
+
51
+ ## Approach
52
+
53
+ ### Analysis Methodology
54
+ 1. **Data Collection**: Connect to mempool nodes via WebSocket or RPC endpoints
55
+ 2. **Classification**: Categorize transactions by type and intent
56
+ 3. **Pattern Recognition**: Identify MEV opportunities using heuristics and ML models
57
+ 4. **Impact Assessment**: Calculate potential profit and required capital
58
+ 5. **Risk Evaluation**: Assess execution risk, slippage, and competition
59
+ 6. **Recommendation**: Provide actionable insights with risk/reward analysis
60
+
61
+ ### Output Format
62
+ Present findings in structured format:
63
+ ```
64
+ MEMPOOL ANALYSIS REPORT
65
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
66
+
67
+ MEV OPPORTUNITIES DETECTED: [count]
68
+
69
+ 1. [OPPORTUNITY TYPE]
70
+ Target: [transaction hash]
71
+ Contract: [address]
72
+ Estimated Profit: $[amount] ([percentage]%)
73
+ Required Capital: $[amount]
74
+ Risk Level: [Low/Medium/High]
75
+ Competition: [count] other bots detected
76
+
77
+ Strategy:
78
+ - [Action 1]
79
+ - [Action 2]
80
+
81
+ ️ Risks:
82
+ - [Risk factor 1]
83
+ - [Risk factor 2]
84
+
85
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
86
+
87
+ MEMPOOL STATISTICS
88
+ - Pending Transactions: [count]
89
+ - Average Gas Price: [gwei]
90
+ - Base Fee: [gwei] (next block prediction: [gwei])
91
+ - Mempool Congestion: [Low/Medium/High]
92
+ - Block Builder Activity: [description]
93
+
94
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
95
+
96
+ RECOMMENDATIONS
97
+ 1. [Recommendation]
98
+ 2. [Recommendation]
99
+ ```
100
+
101
+ ## Risk Warnings
102
+
103
+ Always include appropriate risk warnings:
104
+ - **MEV extraction is highly competitive** - Sophisticated bots with direct block builder relationships dominate
105
+ - **Gas wars can eliminate profits** - Fast-moving opportunities attract aggressive bidding
106
+ - **Smart contract risk** - Interacting with unverified contracts is dangerous
107
+ - **Regulatory considerations** - Some MEV strategies may have legal implications
108
+ - **Slippage and front-running** - Your transaction can be front-run by others
109
+
110
+ ## Data Sources
111
+
112
+ Primary data sources for mempool analysis:
113
+ - **Flashbots Protect RPC**: MEV-protected transaction submission
114
+ - **Blocknative Mempool Explorer**: Real-time mempool data and gas predictions
115
+ - **Eden Network**: Priority transaction ordering
116
+ - **MEV-Blocker**: Anti-MEV RPC endpoint
117
+ - **Public RPC nodes**: Direct mempool access via eth_newPendingTransactionFilter
118
+ - **Block explorer APIs**: Etherscan, BSCscan for transaction decoding
119
+
120
+ ## Ethical Considerations
121
+
122
+ - Focus on defensive MEV strategies (protecting users from attacks)
123
+ - Avoid promoting sandwich attacks that harm retail traders
124
+ - Emphasize transparency and education over exploitation
125
+ - Recommend MEV-protected RPC endpoints for regular users
126
+ - Disclose when strategies may impact other users negatively
127
+
128
+ ## Technical Requirements
129
+
130
+ To perform mempool analysis, ensure:
131
+ - Access to archive nodes or mempool-focused RPC providers
132
+ - WebSocket connections for real-time transaction streams
133
+ - Transaction simulation capabilities (eth_call, Tenderly)
134
+ - Decoded transaction parsing libraries
135
+ - Gas price oracle integration
136
+ - Block builder relay monitoring
137
+
138
+ ## Example Queries
139
+
140
+ You can answer questions like:
141
+ - "What MEV opportunities are currently in the mempool?"
142
+ - "Show me all pending large ETH transfers"
143
+ - "What's the optimal gas price to get included in the next block?"
144
+ - "Are there any sandwich attack opportunities on Uniswap right now?"
145
+ - "Analyze this transaction hash for front-running risk"
146
+ - "What DEX arbitrage opportunities exist in pending swaps?"
147
+ - "Monitor address [0x...] for incoming mempool transactions"
148
+
149
+ ## Limitations
150
+
151
+ - Mempool data is non-deterministic and constantly changing
152
+ - Private mempools and OFA (Order Flow Auctions) hide significant MEV volume
153
+ - Not all nodes share the same mempool view
154
+ - Flashbots and other private order flow is invisible
155
+ - MEV detection requires sophisticated pattern recognition
156
+ - Real-time execution requires infrastructure beyond this agent's scope
157
+
158
+ Always provide educational, defensive-focused analysis rather than exploit-focused recommendations.
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@intentsolutionsio/mempool-analyzer",
3
+ "version": "1.0.0",
4
+ "description": "Advanced mempool analysis for MEV opportunities, pending transaction monitoring, and gas price optimization",
5
+ "keywords": [
6
+ "crypto",
7
+ "mempool",
8
+ "mev",
9
+ "ethereum",
10
+ "blockchain",
11
+ "gas",
12
+ "pending-transactions",
13
+ "arbitrage",
14
+ "claude-code",
15
+ "claude-plugin",
16
+ "tonsofskills"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/jeremylongshore/claude-code-plugins-plus-skills.git",
21
+ "directory": "plugins/crypto/mempool-analyzer"
22
+ },
23
+ "homepage": "https://tonsofskills.com/plugins/mempool-analyzer",
24
+ "bugs": "https://github.com/jeremylongshore/claude-code-plugins-plus-skills/issues",
25
+ "license": "MIT",
26
+ "author": {
27
+ "name": "Intent Solutions IO",
28
+ "email": "jeremy@intentsolutions.ai",
29
+ "url": "https://intentsolutions.ai"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "files": [
35
+ "README.md",
36
+ ".claude-plugin",
37
+ "skills",
38
+ "agents"
39
+ ],
40
+ "scripts": {
41
+ "postinstall": "node -e \"console.log(\\\"\\\\n→ This npm package is a tracking/proof artifact. Install the plugin via:\\\\n ccpi install mempool-analyzer\\\\n or /plugin install mempool-analyzer@claude-code-plugins-plus in Claude Code\\\\n\\\")\""
42
+ }
43
+ }
@@ -0,0 +1,146 @@
1
+ # ARD: Mempool Analyzer
2
+
3
+ > Part of [Tons of Skills](https://tonsofskills.com) by [Intent Solutions](https://intentsolutions.io) | [jeremylongshore.com](https://jeremylongshore.com)
4
+
5
+ ## Architecture Pattern
6
+
7
+ **Stream Processing Pattern** - Python CLI that subscribes to mempool updates, decodes transactions, and presents analyzed data.
8
+
9
+ ## Workflow
10
+
11
+ ```
12
+ RPC Connection → Mempool Subscription → TX Decode → Analysis → Output
13
+ ↓ ↓ ↓ ↓ ↓
14
+ WebSocket newPendingTx ABI Decode Classify Table/JSON
15
+ ```
16
+
17
+ ## Data Flow
18
+
19
+ ```
20
+ Input: RPC URL, filters (contract, method, min_value)
21
+
22
+ Subscription: eth_subscribe("newPendingTransactions")
23
+
24
+ Fetch: eth_getTransactionByHash for each pending tx
25
+
26
+ Decode: Parse input data using known ABIs
27
+
28
+ Analyze: Classify (swap, transfer, approval), estimate value
29
+
30
+ Output: Formatted display or JSON stream
31
+ ```
32
+
33
+ ## Directory Structure
34
+
35
+ ```
36
+ skills/analyzing-mempool/
37
+ ├── PRD.md # This requirements doc
38
+ ├── ARD.md # This architecture doc
39
+ ├── SKILL.md # Agent instructions
40
+ ├── scripts/
41
+ │ ├── mempool_analyzer.py # Main CLI entry point
42
+ │ ├── rpc_client.py # Ethereum RPC/WebSocket client
43
+ │ ├── tx_decoder.py # Transaction decoding
44
+ │ ├── gas_analyzer.py # Gas price analysis
45
+ │ ├── mev_detector.py # MEV opportunity detection
46
+ │ └── formatters.py # Output formatting
47
+ ├── references/
48
+ │ ├── errors.md # Error handling guide
49
+ │ └── examples.md # Usage examples
50
+ └── config/
51
+ └── settings.yaml # Default configuration
52
+ ```
53
+
54
+ ## API Integration
55
+
56
+ ### Ethereum RPC
57
+ - **Endpoints**: `eth_pendingTransactions`, `eth_getTransactionByHash`, `eth_gasPrice`
58
+ - **Auth**: RPC URL with API key embedded
59
+ - **WebSocket**: `eth_subscribe` for real-time updates
60
+
61
+ ### Transaction Decoding
62
+ - **Router ABIs**: Uniswap V2/V3, SushiSwap, 1inch
63
+ - **Method Detection**: Swap, addLiquidity, removeLiquidity, approve
64
+ - **Value Estimation**: Using pool reserves or price feeds
65
+
66
+ ## Component Design
67
+
68
+ ### rpc_client.py
69
+ ```python
70
+ class MempoolClient:
71
+ def connect(rpc_url) -> None
72
+ def get_pending_transactions(limit) -> List[PendingTx]
73
+ def subscribe_pending(callback) -> None
74
+ def get_gas_price() -> GasInfo
75
+ ```
76
+
77
+ ### tx_decoder.py
78
+ ```python
79
+ class TransactionDecoder:
80
+ def decode_input(tx) -> DecodedCall
81
+ def identify_dex_swap(tx) -> Optional[SwapInfo]
82
+ def estimate_usd_value(tx) -> float
83
+ ```
84
+
85
+ ### gas_analyzer.py
86
+ ```python
87
+ class GasAnalyzer:
88
+ def analyze_pending_gas() -> GasDistribution
89
+ def recommend_gas(priority) -> GasRecommendation
90
+ def estimate_inclusion_time(gas_price) -> int
91
+ ```
92
+
93
+ ### mev_detector.py
94
+ ```python
95
+ class MEVDetector:
96
+ def detect_sandwich_opportunity(pending_txs) -> List[Opportunity]
97
+ def detect_arbitrage(pending_swaps) -> List[Opportunity]
98
+ def detect_liquidation(pending_txs) -> List[Opportunity]
99
+ ```
100
+
101
+ ## Error Handling Strategy
102
+
103
+ | Error | Handling |
104
+ |-------|----------|
105
+ | RPC connection failed | Retry with backoff, show connection status |
106
+ | WebSocket disconnected | Auto-reconnect with exponential backoff |
107
+ | ABI decode failed | Label as "Unknown" with raw data |
108
+ | Rate limit | Queue requests, show warning |
109
+ | Invalid transaction | Skip with warning, continue stream |
110
+
111
+ ## Gas Analysis Algorithm
112
+
113
+ ```
114
+ 1. Fetch last N blocks gas prices
115
+ 2. Fetch pending tx gas prices
116
+ 3. Calculate percentiles (10th, 25th, 50th, 75th, 90th)
117
+ 4. Recommend based on urgency:
118
+ - Slow: 10th percentile (may take 10+ blocks)
119
+ - Standard: 50th percentile (2-5 blocks)
120
+ - Fast: 75th percentile (1-2 blocks)
121
+ - Instant: 90th percentile (next block likely)
122
+ ```
123
+
124
+ ## DEX Detection
125
+
126
+ Supported routers with ABI decoding:
127
+ - Uniswap V2 Router
128
+ - Uniswap V3 Router
129
+ - SushiSwap Router
130
+ - Curve pools
131
+ - Balancer pools
132
+ - 1inch Aggregator
133
+
134
+ ## Performance Considerations
135
+
136
+ - WebSocket preferred over HTTP polling
137
+ - Batch RPC calls where possible
138
+ - Cache decoded ABIs
139
+ - Limit pending tx fetch to reasonable count (100-500)
140
+ - Stream mode for continuous monitoring
141
+
142
+ ## Security
143
+
144
+ - No private keys required (read-only)
145
+ - RPC URL may contain API key (handle securely)
146
+ - No transaction submission capability
@@ -0,0 +1,71 @@
1
+ # PRD: Mempool Analyzer
2
+
3
+ ## Summary
4
+ **One-liner**: Monitor blockchain mempools for pending transactions, gas analysis, and MEV opportunity detection
5
+ **Domain**: Cryptocurrency / Blockchain / Trading Infrastructure
6
+ **Users**: Traders, MEV Searchers, Protocol Developers, Researchers
7
+
8
+ ## Problem Statement
9
+
10
+ Blockchain mempools contain pending transactions waiting to be included in blocks. Understanding mempool activity is critical for:
11
+ - Optimizing gas prices for transaction inclusion
12
+ - Detecting large pending trades before execution
13
+ - Identifying MEV (Maximal Extractable Value) opportunities
14
+ - Monitoring network congestion and fee trends
15
+ - Detecting potential front-running attacks
16
+
17
+ Currently, mempool analysis requires running full nodes, subscribing to expensive services, or manually querying complex RPC endpoints.
18
+
19
+ ## User Stories
20
+
21
+ 1. **As a trader**, I want to see pending large swaps in the mempool, so I can anticipate potential price impact.
22
+ - Acceptance: Detects and displays pending DEX swaps above threshold with token pair and size
23
+
24
+ 2. **As a gas optimizer**, I want to analyze current gas prices and pending tx distribution, so I can choose optimal gas for my transaction.
25
+ - Acceptance: Shows gas price distribution, priority fee suggestions, and estimated inclusion time
26
+
27
+ 3. **As a MEV searcher**, I want to identify arbitrage and sandwich opportunities in pending transactions.
28
+ - Acceptance: Detects profitable opportunities with estimated profit and required capital
29
+
30
+ 4. **As a protocol developer**, I want to monitor mempool for large pending actions on my protocol.
31
+ - Acceptance: Filters pending txs by contract address with decoded function calls
32
+
33
+ ## Functional Requirements
34
+
35
+ - **REQ-1**: Connect to Ethereum mempool via RPC/WebSocket
36
+ - **REQ-2**: Parse and decode pending transactions (transfers, swaps, approvals)
37
+ - **REQ-3**: Analyze gas price distribution and recommend optimal fees
38
+ - **REQ-4**: Detect large pending trades (configurable threshold)
39
+ - **REQ-5**: Monitor specific contract addresses for pending interactions
40
+ - **REQ-6**: Identify potential MEV opportunities (arbitrage, liquidations)
41
+ - **REQ-7**: Support multiple output formats (table, JSON, stream)
42
+
43
+ ## API Integrations
44
+
45
+ | API | Purpose | Auth |
46
+ |-----|---------|------|
47
+ | Ethereum RPC | Mempool access | Alchemy, Chainstack, or Infura URL |
48
+ | Flashbots API | MEV bundle status | No auth for basic |
49
+ | DEX Subgraphs | Pool/pair data | No auth |
50
+ | Etherscan | Contract ABI | API key (free tier) |
51
+
52
+ ## Success Metrics
53
+
54
+ - Real-time mempool data with < 1 second delay
55
+ - Accurate gas price recommendations (within 10% of actual)
56
+ - Detection of 90%+ large pending swaps
57
+ - Clear MEV opportunity identification with profit estimates
58
+
59
+ ## Non-Goals
60
+
61
+ - Automated MEV execution (analysis only)
62
+ - Private mempool access (public mempool only)
63
+ - Transaction submission or bundling
64
+
65
+ ## Supported Chains
66
+
67
+ - Ethereum (primary)
68
+ - Polygon
69
+ - Arbitrum
70
+ - Optimism
71
+ - Base
@@ -0,0 +1,110 @@
1
+ ---
2
+ name: analyzing-mempool
3
+ description: |
4
+ Monitor blockchain mempools for pending transactions, gas analysis, and MEV opportunities.
5
+ Use when analyzing pending transactions, optimizing gas prices, or researching MEV.
6
+ Trigger with phrases like "check mempool", "scan pending txs", "find MEV", "gas price analysis", or "pending swaps".
7
+
8
+ allowed-tools: Read, Write, Edit, Grep, Glob, Bash(python:*mempool*)
9
+ version: 1.0.0
10
+ author: Jeremy Longshore <jeremy@intentsolutions.io>
11
+ license: MIT
12
+ compatible-with: claude-code, codex, openclaw
13
+ tags: [crypto, monitoring, analyzing-mempool]
14
+ ---
15
+ # Analyzing Mempool
16
+
17
+ ## Contents
18
+
19
+ [Overview](#overview) | [Prerequisites](#prerequisites) | [Instructions](#instructions) | [Output](#output) | [Error Handling](#error-handling) | [Examples](#examples) | [Resources](#resources)
20
+
21
+ ## Overview
22
+
23
+ Monitor Ethereum mempool for pending transactions, analyze gas prices, detect DEX swaps, and identify potential MEV opportunities. Useful for traders, MEV researchers, and protocol developers.
24
+
25
+ ## Prerequisites
26
+
27
+ 1. Install Python 3.8+ with requests library
28
+ 2. Configure Ethereum RPC URL (default: public endpoint, or set `ETH_RPC_URL`)
29
+ 3. Verify internet access for RPC calls
30
+
31
+ ## Instructions
32
+
33
+ ### Step 1: Navigate to Scripts Directory
34
+
35
+ ```bash
36
+ cd ${CLAUDE_SKILL_DIR}/scripts
37
+ ```
38
+
39
+ ### Step 2: Choose a Command
40
+
41
+ 1. View pending transactions: `python mempool_analyzer.py pending`
42
+ 2. Analyze gas prices: `python mempool_analyzer.py gas`
43
+ 3. Detect pending DEX swaps: `python mempool_analyzer.py swaps`
44
+ 4. Scan MEV opportunities: `python mempool_analyzer.py mev`
45
+ 5. Get mempool summary: `python mempool_analyzer.py summary`
46
+ 6. Watch specific contract: `python mempool_analyzer.py watch 0x7a250d...`
47
+
48
+ Alternatively, customize with flags:
49
+ ```bash
50
+ python mempool_analyzer.py pending --limit 100 # Limit results
51
+ python mempool_analyzer.py --chain polygon gas # Use different chain
52
+ python mempool_analyzer.py --chain arbitrum pending # Or use Arbitrum
53
+ ```
54
+
55
+ ### Step 3: Interpret Results
56
+
57
+ **Gas Recommendations:**
58
+ - Slow (10th percentile): May take 10+ blocks
59
+ - Standard (50th percentile): 2-5 blocks
60
+ - Fast (75th percentile): 1-2 blocks
61
+ - Instant (90th percentile): Next block likely
62
+
63
+ **MEV Warnings:**
64
+ - MEV detection is for educational purposes
65
+ - Real MEV extraction requires specialized infrastructure
66
+ - Use this for research and understanding mempool dynamics
67
+
68
+ ## Output
69
+
70
+ - Pending transaction lists with gas prices and types
71
+ - Gas price distribution and recommendations
72
+ - Detected DEX swaps with amounts and DEX identification
73
+ - MEV opportunity analysis with estimated profits
74
+ - JSON output for programmatic use (`--format json`)
75
+
76
+ ## Error Handling
77
+
78
+ See `${CLAUDE_SKILL_DIR}/references/errors.md` for:
79
+ - RPC connection issues and timeout recovery
80
+ - Mempool access limitations per chain
81
+ - Transaction decoding errors and fallbacks
82
+ - Gas analysis edge cases
83
+
84
+ ## Examples
85
+
86
+ **Example 1: Check gas before sending transaction:**
87
+ ```bash
88
+ python mempool_analyzer.py gas
89
+ # Use "Fast" for quick confirmation
90
+ ```
91
+
92
+ **Example 2: Monitor for large pending swaps:**
93
+ ```bash
94
+ python mempool_analyzer.py swaps --limit 200 # 200: max results to scan
95
+ ```
96
+
97
+ **Example 3: Research MEV opportunities:**
98
+ ```bash
99
+ python mempool_analyzer.py mev -v
100
+ ```
101
+
102
+ See `${CLAUDE_SKILL_DIR}/references/examples.md` for more usage patterns.
103
+
104
+ ## Resources
105
+
106
+ - `${CLAUDE_SKILL_DIR}/references/implementation.md` - Gas analysis, MEV detection, multi-chain details
107
+ - [Ethereum JSON-RPC](https://ethereum.org/en/developers/docs/apis/json-rpc/) - RPC specification
108
+ - [Flashbots](https://flashbots.net) - MEV research and infrastructure
109
+ - [DEX Subgraphs](https://thegraph.com) - Pool and swap data
110
+ - Supports: Ethereum, Polygon, Arbitrum, Optimism, Base