Skip to content

refactor: remove old oracle data dependencies#463

Merged
antoncoding merged 2 commits intomasterfrom
refactor/stale-oracle-data
Mar 20, 2026
Merged

refactor: remove old oracle data dependencies#463
antoncoding merged 2 commits intomasterfrom
refactor/stale-oracle-data

Conversation

@antoncoding
Copy link
Copy Markdown
Owner

@antoncoding antoncoding commented Mar 20, 2026

Summary by CodeRabbit

  • New Features

    • Oracle badges now preserve both recognized vendor names and unverified feed indicators for mixed oracles.
  • Bug Fixes

    • Oracle classification and vendor parsing now rely on verified scanner metadata for more consistent, accurate displays and warnings.
  • Documentation

    • Technical overview updated to reflect metadata-driven oracle shapes and the new metadata-first market loading flow.
  • Chores

    • Removed legacy oracle data caching/hooks and unused GraphQL queries to simplify data pipeline.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Mar 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
monarch Ready Ready Preview, Comment Mar 20, 2026 5:32pm

Request Review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 20, 2026

📝 Walkthrough

Walkthrough

Replaces Morpho-API oracle enrichment with scanner-backed oracle metadata. Removes useOracleDataQuery and related GraphQL queries/types; introduces discriminated oracle output shapes and metadata accessors. Components and hooks now derive oracle classification, vendors, and feeds from useOracleMetadata (chainId + oracleAddress) instead of inline oracle data props.

Changes

Cohort / File(s) Summary
Docs
AGENTS.md, docs/TECHNICAL_OVERVIEW.md
Added validation rules requiring oracle classification from scanner metadata keyed by chainId + oracleAddress; updated Market domain model and oracle output types to a discriminated union; removed pre-generated oracle feed caches and switched dynamic fetches to metadata hooks.
Removed GraphQL / Morpho API surfacing
src/data-sources/morpho-api/vault-allocations.ts, src/graphql/morpho-api-queries.ts, src/graphql/morpho-subgraph-queries.ts, src/graphql/vault-allocation-query.ts
Deleted Morpho API query exports and vault-allocation fetch logic previously used for oracle/feed enrichment.
Hooks / data pipeline
src/hooks/queries/useOracleDataQuery.ts, src/hooks/useMarketData.ts, src/hooks/useProcessedMarkets.ts, src/hooks/useOracleMetadata.ts, src/hooks/useFeedLastUpdatedByChain.ts
Removed useOracleDataQuery; stopped client-side market enrichment with Morpho oracle data; refactored useOracleMetadata to return discriminated outputs and added getStandardOracleDataFromMetadata/getMetaOracleDataFromMetadata; updated feed-last-updated logic to use metadata types.
Oracle/vendor utils
src/utils/oracle.ts, src/utils/marketFilters.ts, src/utils/warnings.ts, src/utils/types.ts
Removed Morpho-specific types/utilities (FeedData, detectFeedVendor, getFeedFromOracleData, MorphoChainlinkOracleData); simplified signatures (getOracleType, parsePriceFeedVendors, checkFeedsPath) to consume metadata-shaped oracle data; removed oracle field from Market type.
Oracle vendor UI & badge updates
src/features/markets/components/oracle-vendor-badge.tsx, src/features/markets/components/market-identity.tsx, src/features/markets/components/market-details-block.tsx, src/features/markets/components/market-selector.tsx, src/features/markets/components/market-info-block.tsx, src/features/markets/components/pending-market-cap.tsx, src/features/markets/components/markets-table-same-loan.tsx
Removed oracleData prop from all OracleVendorBadge usages; badge logic now derives vendors/types from metadata helpers and shows preserved unknown/unverified indicators alongside known vendors; updated vendor extraction to use getStandardOracleDataFromMetadata.
Market oracle & feed components
src/features/markets/components/oracle/... (OracleTypeInfo, MarketOracleFeedInfo, MetaOracleInfo, FeedEntry, Feed tooltips: Chainlink/Compound/Redstone/Pendle/API3/General/Unknown)
Refactored to accept metadata-shaped inputs: tooltips and feed entries now take EnrichedFeed or derive feeds from metadata; removed feedData and oracleData props; vendor detection uses metadata helpers; feed fields (pair, description, heartbeat, etc.) read from enriched metadata.
Prefetch / DataPrefetcher
src/components/DataPrefetcher.tsx
Removed prefetch call to useOracleDataQuery; retained other prefetches (markets, tokens, campaigns).
Minor / formatting
src/data-sources/morpho-api/positions.ts, src/hooks/useUserPositions.ts, various component callsites (market-header.tsx, market-row-detail.tsx, market-table-body.tsx, etc.)
Small signature/import/formattings: type-only imports, single-line helper refactorings, and removal of oracleData prop where passed through.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant UI as Market UI
participant Hooks as useMarketData / useProcessedMarkets
participant Metadata as useOracleMetadata (scanner)
participant Utils as parse/classify utilities
participant Tooltips as FeedTooltip / OracleVendorBadge
UI->>Hooks: request market data (uniqueKey)
Hooks->>Metadata: get metadata by (chainId, oracleAddress)
Metadata-->>Hooks: Standard/Meta/NonStandard output
Hooks->>Utils: classify vendors/feeds using metadata
Hooks-->>UI: market data (no Morpho oracle enrichment; metadata-driven info)
UI->>Tooltips: render OracleVendorBadge / FeedEntry with oracleAddress + derived metadata
Tooltips->>Metadata: (if needed) request feed details / freshness
Tooltips-->>UI: render badge, vendor names, and "unverified" indicators

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.69% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing old oracle data dependencies throughout the codebase.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/stale-oracle-data

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.

@coderabbitai coderabbitai Bot added feature request Specific feature ready to be implemented ui User interface labels Mar 20, 2026
Copy link
Copy Markdown
Collaborator

@starksama starksama left a comment

Choose a reason for hiding this comment

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

I reviewed this PR and ran local validation on refactor/stale-oracle-data.

Blocking before approval:

  • pnpm lint:check fails due formatting drift in:
    • src/hooks/useOracleMetadata.ts
    • src/utils/oracle.ts

pnpm typecheck passes.

Please run formatter/lint autofix and push, then I can re-review and approve quickly.

Copy link
Copy Markdown
Collaborator

@starksama starksama left a comment

Choose a reason for hiding this comment

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

Re-reviewed after the lint fix.

Local validation on latest PR head:

  • pnpm lint:check ✅
  • pnpm typecheck ✅

Looks legit from my side.

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: 1

Caution

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

⚠️ Outside diff range comments (4)
src/hooks/useProcessedMarkets.ts (1)

36-54: ⚠️ Potential issue | 🟡 Minor

Stale JSDoc: step 3 still mentions oracle enrichment.

Line 43 says "Enrich with oracle data" but this step was removed. Update the doc to reflect current pipeline.

📝 Suggested fix
  * Processing steps:
  * 1. Get raw markets from React Query
  * 2. Remove blacklisted markets
- * 3. Enrich with oracle data
- * 4. Separate into allMarkets and whitelistedMarkets
+ * 3. Apply force-unwhitelisted overrides
+ * 4. Separate into allMarkets and whitelistedMarkets
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useProcessedMarkets.ts` around lines 36 - 54, Update the JSDoc for
useProcessedMarkets to remove the stale "Enrich with oracle data" step and
reflect the current pipeline (Get raw markets from React Query, Remove
blacklisted markets, Separate into allMarkets and whitelistedMarkets). Edit the
block comment above the useProcessedMarkets export (the docstring that lists
Processing steps) so step 3 is removed or relabeled to match current behavior
and ensure examples/returns text remain accurate.
src/hooks/useMarketData.ts (1)

98-103: ⚠️ Potential issue | 🔴 Critical

Line 143 uses nonexistent market.oracle field; will always default to zero address.

alloc.market.oracle?.address doesn't exist on the market structure — should be alloc.market.oracleAddress. This breaks marketParams for pull liquidity source markets. Same bug in src/utils/public-allocator.ts:249.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/hooks/useMarketData.ts` around lines 98 - 103, The market struct uses
oracleAddress, not an oracle object; update any use of
alloc.market.oracle?.address to alloc.market.oracleAddress (e.g., inside
useMarketData.ts where marketParams are built and in
src/utils/public-allocator.ts around the referenced line 249) so pull-liquidity
markets pick up the real oracle address (keep the existing zero-address fallback
logic intact).
src/utils/warnings.ts (2)

135-139: ⚠️ Potential issue | 🟠 Major

Oracle warnings now default to Custom when metadata is absent.

oracleMetadataMap is optional here, but getOracleType() falls back to Custom when it isn't provided. That means the legacy getMarketWarningsWithDetail(market, true) path—and any caller that computes warnings before metadata resolves—will add UNRECOGNIZED_ORACLE to ordinary standard/meta markets. Skip oracle-specific warnings until metadata is present, or remove the optional path.

Also applies to: 178-184

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/warnings.ts` around lines 135 - 139, getMarketWarningsWithDetail
currently treats missing oracleMetadataMap as if oracles are unknown because
getOracleType falls back to Custom, causing UNRECOGNIZED_ORACLE to be added
prematurely; update the logic in getMarketWarningsWithDetail (and the
oracle-specific warnings block later where UNRECOGNIZED_ORACLE is added) to
first check that options.oracleMetadataMap is present and contains the market's
oracle entry before calling getOracleType or emitting oracle-specific warnings;
if oracleMetadataMap is undefined or lacks the market's oracle, skip adding
UNRECOGNIZED_ORACLE (or any oracle-specific warnings) so legacy callers or
callers before metadata resolves don't get false-positive oracle warnings.

223-243: ⚠️ Potential issue | 🟠 Major

Primary meta-oracle path failures are ignored.

primaryResult is computed, but only backupResult.isValid can emit INCOMPATIBLE_ORACLE_FEEDS. If the primary route is broken and the backup route is fine, this returns no warning even though the live price source may be invalid. Check both branches and label which side failed.

Possible fix
-        } else if (!backupResult.isValid) {
-          const backupPath = backupResult.missingPath ?? 'Backup oracle does not produce a valid price path for this pair.';
-          result.push({
-            ...INCOMPATIBLE_ORACLE_FEEDS,
-            description: `Backup oracle: ${backupPath}`,
-          });
+        } else {
+          if (!primaryResult.isValid) {
+            const primaryPath = primaryResult.missingPath ?? 'Primary oracle does not produce a valid price path for this pair.';
+            result.push({
+              ...INCOMPATIBLE_ORACLE_FEEDS,
+              description: `Primary oracle: ${primaryPath}`,
+            });
+          }
+          if (!backupResult.isValid) {
+            const backupPath = backupResult.missingPath ?? 'Backup oracle does not produce a valid price path for this pair.';
+            result.push({
+              ...INCOMPATIBLE_ORACLE_FEEDS,
+              description: `Backup oracle: ${backupPath}`,
+            });
+          }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/warnings.ts` around lines 223 - 243, The code only treats
backupResult.isValid as a reason to emit INCOMPATIBLE_ORACLE_FEEDS and ignores
primaryResult failures; update the logic around primaryResult and backupResult
(results of checkEnrichedFeedsPath) to detect and report failures on either
side: if primaryResult.isValid is false push an INCOMPATIBLE_ORACLE_FEEDS
variant describing "Primary oracle: <missingPath>" (and likewise for
backupResult), while preserving the existing
UNRECOGNIZED_FEEDS/UNKNOWN_FEED_FOR_PAIR_MATCHING behavior when hasUnknown is
true; ensure you reference primaryResult, backupResult, checkEnrichedFeedsPath,
UNKNOWN_FEED_FOR_PAIR_MATCHING and INCOMPATIBLE_ORACLE_FEEDS when adding the new
branches so both primary and backup route failures produce clear, side-specific
warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/features/markets/components/oracle-vendor-badge.tsx`:
- Around line 39-45: The badge currently computes oracleType before metadata
resolves which causes oracles to default to Custom; change OracleVendorBadge to
wait for oracleMetadataMap to be defined before calling
getOracleType/getStandardOracleDataFromMetadata/getMetaOracleDataFromMetadata
(or wrap those calls in a memo that depends on oracleMetadataMap), and render a
neutral/loading badge when oracleMetadataMap is undefined; only treat isCustom =
true when getOracleType explicitly returns OracleType.Custom after metadata has
resolved. Use the existing symbols (useOracleMetadata, getOracleType,
getStandardOracleDataFromMetadata, getMetaOracleDataFromMetadata, OracleType) to
locate and gate these calls.

---

Outside diff comments:
In `@src/hooks/useMarketData.ts`:
- Around line 98-103: The market struct uses oracleAddress, not an oracle
object; update any use of alloc.market.oracle?.address to
alloc.market.oracleAddress (e.g., inside useMarketData.ts where marketParams are
built and in src/utils/public-allocator.ts around the referenced line 249) so
pull-liquidity markets pick up the real oracle address (keep the existing
zero-address fallback logic intact).

In `@src/hooks/useProcessedMarkets.ts`:
- Around line 36-54: Update the JSDoc for useProcessedMarkets to remove the
stale "Enrich with oracle data" step and reflect the current pipeline (Get raw
markets from React Query, Remove blacklisted markets, Separate into allMarkets
and whitelistedMarkets). Edit the block comment above the useProcessedMarkets
export (the docstring that lists Processing steps) so step 3 is removed or
relabeled to match current behavior and ensure examples/returns text remain
accurate.

In `@src/utils/warnings.ts`:
- Around line 135-139: getMarketWarningsWithDetail currently treats missing
oracleMetadataMap as if oracles are unknown because getOracleType falls back to
Custom, causing UNRECOGNIZED_ORACLE to be added prematurely; update the logic in
getMarketWarningsWithDetail (and the oracle-specific warnings block later where
UNRECOGNIZED_ORACLE is added) to first check that options.oracleMetadataMap is
present and contains the market's oracle entry before calling getOracleType or
emitting oracle-specific warnings; if oracleMetadataMap is undefined or lacks
the market's oracle, skip adding UNRECOGNIZED_ORACLE (or any oracle-specific
warnings) so legacy callers or callers before metadata resolves don't get
false-positive oracle warnings.
- Around line 223-243: The code only treats backupResult.isValid as a reason to
emit INCOMPATIBLE_ORACLE_FEEDS and ignores primaryResult failures; update the
logic around primaryResult and backupResult (results of checkEnrichedFeedsPath)
to detect and report failures on either side: if primaryResult.isValid is false
push an INCOMPATIBLE_ORACLE_FEEDS variant describing "Primary oracle:
<missingPath>" (and likewise for backupResult), while preserving the existing
UNRECOGNIZED_FEEDS/UNKNOWN_FEED_FOR_PAIR_MATCHING behavior when hasUnknown is
true; ensure you reference primaryResult, backupResult, checkEnrichedFeedsPath,
UNKNOWN_FEED_FOR_PAIR_MATCHING and INCOMPATIBLE_ORACLE_FEEDS when adding the new
branches so both primary and backup route failures produce clear, side-specific
warnings.
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1c50ace3-cfb4-4608-9bd2-cb187f837dfa

📥 Commits

Reviewing files that changed from the base of the PR and between 8415e30 and a72f967.

📒 Files selected for processing (37)
  • AGENTS.md
  • docs/TECHNICAL_OVERVIEW.md
  • src/components/DataPrefetcher.tsx
  • src/data-sources/morpho-api/vault-allocations.ts
  • src/features/market-detail/components/market-header.tsx
  • src/features/markets/components/market-details-block.tsx
  • src/features/markets/components/market-identity.tsx
  • src/features/markets/components/market-info-block.tsx
  • src/features/markets/components/market-selector.tsx
  • src/features/markets/components/markets-table-same-loan.tsx
  • src/features/markets/components/oracle-vendor-badge.tsx
  • src/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/ChainlinkFeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/CompoundFeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/FeedEntry.tsx
  • src/features/markets/components/oracle/MarketOracle/GeneralFeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/MarketOracleFeedInfo.tsx
  • src/features/markets/components/oracle/MarketOracle/MetaOracleInfo.tsx
  • src/features/markets/components/oracle/MarketOracle/OracleTypeInfo.tsx
  • src/features/markets/components/oracle/MarketOracle/PendleFeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/RedstoneFeedTooltip.tsx
  • src/features/markets/components/oracle/MarketOracle/UnknownFeedTooltip.tsx
  • src/features/markets/components/pending-market-cap.tsx
  • src/features/markets/components/table/market-row-detail.tsx
  • src/features/markets/components/table/market-table-body.tsx
  • src/graphql/morpho-api-queries.ts
  • src/graphql/morpho-subgraph-queries.ts
  • src/graphql/vault-allocation-query.ts
  • src/hooks/queries/useOracleDataQuery.ts
  • src/hooks/useFeedLastUpdatedByChain.ts
  • src/hooks/useMarketData.ts
  • src/hooks/useOracleMetadata.ts
  • src/hooks/useProcessedMarkets.ts
  • src/utils/marketFilters.ts
  • src/utils/oracle.ts
  • src/utils/types.ts
  • src/utils/warnings.ts
💤 Files with no reviewable changes (15)
  • src/features/markets/components/market-details-block.tsx
  • src/features/markets/components/market-info-block.tsx
  • src/features/markets/components/table/market-table-body.tsx
  • src/features/market-detail/components/market-header.tsx
  • src/features/markets/components/market-identity.tsx
  • src/components/DataPrefetcher.tsx
  • src/features/markets/components/table/market-row-detail.tsx
  • src/features/markets/components/pending-market-cap.tsx
  • src/features/markets/components/market-selector.tsx
  • src/utils/types.ts
  • src/graphql/vault-allocation-query.ts
  • src/data-sources/morpho-api/vault-allocations.ts
  • src/graphql/morpho-subgraph-queries.ts
  • src/graphql/morpho-api-queries.ts
  • src/hooks/queries/useOracleDataQuery.ts

Comment thread src/features/markets/components/oracle-vendor-badge.tsx
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.

Caution

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

⚠️ Outside diff range comments (1)
src/utils/oracle.ts (1)

137-138: ⚠️ Potential issue | 🟡 Minor

Add optional chaining for feed.pair to match usage elsewhere.

Line 403 uses feed.pair?.length === 2, suggesting pair can be undefined. This line would throw if pair is undefined.

Proposed fix
-  if (feed.pair.length === 2) {
+  if (feed.pair?.length === 2) {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/utils/oracle.ts` around lines 137 - 138, The current check uses feed.pair
directly which will throw if pair is undefined; update the condition to use
optional chaining (e.g., change the if to check feed.pair?.length === 2) and
keep the destructuring of [baseAsset, quoteAsset] = feed.pair only inside that
guarded block so you never access feed.pair when it's undefined.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/utils/oracle.ts`:
- Around line 137-138: The current check uses feed.pair directly which will
throw if pair is undefined; update the condition to use optional chaining (e.g.,
change the if to check feed.pair?.length === 2) and keep the destructuring of
[baseAsset, quoteAsset] = feed.pair only inside that guarded block so you never
access feed.pair when it's undefined.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 67104340-5db6-4948-9e93-c6442ddc39ad

📥 Commits

Reviewing files that changed from the base of the PR and between a72f967 and d83470b.

📒 Files selected for processing (4)
  • src/data-sources/morpho-api/positions.ts
  • src/hooks/useFeedLastUpdatedByChain.ts
  • src/hooks/useUserPositions.ts
  • src/utils/oracle.ts
✅ Files skipped from review due to trivial changes (3)
  • src/data-sources/morpho-api/positions.ts
  • src/hooks/useUserPositions.ts
  • src/hooks/useFeedLastUpdatedByChain.ts

@antoncoding antoncoding merged commit dd95cd1 into master Mar 20, 2026
4 checks passed
@antoncoding antoncoding deleted the refactor/stale-oracle-data branch March 20, 2026 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request Specific feature ready to be implemented ui User interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants