feat: add apr / apy in position view#367
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughIntroduces period-based APY calculation for vaults by adding a new Changes
Sequence DiagramsequenceDiagram
actor User
participant positionsView as positions-view<br/>(Component)
participant useVaultHistoricalApy as useVaultHistoricalApy<br/>(Hook)
participant RPC as RPC Endpoints<br/>(Block Data & Multicalls)
participant userVaultsTable as user-vaults-table<br/>(Component)
User->>positionsView: Select earnings period
activate positionsView
positionsView->>useVaultHistoricalApy: Call with vaults + period
activate useVaultHistoricalApy
useVaultHistoricalApy->>RPC: Fetch current blocks per chain
RPC-->>useVaultHistoricalApy: Current block numbers & timestamps
useVaultHistoricalApy->>useVaultHistoricalApy: Estimate past blocks<br/>(timestamp - period)
useVaultHistoricalApy->>RPC: Fetch timestamps for past blocks
RPC-->>useVaultHistoricalApy: Past block timestamps
useVaultHistoricalApy->>RPC: Multicall current share prices<br/>(convertToAssets per network)
RPC-->>useVaultHistoricalApy: Current share prices
useVaultHistoricalApy->>RPC: Multicall past share prices<br/>(at estimated blocks)
RPC-->>useVaultHistoricalApy: Past share prices
useVaultHistoricalApy->>useVaultHistoricalApy: Calculate APY per vault<br/>(price ratio ^ time factor - 1)
useVaultHistoricalApy-->>positionsView: Map of vault → {actualApy}
deactivate useVaultHistoricalApy
positionsView->>positionsView: Merge actualApy into vault objects
positionsView->>userVaultsTable: Render with period + vaults
activate userVaultsTable
userVaultsTable->>User: Display period label + APY + tooltip
deactivate userVaultsTable
deactivate positionsView
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Important Action Needed: IP Allowlist UpdateIf your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:
Reviews will stop working after February 8, 2026 if the new IP is not added to your allowlist. 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 |
starksama
left a comment
There was a problem hiding this comment.
✅ LGTM
Changes reviewed:
-
New hook — Clean implementation with proper multicall batching per network. Good use of
useMemofor stable query keys and network grouping. -
Extended types —
actualApy,avgCapital,effectiveTimeproperly added toMarketPositionWithEarningsand propagated through. -
Risk indicators removal — Clean deletion of
vault-risk-indicators.tsxand corresponding imports/usage. -
UI updates — Period labels (1D/7D/30D) consistent across both vault and grouped tables. Loading states with PulseLoader are nice.
Minor observations (non-blocking):
- The
formatRatehelper inuser-vaults-table.tsxis clean — could potentially be extracted to utils if reused elsewhere later. colSpanupdated from 10→7 in grouped table matches the removed columns.
Ship it 🚀
starksama
left a comment
There was a problem hiding this comment.
✅ LGTM
Changes reviewed:
-
New useVaultHistoricalApy hook — Clean implementation with proper multicall batching per network. Good use of useMemo for stable query keys and network grouping.
-
Extended types — actualApy, avgCapital, effectiveTime properly added to MarketPositionWithEarnings and propagated through.
-
Risk indicators removal — Clean deletion of vault-risk-indicators.tsx and corresponding imports/usage.
-
UI updates — Period labels (1D/7D/30D) consistent across both vault and grouped tables. Loading states with PulseLoader are nice.
Minor observations (non-blocking):
- The formatRate helper in user-vaults-table.tsx is clean — could potentially be extracted to utils if reused elsewhere later.
- colSpan updated from 10→7 in grouped table matches the removed columns.
Ship it 🚀
Summary by CodeRabbit
New Features
UI Updates