Skip to content

Update Base DIA oracle to equity feeds#2

Open
Siddharth2207 wants to merge 8 commits into
mainfrom
2026-05-16-update-dia-oracle
Open

Update Base DIA oracle to equity feeds#2
Siddharth2207 wants to merge 8 commits into
mainfrom
2026-05-16-update-dia-oracle

Conversation

@Siddharth2207

@Siddharth2207 Siddharth2207 commented May 16, 2026

Copy link
Copy Markdown

Summary

Updates the Base DIA integration from the old demo oracle to DIA’s PushOracleReceiverV2 (Spectra) equity feeds.

Oracle (Base, chain id 8453)

Before After
Contract Demo oracle (0xB8BF…) PushOracleReceiverV2 0xCE521b52513242c5094bc56f57887BB2A05B8129
Keys "BTC/USD" style Ticker strings: AMZN, NVDA, COIN, MSTR, TSLA
Decimals 8 18

Code & docs

  • LibDia: new ORACLE_BASE, DIA_DECIMALS = -18, ticker key docs.
  • README, LibDiaSubParser, and dia-price authoring meta updated for equity tickers and 18-decimal prices.
  • Regenerated DiaWords.pointers.sol and meta after contract changes.

Tests

  • Fork tests at Base block 46061133 with snapshot assertions for all five tickers.
  • dia-price / LibOpDiaPrice tests use "AMZN" instead of "BTC/USD".
  • Fork block timestamp is used for staleness checks (no vm.warp).

Tooling / CI

  • Portable committed .pre-commit-config.yaml (trailing whitespace, shellcheck, prettier, optional forge fmt when forge is on PATH).
  • slither.config.json for static analysis (excludes deps/tests; filters interpreter submodule libs).
  • rain.interpreter submodule bumped to f2ede963 (branch fix/slither-libparse-018871e) — fixes Slither 0.11+ LibParse disable directives.
  • //slither-disable-next-line timestamp on intentional staleness check in LibDia.getPriceNoOlderThan.
  • REUSE.toml annotations for .pre-commit-config.yaml and script/**.

Removed

  • script/verify-dia-oracle-base.sh (oracle verification is out of scope for this repo).

Links

Test plan

  • nix develop -c rainix-sol-test (fork tests against Base RPC)
  • nix develop -c rainix-sol-static
  • nix develop -c rainix-sol-legal (reuse lint)
  • nix develop -c rain-dia-prelude && forge script ./script/BuildPointers.sol && forge fmt then git diff --exit-code (git-clean)
  • Optional: spot-check live prices on Base, e.g. dia-price("AMZN" 3600)

Summary by CodeRabbit

  • New Features

    • Added pre-commit hooks setup documentation and commands.
  • Documentation

    • Updated usage examples with new asset symbols.
    • Updated price precision documentation from 8 to 18 decimal places.
  • Chores

    • Updated oracle configuration for Base chain.
    • Increased DIA price precision to 18 decimals.
    • Updated test coverage with expanded asset symbols.
    • Updated project configuration and annotations.

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.
@coderabbitai

coderabbitai Bot commented May 16, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR updates the DIA oracle integration to use 18-decimal price precision instead of 8, replaces BTC/USD test fixtures with AMZN and additional ticker symbols, adds pre-commit hook documentation, and updates fork configuration to a newer Base block. All changes are cohesive within a single functional update.

Changes

DIA Oracle Decimal Precision and Asset Symbol Update

Layer / File(s) Summary
DIA oracle constants and decimal precision update
src/lib/dia/LibDia.sol, src/lib/parse/LibDiaSubParser.sol
ORACLE_BASE address and DIA_DECIMALS change from -8 to -18. NatSpec updated to reflect 18-decimal precision and ticker-format asset keys (e.g., "AMZN"). Slither timestamp disable comment added before staleness check. SubParser metadata description updated to 18 decimals.
Documentation and metadata updates
README.md
Usage examples and parameter documentation updated: dia-price example key changes from "BTC/USD" to "AMZN", key examples updated to "AMZN"/"NVDA" format, price output precision documented as 18 decimals. New "Pre-commit" section describes git hook setup and run commands.
Test fork configuration and imports
test/lib/LibFork.sol, test/src/concrete/DiaWords.diaPrice.t.sol, test/src/lib/dia/LibDia.t.sol, test/src/lib/op/LibOpDiaPrice.t.sol
FORK_BLOCK_BASE updated to newer Base block height with AMZN-focused documentation. DIA_BTC_USD_TIMESTAMP import removed from all test files, eliminating time-warp-based test initialization.
Test symbol migration and coverage expansion
test/src/concrete/DiaWords.diaPrice.t.sol, test/src/lib/op/LibOpDiaPrice.t.sol, test/src/lib/dia/LibDia.t.sol
DiaWords and LibOpDiaPrice tests change input symbol from "BTC/USD" to "AMZN"; vm.warp removed. LibDia.t.sol adds setUp() for Base fork selection, _assertFeedPrice() helper for pinned price validation, removes BTC/USD round-trip test, and adds AMZN/NVDA/COIN/MSTR/TSLA symbol-specific price tests.
Supporting configuration updates
REUSE.toml, slither.config.json
REUSE.toml annotations paths expanded to include .pre-commit-config.yaml and additional directory patterns. Slither configuration formatting updated.

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'Update Base DIA oracle to equity feeds' directly describes the primary change: switching the Base DIA oracle configuration from demo/crypto feeds (BTC/USD) to equity ticker feeds (AMZN, NVDA, COIN, MSTR, TSLA) with 18-decimal pricing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-16-update-dia-oracle

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Oracle verification is out of scope for this repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0d3c3b2 and e10d330.

📒 Files selected for processing (10)
  • .pre-commit-config.yaml
  • README.md
  • meta/DiaSubParserAuthoringMeta.rain.meta
  • script/verify-dia-oracle-base.sh
  • src/lib/dia/LibDia.sol
  • src/lib/parse/LibDiaSubParser.sol
  • test/lib/LibFork.sol
  • test/src/concrete/DiaWords.diaPrice.t.sol
  • test/src/lib/dia/LibDia.t.sol
  • test/src/lib/op/LibOpDiaPrice.t.sol

Comment thread .pre-commit-config.yaml Outdated
Comment thread script/verify-dia-oracle-base.sh Outdated
Comment thread script/verify-dia-oracle-base.sh Outdated
Comment thread src/lib/dia/LibDia.sol
Comment thread test/lib/LibFork.sol Outdated
Comment thread test/src/lib/dia/LibDia.t.sol
Siddharth2207 and others added 5 commits May 16, 2026 13:26
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.
Regenerate DiaWords.pointers.sol after prelude, add slither.config.json
(fail_on none), patch LibParse slither directives before static analysis,
and annotate new files in REUSE.toml.

Co-authored-by: Cursor <cursoragent@cursor.com>
Remove fix-libparse-slither.sh and the custom rainix-sol-static wrapper;
configure Slither via slither.config.json. Pin rain.interpreter to a
submodule commit that fixes LibParse disable directives for Slither 0.11+.

Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve conflicts from soldeer migration: drop submodules and
.pre-commit-config.yaml, adopt main slither config, update test imports,
and regenerate DiaWords pointers.

Co-authored-by: Cursor <cursoragent@cursor.com>

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 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 `@slither.config.json`:
- Line 2: Remove "timestamp" from the detectors_to_exclude value in the slither
configuration so Slither will report timestamp usage by default; keep using the
inline suppression comments ("//slither-disable-next-line timestamp") for
legitimate cases instead of the global suppression in the detectors_to_exclude
key to preserve static analysis coverage for new code.

In `@src/lib/dia/LibDia.sol`:
- Around line 80-82: Guard the stale-check against future timestamps: before
computing block.timestamp - rawTimestamp in LibDia.sol, ensure you handle the
case rawTimestamp > block.timestamp (or compute the delta safely). Update the
stale-check that currently uses rawTimestamp, block.timestamp and staleAfterUint
so it first checks if rawTimestamp > block.timestamp or uses a safe comparison
like rawTimestamp + staleAfterUint < block.timestamp, and then revert with
StaleDiaPrice(rawTimestamp, staleAfterUint) accordingly; this prevents an
underflow panic and preserves the intended custom stale error path.
🪄 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: a7d53b90-e01e-494e-8e70-fbe25b826152

📥 Commits

Reviewing files that changed from the base of the PR and between cd67af3 and 24f5be6.

⛔ Files ignored due to path filters (1)
  • src/generated/DiaWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (7)
  • REUSE.toml
  • slither.config.json
  • src/lib/dia/LibDia.sol
  • src/lib/parse/LibDiaSubParser.sol
  • test/src/concrete/DiaWords.diaPrice.t.sol
  • test/src/lib/dia/LibDia.t.sol
  • test/src/lib/op/LibOpDiaPrice.t.sol

Comment thread slither.config.json
{
"detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address,timestamp",
"filter_paths": "dependencies,test,forge-std"
"detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address,timestamp",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚖️ Poor tradeoff

Inconsistent timestamp detector handling contradicts the stated PR approach.

The PR objectives explicitly mention "added //slither-disable-next-line timestamp where intentional", indicating a targeted suppression strategy for legitimate timestamp usage. However, globally excluding the timestamp detector here prevents Slither from flagging any timestamp usage anywhere in the codebase, including potentially problematic new code.

Recommendation: Remove timestamp from detectors_to_exclude and rely solely on the inline //slither-disable-next-line timestamp comments for known-safe cases. This preserves static analysis coverage for new timestamp-dependent logic.

🔒 Proposed fix
-  "detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address,timestamp",
+  "detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address,timestamp",
"detectors_to_exclude": "assembly-usage,solc-version,unused-imports,pragma,different-pragma-directives-are-used,unindexed-event-address",
🤖 Prompt for 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.

In `@slither.config.json` at line 2, Remove "timestamp" from the
detectors_to_exclude value in the slither configuration so Slither will report
timestamp usage by default; keep using the inline suppression comments
("//slither-disable-next-line timestamp") for legitimate cases instead of the
global suppression in the detectors_to_exclude key to preserve static analysis
coverage for new code.

Comment thread src/lib/dia/LibDia.sol
Comment on lines +80 to 82
//slither-disable-next-line timestamp
if (block.timestamp - rawTimestamp > staleAfterUint) {
revert StaleDiaPrice(rawTimestamp, staleAfterUint);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Guard stale-check arithmetic against future timestamps.

If the oracle returns rawTimestamp > block.timestamp, block.timestamp - rawTimestamp underflows and reverts with a panic instead of the intended custom stale error path.

Suggested fix
-        //slither-disable-next-line timestamp
-        if (block.timestamp - rawTimestamp > staleAfterUint) {
+        // slither-disable-next-line timestamp
+        if (rawTimestamp > block.timestamp || block.timestamp - rawTimestamp > staleAfterUint) {
             revert StaleDiaPrice(rawTimestamp, staleAfterUint);
         }
🤖 Prompt for 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.

In `@src/lib/dia/LibDia.sol` around lines 80 - 82, Guard the stale-check against
future timestamps: before computing block.timestamp - rawTimestamp in
LibDia.sol, ensure you handle the case rawTimestamp > block.timestamp (or
compute the delta safely). Update the stale-check that currently uses
rawTimestamp, block.timestamp and staleAfterUint so it first checks if
rawTimestamp > block.timestamp or uses a safe comparison like rawTimestamp +
staleAfterUint < block.timestamp, and then revert with
StaleDiaPrice(rawTimestamp, staleAfterUint) accordingly; this prevents an
underflow panic and preserves the intended custom stale error path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant