feat: Add oracle reroute example - #12
Open
petarvujovic98 wants to merge 1 commit into
Open
Conversation
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
petarvujovic98
force-pushed
the
08-04-feat_add_oracle_reroute_example
branch
from
August 5, 2026 11:25
57a4be3 to
8a43e48
Compare
petarvujovic98
force-pushed
the
08-04-feat_add_oracle_reroute_example
branch
from
August 5, 2026 14:39
8a43e48 to
5dee162
Compare
petarvujovic98
marked this pull request as ready for review
August 5, 2026 14:39
petarvujovic98
force-pushed
the
08-04-feat_add_oracle_reroute_example
branch
from
August 5, 2026 16:04
5dee162 to
62fdc28
Compare
petarvujovic98
commented
Aug 5, 2026
Comment on lines
+17
to
+18
| simulator-api = { git = "https://github.com/nitro-svm/nitro-stream", rev = "f49c4f11bf18a4648ac39ef61ed220572fb3e53f" } | ||
| simulator-client = { git = "https://github.com/nitro-svm/nitro-stream", rev = "f49c4f11bf18a4648ac39ef61ed220572fb3e53f" } |
Author
There was a problem hiding this comment.
This will have to be updated to the client/api version that gets published after the nitro-stream PRs land
Yiwen-Gao
reviewed
Aug 6, 2026
Yiwen-Gao
reviewed
Aug 6, 2026
petarvujovic98
force-pushed
the
08-04-feat_add_oracle_reroute_example
branch
4 times, most recently
from
August 6, 2026 14:33
7337e1e to
b5956d6
Compare
petarvujovic98
force-pushed
the
08-04-feat_add_oracle_reroute_example
branch
from
August 7, 2026 12:16
b5956d6 to
1b1fa6c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

TL;DR
Upgrades
simulator-apiandsimulator-clientto v0.17.0 from the git source and rewrites thecounterfactual_flowexample to use account overrides with a time-shifted schedule instead of a discovery-based program upgrade hook.What changed?
simulator-apiandsimulator-clientare now pulled from thenitro-streamgit repository at a pinned revision rather than from crates.io. The new versions addspl-token-2022-interface,spl-token-interface,thiserror,uuid,solana-account-decoder, andsolana-sdk-idsas dependencies, and pull intonic,axum,hyper-timeout,matchit,pin-project,httpdate, anduuidtransitively.The
counterfactual_flowexample is substantially reworked:Upgradeevents and injected a replacement transaction. That discovery-based flow, along withdiscovery.rs, is removed.--lag Kposts the state from slots-Kat slots, pricing the cost of staleness, while--lead Kposts a future state — with caveats for venues that stamp their own last-update slot into the account.capturerecords the account's per-slot states to JSONL viasubscribe_account_diffs,runexecutes one session with optional overrides, andcompareruns an unmodified baseline alongside the modified world and produces a per-leg delta report with median, mean, and p90 bps statistics.--filter-mintand--filter-poolflags scope which swaps are requoted.--program-idis now optional and resolves the venue's Metis route label only when provided.ManagedBacktestSessionreplaces the manualBacktestClientsession loop.ConnectionArgscentralises URL handling, resolving bare hostnames towss://and inferringhttp/httpsfor the RPC endpoint based on the websocket scheme.session_id()call sites inquote_compareandregression_testare updated to usemap_or_elsesince the return type changed.build_shift_actions(positive and negative shifts, empty capture),delta_bps(signed scaling, zero-baseline, sub-bps precision),join_legs(key matching, zero-baseline exclusion),delta_summary(percentile correctness), andConnectionArgsURL construction.Documentation in both READMEs is updated to reflect the new methodology, a worked result over a SOL/USDC prop-AMM pool showing a 99.6% fill-rate collapse at four seconds of staleness, and guidance on Metis quoting non-determinism and the minimum replicate count needed to avoid false positives.
How to test?
Run the unit tests with
cargo test --bin counterfactual_flow.Why make this change?
The discovery-based approach required a real program upgrade event in the replayed range and only allowed injecting a replacement transaction at that moment, making it impractical for testing arbitrary parameter changes. Account overrides are more general: any account the venue reads — oracle, curve, fee config — can be rewritten per slot using real, well-formed historical states on a shifted schedule. This directly quantifies the value of latency improvements and the cost of staleness without needing to construct synthetic account data or wait for an upgrade event.