diff --git a/pages/price-feeds/_meta.json b/pages/price-feeds/_meta.json index 71e6bd4a..6d4ec639 100644 --- a/pages/price-feeds/_meta.json +++ b/pages/price-feeds/_meta.json @@ -60,5 +60,6 @@ }, "pull-updates": "What is a Pull Oracle?", + "why-update-prices": "Why Update Prices", "how-pyth-works": "How Pyth Works" } diff --git a/pages/price-feeds/use-real-time-data/pull-integration/evm.mdx b/pages/price-feeds/use-real-time-data/pull-integration/evm.mdx index f3278a72..dd88fe63 100644 --- a/pages/price-feeds/use-real-time-data/pull-integration/evm.mdx +++ b/pages/price-feeds/use-real-time-data/pull-integration/evm.mdx @@ -46,27 +46,13 @@ Then add the following line to your `remappings.txt` file: @pythnetwork/pyth-sdk-solidity/=node_modules/@pythnetwork/pyth-sdk-solidity ``` -## Why Update Prices - -Pyth uses a pull-based oracle model. Unlike traditional push oracles that automatically update prices on-chain at regular intervals, Pyth requires users to explicitly update the on-chain price before reading it. - -This design offers several advantages: - -- **Lower costs**: You only pay for price updates when you need them -- **Lower latency**: You can fetch the latest price update directly from Pyth's low-latency oracle network and submit it on-chain immediately -- **Flexibility**: Different applications can update prices at different frequencies based on their needs - -In the Pull integration pattern, your contract must: - -1. Accept `priceUpdate` data from the caller (fetched from [Hermes](../../how-pyth-works/hermes)) -2. Call `updatePriceFeeds()` to submit this data on-chain before reading prices -3. Pay a small fee for each update (calculated via `getUpdateFee()`) - - **Important**: If you don't update the price or if the on-chain price becomes - too stale, calls to `getPriceNoOlderThan()` will revert with a `StalePrice` - error (0x19abf40e). See [how to fetch price - updates](../../fetch-price-updates) for more details. + **Important**: Pyth uses a pull oracle model that requires users to update + prices on-chain before reading them. If you don't update the price or if the + on-chain price becomes too stale, calls to `getPriceNoOlderThan()` will revert + with a `StalePrice` error (0x19abf40e). Learn more about [why you need to + update prices](../../why-update-prices) and see [how to fetch price + updates](../../fetch-price-updates) for implementation details. ## Write Contract Code diff --git a/pages/price-feeds/why-update-prices.mdx b/pages/price-feeds/why-update-prices.mdx new file mode 100644 index 00000000..eb35e666 --- /dev/null +++ b/pages/price-feeds/why-update-prices.mdx @@ -0,0 +1,17 @@ +# Why Update Prices + +Pyth uses a pull oracle model. Unlike traditional push oracles that automatically update prices on-chain at regular intervals, Pyth requires users to explicitly update the on-chain price before reading it. + +This design offers several advantages: + +- **Lower costs**: You only pay for price updates when you need them +- **Lower latency**: You can fetch the latest price update directly from Pyth's low-latency oracle network and submit it on-chain immediately +- **Flexibility**: Different applications can update prices at different frequencies based on their needs + +In the pull integration pattern, your contract must: + +1. Accept `priceUpdate` data from the caller (fetched from [Hermes](./how-pyth-works/hermes)) +2. Call `updatePriceFeeds()` to submit this data on-chain before reading prices +3. Pay a small fee for each update (calculated via `getUpdateFee()`) + +If you don't update the price or if the on-chain price becomes too stale, calls to `getPriceNoOlderThan()` will revert with a `StalePrice` error. See [how to fetch price updates](./fetch-price-updates) for more details on obtaining price updates.