feat: vault page#531
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR adds a dedicated Vault page with deposit/withdraw UI, market-hinted and on‑demand market resolution for allocation reads, new allocation/position UI components, and a shared helper to canonicalize Monarch vault links used across navigation and account components. ChangesVault Page Feature
🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels: feature request, ui 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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 |
There was a problem hiding this comment.
Code Review
This pull request introduces a new canonical vault page and refactors vault-related components to utilize targeted market reads, improving performance by avoiding global market registry dependencies. Key updates include the implementation of VaultMarketAllocationsTable for visualizing allocation caps, a new VaultAdapterPositionOverview for detailed market breakdowns, and the standardization of vault navigation via the getMonarchVaultHref utility. Feedback suggests optimizing the vault view to display market breakdowns for empty vaults by enabling empty state visibility and recommends removing an unused variable.
| const { | ||
| positions, | ||
| isPositionsLoading, | ||
| isEarningsLoading, | ||
| loadingStates, | ||
| actualBlockData, | ||
| transactions, | ||
| snapshotsByChain, | ||
| } = useUserPositionsSummaryData(adapterAddress, period, undefined, { | ||
| enabled: hasAdapterPositionTarget && marketHints.length > 0, | ||
| marketHints, | ||
| showEmpty: false, | ||
| }); |
There was a problem hiding this comment.
Scoping the position data fetching to the current chainId and enabling showEmpty ensures that the vault's market breakdown is visible even when the user has no active balance. This provides a better user experience for newly created or empty vaults, preventing a blank state when markets are already configured. Additionally, the unused loadingStates variable has been removed.
const {
positions,
isPositionsLoading,
isEarningsLoading,
actualBlockData,
transactions,
snapshotsByChain,
} = useUserPositionsSummaryData(adapterAddress, period, [chainId], {
enabled: hasAdapterPositionTarget && marketHints.length > 0,
marketHints,
showEmpty: true,
});
References
- Downstream detail-panel empty states must not contradict confirmed parent/header metadata; if a relationship is configured but no child detail exists, hide the optional panel or use neutral child-specific copy.
| return transactions.filter((tx) => tx.data.market && marketKeys.has(tx.data.market.uniqueKey.toLowerCase())); | ||
| }, [currentPosition, transactions]); | ||
| const snapshotChainCount = useMemo(() => Object.keys(snapshotsByChain).length, [snapshotsByChain]); | ||
|
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/components/shared/account-actions-popover.tsx (1)
49-50: ⚡ Quick winUse client-side routing for profile navigation.
Replace
window.location.hrefwith Next router navigation to avoid full page reloads and preserve application state.import { useCallback, type ReactNode } from 'react'; +import { useRouter } from 'next/navigation'; @@ export function AccountActionsPopover({ @@ }: AccountActionsPopoverProps) { + const router = useRouter(); @@ const handleViewAccount = useCallback(() => { - window.location.href = profileHref; - }, [profileHref]); + router.push(profileHref); + }, [profileHref, router]);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/components/shared/account-actions-popover.tsx` around lines 49 - 50, The effect currently forces a full reload by setting window.location.href; replace that with Next's client-side navigation: obtain the router via useRouter() (from 'next/router' for pages-router or 'next/navigation' for app-router) at the top of the component and call router.push(profileHref) inside the effect (keep profileHref in the dependency array). If you choose 'next/navigation' ensure the component is a client component ("use client") and import the correct hook; remove the window.location.href assignment and use router.push(profileHref) instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useVaultAllocations.ts`:
- Around line 150-176: The query currently treats missing or failed
fetchVaultCapMarket results as partial success by skipping failures and
returning nextMarkets; change the queryFn (the useQuery with queryKey
['vault-cap-markets', ...]) so that after Promise.allSettled you inspect results
and if any entry has result.status !== 'fulfilled' or result.value.market is
null/undefined you throw an Error (including the failed marketId(s)) instead of
silently continuing; this will cause the query to be considered failed and
enable refetch/retries. Apply the same pattern to the other similar blocks
referenced (the other useQuery/queryFn sections around the 183-201 and 257-259
ranges) that use fetchVaultCapMarket so they also throw on any rejected or null
responses.
---
Nitpick comments:
In `@src/components/shared/account-actions-popover.tsx`:
- Around line 49-50: The effect currently forces a full reload by setting
window.location.href; replace that with Next's client-side navigation: obtain
the router via useRouter() (from 'next/router' for pages-router or
'next/navigation' for app-router) at the top of the component and call
router.push(profileHref) inside the effect (keep profileHref in the dependency
array). If you choose 'next/navigation' ensure the component is a client
component ("use client") and import the correct hook; remove the
window.location.href assignment and use router.push(profileHref) instead.
🪄 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: a0052628-b710-405b-8eb6-1a5987935529
📒 Files selected for processing (31)
app/vault/[chainId]/[vaultAddress]/page.tsxdocs/VALIDATIONS.mdsrc/components/common/table-container-with-header.tsxsrc/components/shared/account-actions-popover.tsxsrc/components/shared/account-identity.tsxsrc/features/autovault/components/deployment/deployment-context.tsxsrc/features/autovault/components/vault-detail/allocations/allocations/market-view.tsxsrc/features/autovault/components/vault-detail/vault-header.tsxsrc/features/autovault/components/vault-detail/vault-market-allocations.tsxsrc/features/autovault/components/vault-identity.tsxsrc/features/autovault/vault-list-view.tsxsrc/features/autovault/vault-view.tsxsrc/features/history/components/transaction-history-preview.tsxsrc/features/positions/components/account-vault-info.tsxsrc/features/positions/components/allocation-cell.tsxsrc/features/positions/components/user-positions-chart.tsxsrc/features/positions/components/user-vaults-table.tsxsrc/features/positions/components/vault-actions-dropdown.tsxsrc/features/positions/positions-view.tsxsrc/features/vault/components/vault-adapter-position-overview.tsxsrc/features/vault/components/vault-market-allocations-table.tsxsrc/features/vault/vault-view.tsxsrc/hooks/queries/useMarketsQuery.tssrc/hooks/useMorphoMarketAdapters.tssrc/hooks/useProcessedMarkets.tssrc/hooks/useUserPositions.tssrc/hooks/useUserPositionsSummaryData.tssrc/hooks/useVaultAllocations.tssrc/hooks/useVaultPage.tssrc/utils/vaultAllocation.tssrc/utils/vaults.ts
💤 Files with no reviewable changes (3)
- src/features/autovault/components/vault-detail/allocations/allocations/market-view.tsx
- src/features/positions/positions-view.tsx
- src/features/positions/components/user-vaults-table.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/hooks/useVaultAllocations.ts`:
- Around line 75-80: The hook useVaultAllocations currently defaults
includeCollateralAllocations to false but still returns collateralAllocations
(zeroed), which breaks callers; restore the previous behavior by changing the
default of includeCollateralAllocations back to true OR, alternatively, when
includeCollateralAllocations === false omit the collateralAllocations field from
the return value (do not return 0n); update the return construction and the
other occurrence where collateralAllocations is populated (the block around the
collateralAllocations assignment referenced in the comment) so callers only
receive collateralAllocations when includeCollateralAllocations is true.
🪄 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: 96e164f1-c669-420f-b6d7-25b1ebe7f981
📒 Files selected for processing (3)
src/components/shared/account-actions-popover.tsxsrc/features/vault/vault-view.tsxsrc/hooks/useVaultAllocations.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/features/vault/vault-view.tsx
closes #528
Summary by CodeRabbit
New Features
Refactor
Documentation