-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Motivation
MEV-Share is Flashbots' orderflow auction protocol — the primary mechanism for searchers to backrun private transactions on Ethereum today. The TypeScript reference client (mev-share-client-ts) is the only official SDK. A Zig client would be the fastest implementation and give eth.zig a concrete position in the active MEV ecosystem.
What MEV-Share enables
- Private transaction backrunning: Subscribe to a stream of pending tx hints, backrun profitable ones
- Bundle composition: Compose backrun bundles targeting specific pending txs
- MEV profit sharing: A portion of searcher profit flows back to the user who originated the tx
API surface (mirrors mev-share-client-ts)
New file: src/mev_share.zig
pub const MevShareClient = struct {
/// Subscribe to the MEV-Share event stream (SSE).
/// Calls callback for each pending transaction or bundle event.
pub fn on(
self: *MevShareClient,
allocator: std.mem.Allocator,
callback: *const fn (event: PendingEvent) void,
) !void
/// Submit a private transaction with MEV hints.
/// Maps to eth_sendPrivateTransaction.
pub fn sendTransaction(
self: *MevShareClient,
allocator: std.mem.Allocator,
signed_tx: []const u8,
opts: SendTransactionOpts,
) ![32]u8 // tx hash
/// Simulate a MEV-Share bundle (mev_simBundle).
pub fn simulateBundle(
self: *MevShareClient,
allocator: std.mem.Allocator,
opts: flashbots.MevSendBundleOpts,
sim_opts: SimBundleOpts,
) !SimBundleResult
/// Fetch historical event stream data.
pub fn getEventHistory(
self: *MevShareClient,
allocator: std.mem.Allocator,
params: EventHistoryParams,
) ![]EventHistoryEntry
};Key types needed
/// A pending transaction or bundle from the event stream.
pub const PendingEvent = union(enum) {
transaction: PendingTransaction,
bundle: PendingBundle,
};
pub const PendingTransaction = struct {
hash: [32]u8,
logs: ?[]Log,
calldata: ?[]u8,
function_selector: ?[4]u8,
contract_address: ?[20]u8,
to: ?[20]u8,
value: ?u256,
};
pub const PendingBundle = struct {
hash: [32]u8,
txs: []PendingTransaction,
};Implementation notes
- Transport: Depends on
sse_transport.zig(see SSE transport for MEV-Share event streaming #33) for event streaming; uses existinghttp_transport.zigfor JSON-RPC calls - Auth: Reuse
flashbots.zigauth header signing (X-Flashbots-Signature) - Networks: Mainnet endpoint
https://mev-share.flashbots.net; Sepoliahttps://mev-share-goerli.flashbots.net - mev_sendBundle is already implemented in
flashbots.zig— no duplication needed
Relationship to examples
Once this exists, an example backrunner bot (examples/08_mev_share_backrunner.zig) becomes straightforward.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request