@typus/typus-perp-sdk 1.0.70 → 1.0.72

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.
@@ -291,7 +291,7 @@ function getAccumulatedUser() {
291
291
  requestData = {
292
292
  timeRange: {
293
293
  start: "now-1h",
294
- end: now(),
294
+ end: "now",
295
295
  step: 3600,
296
296
  timezone: "Asia/Taipei",
297
297
  },
@@ -400,7 +400,7 @@ function getTlpPriceFromSentio(fromTimestamp, toTimestamp) {
400
400
  });
401
401
  }
402
402
  // getVolumeFromSentio();
403
- // getAccumulatedUser();
403
+ // getAccumulatedUser().then((x) => console.log(x));
404
404
  // getTradingVolumeFromSentio(1747008000, 1, 1747011600);
405
405
  // getTlpPriceFromSentio(now() - 3600 * 24 * 30).then((x) => console.dir(x, { depth: null }));
406
406
  // getTotalVolumeFromSentio(now() - 3600 * 24 * 30).then((x) => console.log(x));
@@ -21,9 +21,13 @@ export declare function getUserOrders(config: TypusConfig, user: string): Promis
21
21
  export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
22
22
  export declare function parseOptionBidReceipts(positions: Position[]): (TypusBidReceipt | null)[];
23
23
  /**
24
- * @returns [[lpShare, incentives][], deactivatingShares[]]
24
+ * @returns [lpShare, incentives][]
25
25
  */
26
- export declare function getUserStake(config: TypusConfig, user: string): Promise<[[LpUserShare, string[]][], DeactivatingShares<typeof TLP_TOKEN>[]]>;
26
+ export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]][]>;
27
+ /**
28
+ * @returns deactivatingShares[]
29
+ */
30
+ export declare function getDeactivatingShares(config: TypusConfig, user: string): Promise<DeactivatingShares<typeof TLP_TOKEN>[]>;
27
31
  /**
28
32
  * @returns [liquidationPrice, pnl(in USD)]
29
33
  */
package/dist/src/fetch.js CHANGED
@@ -56,6 +56,7 @@ exports.getUserOrders = getUserOrders;
56
56
  exports.getUserPositions = getUserPositions;
57
57
  exports.parseOptionBidReceipts = parseOptionBidReceipts;
58
58
  exports.getUserStake = getUserStake;
59
+ exports.getDeactivatingShares = getDeactivatingShares;
59
60
  exports.getLiquidationPriceAndPnl = getLiquidationPriceAndPnl;
60
61
  exports.getPositionCount = getPositionCount;
61
62
  exports.getAllPositions = getAllPositions;
@@ -350,11 +351,11 @@ function parseOptionBidReceipts(positions) {
350
351
  });
351
352
  }
352
353
  /**
353
- * @returns [[lpShare, incentives][], deactivatingShares[]]
354
+ * @returns [lpShare, incentives][]
354
355
  */
355
356
  function getUserStake(config, user) {
356
357
  return __awaiter(this, void 0, void 0, function () {
357
- var provider, tx, res, returnValues, reader, lpShares_1, returnValues, reader, deactivatingShares_1;
358
+ var provider, tx, res, returnValues, reader, lpShares_1;
358
359
  return __generator(this, function (_a) {
359
360
  switch (_a.label) {
360
361
  case 0:
@@ -371,11 +372,6 @@ function getUserStake(config, user) {
371
372
  index: BigInt(0),
372
373
  user: user,
373
374
  });
374
- (0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
375
- registry: _1.LP_POOL,
376
- index: BigInt(0),
377
- user: user,
378
- });
379
375
  return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
380
376
  case 1:
381
377
  res = _a.sent();
@@ -394,7 +390,38 @@ function getUserStake(config, user) {
394
390
  });
395
391
  lpShares_1.push([lpShare, incentives]);
396
392
  });
397
- returnValues = res.results[2].returnValues[0][0];
393
+ return [2 /*return*/, lpShares_1];
394
+ }
395
+ else {
396
+ return [2 /*return*/, []];
397
+ }
398
+ return [2 /*return*/];
399
+ }
400
+ });
401
+ });
402
+ }
403
+ /**
404
+ * @returns deactivatingShares[]
405
+ */
406
+ function getDeactivatingShares(config, user) {
407
+ return __awaiter(this, void 0, void 0, function () {
408
+ var provider, tx, res, returnValues, reader, deactivatingShares_1;
409
+ return __generator(this, function (_a) {
410
+ switch (_a.label) {
411
+ case 0:
412
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
413
+ tx = new transactions_1.Transaction();
414
+ (0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
415
+ registry: _1.LP_POOL,
416
+ index: BigInt(0),
417
+ user: user,
418
+ });
419
+ return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
420
+ case 1:
421
+ res = _a.sent();
422
+ // console.log(res);
423
+ if (res.results) {
424
+ returnValues = res.results[0].returnValues[0][0];
398
425
  reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
399
426
  deactivatingShares_1 = [];
400
427
  reader.readVec(function (reader) {
@@ -404,10 +431,10 @@ function getUserStake(config, user) {
404
431
  deactivatingShares_1.push(lpShare);
405
432
  });
406
433
  // console.log(deactivatingShares);
407
- return [2 /*return*/, [lpShares_1, deactivatingShares_1]];
434
+ return [2 /*return*/, deactivatingShares_1];
408
435
  }
409
436
  else {
410
- return [2 /*return*/, [[], []]];
437
+ return [2 /*return*/, []];
411
438
  }
412
439
  return [2 /*return*/];
413
440
  }
package/dist/src/index.js CHANGED
@@ -36,7 +36,7 @@ transactions_1.Transaction.registerGlobalSerializationPlugin("namedPackagesPlugi
36
36
  exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
37
37
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
38
38
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
39
- exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET" ? "0xaf238f806cef5e86018f9b7243f46b960af84d32a90edb551cb81437b00c1927" : "@typus/perp";
39
+ exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET" ? "0xceddbccc7c674aba60f97104bbe218c59c84f6099d5692a35ec390c5c2dd1131" : "@typus/perp";
40
40
  exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
41
41
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
42
42
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
@@ -44,7 +44,7 @@ exports.STAKE_PACKAGE_ID = exports.NETWORK == "MAINNET"
44
44
  ? "0xc427209145715a00a93d7e674a95c556a7147d79fda1bbaeb1a1cac5f9923966"
45
45
  : "0x220e7ba8923c0c30b57c0baab3bc15d781a39bb294cf7af318c0fc816b5cf7e6";
46
46
  exports.STAKE_PUBLISHED_AT = exports.NETWORK == "MAINNET"
47
- ? "0xf980a07d67e379e8d2fa4cfcb24a765df0fc2c09b70be12ff681dcfd6b2b56ac"
47
+ ? "0x7677c52794bdf0f8c6c6e7c38d584e675a04575f5f551e880c36d317fdc5653f"
48
48
  : "0xf8fa4a303118328de2fb53f49a043fa5bf58b84f372db0d1e7cf7b1f1a47d10e";
49
49
  exports.STAKE_PKG_V1 = exports.NETWORK == "MAINNET"
50
50
  ? "0xc427209145715a00a93d7e674a95c556a7147d79fda1bbaeb1a1cac5f9923966"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.70",
3
+ "version": "1.0.72",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",