Multiple update rule contracts perform division operations before multiplication in critical mathematical calculations, violating fixed-point arithmetic best practices.
The pattern appears in core components:
Weight Calculation Errors:
In pools with large denominators, the initial division could truncate significant digits
This affects the accuracy of weight updates, potentially leading to suboptimal asset allocation
The error compounds with each weight update operation
Raw Division in Normalization:
Uses unsafe raw division (/=) instead of PRBMath's safe division operations
Division result directly affects kappa multiplication, a key anti-momentum parameter
Dividing by number of weights before multiplication can amplify precision loss
More instances detected across multiple contracts:
Gradient Calculation Precision Loss:
Loss of precision in gradient calculations affects the entire update mechanism
Could cause the pool to react incorrectly to price changes
Critical for strategies relying on precise price movement tracking
Channel Following Precision:
Affects envelope calculations and scaling operations
Could lead to incorrect channel boundaries
May result in premature or delayed trading signals
The precision loss from dividing before multiplication affects the protocol's core mathematical operations:
When division occurs first, significant digits can be truncated, especially with large denominators. This truncation then propagates through subsequent multiplications.
These calculations form part of the protocol's trading strategy logic. Precision losses in gradient calculations and channel boundaries can cause:
Missed or mistimed trading opportunities
Suboptimal asset allocation
Degraded price responsiveness
The impact compounds over time as these calculations occur on every weight update, potentially leading to accumulated drift from optimal strategy execution.
Reorder mathematical operations to perform multiplication before division:
This ensures maximum precision is maintained throughout the calculation chain.
## [Low-24] Divide before multiply
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.