Have you ever wondered how DeFi protocols determine the real-time prices of cryptocurrencies for lending, borrowing, and trading?
Let’s assume you use Aave to take out a loan against your Ethereum stack. Have you ever wondered how Aave seem to know exactly how much you can borrow?
While taking that loan, a lot goes on under the hood.
First, Aave needs to know the current price of Ethereum in USD.
But there’s a slight problem.
The blockchain that Aave’s smart contract operates doesn't have access to external data like current market prices.
So, what does it do to allow you to take that loan?
Here’s where an oracle steps in…
An oracle is a service or entity that act as intermediaries to fetch and verify real-world data and relay it to the blockchain, enabling smart contracts to interact with data from the outside world.
The oracle acts as a bridge, fetching the current ETH/USD price from various centralized exchanges and feeding this data to the smart contract. This allows the smart contract to accurately determine how much USD you can borrow against your ETH collateral.
The concept of blockchain oracles has been around almost since the inception of smart contracts. Early efforts in this field included Augur, a decentralized prediction market conceived in 2014, and Oraclize, which was later rebranded as Provable Things.
Without oracles, smart contracts would be like isolated islands, unable to interact with the outside world, making real-world applications like DeFi practically impossible.
There are various kinds of Oracles, but traditionally, push oracles have dominated this space. However, pull oracles are emerging as a more efficient and accurate alternative, particularly for DeFi protocols.
Let’s dig in…
What are Push and Pull oracles?
Push Oracles:
Push oracles are Oracles that proactively provide data to smart contracts without being explicitly requested. When a specified event or condition occurs, the push oracle triggers the smart contract with the relevant data.
That is to say, it is a system that periodically updates a piece of the on-chain state to reflect the off-chain state.
Remember the Ethereum we talked about in the beginning?
A push oracle could update the on-chain price of ETH on Uniswap to track the off-chain ETH price on Binance, triggering an update every 10 minutes or if the price moves by 0.5-1%.
As you can see from the diagram above, Push oracles operate by having designated entities (oracle operators) periodically broadcast price updates to the blockchain.
The problem? Push oracles are expensive and hence don’t scale!
These updates incur transaction fees, which become a significant bottleneck as the number of price feeds and update frequency increase. This cost limits the scalability of push oracles, restricting the number of assets and blockchains they can support.
Furthermore, delayed updates in push oracles can lead to vulnerabilities…
During periods of high network congestion, price updates might be hindered, causing DeFi protocols to rely on outdated data. This can lead to inefficiencies, frontrunning attacks, and potential losses for users.
As a result of these, push oracles have historically been confined to relatively low-frequency updates on a relatively small set of data feeds.
Pull Oracles:
Pull oracles offer a compelling alternative.
Pull oracles, in contrast to push oracles, require smart contracts to request data explicitly. A smart contract will send a query to the oracle, which will then retrieve the requested information and relay it back to the contract.
They work by allowing users to request price updates on-demand. This eliminates the need for constant broadcasting by oracle operators, significantly reducing transaction costs.
As a result, pull oracles can provide:
Higher Scalability: By removing the cost burden of frequent updates, pull oracles can support a much larger number of price feeds and blockchains, catering to the ever-growing demands of DeFi.
Faster Updates: Users can pull the latest price data whenever needed, enabling DeFi protocols to react to market changes in real time. This minimizes the risk of relying on outdated information.
Lower Costs: Since users initiate price requests, the overall cost of Oracle services is reduced. This translates to lower fees for DeFi users and potentially increased adoption.
I’ll get a bit more real…
For pull oracles, the operator of the off-chain component is not responsible for updating the on-chain data. Instead, the operator generates a verifiable payload containing the relevant data, and the smart contract enables anyone to submit these payloads to permissionlessly update the on-chain state.
This means the Oracle operator is no longer required to constantly submit transactions to the blockchain. Hence, adding feeds and blockchains, or increasing the update frequency no longer incurs an ongoing operating cost.
Instead, users of the Oracle pay to “pull” price data only when they need it. This new mechanism solves the scalability problems of push oracles, thereby enabling new kinds of applications.
The Pyth Network Advantage: A Case Study
Launched in 2021, Pyth Network is an oracle originally designed for the Solana blockchain.
Pyth Network is a novel oracle solution that aggregates price data directly from exchanges, market makers, and trading firms. It stands out by introducing confidence intervals, offering a more nuanced view of market prices and uncertainties, especially during periods of high volatility or low liquidity.
Pyth Network was developed in an incubator program run by Jump Crypto, an arm of Jump Trading Group'; a large trading firm based in Chicago. This formative connection to TradFi helped foster the relationships that the project uses to retrieve real-world data.
Pyth network has since become a multi-chain solution for providing pricing data to the DeFi space and is securing over $4b in on-chain assets.
The initial iteration of the Pyth Network on Solana utilized a push oracle design, which received price inputs from data providers through Solana transactions, aggregated them on-chain, and updated the prices in the Solana environment every 400ms.
Despite becoming the most widely adopted decentralized finance (DeFi) oracle on Solana, the Pyth push oracle faced challenges during periods of high volatility and network congestion.
To overcome these limitations, Pyth Network contributors developed a new price oracle employing a pull oracle design.
Oracles are the backbone of DeFi, and Pyth’s high frequency oracle network has been pushing the space forward since 2021. The launch of their pull oracle on Solana gives developers greater control and optionality over how they consume oracle data, and paves the way for expansion into the growing world of new SVM networks. — Austin Federa, Head of Strategy at Solana Foundation
Pyth Network’s Pull Oracle utilizes a unique design where data providers publish price updates off-chain and sign them for verification. Users can then pull these updates on-chain when needed.
This approach eliminates transaction costs for the oracle and data providers, enabling:
1. Cost Efficiency:
Pyth’s pull model shifts transaction costs from the oracle to the user, who incorporates the price update into their transaction. This elimination of continuous transaction fees allows for a higher frequency of updates without the associated costs.
By removing the oracle’s burden of transaction fees, Pyth can support numerous price feeds across various blockchains, making it highly scalable compared to traditional push oracles.
2. Accuracy and Timeliness:
Pythnet’s off-chain updates are nearly free, allowing it to offer frequent price updates. This capability is crucial for accurately tracking asset prices, especially during volatile periods.
Pyth’s empirical analysis demonstrates a 5-10x reduction in price tracking errors compared to competitors. For instance, Pyth’s ETH/USD feed shows significantly lower deviations from the most liquid exchange prices than other oracles.
3. Security and Reliability:
By allowing users to pull prices on demand, Pyth reduces the risk of delayed updates during network congestion or busy periods.
Pyth streams off-chain price updates, signing each one for authenticity. This process ensures that only verified price updates are used, enhancing the reliability of the data.
Practical Implications for DeFi Protocols
Pyth's documentation details a comparative analysis between Pyth and several push-based oracles. The results demonstrate Pyth's superior accuracy in tracking asset prices on centralized exchanges. This is attributed to Pyth's high update frequency, which minimizes deviations from real-time market data.
The analysis highlighted a critical advantage: Pyth's lower right-tail deviations.
This metric signifies that Pyth's worst-case deviations from the true price are significantly lower than those of push oracles. This is particularly important for DeFi protocols. Migrating to pull oracles can fundamentally enhance DeFi protocols in several ways:
Enhanced Security: Reduced risk of outdated price data during network congestion, thereby mitigating potential vulnerabilities.
Cost Savings: Lower transaction fees for the Oracle lead to reduced costs for integrating multiple price feeds and supporting additional blockchains.
Increased Scalability: Ability to support a wider range of assets and blockchains, enabling the development of more complex and diverse financial products.
Improved Accuracy: High-frequency, on-demand updates ensure that price data closely tracks market prices, reducing the risk of arbitrage and improving overall market efficiency.
Conclusion:
Pull Oracles Deliver!
While push oracles have played a vital role in DeFi's early stages, pull oracles offer a more efficient and secure path forward. Their ability to scale, provide faster updates, and reduce costs makes them ideal for the evolving DeFi landscape.
Pyth Network serves as a prime example. With empirical evidence demonstrating substantial improvements in accuracy and cost-efficiency, the case for transitioning to pull oracles is compelling. As DeFi continues to grow, the migration towards pull oracles seems inevitable, paving the way for a more robust and efficient financial future.
References: