metamask-extension
                                
                                 metamask-extension copied to clipboard
                                
                                    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
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
https://github.com/MetaMask/metamask-extension/assets/104780023/25eeb236-c28b-45db-affa-961749625cf8
Steps to reproduce
- Start send+swap transaction
- Select native token as an origin and another token for the destination
- Set Max amount
- 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
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
@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 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:
@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)
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
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
No release label on PR. Adding release label release-12.0.0 on PR, as PR was cherry-picked in branch 12.0.0.
@sleepytanya can we close this out as it looks like it was merged in release 12.0?
@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