@typus/typus-perp-sdk 1.1.21 → 1.1.23
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 +4 -0
- package/dist/src/fetch.js +51 -0
- package/dist/src/index.js +1 -1
- package/package.json +1 -1
package/dist/src/fetch.d.ts
CHANGED
|
@@ -24,6 +24,10 @@ export declare function parseOptionBidReceipts(positions: Position[]): (TypusBid
|
|
|
24
24
|
* @returns [lpShare, incentives]
|
|
25
25
|
*/
|
|
26
26
|
export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]] | null>;
|
|
27
|
+
/**
|
|
28
|
+
* @returns [lpShare, incentives]
|
|
29
|
+
*/
|
|
30
|
+
export declare function getUserStakeById(config: TypusConfig, userShareId: string): Promise<[LpUserShare, string[]] | null>;
|
|
27
31
|
/**
|
|
28
32
|
* @returns deactivatingShares[]
|
|
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.getUserStakeById = getUserStakeById;
|
|
59
60
|
exports.getDeactivatingShares = getDeactivatingShares;
|
|
60
61
|
exports.getLiquidationPriceAndPnl = getLiquidationPriceAndPnl;
|
|
61
62
|
exports.getPositionCount = getPositionCount;
|
|
@@ -400,6 +401,56 @@ function getUserStake(config, user) {
|
|
|
400
401
|
});
|
|
401
402
|
});
|
|
402
403
|
}
|
|
404
|
+
/**
|
|
405
|
+
* @returns [lpShare, incentives]
|
|
406
|
+
*/
|
|
407
|
+
function getUserStakeById(config, userShareId) {
|
|
408
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
409
|
+
var provider, tx, res, returnValues, reader, length_4, lpShare, incentives_2;
|
|
410
|
+
return __generator(this, function (_a) {
|
|
411
|
+
switch (_a.label) {
|
|
412
|
+
case 0:
|
|
413
|
+
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
414
|
+
tx = new transactions_1.Transaction();
|
|
415
|
+
(0, functions_2.allocateIncentive)(tx, {
|
|
416
|
+
version: _1.STAKE_POOL_VERSION,
|
|
417
|
+
registry: _1.STAKE_POOL,
|
|
418
|
+
index: BigInt(0),
|
|
419
|
+
clock: constants_1.CLOCK,
|
|
420
|
+
});
|
|
421
|
+
(0, functions_2.getUserSharesByUserShareId)(tx, {
|
|
422
|
+
registry: _1.STAKE_POOL,
|
|
423
|
+
index: BigInt(0),
|
|
424
|
+
userShareId: BigInt(userShareId),
|
|
425
|
+
});
|
|
426
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: tx })];
|
|
427
|
+
case 1:
|
|
428
|
+
res = _a.sent();
|
|
429
|
+
// console.log(res);
|
|
430
|
+
if (res.results) {
|
|
431
|
+
returnValues = res.results[1].returnValues[0][0];
|
|
432
|
+
reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
433
|
+
length_4 = reader.readULEB();
|
|
434
|
+
// console.log(length);
|
|
435
|
+
if (length_4 == 0) {
|
|
436
|
+
return [2 /*return*/, null];
|
|
437
|
+
}
|
|
438
|
+
lpShare = structs_4.LpUserShare.fromFields(structs_4.LpUserShare.bcs.read(reader));
|
|
439
|
+
incentives_2 = [];
|
|
440
|
+
reader.readVec(function (reader) {
|
|
441
|
+
var incentive = reader.read64();
|
|
442
|
+
incentives_2.push(incentive);
|
|
443
|
+
});
|
|
444
|
+
return [2 /*return*/, [lpShare, incentives_2]];
|
|
445
|
+
}
|
|
446
|
+
else {
|
|
447
|
+
return [2 /*return*/, null];
|
|
448
|
+
}
|
|
449
|
+
return [2 /*return*/];
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
}
|
|
403
454
|
/**
|
|
404
455
|
* @returns deactivatingShares[]
|
|
405
456
|
*/
|
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" ? "
|
|
39
|
+
exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET" ? "0x8076683c7d36dc8dd2cf9bf08fb50d867a89145fe392447fb8a9cdbed0f4f5f1" : "@typus/perp";
|
|
40
40
|
exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
|
|
41
41
|
? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
|
|
42
42
|
: "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
|