Skip to content

Flash Loan & MEV Knowledge Base for Claude Discussions

Notifications You must be signed in to change notification settings

jussirantala/flashmillion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Flash Million - Flash Loan & MEV Knowledge Base for Claude Discussions

A Comprehensive Documentation Repository for In-Depth Claude Conversations about Flash Loans, MEV, and DeFi Arbitrage

Documentation Implementation Guides Last Updated

Documentation Index β€’ Implementation Guides β€’ Architecture Diagrams β€’ Contribute


🎯 What is This Repository?

This repository is a curated knowledge base designed to provide Claude (Anthropic's AI assistant) with comprehensive context about flash loans, MEV (Maximal Extractable Value), and DeFi arbitrage strategies. It enables users to have deep, informed discussions with Claude about these complex topics without repeatedly explaining fundamentals.

Purpose

For Users Interested in Flash Loans & MEV:

  • Get instant, context-aware answers from Claude about flash loan mechanics
  • Discuss MEV strategies with full technical context loaded
  • Analyze implementation approaches with complete code examples
  • Explore profitability and risks with up-to-date information

For Claude:

  • Access 76 comprehensive markdown files covering all aspects of flash loans and MEV
  • Reference real-world implementations from 41 GitHub repositories
  • Provide accurate, nuanced responses based on current (2024-2025) information
  • Guide users through complex technical decisions with full context

πŸ“š What's Included

76 Comprehensive Documentation Files

Category Files Description
Core Protocols 7 files Official Aave V3, Flashbots, provider comparisons
Tutorial Guides 21 files MEV attacks, defenses, optimization, 2024-2025 trends
πŸ†• Implementation Guides 5 files Complete source code for Solidity, TypeScript, Rust, Python
GitHub Examples 41 files Real implementations including rusty-sando (857⭐), advanced MEV bots
Community Discussions 2 files Reddit insights, strategic analyses
πŸ†• Bot Examples 4 bots Production-ready TypeScript bots with full source code

Total: ~25MB of markdown, ~2M+ tokens of comprehensive flash loan and MEV knowledge

πŸ€– NEW: Production-Ready Bot Examples

Four complete, educational TypeScript bots with full source code:

Bot Type Purpose Status
Sandwich Bot MEV Attack Understand sandwich attacks βœ… Complete
Flashloan Arbitrage DeFi Strategy Aave V3 flashloan arbitrage βœ… Complete
Front-Running MEV Detection Detect & analyze front-running βœ… Complete
Back-Running MEV Strategy Event-driven arbitrage βœ… Complete

See bots/README.md for complete bot documentation and architecture diagrams.


πŸš€ Quick Start

For Users: How to Use This with Claude

  1. Open Claude (claude.ai or Claude Code)

  2. Reference documentation using @ syntax:

    @context/INDEX.md
    Help me understand flash loan arbitrage opportunities
    
  3. Load specific topics:

    @context/tutorials/understanding-sandwich-attacks.md
    Explain how sandwich attacks work and how to defend against them
    
  4. Get implementation guidance:

    @context/tutorials/sandwich-bot-typescript-implementation.md
    Help me build a sandwich MEV bot for Arbitrum
    
  5. Analyze strategies:

    @context/discussions/flashloan-vs-mev-analysis.md
    Should I build a flash loan arbitrage bot or MEV sandwich bot?
    

Essential Starting Points

If You Want To... Start Here
Understand basics context/core/techopedia-flash-loan-explained.md
Compare protocols context/core/flash-loan-providers-comparison.md
Learn about MEV attacks context/tutorials/understanding-sandwich-attacks.md
Protect against MEV context/tutorials/preventing-front-running-attacks.md
Build a bot context/tutorials/low-budget-sandwich-bot-roadmap.md
See architecture context/tutorials/ARCHITECTURE.md
Browse everything context/INDEX.md

πŸŽ“ Documentation Structure

flashmillion/
β”œβ”€β”€ README.md                          # This file - start here
β”œβ”€β”€ CLAUDE.md                         # Project instructions for Claude
β”‚
β”œβ”€β”€ context/                          # Main documentation library
β”‚   β”œβ”€β”€ INDEX.md                      # πŸ“– Master catalog of all 76 files
β”‚   β”‚
β”‚   β”œβ”€β”€ core/                         # Protocol documentation (7 files)
β”‚   β”‚   β”œβ”€β”€ aave-flash-loans-documentation.md
β”‚   β”‚   β”œβ”€β”€ flashbots-documentation.md
β”‚   β”‚   β”œβ”€β”€ flash-loan-providers-comparison.md
β”‚   β”‚   └── ...
β”‚   β”‚
β”‚   β”œβ”€β”€ tutorials/                    # Guides & tutorials (21 files)
β”‚   β”‚   β”œβ”€β”€ ARCHITECTURE.md           # Visual system diagrams (Mermaid)
β”‚   β”‚   β”œβ”€β”€ understanding-sandwich-attacks.md (1500+ lines!)
β”‚   β”‚   β”œβ”€β”€ preventing-front-running-attacks.md (850+ lines!)
β”‚   β”‚   β”œβ”€β”€ optimizing-gas-fees.md
β”‚   β”‚   β”œβ”€β”€ programming-languages-for-flash-loans.md
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ πŸ†• low-budget-sandwich-bot-roadmap.md
β”‚   β”‚   β”œβ”€β”€ πŸ†• sandwich-bot-solidity-implementation.md
β”‚   β”‚   β”œβ”€β”€ πŸ†• sandwich-bot-typescript-implementation.md
β”‚   β”‚   β”œβ”€β”€ πŸ†• sandwich-bot-rust-implementation.md
β”‚   β”‚   └── πŸ†• sandwich-bot-python-implementation.md
β”‚   β”‚
β”‚   β”œβ”€β”€ examples/                     # GitHub repo analyses (41 files)
β”‚   β”‚   β”œβ”€β”€ github-mouseless0x-rusty-sando.md (857⭐ sandwich bot)
β”‚   β”‚   β”œβ”€β”€ github-insionCEO-Ethereum-MEV-BOT.md (40⭐ advanced)
β”‚   β”‚   β”œβ”€β”€ github-i3visio-solana-mev-bot.md (1,100⭐ Solana)
β”‚   β”‚   └── ...
β”‚   β”‚
β”‚   └── discussions/                  # Community insights (2 files)
β”‚       β”œβ”€β”€ reddit-flashloan-viability-discussion.md
β”‚       └── flashloan-vs-mev-analysis.md
β”‚
β”œβ”€β”€ πŸ†• bots/                          # Educational MEV bots
β”‚   β”œβ”€β”€ README.md                    # Complete bot documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md              # Visual architecture diagrams
β”‚   β”‚
β”‚   β”œβ”€β”€ sandwich-bot/                # Sandwich attack bot (TypeScript)
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts             # Main bot logic
β”‚   β”‚   β”‚   β”œβ”€β”€ mempoolMonitor.ts    # Mempool transaction detection
β”‚   β”‚   β”‚   β”œβ”€β”€ profitCalculator.ts  # Sandwich profit simulation
β”‚   β”‚   β”‚   └── sandwichExecutor.ts  # Execution engine
β”‚   β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”‚   └── SandwichContract.sol # On-chain sandwich contract
β”‚   β”‚   └── README.md                # Bot documentation
β”‚   β”‚
β”‚   β”œβ”€β”€ aave-flashloan-bot/          # Flashloan arbitrage bot (TypeScript)
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts             # Main bot logic
β”‚   β”‚   β”‚   β”œβ”€β”€ priceScanner.ts      # Multi-DEX price scanning
β”‚   β”‚   β”‚   β”œβ”€β”€ opportunityDetector.ts # Arbitrage detection
β”‚   β”‚   β”‚   └── flashloanExecutor.ts # Aave V3 integration
β”‚   β”‚   β”œβ”€β”€ contracts/
β”‚   β”‚   β”‚   └── FlashloanArbitrage.sol # Flashloan contract
β”‚   β”‚   └── README.md                # Bot documentation
β”‚   β”‚
β”‚   β”œβ”€β”€ aave-frontrun-bot/           # Front-running detection bot (TypeScript)
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ index.ts             # Main bot logic
β”‚   β”‚   β”‚   β”œβ”€β”€ mempoolMonitor.ts    # Aave transaction detection
β”‚   β”‚   β”‚   └── opportunityAnalyzer.ts # Front-run analysis
β”‚   β”‚   └── README.md                # Bot documentation
β”‚   β”‚
β”‚   └── aave-backrun-bot/            # Back-running bot (TypeScript)
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ index.ts             # Main bot logic
β”‚       β”‚   β”œβ”€β”€ eventMonitor.ts      # Aave event monitoring
β”‚       β”‚   └── opportunityDetector.ts # Back-run detection
β”‚       └── README.md                # Bot documentation
β”‚
β”œβ”€β”€ contracts/                        # Shared smart contracts
β”œβ”€β”€ scripts/                          # Deployment scripts
└── test/                            # Test suites

πŸ’‘ Key Features

πŸ†• Complete Implementation Guides (NEW!)

Five production-ready implementations with full source code:

Guide Language/Stack Budget Best For
Roadmap Multi-language $1K-5K Planning & strategy
Solidity + TypeScript Solidity + TS $1K-5K Learning full stack
TypeScript Node.js $1K-5K Fastest start (1-2 weeks)
Rust Rust + Tokio $5K-15K Performance (10-20ms latency)
Python Python Learning Understanding concepts

Each guide includes:

  • βœ… Complete working source code
  • βœ… Smart contracts (where applicable)
  • βœ… Mempool monitoring system
  • βœ… Profitability calculator
  • βœ… Salmonella (honeypot) detection
  • βœ… Deployment instructions
  • βœ… Testing strategies

πŸ“Š Comprehensive Coverage

  • Flash Loan Providers: Aave V3, dYdX, Uniswap V2/V3, Balancer
  • MEV Attacks: Sandwich, front-running, back-running, displacement
  • MEV Defenses: Flashbots Protect, CoW Swap, private RPCs, slippage settings
  • Programming Languages: Solidity, TypeScript, Rust, Python, Huff, Vyper
  • Networks: Ethereum, Arbitrum, Optimism, Base, Polygon, Sui, Solana
  • Real Examples: 41 GitHub repositories analyzed (includes rusty-sando, advanced MEV bots)

🎯 Realistic Assessments

Unlike promotional content, this repository provides:

  • Honest profitability assessments (most MEV bots lose money)
  • Realistic competition analysis (professional bots dominate)
  • Actual cost breakdowns ($1K-5K for L2, $10K-50K for mainnet)
  • Ethical considerations (sandwich attacks harm users)
  • Legal warnings (MEV may be regulated)

🀝 Contributing

We welcome contributions! This is a living knowledge base that improves with community input.

How to Contribute

  1. Add New Documentation

    • Found a new tutorial? Add it to context/tutorials/
    • Discovered a new MEV bot repo? Document it in context/examples/
    • Have insights? Share in context/discussions/
  2. Update Existing Content

    • Fix outdated information
    • Add missing details
    • Improve clarity
  3. Share Implementation Experience

    • Document your bot implementation
    • Share lessons learned
    • Report actual results (anonymized)

Contribution Guidelines

File Format:

**Source:** [URL or "Internal analysis"]
**Date:** [Month Year]

# Title

Content here...

File Naming:

  • source-topic-description.md (e.g., github-username-repo-name.md)
  • Use lowercase and hyphens
  • Be descriptive but concise

File Placement:

  • context/core/ - Official protocol documentation
  • context/tutorials/ - How-to guides, strategies, implementations
  • context/examples/ - GitHub repository analyses
  • context/discussions/ - Community insights, analyses

Pull Request Process:

  1. Fork this repository
  2. Create a new branch (git checkout -b add-new-guide)
  3. Add your documentation file(s)
  4. Update context/INDEX.md with your new file
  5. Submit a pull request with clear description

What We're Looking For:

  • βœ… Up-to-date information (2024-2025 content preferred)
  • βœ… Accurate technical details
  • βœ… Real-world examples and data
  • βœ… Honest assessments (not promotional)
  • βœ… Clear explanations
  • βœ… Proper attribution/sources

What to Avoid:

  • ❌ Promotional content or scams
  • ❌ Outdated information (pre-2023 unless historically relevant)
  • ❌ Unrealistic profit claims
  • ❌ Incomplete or untested code
  • ❌ Plagiarized content

Ways to Contribute

Type Examples
Documentation New tutorials, protocol updates, best practices
Implementation Your bot code, deployment guides, optimizations
Analysis Profitability studies, competitive analysis, market trends
Research Academic papers, MEV research, algorithm analysis
Community Reddit discussions, Discord insights, Twitter threads
Tools Testing frameworks, simulation tools, monitoring scripts

πŸ“– Using This Repository

For Learning

  1. Start with fundamentals:

    • Read context/core/ files to understand protocols
    • Study context/tutorials/understanding-sandwich-attacks.md (essential!)
    • Review context/discussions/ for realistic expectations
  2. Progress to implementation:

    • Choose your language (see context/tutorials/programming-languages-for-flash-loans.md)
    • Follow relevant implementation guide
    • Test on testnets first
  3. Study real examples:

    • Analyze professional bots in context/examples/
    • Understand what makes them successful
    • Learn from their architecture

For Research

  1. Load relevant context into Claude:

    @context/core/aave-flash-loans-documentation.md
    @context/tutorials/understanding-sandwich-attacks.md
    @context/examples/github-mouseless0x-rusty-sando.md
    
    Help me research MEV sandwich attack profitability in 2025
    
  2. Analyze strategies:

    @context/discussions/flashloan-vs-mev-analysis.md
    
    Compare flash loan arbitrage vs MEV attacks - which is more viable?
    
  3. Explore implementations:

    @context/tutorials/sandwich-bot-rust-implementation.md
    
    Explain the high-performance Rust MEV bot architecture
    

For Development

  1. Plan your bot:

    @context/tutorials/low-budget-sandwich-bot-roadmap.md
    
    Help me plan a $3K budget MEV bot for Arbitrum
    
  2. Get implementation help:

    @context/tutorials/sandwich-bot-typescript-implementation.md
    
    Walk me through building this bot step by step
    
  3. Optimize performance:

    @context/tutorials/optimizing-gas-fees.md
    @context/tutorials/importance-of-speed-in-arbitrage.md
    
    How do I optimize my bot for sub-50ms latency?
    

For Strategy Decisions

  1. Assess viability:

    @context/discussions/reddit-flashloan-viability-discussion.md
    @context/discussions/flashloan-vs-mev-analysis.md
    
    Is building a MEV bot worth it in 2025?
    
  2. Choose technology stack:

    @context/tutorials/programming-languages-for-flash-loans.md
    
    Should I use TypeScript or Rust for my MEV bot?
    
  3. Evaluate risks:

    @context/tutorials/preventing-front-running-attacks.md
    @context/tutorials/preventing-sandwich-attacks.md
    
    What are the main risks and how do I protect myself?
    

⚠️ Important Disclaimers

Legal & Ethical Warnings

This repository is for EDUCATIONAL PURPOSES ONLY.

  • ⚠️ Legal Risk: MEV extraction may be considered market manipulation in some jurisdictions
  • ⚠️ Ethical Concerns: Sandwich attacks directly harm other users
  • ⚠️ Financial Risk: Most MEV bots lose money - budget for losses
  • ⚠️ Security Risk: Smart contracts handling funds must be audited
  • ⚠️ Regulatory Risk: MEV is increasingly scrutinized by regulators

Before deploying any MEV bot:

  1. Consult legal counsel in your jurisdiction
  2. Understand the ethical implications
  3. Budget for complete capital loss
  4. Test extensively on testnets
  5. Never commit private keys to repositories
  6. Get professional security audits

Realistic Expectations

Based on analysis of 76 documentation files:

Reality Details
High Competition Sub-5ms detection required for mainnet success
Low Success Rate 5-15% of attempts succeed (even with optimization)
Thin Margins Many opportunities yield <$50 profit after gas
High Costs $1K-5K for L2, $10K-50K for mainnet, plus monthly operating costs
Steep Learning Curve Requires advanced blockchain, DeFi, and MEV knowledge
Constant Optimization Arms race requires continuous improvement

Most Likely Outcome: Educational experience, break-even or small loss

Success Probability: 5-10% for newcomers


🌟 Highlights

Most Valuable Files

Must-Read Before Building:

  1. understanding-sandwich-attacks.md - 1500+ lines, comprehensive
  2. preventing-front-running-attacks.md - 850+ lines, essential defenses
  3. flashloan-vs-mev-analysis.md - Realistic 2025 assessment

Best Implementation Guides:

Real-World Examples:


πŸ“Š Repository Statistics

  • Total Files: 76 markdown documents
  • Total Content: ~25 MB (~2M+ tokens)
  • Coverage: Ethereum, Arbitrum, Optimism, Base, Polygon, Sui, Solana
  • Languages: Solidity, TypeScript, Rust, Python, Huff, Vyper, Move
  • GitHub Examples: 41 repositories (800+ to 10 stars)
  • Last Updated: November 2025
  • Maintenance: Active (contributions welcome!)

πŸ”— Related Resources

Official Documentation

Community

Tools


πŸ“ž Support & Questions

Have questions? Use this repository with Claude:

@context/INDEX.md

I want to [your goal here], where should I start?

Found an issue? Open a GitHub issue or submit a pull request.

Want to discuss? Join Flashbots Discord or r/defi on Reddit.


πŸ“œ License

This repository contains documentation and educational content from various sources:

  • Original content (implementation guides, analyses): MIT License
  • Curated documentation: See individual file headers for source attribution
  • Code examples: See respective licenses in source repositories

When contributing: Ensure you have rights to share the content and provide proper attribution.


πŸ™ Acknowledgments

This knowledge base compiles information from:

  • Official protocol documentation (Aave, Flashbots, Uniswap)
  • 41 open-source GitHub repositories
  • Community discussions (Reddit, Discord)
  • Professional guides (Solulab, TAS, Sahm Capital)
  • Academic research and MEV studies

Special thanks to:

  • rusty-sando (857⭐) - Excellent MEV bot reference
  • Ethereum-MEV-BOT (40⭐) - Advanced implementation
  • The Flashbots team for MEV research and tools
  • The DeFi community for open-source contributions

πŸš€ Get Started

  1. Browse the documentation: Start with context/INDEX.md
  2. Choose your path:
  3. Use with Claude: Reference files using @path/to/file.md syntax
  4. Contribute: Submit PRs to improve the knowledge base

Flash Million - Comprehensive Flash Loan & MEV Knowledge Base

Documentation β€’ Implementation Guides β€’ Architecture β€’ Contribute

Made with πŸ“š for in-depth Claude discussions about DeFi, MEV, and flash loans

About

Flash Loan & MEV Knowledge Base for Claude Discussions

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •