@typus/typus-perp-sdk 1.0.70 → 1.0.71
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.
- package/dist/src/fetch.d.ts +6 -2
- package/dist/src/fetch.js +37 -10
- package/package.json +1 -1
package/dist/src/fetch.d.ts
CHANGED
|
@@ -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 [
|
|
24
|
+
* @returns [lpShare, incentives][]
|
|
25
25
|
*/
|
|
26
|
-
export declare function getUserStake(config: TypusConfig, user: string): Promise<[
|
|
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 [
|
|
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
|
|
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
|
-
|
|
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*/,
|
|
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
|
}
|