Skip to content

fix: add lookback bounds to current performance queries#414

Open
matheus1lva wants to merge 1 commit into
mainfrom
fix/current-performance-lookback
Open

fix: add lookback bounds to current performance queries#414
matheus1lva wants to merge 1 commit into
mainfrom
fix/current-performance-lookback

Conversation

@matheus1lva
Copy link
Copy Markdown
Collaborator

Summary

Split from #400 per review feedback — PR 2 of the split.

Changes

  • CURRENT_PERFORMANCE_LOOKBACK_DAYS env var (default 7) for APY/APR queries in apy-apr.ts. Also adds the lookback filter to getLatestApy and getLatestOracleApr which previously had no time bound.
  • STRATEGY_PERFORMANCE_LOOKBACK_DAYS env var (default 14) for the strategy performance CTE in the v3 vault snapshot hook. Kept separate from the 7-day default since strategy reports may lag.
  • Preserves single-timestamp invariant in fetchStrategyPerformance: restores the original CTE pattern (GROUP BY address, label → MAX block_time) with the added time bound, instead of DISTINCT ON which could pick components from different block_times.
  • JSONB projection for evmlog queries (args->>'field' instead of SELECT args) to reduce transfer size.

Reviewer feedback addressed

  • Env vars for lookback windows instead of hardcoded intervals
  • Single-timestamp invariant preserved (no DISTINCT ON)
  • Separate env vars for the 7d/14d gap (strategy reports lag)

From

Split from #400 (PR 2 per review request). Remaining projection changes (things.ts pushdown, first→firstRow refactors in timeseries hooks) deferred until PRs 1+2 are measured.

- Add CURRENT_PERFORMANCE_LOOKBACK_DAYS env var (default 7) for APY/APR
  queries in apy-apr.ts. Also adds the lookback filter to getLatestApy
  and getLatestOracleApr which previously had no time bound.
- Add STRATEGY_PERFORMANCE_LOOKBACK_DAYS env var (default 14) for the
  strategy performance CTE in the v3 vault snapshot hook.
  Kept separate from the 7-day default since strategy reports may lag.
- Preserve single-timestamp invariant in fetchStrategyPerformance:
  restore the original CTE pattern (GROUP BY address, label → MAX
  block_time) with the added time bound, instead of DISTINCT ON which
  could pick components from different block_times.
- JSONB projection changes (args->>field) for evmlog queries to reduce
  transfer size.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 27, 2026

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

Project Deployment Actions Updated (UTC)
kong Ready Ready Preview, Comment May 27, 2026 12:10pm

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.

1 participant