fix: FixedPointNumber.eq() used multiplication instead of exponentiation#3082
Open
operagxoksana wants to merge 1 commit into
Open
fix: FixedPointNumber.eq() used multiplication instead of exponentiation#3082operagxoksana wants to merge 1 commit into
operagxoksana wants to merge 1 commit into
Conversation
When comparing two FixedPointNumber instances with different scales where this.scale > value.scale, eq() scaled the operand with value.value * BigInt(10) * (this.scale - value.scale) instead of value.value * BigInt(10) ** (this.scale - value.scale). lt/lte/gt/gte already use the correct ** form for both scale-mismatch branches; only this one branch of eq() used * by mistake, e.g.: new FixedPointNumber(500, 2).eq(new FixedPointNumber(5, 0)) // 5.00 vs 5 -> was false, should be true FixedPointNumber has no external consumers yet, so there is no actively exploited path in the current app - but it is a core comparison primitive in src/architecture and any future allowance/balance/permit-amount equality check built on top of it would silently misbehave for mismatched decimals. Adds src/architecture/__tests__/FixedPointNumber.test.ts covering both scale-mismatch directions symmetrically, since only one direction was broken.
|
@operagxoksana is attempting to deploy a commit to the Aave Team on Vercel. A member of the Team first needs to authorize it. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes incorrect scale normalization in
FixedPointNumber.eq()(*-**).This fixes equality checks for values with different scales (e.g.
5.00 == 5) and adds regression tests.