The MAX_V2_DURATION
constant in the ScrvusdOracleV2.vy
contract is intended to represent a maximum duration of 4 years in weeks. However, due to an incorrect multiplication, it instead calculates a period of 192 years, leading to severe misalignment in time-sensitive calculations. This logical flaw can significantly impact financial computations, lockup periods, and reward distributions, potentially resulting in unintended behaviors in the contract's execution.
The comment suggests that the intention is to define a period of 4 years.
The multiplication 4 * 12 * 4
is incorrectly structured:
4
(years)
12
(months per year)
4
(???)
If this calculation were intended to represent 4 years in weeks, the correct formula should have been:
However, in another part of the code, we see a conflicting definition:
The comment suggests it represents half a year (which is 26 weeks).
However, the formula 4 * 6 = 24
weeks, which is not exactly half a year.
Since 1 year = 52 weeks, half a year is:
This inconsistency raises concerns regarding whether MAX_V2_DURATION
is ever properly used, or if certain logic relies on the incorrect value, leading to misalignment in time calculations.
The computed value for MAX_V2_DURATION
is 4 * 12 * 4 = 192 weeks (~3.7 years) instead of 4 * 52 = 208 weeks.
If MAX_V2_DURATION
is mistakenly treated as months instead of weeks, it results in 192 years instead of 4 years.
Since this value limits iterations in loops and calculations in the contract (as seen in _obtain_price_params
), misalignment could result in overflows, unnecessary looping, or improper fund distribution calculations.
In _obtain_price_params
, the loop uses MAX_V2_DURATION
to iterate through price updates:
If MAX_V2_DURATION
is too large, this loop may execute far more times than expected, leading to gas exhaustion or unintended state changes.
Manual Code Review: Identified inconsistency between the comment and the actual multiplication.
Fix the Multiplication Error:
This is simply an approximation. I don't believe there is any incorrect logic here, given as long as this duration of growth is consistently applied, there will arguably be no incorrect oracle prices here. Additionally, I highly doubt there will be a instance where 48 weeks has passed since the last update.
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.