Skip to main content

Module replacement

Module replacement 

Source
Expand description

The parts of a replacementSubscribe payload that every kind carries.

Three mechanisms stand in for a historical swap — metis re-routing a whole transaction, a probe re-pricing one hop, the original replayed as its own baseline — and they carry different shapes. What they share is declared once here and flattened into each shape on both sides of the wire, so a field the server emits cannot be silently dropped by a client that forgot to restate it.

Structs§

ChangeBps
A recorded change, and whether CHANGE_CLAMP_BPS is what bounded it.
DirectFillNotification
One direct-fill probe’s result - the DirectFill shape of ReplacementNotification: a single hop re-priced through a direct-fill template, simulated against the state it would have traded on.
L1Score
What the original filled on L1, and how the shape carrying this scored against it.
OriginalNotification
One replayed original - the Original shape of ReplacementNotification: the historical transaction itself, re-run against the state it was quoted at, so the other two kinds are scored against a number produced the same way rather than against the chain’s.
ReplacementContext
The slot the payload was produced at, in the shape every other subscription’s context takes.
ReplacementCore
The identity and ending every replacement payload carries, whatever kind it is.
RequoteNotification
One rerouted transaction’s simulation result - the Requote shape of ReplacementNotification. The historical original still executed; this is the counterfactual, committed nowhere.
RerouteLegNotification
One re-quoted swap within a rerouted transaction’s simulation.
Signature
A 64-byte Ed25519 signature.
SimCost
What running one stand-in cost, for the kinds that simulate a whole transaction.

Enums§

ReplacementNotification
What stood in for a historical swap, streamed over replacementSubscribe. Internally tagged on kind: three mechanisms answer different questions - metis re-routing a whole transaction, a probe re-pricing one hop, and the original replayed as its own baseline - so they carry different shapes rather than one union.

Constants§

BPS_SCALE
Basis points per whole unit.
CHANGE_CLAMP_BPS
Clamp bound for a single swap’s recorded change, ±1,000% of the base. Losses bound themselves at −100%, so only gains ever reach this; wide enough that no economically real improvement truncates (the old ±100% cap flattened every gain past 2×), tight enough that one dust-base ratio moves a 10k-leg aggregate mean by at most ~10 bps.

Functions§

clamped_change_bps
Change from base to new in bps, clamped to ±CHANGE_CLAMP_BPS. Callers guard base > 0.