@pythnetwork/pyth-solana-receiver 0.2.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,114 +1,192 @@
1
1
  # Pyth Solana Receiver JS SDK
2
2
 
3
- This is a Javascript SDK to interact with the Pyth Solana Receiver contract whose code lives [here](/target_chains/solana).
3
+ [@pythnetwork/pyth-solana-receiver](https://www.npmjs.com/package/@pythnetwork/pyth-solana-receiver) is a Typescript SDK for interacting with the Pyth Solana Receiver contract.
4
+ The SDK enables users to construct transactions that post Pyth price updates to the Solana blockchain and use them in downstream applications.
4
5
 
5
- ## Pull model
6
+ The code for the underlying Pyth Solana Receiver program lives [here](/target_chains/solana).
6
7
 
7
- The Pyth Solana Receiver allows users to consume Pyth price updates on a pull basis. This means that the user is responsible for submitting the price data on-chain whenever they want to interact with an app that requires a price update.
8
+ ## Installation
8
9
 
9
- Price updates get posted into price update accounts, owned by the Receiver contract. Once an update has been posted to a price update account, it can be used by anyone by simply passing the price update account as one of the accounts in a Solana instruction.
10
- Price update accounts can be closed by whoever wrote them to recover the rent.
10
+ You can install the package using your favorite typescript version manager
11
11
 
12
- ## Example use
12
+ **NPM:** `npm install @pythnetwork/pyth-solana-receiver`
13
13
 
14
- ```ts
15
- import { Connection, PublicKey } from "@solana/web3.js";
16
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
14
+ **Yarn:** `yarn add @pythnetwork/pyth-solana-receiver`
15
+
16
+ ## Preliminaries
17
+
18
+ ### Accessing Pyth Prices
19
+
20
+ This SDK is designed to be used in combination with a source of Pyth pricing data.
21
+ There are two different sources of pricing data that users can choose from.
22
+
23
+ - [Hermes](https://docs.pyth.network/price-feeds/pythnet-price-feeds/hermes) is a webservice that provides HTTP and websocket endpoints for retrieving real-time Pyth prices.
24
+ The example code below uses the public Hermes instance hosted by the Pyth Data Association at `https://hermes.pyth.network/`.
25
+ Hermes is also available from several infrastructure providers [listed here](https://docs.pyth.network/price-feeds/api-instances-and-providers/hermes).
26
+ The [Price Service Client](https://github.com/pyth-network/pyth-crosschain/tree/main/price_service/client/js) can be used to access Hermes prices in a convenient way.
27
+ - [Benchmarks](https://docs.pyth.network/benchmarks) is a webservice that provides HTTP endpoints for accessing historical Pyth prices.
28
+ This service can be used for applications that require prices from specific times in the past.
29
+
30
+ Both of these services return Pyth price updates, which are binary blobs of signed and timestamped prices.
31
+ This SDK enables users to post price updates to the Solana blockchain, verify their validity, and consume them in downstream Solana applications.
32
+
33
+ ### Price Feed IDs
34
+
35
+ Pyth identifies each pair of assets (e.g., BTC/USD) with a unique price feed id.
36
+ The price feed id is a UUID written as a hexadecimal string.
37
+ In order to get the price for a specific pair of assets, you will need its corresponding price feed id.
38
+ You can look up all available price feed ids [here](https://pyth.network/developers/price-feed-ids).
39
+
40
+ ### Pyth Solana Receiver
41
+
42
+ The Pyth Solana Receiver provides two different methods for posting and using price updates.
43
+
44
+ First, a price update can be written to a **_price update account_**.
45
+ Once the account has been written, other programs can read the Pyth price from the account by simply including it in their instruction.
46
+ Price update accounts are ephemeral: they have an owner who can overwrite their contents or close the account.
47
+ This method for using Pyth prices is a good fit for applications that need to use prices at specific timestamps (e.g., to settle a trade at a time).
48
+
49
+ Second, a price update can be written to a **_price feed account_**.
50
+ A price feed account is designed to work similarly to a Pyth price feed -- it holds a sequence of price updates that move forward in time.
51
+ Applications can therefore store the address of a price feed account and read its contents whenever they need a recent price for the feed.
52
+ Price feed accounts have a fixed address derived from the feed id and a shard id.
53
+ The shard id allows different applications to use different accounts for the same feed, thereby reducing the impact of solana congestion.
54
+ This method of using Pyth prices is a good fit for applications that always want to use the most recent price.
55
+ Additionally, the [Price Scheduler](../../../../../../../price_pusher/) can be used to continuously write fresh updates to a price feed account, freeing applications from worrying about writing their own updates.
56
+
57
+ This SDK provides methods for working with both types of accounts.
58
+
59
+ ## Usage
60
+
61
+ The `PythSolanaReceiver` class is the main entrypoint for the SDK.
62
+ Instantiate it with a Solana web3 `Connection` and anchor `Wallet`:
63
+
64
+ ```typescript
17
65
  import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
18
- import { MyFirstPythApp, IDL } from "./idl/my_first_pyth_app";
66
+ import { Connection, Keypair, PublicKey } from "@solana/web3.js";
67
+ import { Wallet } from "@coral-xyz/anchor";
68
+
69
+ const connection = new Connection("https://api.mainnet-beta.solana.com");
70
+ const wallet = new Wallet(
71
+ Keypair.fromSecretKey(/* <insert private key here> */)
72
+ );
73
+ const pythSolanaReceiver = new PythSolanaReceiver({ connection, wallet });
74
+ ```
75
+
76
+ ### Post a price update
19
77
 
20
- const SOL_PRICE_FEED_ID =
21
- "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";
22
- const ETH_PRICE_FEED_ID =
23
- "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace";
78
+ Post an update to an ephemeral price update account:
24
79
 
25
- const priceServiceConnection = new PriceServiceConnection(
26
- "https://hermes.pyth.network/",
27
- { priceFeedRequestConfig: { binary: true } }
80
+ ```ts
81
+ // Fetch this from hermes or benchmarks. See Preliminaries section above for more info.
82
+ const priceUpdateData =
83
+ "UE5BVQEAAAADuAEAAAADDQExWGp7w3s3zDxhkNYnzcK2WalKT3uSQqUwetvCf4PgbFzjCdiowrp8Bq8HO+Q+7MHSuQ0BKS3r6attJvmkVbgFAQJlCXsGZdtF88zjeB6sUBcmpuu/J6Ci7tgHiM6hy81rBD5AcU2AQUnYaHvwkzhQsrme4S3SI/F9fZrjMGrPn2jlAQMWvFXRTa/Ga3Kdur06PgxRk2NiIb/RJ+iwXOb1OBljXCqWdew8BTbtVtJSPxb390O/HVzp1L4m3Lw/645pyattAAaKagQCRrWUZvqDhgRGLRqo0o3AWQJ46JD6AdgG/blL115vvembP/F7AjOuMLrjAWS1SgzJMYd9UbblxWkovS2EAQcx9kqzys5E5cRGXjYxD8WRyTb6G7e6g5eGKIX8cT4UHS72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T21ofP2RlJSREqlL/DcmSOJhH9QTVh9wa8YYqSg1+iE+ikKXnzKSgrDke2U1vl9i2AyrXFMrad6iAlAqIDsqW+qZPX5APSvsdas5AE6KoqhrJxgHXY4GtQZxKKvEQs5EPj/wefL0vgTndN6qkAZ9KPuLVL8TCEfZgKdCNOBGqCer8AFUA/2FJGpMREt3xvYFHzRtkE3X3n1glEm1mVICHRjT9Cs4AAABMntCNVwAAAAANC1wx////+AAAAABmEAuNAAAAAGYQC4wAAABMRtENIAAAAAARjpacCqW6MiwuuCTN37nDR9bes6eLYG8IG4MPoSLbarS61bbZ0MR2iLFPUOIDhdYM4b4LG0+l/tt8LJaCtmi5TrICKPfoRdBRgMbQTR1Xkn+oJEQqXe3kH/IIJ6Yl+seCumnf9Wtw85dJ2m3aGx4zXn12Pwz95hE9nyEnmCrXFMrad6iAlAqIDsqW+qZPX5APSvsdas5AE6KoqhrJxgHXY4GtQZxKKvEQs5EPj/wefL0vgTndN6qkAZ9KPuLVL8TCEfZgKdCNOBGqCer8";
84
+
85
+ // Pass `closeUpdateAccounts: true` to the transaction builder constructor to automatically close the
86
+ // price update accounts at the end of the sequence of transactions.
87
+ const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({
88
+ closeUpdateAccounts: false,
89
+ });
90
+ await transactionBuilder.addPostPriceUpdates(priceUpdateData);
91
+
92
+ await transactionBuilder.addPriceConsumerInstructions(
93
+ async (
94
+ getPriceUpdateAccount: (priceFeedId: string) => PublicKey
95
+ ): Promise<InstructionWithEphemeralSigners[]> => {
96
+ // Generate instructions here that use the price updates posted above.
97
+ // getPriceUpdateAccount(<price feed id>) will give you the account for each price update.
98
+ return [];
99
+ }
28
100
  );
29
- const priceUpdateData = await priceServiceConnection.getLatestVaas([
30
- SOL_PRICE_FEED_ID,
31
- ETH_PRICE_FEED_ID,
32
- ]); // Fetch off-chain price update data
33
-
34
- const myFirstPythApp = new Program<MyFirstPythApp>(
35
- IDL as MyFirstPythApp,
36
- MY_FIRST_PYTH_APP_PROGRAM_ID,
37
- {}
101
+
102
+ // Send the instructions in the builder in 1 or more transactions.
103
+ // The builder will pack the instructions into transactions automatically.
104
+ await pythSolanaReceiver.provider.sendAll(
105
+ await transactionBuilder.buildVersionedTransactions({
106
+ computeUnitPriceMicroLamports: 100000,
107
+ })
38
108
  );
109
+ ```
110
+
111
+ The code snippet above will post every price update in `priceUpdateData` to a new ephemeral account.
112
+
113
+ See `examples/post_price_update.ts` for a runnable example of posting a price update.
114
+
115
+ ### Update a price feed account
116
+
117
+ Update the price feed account for shard id 1:
118
+
119
+ ```typescript
120
+ // Fetch this from hermes or benchmarks. See Preliminaries section above for more info.
121
+ const priceUpdateData =
122
+ "UE5BVQEAAAADuAEAAAADDQExWGp7w3s3zDxhkNYnzcK2WalKT3uSQqUwetvCf4PgbFzjCdiowrp8Bq8HO+Q+7MHSuQ0BKS3r6attJvmkVbgFAQJlCXsGZdtF88zjeB6sUBcmpuu/J6Ci7tgHiM6hy81rBD5AcU2AQUnYaHvwkzhQsrme4S3SI/F9fZrjMGrPn2jlAQMWvFXRTa/Ga3Kdur06PgxRk2NiIb/RJ+iwXOb1OBljXCqWdew8BTbtVtJSPxb390O/HVzp1L4m3Lw/645pyattAAaKagQCRrWUZvqDhgRGLRqo0o3AWQJ46JD6AdgG/blL115vvembP/F7AjOuMLrjAWS1SgzJMYd9UbblxWkovS2EAQcx9kqzys5E5cRGXjYxD8WRyTb6G7e6g5eGKIX8cT4UHS72fqrawE+gmn0BWQciThOnSEaP8C/4JWB4qBqZPxMMAQid0Yd8BQNsOvdNNqtE7ETYzqnDKFIN8OHxks6ej2cqXUs605TB+AOZiBtogillICrXBo4PyQuRCacsTjan/NhCAQqdmFKys/qTKCujOWfRfvHSfPNHh2cqDCd8TetgZhj2qXP5Bzah3yoL8mHc1gM62FyRgGPgbjlrsL3f2WPn8W9FAAu0G27GuaEhu6WMqj2LC1M/K6JPENtxLoB+tB9Vhpz6ygAp/Um3W2O6ajKl2H3eXpBNW0VWC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MiwuuCTN37nDR9bes6eLYG8IG4MPoSLbarS61bbZ0MR2iLFPUOIDhdYM4b4LG0+l/tt8LJaCtmi5TrICKPfoRdBRgMbQTR1Xkn+oJEQqXe3kH/IIJ6Yl+seCumnf9Wtw85dJ2m3aGx4zXn12Pwz95hE9nyEnmCrXFMrad6iAlAqIDsqW+qZPX5APSvsdas5AE6KoqhrJxgHXY4GtQZxKKvEQs5EPj/wefL0vgTndN6qkAZ9KPuLVL8TCEfZgKdCNOBGqCer8";
39
123
 
40
124
  const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
41
- await transactionBuilder.addPostPriceUpdates(priceUpdateData);
125
+ // Update the price feed accounts for the feed ids in priceUpdateData and shard id 1
126
+ await transactionBuilder.addUpdatePriceFeed(priceUpdateData, 1);
127
+
42
128
  await transactionBuilder.addPriceConsumerInstructions(
43
129
  async (
44
130
  getPriceUpdateAccount: (priceFeedId: string) => PublicKey
45
131
  ): Promise<InstructionWithEphemeralSigners[]> => {
46
- return [
47
- {
48
- instruction: await myFirstPythApp.methods
49
- .consume()
50
- .accounts({
51
- solPriceUpdate: getPriceUpdateAccount(SOL_PRICE_FEED_ID),
52
- ethPriceUpdate: getPriceUpdateAccount(ETH_PRICE_FEED_ID),
53
- })
54
- .instruction(),
55
- signers: [],
56
- },
57
- ];
132
+ // Generate instructions here that use the price updates posted above.
133
+ // getPriceUpdateAccount(<price feed id>) will give you the account for each price update.
134
+ return [];
58
135
  }
59
136
  );
137
+
138
+ // Send the instructions in the builder in 1 or more transactions.
139
+ // The builder will pack the instructions into transactions automatically.
60
140
  await pythSolanaReceiver.provider.sendAll(
61
141
  await transactionBuilder.buildVersionedTransactions({
62
- computeUnitPriceMicroLamports: 1000000,
142
+ computeUnitPriceMicroLamports: 100000,
63
143
  })
64
144
  );
65
145
  ```
66
146
 
67
- Alternatively you can use the instruction builder methods from `PythSolanaReceiver` :
147
+ The code above will update the price feed accounts for the feeds in `priceUpdateData` (in this example, SOL/USD and ETH/USD).
148
+ The address of the price feed accounts can be derived automatically from the feed id and the shard id:
68
149
 
69
- ```ts
70
- import { PublicKey } from "@solana/web3.js";
71
- import { PriceServiceConnection } from "@pythnetwork/price-service-client";
72
- import { PythSolanaReceiver } from "@pythnetwork/pyth-solana-receiver";
73
- import { MyFirstPythApp, IDL } from "./idl/my_first_pyth_app";
150
+ ```typescript
151
+ const solUsdPriceFeedAccount = pythSolanaReceiver
152
+ .getPriceFeedAccountAddress(1, SOL_PRICE_FEED_ID)
153
+ .toBase58();
154
+ ```
74
155
 
75
- const SOL_PRICE_FEED_ID =
76
- "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d";
77
- const ETH_PRICE_FEED_ID =
78
- "0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace";
156
+ Note that the example above uses a shard id of 1.
157
+ Changing the shard id to a different value will give you a different account address.
79
158
 
80
- const priceServiceConnection = new PriceServiceConnection(
81
- "https://hermes.pyth.network/",
82
- { priceFeedRequestConfig: { binary: true } }
83
- );
84
- const priceUpdateData = await priceServiceConnection.getLatestVaas([
85
- SOL_PRICE_FEED_ID,
86
- ETH_PRICE_FEED_ID,
87
- ]); // Fetch off-chain price update data
159
+ See `examples/update_price_feed.ts` for a runnable example of updating a price feed.
88
160
 
89
- const pythSolanaReceiver = new PythSolanaReceiver({ connection, wallet });
90
- const { postInstructions, closeInstructions, priceFeedIdToPriceUpdateAccount } =
91
- await pythSolanaReceiver.buildPostPriceUpdateInstructions(priceUpdateData); // Get instructions to post the price update data and to close the accounts later
161
+ ### Partially verified price updates
92
162
 
93
- const myFirstPythApp = new Program<MyFirstPythApp>(
94
- IDL as MyFirstPythApp,
95
- MY_FIRST_PYTH_APP_PROGRAM_ID,
96
- {}
97
- );
98
- const consumerInstruction: InstructionWithEphemeralSigners = {
99
- instruction: await myFirstPythApp.methods
100
- .consume()
101
- .accounts({
102
- solPriceUpdate: priceFeedIdToPriceUpdateAccount[SOL_PRICE_FEED_ID],
103
- ethPriceUpdate: priceFeedIdToPriceUpdateAccount[ETH_PRICE_FEED_ID],
104
- })
105
- .instruction(),
106
- signers: [],
107
- };
108
-
109
- const transactions = pythSolanaReceiver.batchIntoVersionedTransactions(
110
- [...postInstructions, consumerInstruction, ...closeInstructions],
111
- { computeUnitPriceMicroLamports: 1000000 }
112
- ); // Put all the instructions together
113
- await pythSolanaReceiver.provider.sendAll(transactions);
163
+ Price updates are relatively large and can take multiple transactions to post on the blockchain.
164
+ You can reduce the size of the transaction payload by using `addPostPartiallyVerifiedPriceUpdates` instead of `addPostPriceUpdates`.
165
+ This method does sacrifice some security however -- please see the method documentation for more details.
166
+
167
+ ### Get Instructions
168
+
169
+ The `PythTransactionBuilder` class used in the examples above helps craft transactions that update prices and then use them in successive instructions.
170
+ However, if you would like to craft your own transactions, `PythSolanaReceiver` exposes several methods for constructing the instructions for working with both price update accounts and price feed accounts.
171
+ See `examples/post_price_update_instructions.ts` for an example of how to work with instructions.
172
+
173
+ ## Examples
174
+
175
+ This SDK includes several runnable examples in the `examples/` directory.
176
+ You can run these examples by performing the following steps.
177
+ First, install and build any necessary typescript dependencies:
178
+
179
+ 1. Clone the `pyth-crosschain` git repo
180
+ 2. Run `npm install` in the root of the repo
181
+ 3. Run `npx lerna run build` anywhere in the repo
182
+ 4. From the `pyth_solana_receiver` directory, run `npx ts-node examples/<example filename>.ts`
183
+
184
+ The examples require a Solana keypair with SOL to send Solana transactions.
185
+ By default, the examples will use the same Solana keypair used by the Solana CLI (at `~/.config/solana/id.json`).
186
+ You can override this default by setting the `SOLANA_KEYPAIR` environment variable:
187
+
188
+ ```bash
189
+ export SOLANA_KEYPAIR=/path/to/keypair/id.json
114
190
  ```
191
+
192
+ If you do not have a Solana keypair, you can generate one by downloading and installing the [Solana CLI](https://docs.solanalabs.com/cli/install), the running `solana-keygen new`.
@@ -1,11 +1,13 @@
1
1
  /// <reference types="node" />
2
- import { AnchorProvider, Program } from "@coral-xyz/anchor";
2
+ import { AnchorProvider, IdlAccounts, Program } from "@coral-xyz/anchor";
3
3
  import { Connection, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
4
4
  import { PythSolanaReceiver as PythSolanaReceiverProgram } from "./idl/pyth_solana_receiver";
5
5
  import { WormholeCoreBridgeSolana } from "./idl/wormhole_core_bridge_solana";
6
6
  import { PublicKey } from "@solana/web3.js";
7
7
  import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
8
8
  import { TransactionBuilder, InstructionWithEphemeralSigners, PriorityFeeConfig } from "@pythnetwork/solana-utils";
9
+ import { PythPushOracle } from "./idl/pyth_push_oracle";
10
+ export type PriceUpdateAccount = IdlAccounts<PythSolanaReceiverProgram>["priceUpdateV2"];
9
11
  /**
10
12
  * Configuration for the PythTransactionBuilder
11
13
  * @property closeUpdateAccounts (default: true) if true, the builder will add instructions to close the price update accounts and the encoded vaa accounts to recover the rent
@@ -15,12 +17,21 @@ export type PythTransactionBuilderConfig = {
15
17
  };
16
18
  /**
17
19
  * A builder class to build transactions that:
18
- * - Post price updates (fully or partially verified)
20
+ * - Post price updates (fully or partially verified) or update price feed accounts
19
21
  * - Consume price updates in a consumer program
20
22
  * - (Optionally) Close price update and encoded vaa accounts to recover the rent (`closeUpdateAccounts` in `PythTransactionBuilderConfig`)
21
23
  *
24
+ * This class provides methods for working with both price update accounts and price feed accounts.
25
+ * Price update accounts are ephemeral accounts containing a single price update, whereas price feed accounts are long-lived
26
+ * accounts that always hold price data for a specific feed id. Price feed accounts can be updated to advance the current price.
27
+ * Applications should choose which type of account to work with based on their needs. In general, applications that
28
+ * want the price at a specific time (e.g., to settle a trade) should use price update accounts, while applications that want
29
+ * any recent price should use price feed accounts.
30
+ *
22
31
  * @example
23
32
  * ```typescript
33
+ *
34
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
24
35
  * const priceUpdateData = await priceServiceConnection.getLatestVaas([
25
36
  * SOL_PRICE_FEED_ID,
26
37
  * ETH_PRICE_FEED_ID,
@@ -28,9 +39,10 @@ export type PythTransactionBuilderConfig = {
28
39
  *
29
40
  * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
30
41
  * await transactionBuilder.addPostPriceUpdates(priceUpdateData);
42
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
31
43
  * await transactionBuilder.addPriceConsumerInstructions(...)
32
44
  *
33
- * await pythSolanaReceiver.provider.sendAll(await transactionBuilder.buildVersionedTransactions({computeUnitPriceMicroLamports:1000000}))
45
+ * await pythSolanaReceiver.provider.sendAll(await transactionBuilder.buildVersionedTransactions({computeUnitPriceMicroLamports:100000}))
34
46
  * ```
35
47
  */
36
48
  export declare class PythTransactionBuilder extends TransactionBuilder {
@@ -41,12 +53,28 @@ export declare class PythTransactionBuilder extends TransactionBuilder {
41
53
  constructor(pythSolanaReceiver: PythSolanaReceiver, config: PythTransactionBuilderConfig);
42
54
  /**
43
55
  * Add instructions to post price updates to the builder.
56
+ * Use this function to post fully verified price updates from the present or from the past for your program to consume.
44
57
  *
45
58
  * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
63
+ * const priceUpdateData = await priceServiceConnection.getLatestVaas([
64
+ * SOL_PRICE_FEED_ID,
65
+ * ETH_PRICE_FEED_ID,
66
+ * ]);
67
+ *
68
+ * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
69
+ * await transactionBuilder.addPostPriceUpdates(priceUpdateData);
70
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
71
+ * await transactionBuilder.addPriceConsumerInstructions(...)
72
+ * ```
46
73
  */
47
74
  addPostPriceUpdates(priceUpdateDataArray: string[]): Promise<void>;
48
75
  /**
49
76
  * Add instructions to post partially verified price updates to the builder.
77
+ * Use this function to post partially verified price updates from the present or from the past for your program to consume.
50
78
  *
51
79
  * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
52
80
  *
@@ -55,6 +83,7 @@ export declare class PythTransactionBuilder extends TransactionBuilder {
55
83
  *
56
84
  * @example
57
85
  * ```typescript
86
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
58
87
  * const priceUpdateData = await priceServiceConnection.getLatestVaas([
59
88
  * SOL_PRICE_FEED_ID,
60
89
  * ETH_PRICE_FEED_ID,
@@ -62,16 +91,39 @@ export declare class PythTransactionBuilder extends TransactionBuilder {
62
91
  *
63
92
  * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
64
93
  * await transactionBuilder.addPostPartiallyVerifiedPriceUpdates(priceUpdateData);
94
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
65
95
  * await transactionBuilder.addPriceConsumerInstructions(...)
66
96
  * ...
67
97
  * ```
68
98
  */
69
99
  addPostPartiallyVerifiedPriceUpdates(priceUpdateDataArray: string[]): Promise<void>;
100
+ /**
101
+ * Add instructions to update price feed accounts to the builder.
102
+ * Price feed accounts are fixed accounts per price feed id that can only be updated with a more recent price.
103
+ *
104
+ * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
105
+ * @param shardId the shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
106
+ *
107
+ * @example
108
+ * ```typescript
109
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
110
+ * const priceUpdateData = await priceServiceConnection.getLatestVaas([
111
+ * SOL_PRICE_FEED_ID,
112
+ * ETH_PRICE_FEED_ID,
113
+ * ]);
114
+ *
115
+ * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
116
+ * await transactionBuilder.addUpdatePriceFeed(priceUpdateData);
117
+ * await transactionBuilder.addPriceConsumerInstructions(...)
118
+ * ...
119
+ * ```
120
+ */
121
+ addUpdatePriceFeed(priceUpdateDataArray: string[], shardId: number): Promise<void>;
70
122
  /**
71
123
  * Add instructions that consume price updates to the builder.
72
124
  *
73
125
  * @param getInstructions a function that given a mapping of price feed IDs to price update accounts, generates a series of instructions. Price updates get posted to ephemeral accounts and this function allows the user to indicate which accounts in their instruction need to be "replaced" with each price update account.
74
- * If multiple price updates for the same price feed id are posted with the same builder, the account corresponding to the last update to get posted will be used.
126
+ * If multiple price updates for the same price feed ID are posted with the same builder, the account corresponding to the last update to get posted will be used.
75
127
  *
76
128
  * @example
77
129
  * ```typescript
@@ -113,8 +165,8 @@ export declare class PythTransactionBuilder extends TransactionBuilder {
113
165
  signers: Signer[];
114
166
  }[];
115
167
  /**
116
- * This method is used to retrieve the address of the price update account where the price update for a given price feed id will be posted.
117
- * If multiple price updates for the same price feed id will be posted with the same builder, the address of the account corresponding to the last update to get posted will be returned.
168
+ * This method is used to retrieve the address of the price update account where the price update for a given price feed ID will be posted.
169
+ * If multiple price updates for the same price feed ID will be posted with the same builder, the address of the account corresponding to the last update to get posted will be returned.
118
170
  * */
119
171
  getPriceUpdateAccount(priceFeedId: string): PublicKey;
120
172
  }
@@ -131,11 +183,13 @@ export declare class PythSolanaReceiver {
131
183
  readonly provider: AnchorProvider;
132
184
  readonly receiver: Program<PythSolanaReceiverProgram>;
133
185
  readonly wormhole: Program<WormholeCoreBridgeSolana>;
134
- constructor({ connection, wallet, wormholeProgramId, receiverProgramId, }: {
186
+ readonly pushOracle: Program<PythPushOracle>;
187
+ constructor({ connection, wallet, wormholeProgramId, receiverProgramId, pushOracleProgramId, }: {
135
188
  connection: Connection;
136
189
  wallet: Wallet;
137
190
  wormholeProgramId?: PublicKey;
138
191
  receiverProgramId?: PublicKey;
192
+ pushOracleProgramId?: PublicKey;
139
193
  });
140
194
  /**
141
195
  * Get a new transaction builder to build transactions that interact with the Pyth Solana Receiver program and consume price updates
@@ -183,6 +237,20 @@ export declare class PythSolanaReceiver {
183
237
  priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>;
184
238
  closeInstructions: InstructionWithEphemeralSigners[];
185
239
  }>;
240
+ /**
241
+ * Build a series of helper instructions that update one or many price feed accounts and another series to close the encoded vaa accounts used to update the price feed accounts.
242
+ *
243
+ * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
244
+ * @param shardId the shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
245
+ * @returns `postInstructions`: the instructions to update the price feed accounts. If the price feed accounts don't contain a recent update, these should be called before consuming the price updates.
246
+ * @returns `priceFeedIdToPriceUpdateAccount`: this is a map of price feed IDs to Solana address. Given a price feed ID, you can use this map to find the account where `postInstructions` will post the price update. Note that since price feed accounts are PDAs, the address of the account can also be found with `getPriceFeedAccountAddress`.
247
+ * @returns `closeInstructions`: the instructions to close the encoded VAA accounts that were used to update the price feed accounts.
248
+ */
249
+ buildUpdatePriceFeedInstructions(priceUpdateDataArray: string[], shardId: number): Promise<{
250
+ postInstructions: InstructionWithEphemeralSigners[];
251
+ priceFeedIdToPriceUpdateAccount: Record<string, PublicKey>;
252
+ closeInstructions: InstructionWithEphemeralSigners[];
253
+ }>;
186
254
  /**
187
255
  * Build an instruction to close an encoded VAA account, recovering the rent.
188
256
  */
@@ -198,5 +266,25 @@ export declare class PythSolanaReceiver {
198
266
  tx: VersionedTransaction;
199
267
  signers: Signer[];
200
268
  }[]>;
269
+ /**
270
+ * Fetch the contents of a price update account
271
+ * @param priceUpdateAccount The address of the price update account
272
+ * @returns The contents of the deserialized price update account or `null` if the account doesn't exist
273
+ */
274
+ fetchPriceUpdateAccount(priceUpdateAccount: PublicKey): Promise<PriceUpdateAccount | null>;
275
+ /**
276
+ * Fetch the contents of a price feed account
277
+ * @param shardId The shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
278
+ * @param priceFeedId The price feed ID.
279
+ * @returns The contents of the deserialized price feed account or `null` if the account doesn't exist
280
+ */
281
+ fetchPriceFeedAccount(shardId: number, priceFeedId: Buffer): Promise<PriceUpdateAccount | null>;
282
+ /**
283
+ * Derive the address of a price feed account
284
+ * @param shardId The shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
285
+ * @param priceFeedId The price feed ID.
286
+ * @returns The address of the price feed account
287
+ */
288
+ getPriceFeedAccountAddress(shardId: number, priceFeedId: Buffer | string): PublicKey;
201
289
  }
202
290
  //# sourceMappingURL=PythSolanaReceiver.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PythSolanaReceiver.d.ts","sourceRoot":"","sources":["../src/PythSolanaReceiver.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,MAAM,EACN,WAAW,EACX,oBAAoB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,kBAAkB,IAAI,yBAAyB,EAEhD,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,wBAAwB,EAEzB,MAAM,mCAAmC,CAAC;AAS3C,OAAO,EAAE,SAAS,EAAW,MAAM,iBAAiB,CAAC;AAUrD,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAO7D,OAAO,EACL,kBAAkB,EAClB,+BAA+B,EAC/B,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAEnC;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG;IACzC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,sBAAuB,SAAQ,kBAAkB;IAC5D,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,C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C;QAC3D,iBAAiB,EAAE,+BAA+B,EAAE,CAAC;KACtD,CAAC;IA6DF;;OAEG;IACG,+BAA+B,CACnC,UAAU,EAAE,SAAS,GACpB,OAAO,CAAC,+BAA+B,CAAC;IAQ3C;;OAEG;IACG,gCAAgC,CACpC,kBAAkB,EAAE,SAAS,GAC5B,OAAO,CAAC,+BAA+B,CAAC;IAQ3C;;OAEG;IACG,8BAA8B,CAClC,YAAY,EAAE,+BAA+B,EAAE,EAC/C,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC;QAAE,EAAE,EAAE,oBAAoB,CAAC;QAAC,OAAO,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IAS7D;;;;OAIG;IACG,uBAAuB,CAC3B,kBAAkB,EAAE,SAAS,GAC5B,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAMrC;;;;;OAKG;IACG,qBAAqB,CACzB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAMrC;;;;;OAKG;IACH,0BAA0B,CACxB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,GAAG,MAAM,GAC3B,SAAS;CAOb"}
@@ -10,14 +10,24 @@ const price_service_sdk_1 = require("@pythnetwork/price-service-sdk");
10
10
  const compute_budget_1 = require("./compute_budget");
11
11
  const vaa_1 = require("./vaa");
12
12
  const solana_utils_1 = require("@pythnetwork/solana-utils");
13
+ const pyth_push_oracle_1 = require("./idl/pyth_push_oracle");
13
14
  /**
14
15
  * A builder class to build transactions that:
15
- * - Post price updates (fully or partially verified)
16
+ * - Post price updates (fully or partially verified) or update price feed accounts
16
17
  * - Consume price updates in a consumer program
17
18
  * - (Optionally) Close price update and encoded vaa accounts to recover the rent (`closeUpdateAccounts` in `PythTransactionBuilderConfig`)
18
19
  *
20
+ * This class provides methods for working with both price update accounts and price feed accounts.
21
+ * Price update accounts are ephemeral accounts containing a single price update, whereas price feed accounts are long-lived
22
+ * accounts that always hold price data for a specific feed id. Price feed accounts can be updated to advance the current price.
23
+ * Applications should choose which type of account to work with based on their needs. In general, applications that
24
+ * want the price at a specific time (e.g., to settle a trade) should use price update accounts, while applications that want
25
+ * any recent price should use price feed accounts.
26
+ *
19
27
  * @example
20
28
  * ```typescript
29
+ *
30
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
21
31
  * const priceUpdateData = await priceServiceConnection.getLatestVaas([
22
32
  * SOL_PRICE_FEED_ID,
23
33
  * ETH_PRICE_FEED_ID,
@@ -25,9 +35,10 @@ const solana_utils_1 = require("@pythnetwork/solana-utils");
25
35
  *
26
36
  * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
27
37
  * await transactionBuilder.addPostPriceUpdates(priceUpdateData);
38
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
28
39
  * await transactionBuilder.addPriceConsumerInstructions(...)
29
40
  *
30
- * await pythSolanaReceiver.provider.sendAll(await transactionBuilder.buildVersionedTransactions({computeUnitPriceMicroLamports:1000000}))
41
+ * await pythSolanaReceiver.provider.sendAll(await transactionBuilder.buildVersionedTransactions({computeUnitPriceMicroLamports:100000}))
31
42
  * ```
32
43
  */
33
44
  class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
@@ -44,8 +55,23 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
44
55
  }
45
56
  /**
46
57
  * Add instructions to post price updates to the builder.
58
+ * Use this function to post fully verified price updates from the present or from the past for your program to consume.
47
59
  *
48
60
  * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
61
+ *
62
+ * @example
63
+ * ```typescript
64
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
65
+ * const priceUpdateData = await priceServiceConnection.getLatestVaas([
66
+ * SOL_PRICE_FEED_ID,
67
+ * ETH_PRICE_FEED_ID,
68
+ * ]);
69
+ *
70
+ * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
71
+ * await transactionBuilder.addPostPriceUpdates(priceUpdateData);
72
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
73
+ * await transactionBuilder.addPriceConsumerInstructions(...)
74
+ * ```
49
75
  */
50
76
  async addPostPriceUpdates(priceUpdateDataArray) {
51
77
  const { postInstructions, priceFeedIdToPriceUpdateAccount, closeInstructions, } = await this.pythSolanaReceiver.buildPostPriceUpdateInstructions(priceUpdateDataArray);
@@ -55,6 +81,7 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
55
81
  }
56
82
  /**
57
83
  * Add instructions to post partially verified price updates to the builder.
84
+ * Use this function to post partially verified price updates from the present or from the past for your program to consume.
58
85
  *
59
86
  * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
60
87
  *
@@ -63,6 +90,7 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
63
90
  *
64
91
  * @example
65
92
  * ```typescript
93
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
66
94
  * const priceUpdateData = await priceServiceConnection.getLatestVaas([
67
95
  * SOL_PRICE_FEED_ID,
68
96
  * ETH_PRICE_FEED_ID,
@@ -70,6 +98,7 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
70
98
  *
71
99
  * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
72
100
  * await transactionBuilder.addPostPartiallyVerifiedPriceUpdates(priceUpdateData);
101
+ * console.log("The SOL/USD price update will get posted to:", transactionBuilder.getPriceUpdateAccount(SOL_PRICE_FEED_ID).toBase58())
73
102
  * await transactionBuilder.addPriceConsumerInstructions(...)
74
103
  * ...
75
104
  * ```
@@ -80,11 +109,38 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
80
109
  Object.assign(this.priceFeedIdToPriceUpdateAccount, priceFeedIdToPriceUpdateAccount);
81
110
  this.addInstructions(postInstructions);
82
111
  }
112
+ /**
113
+ * Add instructions to update price feed accounts to the builder.
114
+ * Price feed accounts are fixed accounts per price feed id that can only be updated with a more recent price.
115
+ *
116
+ * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
117
+ * @param shardId the shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * // Get the price feed ids from https://pyth.network/developers/price-feed-ids#pyth-evm-stable
122
+ * const priceUpdateData = await priceServiceConnection.getLatestVaas([
123
+ * SOL_PRICE_FEED_ID,
124
+ * ETH_PRICE_FEED_ID,
125
+ * ]);
126
+ *
127
+ * const transactionBuilder = pythSolanaReceiver.newTransactionBuilder({});
128
+ * await transactionBuilder.addUpdatePriceFeed(priceUpdateData);
129
+ * await transactionBuilder.addPriceConsumerInstructions(...)
130
+ * ...
131
+ * ```
132
+ */
133
+ async addUpdatePriceFeed(priceUpdateDataArray, shardId) {
134
+ const { postInstructions, priceFeedIdToPriceUpdateAccount, closeInstructions, } = await this.pythSolanaReceiver.buildUpdatePriceFeedInstructions(priceUpdateDataArray, shardId);
135
+ this.closeInstructions.push(...closeInstructions);
136
+ Object.assign(this.priceFeedIdToPriceUpdateAccount, priceFeedIdToPriceUpdateAccount);
137
+ this.addInstructions(postInstructions);
138
+ }
83
139
  /**
84
140
  * Add instructions that consume price updates to the builder.
85
141
  *
86
142
  * @param getInstructions a function that given a mapping of price feed IDs to price update accounts, generates a series of instructions. Price updates get posted to ephemeral accounts and this function allows the user to indicate which accounts in their instruction need to be "replaced" with each price update account.
87
- * If multiple price updates for the same price feed id are posted with the same builder, the account corresponding to the last update to get posted will be used.
143
+ * If multiple price updates for the same price feed ID are posted with the same builder, the account corresponding to the last update to get posted will be used.
88
144
  *
89
145
  * @example
90
146
  * ```typescript
@@ -132,8 +188,8 @@ class PythTransactionBuilder extends solana_utils_1.TransactionBuilder {
132
188
  return super.buildLegacyTransactions(args);
133
189
  }
134
190
  /**
135
- * This method is used to retrieve the address of the price update account where the price update for a given price feed id will be posted.
136
- * If multiple price updates for the same price feed id will be posted with the same builder, the address of the account corresponding to the last update to get posted will be returned.
191
+ * This method is used to retrieve the address of the price update account where the price update for a given price feed ID will be posted.
192
+ * If multiple price updates for the same price feed ID will be posted with the same builder, the address of the account corresponding to the last update to get posted will be returned.
137
193
  * */
138
194
  getPriceUpdateAccount(priceFeedId) {
139
195
  const priceUpdateAccount = this.priceFeedIdToPriceUpdateAccount[priceFeedId];
@@ -157,7 +213,8 @@ class PythSolanaReceiver {
157
213
  provider;
158
214
  receiver;
159
215
  wormhole;
160
- constructor({ connection, wallet, wormholeProgramId = address_1.DEFAULT_WORMHOLE_PROGRAM_ID, receiverProgramId = address_1.DEFAULT_RECEIVER_PROGRAM_ID, }) {
216
+ pushOracle;
217
+ constructor({ connection, wallet, wormholeProgramId = address_1.DEFAULT_WORMHOLE_PROGRAM_ID, receiverProgramId = address_1.DEFAULT_RECEIVER_PROGRAM_ID, pushOracleProgramId = address_1.DEFAULT_PUSH_ORACLE_PROGRAM_ID, }) {
161
218
  this.connection = connection;
162
219
  this.wallet = wallet;
163
220
  this.provider = new anchor_1.AnchorProvider(this.connection, this.wallet, {
@@ -165,6 +222,7 @@ class PythSolanaReceiver {
165
222
  });
166
223
  this.receiver = new anchor_1.Program(pyth_solana_receiver_1.IDL, receiverProgramId, this.provider);
167
224
  this.wormhole = new anchor_1.Program(wormhole_core_bridge_solana_1.IDL, wormholeProgramId, this.provider);
225
+ this.pushOracle = new anchor_1.Program(pyth_push_oracle_1.IDL, pushOracleProgramId, this.provider);
168
226
  }
169
227
  /**
170
228
  * Get a new transaction builder to build transactions that interact with the Pyth Solana Receiver program and consume price updates
@@ -307,6 +365,52 @@ class PythSolanaReceiver {
307
365
  closeInstructions,
308
366
  };
309
367
  }
368
+ /**
369
+ * Build a series of helper instructions that update one or many price feed accounts and another series to close the encoded vaa accounts used to update the price feed accounts.
370
+ *
371
+ * @param priceUpdateDataArray the output of the `@pythnetwork/price-service-client`'s `PriceServiceConnection.getLatestVaas`. This is an array of verifiable price updates.
372
+ * @param shardId the shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
373
+ * @returns `postInstructions`: the instructions to update the price feed accounts. If the price feed accounts don't contain a recent update, these should be called before consuming the price updates.
374
+ * @returns `priceFeedIdToPriceUpdateAccount`: this is a map of price feed IDs to Solana address. Given a price feed ID, you can use this map to find the account where `postInstructions` will post the price update. Note that since price feed accounts are PDAs, the address of the account can also be found with `getPriceFeedAccountAddress`.
375
+ * @returns `closeInstructions`: the instructions to close the encoded VAA accounts that were used to update the price feed accounts.
376
+ */
377
+ async buildUpdatePriceFeedInstructions(priceUpdateDataArray, shardId) {
378
+ const postInstructions = [];
379
+ const priceFeedIdToPriceUpdateAccount = {};
380
+ const closeInstructions = [];
381
+ for (const priceUpdateData of priceUpdateDataArray) {
382
+ const accumulatorUpdateData = (0, price_service_sdk_1.parseAccumulatorUpdateData)(Buffer.from(priceUpdateData, "base64"));
383
+ const { postInstructions: postEncodedVaaInstructions, encodedVaaAddress: encodedVaa, closeInstructions: postEncodedVaacloseInstructions, } = await this.buildPostEncodedVaaInstructions(accumulatorUpdateData.vaa);
384
+ postInstructions.push(...postEncodedVaaInstructions);
385
+ closeInstructions.push(...postEncodedVaacloseInstructions);
386
+ for (const update of accumulatorUpdateData.updates) {
387
+ const feedId = (0, price_service_sdk_1.parsePriceFeedMessage)(update.message).feedId;
388
+ postInstructions.push({
389
+ instruction: await this.pushOracle.methods
390
+ .updatePriceFeed({
391
+ merklePriceUpdate: update,
392
+ treasuryId: address_1.DEFAULT_TREASURY_ID,
393
+ }, shardId, Array.from(feedId))
394
+ .accounts({
395
+ pythSolanaReceiver: this.receiver.programId,
396
+ encodedVaa,
397
+ priceFeedAccount: this.getPriceFeedAccountAddress(shardId, feedId),
398
+ treasury: (0, address_1.getTreasuryPda)(address_1.DEFAULT_TREASURY_ID, this.receiver.programId),
399
+ config: (0, address_1.getConfigPda)(this.receiver.programId),
400
+ })
401
+ .instruction(),
402
+ signers: [],
403
+ computeUnits: compute_budget_1.POST_UPDATE_COMPUTE_BUDGET,
404
+ });
405
+ priceFeedIdToPriceUpdateAccount["0x" + (0, price_service_sdk_1.parsePriceFeedMessage)(update.message).feedId.toString("hex")] = this.getPriceFeedAccountAddress(shardId, feedId);
406
+ }
407
+ }
408
+ return {
409
+ postInstructions,
410
+ priceFeedIdToPriceUpdateAccount,
411
+ closeInstructions,
412
+ };
413
+ }
310
414
  /**
311
415
  * Build an instruction to close an encoded VAA account, recovering the rent.
312
416
  */
@@ -333,5 +437,54 @@ class PythSolanaReceiver {
333
437
  async batchIntoVersionedTransactions(instructions, priorityFeeConfig) {
334
438
  return solana_utils_1.TransactionBuilder.batchIntoVersionedTransactions(this.wallet.publicKey, this.connection, instructions, priorityFeeConfig);
335
439
  }
440
+ /**
441
+ * Fetch the contents of a price update account
442
+ * @param priceUpdateAccount The address of the price update account
443
+ * @returns The contents of the deserialized price update account or `null` if the account doesn't exist
444
+ */
445
+ async fetchPriceUpdateAccount(priceUpdateAccount) {
446
+ return this.receiver.account.priceUpdateV2.fetchNullable(priceUpdateAccount);
447
+ }
448
+ /**
449
+ * Fetch the contents of a price feed account
450
+ * @param shardId The shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
451
+ * @param priceFeedId The price feed ID.
452
+ * @returns The contents of the deserialized price feed account or `null` if the account doesn't exist
453
+ */
454
+ async fetchPriceFeedAccount(shardId, priceFeedId) {
455
+ return this.receiver.account.priceUpdateV2.fetchNullable(this.getPriceFeedAccountAddress(shardId, priceFeedId));
456
+ }
457
+ /**
458
+ * Derive the address of a price feed account
459
+ * @param shardId The shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
460
+ * @param priceFeedId The price feed ID.
461
+ * @returns The address of the price feed account
462
+ */
463
+ getPriceFeedAccountAddress(shardId, priceFeedId) {
464
+ return getPriceFeedAccountForProgram(shardId, priceFeedId, this.pushOracle.programId);
465
+ }
336
466
  }
337
467
  exports.PythSolanaReceiver = PythSolanaReceiver;
468
+ /**
469
+ * Derive the address of a price feed account
470
+ * @param shardId The shard ID of the set of price feed accounts. This shard ID allows for multiple price feed accounts for the same price feed id to exist.
471
+ * @param priceFeedId The price feed ID.
472
+ * @param pushOracleProgramId The program ID of the Pyth Push Oracle program. If not provided, the default deployment will be used.
473
+ * @returns The address of the price feed account
474
+ */
475
+ function getPriceFeedAccountForProgram(shardId, priceFeedId, pushOracleProgramId) {
476
+ if (typeof priceFeedId == "string") {
477
+ if (priceFeedId.startsWith("0x")) {
478
+ priceFeedId = Buffer.from(priceFeedId.slice(2), "hex");
479
+ }
480
+ else {
481
+ priceFeedId = Buffer.from(priceFeedId, "hex");
482
+ }
483
+ }
484
+ if (priceFeedId.length != 32) {
485
+ throw new Error("Feed ID should be 32 bytes long");
486
+ }
487
+ const shardBuffer = Buffer.alloc(2);
488
+ shardBuffer.writeUint16LE(shardId, 0);
489
+ return web3_js_1.PublicKey.findProgramAddressSync([shardBuffer, priceFeedId], pushOracleProgramId ?? address_1.DEFAULT_PUSH_ORACLE_PROGRAM_ID)[0];
490
+ }
package/lib/address.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare const DEFAULT_RECEIVER_PROGRAM_ID: PublicKey;
9
9
  * The program is deployed at this address on all SVM networks.
10
10
  */
11
11
  export declare const DEFAULT_WORMHOLE_PROGRAM_ID: PublicKey;
12
+ export declare const DEFAULT_PUSH_ORACLE_PROGRAM_ID: PublicKey;
12
13
  /**
13
14
  * Returns the address of a guardian set account from the Wormhole program.
14
15
  */
@@ -1 +1 @@
1
- {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACV,MAAM,qBACL,SAAS,cAQ7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc,eACb,MAAM,qBACC,SAAS,cAM7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAuB,SAAS,cAKxD,CAAC"}
1
+ {"version":3,"file":"address.d.ts","sourceRoot":"","sources":["../src/address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C;;;GAGG;AACH,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AACF;;;GAGG;AACH,eAAO,MAAM,2BAA2B,WAEvC,CAAC;AAEF,eAAO,MAAM,8BAA8B,WAE1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACV,MAAM,qBACL,SAAS,cAQ7B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;GAEG;AACH,eAAO,MAAM,cAAc,eACb,MAAM,qBACC,SAAS,cAM7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,sBAAuB,SAAS,cAKxD,CAAC"}
package/lib/address.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getConfigPda = exports.getTreasuryPda = exports.DEFAULT_TREASURY_ID = exports.getGuardianSetPda = exports.DEFAULT_WORMHOLE_PROGRAM_ID = exports.DEFAULT_RECEIVER_PROGRAM_ID = void 0;
3
+ exports.getConfigPda = exports.getTreasuryPda = exports.DEFAULT_TREASURY_ID = exports.getGuardianSetPda = exports.DEFAULT_PUSH_ORACLE_PROGRAM_ID = exports.DEFAULT_WORMHOLE_PROGRAM_ID = exports.DEFAULT_RECEIVER_PROGRAM_ID = void 0;
4
4
  const web3_js_1 = require("@solana/web3.js");
5
5
  /**
6
6
  * The default Pyth Solana Receiver program ID.
@@ -12,6 +12,7 @@ exports.DEFAULT_RECEIVER_PROGRAM_ID = new web3_js_1.PublicKey("rec5EKMGg6MxZYaMd
12
12
  * The program is deployed at this address on all SVM networks.
13
13
  */
14
14
  exports.DEFAULT_WORMHOLE_PROGRAM_ID = new web3_js_1.PublicKey("HDwcJBJXjL9FpJ7UBsYBtaDjsBUhuLCUYoz3zr8SWWaQ");
15
+ exports.DEFAULT_PUSH_ORACLE_PROGRAM_ID = new web3_js_1.PublicKey("pythWSnswVUd12oZpeFP8e9CVaEqJg25g1Vtc2biRsT");
15
16
  /**
16
17
  * Returns the address of a guardian set account from the Wormhole program.
17
18
  */
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * A hard-coded budget for the compute units required for the `verifyEncodedVaa` instruction in the Wormhole program.
3
3
  */
4
- export declare const VERIFY_ENCODED_VAA_COMPUTE_BUDGET = 400000;
4
+ export declare const VERIFY_ENCODED_VAA_COMPUTE_BUDGET = 350000;
5
5
  /**
6
6
  * A hard-coded budget for the compute units required for the `postUpdateAtomic` instruction in the Pyth Solana Receiver program.
7
7
  */
8
- export declare const POST_UPDATE_ATOMIC_COMPUTE_BUDGET = 400000;
8
+ export declare const POST_UPDATE_ATOMIC_COMPUTE_BUDGET = 170000;
9
9
  /**
10
10
  * A hard-coded budget for the compute units required for the `postUpdate` instruction in the Pyth Solana Receiver program.
11
11
  */
12
- export declare const POST_UPDATE_COMPUTE_BUDGET = 200000;
12
+ export declare const POST_UPDATE_COMPUTE_BUDGET = 35000;
13
13
  //# sourceMappingURL=compute_budget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compute_budget.d.ts","sourceRoot":"","sources":["../src/compute_budget.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD;;GAEG;AACH,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD;;GAEG;AACH,eAAO,MAAM,0BAA0B,SAAS,CAAC"}
1
+ {"version":3,"file":"compute_budget.d.ts","sourceRoot":"","sources":["../src/compute_budget.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD;;GAEG;AACH,eAAO,MAAM,iCAAiC,SAAS,CAAC;AACxD;;GAEG;AACH,eAAO,MAAM,0BAA0B,QAAQ,CAAC"}
@@ -4,12 +4,12 @@ exports.POST_UPDATE_COMPUTE_BUDGET = exports.POST_UPDATE_ATOMIC_COMPUTE_BUDGET =
4
4
  /**
5
5
  * A hard-coded budget for the compute units required for the `verifyEncodedVaa` instruction in the Wormhole program.
6
6
  */
7
- exports.VERIFY_ENCODED_VAA_COMPUTE_BUDGET = 400000;
7
+ exports.VERIFY_ENCODED_VAA_COMPUTE_BUDGET = 350000;
8
8
  /**
9
9
  * A hard-coded budget for the compute units required for the `postUpdateAtomic` instruction in the Pyth Solana Receiver program.
10
10
  */
11
- exports.POST_UPDATE_ATOMIC_COMPUTE_BUDGET = 400000;
11
+ exports.POST_UPDATE_ATOMIC_COMPUTE_BUDGET = 170000;
12
12
  /**
13
13
  * A hard-coded budget for the compute units required for the `postUpdate` instruction in the Pyth Solana Receiver program.
14
14
  */
15
- exports.POST_UPDATE_COMPUTE_BUDGET = 200000;
15
+ exports.POST_UPDATE_COMPUTE_BUDGET = 35000;
@@ -0,0 +1,118 @@
1
+ export type PythPushOracle = {
2
+ version: "0.1.0";
3
+ name: "pyth_push_oracle";
4
+ instructions: [
5
+ {
6
+ name: "updatePriceFeed";
7
+ accounts: [
8
+ {
9
+ name: "payer";
10
+ isMut: true;
11
+ isSigner: true;
12
+ },
13
+ {
14
+ name: "pythSolanaReceiver";
15
+ isMut: false;
16
+ isSigner: false;
17
+ },
18
+ {
19
+ name: "encodedVaa";
20
+ isMut: false;
21
+ isSigner: false;
22
+ },
23
+ {
24
+ name: "config";
25
+ isMut: false;
26
+ isSigner: false;
27
+ },
28
+ {
29
+ name: "treasury";
30
+ isMut: true;
31
+ isSigner: false;
32
+ },
33
+ {
34
+ name: "priceFeedAccount";
35
+ isMut: true;
36
+ isSigner: false;
37
+ },
38
+ {
39
+ name: "systemProgram";
40
+ isMut: false;
41
+ isSigner: false;
42
+ }
43
+ ];
44
+ args: [
45
+ {
46
+ name: "params";
47
+ type: {
48
+ defined: "PostUpdateParams";
49
+ };
50
+ },
51
+ {
52
+ name: "shardId";
53
+ type: "u16";
54
+ },
55
+ {
56
+ name: "feedId";
57
+ type: {
58
+ array: ["u8", 32];
59
+ };
60
+ }
61
+ ];
62
+ }
63
+ ];
64
+ types: [
65
+ {
66
+ name: "PostUpdateParams";
67
+ type: {
68
+ kind: "struct";
69
+ fields: [
70
+ {
71
+ name: "merklePriceUpdate";
72
+ type: {
73
+ defined: "MerklePriceUpdate";
74
+ };
75
+ },
76
+ {
77
+ name: "treasuryId";
78
+ type: "u8";
79
+ }
80
+ ];
81
+ };
82
+ },
83
+ {
84
+ name: "MerklePriceUpdate";
85
+ type: {
86
+ kind: "struct";
87
+ fields: [
88
+ {
89
+ name: "message";
90
+ type: "bytes";
91
+ },
92
+ {
93
+ name: "proof";
94
+ type: {
95
+ vec: {
96
+ array: ["u8", 20];
97
+ };
98
+ };
99
+ }
100
+ ];
101
+ };
102
+ }
103
+ ];
104
+ errors: [
105
+ {
106
+ code: 6000;
107
+ name: "UpdatesNotMonotonic";
108
+ msg: "Updates must be monotonically increasing";
109
+ },
110
+ {
111
+ code: 6001;
112
+ name: "PriceFeedMessageMismatch";
113
+ msg: "Trying to update price feed with the wrong feed id";
114
+ }
115
+ ];
116
+ };
117
+ export declare const IDL: PythPushOracle;
118
+ //# sourceMappingURL=pyth_push_oracle.d.ts.map
@@ -0,0 +1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L = void 0;
4
+ exports.IDL = {
5
+ version: "0.1.0",
6
+ name: "pyth_push_oracle",
7
+ instructions: [
8
+ {
9
+ name: "updatePriceFeed",
10
+ accounts: [
11
+ {
12
+ name: "payer",
13
+ isMut: true,
14
+ isSigner: true,
15
+ },
16
+ {
17
+ name: "pythSolanaReceiver",
18
+ isMut: false,
19
+ isSigner: false,
20
+ },
21
+ {
22
+ name: "encodedVaa",
23
+ isMut: false,
24
+ isSigner: false,
25
+ },
26
+ {
27
+ name: "config",
28
+ isMut: false,
29
+ isSigner: false,
30
+ },
31
+ {
32
+ name: "treasury",
33
+ isMut: true,
34
+ isSigner: false,
35
+ },
36
+ {
37
+ name: "priceFeedAccount",
38
+ isMut: true,
39
+ isSigner: false,
40
+ },
41
+ {
42
+ name: "systemProgram",
43
+ isMut: false,
44
+ isSigner: false,
45
+ },
46
+ ],
47
+ args: [
48
+ {
49
+ name: "params",
50
+ type: {
51
+ defined: "PostUpdateParams",
52
+ },
53
+ },
54
+ {
55
+ name: "shardId",
56
+ type: "u16",
57
+ },
58
+ {
59
+ name: "feedId",
60
+ type: {
61
+ array: ["u8", 32],
62
+ },
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ types: [
68
+ {
69
+ name: "PostUpdateParams",
70
+ type: {
71
+ kind: "struct",
72
+ fields: [
73
+ {
74
+ name: "merklePriceUpdate",
75
+ type: {
76
+ defined: "MerklePriceUpdate",
77
+ },
78
+ },
79
+ {
80
+ name: "treasuryId",
81
+ type: "u8",
82
+ },
83
+ ],
84
+ },
85
+ },
86
+ {
87
+ name: "MerklePriceUpdate",
88
+ type: {
89
+ kind: "struct",
90
+ fields: [
91
+ {
92
+ name: "message",
93
+ type: "bytes",
94
+ },
95
+ {
96
+ name: "proof",
97
+ type: {
98
+ vec: {
99
+ array: ["u8", 20],
100
+ },
101
+ },
102
+ },
103
+ ],
104
+ },
105
+ },
106
+ ],
107
+ errors: [
108
+ {
109
+ code: 6000,
110
+ name: "UpdatesNotMonotonic",
111
+ msg: "Updates must be monotonically increasing",
112
+ },
113
+ {
114
+ code: 6001,
115
+ name: "PriceFeedMessageMismatch",
116
+ msg: "Trying to update price feed with the wrong feed id",
117
+ },
118
+ ],
119
+ };
@@ -200,6 +200,11 @@ export type PythSolanaReceiver = {
200
200
  name: "systemProgram";
201
201
  isMut: false;
202
202
  isSigner: false;
203
+ },
204
+ {
205
+ name: "writeAuthority";
206
+ isMut: false;
207
+ isSigner: true;
203
208
  }
204
209
  ];
205
210
  args: [
@@ -252,6 +257,11 @@ export type PythSolanaReceiver = {
252
257
  name: "systemProgram";
253
258
  isMut: false;
254
259
  isSigner: false;
260
+ },
261
+ {
262
+ name: "writeAuthority";
263
+ isMut: false;
264
+ isSigner: true;
255
265
  }
256
266
  ];
257
267
  args: [
@@ -320,7 +330,7 @@ export type PythSolanaReceiver = {
320
330
  };
321
331
  },
322
332
  {
323
- name: "priceUpdateV1";
333
+ name: "priceUpdateV2";
324
334
  type: {
325
335
  kind: "struct";
326
336
  fields: [
@@ -339,6 +349,10 @@ export type PythSolanaReceiver = {
339
349
  type: {
340
350
  defined: "PriceFeedMessage";
341
351
  };
352
+ },
353
+ {
354
+ name: "postedSlot";
355
+ type: "u64";
342
356
  }
343
357
  ];
344
358
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pyth_solana_receiver.d.ts","sourceRoot":"","sources":["../../src/idl/pyth_solana_receiver.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,sBAAsB,CAAC;IAC7B,YAAY,EAAE;QACZ;YACE,IAAI,EAAE,YAAY,CAAC;YACnB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,OAAO,CAAC;oBACd,KAAK,EAAE,IAAI,CAAC;oBACZ,QAAQ,EAAE,IAAI,CAAC;iBAChB;gBACD;oBACE,IAAI,EAAE,QAAQ,CAAC;oBACf,KAAK,EAAE,IAAI,CAAC;oBACZ,QA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AC;SAC/D;QACD;YACE,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,uBAAuB,CAAC;YAC9B,GAAG,EAAE,2DAA2D,CAAC;SAClE;QACD;YACE,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,oBAAoB,CAAC;YAC3B,GAAG,EAAE,6BAA6B,CAAC;SACpC;QACD;YACE,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,6BAA6B,CAAC;YACpC,GAAG,EAAE,gEAAgE,CAAC;SACvE;QACD;YACE,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,mCAAmC,CAAC;YAC1C,GAAG,EAAE,iEAAiE,CAAC;SACxE;QACD;YACE,IAAI,EAAE,IAAI,CAAC;YACX,IAAI,EAAE,+CAA+C,CAAC;YACtD,GAAG,EAAE,4DAA4D,CAAC;SACnE;KACF,CAAC;CACH,CAAC;AAEF,eAAO,MAAM,GAAG,EAAE,kBAumBjB,CAAC"}
@@ -204,6 +204,11 @@ exports.IDL = {
204
204
  isMut: false,
205
205
  isSigner: false,
206
206
  },
207
+ {
208
+ name: "writeAuthority",
209
+ isMut: false,
210
+ isSigner: true,
211
+ },
207
212
  ],
208
213
  args: [
209
214
  {
@@ -256,6 +261,11 @@ exports.IDL = {
256
261
  isMut: false,
257
262
  isSigner: false,
258
263
  },
264
+ {
265
+ name: "writeAuthority",
266
+ isMut: false,
267
+ isSigner: true,
268
+ },
259
269
  ],
260
270
  args: [
261
271
  {
@@ -323,7 +333,7 @@ exports.IDL = {
323
333
  },
324
334
  },
325
335
  {
326
- name: "priceUpdateV1",
336
+ name: "priceUpdateV2",
327
337
  type: {
328
338
  kind: "struct",
329
339
  fields: [
@@ -343,6 +353,10 @@ exports.IDL = {
343
353
  defined: "PriceFeedMessage",
344
354
  },
345
355
  },
356
+ {
357
+ name: "postedSlot",
358
+ type: "u64",
359
+ },
346
360
  ],
347
361
  },
348
362
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pythnetwork/pyth-solana-receiver",
3
- "version": "0.2.3",
3
+ "version": "0.5.0",
4
4
  "description": "Pyth solana receiver SDK",
5
5
  "homepage": "https://pyth.network",
6
6
  "main": "lib/index.js",
@@ -47,5 +47,5 @@
47
47
  "@pythnetwork/solana-utils": "*",
48
48
  "@solana/web3.js": "^1.90.0"
49
49
  },
50
- "gitHead": "ab7560ad3504cd5057d264fa30ee6ff810e1064b"
50
+ "gitHead": "62d189e3b5e3cdbbfba04c1ebd677b28f4a6f693"
51
51
  }