umbra-protocol
umbra-protocol copied to clipboard
Send native token max without dust
Fixes #378

Deploy Preview for jolly-shaw-20fe62 ready!
| Name | Link |
|---|---|
| Latest commit | 1e088d3690e501294c0937a0766fe8f4f6df49d1 |
| Latest deploy log | https://app.netlify.com/sites/jolly-shaw-20fe62/deploys/64136c83e501a900088de284 |
| Deploy Preview | https://deploy-preview-390--jolly-shaw-20fe62.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site settings.
Test failure does not appear to be related to this PR. It's also failing on master
Mainnet max estimate seems a bit high. Not enough eth left to pay for market gas price.

Mainnet max estimate seems a bit high
Interesting. I'm really glad you checked on mainnet! I actually hadn't. (I needed to republish my keys and I was too lazy/cheap to do it before now. 😅) But since I fixed my mainnet setup, I'm actually seeing the opposite -- estimates are too low:
What fee estimate are you seeing in metamask on mainnet @garyghayrat? This is what I'm currently seeing (on 9/12/22 ~3:45pm ET):
I added some logging and it seems like our mainnet estimates are actually consistently 20% too low, even with the 10% scale factor applied. I'm not sure why that is.
Metamask's estimated gas limit is ~64k for a mainnet sendETH:
And ours is 70671 -- exactly 10% higher than metamask's (as expected, given the scale factor). So the issue seems to be with gas prices.
Sure enough, the MM max gas fee is ~11% higher than what we're getting from our provider. And based on https://www.blocknative.com/gas-estimator theirs is correct. I'll need to look into this
@apbendi I was just able to reproduce the error on Arbitrum
I ultimately got it to work (send tx here) by bumping the native send gas limit but tbh I'm not sure why it was a problem to begin with. The gas used by the tx (372,580) was well under the original estimate (461,905). It seems that this might be an issue with metamask? Unclear. But I bumped the scale factor estimateNativeSendGasLimit for arbitrum by an additional 5% (10% total) and that seemed to fix the issue.
I was also able to reproduce on optimism. Optimism fees are just weird, so there was a real fix needed here. I have to get more OETH before I can test that the fix works though.
I wasn't able to reproduce the issue on mainnet. I was able to drain an account without issue. Could you re-confirm you have this problem?
Hey @davidlaprade, I gave this another look and tested out both Arbitrum and Mainnet. The "allowance" errors on Arbitrum are gone, however now both networks show this message in MetaMask:
This is the error I see when MetaMask is on "Market", which is the default. If I switch it to "Low", I'm able to confirm the transaction. So it seems maybe the price estimate for gas is just a bit lower than what MetaMask ends up using. Is there a way we can bump it up?
LCOV of commit 367cf01 during CI #349
Summary coverage rate:
lines......: 81.4% (506 of 622 lines)
functions..: 72.5% (79 of 109 functions)
branches...: 77.8% (260 of 334 branches)
Files changed coverage rate:
|Lines |Functions |Branches
Filename |Rate Num|Rate Num|Rate Num
===========================================================================================
umbra-js/src/utils/utils.ts |86.9% 160|80.0% 15|72.3% 101
@apbendi I just rebased on top of master and retried max sends on mainnet and arbitrum, per:
I gave this another look and tested out both Arbitrum and Mainnet. The "allowance" errors on Arbitrum are gone, however now both networks show this message in MetaMask
I didn't get any errors. Native token max sends worked without issue on both networks for me.
This is the error I see when MetaMask is on "Market", which is the default. If I switch it to "Low", I'm able to confirm the transaction
This comment makes me wonder what your MetaMask settings are. I can't even see Market vs Low options unless I switch on an experimental feature (see screenshot). But actually even with this feature switched on I still had an arbitrum max send work without issue.
At this point I think it'd be helpful to hop on a call so I can see what you're seeing.
Alright @apbendi @mds1, I think I finally figured out the remaining issues we were having. I just rebased on master (again) and I think this is ready for re-review.
I have now tested:
- native token max sends (all 4 supported networks)
- native token partial sends (all 4 supported networks)
- ERC20 token max sends (polygon)
- ERC20 token partial sends (polygon)
- receive native token (all 4 supported networks)
- receive ERC20 (polygon)
- native token max sends on the release preview (all L2s)
Everything worked!
cc @garyghayrat as there is one new string to translate
Coverage after merging send-native-token-max-without-dust-#378 into master will be
| 86.13% |
|---|