refactor: remove old oracle data dependencies#463
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughReplaces 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
Sequence Diagram(s)mermaid Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
starksama
left a comment
There was a problem hiding this comment.
I reviewed this PR and ran local validation on refactor/stale-oracle-data.
Blocking before approval:
pnpm lint:checkfails due formatting drift in:src/hooks/useOracleMetadata.tssrc/utils/oracle.ts
pnpm typecheck passes.
Please run formatter/lint autofix and push, then I can re-review and approve quickly.
starksama
left a comment
There was a problem hiding this comment.
Re-reviewed after the lint fix.
Local validation on latest PR head:
- pnpm lint:check ✅
- pnpm typecheck ✅
Looks legit from my side.
There was a problem hiding this comment.
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 | 🟡 MinorStale 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 | 🔴 CriticalLine 143 uses nonexistent
market.oraclefield; will always default to zero address.
alloc.market.oracle?.addressdoesn't exist on the market structure — should bealloc.market.oracleAddress. This breaks marketParams for pull liquidity source markets. Same bug insrc/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 | 🟠 MajorOracle warnings now default to
Customwhen metadata is absent.
oracleMetadataMapis optional here, butgetOracleType()falls back toCustomwhen it isn't provided. That means the legacygetMarketWarningsWithDetail(market, true)path—and any caller that computes warnings before metadata resolves—will addUNRECOGNIZED_ORACLEto 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 | 🟠 MajorPrimary meta-oracle path failures are ignored.
primaryResultis computed, but onlybackupResult.isValidcan emitINCOMPATIBLE_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
📒 Files selected for processing (37)
AGENTS.mddocs/TECHNICAL_OVERVIEW.mdsrc/components/DataPrefetcher.tsxsrc/data-sources/morpho-api/vault-allocations.tssrc/features/market-detail/components/market-header.tsxsrc/features/markets/components/market-details-block.tsxsrc/features/markets/components/market-identity.tsxsrc/features/markets/components/market-info-block.tsxsrc/features/markets/components/market-selector.tsxsrc/features/markets/components/markets-table-same-loan.tsxsrc/features/markets/components/oracle-vendor-badge.tsxsrc/features/markets/components/oracle/MarketOracle/API3FeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/ChainlinkFeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/CompoundFeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/FeedEntry.tsxsrc/features/markets/components/oracle/MarketOracle/GeneralFeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/MarketOracleFeedInfo.tsxsrc/features/markets/components/oracle/MarketOracle/MetaOracleInfo.tsxsrc/features/markets/components/oracle/MarketOracle/OracleTypeInfo.tsxsrc/features/markets/components/oracle/MarketOracle/PendleFeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/RedstoneFeedTooltip.tsxsrc/features/markets/components/oracle/MarketOracle/UnknownFeedTooltip.tsxsrc/features/markets/components/pending-market-cap.tsxsrc/features/markets/components/table/market-row-detail.tsxsrc/features/markets/components/table/market-table-body.tsxsrc/graphql/morpho-api-queries.tssrc/graphql/morpho-subgraph-queries.tssrc/graphql/vault-allocation-query.tssrc/hooks/queries/useOracleDataQuery.tssrc/hooks/useFeedLastUpdatedByChain.tssrc/hooks/useMarketData.tssrc/hooks/useOracleMetadata.tssrc/hooks/useProcessedMarkets.tssrc/utils/marketFilters.tssrc/utils/oracle.tssrc/utils/types.tssrc/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
There was a problem hiding this comment.
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 | 🟡 MinorAdd optional chaining for
feed.pairto match usage elsewhere.Line 403 uses
feed.pair?.length === 2, suggestingpaircan be undefined. This line would throw ifpairis 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
📒 Files selected for processing (4)
src/data-sources/morpho-api/positions.tssrc/hooks/useFeedLastUpdatedByChain.tssrc/hooks/useUserPositions.tssrc/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
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores