feat: serve the underlying stock price on PriceFrame and Quote (v0.7.0, RAI-2197) - #4
Open
hardyjosh wants to merge 1 commit into
Open
feat: serve the underlying stock price on PriceFrame and Quote (v0.7.0, RAI-2197)#4hardyjosh wants to merge 1 commit into
hardyjosh wants to merge 1 commit into
Conversation
ueco-jb
reviewed
Sep 3, 2026
| @@ -1,2 +1,3 @@ | |||
| /target | |||
| Cargo.lock | |||
| /.pre-commit-config.yaml | |||
There was a problem hiding this comment.
nit: unrelated to the wire change, and this ignore silently blocks committing a shared config here later. Possibly worth dropping.
ueco-jb
approved these changes
Sep 3, 2026
ueco-jb
left a comment
There was a problem hiding this comment.
One optional nit comment posted, otherwise LGTM 👍
…0, RAI-2197) Add underlying_rate_base_to_quote / underlying_rate_quote_to_base to PriceFrame and Quote: the directional rates for the vault's underlying ERC4626 asset (the offchain stock). Defined as the served vault rate un-scaled by the NAV ratio, so consumers can derive the vault price atomically as underlying * live convertToAssets(1 share) and reproduce the SERVED vault rate rather than trusting a signed vault rate, which removes the exact-match NAV gate as a DoS surface. Because the underlying is derived from the served vault rate it is clamp-consistent: when the model's no-cross guard clamps the vault rate, the underlying reflects the clamped rate, so deriving from it cannot reconstruct an unclamped, self-crossing quote. Field docs and wire-format.md state the contract, including that decimal-float division is not a bit-exact inverse of multiplication (derive reproduces the served rate to Float precision). Additive and wire-backward-compatible: both fields carry #[serde(default)] so frames from producers that predate them decode to the all-zero Float. Existing vault rates and nav_ratio are untouched. Wire-contract version bumped 0.6.0 -> 0.7.0. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TQ3QV1QrwmaS7ACSf7cds7
hardyjosh
force-pushed
the
feat/underlying-price
branch
from
September 4, 2026 13:26
7794ed4 to
8bcfd87
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.
What
Adds the underlying (stock) directional price to
PriceFrameandQuote, alongside the existing vault-token rates andnav_ratio:underlying_rate_base_to_quote: WireFloatunderlying_rate_quote_to_base: WireFloatThese are the directional rates for the vault's underlying ERC4626 asset (the offchain stock) — the same rates the model computes before scaling the mark by the vault NAV ratio. Same directionality and spread policy as
rate_base_to_quote/rate_quote_to_base; the only difference is the NAV scaling.Why (RAI-2197 / RAI-1479)
Root of the NAV-ratio "derive, don't gate" pivot. The exact-match NAV gate was found to be a DoS surface (audit H03). Serving the underlying lets on-chain consumers derive the vault price atomically (
vault_price = underlying × convertToAssets(1 share)) instead of asserting a signed ratio. As Josh put it: serve both and let consumers derive if they like.Compatibility
#[serde(default)], so frames from producers that predate them decode to the all-zeroWireFloat. A real stock rate is never all-zero, so that value reads as "not carried".nav_ratioare untouched.base(nav_ratiozero):underlying_rate_* == rate_*(no separate underlying).Version bump + re-pin
Wire-contract version bumped v0.6.0 → v0.7.0. Following the repo's post-merge tag convention, the merge commit gets tagged
v0.7.0and consumers re-pin theirtag = "v0.6.0"totag = "v0.7.0". The companion st0x.pricing PR pins this branch rev meanwhile and carries a Cargo.toml comment noting the re-pin step.Tests
Local gate:
cargo test,cargo clippy --all-targets -D warnings,cargo fmt --check, and the fullpre-commit run --all-filesinrainix#rust-shell(incl. denofmt markdown) all pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01TQ3QV1QrwmaS7ACSf7cds7
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.