The _obtain_price_params function contains a loop that could consume excessive gas.
The loop iterates number_of_periods times (bounded by MAX_V2_DURATION). If parameters_ts - params.last_profit_update is large (e.g., after extended inactivity), number_of_periods could be high enough to exceed gas limits.
Transactions calling functions that use _obtain_price_params could fail due to excessive gas consumption, effectively DoSing the oracle during potentially critical market movements.
# From ScrvusdOracleV2.vy
@view
def _obtain_price_params(parameters_ts: uint256) -> PriceParams:
"""
@notice Obtain Price parameters true or assumed to be true at `parameters_ts`.
Assumes constant gain(in crvUSD rewards) through distribution periods.
@param parameters_ts Timestamp to obtain parameters for
@return Assumed `PriceParams`
"""
params: PriceParams = self.price_params
period: uint256 = self.profit_max_unlock_time
if params.last_profit_update + period >= parameters_ts:
return params
number_of_periods: uint256 = min(
(parameters_ts - params.last_profit_update)
self.max_v2_duration,
)
# locked shares at moment params.last_profit_update
gain: uint256 = (
params.balance_of_self * (params.total_idle + params.total_debt)
)
params.total_idle += gain * number_of_periods
# functions are reduced from `VaultV3._process_report()` given assumptions with constant gain
for _: uint256 in range(number_of_periods, bound=MAX_V2_DURATION):
new_balance_of_self: uint256 = (
params.balance_of_self
* (params.total_supply - params.balance_of_self)
)
params.total_supply -= (
params.balance_of_self * params.balance_of_self
)
params.balance_of_self = new_balance_of_self
# [rest of function omitted for brevity]
Restructure the _obtain_price_params function to avoid loops or ensure the gas cost remains reasonable.