The UpdateWeightRunner uses a single staleness threshold for all oracles in a pool, regardless of their update frequencies. This design fails to account for varying oracle hearbeats and will lead to either premature fallbacks or acceptance of unnecessarily stale data.
QuantMMWeightedPool stores a staleness threshold in storage var at init time:
UpdateWeightRunner fetches that single threshold value and uses it to check freshness for all oracles in a pool:
The issue with this single per-pool threshold is that different oracles have different heartbeats (time between price updates).
Simple example scenario showing the issue:
Pool on mainnet has 2 assets - ETH and USDC. Chainlink ETH/USD and USDC/USD oracles are used as primary oracles and there are backup oracles configured
ETH/USD oracle heartbeat is 1 hour
USDC/USD oracle heartbeat is 24 hour
Using a single threshold necessarly leads to price issues:
if configured threshold is 1 hour, that means USDC/USD oracle prices will be often discarded and unnecessarily backup oracles will be used (which could have the same issue of correct price being discarded)
if configured threshold is 24 hours, that means ETH/USD oracle price will be accepted even when stale (up to 23h stale)
This issue will be even more prominent in pools with more than 2 tokens, ie. in pools with 8 tokens using 8 sets of oracles.
There are multiple negative impacts of this issue:
Higher-frequency oracles accept unnecessarily stale (and incorrect) prices
Lower-frequency oracles trigger unnecessary fallbacks
Increased gas costs from unnecessary oracle fallbacks
I consider this medium risk issue, because it will lead to incorrect prices being used for weight calculations which is the core feature of the protocol.
Manual code review
Staleness thresholds should be configured per-oracle instead of per-pool.
This is by design, staleness is a strategy aspect: it requires all data to have been updated within n minutes. No more precision needed.
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.