Skip to content

feat: show oracle vendors#63

Merged
antoncoding merged 6 commits intomasterfrom
feat/oracles
Oct 12, 2024
Merged

feat: show oracle vendors#63
antoncoding merged 6 commits intomasterfrom
feat/oracles

Conversation

@antoncoding
Copy link
Copy Markdown
Owner

@antoncoding antoncoding commented Oct 12, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a new "Oracle" column in market tables, displaying vendor information through the OracleVendorBadge.
    • Added tooltips for enhanced contextual information regarding oracle feeds.
  • Improvements

    • Streamlined rendering logic for oracle feeds, improving clarity and user experience.
    • Enhanced data structure for oracle information, allowing for better organization and retrieval.
  • Bug Fixes

    • Updated warning descriptions for clarity regarding oracle feed routes.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Oct 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
monarch ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 12, 2024 9:23am

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 12, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request enhance various components related to market data by introducing a new "Oracle" column and refining the handling of oracle-related information. Key modifications include the addition of the OracleVendorBadge component, updates to the MarketRowDetail, MarketTableBody, and SuppliedMarketsDetail components to display oracle data, and restructuring of GraphQL queries in the useMarkets and useUserPositions hooks. Additionally, a new utility for parsing oracle vendor data is introduced, improving the organization and presentation of oracle-related information across the application.

Changes

File Path Change Summary
app/markets/components/MarketRowDetail.tsx Updated ExpandedMarketDetail to use oracleData, introduced hasFeeds, renamed "Oracle" to "Vendors", and simplified rendering of oracle feeds with OracleFeedInfo.
app/markets/components/MarketTableBody.tsx Added a new column for OracleVendorBadge, updated colspan, and included oracle.data from the item object.
app/markets/components/marketsTable.tsx Introduced a new "Oracle" column in the MarketsTable header.
app/positions/components/SuppliedMarketsDetail.tsx Added "Oracle" column to the table header and body, integrated OracleVendorBadge with oracleData.
src/components/FeedInfo/OracleFeedInfo.tsx Changed props from address and title to a single feed prop, updated rendering logic to utilize feed structure and added tooltip functionality.
src/components/OracleVendorBadge.tsx Introduced OracleVendorBadge component to display vendor information based on oracleData.
src/hooks/useMarkets.ts Modified GraphQL query structure to include a nested oracle field with MorphoChainlinkOracleData and MorphoChainlinkOracleV2Data.
src/hooks/useUserPositions.ts Updated GraphQL query to replace oracleFeed with a new oracle field containing detailed oracle information.
src/utils/oracle.ts Added utility functions and types for handling oracle vendor data, including parseOracleVendors and OracleVendorIcons.
src/utils/types.ts Enhanced MarketPosition and Market types with new oracle properties and introduced OracleFeed and MorphoChainlinkOracleData types.
src/utils/warnings.ts Updated descriptions in morphoOfficialWarnings for clarity regarding oracle feed warnings.
src/components/TokenIcon.tsx Minor formatting change; removed an empty line within the TokenIcon function.

Possibly related PRs

  • feat: rebalance #57: Introduces the OracleVendorBadge component, which is directly related to the modifications in the MarketRowDetail.tsx and MarketTableBody.tsx files where the OracleVendorBadge is utilized to display vendor information.
  • feat: new position page #59: Enhances the PositionsSummaryTable component, which includes the integration of warning indicators and a new structure for displaying market positions. The updates to the SuppliedMarketsDetail.tsx component in the main PR also involve displaying oracle-related information, linking the two PRs through their focus on market data presentation and warnings.

🎉 In the land of markets, where data flows,
New badges and columns, the oracle shows.
With vendors now shining, and feeds all aligned,
The updates are here, oh what a find!
Tooltip whispers, insights to share,
In the world of finance, we’re better prepared! 🌟


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 8b1df59 and dff3ee2.

📒 Files selected for processing (5)
  • app/markets/components/MarketRowDetail.tsx (1 hunks)
  • src/components/FeedInfo/OracleFeedInfo.tsx (1 hunks)
  • src/components/OracleVendorBadge.tsx (1 hunks)
  • src/hooks/useMarkets.ts (2 hunks)
  • src/hooks/useUserPositions.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • app/markets/components/MarketRowDetail.tsx
  • src/hooks/useUserPositions.ts
🧰 Additional context used
🔇 Additional comments (9)
src/components/FeedInfo/OracleFeedInfo.tsx (4)

13-20: Props refactored, good job.

Simplified interface with feed prop. Null check added.


22-26: Data handling improved.

Good use of default values and vendor icon selection.


28-41: Content rendering separated.

Good use of icons. Improved readability.


43-58: Tooltip added, past issue fixed.

Hardcoded content replaced with dynamic data. Good job.

src/components/OracleVendorBadge.tsx (3)

1-11: Imports and type definition look good.

Imports and type definition are appropriate for the component's functionality.


13-17: Good job extracting renderVendorIcon function.

The function is concise and handles cases where vendor icon is not available. This addresses the suggestion from the previous review.


19-68: OracleVendorBadge component is well-implemented.

The component handles different scenarios effectively, using conditional rendering and structured tooltip content.

src/hooks/useMarkets.ts (2)

Line range hint 28-91: Good job on the query refactor.

The new FeedFields fragment and updated oracle structure look good. You've addressed the duplication issue nicely.


Line range hint 92-230: Hook implementation looks fine.

The useMarkets hook seems to handle the new oracle data structure correctly. No issues found.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Outside diff range and nitpick comments (4)
src/components/OracleVendorBadge.tsx (1)

41-68: Tooltip implementation and export look good.

Consider memoizing the tooltip content for performance in larger renders.

Example:

const tooltipContent = React.useMemo(() => (
  <div className="m-2">
    {/* ... existing tooltip content ... */}
  </div>
), [vendors]);

// Then in the JSX:
<Tooltip content={tooltipContent} className="rounded-sm">
  {content}
</Tooltip>
app/positions/components/SuppliedMarketsDetail.tsx (1)

169-173: New Oracle data cell added.

Oracle data cell looks good. Consider adding a fallback for missing oracle data.

 <td data-label="Oracle" className="text-center">
   <div className="flex justify-center">
-    <OracleVendorBadge oracleData={position.market.oracle.data} useTooltip />
+    {position.market.oracle.data ? (
+      <OracleVendorBadge oracleData={position.market.oracle.data} useTooltip />
+    ) : (
+      'N/A'
+    )}
   </div>
 </td>
src/utils/types.ts (2)

61-63: Simplify the oracle property structure

Is the data field necessary? You could directly define oracle: MorphoChainlinkOracleData;.


330-332: Consider simplifying the oracle property

As with the earlier suggestion, you might define oracle: MorphoChainlinkOracleData; without the data wrapper.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between ea6ea60 and 8b1df59.

⛔ Files ignored due to path filters (5)
  • src/imgs/oracles/chainlink.png is excluded by !**/*.png
  • src/imgs/oracles/lido.png is excluded by !**/*.png
  • src/imgs/oracles/pyth.png is excluded by !**/*.png
  • src/imgs/oracles/redstone.png is excluded by !**/*.png
  • src/imgs/oracles/uma.png is excluded by !**/*.png
📒 Files selected for processing (12)
  • app/markets/components/MarketRowDetail.tsx (1 hunks)
  • app/markets/components/MarketTableBody.tsx (3 hunks)
  • app/markets/components/marketsTable.tsx (1 hunks)
  • app/positions/components/SuppliedMarketsDetail.tsx (4 hunks)
  • src/components/FeedInfo/OracleFeedInfo.tsx (1 hunks)
  • src/components/OracleVendorBadge.tsx (1 hunks)
  • src/components/TokenIcon.tsx (0 hunks)
  • src/hooks/useMarkets.ts (1 hunks)
  • src/hooks/useUserPositions.ts (1 hunks)
  • src/utils/oracle.ts (1 hunks)
  • src/utils/types.ts (3 hunks)
  • src/utils/warnings.ts (2 hunks)
💤 Files with no reviewable changes (1)
  • src/components/TokenIcon.tsx
🧰 Additional context used
🔇 Additional comments (20)
src/utils/oracle.ts (3)

1-6: Import and type look good.

Clean import and clear type definition.


8-16: Enum covers known vendors.

Good inclusion of 'Unknown' for handling unexpected cases.


28-36: Good input handling.

Null and empty checks prevent errors.

src/components/OracleVendorBadge.tsx (2)

1-11: Imports and type definition look good.

Clean imports and clear type definition.


13-16: Component setup is solid.

Good use of utility function and early checks.

src/utils/warnings.ts (3)

8-8: Good update.

Expanded description covers more cases.


14-14: Nice clarification.

More precise about multiple feed routes.


95-95: Good formatting.

Improved readability.

app/markets/components/marketsTable.tsx (1)

65-65: New Oracle column added.

The change looks good. Ensure MarketTableBody is updated to populate this column.

✅ Verification successful

Oracle column rendering confirmed.

The "Oracle" column is populated using OracleVendorBadge and MarketOracleIndicator components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check if MarketTableBody component renders Oracle data
ast-grep --lang typescript --pattern 'function MarketTableBody($$$) {
  $$$
  <td>$_oracle$_</td>
  $$$
}'

Length of output: 108


Script:

#!/bin/bash
# Search for Oracle column rendering in MarketTableBody component
rg '<td\s*>Oracle\s*</td>' app/markets/components/marketsTable.tsx

Length of output: 68


Script:

#!/bin/bash
# Search for any references to 'Oracle' within MarketTableBody component
rg 'Oracle' app/markets/components/MarketTableBody.tsx

Length of output: 408

app/markets/components/MarketTableBody.tsx (3)

7-7: Import looks good.

New OracleVendorBadge import added correctly.


120-124: New Oracle column added correctly.

OracleVendorBadge component used with proper data.


183-183: Colspan updated correctly.

Expanded row now spans full table width, including new Oracle column.

app/positions/components/SuppliedMarketsDetail.tsx (3)

5-5: New import added.

Import for OracleVendorBadge looks good.


103-103: New Oracle column added.

Oracle column in table header is correct.


116-117: Calculation reformatted.

Improved readability of percentageOfPortfolio calculation.

src/components/FeedInfo/OracleFeedInfo.tsx (1)

14-19: Update usages of OracleFeedInfo to match the new signature

The function now accepts feed instead of address and title. Ensure all components using OracleFeedInfo are updated accordingly.

Run the following script to find usages with old props:

✅ Verification successful

All usages of OracleFeedInfo have been updated to the new signature. No instances with old props found.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Find usages of `OracleFeedInfo` with old props 'address' and 'title'.

# Expectation: No matches should be found.

rg --type tsx --type jsx 'OracleFeedInfo\s*.*address\s*=.*title\s*='

Length of output: 98


Script:

#!/bin/bash
# Description: Find usages of `OracleFeedInfo` with old props 'address' and 'title'.

# Expectation: No matches should be found.

rg -g '*.tsx' -g '*.jsx' 'OracleFeedInfo\s*.*address\s*=.*title\s*='

Length of output: 70

app/markets/components/MarketRowDetail.tsx (1)

1-5: Imports are correctly added

src/utils/types.ts (2)

249-259: OracleFeed type definition is correct


261-266: MorphoChainlinkOracleData type looks good

src/hooks/useMarkets.ts (1)

50-136: Verify that the new oracle data is used correctly

Ensure that the application logic properly handles the new oracle data structure. Check if components or functions consuming this data are updated accordingly.

Run this script to find usages of the oracle fields:

Comment thread src/utils/oracle.ts Outdated
Comment thread src/utils/oracle.ts
Comment thread src/components/OracleVendorBadge.tsx
Comment thread src/components/FeedInfo/OracleFeedInfo.tsx Outdated
Comment thread app/markets/components/MarketRowDetail.tsx Outdated
Comment thread app/markets/components/MarketRowDetail.tsx
Comment thread src/hooks/useUserPositions.ts Outdated
Comment thread src/hooks/useMarkets.ts
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