The _smoothed_price
function calculates max_change
using self.max_price_increment
, which is initialized as 2 * 10**12
(10^12 precision) but can be set between 10**8 and 10**18
via set_max_price_increment. The formula max_change = (self.max_price_increment * (block.timestamp - self.last_update) * last_price) // 10**18
assumes last_price has 10^18 precision and divides by 10**18 to normalize, but self.max_price_increment’s variable precision (10^8 to 10^18) disrupts this alignment, leading to inconsistent max_change values that don’t match the intended smoothing behavior.
If self.max_price_increment
is set to 10**8
, the calculated max_change
will be much smaller than expected.
If self.max_price_increment
is set to 10**18
, the division by 10**18
ensures correct scaling, but this does not hold for all values between 10**8
and 10**18
. (e.g 10**1
2)
This could cause unexpectedly low or high max_change values, leading to incorrect price smoothing behavior.
self.max_price_increment’s precision (10^8 to 10^18) directly affects max_change’s scale.
Initial value (2 * 10**12)
is 10^6 times smaller than 10^18, reducing max_change’s magnitude significantly compared to an intended 10^18-based rate.
The comment suggests an exponential form (max_price_increment / 10**18) ** time, implying max_price_increment should be a rate normalized to 10^18, but the linear formula doesn’t enforce this.
Incorrect Smoothing: When self.max_price_increment is less than 10^18 (e.g., 2 * 10**12), max_change is scaled down by a factor of self.max_price_increment / 10**18 (e.g., 2 * 10^-6), making price changes much smaller than intended, potentially freezing prices or under-smoothing.
Over-Smoothing Risk: If set to 10**8, the effect is 10^10 times smaller, rendering smoothing ineffective.
Behavioral Variability: Different admins setting different values (e.g., 10**12 vs. 10**18) cause unpredictable smoothing, undermining reliability.
Manual
enforce a fixed precision for self.max_price_increment
(e.g., always store it as 10**18
-scaled values).
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.