Expand description
Notifications from replacementSubscribe: one reroute result per original swap. Nothing stands
in for the original; the original kind is the original itself.
Each notification is a ReplacementNotification, tagged by kind:
requote: the transaction re-quoted through the router (RequoteNotification).directFill: one hop rerouted directly to a venue through your template, a venue probe (VenueNotification).original: the original swap replayed as the baseline (OriginalNotification).
Every kind flattens ReplacementCore and L1Score into its top level; the kinds that
simulate a whole transaction also flatten SimCost.
Wire keys are the camelCase of the field names (batch_index is batchIndex), except
ReplacementCore::error, which is err. Units:
- Token amounts are raw base units of their mint, with no decimals applied.
feeis in lamports.- Changes are in basis points (bps): 1 bps = 0.01%.
swapModeisExactInorExactOut.blockTimeis a Unix timestamp in seconds.
Structs§
- Change
Bps - A recorded change, and whether
CHANGE_CLAMP_BPSis what bounded it. - L1Score
- What the original swap filled, and how the stand-in scored against it. Flattened into the
notification’s top level.
l1in a name means the original (onchain) swap. - Original
Notification - The original swap replayed as the baseline (
kind: "original"): the historical transaction re-run against the state it was quoted at, so the other kinds can be scored against a number produced the same way rather than against the chain’s. - Probed
Hop - The hop a venue probe re-priced, as the original swap ran it onchain and as the replay ran it.
- Replacement
Context - The slot the payload was produced at, in the shape every other subscription’s context takes.
- Replacement
Core - The identity and outcome every notification carries, whatever its kind. Flattened into the notification’s top level.
- Requote
Notification - A transaction rerouted through the router (
kind: "requote"): the original swap’s transaction re-quoted and simulated. The original still executed onchain; this result is never committed. - Reroute
LegNotification - One swap of a transaction rerouted through the router.
- Signature
- A 64-byte Ed25519 signature.
- SimCost
- What simulating the stand-in cost. Flattened into the notification’s top level.
- Venue
Notification - A venue probe (
kind: "directFill"): one hop rerouted directly to a venue through your template, simulated against the state it would have traded on.
Enums§
- Replacement
Notification - One reroute result for an original swap, streamed over
replacementSubscribe: through the router, directly to a venue, or the original swap replayed as the baseline. Nothing stands in for the original. Tagged bykind, with the variant’s fields at the top level beside it.
Constants§
- BPS_
SCALE - Basis points per whole unit.
- CHANGE_
CLAMP_ BPS - The bound on one swap’s recorded change: ±100,000 bps (±1,000%). Losses stop at −10,000 bps (−100%) on their own, so only gains reach it.
Functions§
- clamped_
change_ bps - Change from
basetonewin bps,(new - base) * 10_000 / base, clamped to ±CHANGE_CLAMP_BPS.