@typus/typus-sdk 1.2.63 → 1.2.64

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.
@@ -21,3 +21,6 @@ export declare function getFromSentio(event: string, userAddress: string, startT
21
21
  export declare function getNewBidFromSentio(vaults: {
22
22
  [key: string]: Vault;
23
23
  }, userAddress: string, startTimestamp: number): Promise<any>;
24
+ export declare function getExerciseFromSentio(vaults: {
25
+ [key: string]: Vault;
26
+ }, userAddress: string, startTimestamp: number): Promise<any>;
@@ -55,7 +55,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
55
55
  return (mod && mod.__esModule) ? mod : { "default": mod };
56
56
  };
57
57
  Object.defineProperty(exports, "__esModule", { value: true });
58
- exports.getNewBidFromSentio = exports.getFromSentio = exports.parseTxHistory = exports.getAutoBidEvents = exports.getUserEvents = void 0;
58
+ exports.getExerciseFromSentio = exports.getNewBidFromSentio = exports.getFromSentio = exports.parseTxHistory = exports.getAutoBidEvents = exports.getUserEvents = void 0;
59
59
  var token_1 = require("../token");
60
60
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
61
61
  function getUserEvents(provider, sender, cursor) {
@@ -430,6 +430,61 @@ function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
430
430
  });
431
431
  }
432
432
  exports.getNewBidFromSentio = getNewBidFromSentio;
433
+ function getExerciseFromSentio(vaults, userAddress, startTimestamp) {
434
+ return __awaiter(this, void 0, void 0, function () {
435
+ var apiUrl, headers, requestData, jsonData, response, data;
436
+ return __generator(this, function (_a) {
437
+ switch (_a.label) {
438
+ case 0:
439
+ apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
440
+ headers = {
441
+ "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
442
+ "Content-Type": "application/json",
443
+ };
444
+ requestData = {
445
+ sqlQuery: {
446
+ sql: "\n SELECT *\n FROM Exercise N\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
447
+ size: 1000,
448
+ },
449
+ };
450
+ jsonData = JSON.stringify(requestData);
451
+ return [4 /*yield*/, fetch(apiUrl, {
452
+ method: "POST",
453
+ headers: headers,
454
+ body: jsonData,
455
+ })];
456
+ case 1:
457
+ response = _a.sent();
458
+ return [4 /*yield*/, response.json()];
459
+ case 2:
460
+ data = _a.sent();
461
+ return [2 /*return*/, data.result.rows.map(function (x) {
462
+ var _a = __read(parseVaultInfo(vaults, x.index, "ExerciseEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
463
+ // console.log(x);
464
+ var Action = "Auto Exercise";
465
+ if (x.raw_share) {
466
+ var size = Number(x.raw_share) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
467
+ Action = "Auto Exercise ".concat(size, " ").concat(o_token);
468
+ }
469
+ var txHistory = {
470
+ Index: x.index,
471
+ Period: Period,
472
+ Vault: Vault,
473
+ RiskLevel: RiskLevel,
474
+ Action: Action,
475
+ Amount: "".concat(x.amount, " ").concat(x.coin_symbol),
476
+ Tails: x.number,
477
+ Exp: x.exp_earn,
478
+ Date: new Date(x.timestamp),
479
+ txDigest: x.transaction_hash,
480
+ };
481
+ return txHistory;
482
+ })];
483
+ }
484
+ });
485
+ });
486
+ }
487
+ exports.getExerciseFromSentio = getExerciseFromSentio;
433
488
  function parseVaultInfo(vaults, Index, action) {
434
489
  var v = vaults[Index];
435
490
  var Period;
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.63",
5
+ "version": "1.2.64",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.7.12",