🔮 Pyth Network, the best oracle for high-frequency financial data❓
Do you know what is an oracle and their importance? 🔮 Learn more about Oracles and Pyth Network, one of the best on Solana!
Welcome to episode 4 of my adventures on Solana! 🚀
Many of the DeFi apps we use require to get some sort of information from the outside world (or off-chain). Getting the asset price of $TSLA or $BTC requires the use of a blockchain oracle.
That’s why Chainlink or Pyth Network are so important to our use of this technology.
And today, I will talk about my fav 🥰
Pyth Network!
🙋♂️ What is an Oracle?
An oracle is like a messenger that helps computers get information from the outside world. It is like a bridge that connects the world of blockchain with the real world.
Thus, an oracle should provide a secure, reliable, and fast way to get data from external sources. This can be used to verify transactions and verify the accuracy of data. It can also be used to pull data from external sources such as stock prices, weather data, and more. This data can then be used to create smart contracts and automated processes.
This makes oracles an invaluable tool in the world of cryptocurrency and blockchain.
🔥 Why are they necessary for DeFi apps to work?
Defi apps are revolutionizing the way we interact with money. By taking advantage of blockchain technology, these apps allow users to interact with financial products without the need for intermediaries such as banks or brokerages.
Without the use of oracles, DeFi applications would not be able to interact with real-world data. This would make it impossible to create products that require real-world information, such as derivatives or Borrow/Lending protocols. Oracles are necessary for real-time data and price feeds, which are needed for DeFi applications to function properly.
Oracles work by connecting to external data sources and providing the information to a blockchain-based application. The oracle will query the data source, verify the data, and then provide the information to the application. Oracles are typically implemented as decentralized networks, which ensures the data provided is secure and reliable.
🔮 Pyth Network
The Pyth Network has established a direct bridge between data sources and the blockchain, helping applications get high-quality data.
Data is sourced from traders and exchanges and is aggregated to produce reliable, and fair price feeds.
The oracle was launched in April 2021 and went live on Solana mainnet in August 2021. In mid-2022, Pythnet was launched which makes Pyth data available to any chain supported by Wormhole, the cross-chain messaging protocol.
It provides a different solution to the oracle problem, with tailored SDKs to assist with both on- and off-chain integration of price feeds into Defi applications.
🏭 Process
The Pyth Network consists of three main stakeholders:
70+ Publishers, who provide price information directly on the blockchain and earn a portion of the data fee. These publishers includes among others CBOE, Jane Street, and Binance. (full list here)
90+ Consumers, who read price information and pay for it to the likes of Synthetix, Solend and Drift. (full list here)
Delegators, who stake Pyth tokens to earn a portion of the data fees.
The publishers stream a price along with a confidence interval, based on available information, to increase the trustworthiness of the data for consumers.
Here is the list of 200+ price feeds made available on chain by Pyth.
🧮 Pyth Price & Confidence Interval Calculation
The Pyth smart contract is responsible for the price aggregation of all the publishers inputs received into a consolidated price. But how do they do it?
With their aggregation algorithm!
🧗♂️ This aggregation algorithm is designed with three goals in mind:
”Robust to manipulation” Imagine 99 publishers submit a price of $23 for $SOL and 1 publisher with $1. The Pyth price should remain near $23 and not be too influenced by the one outlying publisher. This ensure that “dishonest” or “bad” actors do not impact the price aggregation.
“Aggregate price should appropriately weight data sources with different levels of accuracy” Publishers submit a confidence interval to determine their level of accuracy for a product (price of $SOL). Pyth can find itself with one publisher reporting a price of $23 +/- 1, and another $14 +/- 10. If this happens, Pyth want to be closer to $23 than $14.
“Aggregate confidence interval should reflect the variation between publishers’ prices” This is specific to a scenario where exchanges do not price a product similarly ($3, $8, $12, etc…) and CIs that do not overlap. In this case, Pyth will widen its confidence interval to represent these different prices.
With these goals, the algorithm’s first step is to give each publisher three votes (one for each of their price) and take the median.
Second step is to determine the confidence interval. The algorithm “computes the distance from the aggregate price to the 25th and 75th percentiles of the votes, then selects the larger of the two as the aggregate confidence interval” (Pyth blog).
🧠 Want the full detailed price aggregation and algorithm explanation? Check this Pyth blog post and the docs 📄!
🏎 Update frequency
These price feeds are update every 300ms on Pythnet and Solana mainnet.
As for EVM (Ethereum Virtual Machine) chains, Pyth work as a pull model.
This means that any app or user requesting a price feed will update the Pyth on-chain smart contract with the latest price and can be used on the chain.
⛓ Chains
Thanks to its integration with Wormhole, Pyth is available on 15 chains (Ethereum, BNB, Avalanche, …).
Because of its speed, Solana offers an ideal environment for a project like Pyth to build the product in a cost efficient manner.
🔗 Links
Website - Twitter - Discord - Documentation - Analytics - Pyth Alligator NFT
I mentionned Chainlink in the intro, here is a comprehensive table comparing the two oracles (made by Pyth).
Hope you enjoyed this piece about oracles and Pyth.
⚠️ Important to remember
I am not best suited to say if Pyth is the best in the space. I have a bias but trying to lay out the facts as simply and clearly as I possibly can.
But iykyn 🔮
Make sure to signup to join me on this journey and share it to your friends! 🤗