Skip to content

Update Base DIA oracle to equity feeds#2

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

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

Conversation

@Siddharth2207
Copy link
Copy Markdown

@Siddharth2207 Siddharth2207 commented May 16, 2026

Summary

  • Point LibDia at the new DIA PushOracleReceiverV2 on Base (0xCE521b52513242c5094bc56f57887BB2A05B8129).
  • Use 18-decimal prices and ticker feed keys (AMZN, NVDA, COIN, MSTR, TSLA) instead of the previous demo oracle’s BTC/USD-style keys and 8 decimals.
  • Refresh fork tests, README, and dia-price authoring meta for the new feeds.
  • Add script/verify-dia-oracle-base.sh to verify the oracle contract on Basescan (clones DIA’s Spectra-interoperability repo and initializes forge submodules).

Test plan

  • forge test
  • Confirm dia-price("AMZN" 3600) (and other tickers) against live oracle on Base as needed

Summary by CodeRabbit

  • New Features

    • Added pre-commit git hooks configuration for automated code formatting and validation.
  • Documentation

    • Updated usage examples and documentation for DIA price oracle integration.
    • Added pre-commit setup and usage instructions to README.
  • Updates

    • Updated DIA oracle address for Base network.
    • Changed DIA price precision from 8 to 18 decimal places.
    • Updated test coverage with new oracle data examples.

Review Change Stack

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
Copy link
Copy Markdown

coderabbitai Bot commented May 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 0e99bebe-8d0f-4f5c-a1ba-d67afcc616af

📥 Commits

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

⛔ Files ignored due to path filters (1)
  • src/generated/DiaWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (8)
  • .pre-commit-config.yaml
  • .pre-commit-config.yaml
  • README.md
  • meta/DiaWords.rain.meta
  • src/abstract/DiaExtern.sol
  • src/abstract/DiaSubParser.sol
  • test/lib/LibFork.sol
  • test/src/lib/dia/LibDia.t.sol

Walkthrough

This 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.

Changes

DIA Oracle Decimal Precision and Asset Symbol Update

Layer / File(s) Summary
Core DIA constants and decimal precision
src/lib/dia/LibDia.sol
ORACLE_BASE address and DIA_DECIMALS updated from -8 to -18; NatSpec comments reflect 18-decimal price precision and example key format.
Documentation and metadata updates
README.md, src/lib/parse/LibDiaSubParser.sol
README dia-price usage example and parameter descriptions updated to 18-decimal precision and AMZN/NVDA keys; authoring metadata updated to match. New "Pre-commit" section added to README.
Test fork and infrastructure updates
test/lib/LibFork.sol, test/src/lib/dia/LibDia.t.sol, test/src/concrete/DiaWords.diaPrice.t.sol, test/src/lib/op/LibOpDiaPrice.t.sol
FORK_BLOCK_BASE incremented to newer Base height; DIA_BTC_USD_TIMESTAMP imports removed from all test files; fork documentation references AMZN example data.
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
Test inputs changed from "BTC/USD" to "AMZN"; time-warp steps removed. LibDia.t.sol refactored with shared setUp() and _assertFeedPrice() helper; symbol-specific tests added for AMZN, NVDA, COIN, MSTR, TSLA; string round-trip coverage updated.
Code structure and formatting updates
src/abstract/DiaExtern.sol, src/abstract/DiaSubParser.sol
Function pointer array type declarations reformatted; return statement formatting adjusted. No behavioral changes.

Pre-commit Hook Configuration

Layer / File(s) Summary
Pre-commit hooks configuration
.pre-commit-config.yaml
Replaces Nix store path reference with self-contained hook definitions: trailing whitespace, EOF formatting, ShellCheck, Prettier (markdown/yaml/json), and conditional local forge fmt hook with PATH availability check.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 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 title 'Update Base DIA oracle to equity feeds' accurately summarizes the main change: migrating from a demo oracle with 8-decimal BTC/USD feeds to an equity ticker feed oracle with 18-decimal prices on Base, with corresponding test and documentation updates.
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

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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