Pyth-The Premier Oracle for Low Latency High Fidelity Price Feeds
The term “oracle” originates from ancient Greek mythology, where it referred to an entity(usually a person or sometimes an inanimate object) that could communicate with the Gods and had visions of the future. The name ‘Pyth’ is inspired from Pythia, who was the most well-known and influential among all the oracles.
Pythia was the name of the high priestess of the Temple of Apollo at Delphi. She specifically served as its oracle and was known as the Oracle of Delphi. The name Pythia is derived from Pytho, which in myth was the original name of Delphi.
What is an Oracle and Why do We Need It?
Blockchains are inherently closed off deterministic systems. That means the nodes need to arrive at a shared consensus following the consensus protocol. It also means that introducing external data, which cannot be validated by consensus protocols, becomes near-impossible.
Consider this. You have built out a simple decentralized loan application. The customer deposits a collateral(eg. BTC) in your app and takes out a loan. Pretty simple right? Not really.
- How do you determine the price of BTC at that time? Going further down the rabbit hole, what is really the ‘price’ of an asset, because at any time on an exchange there is a bid-price, and an ask-price for the asset ( We’ll see how Pyth handles this difference, called the ‘bid-ask spread’ later in our quest).
- Another problem is exchanges with low liquidity on their order books are often prone to violent price swings( because they have a high spread). How to determine which exchange will be reliable for determining the price?
- How do you deal with outright malicious agents who will submit manipulated BTC prices to take out an under collaterized loan?
It is here that the need for an oracle comes into the picture. It will act as a decentralized trustless source of such external information, like price feeds. It achieves this by designing incentives for providing accurate data ( eg. the more accurate data some entity provides, the more they are rewarded) and disincentives for providing false/malicious data. Thus, all the nodes of the blockchain can arrive consensus at external data from an oracle.
Pyth Fundamentals
Financial market data is often accessible to only a limited set of institutions and users. The Pyth network is a next-generation oracle solution that aims to bring this valuable financial market data to the general public.
There are basically 3 stakeholders in the Pyth ecosystem: the data providers, the stakers and the consumers of the data feeds.
- Data publishers are premier finance institutions which provide low latency data to the network. Any entity needs to stake tokens to publish data on the network. The reward structure is incentivized in such a way that the institutions giving the most accurate data(in terms of lowest latency and tighter confidence intervals) are preferentially rewarded. On the other hand, entities providing erroneous data will be penalized a portion of their stake.
- The consumers can choose to pay a data protection fee for the data feeds that their apps are consuming. In such a case, if a data publisher provides erroneous data, the penalized portion of their stake is used as a guaranteed payout to the affected consumer.
- The delegators stake tokens for the authenticity of a data publisher, and earn a share of the data protection fees paid by the consumer. Currently the data protection fees are split among the delegators and publishers in a 4:1 ratio. Delegators will lose their stake if the publisher provides erroneous data.
Integrating Pyth into your Products
Pyth currently has SDKs to integrate into products running on the following chains, along with off-chain SDKs in JavaScript, Rust, Python and Go.
Essentially, Pyth will supply you the price in the form of a price component, the confidence interval and the exponent.
In the above example, the confidence interval of the entity is $(1500*10^(-5)) = $0.015 and the price component is $(12276250*10^(-5)) = $122.7625, so essentially the price of the asset ranges between $122.7475 and $122.7775. Publishers providing tighter confidence intervals are rewarded better.
Another tip when using the Javascript off-chain SDK is to configure it so that you query the price of an asset when needed, rather than keeping a subscription open to the Pyth network. In the latter case you keep getting price updates at the rate of Solana’s high throughput and pretty soon your Chrome development console will get overwhelmed or you’ll get the following error that you have run out of calls you can make to the oracle.
Pyth Integrations
It is near impossible to list out all the organizations using Pyth. New integrations are being added each day. These products range from derivative instruments, decentralized exchanges, borrowing/lending, staking, yield farming, etc. You can visit here to see the list of existing consumers and follow them on Twitter to stay up to date on their latest integrations.
Competitors and Scope to Improve
Any oracle project cannot ignore Chainlink. Chainlink, like Pyth, is multichain and provides data feeds to both Solana and Ethereum. The main difference lies in the fact that Chainlink relies on third party nodes for the information they provide, whereas on Pyth the nodes are run by the data providers themselves. So essentially Pyth cuts out the “middle-man”. Pyth also provides lower latency data taking advantage of Solana’s high throughput. Chainlink beats Pyth on the fact that it provides a wide array of data types apart from price feeds(such as weather data, sports, etc.) however the fact also remains that 99% of data consumed by defi apps is financial data.
Other oracles building on Solana include SwithBoard, Umbrella and Dia.
If Pyth manages to bring other data types on their network, as well as ensure that costs remain low (especially on Ethereum, notorious for its high fees), it will be well on its way to being a game-changer in this industry.