metamask-extension icon indicating copy to clipboard operation
metamask-extension copied to clipboard

[Bug]: SOL.USDC > SOL.SOL swap simulation fails due to token balance inconsistency

Open chaoticgoodpanda opened this issue 1 year ago • 3 comments

Describe the bug

When attempting to perform a swap from SOL.USDC to SOL.SOL via MetaMask extension, the swap simulation failed due to an apparent discrepancy in the displayed USDC balance. Specifically, the USDC quantity reported in the quote appeared to be doubled (34,349,749 instead of ~17,174,875, which corresponds to ~$34.35 considering 6 decimals). It seems related to token balances not updating promptly, as the issue resolved itself after some delay.

Expected behavior

The token balance displayed should accurately reflect the actual wallet balance immediately, ensuring the swap simulation succeeds when a user initiates the swap.

Screenshots/Recordings

Please see the attached screenshot for initial failure details (user screenshot from original chat notes).

Image

Steps to reproduce

Ensure your MetaMask extension wallet has a balance of approximately $34.35 in SOL.USDC.

Initiate a swap from SOL.USDC to SOL.SOL.

Observe the quote fetched via the simulation.

Notice the incorrect doubled quantity causing a simulation failure.

Error messages or log output

No explicit log error messages captured. Simulation failure due to incorrect displayed token balance.

Detection stage

In production (default)

Version

12.18.3

Build type

None

Browser

Brave

Operating system

MacOS

Hardware wallet

No response

Additional context

Related issue potentially involving slow balance updates, similar to previous issues: https://github.com/MetaMask/metamask-extension/issues/32897

Issue appeared to self-resolve upon balance state update.

Not previously documented as a specific GitHub issue per internal team discussion.

Severity

No response

chaoticgoodpanda avatar Jun 18 '25 17:06 chaoticgoodpanda

This seems to be an issue where a user

  1. Executes a Swap
  2. After that swap the balance doesn't get updated fast enough
  3. In the middle of the next swap you get the new balance
  4. The new swap is in a broken state because you have less of the balance that you had before

Setting this as Sev3 as we are working on Websockets to make this updates faster

aganglada avatar Jul 04 '25 10:07 aganglada

Should be fixed in 13.1.0 as balances will update very quickly with websockets could you check @javiergarciavera @chaoticgoodpanda

aganglada avatar Aug 12 '25 16:08 aganglada

Checked again and not been able to reproduce in 13.1.2. Closing

aganglada avatar Aug 27 '25 07:08 aganglada