Skip to content

fix(token-details): cp-7.72.0 make sticky swap defaults balance-aware#28057

Merged
Prithpal-Sooriya merged 3 commits into
mainfrom
cursor/sticky-swap-button-defaults-1f78
Mar 31, 2026
Merged

fix(token-details): cp-7.72.0 make sticky swap defaults balance-aware#28057
Prithpal-Sooriya merged 3 commits into
mainfrom
cursor/sticky-swap-button-defaults-1f78

Conversation

@Prithpal-Sooriya

@Prithpal-Sooriya Prithpal-Sooriya commented Mar 27, 2026

Copy link
Copy Markdown
Contributor

Description

Implements balance-aware Swap defaults only for the sticky Swap button in Token Details.

When users tap the sticky Swap CTA from Token Details:

  • If the viewed token has a positive balance, Swap opens with:
    • From = current token
    • To = swap default
  • If the viewed token has zero balance, Swap opens with:
    • From = best available token (same existing selection logic used by sticky Buy flow)
    • To = current token

Scope is intentionally narrow to avoid regressions in other swap entry points:

  • Added a dedicated handleStickySwapPress in useTokenActions
  • Wired TokenDetailsStickyFooter to call onSwap (sticky-only handler)
  • Kept existing non-sticky/legacy swap navigation behavior unchanged
  • Updated Security & Trust screen to continue using generic swap behavior

Changelog

CHANGELOG entry: Fixed Token Details sticky Swap button defaults to use a balance-aware source token selection.

Related issues

Fixes: N/A
Refs: https://consensyssoftware.atlassian.net/browse/ASSETS-2972 #28050

Manual testing steps

Feature: Token Details sticky swap defaults

  Scenario: Token has positive balance
    Given user has balance in token X
    And user opens Token Details for token X
    When user taps the sticky Swap button
    Then Swap opens with token X as the source token
    And destination token is not prefilled as token X

  Scenario: Token has zero balance but user has other eligible assets
    Given user has zero balance in token X
    And user has positive balance in another eligible token Y
    And user opens Token Details for token X
    When user taps the sticky Swap button
    Then Swap opens with token Y as the source token
    And token X is prefilled as the destination token

  Scenario: Legacy/non-sticky swap path remains unchanged
    Given user opens Token Details
    When user navigates via non-sticky swap entry path
    Then existing swap defaults behave as before

Screenshots/Recordings

Before

N/A

After

Tested in Offsite - Approval from @bergarces and @AmarildoGr

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.
Open in Web Open in Cursor 

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 73.68421% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.63%. Comparing base (d50db18) to head (96a313e).
⚠️ Report is 76 commits behind head on main.

Files with missing lines Patch % Lines
...omponents/UI/TokenDetails/hooks/useTokenActions.ts 72.22% 2 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28057      +/-   ##
==========================================
+ Coverage   82.61%   82.63%   +0.02%     
==========================================
  Files        4849     4854       +5     
  Lines      124916   125109     +193     
  Branches    27873    27927      +54     
==========================================
+ Hits       103199   103385     +186     
+ Misses      14609    14603       -6     
- Partials     7108     7121      +13     

☔ 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

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.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - draft PR

All E2E tests pre-selected.

View GitHub Actions results

@github-actions

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
18 value mismatches detected (expected — fixture represents an existing user).
View details

@sonarqubecloud

Copy link
Copy Markdown

@Prithpal-Sooriya Prithpal-Sooriya marked this pull request as ready for review March 31, 2026 07:40
@Prithpal-Sooriya Prithpal-Sooriya requested a review from a team as a code owner March 31, 2026 07:40
@Prithpal-Sooriya Prithpal-Sooriya changed the title fix(token-details): make sticky swap defaults balance-aware fix(token-details): cp-7.72.0 make sticky swap defaults balance-aware Mar 31, 2026

@bergarces bergarces left a comment

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.

LGTM

@cursor cursor Bot left a comment

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.

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.

Comment thread app/components/UI/TokenDetails/Views/TokenDetails.tsx
@Prithpal-Sooriya Prithpal-Sooriya added this pull request to the merge queue Mar 31, 2026
@Prithpal-Sooriya

Copy link
Copy Markdown
Contributor Author

From discussion with @AmarildoGr, we may change the behaviour when to allow users to default swap by stables.

Merged via the queue into main with commit 7362d38 Mar 31, 2026
118 checks passed
@Prithpal-Sooriya Prithpal-Sooriya deleted the cursor/sticky-swap-button-defaults-1f78 branch March 31, 2026 08:06
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 31, 2026
@weitingsun weitingsun added release-7.73.0 Issue or pull request that will be included in release 7.73.0 and removed release-100.10.0 labels Mar 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 size-M team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants