Skip to content

Commit ac2f3d1

Browse files
Add 'Why Update Prices' section to EVM Pull Integration guide (#908)
* Add callout explaining why price updates are needed in Pull integration - Added a warning callout before the 'Write Contract Code' section - Explains the pull-based oracle model concept - Highlights advantages: lower costs, lower latency, flexibility - Details the three steps required in Pull integration - Warns about StalePrice error when prices aren't updated Co-Authored-By: Nidhi Singh <[email protected]> * Fix formatting (prettier and trailing whitespace) Co-Authored-By: Nidhi Singh <[email protected]> * Move title inside callout per review feedback Co-Authored-By: Nidhi Singh <[email protected]> * Restructure to have section heading with Important note in callout Per feedback from @nidhi-singh02: - Added 'Why Update Prices' as a section heading - Moved explanatory content outside the callout - Kept only the Important note about StalePrice errors in the callout Co-Authored-By: Nidhi Singh <[email protected]> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Nidhi Singh <[email protected]>
1 parent 4cd2638 commit ac2f3d1

File tree

1 file changed

+23
-0
lines changed
  • pages/price-feeds/use-real-time-data/pull-integration

1 file changed

+23
-0
lines changed

pages/price-feeds/use-real-time-data/pull-integration/evm.mdx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,29 @@ Then add the following line to your `remappings.txt` file:
4646
@pythnetwork/pyth-sdk-solidity/=node_modules/@pythnetwork/pyth-sdk-solidity
4747
```
4848

49+
## Why Update Prices
50+
51+
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.
52+
53+
This design offers several advantages:
54+
55+
- **Lower costs**: You only pay for price updates when you need them
56+
- **Lower latency**: You can fetch the latest price update directly from Pyth's low-latency oracle network and submit it on-chain immediately
57+
- **Flexibility**: Different applications can update prices at different frequencies based on their needs
58+
59+
In the Pull integration pattern, your contract must:
60+
61+
1. Accept `priceUpdate` data from the caller (fetched from [Hermes](../../how-pyth-works/hermes))
62+
2. Call `updatePriceFeeds()` to submit this data on-chain before reading prices
63+
3. Pay a small fee for each update (calculated via `getUpdateFee()`)
64+
65+
<Callout type="warning" emoji="⚠️">
66+
**Important**: If you don't update the price or if the on-chain price becomes
67+
too stale, calls to `getPriceNoOlderThan()` will revert with a `StalePrice`
68+
error (0x19abf40e). See [how to fetch price
69+
updates](../../fetch-price-updates) for more details.
70+
</Callout>
71+
4972
## Write Contract Code
5073

5174
The code snippet below provides a general template for what your contract code should look like:

0 commit comments

Comments
 (0)