Skip to content

feat: new position page#59

Merged
antoncoding merged 5 commits intomasterfrom
feat/new-positions
Oct 11, 2024
Merged

feat: new position page#59
antoncoding merged 5 commits intomasterfrom
feat/new-positions

Conversation

@antoncoding
Copy link
Owner

@antoncoding antoncoding commented Oct 11, 2024

  • Show warnings in your aggregated position
  • Show collateral icon, put exposure graph in expanded area

Summary by CodeRabbit

Release Notes

  • New Features

    • Dynamic "View Portfolio" button now incorporates user address for personalized navigation.
    • Added WarningTooltip component to display categorized warnings in market details.
    • Introduced TokenIcon component for visual representation of assets.
  • Improvements

    • Enhanced styling for toast notifications.
    • Updated header text in the Positions component from "Your Supplies" to "Portfolio."
    • Improved PositionsSummaryTable with new columns for asset sizes and warnings.
    • Enhanced warning management system in PositionsSummaryTable.
  • Bug Fixes

    • Corrected naming inconsistencies in risk indicators.
  • Documentation

    • Updated warning messages for clarity and conciseness.

@vercel
Copy link
Contributor

vercel bot commented Oct 11, 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 11, 2024 9:53am

@coderabbitai
Copy link

coderabbitai bot commented Oct 11, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes in this pull request involve multiple components across the application. Key modifications include the integration of user account data into the HomePage, enhancements to the PositionsSummaryTable and SuppliedMarketsDetail components for better warning management, and the introduction of a new TokenIcon component. Additionally, various types have been modified to include detailed warning information. Overall, these changes improve the user interface and functionality related to market positions and warnings.

Changes

File Change Summary
app/home/HomePage.tsx Added useAccount import, extracted address for dynamic "View Portfolio" button link.
app/layout.tsx Added bodyClassName prop to ToastContainer for styling.
app/markets/components/RiskIndicator.tsx Updated RiskIndicatorFromWarning to use WarningWithDetail, added isBatched parameter, corrected greeDescription to greenDescription, and modified return logic based on warnings.
app/positions/components/PositionsContent.tsx Changed header text from "Your Supplies" to "Portfolio".
app/positions/components/PositionsSummaryTable.tsx Added TokenIcon, updated header labels, modified rendering logic to include warnings, and adjusted processedPositions logic.
app/positions/components/SuppliedMarketsDetail.tsx Introduced WarningTooltip, updated table headers, added percentage calculation for portfolio, and improved styling and rendering logic for collateral assets.
src/components/TokenIcon.tsx Introduced new TokenIcon component for displaying token images based on address and chain ID.
src/hooks/useUserPositions.ts Enhanced fetchData to include warningsWithDetail in market positions.
src/utils/types.ts Added warningsWithDetail to MarketPosition, renamed warningsWithDetail to allWarnings in GroupedPosition.
src/utils/warnings.ts Simplified the description for the low_liquidity warning in morphoOfficialWarnings.

Possibly related PRs

  • feat: rebalance #57: This PR integrates user account data into the HomePage, relevant to the rebalance feature introduced in PR feat: rebalance #57 that also utilizes user account information for managing market positions and rebalancing actions.

🎉 In the code we dance and play,
New features bloom, bright as the day!
With warnings clear and icons bright,
Our app shines on, a pure delight!
From homes to markets, all in sync,
Together we build, together we think! 🌟


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

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

🧹 Outside diff range and nitpick comments (4)
app/layout.tsx (1)

36-36: Good font choice for toasts.

Adding font-zen to toasts matches app style. Consider moving font classes to a constant for consistency.

app/home/HomePage.tsx (1)

55-55: Good dynamic link.

Uses address in href. Consider adding a loading state or disabling the button when address is undefined.

src/components/layout/header/Navbar.tsx (1)

79-80: Good change, small tweak needed

The dynamic route for positions is good. Consider adding a fallback for when address is empty.

Try this:

-<NavbarLink href={`/positions/${address ?? ''}`} matchKey="positions">
+<NavbarLink href={`/positions/${address || 'connect'}`} matchKey="positions">
app/positions/components/PositionsSummaryTable.tsx (1)

136-136: Remove debug console.log statement.

Consider removing this debug statement.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f034e50 and e4839e4.

📒 Files selected for processing (11)
  • app/home/HomePage.tsx (3 hunks)
  • app/layout.tsx (1 hunks)
  • app/markets/components/RiskIndicator.tsx (2 hunks)
  • app/positions/components/PositionsContent.tsx (1 hunks)
  • app/positions/components/PositionsSummaryTable.tsx (7 hunks)
  • app/positions/components/SuppliedMarketsDetail.tsx (3 hunks)
  • src/components/TokenIcon.tsx (1 hunks)
  • src/components/layout/header/Navbar.tsx (1 hunks)
  • src/hooks/useUserPositions.ts (3 hunks)
  • src/utils/types.ts (2 hunks)
  • src/utils/warnings.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/positions/components/PositionsContent.tsx
🧰 Additional context used
🔇 Additional comments (19)
src/components/TokenIcon.tsx (2)

1-10: Imports and type definition look good.


12-14: Component function looks correct.

app/home/HomePage.tsx (2)

4-4: Good import.

Adds useAccount from wagmi. Needed for new feature.


20-21: Correct hook usage.

Extracts address from useAccount. Good placement.

src/components/layout/header/Navbar.tsx (1)

84-85: Looks good

The markets link update is correct and matches the PR objectives.

src/utils/warnings.ts (1)

83-83: Good change.

Simpler warning. Clearer for users.

src/utils/types.ts (1)

61-61: Good addition.

Adds detailed warnings to MarketPosition. Matches PR goals.

app/markets/components/RiskIndicator.tsx (5)

2-2: Import is correctly updated


25-56: 'RiskIndicatorFromWarning' function changes look good

The addition of 'isBatched' parameter and the adjusted descriptions are proper.


59-73: 'MarketAssetIndicator' function updates are valid


78-92: 'MarketOracleIndicator' function updates are valid


97-111: 'MarketDebtIndicator' function updates are valid

src/hooks/useUserPositions.ts (2)

5-6: Necessary imports added.

The required types and functions are imported.


87-91: GraphQL query updated with 'warnings'.

The 'warnings' field and its attributes are correctly added.

app/positions/components/PositionsSummaryTable.tsx (5)

64-64: Efficient aggregation of warnings.

Good use of Set to deduplicate warnings.

Also applies to: 71-75


193-196: Table headers updated appropriately.

Headers match the new data presentation.


222-232: Rendering TokenIcon for loan assets looks good.

Displays asset icons effectively.


237-253: Displaying collateral TokenIcons is well implemented.

Collaterals are correctly shown with icons.


255-267: Check market prop in RiskIndicator components.

Verify that passing { warningsWithDetail: position.allWarnings } satisfies the expected market prop requirements.

Run the following script to check the expected properties:

✅ Verification successful

Verified market prop in RiskIndicator components.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check the required properties for the 'market' prop in RiskIndicator components.

# Test: Search for the type definition of the 'market' prop in 'MarketAssetIndicator'.

rg --type tsx 'function MarketAssetIndicator' -A 10

Length of output: 81


Script:

#!/bin/bash
# Description: Check the required properties for the 'market' prop in RiskIndicator components.

# Test: Search for the type definition of the 'market' prop in 'MarketAssetIndicator'.

rg 'function MarketAssetIndicator' --glob '*.tsx' -A 10

Length of output: 768


Script:

#!/bin/bash
# Description: Find the type definition of 'allWarnings'

rg 'allWarnings\s*:' --glob '*.tsx' -A 5

Length of output: 520

Copy link

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

🧹 Outside diff range and nitpick comments (2)
app/positions/components/SuppliedMarketsDetail.tsx (2)

17-36: WarningTooltip component looks good.

Consider memoizing the component for performance if it's used frequently.

const WarningTooltip = React.memo(({ warnings }: { warnings: WarningWithDetail[] }) => {
  // ... existing code ...
});

58-96: Collateral exposure visualization is well-implemented.

Consider adding aria labels for better accessibility.

Example:

<div
  aria-label={`${collateral.symbol}: ${collateral.percentage.toFixed(2)}% of collateral`}
  // ... existing props ...
/>
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between e4839e4 and 4e4485f.

📒 Files selected for processing (5)
  • app/positions/components/SuppliedMarketsDetail.tsx (3 hunks)
  • src/components/TokenIcon.tsx (1 hunks)
  • src/hooks/useUserPositions.ts (3 hunks)
  • src/utils/types.ts (2 hunks)
  • src/utils/warnings.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/TokenIcon.tsx
  • src/hooks/useUserPositions.ts
  • src/utils/types.ts
  • src/utils/warnings.ts
🧰 Additional context used
🔇 Additional comments (5)
app/positions/components/SuppliedMarketsDetail.tsx (5)

2-2: Imports look good.

New imports align with added features.

Also applies to: 4-5, 8-8


51-55: getWarningColor function is clear and effective.

Good use of priority-based color assignment.


100-100: Table header changes improve clarity.

"Market" and "% of Portfolio" are more descriptive.

Also applies to: 105-105


114-115: Percentage calculation and warning display are well-implemented.

Good job handling the zero totalSupply case and adding the warning tooltip.

Also applies to: 119-149


154-159: TokenIcon and portfolio percentage visualization look great.

Improves visual representation of data.

Also applies to: 175-186

@antoncoding antoncoding merged commit ea6ea60 into master Oct 11, 2024
@antoncoding antoncoding deleted the feat/new-positions branch October 11, 2024 09:55
This was referenced Dec 8, 2024
@coderabbitai coderabbitai bot mentioned this pull request Dec 19, 2024
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 20, 2025
@coderabbitai coderabbitai bot mentioned this pull request Sep 6, 2025
@coderabbitai coderabbitai bot mentioned this pull request Oct 13, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 9, 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