@typus/typus-sdk 1.9.1 → 1.9.2

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.
@@ -51,15 +51,6 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
55
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
56
- if (ar || !(i in from)) {
57
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
58
- ar[i] = from[i];
59
- }
60
- }
61
- return to.concat(ar || Array.prototype.slice.call(from));
62
- };
63
54
  Object.defineProperty(exports, "__esModule", { value: true });
64
55
  exports.getVaults = getVaults;
65
56
  exports.getAuctions = getAuctions;
@@ -67,7 +58,6 @@ exports.getAuctionBids = getAuctionBids;
67
58
  exports.getDepositShares = getDepositShares;
68
59
  exports.getMyBids = getMyBids;
69
60
  exports.getRefundShares = getRefundShares;
70
- exports.getUserOwnedObjects = getUserOwnedObjects;
71
61
  var transactions_1 = require("@mysten/sui/transactions");
72
62
  var bcs_1 = require("@mysten/bcs");
73
63
  var utils_1 = require("../../src/utils");
@@ -513,7 +503,7 @@ function getMyBids(config, input) {
513
503
  // early return if no results
514
504
  return [2 /*return*/, {}];
515
505
  }
516
- bytes = results[results.length - 1].returnValues[0].bcs;
506
+ bytes = results[results.length - 1].returnValues[0][0];
517
507
  reader = new bcs_1.BcsReader(new Uint8Array(bytes));
518
508
  result = Array.from(new Map()).reduce(function (map, _a) {
519
509
  var _b = __read(_a, 2), key = _b[0], value = _b[1];
@@ -571,8 +561,6 @@ function getRefundShares(config, input) {
571
561
  });
572
562
  return [4 /*yield*/, provider.simulateTransaction({
573
563
  transaction: transaction,
574
- checksEnabled: false,
575
- include: { commandResults: true },
576
564
  })];
577
565
  case 1:
578
566
  results = (_a.sent()).commandResults;
@@ -595,35 +583,3 @@ function getRefundShares(config, input) {
595
583
  });
596
584
  });
597
585
  }
598
- function getUserOwnedObjects(config, user) {
599
- return __awaiter(this, void 0, void 0, function () {
600
- var provider, result, hasNextPage, data, cursor;
601
- return __generator(this, function (_a) {
602
- switch (_a.label) {
603
- case 0:
604
- provider = config.gRpcClient();
605
- return [4 /*yield*/, provider.listOwnedObjects({ owner: user, include: { content: true } })];
606
- case 1:
607
- result = _a.sent();
608
- hasNextPage = result.hasNextPage;
609
- data = result.objects;
610
- cursor = result.cursor;
611
- _a.label = 2;
612
- case 2:
613
- if (!hasNextPage) return [3 /*break*/, 4];
614
- return [4 /*yield*/, provider.listOwnedObjects({
615
- owner: user,
616
- cursor: cursor,
617
- include: { content: true },
618
- })];
619
- case 3:
620
- result = _a.sent();
621
- data = __spreadArray(__spreadArray([], __read(data), false), __read(result.objects), false);
622
- hasNextPage = result.hasNextPage;
623
- cursor = result.cursor;
624
- return [3 /*break*/, 2];
625
- case 4: return [2 /*return*/, data];
626
- }
627
- });
628
- });
629
- }
@@ -57,11 +57,7 @@ function getAirdrop(config, input) {
57
57
  target: "".concat(config.package.launch.airdrop, "::airdrop::get_airdrop_bcs"),
58
58
  arguments: [transaction.object(config.registry.launch.airdrop), transaction.pure.address(input.user)],
59
59
  });
60
- return [4 /*yield*/, provider.simulateTransaction({
61
- transaction: transaction,
62
- checksEnabled: false,
63
- include: { commandResults: true },
64
- })];
60
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
65
61
  case 1:
66
62
  devInspectTransactionBlockResult = _a.sent();
67
63
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -118,11 +118,11 @@ function getFund(config, input) {
118
118
  results = (_a.sent())
119
119
  .commandResults;
120
120
  funds = {};
121
- // console.log(results);
122
121
  results === null || results === void 0 ? void 0 : results.forEach(function (result, i) {
123
122
  // @ts-ignore
124
123
  var bytes = result.returnValues[0].bcs;
125
124
  var reader = new bcs_1.BcsReader(new Uint8Array(bytes));
125
+ reader.readULEB();
126
126
  var fund = reader.readVec(function (reader) {
127
127
  return {
128
128
  balance: reader.read64(),
@@ -133,11 +133,7 @@ function getEndedTips(config) {
133
133
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tips_bcs"),
134
134
  arguments: [transaction.object(config.registry.launch.improvementProposal)],
135
135
  });
136
- return [4 /*yield*/, provider.simulateTransaction({
137
- transaction: transaction,
138
- checksEnabled: false,
139
- include: { commandResults: true },
140
- })];
136
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
141
137
  case 1:
142
138
  devInspectTransactionBlockResult = _a.sent();
143
139
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -202,11 +198,7 @@ function getOngoingTipVotes(config, input) {
202
198
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ongoing_tip_votes_bcs"),
203
199
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
204
200
  });
205
- return [4 /*yield*/, provider.simulateTransaction({
206
- transaction: transaction,
207
- checksEnabled: false,
208
- include: { commandResults: true },
209
- })];
201
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
210
202
  case 1:
211
203
  devInspectTransactionBlockResult = _a.sent();
212
204
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -243,11 +235,7 @@ function getEndedTipVotes(config, input) {
243
235
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tip_votes_bcs"),
244
236
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
245
237
  });
246
- return [4 /*yield*/, provider.simulateTransaction({
247
- transaction: transaction,
248
- checksEnabled: false,
249
- include: { commandResults: true },
250
- })];
238
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
251
239
  case 1:
252
240
  devInspectTransactionBlockResult = _a.sent();
253
241
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -284,11 +272,7 @@ function getTipVotes(config, input) {
284
272
  target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_tip_votes_bcs"),
285
273
  arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.u64(input.index)],
286
274
  });
287
- return [4 /*yield*/, provider.simulateTransaction({
288
- transaction: transaction,
289
- checksEnabled: false,
290
- include: { commandResults: true },
291
- })];
275
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
292
276
  case 1:
293
277
  devInspectTransactionBlockResult = _a.sent();
294
278
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -54,11 +54,7 @@ function getVeTypus(config, input) {
54
54
  target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus_bcs"),
55
55
  arguments: [transaction.object(config.registry.launch.veTypus), transaction.pure.address(input.user)],
56
56
  });
57
- return [4 /*yield*/, provider.simulateTransaction({
58
- transaction: transaction,
59
- checksEnabled: false,
60
- include: { commandResults: true },
61
- })];
57
+ return [4 /*yield*/, provider.simulateTransaction({ transaction: transaction })];
62
58
  case 1:
63
59
  devInspectTransactionBlockResult = _a.sent();
64
60
  bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
@@ -51,6 +51,17 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
+ var __values = (this && this.__values) || function(o) {
55
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
+ if (m) return m.call(o);
57
+ if (o && typeof o.length === "number") return {
58
+ next: function () {
59
+ if (o && i >= o.length) o = void 0;
60
+ return { value: o && o[i++], done: !o };
61
+ }
62
+ };
63
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
+ };
54
65
  Object.defineProperty(exports, "__esModule", { value: true });
55
66
  exports.getPairPrices = getPairPrices;
56
67
  exports.getLatestPrice = getLatestPrice;
@@ -197,13 +208,54 @@ function getPythLatestPriceBySymbols(symbols) {
197
208
  }
198
209
  function getLatestPriceUSD() {
199
210
  return __awaiter(this, void 0, void 0, function () {
200
- var prices;
201
- return __generator(this, function (_a) {
202
- switch (_a.label) {
211
+ var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, result, e_2_1;
212
+ var e_2, _c;
213
+ return __generator(this, function (_d) {
214
+ switch (_d.label) {
203
215
  case 0: return [4 /*yield*/, getPythLatestPrice()];
204
216
  case 1:
205
- prices = (_a.sent());
206
- return [2 /*return*/, prices];
217
+ prices = (_d.sent());
218
+ _d.label = 2;
219
+ case 2:
220
+ _d.trys.push([2, 7, 8, 9]);
221
+ _a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI", "SCASUI", "USDYUSDC"]), _b = _a.next();
222
+ _d.label = 3;
223
+ case 3:
224
+ if (!!_b.done) return [3 /*break*/, 6];
225
+ pair = _b.value;
226
+ currentTimestampInSeconds = Math.floor(new Date().getTime() / 1000);
227
+ minuteAgo = currentTimestampInSeconds - 300;
228
+ return [4 /*yield*/, getPairPrices(pair, minuteAgo.toString(), currentTimestampInSeconds.toString())];
229
+ case 4:
230
+ res = _d.sent();
231
+ price = res.at(-1).price;
232
+ result = void 0;
233
+ if (pair.startsWith("SUI")) {
234
+ result = prices.get("SUI") / Number(price);
235
+ }
236
+ else if (pair.endsWith("SUI")) {
237
+ result = prices.get("SUI") * Number(price);
238
+ }
239
+ else {
240
+ result = Number(price);
241
+ }
242
+ prices.set(pair.replace("SUI", ""), result);
243
+ _d.label = 5;
244
+ case 5:
245
+ _b = _a.next();
246
+ return [3 /*break*/, 3];
247
+ case 6: return [3 /*break*/, 9];
248
+ case 7:
249
+ e_2_1 = _d.sent();
250
+ e_2 = { error: e_2_1 };
251
+ return [3 /*break*/, 9];
252
+ case 8:
253
+ try {
254
+ if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
255
+ }
256
+ finally { if (e_2) throw e_2.error; }
257
+ return [7 /*endfinally*/];
258
+ case 9: return [2 /*return*/, prices];
207
259
  }
208
260
  });
209
261
  });
@@ -59,7 +59,7 @@ exports.getExerciseFromSentio = getExerciseFromSentio;
59
59
  var typus_dov_single_v2_1 = require("../../../../src/typus-dov-single-v2");
60
60
  var constants_1 = require("../../../../src/constants");
61
61
  var headers = {
62
- "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
62
+ "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
63
63
  "Content-Type": "application/json",
64
64
  };
65
65
  function getFromSentio(event, userAddress, startTimestamp) {
@@ -71,7 +71,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
71
71
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
72
72
  requestData = {
73
73
  sqlQuery: {
74
- sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinctId = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
74
+ sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
75
75
  size: 1000,
76
76
  },
77
77
  };
@@ -86,7 +86,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
86
86
  return [4 /*yield*/, response.json()];
87
87
  case 2:
88
88
  data = _a.sent();
89
- console.log(data);
89
+ // console.log(data);
90
90
  return [2 /*return*/, data.result.rows];
91
91
  }
92
92
  });
@@ -101,7 +101,7 @@ function getFromSentioWithExpUp(event, userAddress, startTimestamp) {
101
101
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
102
102
  requestData = {
103
103
  sqlQuery: {
104
- sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinctId, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash AND N.log_index + 1 = S.log_index\n WHERE N.distinctId = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
104
+ sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash AND N.log_index + 1 = S.log_index\n WHERE N.distinct_id = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
105
105
  size: 1000,
106
106
  },
107
107
  };
@@ -50,7 +50,7 @@ function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
50
50
  });
51
51
  }
52
52
  var headers = {
53
- "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
53
+ "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
54
54
  "Content-Type": "application/json",
55
55
  };
56
56
  function getExpLeaderBoard(startTimestamp, endTimestamp) {
@@ -55,7 +55,7 @@ exports.getAccumulatedUser = getAccumulatedUser;
55
55
  exports.getAccumulatedNotionalVolumeUSD = getAccumulatedNotionalVolumeUSD;
56
56
  exports.getSafuAccumulatedRewardGeneratedUSD = getSafuAccumulatedRewardGeneratedUSD;
57
57
  var headers = {
58
- "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
58
+ "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
59
59
  "Content-Type": "application/json",
60
60
  };
61
61
  function getTotalDepositorIncentive() {
@@ -96,7 +96,7 @@ function getTotalPremium() {
96
96
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
97
97
  requestData = {
98
98
  timeRange: {
99
- start: "now-1h",
99
+ start: "now",
100
100
  end: "now",
101
101
  step: 3600,
102
102
  timezone: "Europe/Paris",
@@ -148,7 +148,7 @@ function getAccumulatedRewardGeneratedUSD() {
148
148
  apiUrlV1 = "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query";
149
149
  requestDataV1 = {
150
150
  timeRange: {
151
- start: "now-1h",
151
+ start: "now",
152
152
  end: "now",
153
153
  step: 3600,
154
154
  timezone: "Asia/Taipei",
@@ -188,7 +188,7 @@ function getAccumulatedRewardGeneratedUSD() {
188
188
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
189
189
  requestData = {
190
190
  timeRange: {
191
- start: "now-1h",
191
+ start: "now",
192
192
  end: "now",
193
193
  step: 3600,
194
194
  timezone: "Asia/Taipei",
@@ -283,10 +283,12 @@ function getAccumulatedUser() {
283
283
  apiUrl = apiUrls_1_1.value;
284
284
  requestData = {
285
285
  timeRange: {
286
- start: "now-3d",
286
+ start: "now-1h",
287
287
  end: "now",
288
- step: 86400,
288
+ step: 3600,
289
+ timezone: "Asia/Taipei",
289
290
  },
291
+ limit: 1,
290
292
  queries: [
291
293
  {
292
294
  eventsQuery: {
@@ -305,7 +307,7 @@ function getAccumulatedUser() {
305
307
  },
306
308
  },
307
309
  groupBy: [],
308
- limit: 0,
310
+ limit: 1,
309
311
  functions: [],
310
312
  disabled: false,
311
313
  },
@@ -326,8 +328,8 @@ function getAccumulatedUser() {
326
328
  return [4 /*yield*/, response.json()];
327
329
  case 4:
328
330
  data = _b.sent();
329
- // console.dir(data.results[0].matrix, { depth: null });
330
- result.push(data.results[0].matrix.samples[0].values.at(-1).value);
331
+ // console.log(data.results[0].matrix.samples[0].values[0].value);
332
+ result.push(data.results[0].matrix.samples[0].values[0].value);
331
333
  _b.label = 5;
332
334
  case 5:
333
335
  apiUrls_1_1 = apiUrls_1.next();
@@ -373,9 +375,10 @@ function getAccumulatedNotionalVolumeUSD() {
373
375
  apiUrl = apiUrls_2_1.value;
374
376
  requestData = {
375
377
  timeRange: {
376
- start: "now-1h",
378
+ start: "now",
377
379
  end: "now",
378
380
  step: 3600,
381
+ timezone: "Asia/Taipei",
379
382
  },
380
383
  limit: 1,
381
384
  queries: [
@@ -443,7 +446,7 @@ function getSafuAccumulatedRewardGeneratedUSD() {
443
446
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
444
447
  requestData = {
445
448
  timeRange: {
446
- start: "now-1h",
449
+ start: "now",
447
450
  end: "now",
448
451
  step: 3600,
449
452
  timezone: "Asia/Taipei",
@@ -486,8 +489,5 @@ function getSafuAccumulatedRewardGeneratedUSD() {
486
489
  });
487
490
  });
488
491
  }
489
- // getTotalDepositorIncentive().then((res) => console.log(res));
490
- // getTotalPremium().then((res) => console.log(res));
491
- // getAccumulatedNotionalVolumeUSD().then((res) => console.log(res));
492
- // getAccumulatedUser().then((res) => console.log(res));
493
- // getAccumulatedRewardGeneratedUSD().then((res) => console.log(res));
492
+ // getAccumulatedNotionalVolumeUSD();
493
+ // getAccumulatedUser();
@@ -40,7 +40,7 @@ exports.getVaultHistorySummary = getVaultHistorySummary;
40
40
  exports.getFilledSummary = getFilledSummary;
41
41
  exports.getVaultHistory = getVaultHistory;
42
42
  var headers = {
43
- "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
43
+ "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
44
44
  "Content-Type": "application/json",
45
45
  };
46
46
  function getVaultHistorySummary(startTimestamp) {
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.9.1",
5
+ "version": "1.9.2",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "2.0.3",
8
8
  "@mysten/kiosk": "1.2.0",
@@ -50,6 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/Typus-Lab/typus-sdk/issues"
52
52
  },
53
- "homepage": "https://github.com/Typus-Lab/typus-sdk#readme",
54
- "packageManager": "yarn@4.10.3+sha512.c38cafb5c7bb273f3926d04e55e1d8c9dfa7d9c3ea1f36a4868fa028b9e5f72298f0b7f401ad5eb921749eb012eb1c3bb74bf7503df3ee43fd600d14a018266f"
55
- }
53
+ "homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
54
+ }
@@ -1,36 +0,0 @@
1
- import { KioskClient, KioskListing } from "@mysten/kiosk";
2
- import { SuiGraphQLClient } from "@mysten/sui/graphql";
3
- export interface TailsId {
4
- nftId: string;
5
- kiosk: string;
6
- kioskCap: string;
7
- tails: Tails | undefined;
8
- isPersonal: boolean;
9
- listing?: KioskListing;
10
- }
11
- export interface kioskOwnerCap {
12
- kioskId: string;
13
- objectId: string;
14
- isPersonal: boolean;
15
- }
16
- export declare function getTailsIds(kioskClient: KioskClient, NFT_PACKAGE_ORIGIN: string, kioskOwnerCaps: kioskOwnerCap[]): Promise<TailsId[]>;
17
- export interface TailsWithType extends Tails {
18
- type: string | null | undefined;
19
- }
20
- export declare function getTails(provider: SuiGraphQLClient, tailsIds: string[]): Promise<TailsWithType[]>;
21
- export interface Tails {
22
- id: string;
23
- name: string;
24
- number: string;
25
- url: string;
26
- level: string;
27
- exp: string;
28
- first_bid: string;
29
- first_deposit: string;
30
- first_deposit_nft: string;
31
- attributes: Map<string, string>;
32
- u64_padding: Map<string, string>;
33
- }
34
- export declare function getLevelExp(level: number): number | undefined;
35
- export declare const LevelExpVec: number[];
36
- export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];