@typus/typus-sdk 1.2.74 → 1.2.75

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.
@@ -1,6 +1,7 @@
1
1
  export declare function getTotalDepositorIncentive(): Promise<TokenAmount>;
2
2
  export declare function getTotalPremium(): Promise<number>;
3
- export declare function getAccumulatedRewardGeneratedUSD(): Promise<number>;
3
+ /** Returns Accumulated Rewards im USD [v1, v2] */
4
+ export declare function getAccumulatedRewardGeneratedUSD(): Promise<[number, number]>;
4
5
  export declare function getTotalProfitSharingClaimed(): Promise<TokenAmount[]>;
5
6
  import { SuiClient } from "@mysten/sui.js/client";
6
7
  export declare function getTotalProfitSharing(provider: SuiClient): Promise<TokenAmount[]>;
@@ -8,4 +9,8 @@ interface TokenAmount {
8
9
  token: string;
9
10
  total_amount: string;
10
11
  }
12
+ /** Returns Accumulated Users [v1, v2] */
13
+ export declare function getAccumulatedUser(): Promise<number[]>;
14
+ /** Returns Accumulated Notional Volume in USD [v1, v2] */
15
+ export declare function getAccumulatedNotionalVolumeUSD(): Promise<number[]>;
11
16
  export {};
@@ -47,7 +47,7 @@ var __values = (this && this.__values) || function(o) {
47
47
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
48
48
  };
49
49
  Object.defineProperty(exports, "__esModule", { value: true });
50
- exports.getTotalProfitSharing = exports.getTotalProfitSharingClaimed = exports.getAccumulatedRewardGeneratedUSD = exports.getTotalPremium = exports.getTotalDepositorIncentive = void 0;
50
+ exports.getAccumulatedNotionalVolumeUSD = exports.getAccumulatedUser = exports.getTotalProfitSharing = exports.getTotalProfitSharingClaimed = exports.getAccumulatedRewardGeneratedUSD = exports.getTotalPremium = exports.getTotalDepositorIncentive = void 0;
51
51
  var headers = {
52
52
  "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
53
53
  "Content-Type": "application/json",
@@ -146,12 +146,73 @@ function getTotalPremium() {
146
146
  });
147
147
  }
148
148
  exports.getTotalPremium = getTotalPremium;
149
+ /** Returns Accumulated Rewards im USD [v1, v2] */
149
150
  function getAccumulatedRewardGeneratedUSD() {
150
151
  return __awaiter(this, void 0, void 0, function () {
151
- var apiUrl, requestData, jsonData, response, data;
152
+ var apiUrlV1, requestDataV1, jsonDataV1, responseV1, dataV1, apiUrl, requestData, jsonData, response, data;
152
153
  return __generator(this, function (_a) {
153
154
  switch (_a.label) {
154
155
  case 0:
156
+ apiUrlV1 = "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query";
157
+ requestDataV1 = {
158
+ timeRange: {
159
+ start: "now",
160
+ end: "now",
161
+ step: 3600,
162
+ timezone: "Asia/Taipei",
163
+ },
164
+ limit: 1,
165
+ queries: [
166
+ {
167
+ metricsQuery: {
168
+ query: "premiumUSD",
169
+ alias: "",
170
+ id: "a",
171
+ labelSelector: {},
172
+ aggregate: {
173
+ op: "SUM",
174
+ grouping: [],
175
+ },
176
+ functions: [
177
+ {
178
+ name: "sum_over_time",
179
+ arguments: [
180
+ {
181
+ durationValue: {
182
+ value: 100,
183
+ unit: "w",
184
+ },
185
+ },
186
+ ],
187
+ },
188
+ ],
189
+ disabled: true,
190
+ },
191
+ dataSource: "METRICS",
192
+ sourceName: "",
193
+ },
194
+ ],
195
+ formulas: [
196
+ {
197
+ expression: "a/2",
198
+ alias: "",
199
+ id: "A",
200
+ disabled: false,
201
+ functions: [],
202
+ },
203
+ ],
204
+ };
205
+ jsonDataV1 = JSON.stringify(requestDataV1);
206
+ return [4 /*yield*/, fetch(apiUrlV1, {
207
+ method: "POST",
208
+ headers: headers,
209
+ body: jsonDataV1,
210
+ })];
211
+ case 1:
212
+ responseV1 = _a.sent();
213
+ return [4 /*yield*/, responseV1.json()];
214
+ case 2:
215
+ dataV1 = _a.sent();
155
216
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
156
217
  requestData = {
157
218
  timeRange: {
@@ -187,13 +248,13 @@ function getAccumulatedRewardGeneratedUSD() {
187
248
  headers: headers,
188
249
  body: jsonData,
189
250
  })];
190
- case 1:
251
+ case 3:
191
252
  response = _a.sent();
192
253
  return [4 /*yield*/, response.json()];
193
- case 2:
254
+ case 4:
194
255
  data = _a.sent();
195
256
  // console.log(data);
196
- return [2 /*return*/, data.results[0].matrix.samples[0].values[0].value];
257
+ return [2 /*return*/, [dataV1.results[0].matrix.samples[0].values[0].value, data.results[0].matrix.samples[0].values[0].value]];
197
258
  }
198
259
  });
199
260
  });
@@ -301,6 +362,180 @@ function getTotalProfitSharing(provider) {
301
362
  });
302
363
  }
303
364
  exports.getTotalProfitSharing = getTotalProfitSharing;
365
+ /** Returns Accumulated Users [v1, v2] */
366
+ function getAccumulatedUser() {
367
+ return __awaiter(this, void 0, void 0, function () {
368
+ var apiUrls, result, apiUrls_1, apiUrls_1_1, apiUrl, requestData, jsonData, response, data, e_3_1;
369
+ var e_3, _a;
370
+ return __generator(this, function (_b) {
371
+ switch (_b.label) {
372
+ case 0:
373
+ apiUrls = [
374
+ "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query",
375
+ "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query",
376
+ ];
377
+ result = [];
378
+ _b.label = 1;
379
+ case 1:
380
+ _b.trys.push([1, 7, 8, 9]);
381
+ apiUrls_1 = __values(apiUrls), apiUrls_1_1 = apiUrls_1.next();
382
+ _b.label = 2;
383
+ case 2:
384
+ if (!!apiUrls_1_1.done) return [3 /*break*/, 6];
385
+ apiUrl = apiUrls_1_1.value;
386
+ requestData = {
387
+ timeRange: {
388
+ start: "now-1h",
389
+ end: "now",
390
+ step: 3600,
391
+ timezone: "Asia/Taipei",
392
+ },
393
+ limit: 1,
394
+ queries: [
395
+ {
396
+ eventsQuery: {
397
+ resource: {
398
+ name: "",
399
+ type: "EVENTS",
400
+ },
401
+ alias: "",
402
+ id: "a",
403
+ aggregation: {
404
+ countUnique: {
405
+ duration: {
406
+ value: 0,
407
+ unit: "day",
408
+ },
409
+ },
410
+ },
411
+ groupBy: [],
412
+ limit: 1,
413
+ functions: [],
414
+ disabled: false,
415
+ },
416
+ dataSource: "EVENTS",
417
+ sourceName: "",
418
+ },
419
+ ],
420
+ formulas: [],
421
+ };
422
+ jsonData = JSON.stringify(requestData);
423
+ return [4 /*yield*/, fetch(apiUrl, {
424
+ method: "POST",
425
+ headers: headers,
426
+ body: jsonData,
427
+ })];
428
+ case 3:
429
+ response = _b.sent();
430
+ return [4 /*yield*/, response.json()];
431
+ case 4:
432
+ data = _b.sent();
433
+ // console.log(data.results[0].matrix.samples[0].values[0].value);
434
+ result.push(data.results[0].matrix.samples[0].values[0].value);
435
+ _b.label = 5;
436
+ case 5:
437
+ apiUrls_1_1 = apiUrls_1.next();
438
+ return [3 /*break*/, 2];
439
+ case 6: return [3 /*break*/, 9];
440
+ case 7:
441
+ e_3_1 = _b.sent();
442
+ e_3 = { error: e_3_1 };
443
+ return [3 /*break*/, 9];
444
+ case 8:
445
+ try {
446
+ if (apiUrls_1_1 && !apiUrls_1_1.done && (_a = apiUrls_1.return)) _a.call(apiUrls_1);
447
+ }
448
+ finally { if (e_3) throw e_3.error; }
449
+ return [7 /*endfinally*/];
450
+ case 9: return [2 /*return*/, result];
451
+ }
452
+ });
453
+ });
454
+ }
455
+ exports.getAccumulatedUser = getAccumulatedUser;
456
+ /** Returns Accumulated Notional Volume in USD [v1, v2] */
457
+ function getAccumulatedNotionalVolumeUSD() {
458
+ return __awaiter(this, void 0, void 0, function () {
459
+ var apiUrls, result, apiUrls_2, apiUrls_2_1, apiUrl, requestData, jsonData, response, data, e_4_1;
460
+ var e_4, _a;
461
+ return __generator(this, function (_b) {
462
+ switch (_b.label) {
463
+ case 0:
464
+ apiUrls = [
465
+ "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query",
466
+ "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query",
467
+ ];
468
+ result = [];
469
+ _b.label = 1;
470
+ case 1:
471
+ _b.trys.push([1, 7, 8, 9]);
472
+ apiUrls_2 = __values(apiUrls), apiUrls_2_1 = apiUrls_2.next();
473
+ _b.label = 2;
474
+ case 2:
475
+ if (!!apiUrls_2_1.done) return [3 /*break*/, 6];
476
+ apiUrl = apiUrls_2_1.value;
477
+ requestData = {
478
+ timeRange: {
479
+ start: "now",
480
+ end: "now",
481
+ step: 3600,
482
+ timezone: "Asia/Taipei",
483
+ },
484
+ limit: 1,
485
+ queries: [
486
+ {
487
+ metricsQuery: {
488
+ query: "AccumulatedNotionalVolumeUSD",
489
+ alias: "",
490
+ id: "a",
491
+ labelSelector: {},
492
+ aggregate: {
493
+ op: "SUM",
494
+ grouping: [],
495
+ },
496
+ functions: [],
497
+ disabled: false,
498
+ },
499
+ dataSource: "METRICS",
500
+ sourceName: "",
501
+ },
502
+ ],
503
+ formulas: [],
504
+ };
505
+ jsonData = JSON.stringify(requestData);
506
+ return [4 /*yield*/, fetch(apiUrl, {
507
+ method: "POST",
508
+ headers: headers,
509
+ body: jsonData,
510
+ })];
511
+ case 3:
512
+ response = _b.sent();
513
+ return [4 /*yield*/, response.json()];
514
+ case 4:
515
+ data = _b.sent();
516
+ console.log(data.results[0]);
517
+ result.push(data.results[0].matrix.samples[0].values[0].value);
518
+ _b.label = 5;
519
+ case 5:
520
+ apiUrls_2_1 = apiUrls_2.next();
521
+ return [3 /*break*/, 2];
522
+ case 6: return [3 /*break*/, 9];
523
+ case 7:
524
+ e_4_1 = _b.sent();
525
+ e_4 = { error: e_4_1 };
526
+ return [3 /*break*/, 9];
527
+ case 8:
528
+ try {
529
+ if (apiUrls_2_1 && !apiUrls_2_1.done && (_a = apiUrls_2.return)) _a.call(apiUrls_2);
530
+ }
531
+ finally { if (e_4) throw e_4.error; }
532
+ return [7 /*endfinally*/];
533
+ case 9: return [2 /*return*/, result];
534
+ }
535
+ });
536
+ });
537
+ }
538
+ exports.getAccumulatedNotionalVolumeUSD = getAccumulatedNotionalVolumeUSD;
304
539
  var token_1 = require("../../token");
305
540
  (function () { return __awaiter(void 0, void 0, void 0, function () {
306
541
  return __generator(this, function (_a) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.2.74",
5
+ "version": "1.2.75",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.7.12",