Skip to content

Add DIA price minimum update timestamp word#46

Closed
JuaniRios wants to merge 1 commit into
mainfrom
dia-price-after-freshness-boundary
Closed

Add DIA price minimum update timestamp word#46
JuaniRios wants to merge 1 commit into
mainfrom
dia-price-after-freshness-boundary

Conversation

@JuaniRios

@JuaniRios JuaniRios commented Jul 17, 2026

Copy link
Copy Markdown

What

Adds dia-price-after, which is the same DIA price read as dia-price but with an extra minimumUpdatedAt input.

This lets callers reject prices whose DIA update happened before a caller-defined boundary, e.g. market open / session start.

Why

staleAfter only says "not older than N seconds from now". It does not say "this price was marked after the event I care about".

For the liquidity bot case, that means we can wait for a fresh DIA mark after session start instead of encoding this as downstream strategy-specific oracle glue.

How

  • Adds LibDia.getPriceNoOlderThanAndUpdatedAfter.
  • Adds the dia-price-after extern word with 3 inputs and 2 outputs.
  • Regenerates pointer and metadata artifacts.
  • Documents the new word in the README.

Testing

  • forge test

Summary by CodeRabbit

  • New Features
    • Added the dia-price-after oracle query.
    • Supports a caller-defined minimum acceptable update timestamp and a maximum staleness timeout.
    • Returns both the price and the last update timestamp.
  • Bug Fixes
    • Strengthened validation to revert when the returned price is zero (with a recent timestamp).
    • Added clearer rejection for data older than the minimum timestamp.
  • Documentation
    • Updated README with usage examples and full input/output details for dia-price-after.
  • Tests
    • Added coverage for boundary conditions and expected revert cases for dia-price-after.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

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: 2cfacfbd-ef73-417e-9f69-8c998474dd22

📥 Commits

Reviewing files that changed from the base of the PR and between dadc871 and f70720f.

⛔ Files ignored due to path filters (1)
  • src/generated/DiaWords.pointers.sol is excluded by !**/generated/**
📒 Files selected for processing (16)
  • README.md
  • meta/DiaSubParserAuthoringMeta.rain.meta
  • meta/DiaWords.rain.meta
  • script/Build.sol
  • src/abstract/DiaExtern.sol
  • src/abstract/DiaSubParser.sol
  • src/lib/dia/LibDia.sol
  • src/lib/op/LibOpDiaPrice.sol
  • src/lib/parse/LibDiaSubParser.sol
  • test/src/concrete/DiaWords.diaPrice.t.sol
  • test/src/lib/dia/LibDia.fromStringV3.sol
  • test/src/lib/dia/LibDia.getOracleContract.t.sol
  • test/src/lib/dia/LibDia.intOrAStringToString.t.sol
  • test/src/lib/dia/LibDia.t.sol
  • test/src/lib/dia/LibDiaGetOracleContractExternalWrapper.sol
  • test/src/lib/op/LibOpDiaPrice.t.sol

Walkthrough

Changes

The DIA integration adds dia-price-after, accepting a price key, minimum update timestamp, and stale-after duration. Oracle validation, extern dispatch, sub-parser registration, authoring metadata, README documentation, build wiring, and supporting tests were added.

DIA price-after operation

Layer / File(s) Summary
Oracle timestamp validation
src/lib/dia/LibDia.sol, test/src/lib/dia/*
Adds minimum timestamp and zero-price validation while preserving stale-price checks, with boundary, revert, encoding, and oracle contract tests.
Extern and parser wiring
src/lib/op/LibOpDiaPrice.sol, src/abstract/*, src/lib/parse/LibDiaSubParser.sol, test/src/lib/op/*, test/src/concrete/*
Adds the three-input, two-output operation, opcode and function-pointer mappings, parser support, dispatch execution, and runtime/integrity tests.
Authoring metadata and documentation
meta/*, README.md
Documents and serializes the new dia-price-after word, including parameters, outputs, and revert conditions.
Build support
script/Build.sol
Adds the Build contract inheriting from BuildPointers.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant RainParser
  participant DiaSubParser
  participant DiaExtern
  participant LibOpDiaPrice
  participant LibDia
  participant DIAOracle
  RainParser->>DiaSubParser: parse dia-price-after
  DiaSubParser->>DiaExtern: dispatch OPCODE_DIA_PRICE_AFTER
  DiaExtern->>LibOpDiaPrice: runAfter(key, minimumUpdatedAt, staleAfter)
  LibOpDiaPrice->>LibDia: getPriceNoOlderThanAndUpdatedAfter(...)
  LibDia->>DIAOracle: fetch price and timestamp
  DIAOracle-->>LibDia: raw price and update timestamp
  LibDia-->>LibOpDiaPrice: price and updatedAt
  LibOpDiaPrice-->>DiaExtern: return two stack outputs
Loading

Possibly related issues

  • Issue 11: The extern-dispatch test updates exercise DiaWords.extern instead of calling LibOpDiaPrice.run directly.
  • Issue 22: Round-trip tests for intOrAStringToString were added, but empty-string and 31-byte boundary cases remain uncovered.
🚥 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 clearly matches the main change: adding a DIA price word that enforces a minimum update timestamp.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch dia-price-after-freshness-boundary

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.

Copy link
Copy Markdown
Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@JuaniRios
JuaniRios marked this pull request as ready for review July 17, 2026 14:46
@JuaniRios
JuaniRios force-pushed the dia-price-after-freshness-boundary branch 2 times, most recently from ed301ab to 9f2eada Compare July 17, 2026 15:02
@JuaniRios JuaniRios self-assigned this Jul 17, 2026
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