@typus/typus-perp-sdk 1.0.61-upgrade-zero-col-a → 1.0.61-upgrade-zero-col-c

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.
@@ -13,7 +13,18 @@ export interface Volume {
13
13
  timestamp: string;
14
14
  value: number;
15
15
  }
16
- export declare function getTlpFeeFromSentio(): Promise<number>;
17
- export declare function getTotalVolumeFromSentio(fromTimestamp: number, toTimestamp: number): Promise<number>;
16
+ export declare function getTlpFeeFromSentio(fromTimestamp: number, toTimestamp?: number): Promise<number>;
17
+ export declare function getTotalVolumeFromSentio(fromTimestamp: number, toTimestamp?: number): Promise<number>;
18
18
  /** Returns Accumulated Users */
19
19
  export declare function getAccumulatedUser(): Promise<number>;
20
+ /**
21
+ * Inputs:
22
+ * fromTimestamp: number, toTimestamp?: number
23
+ *
24
+ * Returns
25
+ * { timestamp: string, value: number }[]
26
+ */
27
+ export declare function getTlpPriceFromSentio(fromTimestamp: number, toTimestamp?: number): Promise<{
28
+ timestamp: string;
29
+ value: number;
30
+ }[]>;
@@ -41,6 +41,7 @@ exports.getTradingVolumeFromSentio = getTradingVolumeFromSentio;
41
41
  exports.getTlpFeeFromSentio = getTlpFeeFromSentio;
42
42
  exports.getTotalVolumeFromSentio = getTotalVolumeFromSentio;
43
43
  exports.getAccumulatedUser = getAccumulatedUser;
44
+ exports.getTlpPriceFromSentio = getTlpPriceFromSentio;
44
45
  var src_1 = require("../../src");
45
46
  var headers = {
46
47
  "api-key": "ffJa6FwxeJNrQP8NZ5doEMXqdSA7XM6mT",
@@ -99,9 +100,7 @@ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
99
100
  return __generator(this, function (_a) {
100
101
  switch (_a.label) {
101
102
  case 0:
102
- apiUrl = src_1.NETWORK == "MAINNET"
103
- ? "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query"
104
- : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
103
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query";
105
104
  requestData = {
106
105
  timeRange: {
107
106
  start: "".concat(fromTimestamp),
@@ -171,19 +170,17 @@ function getTradingVolumeFromSentio(fromTimestamp, interval, toTimestamp) {
171
170
  });
172
171
  });
173
172
  }
174
- function getTlpFeeFromSentio() {
173
+ function getTlpFeeFromSentio(fromTimestamp, toTimestamp) {
175
174
  return __awaiter(this, void 0, void 0, function () {
176
175
  var apiUrl, requestData, jsonData, response, data, first, last, fee;
177
176
  return __generator(this, function (_a) {
178
177
  switch (_a.label) {
179
178
  case 0:
180
- apiUrl = src_1.NETWORK == "MAINNET"
181
- ? "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query"
182
- : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
179
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query";
183
180
  requestData = {
184
181
  timeRange: {
185
- start: "now-7d",
186
- end: "now",
182
+ start: "".concat(fromTimestamp),
183
+ end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : "now"),
187
184
  step: 3600,
188
185
  },
189
186
  limit: 20,
@@ -233,13 +230,11 @@ function getTotalVolumeFromSentio(fromTimestamp, toTimestamp) {
233
230
  return __generator(this, function (_a) {
234
231
  switch (_a.label) {
235
232
  case 0:
236
- apiUrl = src_1.NETWORK == "MAINNET"
237
- ? "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query"
238
- : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
233
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query";
239
234
  requestData = {
240
235
  timeRange: {
241
236
  start: "".concat(fromTimestamp),
242
- end: "".concat(toTimestamp),
237
+ end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : "now"),
243
238
  step: 3600,
244
239
  },
245
240
  limit: 1,
@@ -289,9 +284,7 @@ function getAccumulatedUser() {
289
284
  return __generator(this, function (_a) {
290
285
  switch (_a.label) {
291
286
  case 0:
292
- apiUrl = src_1.NETWORK == "MAINNET"
293
- ? "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query"
294
- : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
287
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query";
295
288
  requestData = {
296
289
  timeRange: {
297
290
  start: "now-1h",
@@ -346,8 +339,66 @@ function getAccumulatedUser() {
346
339
  });
347
340
  });
348
341
  }
342
+ /**
343
+ * Inputs:
344
+ * fromTimestamp: number, toTimestamp?: number
345
+ *
346
+ * Returns
347
+ * { timestamp: string, value: number }[]
348
+ */
349
+ function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
350
+ return __awaiter(this, void 0, void 0, function () {
351
+ var apiUrl, requestData, jsonData, response, data, samples;
352
+ return __generator(this, function (_a) {
353
+ switch (_a.label) {
354
+ case 0:
355
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query";
356
+ requestData = {
357
+ timeRange: {
358
+ start: "".concat(fromTimestamp),
359
+ end: "".concat(toTimestamp !== null && toTimestamp !== void 0 ? toTimestamp : "now"),
360
+ step: 3600,
361
+ },
362
+ limit: 30 * 24,
363
+ queries: [
364
+ {
365
+ metricsQuery: {
366
+ query: "tlp_price",
367
+ alias: "",
368
+ id: "a",
369
+ labelSelector: {},
370
+ aggregate: null,
371
+ functions: [],
372
+ color: "",
373
+ disabled: false,
374
+ },
375
+ dataSource: "METRICS",
376
+ sourceName: "",
377
+ },
378
+ ],
379
+ formulas: [],
380
+ };
381
+ jsonData = JSON.stringify(requestData);
382
+ return [4 /*yield*/, fetch(apiUrl, {
383
+ method: "POST",
384
+ headers: headers,
385
+ body: jsonData,
386
+ })];
387
+ case 1:
388
+ response = _a.sent();
389
+ return [4 /*yield*/, response.json()];
390
+ case 2:
391
+ data = _a.sent();
392
+ samples = data.results[0].matrix.samples;
393
+ // console.log(samples[0].values);
394
+ return [2 /*return*/, samples];
395
+ }
396
+ });
397
+ });
398
+ }
349
399
  // getVolumeFromSentio();
350
- // getTlpFeeFromSentio();
351
400
  // getAccumulatedUser();
352
401
  // getTradingVolumeFromSentio(1747008000, 1, 1747011600);
353
- // getTotalVolumeFromSentio(1747008000, 1747011600);
402
+ // getTotalVolumeFromSentio(1748995200);
403
+ // getTlpPriceFromSentio(1748995200);
404
+ // getTlpFeeFromSentio(1748995200);
package/dist/src/index.js CHANGED
@@ -26,12 +26,16 @@ dotenv_1.default.config();
26
26
  exports.NETWORK = process.env.NEXT_PUBLIC_CLUSTER == "mainnet" ? "MAINNET" : "TESTNET";
27
27
  console.log("Load .env NEXT_PUBLIC_CLUSTER: ".concat(process.env.NEXT_PUBLIC_CLUSTER));
28
28
  console.log("Initializing Typus Perp SDK for ".concat(exports.NETWORK));
29
+ /** Register the MVR plugin globally */
30
+ var transactions_1 = require("@mysten/sui/transactions");
31
+ var mvrPlugin = exports.NETWORK == "MAINNET" ? "https://mainnet.mvr.mystenlabs.com" : "https://testnet.mvr.mystenlabs.com";
32
+ var plugin = (0, transactions_1.namedPackagesPlugin)({ url: mvrPlugin });
33
+ /** Register the MVR plugin globally (once) for our PTB construction */
34
+ transactions_1.Transaction.registerGlobalSerializationPlugin("namedPackagesPlugin", plugin);
29
35
  exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
30
36
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
31
37
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
32
- exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET"
33
- ? "0xb7e4416296bb3629547b5a0ab24dec17851760eca393c58fb62edbab71c76fa2"
34
- : "0xf2958d5c93ca6ed356346ea322cd359df2d6b066298d3e004fc8a36d93ce99c6";
38
+ exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET" ? "0xb7e4416296bb3629547b5a0ab24dec17851760eca393c58fb62edbab71c76fa2" : "@typus/perp";
35
39
  exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
36
40
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
37
41
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.61-upgrade-zero-col-a",
3
+ "version": "1.0.61-upgrade-zero-col-c",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
7
7
  "license": "MIT",
8
8
  "dependencies": {
9
- "@typus/typus-sdk": "1.7.1"
9
+ "@typus/typus-sdk": "1.7.2"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@types/bs58": "^4.0.1",