A Deep Dive into the Pyth Network
Oracles are the data engines to a magical spacecraft called Web3!🔮
It was ancient Greece, where there was a firm belief in the Oracles, they were people who mediated as translators between questions by humans and answers by the gods.
In ancient Greece, each god had his own Oracle, and the most famous one of all is PYHIA, a woman who is an oracle of Apollo, the sun god. And as you can observe the ancient oracle is very similar to our Pyth network in name and functionality.
Like an ancient oracle is assigned the task to communicate with god and truthfully transfer information to the one who asked the question, Decentralized Oracles do the same job, by communicating with nodes, collecting data, and truthfully transferring data to the consumers.
(😎 Before diving deep..)
(And the crystal ball says, you are going to love the rest of this article! ❤️)
In the next section let us find out what is an oracle and its use in the working of a smart contract, using a real-life application-oriented example! 🚀
What is an Oracle in Web3?
We know that:
WEB1: is about reading the data on the internet,
WEB2: is about interacting with data on the internet by enabling seamless read and write capabilities, i.e., the present-day internet, con
WEB3: is all about read-write-own pieces of the internet in a truthful, transparent, and secure way.
Everything in WEB3 is enabled using blockchain technology coupled with SMART CONTRACTS. But what are they? In short, they can be termed as a code that is run on top of a blockchain network that takes data as input and when this data triggers an action, the smart contract automatically executes this action, without any manual intervention.
Let us understand this with an example. Let us assume the case of a LOAN COMPANY, where the company gives a candidate a certain amount of loan to start his/her business based on the value of the collateral they keep under the company’s control. If the candidate gave his/her shares in an XYZ company as collateral to the loan company, based on the current value of the shares, the interest rate of the loan is adjusted every month.
This process can be automated using smart contracts and loans can be given to anyone who submits their shares in return under the ownership of the contract.
BUT, how does the contract know the current value of the stock, to adjust the interest on the loan price?
Can it take a single source of a centralized external platform or entity as its primary source of data?
What if the single source gets down, then there is no data to adjust the interest rate.
What is the source is centralized and the data is rather controlled by an entity.
These points are completely against the principles of web3 and blockchain, which keeps truth and decentralization as their principal ideals.
To overcome these problems faced by smart contracts in dealing with external data, Oracles have come up as an infrastructural data service, to collect, aggregate, and truthfully deliver the data to the consumer contract.
In this article, we are going to deep dive and understand one of the most used Oracle networks on the Solana blockchain, Pyth Network, to understand its working, advantages, potential, and progress!
Introduction to Pyth Network 🔮
Pyth network is a decentralized oracle, which aims to provide blockchains with accurate external data, especially financial data and price feed of various entities like:
Equities
Commodities
Cryptocurrencies
Pyth network solves the problem of accurate and decentralized data transmission to blockchains, using key concepts like Multiple-Party data aggregation, confidence intervals, incentivization, resolving claim processes using the HUMAN protocol, etc.
In this article, we study these key concepts, the landscape around the Pyth network, and Oracles in general as follows:
Components of the Pyth network
As we saw earlier the Pyth network operates the oracle to transmit real-time external data to the smart contracts on the blockchain. The components which run this network are:
Publishers
Price aggregation mechanisms
Consumers
Delegators
Publishers
Publishers are the sources of information that deliver the data to the oracle. The beauty of the Pyth oracle lies in the fact that it collects the same data from various publishers of information. Using various price aggregation methods the Pyth oracle aggregates this data from various sources into a singular endpoint, for the consumers to access.
The publishers are then rated based on the quality of data or accuracy of data they provide to the oracle. The higher a publisher is rated by the oracle, the higher share of incentives they get from the reward pool, and vice-versa.
This reward based incentivization by the Pyth network, forces the publishers to provide truthful data, to get better rewards.
In a short period of time, Pyth network managed to get a huge list of trustworthy names in the crypto and DeFi industry as its data publishers this list includes:
FTX
Jane street
Jump Trading
OKX
Gemini, and 70+ more companies.
Price aggregation mechanisms
Imagine if there is a single publisher who is ready to incur incentive losses by providing wrong data to the oracle, but aims to compromise the consumers who use this data.
To maintain the robustness of the oracle, the Pyth network uses several price aggregation mechanisms to finalize the final data endpoint before delivering it to the consumers.
There are broadly two types of price aggregation mechanisms in the Pyth network:
Simple moving average aggregation
Exponentially weighted moving average aggregation based on time intervals
Let us now explore the first and primary price aggregation mechanism:
Simple moving average aggregation
In simple moving average aggregation, the algorithm considers the FOUR most important conditions to evaluate an optimal aggregate point, they are:
Managing outliers
It is important for the aggregation mechanism to eliminate outliers in the data if they have a negative impact on the average of the remaining members in the cohort. This can be seen in the above (fig a).
Hence when a platform provides a data point that stands at 100 and if a sufficient number of other platforms provide data at 180, the platform with 100 as the data point is considered an outlier and ignored from the aggregation.
This prevents individual platform exploitation or single point of failure of the oracle while evaluating the aggregate.
Evaluation based on confident intervals
Confidence intervals are uncertainty ranges given by the platforms along with the data endpoint. These help the aggregation protocol to make sure how confident the entity is on the provided data.
For example, a platform with a data value of 100, with a confidence interval of +/-1 indicates a tight confidence interval, thus highly confident in the given data.
From (fig b) we can understand that the aggregated value swings closer toward data points with higher confidence intervals.
Vote-based weighting mechanism
The aggregation protocol considers three key parameters as votes and the higher the votes received by a platform’s data value, the greater its weight contribution towards the final aggregate value.
The three key parameters to be voted on are:
a. One vote on the price
b. One vote on the positive confidence interval
c. One vote on the negative confidence interval
Percentile based median
In the final check, the aggregation protocol takes the above-mentioned votes and takes the median between the 25th and 75th percentile of the individual votes, and takes the larger distance between them as the final aggregate confidence interval.
BUT, what if a platform or an entitiy which has been a good data provider since a long time starts to manipulate the data all of a sudden? Then it takes time for the system to recognize the attack, as it takes time to reduce the positive weights gained by the platform since long time.
Question: So how can the aggregation platform respond quickly to the attack by a data providing source?
Answer: Exponential weighted moving average!
Exponential weighted moving average
This is not much different from a simple weighted moving average, but it adds an additional column to the protocol, time.
EMA, calculates the weights to each data value based on the goodness or the accuracy of data since the last x mins, or a certain fixed time period.
This allows the protocol to calculate the local accuracy of the entity hence allowing it to quickly respond to any manipulation by even a once highly trustworthy entity!
Consumers
For oracles like the Pyth network, the consumers are the smart contracts running on top of blockchain networks. In the case of the Pyth Network, it is specially built for the Solana Blockchain to revolutionize the DeFi ecosystem on Solana.
Pyth network initially built its protocol on top of Solana, to take advantage of the network’s sub-second latency transactions, which are very important for updating the real-time price feeds in financial markets.
But the Pyth network didn’t stop there, instead, it spread its endpoints to various other chains like EVM-based Ethereum L2s (Polygon, Avalance, etc) and upcoming onto Cosmos chain, etc. More about these cross-chain applications in further sections.
Pyth network emerged as the largest oracle on the Solana DeFi ecosystem within no time, with multiple major consumers from all segments of the Solana ecosystem ranging from Trading to Infrastructure, Data services to Analytics, etc using their services. The major consumer platforms include:
The primary reasons why consumers are getting attracted to the modern Pyth Network Oracle, compared to other legacy oracles are the incentivization program and payouts available in case of data manipulation.
Pyth network collects DATA FEES from the consumers to pay the publishers and delegators to ensure the stakes for maintaining accurate data. At the same time, this allows the network to make sure the publishers and delegators have something at stake when the data is inaccurate. This stake is given as a payout to the consumer whenever there is an inaccuracy in the data. All the above transactions are done using a native token called the $PYTH token!
Delegators
Delegators are a crucial component in the working of the Pyth network as an oracle. They stake their $PYTH tokens against a data endpoint like the value of Gold in the metals section, or the value of GOOG 0.00%↑ stock price (Google), implying that they strongly believe that the current price of the stock or metal is accurate from a certain publisher.
This staking by the Delegators increases the confidence in the accuracy of the prices, and if the accuracy is maintained over a period, the delegators earn a share of the DATA FEE, collected from the Consumers!
And if their prediction on the accuracy is wrong, i.e., the data is inaccurate, then the delegators lose their stake in the data and this stake is returned to the consumers as a payout for the damage due to the wrong data!
No wonder, why customers are queuing to the Pyth network to get safe and insured data! Pyth Consumers always be like:
Core working of the Pyth network as an Oracle
As mentioned in the components section, the primary components in the working of the Pyth network as a decentralized oracle are:
Publishers: Who send the data to the oracle
Aggregation protocol: This finalizes the end value of the data endpoint
Delegators: People who stake value to maintain the accuracy of the data
Consumers: Smart contracts which consume the data generated from the Oracle
Other Key concepts are:
Claim process: The process in which the reward pool and the consumer payouts are managed using a specialized, automated protocol called HUMAN protocol!
Governance: Using the $PYTH tokens Publishers, Delegators and Consumers can vote for changes in the Pyth oracle structure and the organization’s upcoming decisions.
CORE WORKING FLOW:
As shown in the above diagram the Publishers start the process of transmitting price data to the oracle.
This data is aggregated using the SMA and EMA mechanisms to finalize the data endpoint to be supplied to the consumers.
Consumers use this data endpoint to access the external data in a safe, decentralized, and secured fashion from the Pyth oracle, to process and use in their smart contracts. In exchange, they pay a DATA FEE to the Pyth network’s reward pool!
At the same time, the delegators stake their $PYTH tokens to initiate the claim process and maintain the accuracy of the data. If the data proves to be accurate they earn a share from the DATA FEE, which is sent to the Publishers from the Consumers.
And if the data proves to be inaccurate to compensate for the loss incurred by the consumer, both the stakes of publishers and delegators are cut short and given to the Consumer as a payout
Cross-Chain performance of Pyth: A game-changer 🪄
It is mentioned earlier in the article that Pyth Network is a Solana Blockchain-based decentralized Oracle to facilitate data infrastructure on Solana. Before diving deeper let us understand why Pyth network chooses Solana as its first choice:
Solana is the fastest blockchain network among the Popular names like Bitcoin, Ethereum, etc. To put this into persepctive Bitcoin takes 10 minutes to generate a block, at the same time Ethereum takes 10-20 seconds to generate a block. Solana takes a record time of just 400 milli seconds to generate a block!! This makes the Solana network, the most suitable form of blockchain to maintain decentralized real-time transactions.
Every data pushed into the oracle by the publisher nodes, are nothing but on-chain transactions, which might proove very costly on other networks, but Solana is one of the cheapest networks available to push transactions regularly without much cost to the end users.
These properties of Solana allowed Pyth to build an on-demand decentralized oracle to transmit data between publishers and consumers, in a cheap and rapid fast fashion.
But this is not the case with other prominent EVM-based and other blockchains. Hence Pyth is expanding to other networks to solve their legacy oracle problem using WORMHOLES!
A wormhole is a transaction protocol built to facilitate seamless transactions between two different networks. Pyth uses this generic wormhole messaging protocol to transmit data between networks, but how??
Pyth x Wormhole workflow:
Initially, the pyth contract on the Solana blockchain receives the data from the Publishers and when this data is aggregated and ready, it is pushed to the wormhole.
Now on the other side of the wormhole lies a Pyth smart contract of the specific chain in which the data needs to be transferred. For example, let us consider it to be Ethereum, then any protocol can request data from the wormhole onto the Pyth contract and read the data from the contract.
This data once entered into the Ethereum Pyth contract can be read by any other protocol on the Ethereum protocol. This reduces transaction costs, and increases the speed of data transmission at the same time!
Pyth already expanded to the BNB chain and most of the other popular EVM L2s like Polygon and Avalance!
This feature is a game-changing ability in the hands of the Pyth network to establish itself as the market leader in decentralized Oracle infrastructure across chains! Because who doesn’t want high-speed transactions at a cheap cost on-demand?
Oracle landscape and Pyth’s competitors👊
Pyth network manages over 90% of the decentralized oracle transactions on the Solana Blockchain, thus making itself the market leader on Solana. Whereas coming to other blockchains like Ethereum, there are still some popular oracles out there giving a fight to Pyth, let us explore what are they!
Chainlink: Chainlink is one of the most popular decentralized oracles in the Ethereum network, where it transmits data across various topics from Finance, Sports, Weather, etc. It also provides Randomness data, which is a crucial factor in building abstract patterns and designs in a crypto product like NFT, this is a much-needed feature for smart contracts. Chainlink expanded itself to Solana in a limited launch, aiming for a much bigger expansion.
DIA: DIA or Decentralized Information asset is another popular decentralized oracle protocol, which is basically an open-sourced, customizable and transparent oracle for web3. DIA offers customizable data feeds along with a randomness much-like chainlink.
Switchboard: Switchboard is another Solana-based decentralized oracle, which offers all the features offered by chainlink and DIA like customizable data feeds ranging from oil barrel prices to weather reports, SAP prices to Crypto volume analytics!
Other similar prominent oracles across chains include:
OKAY!! All these decentralized oracles seems to be good, but WHY SHOULD I CHOOSE PYTH OVER OTHERS!
Here we have 100s of Oracles available across the chains, and we know that the fastest and cheapest chain of all is Solana, so only 10s of chains inherit them like Pyth itself and other oracles like Switchboard.
From these 10s of Oracles on Solana, PYTH IS THE ONLY DECENTRALIZED ORACLE TO HAVE:
a. Incentivized mechanism for Delegators and Publishers.
b. Data assurance pay-out mechanism to the consumers.
c. Cross chain validity using wormhole and on-demand data requests!
Yes Pyth have a few features which it needs to be the true dominating force in the decentralized oracle space, which we will discuss in the next section!
Missing pieces to become a dominating force!✨
Pyth has many unique features ranging from multi-chain support, with native Solana like speed and cheap costs, insured payouts to consumers for data mishaps, etc. But there are still some essential features that Pyth needs to imbibe to become the true leader across chains:
Expansion to various other data feeds, other than financial pricing data. This customizable option gives users a chance to collect data feeds into their smart contracts from a wide catalog of options and also caters to a wider audience.
Adding verifiable randomness to the data feeds! Generating random data is surprisingly hard on smart contracts because of their transparent nature, which makes all their properties visible to the public. Hence getting random data from an oracle helps developers in the:
a. Development of open-world metaverse games like Minecraft.
b. Generating random IDs for unique products.
c. Creating unique NFTs, etc.
Conclusion
From the above discussion, we can clearly understand how important decentralized oracles are to the working of smart contracts, to perform any meaningful operation to interact with the external world.
Analyzing the dune analytics statics of Pyth networks which
clearly shows how fast the oracle has grown over a couple of years, this proves that Pyth has an amazing path forward as a cross-chain oracle leader, and I am as excited as you all to witness this journey!
Hope you all enjoyed reading through my article!❤️
By,
Rohit Kumar Varma
(Excited to connect with you folks at, Twitter ❤️)
References: