Skip to content

feat: compound v3 APY using on-chain profitMaxUnlockTime#354

Merged
matheus1lva merged 1 commit intomainfrom
feat/compounding-apy
Mar 5, 2026
Merged

feat: compound v3 APY using on-chain profitMaxUnlockTime#354
matheus1lva merged 1 commit intomainfrom
feat/compounding-apy

Conversation

@matheus1lva
Copy link
Collaborator

@matheus1lva matheus1lva commented Mar 3, 2026

Summary

  • V3 vault APY-to-APR decompounding now uses profitMaxUnlockTime read on-chain instead of a hardcoded 52 weekly periods
  • Compounding periods: n = 31,556,952 / profitMaxUnlockTime (e.g., ~52 for 7-day unlock windows)
  • Falls back to 365 (daily compounding) if profitMaxUnlockTime is 0 or the RPC call fails
  • V2 vaults remain unchanged at 52 periods

Context

Per feedback from juniordevbot: the compounding periods should reflect the vault's actual profitMaxUnlockTime rather than assuming weekly (52). Most v3 vaults use ~7 day unlock periods, but this varies per vault.

Changed files

  • packages/ingest/abis/yearn/lib/apy.ts — added getCompoundingPeriods() function, v3 path uses it instead of hardcoded 52

Test plan

  • Start the dev environment
make dev
  • Configure abis.local.yaml to index a v3 vault:
cron:
  name: AbiFanout
  queue: fanout
  job: abis
  schedule: '*/15 * * * *'
  start: false

abis:
  - abiPath: 'yearn/3/vault'
    sources: [
      { chainId: 1, address: '0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204', inceptBlock: 19419991 }
    ]
  • Configure manuals.local.yaml so the vault is created as a thing:
manuals:
  - chainId: 1
    address: '0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204'
    label: 'vault'
    defaults: {
      erc4626: true,
      v3: true,
      yearn: true,
      apiVersion: '3.0.2',
      origin: "yearn",
      inceptBlock: 19419991
    }
  • In the terminal UI (pane 2), select Ingestfanout abis to trigger indexing. Run it multiple times for full initialization.

  • Trigger APY recalculation via Ingestfanout replays in the terminal UI

  • Watch the ingest pane for APY processing logs — look for 🧮 apy-bwd-delta-pps entries. If profitMaxUnlockTime read fails, you'll see:

🚨 getCompoundingPeriods readContract fail <chainId> <address> <blockNumber>
  • Query v3 vault APY outputs from the psql pane (pane 3):
SELECT o.chain_id, o.address, o.component, o.value, o.block_number
FROM output o
JOIN thing t ON o.chain_id = t.chain_id AND o.address = t.address
WHERE t.label = 'vault'
  AND t.defaults->>'apiVersion' >= '3.0.0'
  AND o.label = 'apy-bwd-delta-pps'
  AND o.component IN ('net', 'grossApr')
ORDER BY o.block_time DESC
LIMIT 20;

Expected: grossApr values should be present and reasonable. For vaults with ~7 day profitMaxUnlockTime, values should be very close to the previous 52-period calculation.

  • Spot-check the vault's profitMaxUnlockTime on-chain:
cast call 0xBe53A109B494E5c9f97b9Cd39Fe969BE68BF6204 "profitMaxUnlockTime()(uint256)" --rpc-url $RPC_1

Expected: e.g., 604800 (7 days) → 31556952 / 604800 ≈ 52.18 periods/year

  • Shutdown
make down

🤖 Generated with Claude Code

Instead of hardcoding 52 weekly compounding periods for all vaults,
v3 APY now compounds based on the vault's profitMaxUnlockTime read
on-chain: n = seconds_per_year / profitMaxUnlockTime.

For ~7 day unlocks this yields ~52 periods/year. Falls back to daily
(365) if profitMaxUnlockTime is 0 or the read fails. V2 vaults
remain unchanged at 52.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Mar 3, 2026

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

Project Deployment Actions Updated (UTC)
kong Ready Ready Preview, Comment Mar 3, 2026 9:08pm

Request Review

@matheus1lva matheus1lva marked this pull request as ready for review March 4, 2026 12:42
Copy link
Collaborator

@murderteeth murderteeth left a comment

Choose a reason for hiding this comment

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

lgtm

@matheus1lva matheus1lva merged commit 4ba7235 into main Mar 5, 2026
3 checks passed
@murderteeth murderteeth deleted the feat/compounding-apy branch March 14, 2026 18:02
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.

2 participants