Skip to content

B5 ewma apy display#165

Open
cyberdocs120 wants to merge 2 commits into
Dgetsylver:mainfrom
cyberdocs120:b5-ewma-apy-display
Open

B5 ewma apy display#165
cyberdocs120 wants to merge 2 commits into
Dgetsylver:mainfrom
cyberdocs120:b5-ewma-apy-display

Conversation

@cyberdocs120
Copy link
Copy Markdown

Summary

Closes #32.

  • EWMA computation (blend.ts): fetchEwmaRates() fetches the last 30 days
    of snapshots from the B3 /rates endpoint and computes an exponentially-weighted
    moving average with a 7-day half-life (α ≈ 0.0029 per 15-min tick).

  • Toggle (main.ts + index.html): "Instant / Smoothed (7d EWMA)" button
    above the APR grid. Net supply APY, net borrow cost, and position net APY all
    switch to EWMA values when smoothed mode is active. Results are cached per
    pool+asset and cleared on pool/asset change.

  • Docs panel (index.html): collapsible <details id="ewma-docs"> below the
    pool footer explains what EWMA is, the half-life, and the formula.

Files changed

  • frontend/src/blend.ts
  • frontend/src/main.ts
  • frontend/index.html

- Add rate_snapshots table + index to schema.sql
- Cron writes (pool, asset, supply_rate, borrow_rate, util, blnd_eps) snapshot each 15-min tick
- Cron prunes snapshots older than 365 days
- Add GET /rates?pool=&asset=&window= public endpoint
- Expose util + blndEps fields on ReserveRates
- Add fetchEwmaRates() to blend.ts: fetches 30d snapshots from B3 /rates
  endpoint and computes EWMA with 7-day half-life (α ≈ 0.0029 per 15-min tick)
- Add apyMode state (instant | smoothed) and activeRates() helper in main.ts
- Net supply APY and net borrow cost rows use activeRates() — affected by toggle
- Position net APY in renderPosition() also uses activeRates()
- Toggle button (#apy-mode-toggle) in APR section header switches modes
- EWMA results cached per pool+asset; cache cleared on pool/asset switch
- Docs panel (<details id=ewma-docs>) explains EWMA, half-life, and formula
@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@cyberdocs120 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

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.

B5: EWMA / time-weighted APY display

1 participant