Skip to content

feat: add vault history analytics#613

Open
antoncoding wants to merge 5 commits into
masterfrom
codex/vault-history-charts
Open

feat: add vault history analytics#613
antoncoding wants to merge 5 commits into
masterfrom
codex/vault-history-charts

Conversation

@antoncoding

@antoncoding antoncoding commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • add clean native yield, total deposits, vault exposure, and secondary share-price history to vault detail pages
  • use one shared 1D to 6M period control across the analytics section
  • replace the misplaced position-history loading text with an in-card skeleton

Data architecture

  • Morpho Vault V2 history is the primary source for avgApy, totalAssets, and sharePrice
  • Morpho transport and response normalization live in src/data-sources/morpho-api/vault-history.ts
  • archive RPC is only used when Morpho omits deposits or share price, and lives in src/data-sources/rpc/vault-history.ts
  • RPC fallback uses the shared viem client, respects custom RPC configuration, and multicalls totalAssets plus previewRedeem at each historical block
  • React Query orchestration and caching live in src/hooks/queries/useVaultHistoryQuery.ts
  • UI components have no direct Morpho, Monarch, RPC, viem-client, or wagmi reads
  • native yield is hidden when the chain is not supported by the Morpho API

Monarch is not used for these vault series today because cumulative deposit and withdrawal events do not represent historical total assets after accrued yield. Full Monarch support needs historical vault-state snapshots or an equivalent accrued-assets series.

Validation

  • npx ultracite fix
  • npx ultracite check
  • pnpm typecheck
  • pnpm build
  • live Mainnet vault QA at 7D and 6M

Preview

Open any Vault V2 detail route. The expected order is native APR/APY, total deposits, vault exposure over time, market breakdown, then share price.

Summary by CodeRabbit

  • New Features
    • Added vault analytics history charts for native yield, deposits, and share price (including a dedicated share-price view).
    • Introduced compact analytics-period controls to switch chart timeframes.
    • Improved chart resilience by sourcing history from the most relevant provider and falling back when needed.
    • Added consistent skeleton loading states for position and vault exposure charts, with aligned chart titles.
  • Documentation
    • Updated technical documentation to cover the new vault history analytics and how chart data is sourced/derived.

@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
monarch Ready Ready Preview, Comment Jul 21, 2026 2:59pm

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@antoncoding, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 11 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ef67a5bb-b2e6-4aee-9f93-cece08de7185

📥 Commits

Reviewing files that changed from the base of the PR and between 23cd019 and b0da659.

📒 Files selected for processing (6)
  • src/features/positions/components/user-positions-chart.tsx
  • src/features/vault/components/vault-adapter-position-overview.tsx
  • src/features/vault/components/vault-history-charts.tsx
  • src/features/vault/vault-view.tsx
  • src/hooks/usePositionChartTransactions.ts
  • src/hooks/useUserPositionsSummaryData.ts
📝 Walkthrough

Walkthrough

Vault detail analytics now use unified Morpho Vault V2 history with RPC fallbacks. New charts display native yield, deposits, and share price. Position charts gain reusable skeleton loading states and configurable titles.

Changes

Vault history analytics

Layer / File(s) Summary
History data sources
src/graphql/vault-queries.ts, src/data-sources/morpho-api/vault-history.ts, src/data-sources/rpc/vault-history.ts
Adds normalized Morpho history fetching and RPC block reads for deposits and share price.
History query and fallback selection
src/hooks/queries/useVaultHistoryQuery.ts
Caches vault history, scales asset values, and selects Morpho, RPC, or unavailable data per metric.
Vault history charts and period control
src/features/vault/components/vault-history-charts.tsx, src/features/vault/components/vault-analytics-period-control.tsx
Adds metric charts, loading and empty states, rate formatting, share-price domains, and compact period buttons.
Vault analytics integration and documentation
src/features/autovault/vault-view.tsx, src/features/vault/vault-view.tsx, docs/TECHNICAL_OVERVIEW.md
Replaces the former share-price chart, wires analytics timeframe state, and documents the history data flow.

Reusable chart loading states

Layer / File(s) Summary
Chart skeleton and title contract
src/features/positions/components/user-positions-chart.tsx
Adds UserPositionsChartSkeleton and supports configurable chart titles while preserving the existing default.
Loading-state consumers
src/features/position-detail/components/history-tab.tsx, src/features/vault/components/vault-adapter-position-overview.tsx
Uses the shared skeleton for position history and vault exposure loading states.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant VaultView
  participant VaultHistoryCharts
  participant useVaultHistoryQuery
  participant MorphoAPI
  participant ArchiveRPC
  VaultView->>VaultHistoryCharts: render selected vault and period
  VaultHistoryCharts->>useVaultHistoryQuery: request cached history
  useVaultHistoryQuery->>MorphoAPI: fetch Vault V2 historical state
  MorphoAPI-->>useVaultHistoryQuery: native APY and total assets
  useVaultHistoryQuery->>ArchiveRPC: fetch missing deposits or share price
  ArchiveRPC-->>useVaultHistoryQuery: block-based metric series
  useVaultHistoryQuery-->>VaultHistoryCharts: normalized metrics and sources
  VaultHistoryCharts-->>VaultView: render analytics charts
Loading

Possibly related PRs

Suggested labels: feature request, ui

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding vault history analytics.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/vault-history-charts

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.

@coderabbitai coderabbitai Bot added feature request Specific feature ready to be implemented ui User interface labels Jul 21, 2026

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

Copy link
Copy Markdown

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 replaces the single vault share price chart with a comprehensive vault history visualization system. It introduces the 'useVaultHistoryQuery' hook and 'VaultHistoryCharts' component to fetch and display native yield, total deposits, and share price history. Data is primarily retrieved from the Morpho API, with an on-chain archive RPC fallback for total assets and share price. Additionally, it refactors the period selector control, introduces a skeleton loading state for position history charts, and updates the technical documentation. No review comments were provided, so there is no feedback to address.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

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/features/positions/components/user-positions-chart.tsx`:
- Around line 61-71: Update UserPositionsChartSkeleton so its screen-reader
loading announcement incorporates the supplied title prop, keeping the
announcement synchronized with the visible chart heading, including custom
titles passed by VaultAdapterPositionOverview.
🪄 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: dabb6c63-03a2-4028-a7ea-1d23e2668402

📥 Commits

Reviewing files that changed from the base of the PR and between b173698 and 608681c.

📒 Files selected for processing (15)
  • docs/TECHNICAL_OVERVIEW.md
  • src/data-sources/morpho-api/vault-history.ts
  • src/data-sources/morpho-api/vault-share-price-history.ts
  • src/data-sources/rpc/vault-history.ts
  • src/features/autovault/vault-view.tsx
  • src/features/position-detail/components/history-tab.tsx
  • src/features/positions/components/user-positions-chart.tsx
  • src/features/vault/components/vault-adapter-position-overview.tsx
  • src/features/vault/components/vault-analytics-period-control.tsx
  • src/features/vault/components/vault-history-charts.tsx
  • src/features/vault/components/vault-share-price-chart.tsx
  • src/features/vault/vault-view.tsx
  • src/graphql/vault-queries.ts
  • src/hooks/queries/useVaultHistoryQuery.ts
  • src/hooks/useVaultSharePriceHistory.ts
💤 Files with no reviewable changes (3)
  • src/features/vault/components/vault-share-price-chart.tsx
  • src/hooks/useVaultSharePriceHistory.ts
  • src/data-sources/morpho-api/vault-share-price-history.ts

Comment thread src/features/positions/components/user-positions-chart.tsx Outdated
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.

1 participant