Skip to content

apy dashboard - #6

Merged
thewealthyplace merged 18 commits into
mainfrom
feature/apy-dashboard-issue-3
Feb 24, 2026
Merged

apy dashboard#6
thewealthyplace merged 18 commits into
mainfrom
feature/apy-dashboard-issue-3

Conversation

@thewealthyplace

Copy link
Copy Markdown
Owner

closes #3

…board

Sets up Next.js 14 project with recharts for APY charts, stacks.js for
chain reads, and vitest for unit tests.
Defines TypeScript interfaces for pool stats, cycle history, wallet earnings,
and WebSocket events. APY formula: (btcValueUsd / stxValueUsd) * 26 * 100.
Includes CSV export, block/cycle helpers, and mock history generator.
Returns current cycle number, block countdown, total STX stacked,
BTC committed, estimated APY (formula: btcValueUsd/stxValueUsd*26*100),
and per-pool breakdowns. 10-second server-side cache with stale-while-revalidate.
Returns per-cycle APY, BTC rewards, STX stacked, and USD prices for up to
52 historical stacking cycles. Merges on-chain data where available with
synthetic fallback. Includes average, max, and min APY across the window.
Returns per-cycle BTC earnings, pool share %, total BTC earned, unrealized APY,
and next distribution estimate for a given Stacks wallet address.
Validates address format, reads on-chain positions, and falls back to synthetic
data when chain API is unreachable.
Server-Sent Events stream broadcasts new_block, pool_stats_update, and
cycle_change events to all connected clients. WebSocket relay connects to
Hiro API upstream and reconnects automatically on disconnect.
Heartbeat every 15s keeps connections alive through proxies.
…ing fallback

Connects to /api/v1/ws SSE stream, merges pool_stats_update events into state
on every block without full page reload. Falls back to 12-second polling when
EventSource is unavailable. Re-fetches full stats on cycle_change events.
useAPYHistory: fetches GET /api/v1/pool/history, re-fetches on refetch().
useWalletEarnings: fetches wallet earnings, exposes exportCSV() that generates
and downloads a CSV of per-cycle BTC earnings with pool share, value, and dates.
Displays DD:HH:MM:SS countdown to cycle end, cycle progress bar,
current block / cycle end block, and blocks remaining. Timer ticks
every second client-side; resets when blocksUntilCycleEnd prop changes.
Accessible aria-live region and progress bar.
Displays live connection dot, block height, STX stacked, BTC committed,
estimated APY with variability disclaimer, participant count, and per-pool
breakdown table. Renders skeleton placeholders while loading.
Recharts LineChart showing bitstake APY vs solo stacking reference line.
3-month / 6-month / 1-year window toggle, average APY reference line,
custom tooltip with cycle number and per-series values.
Variability disclaimer below chart.
Displays total BTC earned, USD value, STX staked, unrealized APY, and
next distribution date. Per-cycle earnings table with pool, share %,
BTC earned, USD value, and claimed status. CSV export button calls
exportCSV() from useWalletEarnings hook. Wallet-not-connected empty state.
Renders a grid of past/current/future stacking cycles. Each cell shows
cycle number, estimated start/end dates, and block range. User's unlock
blocks are highlighted with a badge and date. Configurable visible range.
…onents

Integrates CycleCountdown, LivePoolStats, APYChart, CycleCalendar, and
WalletEarnings. Supports read-only mode via ?address= query param.
Data refreshes without full page reload via SSE + hooks.
Covers: computeAPY formula (zero inputs, known values, CYCLES_PER_YEAR),
formatSTX/BTC/APY, block/cycle helpers, CSV generation/escaping,
averageAPY, and mock cycle history generation.
…tants

Extends CONTRACTS with oracle, TWAP accumulator, and circuit breaker entries.
Adds API_ENDPOINTS map for pool stats, history, wallet earnings, and SSE stream.
CI: adds dedicated APY utility test step and runs all frontend tests with npm.
README: marks dashboard, APY chart, cycle calendar, earnings CSV, and SSE feed as complete.
@thewealthyplace
thewealthyplace merged commit ac20e8a into main Feb 24, 2026
2 of 6 checks passed
@thewealthyplace
thewealthyplace deleted the feature/apy-dashboard-issue-3 branch February 24, 2026 23:05
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.

Build real-time APY tracking dashboard with historical BTC yield charts

1 participant