Skip to content

feat: auto slippage support for RWA tokens cp-7.76.0#29592

Merged
satyajeetkolhapure merged 21 commits into
mainfrom
feat/auto-slippage-for-rwa
May 4, 2026
Merged

feat: auto slippage support for RWA tokens cp-7.76.0#29592
satyajeetkolhapure merged 21 commits into
mainfrom
feat/auto-slippage-for-rwa

Conversation

@satyajeetkolhapure

@satyajeetkolhapure satyajeetkolhapure commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds support for auto slippage for RWA tokens

COW swap liquidity is volatile and to address it, cow swap provides dynamic slippage suggestion service in there SDK.
Bridge api is using it. On extension and mobile, we are providing auto option by default when one or both tokens are RWA (same is implemented for solana tokens)
When it is auto, dynamic slippage is applied.

We also want user to have freedom to choose slippage. Hence we have kept existing options to choose along with auto.

Changelog

CHANGELOG entry: Added auto slippage support for RWA tokens

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

image

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 slippage behavior for same-chain EVM swaps when a stock-class RWA token is involved, which can affect quote execution outcomes and UX. Risk is mitigated by gating on the RWA remote feature flag and adding targeted unit/integration tests.

Overview
Adds a new selectIsRwaSwap selector (same-chain EVM + stock RWA token + RWA flag enabled) and uses it to treat those swaps like Solana same-chain swaps for slippage.

When selectIsRwaSwap is true, useInitialSlippage now initializes slippage to DEFAULT_SLIPPAGE_RWA (undefined → provider dynamic slippage) and useSlippageConfig injects an auto preset (['auto','0.5','2']) into the slippage options.

Refactors stock-RWA detection into shared isStockRwaBridgeToken, forwards rwaData through Token Details swap navigation, and adds/updates tests covering the new selector and slippage behavior (including a BridgeView RWA swap case).

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

@satyajeetkolhapure satyajeetkolhapure self-assigned this Apr 30, 2026
@satyajeetkolhapure satyajeetkolhapure requested a review from a team as a code owner April 30, 2026 20:18
@metamaskbotv2 metamaskbotv2 Bot added the team-be-trade BE Trade team label Apr 30, 2026
@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.

@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 74a79f7. Configure here.

Comment thread app/components/UI/Bridge/Views/BridgeView/BridgeView.test.tsx Outdated
@vivek-consensys vivek-consensys changed the title feat: auto slippage support for RWA tokens feat: auto slippage support for RWA tokens cp-7.76.0 May 1, 2026
@metamaskbotv2 metamaskbotv2 Bot requested a review from a team as a code owner May 1, 2026 14:24
@github-actions github-actions Bot added size-L and removed size-M labels May 1, 2026

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

Remove version bumps

@satyajeetkolhapure satyajeetkolhapure requested a review from a team as a code owner May 1, 2026 18:23

@Cal-L Cal-L 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

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.84%. Comparing base (51b6bbd) to head (19b012b).
⚠️ Report is 37 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29592      +/-   ##
==========================================
- Coverage   82.15%   81.84%   -0.32%     
==========================================
  Files        5178     5245      +67     
  Lines      137450   138671    +1221     
  Branches    31079    31456     +377     
==========================================
+ Hits       112924   113494     +570     
- Misses      16875    17453     +578     
- Partials     7651     7724      +73     

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

@vivek-consensys vivek-consensys added the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label May 4, 2026
@github-project-automation github-project-automation Bot moved this to Needs dev review in PR review queue May 4, 2026
@vivek-consensys vivek-consensys added the QA Passed QA testing has been completed and passed label May 4, 2026
@github-actions

github-actions Bot commented May 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes in this PR are focused on adding RWA (Real World Assets) stock token support to the Bridge/Swap flow:

  1. AppConstants.ts: Added DEFAULT_SLIPPAGE_RWA: undefined - a new constant for RWA token slippage configuration.

  2. bridge/index.ts (Redux slice): Added selectIsRwaSwap selector that identifies when a same-chain EVM swap involves a stock RWA token with the RWA feature flag enabled.

  3. isStockRwaBridgeToken.ts: New utility function extracted from useRWAToken to check if a token is a stock-class RWA asset - enables use outside React components (e.g., in Redux selectors).

  4. useInitialSlippage: Updated to set slippage to undefined (auto) for RWA stock token swaps, similar to Solana swap behavior.

  5. useSlippageConfig: Updated to include "auto" slippage option in the UI when isRwaSwap is true.

  6. useRWAToken: Refactored isStockToken to use the new shared utility (no behavioral change).

  7. useTokenActions: Added rwaData to the token object passed when navigating to swap from token details - ensures RWA token metadata is preserved through the swap flow.

Tag Selection Rationale:

  • SmokeSwap: Directly affected - the slippage configuration and initial slippage logic for swap flows have been modified. The useTokenActions change ensures rwaData is passed when initiating swaps from token details. These changes affect the swap/bridge flow for RWA tokens.
  • SmokeConfirmations: Required per SmokeSwap tag description - "When selecting SmokeSwap, also select SmokeConfirmations (transaction confirmations are part of the flow)."

The changes are additive (new RWA feature support) and don't modify existing non-RWA swap logic, so the risk is medium. The changes are well-tested with unit tests. No navigation, Engine, or controller architecture changes are involved.

Performance Test Selection:
The changes are focused on RWA token slippage logic in the Bridge/Swap flow. These are feature additions (new selectors, utility functions, slippage configuration) that don't affect rendering performance, list rendering, app startup, or other performance-sensitive areas. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 4, 2026

Copy link
Copy Markdown

@satyajeetkolhapure satyajeetkolhapure added this pull request to the merge queue May 4, 2026
@github-project-automation github-project-automation Bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue May 4, 2026
Merged via the queue into main with commit 355c9b6 May 4, 2026
99 checks passed
@satyajeetkolhapure satyajeetkolhapure deleted the feat/auto-slippage-for-rwa branch May 4, 2026 14:15
@github-actions github-actions Bot locked and limited conversation to collaborators May 4, 2026
@github-actions github-actions Bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label May 4, 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 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

QA Passed QA testing has been completed and passed release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-L team-be-trade BE Trade team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

7 participants