Update Base DIA oracle to equity feeds#2
Conversation
Point LibDia at the new oracle contract, use 18-decimal prices and ticker keys (AMZN, NVDA, etc.), refresh fork tests and docs, and add a Basescan verification helper script.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (8)
WalkthroughThis PR updates the DIA oracle integration to use 18-decimal price precision instead of 8, migrates test coverage from BTC/USD to AMZN and other equity symbols, and establishes portable pre-commit hook configuration. Core constants and documentation are updated consistently, with test infrastructure and coverage restructured to support the new asset class and decimal scale. ChangesDIA Oracle Decimal Precision and Asset Symbol Update
Pre-commit Hook Configuration
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Oracle verification is out of scope for this repository.
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.pre-commit-config.yaml:
- Line 1: The .pre-commit-config.yaml is a symlink to a Nix store file which
breaks for non-Nix contributors; either replace the symlink with a portable YAML
config named .pre-commit-config.yaml (a committed static config) or add
documentation to README.md explaining the Nix-based pre-commit setup (describe
flake.nix devShell -> rainix -> pre-commit hooks and steps to enable them).
Update the repo by committing the static YAML or by adding a short "Pre-commit /
Nix" section to README.md with exact commands to enter the dev shell and
install/run pre-commit so cloned repos work for non-Nix users.
In `@script/verify-dia-oracle-base.sh`:
- Around line 18-21: The script currently only validates ETHERSCAN_API_KEY; add
a fail-fast check for required executables by verifying that git, forge, cast,
and npm are available (use command -v or which) and if any are missing print a
clear error to stderr and exit 1. Place this check near the existing
ETHERSCAN_API_KEY validation so missing tools are detected early; reference the
ETHERSCAN_API_KEY check location and ensure the error messages name the missing
executable(s) and use a non-zero exit code.
- Around line 16-27: The script currently allows SPECTRA_REF to default to
"main" (SPECTRA_REF) and skips updating an existing clone (SPECTRA_REPO), which
makes verification nondeterministic; change the logic to require an explicit,
immutable ref (reject empty or "main") or validate SPECTRA_REF looks like a
commit SHA, and when SPECTRA_REPO exists always perform a deterministic sync:
run a git fetch on SPECTRA_REPO and then checkout/reset to the exact SPECTRA_REF
(use git fetch origin && git checkout --force SPECTRA_REF && git reset --hard
origin/SPECTRA_REF or equivalent) so verification always uses the pinned
revision rather than stale repo state. Ensure these steps reference SPECTRA_REF
and SPECTRA_REPO and error out if checkout/reset fails.
In `@src/lib/dia/LibDia.sol`:
- Line 22: Confirm and validate the DIA oracle address used in LibDia.sol: the
constant ORACLE_BASE (typed as IDIAOracleV2) must be verified against official
DIA channels or replaced with a configurable/constructor-injected address so
deployments use an authenticated mainnet address; update ORACLE_BASE only after
confirming the correct address from DIA documentation or governance, and
consider adding a clear comment referencing the source of the verified address
and/or switching IDIAOracleV2 ORACLE_BASE to a constructor/setter-backed value
to avoid hardcoding an unverified address.
In `@test/lib/LibFork.sol`:
- Around line 7-9: Update the block comment in LibFork.sol that currently says
"Tests use vm.warp to set block.timestamp close to the DIA update time" to
instead state that the fork block already has an appropriate timestamp for DIA
staleness checks and that vm.warp is no longer used; locate the comment near the
top of the file (the block starting with "A recent Base block. DIA oracle has
AMZN data...") and replace the vm.warp reference with a brief note that the fork
timestamp suffices for tests.
In `@test/src/lib/dia/LibDia.t.sol`:
- Around line 76-94: Add inline comments above the hardcoded-price tests
(functions testGetPriceAmzn, testGetPriceNvda, testGetPriceCoin,
testGetPriceMstr, testGetPriceTsla and the helper _assertFeedPrice) documenting
the exact oracle contract address (0xCE521b52513242c5094bc56f57887BB2A05B8129),
the fork block used (46061133), the date/time of the snapshot, and the
verification steps to reproduce the values (e.g., how to call the DIA oracle or
use an ethers/viem/eth_getStorageAt/eth_call command against that block and
path), plus a short note on updating values when changing fork block; ensure the
comments include the listed numeric price values and a concise one-line
reproducible command or method to fetch them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0d344cfa-561d-482d-ae0a-6f6b5d00bb8c
📒 Files selected for processing (10)
.pre-commit-config.yamlREADME.mdmeta/DiaSubParserAuthoringMeta.rain.metascript/verify-dia-oracle-base.shsrc/lib/dia/LibDia.solsrc/lib/parse/LibDiaSubParser.soltest/lib/LibFork.soltest/src/concrete/DiaWords.diaPrice.t.soltest/src/lib/dia/LibDia.t.soltest/src/lib/op/LibOpDiaPrice.t.sol
Commit a static .pre-commit-config.yaml so non-Nix contributors can run pre-commit install; git-hooks.nix leaves the file in place when present.
Summary
LibDiaat the new DIAPushOracleReceiverV2on Base (0xCE521b52513242c5094bc56f57887BB2A05B8129).AMZN,NVDA,COIN,MSTR,TSLA) instead of the previous demo oracle’sBTC/USD-style keys and 8 decimals.dia-priceauthoring meta for the new feeds.script/verify-dia-oracle-base.shto verify the oracle contract on Basescan (clones DIA’s Spectra-interoperability repo and initializes forge submodules).Test plan
forge testdia-price("AMZN" 3600)(and other tickers) against live oracle on Base as neededSummary by CodeRabbit
New Features
Documentation
Updates