Platform usage: add Whole sale buy-velocity window #233

Closed
opened 2026-05-21 12:59:03 +00:00 by PlasticDigits · 11 comments
PlasticDigits commented 2026-05-21 12:59:03 +00:00 (Migrated from gitlab.com)

Summary

On /timecurve/protocol, the Platform usage card (#231) exposes Buy velocity with a two-option toggle: Last hour (default) and Last day (velocity_window=1h|24h).

Add a third option — Whole sale — beside those windows so operators can see buy velocity across the entire active sale, not only the trailing 1h/24h slices.

Current behavior

  • Frontend: TimeCurveProtocolPlatformUsageSection renders ["1h", "24h"] only (Last hour / Last day).
  • Indexer: GET /v1/timecurve/platform-usage accepts velocity_window=1h|24h; counts buys with block_timestamp >= anchor - window_sec (parse_velocity_window).

Desired behavior

  • UI: Velocity toggle becomes Last hour · Last day · Whole sale (label TBD if copy prefers “Entire sale”).
  • Semantics: Whole sale counts all indexed buys from sale_start through the velocity anchor (same anchor as today: chain-timer head, else MAX(block_timestamp) on buys).
  • Display: Reuse existing copy pattern — N buys · avg X buys / hour — with window_hours derived from elapsed seconds since sale_start (minimum 1h divisor or document zero/pre-open edge case).
  • Pre-open: If sale has not started (sale_start unset or anchor < sale_start), show empty-state copy consistent with No buys in this window (#200).

Implementation notes

  • Extend indexer velocity_window (e.g. sale or all) and SQL filter: block_timestamp >= sale_start_sec (expose sale_start_sec on chain-timer or read from sale metadata already indexed).
  • Extend PlatformUsageVelocityWindow in frontend/src/lib/indexerApi.ts + API path helper tests.
  • Update docs/invariants/manual QA spawned from #231 (INV-INDEXER-231, INV-FRONTEND-231, timecurve-views §231).

Acceptance criteria

  • Third toggle Whole sale visible next to Last hour / Last day on protocol AUDIT Platform usage.
  • Indexer returns correct velocity.buy_count and avg_buys_per_hour for full-sale window.
  • Unit/integration tests cover new window; Playwright touches velocity toggle if feasible.
  • Docs + manual QA checklist updated.
  • Parent feature: #231
## Summary On **`/timecurve/protocol`**, the **Platform usage** card (**[#231](https://gitlab.com/PlasticDigits/yieldomega/-/issues/231)**) exposes **Buy velocity** with a two-option toggle: **Last hour** (default) and **Last day** (`velocity_window=1h|24h`). Add a third option — **Whole sale** — beside those windows so operators can see buy velocity across the entire active sale, not only the trailing 1h/24h slices. ## Current behavior - Frontend: `TimeCurveProtocolPlatformUsageSection` renders `["1h", "24h"]` only (`Last hour` / `Last day`). - Indexer: `GET /v1/timecurve/platform-usage` accepts `velocity_window=1h|24h`; counts buys with `block_timestamp >= anchor - window_sec` ([`parse_velocity_window`](../../indexer/src/api.rs)). ## Desired behavior - **UI:** Velocity toggle becomes **Last hour** · **Last day** · **Whole sale** (label TBD if copy prefers “Entire sale”). - **Semantics:** **Whole sale** counts all indexed buys from **`sale_start`** through the velocity anchor (same anchor as today: chain-timer head, else `MAX(block_timestamp)` on buys). - **Display:** Reuse existing copy pattern — **N buys · avg X buys / hour** — with `window_hours` derived from elapsed seconds since `sale_start` (minimum 1h divisor or document zero/pre-open edge case). - **Pre-open:** If sale has not started (`sale_start` unset or anchor < `sale_start`), show empty-state copy consistent with **No buys in this window** ([#200](https://gitlab.com/PlasticDigits/yieldomega/-/issues/200)). ## Implementation notes - Extend indexer `velocity_window` (e.g. `sale` or `all`) and SQL filter: `block_timestamp >= sale_start_sec` (expose `sale_start_sec` on chain-timer or read from sale metadata already indexed). - Extend `PlatformUsageVelocityWindow` in `frontend/src/lib/indexerApi.ts` + API path helper tests. - Update docs/invariants/manual QA spawned from **#231** (`INV-INDEXER-231`, `INV-FRONTEND-231`, `timecurve-views §231`). ## Acceptance criteria - [x] Third toggle **Whole sale** visible next to **Last hour** / **Last day** on protocol AUDIT Platform usage. - [x] Indexer returns correct `velocity.buy_count` and `avg_buys_per_hour` for full-sale window. - [x] Unit/integration tests cover new window; Playwright touches velocity toggle if feasible. - [x] Docs + manual QA checklist updated. ## Related - Parent feature: [#231](https://gitlab.com/PlasticDigits/yieldomega/-/issues/231)
PlasticDigits commented 2026-05-21 12:59:05 +00:00 (Migrated from gitlab.com)

marked as related to #231

marked as related to #231
PlasticDigits commented 2026-05-21 13:21:02 +00:00 (Migrated from gitlab.com)

mentioned in issue #234

mentioned in issue #234
Brouie commented 2026-05-22 03:28:16 +00:00 (Migrated from gitlab.com)

mentioned in commit 81e600b3e7

mentioned in commit 81e600b3e7aa9c36dff13561809063c414f39542
Brouie commented 2026-05-22 03:28:57 +00:00 (Migrated from gitlab.com)

mentioned in merge request !393

mentioned in merge request !393
Brouie commented 2026-05-22 03:31:39 +00:00 (Migrated from gitlab.com)

marked the checklist item Third toggle Whole sale visible next to Last hour / Last day on protocol AUDIT Platform usage. as completed

marked the checklist item **Third toggle Whole sale visible next to Last hour / Last day on protocol AUDIT Platform usage\.** as completed
Brouie commented 2026-05-22 03:31:42 +00:00 (Migrated from gitlab.com)

marked the checklist item Indexer returns correct velocity.buy_count and avg_buys_per_hour for full-sale window. as completed

marked the checklist item **Indexer returns correct velocity\.buy\_count and avg\_buys\_per\_hour for full\-sale window\.** as completed
Brouie commented 2026-05-22 03:31:43 +00:00 (Migrated from gitlab.com)

marked the checklist item Unit/integration tests cover new window; Playwright touches velocity toggle if feasible. as completed

marked the checklist item **Unit/integration tests cover new window; Playwright touches velocity toggle if feasible\.** as completed
Brouie commented 2026-05-22 03:31:45 +00:00 (Migrated from gitlab.com)

marked the checklist item Docs + manual QA checklist updated. as completed

marked the checklist item **Docs \+ manual QA checklist updated\.** as completed
Brouie commented 2026-05-22 03:32:08 +00:00 (Migrated from gitlab.com)

Opened MR !393, implements all 4 acceptance criteria. Ready for review when you're free @PlasticDigits

Opened MR !393, implements all 4 acceptance criteria. Ready for review when you're free @PlasticDigits
PlasticDigits commented 2026-05-22 05:14:46 +00:00 (Migrated from gitlab.com)

mentioned in commit 0099b640de

mentioned in commit 0099b640de06baeea69a16d4b1e50ee8d384165f
PlasticDigits commented 2026-05-22 05:21:27 +00:00 (Migrated from gitlab.com)

mentioned in commit 6893aa6643

mentioned in commit 6893aa6643f26d75025481c9971be5b1e7c963ff
PlasticDigits (Migrated from gitlab.com) closed this issue 2026-05-22 05:21:28 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code/yieldomega#233
No description provided.