Skip to content

fix(stdlib): use bigint arithmetic in GasFees.mul() for non-integer scalars#22383

Open
danielntmd wants to merge 1 commit intomerge-train/spartanfrom
danielntmd/a-797-gasfees-mul-precision
Open

fix(stdlib): use bigint arithmetic in GasFees.mul() for non-integer scalars#22383
danielntmd wants to merge 1 commit intomerge-train/spartanfrom
danielntmd/a-797-gasfees-mul-precision

Conversation

@danielntmd
Copy link
Copy Markdown
Contributor

GasFees.mul() converted bigint fee values to Number for non-integer scalar multiplication, silently losing precision for values above 2^53. Since gas fees are UInt128 and can exceed 2^53 under realistic conditions (e.g. when the fee asset depreciates relative to ETH), this produced incorrect fee calculations in wallet code that calls .mul(1.5).

Replaced the Number conversion with scaled bigint arithmetic that preserves full precision for all UInt128 values while maintaining the ceiling behavior needed for fee padding.

…calars

GasFees.mul() converted bigint fee values to Number for non-integer
scalar multiplication, silently losing precision for values above 2^53.
Since gas fees are UInt128 and can exceed 2^53 under realistic conditions
(e.g. when the fee asset depreciates relative to ETH), this produced
incorrect fee calculations in wallet code that calls .mul(1.5).

Replaced the Number conversion with scaled bigint arithmetic that
preserves full precision for all UInt128 values while maintaining the
ceiling behavior needed for fee padding.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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