Skip to content

feat: vault page#531

Merged
antoncoding merged 7 commits into
masterfrom
feat/vault
May 18, 2026
Merged

feat: vault page#531
antoncoding merged 7 commits into
masterfrom
feat/vault

Conversation

@antoncoding
Copy link
Copy Markdown
Owner

@antoncoding antoncoding commented May 18, 2026

closes #528

Summary by CodeRabbit

  • New Features

    • Vault detail pages with improved metadata and Monarch vault links
    • Market allocations table and a vault adapter position overview
    • Enhanced transaction/position previews with scoped market support
  • Refactor

    • Navigation updated to use canonical Monarch vault routes
    • Market/allocations fetching and loading behavior streamlined
    • Component props/contracts adjusted for clearer vault/profile flows
  • Documentation

    • Added validation rules for vault pages and UI linking

Review Change Stack

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 18, 2026

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

Project Deployment Actions Updated (UTC)
monarch Ready Ready Preview, Comment May 18, 2026 3:56pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Rate limit exceeded

@antoncoding has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 41 minutes and 44 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 812a93d7-97c7-4620-90d6-19e8f1189645

📥 Commits

Reviewing files that changed from the base of the PR and between 4b75570 and d9d0494.

📒 Files selected for processing (4)
  • src/features/autovault/components/vault-detail/vault-header.tsx
  • src/hooks/useVaultAllocations.ts
  • src/hooks/useVaultV2.ts
  • src/modals/vault/vault-withdraw-modal.tsx
📝 Walkthrough

Walkthrough

This 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.

Changes

Vault Page Feature

Layer / File(s) Summary
Vault routing helper and navigation updates
src/utils/vaults.ts, src/features/autovault/components/deployment/deployment-context.tsx, src/features/autovault/vault-list-view.tsx, src/features/autovault/components/vault-identity.tsx, src/features/positions/components/vault-actions-dropdown.tsx, src/features/positions/components/account-vault-info.tsx
New getMonarchVaultHref(chainId, address) generates Monarch vault URLs; vault navigation and vault-link rendering updated across deployment, list view, identity, actions dropdown, and account-vault info.
Market hints and query enabling infrastructure
src/hooks/useUserPositions.ts, src/hooks/useUserPositionsSummaryData.ts, src/hooks/queries/useMarketsQuery.ts, src/hooks/useProcessedMarkets.ts, src/hooks/useVaultAllocations.ts
Adds UserPositionMarketHint and options to support targeted market reads; introduces options.enabled gating in market hooks; refactors useVaultAllocations to fetch required markets on-demand with Monarch→Morpho→Subgraph fallback.
Vault page hook and APY computation
src/hooks/useVaultPage.ts
vaultAPY now computed from allocation data and token decimals; vault24hEarnings set to null; APY loading follows allocations query.
Account actions and identity vault routing
src/components/shared/account-actions-popover.tsx, src/components/shared/account-identity.tsx
AccountActionsPopover accepts profileHref/profileLabel and navigates via router; AccountIdentity derives Monarch vault profile links for vault‑v2 identities and passes them to action popovers across variants.
Transaction history preview with markets prop
src/features/history/components/transaction-history-preview.tsx
TransactionHistoryPreview accepts optional markets and marketsLoading (replaces isVaultAdapter), scopes transaction queries to provided markets, and replaces the hover-animated "Details" link with a compact Button+Link UI and unified preview loading.
Vault market allocations table and adapter position overview
src/features/vault/components/vault-market-allocations-table.tsx, src/features/vault/components/vault-adapter-position-overview.tsx
Adds VaultMarketAllocationsTable (summary/position modes, cap display, realized/earned fields) and VaultAdapterPositionOverview (period selector, grouped chart, market breakdown).
Main vault page with header, position detail, and modals
src/features/vault/vault-view.tsx, app/vault/[chainId]/[vaultAddress]/page.tsx
New VaultContent client page wiring route params, vault hooks, deposit/withdraw modals, adapter-position detail using market hints, transaction history preview with filtered markets, error/loading states, and Next.js page metadata export.
Vault header enhancements, allocation utilities, and supporting changes
src/features/autovault/components/vault-detail/vault-header.tsx, src/utils/vaultAllocation.ts, src/features/autovault/components/vault-detail/vault-market-allocations.tsx, src/components/common/table-container-with-header.tsx, src/features/positions/components/allocation-cell.tsx, src/features/positions/components/user-positions-chart.tsx, docs/VALIDATIONS.md
VaultHeader extended with sentinels/owner/adapters/morphoHref/showWithdrawWhenEmpty; Withdraw rendering/disabled logic adjusted; Sentinels section added; MarketView removed in favor of new table; adds RELATIVE_CAP_SCALE, parseRelativeCap, formatVaultAbsoluteCap; table header styling and validations updated.

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • antoncoding/monarch#481: Modifies src/hooks/useProcessedMarkets.ts and supplying-vault metadata merging, directly related to market data pipeline changes.
  • antoncoding/monarch#77: Refactors useUserPositions.ts position query shape, overlapping with market-hints and query key changes.
  • antoncoding/monarch#327: Changes table/header components; overlaps with header styling and container updates used here.

Suggested labels: feature request, ui

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning Most changes support vault page delivery, but several refactors appear tangential: AccountActionsPopover customization, AccountIdentity profile navigation updates, and table styling changes extend beyond the vault page scope. Review and clarify whether AccountActionsPopover profile routing, AccountIdentity vault linking, and table styling changes are prerequisites for the vault page or separate improvements.
Docstring Coverage ⚠️ Warning Docstring coverage is 22.58% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: vault page' accurately describes the main change—adding a new vault page feature. It's concise, clear, and directly reflects the primary deliverable.
Linked Issues check ✅ Passed The PR implements the core requirements: a dedicated vault page for deposit/withdraw flows, reusing autovault components and hooks as specified in issue #528.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/vault

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 May 18, 2026
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +111 to +123
const {
positions,
isPositionsLoading,
isEarningsLoading,
loadingStates,
actualBlockData,
transactions,
snapshotsByChain,
} = useUserPositionsSummaryData(adapterAddress, period, undefined, {
enabled: hasAdapterPositionTarget && marketHints.length > 0,
marketHints,
showEmpty: false,
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

high

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
  1. 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]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The snapshotChainCount variable is calculated but never used within the component. It should be removed to keep the code clean and avoid unnecessary computation.

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

🧹 Nitpick comments (1)
src/components/shared/account-actions-popover.tsx (1)

49-50: ⚡ Quick win

Use client-side routing for profile navigation.

Replace window.location.href with 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

📥 Commits

Reviewing files that changed from the base of the PR and between 01e7f43 and 39edf4f.

📒 Files selected for processing (31)
  • app/vault/[chainId]/[vaultAddress]/page.tsx
  • docs/VALIDATIONS.md
  • src/components/common/table-container-with-header.tsx
  • src/components/shared/account-actions-popover.tsx
  • src/components/shared/account-identity.tsx
  • src/features/autovault/components/deployment/deployment-context.tsx
  • src/features/autovault/components/vault-detail/allocations/allocations/market-view.tsx
  • src/features/autovault/components/vault-detail/vault-header.tsx
  • src/features/autovault/components/vault-detail/vault-market-allocations.tsx
  • src/features/autovault/components/vault-identity.tsx
  • src/features/autovault/vault-list-view.tsx
  • src/features/autovault/vault-view.tsx
  • src/features/history/components/transaction-history-preview.tsx
  • src/features/positions/components/account-vault-info.tsx
  • src/features/positions/components/allocation-cell.tsx
  • src/features/positions/components/user-positions-chart.tsx
  • src/features/positions/components/user-vaults-table.tsx
  • src/features/positions/components/vault-actions-dropdown.tsx
  • src/features/positions/positions-view.tsx
  • src/features/vault/components/vault-adapter-position-overview.tsx
  • src/features/vault/components/vault-market-allocations-table.tsx
  • src/features/vault/vault-view.tsx
  • src/hooks/queries/useMarketsQuery.ts
  • src/hooks/useMorphoMarketAdapters.ts
  • src/hooks/useProcessedMarkets.ts
  • src/hooks/useUserPositions.ts
  • src/hooks/useUserPositionsSummaryData.ts
  • src/hooks/useVaultAllocations.ts
  • src/hooks/useVaultPage.ts
  • src/utils/vaultAllocation.ts
  • src/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

Comment thread src/hooks/useVaultAllocations.ts
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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 39edf4f and 4b75570.

📒 Files selected for processing (3)
  • src/components/shared/account-actions-popover.tsx
  • src/features/vault/vault-view.tsx
  • src/hooks/useVaultAllocations.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/features/vault/vault-view.tsx

Comment thread src/hooks/useVaultAllocations.ts
@antoncoding antoncoding merged commit 31157e2 into master May 18, 2026
4 checks passed
@antoncoding antoncoding deleted the feat/vault branch May 18, 2026 15:58
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.

feat: support deposit to vaults

1 participant