Skip to content

Add strategy estimated apr breakdown to yvusd#361

Open
matheus1lva wants to merge 4 commits intomainfrom
codex/update-yvusd-apr-fetch-logic
Open

Add strategy estimated apr breakdown to yvusd#361
matheus1lva wants to merge 4 commits intomainfrom
codex/update-yvusd-apr-fetch-logic

Conversation

@matheus1lva
Copy link
Collaborator

@matheus1lva matheus1lva commented Mar 11, 2026

Summary

This PR fixes strategy-level estimated APR hydration for yvUSD snapshots by making the ingest pipeline derive the APR label from the vault first and then query each strategy with that same label.

What changed

  • packages/ingest/abis/yearn/3/vault/snapshot/hook.ts

    • Uses vault estimated APR type (performance.estimated.type) as the source label for strategy estimated APR lookups.
    • Fetches strategy estimated APR per strategy address using that vault-derived label.
    • Makes strategy snapshot joins case-insensitive so composition metadata (name, latestReportApr, existing performance) resolves reliably.
    • Avoids defaulting strategy performance to {} when no data exists.
  • packages/ingest/helpers/apy-apr.ts

    • Fixes getLatestEstimatedAprV3 label filtering logic:
      • exact label when provided
      • LIKE '%-estimated-apr' when not provided
    • Uses case-insensitive address matching.
  • packages/web/app/api/rest/snapshot/db.ts

    • Adds read-time enrichment fallback for strategy estimated APR on REST snapshots by mapping vault output label rows to composition strategy addresses.

Why

yvusd-estimated-apr is emitted relative to vault context and must be consistently resolved before strategy-level lookups. Without this, composition could return missing strategy APR, Unknown names, empty performance objects, and null latest report APR due to snapshot row mismatch.

Manual Testing

1) Configure focused local indexing input

Create/update your local config override with the following exact content (or equivalent merged config):

cron:
  - name: AbiFanout
    queue: fanout
    job: abis
    schedule: '*/15 * * * *'
    start: false

abis:
  - abiPath: 'yearn/3/vault'
    sources: [
      { chainId: 1, address: '0x696d02Db93291651ED510704c9b286841d506987', inceptBlock: 23407494 }
    ]

2) Run indexing

  • Start services (make dev).
  • Trigger fanout abis from terminal UI (or run equivalent job trigger).
  • Wait for extract/load queues to drain.

3) Validate data in DB

Confirm latest estimated label exists for vault and strategies:

-- vault label should exist
SELECT chain_id, address, label, block_time
FROM output
WHERE chain_id = 1
  AND lower(address) = lower('0x696d02Db93291651ED510704c9b286841d506987')
  AND label LIKE '%-estimated-apr'
ORDER BY block_time DESC
LIMIT 20;

4) Refresh REST snapshot cache and run web

cd packages/web
bun run app/api/rest/snapshot/refresh-snapshot.ts
bun run dev

5) Validate REST snapshot payload

curl -s http://localhost:3001/api/rest/snapshot/1/0x696d02db93291651ed510704c9b286841d506987 | jq

Expected:

  • Top-level performance.estimated.type is populated for vault when output exists.
  • composition[*].name is resolved (not universally Unknown where strategy snapshot/meta exists).
  • composition[*].latestReportApr is populated where strategy report data exists.
  • composition[*].performance.estimated is present for strategies with matching output rows for the vault-derived label.
  • No blanket performance: {} defaults when no performance data exists.

6) Regression checks

  • Non-yvUSD vault snapshots continue returning valid composition, fees, and oracle/historical performance.
  • getLatestEstimatedAprV3 still returns expected values for previous labels (crv/velo/aero) where applicable.

Results

{
            "name": "Unknown",
            "status": "active",
            "address": "0xF28DC8B6DeD7E45F8cf84B9972487C8e1857A442",
            "maxDebt": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
            "totalGain": "0",
            "totalLoss": "0",
            "activation": "1773109931",
            "lastReport": "1773109931",
            "maxDebtUsd": 115792089237316200000000000000000000000000000000000000000000000000000000,
            "currentDebt": "100000000000",
            "performance": {
                "estimated": {
                    "apr": 0.003825547818610449,
                    "type": "yvusd-estimated-apr",
                    "components": {}
                }
            },
            "totalGainUsd": 0,
            "totalLossUsd": 0,
            "currentDebtUsd": 100000,
            "performanceFee": "0",
            "latestReportApr": null
        },

It's just showing unknown becuase i constrained to only that address locally.

@vercel
Copy link

vercel bot commented Mar 11, 2026

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

Project Deployment Actions Updated (UTC)
kong Ready Ready Preview, Comment Mar 11, 2026 4:05pm

Request Review

@matheus1lva matheus1lva changed the title Fix yvUSD strategy estimated APR hydration in snapshots Add strategy estimated apr breakdown to yvusd Mar 11, 2026
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.

1 participant