@pythnetwork/hermes-client 2.0.0 → 3.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,293 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
+ for(var name in all)Object.defineProperty(target, name, {
7
+ enumerable: true,
8
+ get: Object.getOwnPropertyDescriptor(all, name).get
9
+ });
10
+ }
11
+ _export(exports, {
12
+ get api () {
13
+ return api;
14
+ },
15
+ get createApiClient () {
16
+ return createApiClient;
17
+ },
18
+ get schemas () {
19
+ return schemas;
20
+ }
21
+ });
22
+ const _core = require("@zodios/core");
23
+ const _zod = require("zod");
24
+ const AssetType = _zod.z.enum([
25
+ "crypto",
26
+ "fx",
27
+ "equity",
28
+ "metal",
29
+ "rates",
30
+ "crypto_redemption_rate",
31
+ "commodities",
32
+ "crypto_index",
33
+ "crypto_nav",
34
+ "eco",
35
+ "kalshi"
36
+ ]);
37
+ const asset_type = AssetType.nullish();
38
+ const RpcPriceIdentifier = _zod.z.string();
39
+ const PriceFeedMetadata = _zod.z.object({
40
+ attributes: _zod.z.record(_zod.z.string()),
41
+ id: RpcPriceIdentifier
42
+ }).passthrough();
43
+ const PriceIdInput = _zod.z.string();
44
+ const EncodingType = _zod.z.enum([
45
+ "hex",
46
+ "base64"
47
+ ]);
48
+ const BinaryUpdate = _zod.z.object({
49
+ data: _zod.z.array(_zod.z.string()),
50
+ encoding: EncodingType
51
+ }).passthrough();
52
+ const RpcPrice = _zod.z.object({
53
+ conf: _zod.z.string(),
54
+ expo: _zod.z.number().int(),
55
+ price: _zod.z.string(),
56
+ publish_time: _zod.z.number().int()
57
+ }).passthrough();
58
+ const RpcPriceFeedMetadataV2 = _zod.z.object({
59
+ prev_publish_time: _zod.z.number().int().nullable(),
60
+ proof_available_time: _zod.z.number().int().nullable(),
61
+ slot: _zod.z.number().int().gte(0).nullable()
62
+ }).partial().passthrough();
63
+ const ParsedPriceUpdate = _zod.z.object({
64
+ ema_price: RpcPrice,
65
+ id: RpcPriceIdentifier,
66
+ metadata: RpcPriceFeedMetadataV2,
67
+ price: RpcPrice
68
+ }).passthrough();
69
+ const PriceUpdate = _zod.z.object({
70
+ binary: BinaryUpdate,
71
+ parsed: _zod.z.array(ParsedPriceUpdate).nullish()
72
+ }).passthrough();
73
+ const ParsedPublisherStakeCap = _zod.z.object({
74
+ cap: _zod.z.number().int().gte(0),
75
+ publisher: _zod.z.string()
76
+ }).passthrough();
77
+ const ParsedPublisherStakeCapsUpdate = _zod.z.object({
78
+ publisher_stake_caps: _zod.z.array(ParsedPublisherStakeCap)
79
+ }).passthrough();
80
+ const LatestPublisherStakeCapsUpdateDataResponse = _zod.z.object({
81
+ binary: BinaryUpdate,
82
+ parsed: _zod.z.array(ParsedPublisherStakeCapsUpdate).nullish()
83
+ }).passthrough();
84
+ const schemas = {
85
+ AssetType,
86
+ asset_type,
87
+ RpcPriceIdentifier,
88
+ PriceFeedMetadata,
89
+ PriceIdInput,
90
+ EncodingType,
91
+ BinaryUpdate,
92
+ RpcPrice,
93
+ RpcPriceFeedMetadataV2,
94
+ ParsedPriceUpdate,
95
+ PriceUpdate,
96
+ ParsedPublisherStakeCap,
97
+ ParsedPublisherStakeCapsUpdate,
98
+ LatestPublisherStakeCapsUpdateDataResponse
99
+ };
100
+ const endpoints = (0, _core.makeApi)([
101
+ {
102
+ method: "get",
103
+ path: "/v2/price_feeds",
104
+ alias: "price_feeds_metadata",
105
+ description: `Get the set of price feeds.
106
+
107
+ This endpoint fetches all price feeds from the Pyth network. It can be filtered by asset type
108
+ and query string.`,
109
+ requestFormat: "json",
110
+ parameters: [
111
+ {
112
+ name: "query",
113
+ type: "Query",
114
+ schema: _zod.z.string().nullish()
115
+ },
116
+ {
117
+ name: "asset_type",
118
+ type: "Query",
119
+ schema: asset_type
120
+ }
121
+ ],
122
+ response: _zod.z.array(PriceFeedMetadata)
123
+ },
124
+ {
125
+ method: "get",
126
+ path: "/v2/updates/price/:publish_time",
127
+ alias: "timestamp_price_updates",
128
+ description: `Get the latest price updates by price feed id.
129
+
130
+ Given a collection of price feed ids, retrieve the latest Pyth price for each price feed.`,
131
+ requestFormat: "json",
132
+ parameters: [
133
+ {
134
+ name: "publish_time",
135
+ type: "Path",
136
+ schema: _zod.z.number().int()
137
+ },
138
+ {
139
+ name: "ids[]",
140
+ type: "Query",
141
+ schema: _zod.z.array(PriceIdInput)
142
+ },
143
+ {
144
+ name: "encoding",
145
+ type: "Query",
146
+ schema: _zod.z.enum([
147
+ "hex",
148
+ "base64"
149
+ ]).optional()
150
+ },
151
+ {
152
+ name: "parsed",
153
+ type: "Query",
154
+ schema: _zod.z.boolean().optional()
155
+ },
156
+ {
157
+ name: "ignore_invalid_price_ids",
158
+ type: "Query",
159
+ schema: _zod.z.boolean().optional()
160
+ }
161
+ ],
162
+ response: PriceUpdate,
163
+ errors: [
164
+ {
165
+ status: 404,
166
+ description: `Price ids not found`,
167
+ schema: _zod.z.void()
168
+ }
169
+ ]
170
+ },
171
+ {
172
+ method: "get",
173
+ path: "/v2/updates/price/latest",
174
+ alias: "latest_price_updates",
175
+ description: `Get the latest price updates by price feed id.
176
+
177
+ Given a collection of price feed ids, retrieve the latest Pyth price for each price feed.`,
178
+ requestFormat: "json",
179
+ parameters: [
180
+ {
181
+ name: "ids[]",
182
+ type: "Query",
183
+ schema: _zod.z.array(PriceIdInput)
184
+ },
185
+ {
186
+ name: "encoding",
187
+ type: "Query",
188
+ schema: _zod.z.enum([
189
+ "hex",
190
+ "base64"
191
+ ]).optional()
192
+ },
193
+ {
194
+ name: "parsed",
195
+ type: "Query",
196
+ schema: _zod.z.boolean().optional()
197
+ },
198
+ {
199
+ name: "ignore_invalid_price_ids",
200
+ type: "Query",
201
+ schema: _zod.z.boolean().optional()
202
+ }
203
+ ],
204
+ response: PriceUpdate,
205
+ errors: [
206
+ {
207
+ status: 404,
208
+ description: `Price ids not found`,
209
+ schema: _zod.z.void()
210
+ }
211
+ ]
212
+ },
213
+ {
214
+ method: "get",
215
+ path: "/v2/updates/price/stream",
216
+ alias: "price_stream_sse_handler",
217
+ description: `SSE route handler for streaming price updates.
218
+
219
+ The connection will automatically close after 24 hours to prevent resource leaks.
220
+ Clients should implement reconnection logic to maintain continuous price updates.`,
221
+ requestFormat: "json",
222
+ parameters: [
223
+ {
224
+ name: "ids[]",
225
+ type: "Query",
226
+ schema: _zod.z.array(PriceIdInput)
227
+ },
228
+ {
229
+ name: "encoding",
230
+ type: "Query",
231
+ schema: _zod.z.enum([
232
+ "hex",
233
+ "base64"
234
+ ]).optional()
235
+ },
236
+ {
237
+ name: "parsed",
238
+ type: "Query",
239
+ schema: _zod.z.boolean().optional()
240
+ },
241
+ {
242
+ name: "allow_unordered",
243
+ type: "Query",
244
+ schema: _zod.z.boolean().optional()
245
+ },
246
+ {
247
+ name: "benchmarks_only",
248
+ type: "Query",
249
+ schema: _zod.z.boolean().optional()
250
+ },
251
+ {
252
+ name: "ignore_invalid_price_ids",
253
+ type: "Query",
254
+ schema: _zod.z.boolean().optional()
255
+ }
256
+ ],
257
+ response: PriceUpdate,
258
+ errors: [
259
+ {
260
+ status: 404,
261
+ description: `Price ids not found`,
262
+ schema: _zod.z.void()
263
+ }
264
+ ]
265
+ },
266
+ {
267
+ method: "get",
268
+ path: "/v2/updates/publisher_stake_caps/latest",
269
+ alias: "latest_publisher_stake_caps",
270
+ description: `Get the most recent publisher stake caps update data.`,
271
+ requestFormat: "json",
272
+ parameters: [
273
+ {
274
+ name: "encoding",
275
+ type: "Query",
276
+ schema: _zod.z.enum([
277
+ "hex",
278
+ "base64"
279
+ ]).optional()
280
+ },
281
+ {
282
+ name: "parsed",
283
+ type: "Query",
284
+ schema: _zod.z.boolean().optional()
285
+ }
286
+ ],
287
+ response: LatestPublisherStakeCapsUpdateDataResponse
288
+ }
289
+ ]);
290
+ const api = new _core.Zodios(endpoints);
291
+ function createApiClient(baseUrl, options) {
292
+ return new _core.Zodios(baseUrl, endpoints, options);
293
+ }