[4.2] Pyth Oracle Integration (on-chain) — 0xfave - #66
Merged
Conversation
- Dynamic Pyth V2 price offset (48 + num x 96) - works on real feeds - Optional oracle in MatchOrdersAccounts - backward-compatible - Oracle price + timestamp cached to Market account - PMM effective price with clamped inventory skew [-100%%, +100%%] - 3 integration tests + 9 unit tests for oracle validation - Zero new crate deps, zero [patch] sections, zero clippy warnings
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.
Summary
Implements Ticket 4.2 — Pyth Oracle Integration for the FluxDEX on-chain program. Zero new crate dependencies, zero
[patch]sections, zero clippy warnings.What changed
New file:
src/oracle.rs(457 lines)HEADER_SIZE + num × COMP_SIZE) — works on real feeds with 25+ publishersModified:
src/instruction.rsMatchOrdersAccountsgains optionaloracle_price: Option<&AccountView>(8th account)Modified:
src/processor.rsmatch_orders()validates oracle (confidence ≤ 5%, staleness ≤ 60 s), cachesoracle_price+oracle_timestampto Market accountModified:
tests/flux_dex_tests.rsmatch_orders_ix_with_oracle()— helper with optional 8th oracle accountsetup_pyth_oracle()— builds a correctly formed mock Pyth V2 price accountKey design decisions
MatchOrdersAccountsPlaceOrderVerification
cargo test-sbf: 119 tests pass (44 unit + 75 integration)cargo clippy -- -D warnings: 0 warnings (only pre-existing edition2024 feature notice)cargo build-sbf: clean buildCloses #33