The _smoothed_price
function uses a linear approximation to compute the maximum allowed price change, which inherently involves integer division and truncation of fractional components. Over multiple updates, this can lead to cumulative rounding errors that may be exploited to gradually manipulate the oracle's reported price.
The function calculates the maximum change (max_change
) as:
It then clamps the raw price if the difference between raw_price
and last_price
exceeds max_change
.
Unlike exponential smoothing, which would naturally account for the time-dependent change using a multiplicative factor (i.e., last_price * e^(rate * time_delta)
), the linear method truncates fractional differences. This design choice is made for simplicity but introduces unavoidable rounding errors.
When small deviations in price occur repeatedly—whether due to market conditions or attacker-induced manipulation—each update may lose a small fractional value due to truncation. Over many updates, these losses can accumulate, causing the smoothed price to diverge from the ideal value.
The cumulative error may lead to an undervalued or overvalued price relative to the actual underlying asset value. Although the error per update might be minimal, its gradual accumulation can result in significant financial discrepancies that harm liquidity providers.
Manual Review
Replace the linear approximation with an exponential model such as:
where rate
is derived from max_price_increment
to better capture compounding effects and reduce truncation errors.
All values will be scaled to a combined of 36 decimals before division (be it price-related values or totalSupply). Considering the 18 decimals of all values, no realistic values were presented in any duplicates to proof a substantial impact on precision loss.
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.