Skip to content

Add 90-day APY component to historical APY calculation#329

Open
matheus1lva wants to merge 1 commit intomainfrom
feat/add-90-apy
Open

Add 90-day APY component to historical APY calculation#329
matheus1lva wants to merge 1 commit intomainfrom
feat/add-90-apy

Conversation

@matheus1lva
Copy link
Collaborator

@matheus1lva matheus1lva commented Jan 31, 2026

Summary

Adds a 90-day (quarterly) APY component to the historical APY calculation system, providing users with a medium-term performance view alongside the existing weekly, monthly, and inception metrics. This fills the gap between monthly (30-day) and inception timeframes for better vault performance analysis.

Closes #259

How to review

  1. Start with the calculation logic: Review packages/ingest/abis/yearn/lib/apy.ts to see how quarterly APY follows the same pattern as weekly/monthly
  2. Check the schema changes: Verify the Zod schema includes quarterlyNet, quarterlyPricePerShare, and quarterlyBlockNumber
  3. Review API exposure: Check GraphQL (packages/web/app/api/gql/typeDefs/vault.ts) and REST API (packages/web/app/api/rest/list/db.ts) schema updates
  4. Verify test coverage: Look at packages/ingest/abis/yearn/lib/apy.spec.ts for test assertions including edge case handling

The changes are purely additive — no existing functionality is modified.

Test plan

  • Automated: All existing tests updated with quarterly APY assertions
    • Run: `bun --filter ingest test`
    • Tests verify calculation correctness and edge case (vault age < 90 days returns undefined)
  • Manual: Verified with production data from vault 0xdA816459F1AB5631232FE5e97a05BBBb94970c95 (yvDAI)
    • Query: `SELECT component, value FROM output WHERE chain_id = 1 AND address = '0xdA816459F1AB5631232FE5e97a05BBBb94970c95' AND label = 'apy-bwd-delta-pps' AND component LIKE 'quarterly%'`
    • Confirmed quarterlyNet, quarterlyPricePerShare, and quarterlyBlockNumber are calculated correctly
{
  "data": {
    "vault": {
      "performance": {
        "historical": {
          "quarterlyNet": 0.04043234856505595
        }
      }
    }
  }
}

through gql

Risk / impact

Low risk — This change follows the exact same pattern as existing weekly and monthly APY calculations:

  • Uses the same `compoundAndAnnualizeDelta` function for consistency
  • Handles edge cases identically (returns undefined when vault age < 90 days)
  • Only adds new fields, doesn't modify existing calculations
  • No database migrations required (outputs stored in existing `output` table)

Rollback: If issues arise, the quarterly fields can be safely ignored by clients — existing weekly/monthly/inception APY remain unchanged.

Add quarterly APY metrics to provide medium-term vault performance view:
- Add quarterlyNet, quarterlyPricePerShare, quarterlyBlockNumber fields
- Implement 90-day calculation logic following existing patterns
- Store quarterly components in database output
- Expose quarterly fields in GraphQL and REST APIs
- Handle edge case for vaults younger than 90 days (returns undefined)
- Add test coverage for quarterly APY calculations
@vercel
Copy link

vercel bot commented Jan 31, 2026

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

Project Deployment Actions Updated (UTC)
kong Ready Ready Preview, Comment Jan 31, 2026 3:48pm

Request Review

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.

Add 90-day APY Component to Historical APY Calculation

1 participant