feat(timecurve-protocol): add Whole sale buy-velocity window (GitLab #233) #393

Merged
Brouie merged 2 commits from feat/233-whole-sale-velocity into main 2026-05-22 05:21:27 +00:00
Brouie commented 2026-05-22 03:28:53 +00:00 (Migrated from gitlab.com)

Closes #233.

Adds a third Whole sale toggle to the Buy velocity widget on /timecurve/protocol (AUDIT). The window counts all indexed buys from sale_start through the velocity anchor, with window_hours derived dynamically from elapsed seconds since sale start (min 1).

Indexer

  • velocity_window query param accepts sale alongside 1h / 24h.
  • parse_velocity_window refactored to return a VelocityWindow enum so the Sale variant can resolve window_start and window_hours at request time from chain_timer.timer.sale_start_sec.
  • Pre-open guard: when sale_start_sec is unset (0) or anchor < sale_start, returns zero buys + avg 0 without divide-by-zero. Matches #200 empty-state contract.
  • SCHEMA_VERSION bumped to 1.27.0.

Frontend

  • PlatformUsageVelocityWindow type union extended with "sale".
  • TimeCurveProtocolPlatformUsageSection toggle adds third pill labeled Whole sale. Existing flex-wrap: wrap on .platform-usage-velocity__toggle handles mobile layout cleanly — no CSS changes needed. Active-state arcade-green token reused so the third pill matches branding.

Tests

  • indexerApi.test.ts gets a sale path-helper case (asserts velocity_window=sale in the constructed URL).
  • New integration test postgres_gitlab233_platform_usage_velocity_window_sale in integration_stage2.rs covers:
    • Happy path: sale_start = 1_000_000, anchor = 1_010_000, 3 in-window + 1 pre-sale buy → buy_count = 3, avg = 1.5 (window_hours = 2).
    • Pre-open guard: timer.sale_start_sec = "0" → buy_count = 0, avg = 0.
    • BAD_REQUEST: unknown windows like 7d still rejected (sale accepted but error message extended).
  • Existing tests stay green: indexer cargo test --lib 48/48, frontend npm test 572/572.

Docs

  • INV-INDEXER-231-PLATFORM-USAGE Route row lists sale option; Velocity row documents window_start = sale_start_sec and window_hours = floor((anchor - sale_start) / 3600) math + pre-open behavior.
  • INV-FRONTEND-231-PLATFORM-USAGE Velocity UI row updated with Last hour / Last day / Whole sale toggles.
  • timecurve-views §231 Buy velocity bullet updated.
  • manual-qa-checklists.md #231 step 5 adds the Whole sale toggle case.
  • Schema reference bumped to 1.27.0.

Acceptance criteria

  • Third toggle Whole sale visible next to Last hour / Last day.
  • Indexer returns correct velocity.buy_count and avg_buys_per_hour for full-sale window.
  • Unit + integration tests cover new window.
  • Docs + manual QA checklist updated.

Out of scope

  • Playwright touches velocity toggle (issue spec says "if feasible" — no e2e changes needed since existing data-testid hooks are reused: timecurve-protocol-platform-usage-velocity-sale is auto-derived from the existing template literal).
  • No CSS changes — leaving design pass items (touch targets ≥44px, etc.) to nullvector's #234 design pass.
Closes #233. Adds a third `Whole sale` toggle to the Buy velocity widget on `/timecurve/protocol` (AUDIT). The window counts all indexed buys from `sale_start` through the velocity anchor, with `window_hours` derived dynamically from elapsed seconds since sale start (min 1). ## Indexer - `velocity_window` query param accepts `sale` alongside `1h` / `24h`. - `parse_velocity_window` refactored to return a `VelocityWindow` enum so the `Sale` variant can resolve `window_start` and `window_hours` at request time from `chain_timer.timer.sale_start_sec`. - Pre-open guard: when `sale_start_sec` is unset (`0`) or `anchor < sale_start`, returns zero buys + avg 0 without divide-by-zero. Matches `#200` empty-state contract. - `SCHEMA_VERSION` bumped to `1.27.0`. ## Frontend - `PlatformUsageVelocityWindow` type union extended with `"sale"`. - `TimeCurveProtocolPlatformUsageSection` toggle adds third pill labeled `Whole sale`. Existing `flex-wrap: wrap` on `.platform-usage-velocity__toggle` handles mobile layout cleanly — no CSS changes needed. Active-state arcade-green token reused so the third pill matches branding. ## Tests - `indexerApi.test.ts` gets a `sale` path-helper case (asserts `velocity_window=sale` in the constructed URL). - New integration test `postgres_gitlab233_platform_usage_velocity_window_sale` in `integration_stage2.rs` covers: - **Happy path:** `sale_start = 1_000_000`, anchor = `1_010_000`, 3 in-window + 1 pre-sale buy → `buy_count = 3`, `avg = 1.5` (window_hours = 2). - **Pre-open guard:** `timer.sale_start_sec = "0"` → `buy_count = 0`, `avg = 0`. - **BAD_REQUEST:** unknown windows like `7d` still rejected (`sale` accepted but error message extended). - Existing tests stay green: indexer `cargo test --lib` 48/48, frontend `npm test` 572/572. ## Docs - `INV-INDEXER-231-PLATFORM-USAGE` Route row lists `sale` option; Velocity row documents `window_start = sale_start_sec` and `window_hours = floor((anchor - sale_start) / 3600)` math + pre-open behavior. - `INV-FRONTEND-231-PLATFORM-USAGE` Velocity UI row updated with `Last hour / Last day / Whole sale` toggles. - `timecurve-views §231` Buy velocity bullet updated. - `manual-qa-checklists.md #231` step 5 adds the Whole sale toggle case. - Schema reference bumped to `1.27.0`. ## Acceptance criteria - [x] Third toggle `Whole sale` visible next to `Last hour` / `Last day`. - [x] Indexer returns correct `velocity.buy_count` and `avg_buys_per_hour` for full-sale window. - [x] Unit + integration tests cover new window. - [x] Docs + manual QA checklist updated. ## Out of scope - Playwright touches velocity toggle (issue spec says "if feasible" — no e2e changes needed since existing data-testid hooks are reused: `timecurve-protocol-platform-usage-velocity-sale` is auto-derived from the existing template literal). - No CSS changes — leaving design pass items (touch targets ≥44px, etc.) to nullvector's #234 design pass.
Brouie commented 2026-05-22 03:32:08 +00:00 (Migrated from gitlab.com)

mentioned in issue #233

mentioned in issue #233
PlasticDigits commented 2026-05-22 05:15:30 +00:00 (Migrated from gitlab.com)

added 1 commit

  • 0099b640 - perf(indexer): tighten platform-usage velocity queries (GitLab #233)

Compare with previous version

added 1 commit <ul><li>0099b640 - perf(indexer): tighten platform-usage velocity queries (GitLab #233)</li></ul> [Compare with previous version](/PlasticDigits/yieldomega/-/merge_requests/23/diffs?diff_id=1813371194&start_sha=81e600b3e7aa9c36dff13561809063c414f39542)
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) merged commit 6893aa6643 into main 2026-05-22 05:21:28 +00:00
Sign in to join this conversation.
No reviewers
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!393
No description provided.