You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Uniswap v3 TWAP oracles may fail in more subtle ways than manipulation. When calling observe, the oracle specifies a secondsAgo which is a parameter that sets the length of the TWAP. Observations is an array that contains cumulative values of the TWAP. If you call observe with secondsAgo = $[3600,0]$ you should get a 1 hour TWAP right? Well as long as sufficiently many entries of the observations array have been initialized so that the earliest tick cumulative was added at least an hour ago, you would be right. If the earliest tick cumulative is more recent than an hour ago, you are not actually getting a 1 hour TWAP you are getting something shorter.
The key insight in this discussion is that the number of initialized observations on a univ3 pool decides its TWAP behavior as much or more than secondsAgo in the observe call. The actionable result is to monitor this input when calculating oracle quality.
Thanks for opening this and linking these resources @sambacha, much appreciated! And apologies for getting back to you just now
On manipulation attacks
The Euler document linked actually states that single block manipulation is basically not possible, while multi-block risks outweighs potential rewards.
Practical considerations show that in real-life circumstances an attack on a Uni v3 TWAP for a liquid asset would be infeasible.
Also I'm not following the matter closely but from their docs it seems they're still using Uniswap as primary oracles and only use Chainlink for pairs with liquidity insufficient to protect from manipulation.
On oracle quality
Yes, number of observations influence oracle quality, which is why the feed provides a way to programmatically increase cardinality.
I'm planning to add an index to estimate quality and safety of a pool, allowing the caller to decide whether to rely on a quote based on them. This would take into account mainly observations and liquidity, but if you have suggestions I'd love to hear them!
TWAP is more susceptible to manipulation attacks in PoS, in fact Euler has moved to Chainlink from their TWAP oracles
https://github.com/euler-xyz/uni-v3-twap-manipulation
From
Liveness
sectionUniswap v3 TWAP oracles may fail in more subtle ways than manipulation. When calling observe, the oracle specifies a$[3600,0]$ you should get a 1 hour TWAP right? Well as long as sufficiently many entries of the observations array have been initialized so that the earliest tick cumulative was added at least an hour ago, you would be right. If the earliest tick cumulative is more recent than an hour ago, you are not actually getting a 1 hour TWAP you are getting something shorter.
secondsAgo
which is a parameter that sets the length of the TWAP. Observations is an array that contains cumulative values of the TWAP. If you call observe withsecondsAgo
=The key insight in this discussion is that the number of initialized observations on a univ3 pool decides its TWAP behavior as much or more than
secondsAgo
in the observe call. The actionable result is to monitor this input when calculating oracle quality.Refs.
https://www.euler.finance/blog/oracle-attack-simulator
https://oracle.euler.finance/
euler-xyz/uni-v3-twap-manipulation#3
The text was updated successfully, but these errors were encountered: