0

Been studying up on uniswap logic, and the time weighted average oracle system. From what I know, on chain oracles have traditionally been susceptible to manipulation attacks, and generally in my mind so far don't seem very useful or safe. It adds some extra gas to the first transaction per block per pair, and I'm considering if that additional gas spent is really worth it for the service it provides.

I was wondering if anyone knew of any good examples of dex TWAP oracles being used safely for a good application.

3
  • 1
    It's a good question. (Although not a good fit for Stack Exchange sites because it invites opinion-based answers.) As mentioned, Synthetix is one example; ICHI is another, although not a fully successful one, as there was an attack recently: twitter.com/spreekaway/status/1596185188643442689
    – kfx
    Nov 28, 2022 at 7:53
  • Yeah youre right haha, its probably not the best type of question for stack exchanges. Thanks for the examples! I'm developing on a Uniswap fork, and weighing the decision of keeping the oracle in the new project. Uniswap seemed to think the assumption of it not mattering much since it only runs once per block I don't think seems to hold too much weight, because its also once per PAIR per block, so it actually runs and increases gas cost pretty often in reality.
    – Bruce
    Nov 28, 2022 at 20:56
  • 1
    Your best approach is probably to try to connect with someone from Uniswap and ask them directly. Austin Adams had a blog post about oracles recently. Actually in the post they say that PoS makes their oracles even less reliable...
    – kfx
    Nov 29, 2022 at 17:22

3 Answers 3

2

Synthetix uses TWAP oracles based on a configurable window for sourcing the DEX-based price of synth, with aggregation of Uniswap V3's latest price and spot price, and compare the rate with that of Chainlink. This use is part of providing a new exchange function that allows users to atomically exchange assets without fee reclamation by pricing synths via a combination of Chainlink and DEX oracles (Uniswap V3).

See: https://github.com/Synthetixio/SIPs/blob/master/content/sips/sip-120.md

1
  • Interesting. Thanks for the example!
    – Bruce
    Nov 28, 2022 at 20:56
0

Averaging the price value DOES add some complexity to the process of price manipulation. You need to manipulate each "price tick", and these operations are always worthy of gas. Main factors:

  1. it saves you from reentrancy attacks on price because it won't have a big effect on time-averaged price.
  2. it should make it economically inefficient to adjust all previous timestamps to make one final operation. Basically, because other market players can play against an attacker in this period

So it works better than not time-smoothed oracles in these situations

0

Time weight average means each time-interval has an equal impact on price so if someone wants to manipulate the price, they will only manipulate the last time-interval price so overall price will not be effected too much.

enter image description here

If someone wants to manipulate the last candle over given those candles in the image, how much effect it will have on the overall price? In order to affect the overall price, the manipulator must shift each candle's average price to very high or low. In uniswap world, each candle you see is actually the average price of a block. Obviously, longer is the time, better resistance but the less accurate price.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.