MetaMask / MetaMask/metamask-mobile
Fix incorrect transaction cost display for USDC.e deposits without POL gas
- Dominant language
- TypeScript
- Stars
- 3k
- Forks
- 1.7k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 669
Description
## Description
When depositing USDC.e on Polygon without having POL for gas, the success toast incorrectly shows the total cost of the transaction (deposit + gas) as the deposit amount, rather than just the deposit amount.
## Root Cause Analysis
When the deposit succeeds, the data received from MM Pay has incomplete fee information:
```json
{
"bridgeFeeFiat": "0",
"chainId": "0x89",
"isPostQuote": undefined,
"networkFeeFiat": "0",
"targetFiat": "0",
"tokenAddress": "0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174",
"totalFiat": "0.824763"
}
```
**Current Calculation Logic**
The current implementation calculates the deposit amount via:
```
totalFiat - bridgeFeeFiat - networkFeeFiat
```
However, for Polygon USDC.e deposits, the fees are set to `0` and `targetFiat` is also `0`, causing the full `totalFiat` (which includes gas costs) to be displayed as the deposit amount.
**Why This Happens**
When using Polygon USDC.e, a quote is not needed from the bridge service, so the fee breakdown data isn't populated. This creates a gap where the transaction succeeds but the confirmation UI doesn't have the correct data to display the actual deposit amount.
## Expected Behavior
The success toast should display only the deposit amount, excluding any gas fees.
## Actual Behavior
The success toast displays the total transaction cost (deposit + gas) as if it were the deposit amount.
## Steps to Reproduce
1. Have a wallet with USDC.e on Polygon but no POL for gas
2. Initiate a USDC.e deposit
3. Complete the transaction (gas paid via alternative method)
4. Observe the success toast showing incorrect deposit amount
## Related
- Jira: PRED-672
- This issue was identified as a gap that needs investigation when no quote is required for the transaction
## Technical Notes
The fix likely needs to handle the case where fee data isn't populated from the quote service, either by:
1. Populating the fee breakdown data even when a quote isn't needed
2. Calculating the deposit amount differently when fee data is unavailable
3. Using an alternative data source for the actual deposit amount
Contributor guide
Assessment
This issue has not been assessed yet.