-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ratio.quantize() shouldn't increase precision unnecessarily (#9926)
## Description Ratios are designed to hold fractions as ratios with arbitrary length denominators. A few operations (multiplication) can cause the denominators to grow rapidly. To allow holders of growing ratios to manage this, we provide a method `quantize()`, which returns a ratio that approximates the original value, but with a smaller denominator. The current implementation uses the provided denominator even if it is larger. This doesn't gain anything, and can lose precision unnecessarily ### Security Considerations No security implications. ### Scaling Considerations The quantize() method is used to limit the size of very large BigInts. This improvement only makes that better. ### Documentation Considerations No need for changes. The current doc does say "Make an equivalant ratio with a new denominator", even though the result is only an approximation. ### Testing Considerations Added new tests. ### Upgrade Considerations No hurry to get this included in any particular contract upgrade.
- Loading branch information
Showing
5 changed files
with
53 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+25 Bytes
(100%)
packages/inter-protocol/test/vaultFactory/snapshots/vaultFactory.test.js.snap
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters