Skip to content

Conversation

@thedavidmeister
Copy link
Contributor

@thedavidmeister thedavidmeister commented Nov 6, 2025

Motivation

Solution

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

Summary by CodeRabbit

  • New Features
    • Added support for BTC/USD, WBTC/USD, ETH/USD, WETH/USD, and XRP/USD price feeds and prioritized crypto feed selection where applicable.
  • Tests
    • Expanded test coverage and added assertions for the new crypto feeds, including price freshness/no-older-than checks on Arbitrum and extended mapping validations.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 6, 2025

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • src/generated/PythWords.pointers.sol is excluded by !**/generated/**

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Adds five Crypto USD price-feed constants to LibPyth, updates getPriceFeedId to recognize crypto symbols (checked before equity), adjusts a test signature in the gas snapshot, and extends tests to assert the new constants and price/no-older-than behavior.

Changes

Cohort / File(s) Summary
Gas snapshot
\.gas-snapshot
Updated test signature for LibOpPythPriceTest::testIntegrity from (uint256,uint256,uint256) to (bytes32,uint256,uint256); gas metrics recalculated.
LibPyth core
src/lib/pyth/LibPyth.sol
Added bytes32 PRICE_FEED_ID_* and IntOrAString symbol constants for Crypto BTC/WBTC/ETH/WETH/XRP (USD). Extended getPriceFeedId(IntOrAString) to match crypto symbols before existing equity branches.
Tests — constants & mappings
test/src/lib/pyth/LibPyth.constants.t.sol, test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol
Added assertions validating new crypto IntOrAString constants and that getPriceFeedId returns the corresponding PRICE_FEED_ID_* constants; updated unknown-symbol exclusions to skip the new crypto symbols.
Tests — price/no-older-than
test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol
Added checkPriceNoOlderThan invocations for Crypto.BTC/USD, Crypto.WBTC/USD, Crypto.ETH/USD, Crypto.WETH/USD, and Crypto.XRP/USD with specified max-age and expected price/confidence values.

Sequence Diagram(s)

sequenceDiagram
  participant Test as Tests
  participant Lib as LibPyth
  participant Const as PRICE_FEED_ID_*

  rect rgb(245,250,255)
  Note over Test,Lib: Resolve feed ID for an IntOrAString symbol
  Test->>Lib: getPriceFeedId(feedSymbolIntOrAString)
  alt symbol matches Crypto.* / USD
    Lib->>Const: match crypto branch -> return PRICE_FEED_ID_CRYPTO_*
    Const-->>Lib: PRICE_FEED_ID_CRYPTO_*
    Lib-->>Test: bytes32 crypto feed id
  else other (equity/previous cases)
    Lib->>Const: evaluate equity branches -> return PRICE_FEED_ID_*
    Const-->>Lib: PRICE_FEED_ID_*
    Lib-->>Test: bytes32 feed id
  end
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify correctness of the new bytes32 PRICE_FEED_ID_* constant values.
  • Confirm IntOrAString symbol constants correspond exactly to tested string representations.
  • Check getPriceFeedId ordering to avoid accidental collisions or misclassification.
  • Review added test ages and expected packed price/confidence values for correctness.

Possibly related PRs

Suggested reviewers

  • hardyjosh

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'feed ids' is vague and generic, lacking specificity about what feed IDs are being added, modified, or their purpose. Consider a more descriptive title such as 'Add crypto price feed constants (BTC, WBTC, ETH, WETH, XRP)' or 'Support crypto feeds in LibPyth' to clarify the main change.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

@thedavidmeister thedavidmeister self-assigned this Nov 6, 2025
Copy link
Contributor

@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: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/pyth/LibPyth.sol (1)

127-161: Consider addressing the O(1) lookup table TODO.

The getPriceFeedId function now contains 15+ sequential if-else branches. With the addition of 5 crypto feeds, this linear search pattern is becoming less maintainable and incurs increasing gas costs as the feed list grows.

The TODO comment at line 124 suggests replacing this with an O(1) lookup table. Given the growing number of feeds, this would be a good time to implement a mapping-based solution. This would provide:

  • O(1) lookup time (constant gas cost)
  • Better maintainability
  • Easier to add new feeds in the future

Would you like me to open an issue to track implementing the O(1) lookup table?

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9a02755 and 4fb967d.

📒 Files selected for processing (3)
  • src/lib/pyth/LibPyth.sol (2 hunks)
  • test/src/lib/pyth/LibPyth.constants.t.sol (1 hunks)
  • test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol (2 hunks)
🔇 Additional comments (4)
src/lib/pyth/LibPyth.sol (1)

127-136: LGTM: Crypto feeds correctly integrated.

The crypto feed branches are correctly implemented and logically placed before equity feeds. Each branch properly maps the IntOrAString symbol to its corresponding price feed ID.

test/src/lib/pyth/LibPyth.constants.t.sol (1)

16-35: LGTM: Comprehensive test coverage for crypto constants.

The test assertions correctly validate that each crypto price feed symbol constant matches its expected IntOrAString encoding. The pattern is consistent with the existing equity tests and provides complete coverage of all 5 new crypto feeds.

test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol (2)

16-32: LGTM: Crypto feed mappings correctly tested.

The test assertions properly validate that getPriceFeedId returns the correct price feed ID for each crypto symbol. The tests cover all 5 new crypto feeds and follow the established pattern from the equity feed tests.


81-85: LGTM: Fuzz test correctly excludes new crypto feeds.

The vm.assume conditions properly exclude all 5 new crypto feed symbols from the unknown mappings fuzz test. This ensures the test only validates that truly unsupported symbols revert with UnsupportedFeedSymbol.

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4fb967d and 0ac35e4.

📒 Files selected for processing (1)
  • test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol (1 hunks)

@thedavidmeister thedavidmeister merged commit 33f006a into main Nov 7, 2025
5 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Nov 7, 2025
4 tasks
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.

2 participants