Skip to content

Implement portfolio rebalance, milestone rewards, analytics chart, and reputation score (#1139, #1141, #1142, #1143) - #1184

Merged
Chucks1093 merged 2 commits into
accesslayerorg:devfrom
KingFRANKHOOD:feat/issues-1139-1141-1142-1143
Oct 27, 2026
Merged

Chucks1093 merged 2 commits into
accesslayerorg:devfrom
KingFRANKHOOD:feat/issues-1139-1141-1142-1143

Conversation

@KingFRANKHOOD

Copy link
Copy Markdown
Contributor

Summary

This PR implements four features requested in the Stellar Wave issues.

#1139 — Portfolio rebalance UI with target allocation configuration

  • PortfolioRebalancePanel: per-key target % inputs with a running total validator (error when ≠ 100%), Preview Rebalance button calling get_rebalance_preview, swap preview table with estimated costs, Execute Rebalance button (disabled until allocations sum to 100%), RebalanceExecuted toast with per-key swap summary.
  • New rebalance.service.ts, rebalance.utils.ts, useRebalance.ts hook (useRebalancePreviewMutation + useExecuteRebalanceMutation).
  • Wired as new "Rebalance" tab on the portfolio page.

#1141 — Holder milestone rewards tracker on portfolio page

  • MilestoneRewardsSection: milestone cards per held key (30d/90d/180d/365d) with claimed/claimable/locked states, progress bars showing days held vs next threshold, Claim buttons triggering claim_milestone_reward contract call, claimed milestones showing received amount and claim date, empty state when no milestones exist.
  • New milestoneRewards.service.ts, milestoneRewards.utils.ts, useMilestoneRewards.ts hook with optimistic cache update on claim.
  • Wired as new "Milestones" tab on the portfolio page.

#1142 — Key analytics chart with daily snapshot history

  • KeyAnalyticsHistoryChart: Recharts LineChart with metric tab selector (Price / Volume / Holders / Market Cap), date range picker (7d / 30d / 90d / All Time), tooltip showing exact value on hover, connectNulls={false} so sparse data renders gaps instead of false lines, key={metric} on the LineChart element eliminates animation flicker when switching metrics.
  • New keySnapshotHistory.service.ts, keySnapshotHistory.utils.ts, useKeySnapshotHistory.ts hook (5-min stale time).
  • Wired into the key detail page as an "Analytics History" section.

#1143 — Key reputation score display

  • ReputationScoreBadge: compact badge on discovery feed KeyCards showing the score out of 1000 with a colour-coded tier and a tooltip explaining the methodology.
  • ReputationBreakdownPanel: full breakdown on the key detail page with a RadarChart of the four component scores (trade volume, holder retention, price stability, rating) and a dl listing each metric's raw value.
  • New keyReputation.service.ts, keyReputation.utils.ts, useKeyReputation.ts hook.

Test plan

  • Rebalance: set allocations not summing to 100 → error shown, Execute disabled; set to 100 → Preview enabled; click Preview → swap table shown; click Execute → RebalanceExecuted toast.
  • Milestones: open "Milestones" tab on portfolio page; verify claimed/claimable/locked card states render; click Claim → card flips to claimed.
  • Analytics chart: open any key detail page; verify 4 metric tabs and 4 range buttons switch correctly; tooltip shows value on hover.
  • Reputation: discovery feed cards show reputation badge; key detail page shows radar chart with all 4 metrics and per-metric breakdown.

Closes #1139
Closes #1141
Closes #1142
Closes #1143

…rorg#1142, accesslayerorg#1143

Issue accesslayerorg#1139 — Portfolio rebalance UI with target allocation configuration
- Added src/services/rebalance.service.ts: getRebalancePreview POST endpoint
- Added src/utils/rebalance.utils.ts: allocation validation, sum, build helpers
- Added src/hooks/useRebalance.ts: useRebalancePreviewMutation and useExecuteRebalanceMutation using execute_rebalance contract call
- Added src/components/common/PortfolioRebalancePanel.tsx: per-key target % inputs, running sum validator with error when not 100%, Preview Rebalance button, swap preview results, Execute Rebalance button (disabled until valid), RebalanceExecuted toast on confirmation
- Wired into ProfilePage.tsx as new "Rebalance" tab

Issue accesslayerorg#1141 — Holder milestone rewards tracker on portfolio page
- Added src/services/milestoneRewards.service.ts: GET /wallets/:wallet/milestone-rewards
- Added src/utils/milestoneRewards.utils.ts: resolveMilestoneState (claimed/claimable/locked), milestoneProgressPercent, hasAnyMilestones
- Added src/hooks/useMilestoneRewards.ts: useMilestoneRewards query and useClaimMilestoneReward mutation (claim_milestone_reward contract call with optimistic cache update)
- Added src/components/common/MilestoneRewardsSection.tsx: per-key milestone cards (30/90/180/365d), progress bars, claim buttons, claimed state with received amount and date, empty state
- Wired into ProfilePage.tsx as new "Milestones" tab

Issue accesslayerorg#1142 — Key analytics chart with daily snapshot history
- Added src/services/keySnapshotHistory.service.ts: GET /keys/:key_id/snapshots?range=X
- Added src/utils/keySnapshotHistory.utils.ts: buildSnapshotHistoryPoints, formatMetricValue, range/metric constants
- Added src/hooks/useKeySnapshotHistory.ts: useKeySnapshotHistory query (5-min stale time)
- Added src/components/common/KeyAnalyticsHistoryChart.tsx: Recharts LineChart with metric tabs (Price/Volume/Holders/Market Cap), date range picker (7d/30d/90d/All Time), tooltip with exact values, connectNulls=false for sparse data, no animation flicker on metric switch via key prop
- Wired into CreatorDetailPage.tsx as "Analytics History" section

Issue accesslayerorg#1143 — Key reputation score display
- Added src/services/keyReputation.service.ts: GET /keys/:key_id/reputation
- Added src/utils/keyReputation.utils.ts: buildReputationRadarData, clampReputationScore, reputationTier, REPUTATION_METHODOLOGY_TOOLTIP
- Added src/hooks/useKeyReputation.ts: useKeyReputation query (5-min stale time)
- Added src/components/common/ReputationScoreBadge.tsx: badge on discovery KeyCard showing score/1000 with tooltip explaining methodology
- Added src/components/common/ReputationBreakdownPanel.tsx: Recharts RadarChart for four metrics, per-metric dl breakdown, composite score
- Wired ReputationScoreBadge into DiscoveryKeyCard.tsx
- Wired ReputationBreakdownPanel into CreatorDetailPage.tsx as "Reputation" section
- Added queryKeys entries for snapshotHistory, reputation, milestoneRewards, rebalance
@Chucks1093

Copy link
Copy Markdown
Member

⚠️ Merge Conflict Detected

This PR currently has a merge conflict and cannot be merged until it is resolved.

Please rebase or merge the latest changes from the base branch into your branch and push again.

1 similar comment
@Chucks1093

Copy link
Copy Markdown
Member

⚠️ Merge Conflict Detected

This PR currently has a merge conflict and cannot be merged until it is resolved.

Please rebase or merge the latest changes from the base branch into your branch and push again.

@Chucks1093

Copy link
Copy Markdown
Member

✅ PR Ready for Review

Due to a recent malware incident affecting our repositories, all PRs are required to pass automated security checks before being reviewed for merging.

This PR has passed all automated checks:

  • ✅ Security scan — no malicious code detected
  • ✅ No merge conflicts
  • ✅ CI checks passed

Next step: Please share this PR link in our Telegram group so a maintainer can review and merge it: https://t.me/c/accesslayerorg/8514

@Chucks1093
Chucks1093 merged commit 89acf85 into accesslayerorg:dev Oct 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants