Euler: Evaluating On Chain Median Pricing Oracles

In the presentation above, Euler Co-founder, Doug Hoyte, gives us insights into the team’s extensive research into TWAP oracles and introduces their very own oracle design. Before we dive into Doug’s presentation, here are some important concepts to take note of. 

What is Euler?
Euler is a permissionless DeFi lending protocol that allows users to lend and borrow almost any crypto asset without the need for a trusted third party. Euler’s unique protocol design requires a more sophisticated application of price oracles. The Euler team has done extensive research into this field in order to ensure a truly permissionless and decentralized protocol while maintaining security. In this presentation, Doug Hoyte, Co-founder of Euler, presents the work done to improve upon the Uniswap V3 TWAP (time-weighted average price) oracle design, and introduces a whole new on-chain price oracle design. 

Comparing Uniswap V2 & V3
In his presentation, Doug discusses the differences between Uniswap V2 and V3 TWAP oracles. The biggest difference noted is that the price observations on V3 are stored directly in the contract itself, making it much easier to use. Another difference noted was Uniswap V2’s use of arithmetic mean calculation and V3’s use of geometric mean. Arithmetic and geometric means are two different ways of calculating the average price of an asset. According to Doug, though using the geometric mean would be more practical, it is not as efficient as arithmetic averaging. This Investopedia post provides more information about the differences between arithmetic and geometric mean calculations. A more detailed explanation about Uniswap V3’s use of geometric mean can be found in this video by Smart Contract Programmer.

Why not just take spot price data?
According to Doug, simply reading the price off of a blockchain is not effective because it can be easily manipulated with an “atomic transaction” – a huge trade or transaction that affects an asset’s on-chain price.

Below is an elaboration on how such an attack would work: 

  1. Start an atomic transaction as a smart contract
  2. Make a gigantic trade on the exchange to move the price
  3. Invoke a “victim contract” which would then be fulfilled based on the wrong price. . A victim contract refers to the smart contract that is settled using the incorrect price data. For example, the contract could be used to issue a loan based on an incorrect price on a lending protocol. 
  4. The attacker receives their funds or loan once the victim contract is settled
  5. The attacker makes the opposite trade on the exchange to move the price back and recover their funds

Time-Weighted Average Price (TWAP) 
TWAP is an aggregation method that calculates the mean price of cryptocurrencies over a specified period of time. Using TWAP oracles instead of a single price point helps to weed out short-term price changes and is also much harder to manipulate. However, they still have their shortcomings. In his presentation, Doug explains possible attacks on TWAP oracles, including multiple block attacks where miners take control of several blocks with “selfish mining”. Doug also highlights how upcoming changes to the Ethereum blockchain such as proof-of-stake and MEV Boost could make such multi-block attacks much cheaper and easier to carry out. 

Euler’s new oracle design
As the big surprise in Doug’s presentation, Euler’s new oracle design was introduced. The new design includes improvements to the Uniswap V3 oracle which Euler has been using for some time. Some of the goals for Euler’s new oracle include increasing the oracle’s resiliency to attacks as well as improving on gas fees inefficiencies faced by the Uniswap V3 oracle.

In his presentation, Doug discusses how the Euler oracle was tested. Using real event data, the Euler oracle was tested against Uniswap V3’s. These simulations compared each oracle’s price reports to real prices, as well as the gas usage of the two oracles.

In the crash triggered by Terra’s collapse on 12th May 2022, extreme volatility in the price of USDC/WETH led to the Euler oracle’s gas usage being higher than Uniswap V3’s. While Doug described this as the “worst case scenario” for the Euler oracle, this only refers to gas usage. The oracle reported prices accurately throughout the period of market turmoil. 

QuickSelect Algorithm
In computer science, QuickSelect is an algorithm that is used to find the weighted median. Euler uses a variation of “QuickSelect”. Doug elaborates on Euler’s use of QuickSelect, the limitations of the algorithm, as well as Euler’s plans on how to deal with those shortcomings. 

For full details about Euler’s proposed price oracle design refer to this GitHub article by Doug Hoyte. 

Euler was a Platinum Sponsor at the world’s first Blockchain Oracle Summit, the only conference to focus solely on oracles’ importance and design. Building a truly decentralized, next-generation DeFi protocol led the Euler team deep down the rabbit hole of oracle security. The team’s wealth of wisdom about TWAP oracles and how to manipulate them was a crucial part of our research process for BOS22.

Find out more about Euler: 
Euler Website
Euler Documentation
Euler Twitter
Euler Discord
Michael Bentley Twitter
Doug Hoyte Github

Twitter
Telegram
LinkedIn
Email

Building Autonomous Multi-Chain DApps Using Cross-Chain Automation Powered by Gelato

In the presentation below, Hilmar Orth, founder of Gelato Network, presented on the evolution of multi-chain applications and the impact autonomous cross-chain dApps would have on the ecosystem.  Below are some highlights from his presentation.  What Is Gelato? Gelato Network is web3’s decentralised backend that enables projects to augment their smart contracts by being able to

Read More »

Zero-Knowledge Proofs: Where Data Verification Meets Privacy

In the presentation below, Laurence Kirk, CEO of Extropy.io, presented on Zero-Knowledge Proof and how it could be applied to Oracles, focusing on the challenges in data verification and privacy standards.  Below are major highlights from his presentation.  What Is Extropy?Extropy is a consultancy firm that offers auditing and software development services for , Distributed

Read More »

The Future is Multichain; Enhancing the Interoperability of DApps with Cross-Chain Oracles 

Ethereum, Bitcoin, Binance Smart Chain, Polygon, Cosmos, Polkadot, Optimism… the list goes on.  As more blockchains are being created with a multitude of decentralized applications (dApps) being built and used on each one of them, the conversation around the need for an interoperable future has never been more important. There have been many discussions about

Read More »

Evaluating the Integration of Subjective Oracles for Executing DAO Decisions

In the presentation below, Clément Lesaege, co-founder and chief technical officer of Kleros, presented on the integration of subjective oracles for executing DAO decisions and the role Kleros could play in the evolution of DAO governance.  Below are the highlights of his presentation.  What is Kleros?Kleros is a decentralized protocol built on the Ethereum blockchain

Read More »

Oracles as a Catalyst for Bridging Real World Assets On-Chain

In the presentation below, Niklas Kunkel, Oracle Core Unit Facilitator at MakerDAO, talks about the role that oracles play in bridging real world assets on-chain. Below are further explanations of key points highlighted during his talk. Introduction to MakerDAO & StablecoinsMakerDAO is a decentralised autonomous organisation (DAO) that guides the development of the Maker protocol.

Read More »

Ensuring Honesty in Decentralised Systems: Oracle Manipulation & OEV 

In the presentation below, Dominik Muhs, Senior Security Engineer from ConsenSys Diligence, dives deep into the world of oracles, explaining how they can be broken and what would be required to prevent future manipulations. Here are some key concepts highlighted in the talk. What is ConsenSys Diligence?ConsenSys Diligence is the blockchain security and auditing arm

Read More »