Skip to content

fix: computePovwRate no longer double-skips the latest completed epoch - #40

Merged
mintybasil merged 2 commits into
mainfrom
zeroklaw/fix-compute-povw-rate-double-skip
May 7, 2026
Merged

fix: computePovwRate no longer double-skips the latest completed epoch#40
mintybasil merged 2 commits into
mainfrom
zeroklaw/fix-compute-povw-rate-double-skip

Conversation

@zeroklaw

@zeroklaw zeroklaw commented May 7, 2026

Copy link
Copy Markdown
Member

Problem

computePovwRate in src/lib/parseEpochs.ts double-skips the latest completed epoch. The function uses slice(1, lookback + 1) to "skip the latest epoch" (the ongoing one), but the /api/epochs endpoint already excludes the ongoing epoch — it returns only completed epochs. This means slice(1) skips the most recent completed epoch instead, which is the most data-relevant point for the PoVW rate calculation.

Impact

With 99 completed epochs and a lookback of 10, computePovwRate was using epochs 2–11 (sorted desc) instead of epochs 1–10. The most recent completed epoch was always excluded.

Fix

Changed slice(1, lookback + 1) to slice(0, lookback) since the API already handles ongoing-epoch exclusion. Updated comments to reflect the correct behavior.

Testing

  • Added regression tests in src/lib/parseEpochs.test.ts covering:
    • Most recent epoch is included in calculation
    • Exactly lookback number of epochs are used
    • Default lookback of 10 works correctly

Fixes #35

@github-actions

github-actions Bot commented May 7, 2026

Copy link
Copy Markdown

Preview deployment

URL
Latest commit https://e6b9b91c.boundless-profit-explorer.pages.dev
Branch alias https://head.boundless-profit-explorer.pages.dev

The branch alias URL always points to the latest commit on this PR.

@mintybasil
mintybasil merged commit 73c5cef into main May 7, 2026
1 check passed
@mintybasil
mintybasil deleted the zeroklaw/fix-compute-povw-rate-double-skip branch May 7, 2026 18:25
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.

Fix: computePovwRate double-skips the latest completed epoch

2 participants