Before updating the price, the result for querying price_v2 is 10^18, which works well, but the function _obtain_price_params
executing unnecessary logic.
When calling price_v2, the functions will call as below
price_v2 => _price_v2 => _raw_price => _obtain_price_params
Should notice _raw_price
take the current block. timestamp
as the default params, so _obtain_price_params will get the the current block. timestamp
.
For function _obtain_price_params
, params.last_profit_update + period
It will also equal the period as the initial value as last_profit_update = 0. so its value (7 * 86400) is forever less than current block.timestamp
. So the following logic will be executed, and to update full_profit_unlock_date , last_profit_update
, These new values have no meaning when calculating the raw price.
@viewdef _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_paramsperiod: uint256 = self.profit_max_unlock_time# Calling price_v2 before updating the price will skip the below logic and continue to executethe following logic, Although the following logic is no need to executeif params.last_profit_update + period >= parameters_ts:return params......params.full_profit_unlock_date += number_of_periods * periodparams.last_profit_update += number_of_periods * period
Executing much unnecessary logic and no need to update params.full_profit_unlock_date, params.last_profit_update
pytest
pytest -s tests/scrvusd/oracle/stateful/test_prices.py
Add the below test functions in this file https://github.com/CodeHawks-Contests/2025-03-curve/blob/198820f0c30d5080f75073243677ff716429dbfd/tests/scrvusd/oracle/stateful/test_prices.py#L193
To get the calculated price params, add the below temp function in ScrvusdOracleV2.vy.
Test results
For the test results full_profit_unlock_date,last_profit_update
changed, the new values have no meaning; others remain the same.
Add params.last_profit_update ==0
, just return the initial price param instead of executing the following logic
- Sponsor Comments - State root oracles usually do not provide block.timestamp, so it's simply not available. That is why last_profit_update is intended. - In `update_price`, this value must be a future block, meaning this update is a state checked and allowed by the OOS verifier contracts. The impact is also increasingly limited given price is smoothen and any updates via the block hash `verifyScrvusdByBlockHash` can also update the prices appropriately, meaning the price will likely stay within safe arbitrage range aligning with protocol logic
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.