This repository was archived by the owner on Aug 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,12 @@ | ||
# Cross-chain | ||
|
||
Pyth needs a cross-chain component to ferry prices on [Pythnet](pythnet.md) to target chains. Pyth Network uses a “pull” update model for target chain prices: instead of continually pushing updates to each target chain, users pull the prices on-chain when they are needed. This pull model is highly scalable and allows Pyth Network to deliver high-frequency price updates for a large number of products without overwhelming the transaction capacity of target chains (or incurring excessive gas fees). | ||
|
||
The diagram below shows how prices are delivered from Pythnet to target chains. | ||
Pyth uses a cross-chain mechanism to transfer prices from [Pythnet](pythnet.md) to target chains. | ||
The diagram below shows how prices are delivered from Pythnet to target chains: | ||
|
||
 | ||
|
||
Data providers publish their prices on Pythnet. The on-chain [aggregation program](price-aggregation.md) then aggregates prices for a feed to obtain the aggregate price and confidence. Next, the attester program regularly attests to the most recently observed Pyth prices and creates a Wormhole message to be sent to the Wormhole contract on Pythnet. The Wormhole guardians then observe the attestation message and create a signed VAA for the message. | ||
Data providers publish their prices on Pythnet. The on-chain [oracle program](oracle-program.md) then aggregates prices for a feed to obtain the aggregate price and confidence. Next, the attester program regularly attests to the most recently observed Pyth prices and creates a Wormhole message to be sent to the Wormhole contract on Pythnet. The Wormhole guardians then observe the attestation message and create a signed VAA for the message. | ||
|
||
The price service API continually listens to Wormhole for Pyth price update messages. It stores the latest update message in memory and exposes HTTP and websocket APIs for retrieving the latest update. (Anyone can run an instance of this webservice, but the Pyth Data Association runs a public instance for convenience.) When a user wants to use a Pyth price in a transaction, they retrieve the latest update message (a signed VAA) from the price service and submit it in their transaction. The target chain Pyth contract will verify the validity of the price update message and, if it is valid, store the new price in its on-chain storage. | ||
The price service API continually listens to Wormhole for Pyth price update messages. It stores the latest update message in memory and exposes HTTP and websocket APIs for retrieving the latest update. (Anyone can run an instance of this webservice, but the Pyth Data Association runs a public instance for convenience.) When a user wants to use a Pyth price in a transaction, they retrieve the latest update message (a signed VAA) from the price service and submit it in their transaction. The target chain Pyth contract will verify the validity of the price update message and, if it is valid, store the new price in its on-chain storage. See [on-demand updates](pythnet-price-feeds/on-demand) for more details about this process. | ||
|
||
Finally, on-chain protocols integrate with the Pyth contract via a simple API that retrieves the current Pyth price from its on-chain storage. This API will return the current price as long as it has been updated sufficiently recently; this approach works because users will have updated the Pyth price earlier in the same transaction. Protocols can configure the recency threshold to suit their needs — e.g., latency sensitive applications can set a lower threshold than the default. | ||
|
||
|
||
|
||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +0,0 @@ | ||
--- | ||
description: >- | ||
For more information, visit the Pyth whitepaper | ||
https://pyth.network/whitepaper | ||
--- | ||
|
||
# How Pyth Works | ||
|
||
Growth in DeFi requires high-fidelity, time-sensitive, real-world data, direct from the source and made available on any L1 blockchain. Financial market data, however, is often accessible to only a limited set of institutions and users. Traditional markets typically maintain strict control over and access to both live and historical price feeds. Consequently, only a selected group of users has access to the most timely, accurate, and valuable information. | ||
|
||
The Pyth network is a next-generation oracle solution that aims to bring this valuable financial market data to the general public. The network does so by incentivizing market participants — trading firms, market makers, and exchanges — to share directly on-chain the price data collected as part of their existing operations. Pyth's data providers include some of the largest **traders**, **exchanges**, and **financial services** players who create unique high quality market data. This includes real world market data in **equities**, **fx, crypto, and metals with ambitions to scale across asset classes**. Data publishers include Jump Trading Group, [GTS](https://pythnetwork.medium.com/new-pyth-data-provider-gts-555c4d0e362b), Jane Street, Hudson River Trading, [LMAX](https://pythnetwork.medium.com/new-pyth-data-provider-lmax-dd05264d1a16), [Virtu](https://pythnetwork.medium.com/new-pyth-data-provider-virtu-financial-ed09143f44d5), [BSX](https://pythnetwork.medium.com/new-pyth-data-provider-the-bermuda-stock-exchange-ccf3c04bd430), [CTC](https://pythnetwork.medium.com/new-pyth-data-provider-chicago-trading-company-64a457340443), and [many more](https://pyth.network/publishers/). | ||
|
||
The network then aggregates this first-party price data (still on-chain) and makes it available for use by either on- or off-chain applications. | ||
|
||
End-users of Pyth data can elect to pay data fees to gain protection against a potential oracle failure. As data publishers must stake tokens in order to publish data for a product, the stake of at-fault publishers (if they make the aggregate price erroneous) will be used as a payout to those end-users voluntarily paying fees. Delegators choose which product (price feed) and a publisher to stake on top of in order to earn data fees (or lose their stake if the oracle is inaccurate due to publisher faults). Initially, 80% of the data fees will go to delegators while the remaining 20% will be shared among publishers — this, among other parameters, will be subject to change through a PYTH governance. | ||
|
||
The goal of the design and mechanics around the PYTH token aim to make the Pyth network self-sustaining and decentralized. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Oracle Program | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added this page mostly because it makes the left nav menu make more sense. At the moment, the nav menu goes from "cross chain" to "Solana Account Structure". I think there needs to be a transition between those. |
||
|
||
The oracle program is responsible for several tasks: | ||
|
||
1. Maintaining the set of price feeds. | ||
2. Storing the contributions of data providers to each price feed. | ||
3. Combining the individual data providers' prices into a single aggregate price and confidence interval. | ||
4. Performing any additional stateful computations on the resulting price series, such as computing moving averages. | ||
|
||
The oracle solves these problems by maintaining a collection of [Solana accounts](account-structure.md) to represent the set of price feeds. | ||
Each feed has two accounts: a product account to store [metadata](product-metadata.md) and a price account. | ||
The price account stores a list of authorized data providers for this specific price feed, and allocates storage space for each data provider's price. | ||
The oracle program exposes an instruction called `upd_price` that enables an authorized data provider to update the price account with their current estimate of the price and confidence interval. | ||
Additionally, the first time that `upd_price` is called in a slot, it will [aggregate](price-aggregation.md) the individual data provider's prices into an aggregate price and confidence interval. | ||
Only the aggregate price and confidence are made available for use in downstream applications; the individual data providers prices are internal state of the oracle program. | ||
Finally, the oracle program computes an [exponentially-weighted moving average](ema-price-aggregation.md) of the oracle price. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the old section was a mix of how things currently work and stuff described in the whitepaper that doesn't exist. separate the two.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the whitepaper section right now is all copy-paste from the existing text. i'll circle back and update that text in a follow up pr