finds.dev← search

// the find

libevm/subway

★ 2,204 · Solidity · MIT · updated Aug 2023

A practical example on how to perform sandwich attacks on Ethereum

An educational reference implementation for sandwiching UniswapV2 swaps: Solidity/Yul+ contracts for the sandwich execution plus a JavaScript bot that reads the mempool, decodes swaps, and fires bundles. It's for developers trying to understand MEV mechanics end-to-end, not for anyone looking to actually run this in production.

Covers the full pipeline rather than just the contract — mempool decoding, profit calculation, gas bribe math, and bundle submission are all there, which is rare for MEV example repos that usually just show the Solidity half. The Yul+ contract keeps the hot path (swap + transfer) minimal, so it's a decent read for anyone learning gas-sensitive low-level Solidity. The README is upfront about what's missing instead of overselling the bot's sophistication.

No uncle bandit protection, by the author's own admission, so running this as-is would get the bot's profit stolen by anyone watching the same mempool. The bot side has zero tests — only the contract has a Foundry test. Last push was August 2023, and mempool-based sandwiching on mainnet has largely moved to private order flow (Flashbots Protect, MEV-Share) since then, so the bot's core assumption — that profitable targets are visible in the public mempool — is increasingly stale. No poison token checks or circuit breakers, which the README flags, but those aren't nice-to-haves, they're most of what separates a toy from something that survives contact with real liquidity.

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 →