You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: adds deeply liquid stablecoin slippage value of 0.5 (#31744)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->
## **Description**
### Purpose:
To automatically apply a lower default slippage (0.5%) when fetching
swap quotes for stablecoin pairs (like USDC/USDT), while using the
user's custom setting for other pairs. This improves the swap experience
for stablecoins and avoids unnecessary API calls with incorrect
slippage.
### Changes Made:
- Address-Based Stablecoin Definition: Introduced a StablecoinsByChainId
map in shared/constants/swaps.ts that lists known stablecoin contract
addresses for each supported network, mirroring the mobile
implementation.
- Refactored Slippage Logic: Modified the fetchQuotesAndSetQuoteState
function in ui/ducks/swaps/swaps.js to:
--- Check the from and to token addresses against the
StablecoinsByChainId map for the current network using a
case-insensitive comparison.
--- Determine the correct slippage (Slippage.stable or the user's
maxSlippage) before dispatching the quote fetch action.
- Updated Fetch & Analytics: Ensured the determined slippage value is
passed to the API request and correctly logged in analytics events.
<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->
[](https://codespaces.new/MetaMask/metamask-extension/pull/31744?quickstart=1)
## **Related issues**
Fixes: https://consensyssoftware.atlassian.net/browse/MMS-2169
## **Manual testing steps**
1. Go to the swap page
2. On any EVM chain, try to swap between USDT <-> USDC
3. Observe a default slippage value of 0.5% instead of 2%
## **Screenshots/Recordings**
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<img width="398" alt="Screenshot 2025-04-08 at 11 06 50 PM"
src="https://github.com/user-attachments/assets/e217a785-fcea-43b4-9c7f-1917ad39dbf4"
/>
<img width="396" alt="Screenshot 2025-04-08 at 11 06 45 PM"
src="https://github.com/user-attachments/assets/e501d8b4-d9e9-4d04-8a86-d60865ef140b"
/>
<img width="395" alt="Screenshot 2025-04-08 at 11 06 59 PM"
src="https://github.com/user-attachments/assets/6df22839-9a03-40b4-8fdc-b427d3a90f25"
/>
<!-- [screenshots/recordings] -->
### **After**
<img width="397" alt="Screenshot 2025-04-08 at 11 07 26 PM"
src="https://github.com/user-attachments/assets/7dcb5a60-822d-4ce6-94ea-fc1678f889e7"
/>
<img width="396" alt="Screenshot 2025-04-08 at 11 07 31 PM"
src="https://github.com/user-attachments/assets/7cf67f69-5278-4414-a96d-457f24fb6c45"
/>
<img width="397" alt="Screenshot 2025-04-08 at 11 07 42 PM"
src="https://github.com/user-attachments/assets/8f7c4c90-63fb-467e-a3ab-3e91db6882e0"
/>
<!-- [screenshots/recordings] -->
## **Pre-merge author checklist**
- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I’ve included tests if applicable
- [x] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.
## **Pre-merge reviewer checklist**
- [x] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [x] 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.
0 commit comments