VIP-XX: Integrate with Pyth as an oracle

Disclaimer: I am a contributor to the Pyth network protocol through my work for the Pyth Data Association — more details on the association here.

Rationale

To further secure its users’ assets and the overall platform, Venus needs to build a more resilient and comprehensive pricing mechanism to avoid relying on a single source of truth which may very well become a “single point of failure” in certain scenarios.

Summary

This is a proposal to integrate (when possible) the Pyth network oracle price feeds as a secondary source for asset pricing on Venus Protocol.

Motivations

Deposited assets on Venus are gathered into a single pool: a single erroneous instance of pricing information used by Venus protocol can open the door to an attack and cause significant losses of users’ or protocol’s funds. Unwarranted liquidations of users’ positions is another important risk if the program were to be served erroneous pricing information.

Venus designing a highly robust system to accurately and fairly value every asset it supports (regardless of any situation) will generate even greater confidence from existing users and may attract new Venus users which will, in turn, increase the general amounts deposited and borrowed (and thus protocol revenue).

Timeliness of pricing information is also an important safety consideration for Venus’ design: not receiving a price may be just as bad as receiving an inaccurate one.

The motivation is to never ever again have these unfortunate events: (Venus Statement on) LUNA Incident #1 #2 #3

Pyth Network Background

What is Pyth?

The Pyth network is a first-party financial oracle network designed to publish continuous real-world data on-chain in a tamper-resistant, decentralized, and self-sustainable environment.

The network incentivizes market participants — exchanges, market makers, and financial services providers — to share directly on-chain (on Solana) the price data collected as part of their existing operations. The network then aggregates this first-party price data with a robust algorithm (still on-chain) and makes it available for free to either on- or off-chain applications. End-users of Pyth data will later be able to voluntarily pay data fees to gain protection against a potential oracle failure as well as attract additional publishers to make the network more robust.

Launched on Solana mainnet in August 2021, Pyth finished the year securing over $1B in Value (TVS), facilitated over $7B in trading (including perpetual and synthetics platforms), and with 38 announced mainnet integration partners and 41 data publishers. Since then, Pyth TVS reached about $2B spread over 50 integrations and welcomed more than 15 new data publishers. Find out about our users on the Pyth website.

While most Pyth users are on Solana and the Pyth smart contract (to generate prices) is also on Solana, our goal has always been to make previously inaccessible data available to all projects and users regardless of their blockchain base.

Thanks to Wormhole and the BNB Chain team, the BNB Chain will be the first blockchain outside of Solana to receive Pyth pricing data. We hope to empower leading BNB projects such as Venus into building more robust systems thanks to Pyth’s powerful data.

For more details on the Pyth network and how it will work once it becomes features-complete, I recommend the following: Pyth Whitepaper, Pyth Whitepaper Summary, Pyth Whitepaper Walkthrough, and Pyth Wiki.

Pyth Today

Rather than going into things not yet live, I will just focus on the current state of the network and highlight what is already live and working:

Pyth already supports 70+ price feeds for crypto, FX, equities, and metals. As Pyth goes live on the BNB Chain, we will look to support more assets that are popular on the BNB Chain. For reference, the BTC/USD price is derived from the inputs of 32 publishers directly interacting with the Pyth smart contract. Smaller (crypto) assets have for now about 8 publishers but we are actively working on increasing this number.

In addition to a high-quality set of publishers and a sophisticated aggregation algorithm, Pyth price feeds also come with extra features like a confidence interval and EMA prices.

The confidence interval represents the width around a price estimate in which publishers believe the true price probably lies. Each Pyth publisher reports both a price estimate and confidence interval (for that estimate) to be aggregated, and the aggregated price will have its own aggregated confidence interval value. More information is available here. We look forward to producing recaps of Pyth’s performance in the highly volatile periods.

Pyth also offers an exponentially-weighted moving average (EMA) price and exponentially-weighted moving average (EMA) confidence. These values are time-weighted averages of the aggregate price and confidence. Both the EMA price and confidence are natively available from Pyth price accounts. More information on this here.

More details can be found here: Pyth Publishers, Pyth Consumers, Pyth Metrics. Pyth Docs.

Pyth x Wormhole x BNB Chain

Pyth prices are published on Solana and relayed to EVM chains using Wormhole Network as a cross-chain message passing bridge. Wormhole Network observes when Pyth prices on Solana have changed and publishes an off-chain signed message attesting to this fact. (A more detailed explanation can be found here).

This signed message can then be submitted to the Pyth contract on the EVM networks, which will verify the Wormhole message and update the Pyth contract with the new price.

Price updates are not submitted on the EVM networks automatically: rather, when a consumer needs to use the value of a price, they should first submit the latest Wormhole update for that price to the Pyth contract on the EVM network they are working on. This will make the most recent price update available on-chain for EVM contracts to use. Updating the price needs to be done in an off-chain program, using the pyth-evm-js package.

The Pyth oracle is currently live on the BNB Chain Testnet — Contract address: 0x621284a611b64dEa837924092F3B6C12C03C386E — and we are looking forward to deploying it on Mainnet once we receive a positive security audit. BNB Chain Testnet currently receives pricing information for 6 assets (ALGO, BTC, ETH, LUNA, USDC, UST), but all Pyth price feeds will be deployed once we release on Mainnet.

It’s still early days in terms of making Pyth data available on other chains. There are many exciting developments to be made, and we would be honored to work alongside Venus and other BNB Chain dApps to create the best experience of using Pyth from BNB Chain. An example of such developments includes a ‘decentralized’ vault where dApps could collectively allocate funds to trigger frequent updates at a marginal cost to each dApp. Other improvements being looked at are failsafes for periods of Solana congestions.

Specification

Venus x Pyth Supported Pair

Venus currently supports the following assets on its platform: UST, DOT, DAI, CAKE, MATIC, AAVE, TRX, USDC, FIL, BNB, TUSD, ADA, USDT, BUSD, BCH, LTC, LINK, BETH, XRP, BTCB, DOGE, ETH, SXP, XVS, LUNA, and VAI

Not all these Venus markets have corresponding Pyth price feeds yet. What’s currently missing: DAI, CAKE, AAVE, TRX, FIL, TUSD, BUSD, LINK, (BETH), XRP, (BTCB), SXP, XVS, and VAI

Alongside our deployment to the BNB Chain, work is already being done to onboard new assets such as BUSD and TUSD. If this proposal is positively received by the community, we would look to rapidly supporting more of the Venus platform-supported assets (XVS and VAI especially).

In turn, Venus could expand the assets supported on its platform and further boost its deposited assets and TVL by integrating with Pyth. Solana protocols would also be able to easily leverage BNB Chain assets, which would increase their overall utility.

Discussion

How can Venus’ oracle module be the most accurate and resilient in cases of prolonged and intense market volatility as well as be robust to any operational issues experienced by its selected sources of pricing information?

References

Pyth Data Association

Pyth Website

Pyth Whitepaper

Pyth Whitepaper Summary

Pyth Whitepaper Walkthrough

Pyth Wiki

Pyth Docs

Pyth Publishers

Pyth Consumers

Pyth Price Feeds

Venus Statement on LUNA Incident #1 #2 #3

3 Likes

Interesting. I can see the advantage of connecting Venus to the Solana ecosystem. However Pyth seems still premature, not tested to a similar extent as for instance chainlink and the monetization not yet started. When pyth token? If there are two systems and a mismatch , which one is telling the “truth”?

1 Like

You could use Pyth as a fallback oracle, and maybe Band Protocol if it is available on BNB.
The oracle of Scream Protocol is an example of such superposition of oracles, sorted by priority in the oracle contract.

1 Like

Solana has gone down 7 times the past year, with the latest outage being literally yesterday. Doesn’t this mean if/when it goes down again, Venus won’t have fresh price data in the event of going to a fallback mechanism, because Solana needs to be ‘up’ to have fresh price data published (which then flows through to BNB via Wormhole)? These outages always seem to last for literally hours. Having hours old price data will lead to exploits as we’ve seen recently. Please correct me if I got any of this wrong?

But if I’m right, to me that sounds like a risk to take on, even if only as a fallback mechanism. You’re essentially putting the the security and integrity of Venus Protocol in the hands of the availability of the Solana network whenever it has to default to a fallback mechanism. The fallback should be just as good as the primary solution in its security & reliability guarantees

1 Like

I’d argue that we should judge the oracle based on its design and its performance during extreme market situations like the most recent LUNA/UST incident.

In my view, Pyth is definitely the dominant oracle in the Solana ecosystem with more than 90% of DeFi protocols on Solana using Pyth. They grew rapidly because of their design, safety features, and data quality standards. This is even before having a token.

More specifically, Pyth is unique in its offering of confidence intervals, minimum publisher rules, fully on-chain aggregation, and a network design that only allows for high-quality (first-party) data sources

Because of its unique network design, Pyth has an extremely transparent aggregation method as well as the ability to introduce useful metrics like the confidence interval. Confidence intervals are especially great for user safety, protocols can now take into consideration the conviction in a price’s certainty before liquidating

Now that Pyth is launching on BNB, the features mentioned above will be extremely enticing for DeFi protocols there too. I think Venus should take the opportunity to be one of the first BNB Chain protocols to leverage Pyth’s modern oracle design.

As for how Venus could handle both oracles, I can think of a few possibilities:

  • Keeping Chainlink as the main oracle, Pyth as a fail-safe
  • Making Pyth the main oracle, Chainlink as a fail-safe
  • Combining Chainlink and Pyth into a single oracle module.
2 Likes

Hey! Thanks again for the comment!

Pyth acknowledges the Solana dependency is suboptimal for non-Solana dApps and will have redundancy before going live on the BNB Chain & BAS mainnet.

Pyth currently uses Solana mainnet-beta as the layer where all price aggregation occurs. Solana was selected because it is (1) a very fast and low-cost public blockchain that makes it possible for data providers to publish their price updates on-chain, and (2) an easy place for anyone with a general understanding of blockchains to be able to validate the provenance of the aggregation and data provided.

All these have served Pyth very well in building a reputation as a transparent oracle with publicly announced first-party data sources.

Solana in its current state is not without its own growing pains as correctly pointed out. While the news tends to exaggerate the downtime with some arguments, it’s closer to 4 halts rather than 7, in either case, it’s a problem — #1 #2. Pyth data needs to be available to be used.

The core engineering team is working on redundancy so that even when Solana is down, Pyth prices will remain available on the BNB Chain and other BAS ones. We value downstream applications’ security and need to have access to accurate & timely data so Pyth will not go live on the BNB Chain or any other BAS mainnet until this the redundancy is hardened and working.

We’ll be discussing more Pyth things with the Venus team and you, the community, on Wednesday, June 8 @ 16:00 UTC in Venus Discord, so be sure to tune in.

2 Likes