Add MEV-Share backrunner example (closes #38)#78
Conversation
examples/08_mev_share_backrunner.zig: a heavily-commented teaching bot that subscribes to the MEV-Share SSE hint stream, matches pending-tx hints against a comptime-built table of Uniswap V2/V3 swap selectors, and composes a backrun bundle (user tx hash + our signed EIP-1559 tx) submitted via mev_sendBundle. DRY_RUN=1 default prints the bundle JSON instead of submitting; all config via env vars with Sepolia defaults. Showcases: comptime selector dispatch, the mev_share client + SSE stream, EIP-1559 construction/signing/serialization, and bundle composition. Dog-fooding this first consumer of mev_share surfaced and fixed two latent Zig 0.16 breakages in sse_transport.SseParser.feedLine (std.mem.trimRight renamed to trimEnd; mismatched anonymous-struct types) -- the on() stream path was uncompilable for any consumer and is not exercised by unit tests. Verified by streaming live mainnet MEV-Share events.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
📝 WalkthroughWalkthroughThis PR introduces a complete MEV-Share backrunner example that demonstrates subscribing to the Flashbots MEV-Share pending-transaction stream, matching hints against compile-time Uniswap swap selectors, and submitting backrun bundles. The change includes a critical fix to the SSE parser and comprehensive documentation. ChangesMEV-Share Backrunner Bot and Tooling
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
What
examples/08_mev_share_backrunner.zig— a teaching MEV-Share backrunner that ties together the new MEV stack: comptime-built Uniswap V2/V3 swap-selector table, themev_shareSSE hint stream, EIP-1559 backrun construction/signing, andmev_sendBundlebundle composition.DRY_RUN=1default (prints the bundle JSON instead of submitting); env-var config with Sepolia defaults.It works against the live network
Run against the mainnet stream, it matched hash-only and bundle hints in real time and printed the bundle it would submit. Sample:
Bug fixes from dog-fooding (first consumer of mev_share)
MevShareClient.onwas uncompilable for any consumer:sse_transport.SseParser.feedLineusedstd.mem.trimRight(renamedtrimEndin Zig 0.16) and built two anonymous structs with mismatched inferred types. Neither surfaced in CI becausefeedLineis only reached via the network path, not unit tests. Fixed both insrc/sse_transport.zig;zig build teststill passes. (TherefAllDeclsRecursivetest added in #63 covers mev_share itself but not sse_transport — I'll file a follow-up to extend that guard.)Also
README +
docs/content/docs/examples.mdxentries; CHANGELOG Added/Fixed bullets.Verification
examples build, root
zig build test,zig fmt --check, andpnpm -C docs buildall pass on Zig 0.16.0.Closes #38
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Documentation