apy dashboard - #6
Merged
Merged
Conversation
…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.
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.
closes #3