-
Notifications
You must be signed in to change notification settings - Fork 5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Sentry] [Bug] Bug/Error: div() number type has more than 15 significant digits #13738
Comments
This issue has been automatically marked as stale because it has not had recent activity in the last 90 days. It will be closed in 45 days if there is no further activity. The MetaMask team intends on reviewing this issue before close, and removing the stale label if it is still a bug. We welcome new comments on this issue. We do not intend on closing issues if they report bugs that are still reproducible. Thank you for your contributions. |
This issue was closed because there has been no follow up activity in the last 45 days. If you feel this was closed in error, please reopen and provide evidence on the latest release of the extension. Thank you for your contributions. |
Sentry issue: METAMASK-X885 |
Elevating this to a sev1 as it occurs in |
Probably not a bug anymore, but we shall investigate why it was solved. |
Hi team, any update on this one? |
@MetaMask/swaps-engineers Hi team, can you please confirm this is still happening? |
@vpintorico happened twice in the last 3 months:
@infiniteflower @nikoferro I can reproduce with this:
|
hi there 👋🏼 I dug into a separate, related issue in the repo (See "Technical Details" here) I see the issue in calcTokenAmount and am working on a solution |
Q: how may the app pass a fractional value as the cc: @klejeune |
cc: @klejeune It turns out there was a way to cause the error without decimals being fractional. For example, when decimals = 36 it would cause the error reported in Sentry:
Created the fix for this here #25799 |
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** #### This PR: - Fixes a BigNumber Error on calcTokenAmount - Fixes Swaps destinationAmount type. '0' should take place of null occurrences - Adds calcTokenAmount tests #### Explanation: When certain large params are passed, e.g. when the decimal passed is 36, the calculation of `Math.pow(10, Number(decimals || 0))` is expected → 100000000. Then, when we pass this to BigNumber div() we get the error: ``` BigNumber Error: div() number type has more than 15 significant digits: 9.999999999999999e+35 ``` however, if we pass the same value as a BigNumber, we do not get the error. That is, instead of passing the result of `Math.pow(10, Number(decimals || 0))`, we pass the result of `new BigNumber(10).pow(decimals)` honestly, I don't quite understand why this is. We can see the [bignumber.js#div code here](https://github.com/MikeMcl/bignumber.js/blob/v4.1.0/bignumber.js#L750) #### Other notes: - It turns out that updating the bignumber.js package from 4.1.0 → 9.1.2 could also fix this issue - There is another, less-used BigNumber class that exists in our code ([this BigNumber div code](https://github.com/ethers-io/ethers.js/blob/f97b92bbb1bde22fcc44100af78d7f31602863ab/packages/bignumber/src.ts/bignumber.ts#L81)) --- [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/25799?quickstart=1) ## **Related issues** Fixes: #13738 Related: #25741 (comment) ## **Manual testing steps** 1. Go to this page... 2. 3. ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** (divisor was previously called multiplier) ![CleanShot 2024-07-16 at 01 07 09@2x](https://github.com/user-attachments/assets/f1444f58-ca02-404a-aba9-153455bb177c) ### **After** ![CleanShot 2024-07-16 at 01 19 06@2x](https://github.com/user-attachments/assets/c5251516-f8b1-459a-be5f-06f99d66b3f7) ## **Pre-merge author checklist** - [ ] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
Collaborative Effort Required for Root Cause Analysis (RCA) on Critical Issues We are quickly approaching the end of the quarter and we encourage you once again to take some moments and perform RCA on this critical issue. You may do so by answering the questions below: 1. What PR fixed the issue? Please provide your answers as a reply to this comment and tag me as well. You can read more about the initiative here. Thank you! Tagging eng. who added the fix: @digiwand |
Hello again @benjisclowder, just sent a related RCA, which was focused on a related precision issue. Backlinking here: (Ref). Please reach out if any of this is unclear and I can update it. Thank you!
|
The text was updated successfully, but these errors were encountered: