Skip to content

feat(rewards): add Perps Trading campaign participant outcome#29648

Merged
VGR-GIT merged 11 commits into
mainfrom
rwds-perps-trading-outcome
May 6, 2026
Merged

feat(rewards): add Perps Trading campaign participant outcome#29648
VGR-GIT merged 11 commits into
mainfrom
rwds-perps-trading-outcome

Conversation

@VGR-GIT
Copy link
Copy Markdown
Contributor

@VGR-GIT VGR-GIT commented May 4, 2026

Description

Adds Perps Trading campaign outcome support to the Rewards stack, mirroring the Ondo GM outcome pattern.

After a Perps Trading campaign ends, opted-in participants can query GET /perps-trading/:campaignId/outcome/me to learn whether they won. This PR wires that endpoint into the mobile app end-to-end:

  • Winners (have a winnerVerificationCode + pending status) see a toast → tap → PerpsTradingCampaignWinningView showing their rank, verification code (copy or email to claim prize)
  • Non-winners once results are final (finalized status, no code) see a toast → tap → campaigns view

Changelog

CHANGELOG entry: null

Related issues

Fixes: rwds-perps-trading-outcome

Changes

Layer File What
Types types.ts CampaignType.PERPS_TRADING, PerpsTradingCampaignParticipantOutcomeDto
Data service rewards-data-service.ts getPerpsTradingCampaignParticipantOutcome()GET /perps-trading/:campaignId/outcome/me
Controller RewardsController.ts Method with 10-min in-memory cache + auth retry
Action types / Messenger multiple Registered in action union and allowed actions
Hook usePerpsTradingCampaignParticipantOutcome.ts Fetches outcome via controller messenger
Toast hook usePerpsTradingCampaignEndedOutcomeToast.ts winner_pending → winning view; participant_finalized → campaigns
Screen PerpsTradingCampaignWinningView.tsx Rank + verification code, copy + mailto
Utility formatUtils.ts formatOrdinalRank() (1st/2nd/3rd…)
Routes / Navigator multiple New route constant, screen registered, toast hook wired
Strings en.json Toast + winning view copy

Manual testing steps

Feature: Perps Trading campaign outcome

  Scenario: winner sees outcome toast and winning view
    Given a Perps Trading campaign that has ended
    And the current user is opted in and has a winner row with status "pending" and a verification code

    When the user opens the Rewards section
    Then a toast appears: "You won! 🏆" with "View details" link
    When the user taps "View details"
    Then the PerpsTradingCampaignWinningView opens showing their rank and verification code
    And the user can copy the code or tap "Open mail" to email perpscampaign@consensys.net

  Scenario: non-winner sees finalized toast
    Given a Perps Trading campaign that has ended with 20 finalized winners
    And the current user is opted in but has no winner row

    When the user opens the Rewards section
    Then a toast appears: "The results are in" with "View" link
    When the user taps "View"
    Then the user is navigated to the campaigns view

Screenshots/Recordings

Before

No Perps Trading outcome UI.

After

Simulator Screenshot - E2E Test  - 2026-05-05 at 19 33 02 Simulator Screenshot - E2E Test  - 2026-05-05 at 20 50 09 Simulator Screenshot - E2E Test  - 2026-05-05 at 20 53 05 Simulator Screenshot - E2E Test  - 2026-05-05 at 20 53 10

(to be added — requires a completed Perps Trading campaign with backend data)

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Adds new post-campaign outcome UI/UX (toasts, auto-navigation, new routes/screens) that can affect user navigation and state gating across Rewards; issues would mainly surface as incorrect redirects or missing banners/toasts.

Overview
Adds a shared CampaignWinningView and wires both Ondo and Perps campaigns to use it for winner verification-code display (copy + mailto) with a consistent fallback when no code is available.

Introduces a generic useCampaignParticipantOutcome + useCampaignOutcomeToast pattern, then adds Perps Trading support via usePerpsTradingCampaignParticipantOutcome and usePerpsTradingCampaignEndedOutcomeToast, mounting these toasts on RewardsDashboard and CampaignsView.

Expands Perps Trading end-of-campaign UX: new PerpsTradingCampaignWinningView route/screen, outcome banners on details/stats (with one-time session auto-navigation for pending winners), an ended-campaign stats panel, and tweaks to completed-campaign stat presentation (hide pending tag; hide volume/margin once complete). Also consolidates outcome banner locale keys and generalizes CampaignOutcomeBanner usage across campaigns.

Reviewed by Cursor Bugbot for commit 464bd29. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@VGR-GIT VGR-GIT added the team-rewards Rewards team label May 4, 2026
@VGR-GIT VGR-GIT force-pushed the rwds-perps-trading-outcome branch from e03edf7 to 654b02c Compare May 4, 2026 14:41
@sophieqgu sophieqgu force-pushed the rwds-perps-trading-outcome branch 3 times, most recently from 5c8c9bc to 83a1a6f Compare May 5, 2026 21:27
- Add `PERPS_TRADING` to `CampaignType` enum
- Add `PerpsTradingCampaignParticipantOutcomeDto` type
- Add `getPerpsTradingCampaignParticipantOutcome` to data service, controller (10 min cache), action types, and messenger
- Add `usePerpsTradingCampaignParticipantOutcome` hook for fetching outcome
- Add `usePerpsTradingCampaignEndedOutcomeToast` hook: shows winner toast (→ winning view) or participant_finalized toast (→ campaigns)
- Add `PerpsTradingCampaignWinningView` screen: displays rank and verification code, with copy/mail actions
- Add `formatOrdinalRank` utility to formatUtils
- Wire navigator with new screen and toast hook
- Add en.json strings for toast and winning view

Co-authored-by: VGR-GIT <vangulckrik@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

fix(rewards): use COPY_WINNER_VERIFICATION_CODE metric for winning view copy action

Replace the incorrect COPY_REFERRAL_CODE button type with a dedicated
COPY_WINNER_VERIFICATION_CODE value in the analytics event fired when a
user copies their verification code on the Perps Trading winning view.

Co-authored-by: VGR-GIT <vangulckrik@gmail.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>

Reduce duplication

Add test coverage

Fix lint
@sophieqgu sophieqgu force-pushed the rwds-perps-trading-outcome branch from 83a1a6f to 2ab5074 Compare May 5, 2026 23:25
@sophieqgu sophieqgu marked this pull request as ready for review May 6, 2026 00:57
@sophieqgu sophieqgu requested a review from a team as a code owner May 6, 2026 00:57
Comment thread app/components/UI/Rewards/RewardsNavigator.tsx
Comment thread app/components/UI/Rewards/hooks/useOndoOutcomeToast.ts
Comment thread app/components/UI/Rewards/hooks/useCampaignOutcomeToast.ts
Comment thread app/components/UI/Rewards/hooks/useCampaignOutcomeToast.ts
Comment thread app/components/UI/Rewards/Views/CampaignWinningView.test.tsx
Comment thread app/components/UI/Rewards/Views/CampaignWinningView.tsx Outdated
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 35.38462% with 126 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.56%. Comparing base (8437791) to head (7d128ab).
⚠️ Report is 100 commits behind head on main.

Files with missing lines Patch % Lines
...onents/UI/Rewards/hooks/useCampaignOutcomeToast.ts 0.00% 46 Missing ⚠️
...omponents/UI/Rewards/Views/CampaignWinningView.tsx 5.88% 32 Missing ⚠️
...ontrollers/rewards-controller/RewardsController.ts 6.66% 14 Missing ⚠️
...ds/components/Campaigns/CampaignOutcomeBanners.tsx 12.50% 7 Missing ⚠️
...UI/Rewards/Views/PerpsTradingCampaignStatsView.tsx 0.00% 6 Missing ⚠️
...ewards-controller/services/rewards-data-service.ts 0.00% 5 Missing ⚠️
...nents/UI/Rewards/Views/OndoCampaignWinningView.tsx 0.00% 4 Missing ⚠️
...components/UI/Rewards/hooks/useOndoOutcomeToast.ts 0.00% 4 Missing ⚠️
.../Rewards/Views/PerpsTradingCampaignDetailsView.tsx 78.57% 0 Missing and 3 partials ⚠️
app/components/UI/Rewards/Views/CampaignsView.tsx 0.00% 2 Missing ⚠️
... and 3 more
Additional details and impacted files
@@             Coverage Diff             @@
##             main   #29648       +/-   ##
===========================================
- Coverage   81.86%   56.56%   -25.30%     
===========================================
  Files        5255     5296       +41     
  Lines      138980   140196     +1216     
  Branches    31518    31878      +360     
===========================================
- Hits       113774    79307    -34467     
- Misses      17465    54305    +36840     
+ Partials     7741     6584     -1157     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 78%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR introduces Perps Trading Campaign participant outcome functionality:

  1. RewardsController - New getPerpsTradingCampaignParticipantOutcome method with 10-minute caching, new messenger action registered. This is a critical file change but additive (no breaking changes to existing controller methods).

  2. New UI - PerpsTradingCampaignWinningView (new screen), usePerpsTradingCampaignParticipantOutcome hook, usePerpsTradingCampaignEndedOutcomeToast hook, generic useCampaignOutcomeToast abstraction.

  3. Breaking change in Redux - dismissCampaignOutcomeToast variant values changed from winner_verify/participant_no_winner to winner/non_winner. This affects both Ondo and Perps campaign outcome toast dismissal logic. Existing persisted Redux state with old variant keys would not match new keys, potentially causing toasts to re-appear.

  4. useOndoOutcomeToast refactored - Now delegates to generic useCampaignOutcomeToast. The Ondo outcome toast behavior changes (new toast styles via outcomeWinner/outcomeNonWinner instead of old inline implementation).

  5. CampaignOutcomeBanners renamed - OndoCampaignOutcomeBannersCampaignOutcomeBanners, with i18n key changes from rewards.ondo_outcome_banner.* to rewards.campaign_outcome_banner.*.

  6. New route - REWARDS_PERPS_TRADING_CAMPAIGN_WINNING_VIEW added to Routes.ts and RewardsNavigator.

Tag selection rationale:

  • SmokePerps: Directly impacts perps trading campaign details view (auto-navigation to winning view, outcome banners, ended stats), new winning view screen, and outcome toast for perps campaigns.
  • SmokeWalletPlatform: Perps is a section inside the Trending tab. The Rewards navigator changes and new routes affect the wallet platform. The Ondo outcome toast refactoring could affect Ondo campaign flows visible in the wallet.
  • SmokeConfirmations: Per SmokePerps tag description, when selecting SmokePerps, also select SmokeConfirmations (Add Funds deposits are on-chain transactions).

No E2E tests exist specifically for the Rewards feature (no tests/smoke/rewards directory), so these tags cover the closest related test suites.

Performance Test Selection:
The changes are focused on Rewards/Perps campaign outcome functionality - new API endpoint, caching layer, UI views, and toast notifications. These are feature additions to an existing rewards system and do not impact core performance-sensitive paths like app launch, login, account list rendering, asset loading, or swap flows. No performance tests are warranted.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 464bd29. Configure here.

}

const showEndedStats =
isComplete && !isParticipantStatusLoading && (!isOptedIn || !hasPosition);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ended stats flash during position loading for opted-in users

Medium Severity

The showEndedStats condition doesn't check isPositionLoading for opted-in users, causing a brief layout flash. When an opted-in user visits a completed campaign and their leaderboard position is still loading, hasPosition is false, making showCampaignEndedStats true. Once position loads, showStatsSummarySection takes over and showCampaignEndedStats flips to false. The showHowItWorksSection calculation correctly guards against this with !isPositionLoading, but showEndedStats does not.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 464bd29. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 6, 2026

@VGR-GIT VGR-GIT enabled auto-merge May 6, 2026 09:56
@VGR-GIT VGR-GIT added this pull request to the merge queue May 6, 2026
Merged via the queue into main with commit 08675af May 6, 2026
113 of 114 checks passed
@VGR-GIT VGR-GIT deleted the rwds-perps-trading-outcome branch May 6, 2026 10:19
@github-actions github-actions Bot locked and limited conversation to collaborators May 6, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-XL team-rewards Rewards team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants