Skip to content

chore: deprioritize destination token in QuickBuy source preselection#31015

Merged
zone-live merged 9 commits into
mainfrom
TSA-593-quickbuy-pay-with-preselect-token-pick
Jun 3, 2026
Merged

chore: deprioritize destination token in QuickBuy source preselection#31015
zone-live merged 9 commits into
mainfrom
TSA-593-quickbuy-pay-with-preselect-token-pick

Conversation

@zone-live

@zone-live zone-live commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Description

QuickBuy was preselecting the same token the user intended to buy (SOL→SOL) because selectDefaultSourceToken had no awareness of the destination token. This PR adds an optional destToken parameter to that function: before running the four priority tiers (native-on-dest → any-on-dest → native-elsewhere → first), the destination token is filtered out of the candidate pool so a more useful holding is picked instead. If the user holds nothing else, the destination token is still returned as a last resort, keeping the picker non-empty while the Buy CTA remains disabled via the existing no-quotes path.

Simulator.Screen.Recording.-.iPhone.17.Pro.-.2026-06-03.at.14.25.58.mov

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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
Changes default pay-with token logic, destination token resolution, and bridge quote token identity—core to trade execution—with broad new test coverage but real user-money impact if matching rules regress.

Overview
QuickBuy Pay with preselection now excludes the asset you are buying: selectDefaultSourceToken takes an optional destination token (address/chain, with a non-EVM symbol fallback only), waits until setup finishes so addresses match normalized CAIP/bare forms, and respects manual picker choices.

Setup & stability: useQuickBuySetup decodes CAIP-19 positions (natives via getNativeSourceToken, EVM bare hex for quotes). usePositionTokenBalance no longer crashes on BTC/Tron. Buy-mode rate pills use a local dest token copy with market rate so quote/redux tokens stay stable.

UI: Amount entry is slider-only (hidden keyboard path removed but props kept). Slider shows quarter marks at 25/50/75; exchange rates use locale-aware Intl formatting.

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

@github-actions

github-actions Bot commented Jun 3, 2026

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 github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 3, 2026
@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 3, 2026
@github-actions github-actions Bot added the size-M label Jun 3, 2026
@zone-live zone-live removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 3, 2026
@zone-live zone-live marked this pull request as ready for review June 3, 2026 14:03
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 3, 2026
@github-actions github-actions Bot added size-L and removed size-M labels Jun 3, 2026

@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.

Reviewed by Cursor Bugbot for commit 466e48b. Configure here.

@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are all within the SocialLeaderboard/QuickBuy feature area, which is the trading entry point from the Trending tab. Key changes include:

  1. useQuickBuyController.ts: Logic fixes for source token auto-selection (prevents "buy SOL with SOL" same-token preselection), adds destTokenForRate to fix exchange rate display without breaking quote stability, and preserves manual token picker selections via isManualSelectionRef.

  2. tokenSelection.ts: Updated selectDefaultSourceToken to filter out the destination token from source candidates - backward compatible (new optional parameter).

  3. useQuickBuySetup.ts: Added CAIP-19 parsing for native assets (SOL, BTC, ETH, POL via slip44 namespace) - expands support for native token positions.

  4. usePositionTokenBalance.ts: Added early return for non-EVM, non-Solana chains (BTC, Tron) to prevent crashes.

  5. QuickBuyAmountSection.tsx: Removed keyboard/numpad input path (temporarily disabled), simplified to slider-only.

  6. QuickBuyPercentageSlider.tsx: Visual marker changes (removed 0/100 markers, color change).

  7. formatExchangeRate.ts: Improved locale-aware formatting.

Tag selection rationale:

  • SmokeWalletPlatform: The QuickBuy feature is accessed from the Trending tab (SocialLeaderboard), which is directly tested by SmokeWalletPlatform's trending tests. Changes to the Perps section within Trending affect this tag.
  • SmokePerps: The Perps trading flow uses QuickBuy as its entry point for Add Funds. The token selection and native asset handling changes directly affect this flow.
  • SmokeSwap: QuickBuy uses BridgeController infrastructure (same as swap/bridge flows). The token selection logic changes could affect how source tokens are selected in swap flows.
  • SmokeConfirmations: QuickBuy submits transactions via BridgeStatusController.submitTx, which goes through the confirmation flow. Per tag descriptions, SmokePerps and SmokeSwap require SmokeConfirmations.

There are no dedicated E2E tests for QuickBuy/SocialLeaderboard specifically, so these are the closest relevant test suites. Confidence is moderate because the changes are isolated to QuickBuy components but touch bridge/swap infrastructure.

Performance Test Selection:
The changes are focused on logic fixes within the QuickBuy component (token selection, CAIP-19 parsing, UI simplification). While there are UI changes (slider markers, amount section), these are minor visual tweaks that don't significantly impact rendering performance. The core changes are bug fixes to token selection logic and native asset handling, not performance-sensitive code paths. No performance test tags are warranted.

View GitHub Actions results

@zone-live zone-live enabled auto-merge June 3, 2026 16:10
@zone-live zone-live added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jun 3, 2026
@zone-live zone-live added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit 8406e2c Jun 3, 2026
311 of 313 checks passed
@zone-live zone-live deleted the TSA-593-quickbuy-pay-with-preselect-token-pick branch June 3, 2026 17:29
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk:medium AI analysis: medium risk size-L skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants