-
Notifications
You must be signed in to change notification settings - Fork 308
Chore(dev hub) pricefeed improvements #3052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
6fb17cd
chore(dev-hub) Move price feeds core to v1
aditya520 4a14b16
chore(dev-hub) Move source to lib
aditya520 24c3361
llm
aditya520 b30a082
chore(dev-hub)-llm-improvements
aditya520 7c4a795
chore(dev-hub) Open API support
aditya520 877bae8
chore(dev-hub) Move Pyth lazer pages
aditya520 6081d8e
chore(dev-hub) Typo fix
aditya520 26d08e7
fixes
alexcambose 38128e8
formatting
alexcambose 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
67 changes: 67 additions & 0 deletions
67
apps/developer-hub/content/docs/openapi/(generated)/index.mdx
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,67 @@ | ||
| --- | ||
| title: fortuna | ||
| full: true | ||
| _openapi: | ||
| toc: | ||
| - depth: 2 | ||
| title: Get the list of supported chain ids | ||
| url: "#get-the-list-of-supported-chain-ids" | ||
| - depth: 2 | ||
| title: Reveal the random value for a given sequence number and blockchain. | ||
| url: "#reveal-the-random-value-for-a-given-sequence-number-and-blockchain" | ||
| - depth: 2 | ||
| title: Returns the logs of all requests captured by the keeper. | ||
| url: "#returns-the-logs-of-all-requests-captured-by-the-keeper" | ||
| structuredData: | ||
| headings: | ||
| - content: Get the list of supported chain ids | ||
| id: get-the-list-of-supported-chain-ids | ||
| - content: Reveal the random value for a given sequence number and blockchain. | ||
| id: reveal-the-random-value-for-a-given-sequence-number-and-blockchain | ||
| - content: Returns the logs of all requests captured by the keeper. | ||
| id: returns-the-logs-of-all-requests-captured-by-the-keeper | ||
| contents: | ||
| - content: Get the list of supported chain ids | ||
| heading: get-the-list-of-supported-chain-ids | ||
| - content: >- | ||
| Reveal the random value for a given sequence number and blockchain. | ||
|
|
||
|
|
||
| Given a sequence number, retrieve the corresponding random value that | ||
| this provider has committed to. | ||
|
|
||
| This endpoint will not return the random value unless someone has | ||
| requested the sequence number on-chain. | ||
|
|
||
|
|
||
| Every blockchain supported by this service has a distinct sequence of | ||
| random numbers and chain_id. | ||
|
|
||
| Callers must pass the appropriate chain_id to ensure they fetch the | ||
| correct random number. | ||
| heading: reveal-the-random-value-for-a-given-sequence-number-and-blockchain | ||
| - content: >- | ||
| Returns the logs of all requests captured by the keeper. | ||
|
|
||
|
|
||
| This endpoint allows you to filter the logs by a specific network ID, | ||
| a query string (which can be a transaction hash, sender address, or | ||
| sequence number), and a time range. | ||
|
|
||
| This is useful for debugging and monitoring the requests made to the | ||
| Entropy contracts on various chains. | ||
| heading: returns-the-logs-of-all-requests-captured-by-the-keeper | ||
| --- | ||
|
|
||
| {/* This file was generated by Fumadocs. Do not edit this file directly. Any changes should be made by running the generation command again. */} | ||
|
|
||
| <APIPage | ||
| document={"https://fortuna.dourolabs.app/docs/openapi.json"} | ||
| operations={[ | ||
| { path: "/v1/chains", method: "get" }, | ||
| { path: "/v1/chains/{chain_id}/revelations/{sequence}", method: "get" }, | ||
| { path: "/v1/logs", method: "get" }, | ||
| ]} | ||
| webhooks={[]} | ||
| hasHead={true} | ||
| /> |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...oper-hub/content/docs/pyth-core/meta.json → ...hub/content/docs/price-feeds/v1/meta.json
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
apps/developer-hub/content/docs/price-feeds/v2/acquire-an-access-token.mdx
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,36 @@ | ||
| --- | ||
| title: "Acquire an Access Token" | ||
| description: "This guide explains how to acquire an access token for Pyth Lazer, which is required to authenticate websocket connections and subscribe to price updates." | ||
| full: false | ||
| index: false | ||
| --- | ||
|
|
||
| This guide explains how to acquire an access token for Pyth Lazer, which is required to authenticate websocket connections and subscribe to price updates. | ||
|
|
||
| ## Request Access Token | ||
|
|
||
| Please fill out [this form](https://tally.so/r/nP2lG5) to contact the Pyth team and get the access token. | ||
|
|
||
| <InfoBox variant="info"> | ||
| Access tokens are required for all Pyth Lazer websocket connections. Make sure | ||
| to keep your token secure and do not share it publicly. | ||
| </InfoBox> | ||
|
|
||
| ## Using the Access Token | ||
|
|
||
| Once you receive your access token, use it to authenticate the websocket connection by passing it as an `Authorization` header with the value `Bearer {token}`. | ||
|
|
||
| ### Example Usage | ||
|
|
||
| ```js copy | ||
| import { PythLazerClient } from "@pythnetwork/pyth-lazer-sdk"; | ||
|
|
||
| const client = await PythLazerClient.create( | ||
| ["wss://pyth-lazer.dourolabs.app/v1/stream"], | ||
| "YOUR_ACCESS_TOKEN", | ||
| ); | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
|
|
||
| After acquiring your access token, you can proceed to [subscribe to price updates](./subscribe-price-updates.mdx) using the Pyth Lazer websocket API. |
6 changes: 6 additions & 0 deletions
6
apps/developer-hub/content/docs/price-feeds/v2/getting-started.mdx
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,6 @@ | ||
| --- | ||
| title: "Getting Started with Pyth Lazer" | ||
| description: "Please refer to the how-to guides to get started." | ||
| full: false | ||
| index: false | ||
| --- |
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,24 @@ | ||
| --- | ||
| title: "Pyth Lazer" | ||
| description: >- | ||
| Pyth Lazer is a low latency, highly customizable price oracle. | ||
| full: false | ||
| index: true | ||
| --- | ||
|
|
||
| Pyth Lazer is a low latency, highly customizable price oracle. | ||
| It offers a customizable set of price feeds, target chains (EVM or Solana) and channels (real time or fixed rate): | ||
|
|
||
| - Real time channels send updates as frequently as they become available; | ||
| - Fixed rate channels send updates at fixed time intervals (you can choose between 50 ms or 200 ms). | ||
|
|
||
| The table below shows the difference between Pyth Core and Pyth Lazer: | ||
|
|
||
| | | **Pyth Core** | **Pyth Lazer** | | ||
| | ----------------------- | -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | | ||
| | **Solution Type** | Stable, secure, and decentralized price data source for a broad spectrum of DeFi or TradFi applications. | **Permissioned** service focused on **ultra-low-latency** price and market data for highly latency-sensitive users. | | ||
| | **Frequency** | 400ms on Pythnet appchain with support for risk mitigation via Benchmarks and confidence intervals. | **1ms** (**real-time**), 50ms, and 200ms channels, **customizable** frequencies, and throttling support to address different needs. | | ||
| | **Data Types** | Aggregate price and confidence intervals. | Aggregate price, bid/ask price, and **customizable** market data (market depth and more). | | ||
| | **Fees** | On-chain fee per signed cross-chain price update. | On-chain fee per signed cross-chain price update. | | ||
| | **Update Costs** | >1,000-byte proofs and complex signature verification. | **100-byte proofs** and simple signature verification. | | ||
| | **Integration Process** | Open and permissionless integration for any Web3 or Web2 protocol. | **Specialized** and **permissioned** solution for protocols prioritizing performance over some elements of decentralization. | |
6 changes: 6 additions & 0 deletions
6
apps/developer-hub/content/docs/price-feeds/v2/integrate-as-a-consumer/meta.json
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,6 @@ | ||
| { | ||
| "title": "Integrate as a Consumer", | ||
| "description": "Real-time data from financial institutions", | ||
| "icon": "ChartLine", | ||
| "pages": ["on-solana-and-fogo", "on-evm-chains"] | ||
| } |
155 changes: 155 additions & 0 deletions
155
...loper-hub/content/docs/price-feeds/v2/integrate-as-a-consumer/on-evm-chains.mdx
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,155 @@ | ||
| --- | ||
| title: "On EVM chains" | ||
| description: "This guide explains how to integrate Pyth Lazer into your EVM smart contracts." | ||
| full: false | ||
| index: false | ||
| --- | ||
|
|
||
| This guide is intended to serve users who wants to consume prices from the Pyth Lazer on **EVM chains**. | ||
|
|
||
| Integrating with Pyth Lazer in smart contracts as a consumer is a three-step process: | ||
|
|
||
| 1. **Use** Pyth Lazer SDK in EVM smart contracts to parse the price updates. | ||
| 2. **Subscribe** to Pyth Lazer websocket to receive price updates on backend or frontend. | ||
| 3. **Include** the price updates into the smart contract transactions. | ||
|
|
||
| <Steps> | ||
|
|
||
| ### Use Pyth Lazer SDK in smart contracts | ||
|
|
||
| Pyth Lazer provides a [Solidity SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/contracts/evm), which allows consumers to parse the price updates. | ||
|
|
||
| ```bash copy | ||
| forge install pyth-network/pyth-crosschain | ||
| ``` | ||
|
|
||
| Add the following to `requirements.txt{:js}` file: | ||
|
|
||
| ```bash copy | ||
| pyth-lazer-sdk/=lib/pyth-network/pyth-crosschain/lazer/contracts/evm | ||
| ``` | ||
|
|
||
| Once the SDK is installed, one can import the sdk into smart contracts: | ||
|
|
||
| ```solidity copy | ||
| import { PythLazer } from "pyth-lazer-sdk/PythLazer.sol"; | ||
| import { PythLazerLib } from "pyth-lazer-sdk/PythLazerLib.sol"; | ||
|
|
||
| ``` | ||
|
|
||
| After importing the SDK, initialize the [`PythLazer`](https://github.com/pyth-network/pyth-crosschain/blob/main/lazer/contracts/evm/src/PythLazer.sol#L7) contract and set up state varables to store prices and timestamps: | ||
|
|
||
| ```solidity copy | ||
| contract ExampleConsumer { | ||
| // Example state. | ||
| PythLazer pythLazer; | ||
| uint64 public price; | ||
| uint64 public timestamp; | ||
|
|
||
| //... | ||
|
|
||
| constructor(address pythLazerAddress) { | ||
| pythLazer = PythLazer(pythLazerAddress); | ||
| } | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| Add an argument of type `bytes calldata{:solidity}` to the method which will receive the Pyth Lazer price udpate: | ||
|
|
||
| ```solidity copy | ||
| function updatePrice(bytes calldata priceUpdate) public payable { | ||
| uint256 verification_fee = pythLazer.verification_fee(); | ||
| (bytes calldata payload, ) = verifyUpdate{ value: verification_fee }(update); | ||
| //... | ||
| } | ||
|
|
||
| ``` | ||
|
|
||
| The `verifyUpdate` function will verify the price update and return the payload and the verification fee. This call takes a fee which can be queried from [`verification_fee(){:solidity}`](https://github.com/pyth-network/pyth-crosschain/blob/main/lazer/contracts/evm/src/PythLazer.sol#L9) function and passed to the `verifyUpdate` call. This fee is used to cover the cost of verifying the price update. | ||
|
|
||
| This SDK provides [`parsePayloadHeader`](https://github.com/pyth-network/pyth-crosschain/blob/main/lazer/contracts/evm/src/PythLazerLib.sol#L21) method to retrieve the values from the payload header. | ||
|
|
||
| ```solidity copy | ||
| (uint64 _timestamp, Channel channel, uint8 feedsLen, uint16 pos) = parsePayloadHeader(payload); | ||
| ``` | ||
|
|
||
| This method returns: | ||
|
|
||
| - `_timestamp`: The timestamp of the price update. | ||
| - `channel`: The channel of the price update. | ||
| - `feedsLen`: The number of feeds in the price update. | ||
| - `pos`: The cursor position of the payload. | ||
|
|
||
| One can iterate over all the feeds and properties present within the price update, modifying the state variables as necessary. | ||
|
|
||
| Here is an example of how to iterate over the feeds and properties: | ||
|
|
||
| ```solidity copy | ||
| for (uint8 i = 0; i < feedsLen; i++) { | ||
| uint32 feedId; | ||
| uint8 num_properties; | ||
| (feedId, num_properties, pos) = parseFeedHeader(payload, pos); | ||
| for (uint8 j = 0; j < num_properties; j++) { | ||
| PriceFeedProperty property; | ||
| (property, pos) = parseFeedProperty(payload, pos); | ||
| if (property == PriceFeedProperty.Price) { | ||
| uint64 _price; | ||
| (_price, pos) = parseFeedValueUint64(payload, pos); | ||
| if (feedId == 2 && _timestamp > timestamp) { | ||
| price = _price; | ||
| timestamp = _timestamp; | ||
| } | ||
| } else if (property == PriceFeedProperty.BestBidPrice) { | ||
| uint64 _price; | ||
| (_price, pos) = parseFeedValueUint64(payload, pos); | ||
| } else if (property == PriceFeedProperty.BestAskPrice) { | ||
| uint64 _price; | ||
| (_price, pos) = parseFeedValueUint64(payload, pos); | ||
| } else { | ||
| revert("unknown property"); | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| <Callout type="warning" emoji="⚠️"> | ||
| Make sure to pass the `pos` variable to every parsing call and assign the | ||
| returned `pos` value to the same variable. Failure to do so will cause | ||
| incorrect parsing results. | ||
| </Callout> | ||
|
|
||
| <Callout type="warning" emoji="⚠️"> | ||
| When calling these parse functions, you must not skip price feeds or | ||
| properties. Every parsing function will modify your `pos` variable, so | ||
| skipping a call of `parseFeedHeader`, `parseFeedProperty`, or | ||
| `parseFeedValueUint64` will lead to incorrect parsing results. Keep in mind | ||
| that you can customize the set of price feeds and properties when requesting | ||
| price updates via WebSocket. This will be explained in the next step. | ||
| </Callout> | ||
|
|
||
| ### Subscribe to Pyth Lazer to receive Price Updates | ||
|
|
||
| Pyth Lazer provides a websocket endpoint to receive price updates. Moreover, Pyth Lazer also provides a [Typescript SDK](https://github.com/pyth-network/pyth-crosschain/tree/main/lazer/sdk/js) to subscribe to the websocket endpoint. | ||
|
|
||
| Consult [How to subscribe to price updates from Pyth Lazer](../subscribe-price-updates.mdx) for a complete step-by-step guide. | ||
|
|
||
| ### Include the price updates into smart contract transactions | ||
|
|
||
| Now that you have the price updates, and your smart contract is able to parse the price updates, you can include the price updates into the smart contract transactions by passing the price updates received from the previous step as an argument to the `updatePrice` method of your smart contract. | ||
|
|
||
| </Steps> | ||
|
|
||
| ## Additional Resources | ||
|
|
||
| You may find these additional resources helpful for integrating Pyth Lazer into your EVM smart contracts. | ||
|
|
||
| ### Price Feed IDs | ||
|
|
||
| Pyth Lazer supports a wide range of price feeds. Consult the [Price Feed IDs](../price-feed-ids.mdx) page for a complete list of supported price feeds. | ||
|
|
||
| ### Examples | ||
|
|
||
| [Pyth-lazer-example-evm](https://github.com/pyth-network/pyth-examples/tree/main/lazer/evm) is a simple example contract that parses and consumes price updates from Pyth Lazer. | ||
|
|
||
| [pyth-lazer-example-js](https://github.com/pyth-network/pyth-examples/tree/main/lazer/js) is a simple example for subscribing to the Pyth Lazer websocket. |
Oops, something went wrong.
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.
this page is giving 500 https://developer-loc72zn3h-pyth-network.vercel.app/express-relay/contract-addresses with error
Error: Expected componentCopyAddressto be defined: you likely forgot to import, pass, or provide it.CopyAddress shouldn't be removed. Pls check