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

[Bug]: When sending the max amount in native currency selecting another destination token, users encounter a warning "Insufficient funds for gas," even though the account possesses sufficient funds

Open sleepytanya opened this issue 1 year ago • 7 comments

Describe the bug

When attempting to send the maximum amount of native tokens from an account selecting another destination token, users encounter a warning on the confirmation screen indicating "Insufficient funds for gas," even though the account possesses sufficient funds.

Expected behavior

All fees and amounts accurately calculated and displayed on the confirmation screen.

Screenshots/Recordings

Screenshot 2024-06-13 at 00 38 26

https://github.com/MetaMask/metamask-extension/assets/104780023/25eeb236-c28b-45db-affa-961749625cf8

Steps to reproduce

  1. Start send+swap transaction
  2. Select native token as an origin and another token for the destination
  3. Set Max amount
  4. See the warning about insufficient funds

Error messages or log output

No response

Version

12.0.0

Build type

None

Browser

Chrome, Firefox

Operating system

MacOS

Hardware wallet

No response

Additional context

No response

Severity

No response

sleepytanya avatar Jun 13 '24 05:06 sleepytanya

I don't believe this is a bug. The insufficient funds for gas warning is shown based on the swap+send gas, not the basic send gas used for the "max" calculation. With that, the UI here could better communicate that so I'm leaving this open for now, but I don't think this would be sev2

BZahory avatar Jun 19 '24 14:06 BZahory

@sleepytanya If you take the same action with the same account on the current production build (v11.16.12) do you get the same warning? Or are you able to proceed with the transaction?

danjm avatar Jun 20 '24 00:06 danjm

@danjm v11.16.12 doesn't have send+swap, just simple Send flow. Using Max on v11.16.12 doesn't cause any issues.

Or are you able to proceed with the transaction?

On 12.0.0 the transaction with the 'Max' amount can't be confirmed, 'Confirm' button is disabled. If user selects non-native<->non-native or non-native->native token for send+swap, then 'Max' amount is calculated correctly:

Screenshot 2024-06-20 at 00 01 00

sleepytanya avatar Jun 20 '24 03:06 sleepytanya

@BZahory @sleepytanya can we define expected behavior as follows:

GIVEN Native to non-native AND Token amount is Max THEN No funds remain for gas

Inform the user that max amount cannot be used and recommend to reduce token amount (copy to be worked on with content design)

hesterbruikman avatar Jun 20 '24 10:06 hesterbruikman

when maxing srcToken (current behavior)

srcToken destToken insufficient funds? reason
nativeToken nativeToken false uses native send gas
nativeToken ERC20 true a swap is performed, max consumes too much gas to perform a swap
ERC20 nativeToken false a swap is performed
ERC20 ERC20 false a swap is performed

I'm under the impression we can just use the logic that otherwise would be a standard swap given that it this problem only seemingly happens when performing a send from nativeToken -> ERC20

ejwessel avatar Jun 27 '24 19:06 ejwessel

Latest v12.0.0 build https://github.com/MetaMask/metamask-extension/pull/25098#issuecomment-2251300111

https://github.com/user-attachments/assets/c68a6531-ce70-4bc0-b29f-7cb484c6cbe3

sleepytanya avatar Jul 25 '24 21:07 sleepytanya

No release label on PR. Adding release label release-12.0.0 on PR, as PR was cherry-picked in branch 12.0.0.

metamaskbot avatar Jul 29 '24 13:07 metamaskbot

@sleepytanya can we close this out as it looks like it was merged in release 12.0?

ejwessel avatar Aug 31 '24 01:08 ejwessel

@ejwessel Closing!

nativeToken -> nativeToken nativeToken -> ERC20 (Max option is unavailable) ERC20 -> nativeToken ERC20 -> ERC20

All scenarios above work as expected in 12.0.0.

https://github.com/user-attachments/assets/25c843d5-a129-4e61-bfdc-6f1e4efb4d4e

sleepytanya avatar Sep 02 '24 21:09 sleepytanya