Skip to content

fix: FixedPointNumber.eq() used multiplication instead of exponentiation#3082

Open
operagxoksana wants to merge 1 commit into
aave:mainfrom
operagxoksana:fix/fixed-point-number-eq-scale-mismatch
Open

fix: FixedPointNumber.eq() used multiplication instead of exponentiation#3082
operagxoksana wants to merge 1 commit into
aave:mainfrom
operagxoksana:fix/fixed-point-number-eq-scale-mismatch

Conversation

@operagxoksana

@operagxoksana operagxoksana commented Jul 23, 2026

Copy link
Copy Markdown

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.

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.
@odin-by-borg

odin-by-borg Bot commented Jul 23, 2026

Copy link
Copy Markdown

Mjolnir Security Review

StatusQueued for review...

View in Odin

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

@operagxoksana is attempting to deploy a commit to the Aave Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant