@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.
- package/README.md +6 -5
- package/dist/cjs/hermes-client.cjs +209 -0
- package/{lib/HermesClient.d.ts → dist/cjs/hermes-client.d.ts} +20 -34
- package/dist/cjs/index.cjs +18 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/utils.cjs +22 -0
- package/{lib → dist/cjs}/utils.d.ts +0 -1
- package/dist/cjs/zodSchemas.cjs +293 -0
- package/{lib → dist/cjs}/zodSchemas.d.ts +20 -827
- package/dist/esm/hermes-client.d.ts +145 -0
- package/dist/esm/hermes-client.mjs +199 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/utils.d.ts +1 -0
- package/dist/esm/utils.mjs +12 -0
- package/dist/esm/zodSchemas.d.ts +4146 -0
- package/dist/esm/zodSchemas.mjs +272 -0
- package/package.json +70 -23
- package/lib/HermesClient.d.ts.map +0 -1
- package/lib/HermesClient.js +0 -216
- package/lib/examples/HermesClient.d.ts +0 -2
- package/lib/examples/HermesClient.d.ts.map +0 -1
- package/lib/examples/HermesClient.js +0 -86
- package/lib/utils.d.ts.map +0 -1
- package/lib/utils.js +0 -13
- package/lib/zodSchemas.d.ts.map +0 -1
- package/lib/zodSchemas.js +0 -322
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const yargs_1 = __importDefault(require("yargs"));
|
|
7
|
-
const helpers_1 = require("yargs/helpers");
|
|
8
|
-
const HermesClient_1 = require("../HermesClient");
|
|
9
|
-
function sleep(ms) {
|
|
10
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
11
|
-
}
|
|
12
|
-
const argv = (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
|
13
|
-
.option("endpoint", {
|
|
14
|
-
description: "Endpoint URL for the price service. e.g: https://endpoint/example",
|
|
15
|
-
type: "string",
|
|
16
|
-
required: true,
|
|
17
|
-
})
|
|
18
|
-
.option("price-ids", {
|
|
19
|
-
description: "Space separated price feed ids (in hex without leading 0x) to fetch." +
|
|
20
|
-
" e.g: f9c0172ba10dfa4d19088d...",
|
|
21
|
-
type: "array",
|
|
22
|
-
required: true,
|
|
23
|
-
})
|
|
24
|
-
.help()
|
|
25
|
-
.alias("help", "h")
|
|
26
|
-
.parserConfiguration({
|
|
27
|
-
"parse-numbers": false,
|
|
28
|
-
})
|
|
29
|
-
.parseSync();
|
|
30
|
-
/**
|
|
31
|
-
* Extracts the endpoint and basic authorization headers from a given URL string.
|
|
32
|
-
*
|
|
33
|
-
* @param {string} urlString - The URL string containing the endpoint and optional basic auth credentials.
|
|
34
|
-
* @returns {{ endpoint: string; headers: HeadersInit }} An object containing the endpoint URL and headers.
|
|
35
|
-
*/
|
|
36
|
-
function extractBasicAuthorizationHeadersFromUrl(urlString) {
|
|
37
|
-
const url = new URL(urlString);
|
|
38
|
-
const headers = {};
|
|
39
|
-
if (url.username && url.password) {
|
|
40
|
-
headers["Authorization"] = `Basic ${btoa(`${url.username}:${url.password}`)}`;
|
|
41
|
-
url.username = "";
|
|
42
|
-
url.password = "";
|
|
43
|
-
}
|
|
44
|
-
return { endpoint: url.toString(), headers };
|
|
45
|
-
}
|
|
46
|
-
async function run() {
|
|
47
|
-
const { endpoint, headers } = extractBasicAuthorizationHeadersFromUrl(argv.endpoint);
|
|
48
|
-
const connection = new HermesClient_1.HermesClient(endpoint, { headers });
|
|
49
|
-
const priceIds = argv.priceIds;
|
|
50
|
-
// Get price feeds
|
|
51
|
-
console.log(`Price feeds matching "btc" with asset type "crypto":`);
|
|
52
|
-
const priceFeeds = await connection.getPriceFeeds({
|
|
53
|
-
query: "btc",
|
|
54
|
-
assetType: "crypto",
|
|
55
|
-
});
|
|
56
|
-
console.log(priceFeeds);
|
|
57
|
-
// Latest price updates
|
|
58
|
-
console.log(`Latest price updates for price IDs ${priceIds}:`);
|
|
59
|
-
const priceUpdates = await connection.getLatestPriceUpdates(priceIds);
|
|
60
|
-
console.log(priceUpdates);
|
|
61
|
-
// Get the latest 5 second TWAPs
|
|
62
|
-
console.log(`Latest 5 second TWAPs for price IDs ${priceIds}`);
|
|
63
|
-
const twapUpdates = await connection.getLatestTwaps(priceIds, 5);
|
|
64
|
-
console.log(twapUpdates);
|
|
65
|
-
// Streaming price updates
|
|
66
|
-
console.log(`Streaming latest prices for price IDs ${priceIds}...`);
|
|
67
|
-
const eventSource = await connection.getPriceUpdatesStream(priceIds, {
|
|
68
|
-
encoding: "hex",
|
|
69
|
-
parsed: true,
|
|
70
|
-
allowUnordered: false,
|
|
71
|
-
benchmarksOnly: true,
|
|
72
|
-
});
|
|
73
|
-
eventSource.onmessage = (event) => {
|
|
74
|
-
console.log("Received price update:", event.data);
|
|
75
|
-
const _priceUpdate = JSON.parse(event.data);
|
|
76
|
-
};
|
|
77
|
-
eventSource.onerror = (error) => {
|
|
78
|
-
console.error("Error receiving updates:", error);
|
|
79
|
-
eventSource.close();
|
|
80
|
-
};
|
|
81
|
-
await sleep(5000);
|
|
82
|
-
// To stop listening to the updates, you can call eventSource.close();
|
|
83
|
-
console.log("Closing event source.");
|
|
84
|
-
eventSource.close();
|
|
85
|
-
}
|
|
86
|
-
run();
|
package/lib/utils.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAIA,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,GACpC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,CAMlC"}
|
package/lib/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.camelToSnakeCaseObject = camelToSnakeCaseObject;
|
|
4
|
-
function camelToSnakeCase(str) {
|
|
5
|
-
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
6
|
-
}
|
|
7
|
-
function camelToSnakeCaseObject(obj) {
|
|
8
|
-
const result = {};
|
|
9
|
-
Object.keys(obj).forEach((key) => {
|
|
10
|
-
result[camelToSnakeCase(key)] = obj[key];
|
|
11
|
-
});
|
|
12
|
-
return result;
|
|
13
|
-
}
|
package/lib/zodSchemas.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zodSchemas.d.ts","sourceRoot":"","sources":["../src/zodSchemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8ExB,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEvE"}
|
package/lib/zodSchemas.js
DELETED
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.api = exports.schemas = void 0;
|
|
4
|
-
exports.createApiClient = createApiClient;
|
|
5
|
-
const core_1 = require("@zodios/core");
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const AssetType = zod_1.z.enum([
|
|
8
|
-
"crypto",
|
|
9
|
-
"fx",
|
|
10
|
-
"equity",
|
|
11
|
-
"metal",
|
|
12
|
-
"rates",
|
|
13
|
-
"crypto_redemption_rate",
|
|
14
|
-
]);
|
|
15
|
-
const asset_type = AssetType.nullish();
|
|
16
|
-
const RpcPriceIdentifier = zod_1.z.string();
|
|
17
|
-
const PriceFeedMetadata = zod_1.z
|
|
18
|
-
.object({ attributes: zod_1.z.record(zod_1.z.string()), id: RpcPriceIdentifier })
|
|
19
|
-
.passthrough();
|
|
20
|
-
const PriceIdInput = zod_1.z.string();
|
|
21
|
-
const EncodingType = zod_1.z.enum(["hex", "base64"]);
|
|
22
|
-
const BinaryUpdate = zod_1.z
|
|
23
|
-
.object({ data: zod_1.z.array(zod_1.z.string()), encoding: EncodingType })
|
|
24
|
-
.passthrough();
|
|
25
|
-
const RpcPrice = zod_1.z
|
|
26
|
-
.object({
|
|
27
|
-
conf: zod_1.z.string(),
|
|
28
|
-
expo: zod_1.z.number().int(),
|
|
29
|
-
price: zod_1.z.string(),
|
|
30
|
-
publish_time: zod_1.z.number().int(),
|
|
31
|
-
})
|
|
32
|
-
.passthrough();
|
|
33
|
-
const RpcPriceFeedMetadataV2 = zod_1.z
|
|
34
|
-
.object({
|
|
35
|
-
prev_publish_time: zod_1.z.number().int().nullable(),
|
|
36
|
-
proof_available_time: zod_1.z.number().int().nullable(),
|
|
37
|
-
slot: zod_1.z.number().int().gte(0).nullable(),
|
|
38
|
-
})
|
|
39
|
-
.partial()
|
|
40
|
-
.passthrough();
|
|
41
|
-
const ParsedPriceUpdate = zod_1.z
|
|
42
|
-
.object({
|
|
43
|
-
ema_price: RpcPrice,
|
|
44
|
-
id: RpcPriceIdentifier,
|
|
45
|
-
metadata: RpcPriceFeedMetadataV2,
|
|
46
|
-
price: RpcPrice,
|
|
47
|
-
})
|
|
48
|
-
.passthrough();
|
|
49
|
-
const PriceUpdate = zod_1.z
|
|
50
|
-
.object({
|
|
51
|
-
binary: BinaryUpdate,
|
|
52
|
-
parsed: zod_1.z.array(ParsedPriceUpdate).nullish(),
|
|
53
|
-
})
|
|
54
|
-
.passthrough();
|
|
55
|
-
const ParsedPublisherStakeCap = zod_1.z
|
|
56
|
-
.object({ cap: zod_1.z.number().int().gte(0), publisher: zod_1.z.string() })
|
|
57
|
-
.passthrough();
|
|
58
|
-
const ParsedPublisherStakeCapsUpdate = zod_1.z
|
|
59
|
-
.object({ publisher_stake_caps: zod_1.z.array(ParsedPublisherStakeCap) })
|
|
60
|
-
.passthrough();
|
|
61
|
-
const LatestPublisherStakeCapsUpdateDataResponse = zod_1.z
|
|
62
|
-
.object({
|
|
63
|
-
binary: BinaryUpdate,
|
|
64
|
-
parsed: zod_1.z.array(ParsedPublisherStakeCapsUpdate).nullish(),
|
|
65
|
-
})
|
|
66
|
-
.passthrough();
|
|
67
|
-
const ParsedPriceFeedTwap = zod_1.z
|
|
68
|
-
.object({
|
|
69
|
-
down_slots_ratio: zod_1.z.string(),
|
|
70
|
-
end_timestamp: zod_1.z.number().int(),
|
|
71
|
-
id: RpcPriceIdentifier,
|
|
72
|
-
start_timestamp: zod_1.z.number().int(),
|
|
73
|
-
twap: RpcPrice,
|
|
74
|
-
})
|
|
75
|
-
.passthrough();
|
|
76
|
-
const TwapsResponse = zod_1.z
|
|
77
|
-
.object({
|
|
78
|
-
binary: BinaryUpdate,
|
|
79
|
-
parsed: zod_1.z.array(ParsedPriceFeedTwap).nullish(),
|
|
80
|
-
})
|
|
81
|
-
.passthrough();
|
|
82
|
-
exports.schemas = {
|
|
83
|
-
AssetType,
|
|
84
|
-
asset_type,
|
|
85
|
-
RpcPriceIdentifier,
|
|
86
|
-
PriceFeedMetadata,
|
|
87
|
-
PriceIdInput,
|
|
88
|
-
EncodingType,
|
|
89
|
-
BinaryUpdate,
|
|
90
|
-
RpcPrice,
|
|
91
|
-
RpcPriceFeedMetadataV2,
|
|
92
|
-
ParsedPriceUpdate,
|
|
93
|
-
PriceUpdate,
|
|
94
|
-
ParsedPublisherStakeCap,
|
|
95
|
-
ParsedPublisherStakeCapsUpdate,
|
|
96
|
-
LatestPublisherStakeCapsUpdateDataResponse,
|
|
97
|
-
ParsedPriceFeedTwap,
|
|
98
|
-
TwapsResponse,
|
|
99
|
-
};
|
|
100
|
-
const endpoints = (0, core_1.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_1.z.string().nullish(),
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
name: "asset_type",
|
|
118
|
-
type: "Query",
|
|
119
|
-
schema: asset_type,
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
response: zod_1.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_1.z.number().int(),
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
name: "ids[]",
|
|
140
|
-
type: "Query",
|
|
141
|
-
schema: zod_1.z.array(PriceIdInput),
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
name: "encoding",
|
|
145
|
-
type: "Query",
|
|
146
|
-
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: "parsed",
|
|
150
|
-
type: "Query",
|
|
151
|
-
schema: zod_1.z.boolean().optional(),
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: "ignore_invalid_price_ids",
|
|
155
|
-
type: "Query",
|
|
156
|
-
schema: zod_1.z.boolean().optional(),
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
response: PriceUpdate,
|
|
160
|
-
errors: [
|
|
161
|
-
{
|
|
162
|
-
status: 404,
|
|
163
|
-
description: `Price ids not found`,
|
|
164
|
-
schema: zod_1.z.void(),
|
|
165
|
-
},
|
|
166
|
-
],
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
method: "get",
|
|
170
|
-
path: "/v2/updates/price/latest",
|
|
171
|
-
alias: "latest_price_updates",
|
|
172
|
-
description: `Get the latest price updates by price feed id.
|
|
173
|
-
|
|
174
|
-
Given a collection of price feed ids, retrieve the latest Pyth price for each price feed.`,
|
|
175
|
-
requestFormat: "json",
|
|
176
|
-
parameters: [
|
|
177
|
-
{
|
|
178
|
-
name: "ids[]",
|
|
179
|
-
type: "Query",
|
|
180
|
-
schema: zod_1.z.array(PriceIdInput),
|
|
181
|
-
},
|
|
182
|
-
{
|
|
183
|
-
name: "encoding",
|
|
184
|
-
type: "Query",
|
|
185
|
-
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
186
|
-
},
|
|
187
|
-
{
|
|
188
|
-
name: "parsed",
|
|
189
|
-
type: "Query",
|
|
190
|
-
schema: zod_1.z.boolean().optional(),
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: "ignore_invalid_price_ids",
|
|
194
|
-
type: "Query",
|
|
195
|
-
schema: zod_1.z.boolean().optional(),
|
|
196
|
-
},
|
|
197
|
-
],
|
|
198
|
-
response: PriceUpdate,
|
|
199
|
-
errors: [
|
|
200
|
-
{
|
|
201
|
-
status: 404,
|
|
202
|
-
description: `Price ids not found`,
|
|
203
|
-
schema: zod_1.z.void(),
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
{
|
|
208
|
-
method: "get",
|
|
209
|
-
path: "/v2/updates/price/stream",
|
|
210
|
-
alias: "price_stream_sse_handler",
|
|
211
|
-
description: `SSE route handler for streaming price updates.`,
|
|
212
|
-
requestFormat: "json",
|
|
213
|
-
parameters: [
|
|
214
|
-
{
|
|
215
|
-
name: "ids[]",
|
|
216
|
-
type: "Query",
|
|
217
|
-
schema: zod_1.z.array(PriceIdInput),
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
name: "encoding",
|
|
221
|
-
type: "Query",
|
|
222
|
-
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
name: "parsed",
|
|
226
|
-
type: "Query",
|
|
227
|
-
schema: zod_1.z.boolean().optional(),
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: "allow_unordered",
|
|
231
|
-
type: "Query",
|
|
232
|
-
schema: zod_1.z.boolean().optional(),
|
|
233
|
-
},
|
|
234
|
-
{
|
|
235
|
-
name: "benchmarks_only",
|
|
236
|
-
type: "Query",
|
|
237
|
-
schema: zod_1.z.boolean().optional(),
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: "ignore_invalid_price_ids",
|
|
241
|
-
type: "Query",
|
|
242
|
-
schema: zod_1.z.boolean().optional(),
|
|
243
|
-
},
|
|
244
|
-
],
|
|
245
|
-
response: PriceUpdate,
|
|
246
|
-
errors: [
|
|
247
|
-
{
|
|
248
|
-
status: 404,
|
|
249
|
-
description: `Price ids not found`,
|
|
250
|
-
schema: zod_1.z.void(),
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
},
|
|
254
|
-
{
|
|
255
|
-
method: "get",
|
|
256
|
-
path: "/v2/updates/publisher_stake_caps/latest",
|
|
257
|
-
alias: "latest_publisher_stake_caps",
|
|
258
|
-
description: `Get the most recent publisher stake caps update data.`,
|
|
259
|
-
requestFormat: "json",
|
|
260
|
-
parameters: [
|
|
261
|
-
{
|
|
262
|
-
name: "encoding",
|
|
263
|
-
type: "Query",
|
|
264
|
-
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
265
|
-
},
|
|
266
|
-
{
|
|
267
|
-
name: "parsed",
|
|
268
|
-
type: "Query",
|
|
269
|
-
schema: zod_1.z.boolean().optional(),
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
response: LatestPublisherStakeCapsUpdateDataResponse,
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
method: "get",
|
|
276
|
-
path: "/v2/updates/twap/:window_seconds/latest",
|
|
277
|
-
alias: "latest_twaps",
|
|
278
|
-
description: `Get the latest TWAP by price feed id with a custom time window.
|
|
279
|
-
|
|
280
|
-
Given a collection of price feed ids, retrieve the latest Pyth TWAP price for each price feed.`,
|
|
281
|
-
requestFormat: "json",
|
|
282
|
-
parameters: [
|
|
283
|
-
{
|
|
284
|
-
name: "window_seconds",
|
|
285
|
-
type: "Path",
|
|
286
|
-
schema: zod_1.z.number().int().gte(0),
|
|
287
|
-
},
|
|
288
|
-
{
|
|
289
|
-
name: "ids[]",
|
|
290
|
-
type: "Query",
|
|
291
|
-
schema: zod_1.z.array(PriceIdInput),
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
name: "encoding",
|
|
295
|
-
type: "Query",
|
|
296
|
-
schema: zod_1.z.enum(["hex", "base64"]).optional(),
|
|
297
|
-
},
|
|
298
|
-
{
|
|
299
|
-
name: "parsed",
|
|
300
|
-
type: "Query",
|
|
301
|
-
schema: zod_1.z.boolean().optional(),
|
|
302
|
-
},
|
|
303
|
-
{
|
|
304
|
-
name: "ignore_invalid_price_ids",
|
|
305
|
-
type: "Query",
|
|
306
|
-
schema: zod_1.z.boolean().optional(),
|
|
307
|
-
},
|
|
308
|
-
],
|
|
309
|
-
response: TwapsResponse,
|
|
310
|
-
errors: [
|
|
311
|
-
{
|
|
312
|
-
status: 404,
|
|
313
|
-
description: `Price ids not found`,
|
|
314
|
-
schema: zod_1.z.void(),
|
|
315
|
-
},
|
|
316
|
-
],
|
|
317
|
-
},
|
|
318
|
-
]);
|
|
319
|
-
exports.api = new core_1.Zodios(endpoints);
|
|
320
|
-
function createApiClient(baseUrl, options) {
|
|
321
|
-
return new core_1.Zodios(baseUrl, endpoints, options);
|
|
322
|
-
}
|