The update_price
function in ScrvusdOracleV2.vy
calculates and stores last_prices
based on old parameters before updating to new parameters. However, it sets the last_update
timestamp to the current block timestamp. This inconsistency causes the smoothening mechanism to use incorrect baseline prices with current timestamps, potentially allowing faster-than-intended price movements and creating arbitrage opportunities.
In the update_price
function, the contract stores the last prices for smoothening before updating the price parameters:
The issue is that:
The contract calculates last_prices
using old parameters
It sets last_update
to the current timestamp
It then updates the parameters
This creates a mismatch where old prices are stored with a current timestamp. When the smoothening function calculates the allowed change, it uses this timestamp to determine how much time has passed:
This inconsistency can lead to:
Incorrect Price Transitions: The smoothening mechanism will allow larger price movements than intended because it calculates the time difference from an incorrect starting point.
Potential Arbitrage Opportunities: Systems that rely on this oracle for pricing (like stableswap-ng pools) could be exploited through arbitrage when prices move faster than intended.
Compounding Errors: Multiple rapid updates could exacerbate this issue, potentially causing significant price drift in a short time.
The impact is medium because it affects core oracle functionality and could indirectly put funds at risk in systems that rely on this oracle's accuracy, though it requires specific conditions to exploit.
Manual code review
Update the order of operations to calculate last_prices
after updating parameters:
- 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.