B5 ewma apy display#165
Open
cyberdocs120 wants to merge 2 commits into
Open
Conversation
- 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
|
@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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #32.
EWMA computation (
blend.ts):fetchEwmaRates()fetches the last 30 daysof snapshots from the B3
/ratesendpoint and computes an exponentially-weightedmoving average with a 7-day half-life (α ≈ 0.0029 per 15-min tick).
Toggle (
main.ts+index.html): "Instant / Smoothed (7d EWMA)" buttonabove 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 thepool footer explains what EWMA is, the half-life, and the formula.
Files changed
frontend/src/blend.tsfrontend/src/main.tsfrontend/index.html