finds.dev← search

// the find

pedrobergamini/flashloaner-contract

★ 545 · Solidity · updated Dec 2025

This repo introduces a simple example of how to arbitrage trade on-chain using flash loans.

A Foundry-based flash loan arbitrage example that wires up Uniswap V2's uniswapV2Call callback to execute a swap on a second AMM and pocket the spread. It's a teaching tool, not production code — the kind of thing you read to understand how flash swaps work mechanically before building something real. Target audience is Solidity developers new to DeFi primitives.

Foundry-only toolchain is the right call — no Hardhat baggage, fast fuzz tests, and forge script for deployment simulation all in one place. Fuzz tests that sweep reserve balances and borrow sizes actually catch edge cases that a fixed-value test suite would miss. Custom errors and structured events are a meaningful improvement over the bare-bones examples this repo replaces. QuoteRepayment script is a practical addition — querying live reserves before committing to a transaction is exactly the workflow you'd use in practice.

Hardcoded to Uniswap V2; V3 flash loans work differently and V2 liquidity is thin on most chains now, so this has limited practical value unless you're targeting a chain where V2 forks still dominate. No slippage protection or profitability check before executing the second swap — in a real deployment, price movement between quoting and execution would eat your profit or cause a revert. Only tests one AMM hop; real arbitrage routes often chain three or more swaps, and the contract structure doesn't generalize cleanly to that. The README frames this as a 'modernized' example but there's no discussion of MEV or the reality that any profitable opportunity visible on a public mempool gets frontrun by bots within the same block.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →