Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/developer-hub/content/docs/entropy/chainlist.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ Entropy callbacks the consumer as part of this transaction.

<InfoBox variant="info">
<div>
The fees for testnets kept deliberately low and different from the mainnet
fees.
The fees for testnets are kept deliberately low and different from the
mainnet fees.
</div>
</InfoBox>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ description: >-
Express Relay is currently deployed on the following SVM environments:
---

import CopyAddress from "../../../src/components/CopyAddress";

<Tabs items={['Production', 'Testing']}>
<Tab value="production">

Comment on lines 4 to 9
Copy link
Contributor

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 component CopyAddress to be defined: you likely forgot to import, pass, or provide it.

CopyAddress shouldn't be removed. Pls check

Expand Down
67 changes: 67 additions & 0 deletions apps/developer-hub/content/docs/openapi/(generated)/index.mdx
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}
/>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Price Feed Contract Addresses on Aptos

Pyth is currently deployed on Aptos Mainnet, Aptos Testnet, and Movement devnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Price Feed Contract Addresses on Fuel

Pyth is currently deployed on Fuel Mainnet and Fuel Testnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Price Feed Contract Addresses on Movement

Pyth is currently deployed on the following Movement networks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Program Addresses on Solana and other SVM chains

The Pyth Oracle consists of two different programs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Price Feed Contract Addresses on Starknet

Pyth is deployed on both Starknet Mainnet and Testnet.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ full: false
index: false
---

import CopyAddress from "../../../../src/components/CopyAddress";

# Price Feed Contract Addresses on TON

Pyth is currently deployed on TON Mainnet and TON Testnet.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"title": "Pyth Core",
"title": "Price Feeds",
"description": "Real-time data from financial institutions",
"icon": "ChartLine",
"pages": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ For a more in-depth explanation on the differences between push and pull oracles

## Comparing Push and Pull

![](./assets/Push-vs-Pull-Oracle.jpg)
{/* ![](./assets/Push-vs-Pull-Oracle.jpg) */}

Push and pull oracles differ on a number of important dimensions:

Expand Down
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.
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
---
24 changes: 24 additions & 0 deletions apps/developer-hub/content/docs/price-feeds/v2/index.mdx
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. |
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"]
}
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.
Loading
Loading