pangu-sdk 0.1.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.
@@ -0,0 +1,86 @@
1
+ import { VersionedTransaction, Signer, PublicKey, Connection } from '@solana/web3.js';
2
+ import { F as FeedId, S as Sale } from './accounts-BuD-oCcr.js';
3
+
4
+ /**
5
+ * Keeping a banded sale's price fresh.
6
+ *
7
+ * Node and server only. It reaches Pyth's Hermes service over the network with
8
+ * an API key, and it pulls in `@pythnetwork/pyth-solana-receiver`, so the web
9
+ * app calls it from a server route and never from the browser. The key would be
10
+ * in every browser bundle otherwise, and every Hermes read has needed one since
11
+ * 26 August 2026
12
+ * (https://docs.pyth.network/price-feeds/core/upgrade/preparing). Reading a price back is
13
+ * `readPrice` in the core entry point, which is browser safe.
14
+ */
15
+
16
+ /** The environment variable the Hermes key is read from. Server side only. */
17
+ declare const API_KEY_VARIABLE = "PYTH_API_KEY";
18
+ /** The feed a refresh writes: taken off a sale, or given by hand. */
19
+ interface FeedChoice {
20
+ priceFeedId: FeedId;
21
+ /** Defaults to Pangu's own shard, the one its refresher writes. */
22
+ shard?: number;
23
+ }
24
+ interface RefreshPriceInput {
25
+ connection: Connection;
26
+ /** Who pays the fee. Anyone can: the payer is not part of the address. */
27
+ payer: PublicKey;
28
+ /** A sale read from the chain, or the feed by hand. */
29
+ sale?: Sale;
30
+ feed?: FeedChoice;
31
+ /**
32
+ * The Hermes API key. Defaults to `PYTH_API_KEY` in the environment, which is
33
+ * where it should live: it is never a value a browser or a caller passes in.
34
+ */
35
+ apiKey?: string;
36
+ /** Another Hermes host, for a self-hosted one. */
37
+ hermesUrl?: string;
38
+ }
39
+ /** One transaction of a refresh, unsigned, with the keys it needs besides the payer. */
40
+ interface RefreshTransaction {
41
+ transaction: VersionedTransaction;
42
+ /** Ephemeral accounts the guardian-signed update is verified through. */
43
+ signers: Signer[];
44
+ }
45
+ interface RefreshPrice {
46
+ /**
47
+ * Unsigned, in order. The payer signs each one and sends them in this order:
48
+ * the update is posted into an encoded VAA account first and the price feed
49
+ * account is written from it second, and the pair does not fit in one
50
+ * transaction.
51
+ */
52
+ transactions: RefreshTransaction[];
53
+ /** The one account this feed and shard write to, for reading back afterwards. */
54
+ priceAccount: PublicKey;
55
+ shard: number;
56
+ /** Lowercase hex, no prefix. */
57
+ feedId: string;
58
+ /** Every transaction's bytes added up, against a limit of 1232 each. */
59
+ bytes: number;
60
+ }
61
+ /**
62
+ * Builds the transactions that write a fresh stock price into the one account
63
+ * this sale reads.
64
+ *
65
+ * Anybody can send them and the payer is not one of the account's seeds, so the
66
+ * address never moves and a sale can name it before anyone has ever refreshed
67
+ * it. It takes two transactions, not one: the guardian-signed update has to be
68
+ * posted into an encoded VAA account before the price feed account can be
69
+ * written from it, and the pair does not fit in 1232 bytes. So a refresh cannot
70
+ * ride along with a buy; send it first and the buy straight after, inside the
71
+ * age the sale allows.
72
+ *
73
+ * The encoded VAA account is closed by the last transaction, which is the
74
+ * difference between a refresh costing about 35 thousand lamports and about
75
+ * 2.4 million (docs/measurements/price-band-pyth.md). The price feed account
76
+ * itself is a program address, it is not one of the accounts closed, and it
77
+ * stays where it is.
78
+ *
79
+ * Node and server only. Signs and sends nothing.
80
+ *
81
+ * Throws PanguInputError when neither a sale nor a feed is given, when the sale
82
+ * has no band, when there is no API key, or when Hermes refuses.
83
+ */
84
+ declare function refreshPriceTransaction(input: RefreshPriceInput): Promise<RefreshPrice>;
85
+
86
+ export { API_KEY_VARIABLE, type FeedChoice, type RefreshPrice, type RefreshPriceInput, type RefreshTransaction, refreshPriceTransaction };