Expand description
Standalone subscriptions to a session’s RPC endpoint.
Each subscribe_* function opens its own WebSocket to the session’s RPC endpoint
(SessionInfo::rpc_endpoint), runs your callback
once per notification on a background task, and returns a handle.
- These functions never reconnect. If the server closes the socket, the handle’s
shutdownreturnsSubscriptionRuntimeError::Closedand the notifications after the close are lost. On aManagedBacktestSession, prefer itssubscribe_*methods, which reconnect and deliver results asManagedEvents. - Subscribe before you continue the session, or you miss the notifications sent before the subscription was confirmed.
- Always finish with
handle.shutdown().await?, before you close the session. Dropping a handle does not stop its task.
Per-account diffs (subscribe_account_diffs, subscribe_account_diffs_many) and program
logs (subscribe_program_logs) are only available here.
Structs§
- Account
Diff Context - Slot context included in every account diff notification.
- Account
Diff Notification - A single account diff notification delivered by
accountDiffSubscribe. - Account
Diff Subscription Handle - Handle for a running account diff or program diff subscription.
- Action
Result Context - Slot context included in every action result.
- Action
Result Notification - One scheduled-action result delivered by
actionSubscribe. - Action
Subscription Handle - Handle for a running
subscribe_actionssubscription. - Action
Transaction Outcome - One transaction’s result within a scheduled action’s sequence.
- Diagnostic
Context - Slot context included in every diagnostic sample.
- Diagnostic
Notification - One market’s
/diagnosticsample at one size, delivered bydiagnosticSubscribe: the router’s own pricing, not a fill the venue produced. - Diagnostic
Subscription Handle - Handle for a running
subscribe_diagnosticssubscription. - 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. - LogSubscription
Handle - Handle for a running
subscribe_program_logssubscription. - 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.
- Routed
Account Diff Notification - An account diff from
subscribe_account_diffs_many, tagged with the subscribed account that produced it. - Subscription
Handle - Handle for a running subscription; every typed handle converts into it with
From. - 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. - Subscription
Error - Error starting a subscription. Returned by the
subscribe_*functions before any notification is delivered; no background task is left running. - Subscription
Runtime Error - Error from a running subscription, returned by the handle’s
shutdown. - UiAccount
Conversion Error - Error decoding a serialized
UiAccountinto the wireAccountDatashape.
Functions§
- account_
data_ from_ ui - Decode a serde-serialized
UiAccount(thepre/postpayload shape) into the wireAccountDatashape. Only base64 data is supported;spacefalls back to the decoded data length when absent. - subscribe_
account_ diffs - Subscribe to the changes of one account.
- subscribe_
account_ diffs_ many - Subscribe to the changes of many accounts over one WebSocket.
- subscribe_
actions - Subscribe to the results of the session’s scheduled actions.
- subscribe_
diagnostics - Subscribe to the session’s
/diagnosticsamples. - subscribe_
program_ diffs - Subscribe to the changes of every account a program owns.
- subscribe_
program_ logs - Subscribe to the logs of every transaction that mentions
program_id. - subscribe_
replacements - Subscribe to the session’s reroute results.