@typus/typus-perp-sdk 1.0.63 → 1.0.65
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.js +28 -14
- package/dist/src/index.js +1 -1
- package/package.json +1 -1
package/dist/src/fetch.js
CHANGED
|
@@ -379,9 +379,6 @@ function getUserStake(config, user) {
|
|
|
379
379
|
reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
380
380
|
lpShares_1 = [];
|
|
381
381
|
reader.readVec(function (reader) {
|
|
382
|
-
var length = reader.readULEB();
|
|
383
|
-
// let bytes = reader.readBytes(length);
|
|
384
|
-
// let lpShare = LpUserShare.fromBcs(Uint8Array.from(Array.from(bytes)));
|
|
385
382
|
var lpShare = structs_4.LpUserShare.fromFields(structs_4.LpUserShare.bcs.read(reader));
|
|
386
383
|
var incentives = [];
|
|
387
384
|
reader.readVec(function (reader) {
|
|
@@ -538,7 +535,7 @@ function getPositionCount(config, input) {
|
|
|
538
535
|
}
|
|
539
536
|
function getAllPositions(config, input) {
|
|
540
537
|
return __awaiter(this, void 0, void 0, function () {
|
|
541
|
-
var provider, tx, res, raw, withoutMaxPage, reader, userPositionsLen, positions, i,
|
|
538
|
+
var provider, tx, res, raw, withoutMaxPage, buffer, view, reader, userPositionsLen, positions, i, bytes, pos;
|
|
542
539
|
var _a, _b, _c, _d;
|
|
543
540
|
return __generator(this, function (_e) {
|
|
544
541
|
switch (_e.label) {
|
|
@@ -558,25 +555,42 @@ function getAllPositions(config, input) {
|
|
|
558
555
|
})];
|
|
559
556
|
case 1:
|
|
560
557
|
res = _e.sent();
|
|
561
|
-
console.log(res);
|
|
562
558
|
if (!((_d = (_c = (_b = (_a = res.results) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.returnValues) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[0])) {
|
|
563
559
|
return [2 /*return*/, []];
|
|
564
560
|
}
|
|
565
561
|
raw = new Uint8Array(res.results[0].returnValues[0][0]);
|
|
562
|
+
console.debug("Raw data length:", raw.length);
|
|
566
563
|
// 1) 至少要有 8 bytes 的 max_page
|
|
567
564
|
if (raw.length < 8)
|
|
568
565
|
return [2 /*return*/, []];
|
|
569
566
|
withoutMaxPage = raw.slice(0, raw.length - 8);
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
567
|
+
console.log("Data without max page length:", withoutMaxPage.length);
|
|
568
|
+
buffer = new ArrayBuffer(withoutMaxPage.length);
|
|
569
|
+
view = new Uint8Array(buffer);
|
|
570
|
+
view.set(withoutMaxPage);
|
|
571
|
+
reader = new bcs_1.BcsReader(view);
|
|
572
|
+
try {
|
|
573
|
+
userPositionsLen = reader.read8() - 1;
|
|
574
|
+
console.debug("User positions length:", userPositionsLen);
|
|
575
|
+
positions = [];
|
|
576
|
+
for (i = 0; i < userPositionsLen; i++) {
|
|
577
|
+
try {
|
|
578
|
+
bytes = reader.readBytes(reader.readULEB());
|
|
579
|
+
pos = structs_3.Position.fromBcs(Uint8Array.from(Array.from(bytes)));
|
|
580
|
+
positions.push(pos);
|
|
581
|
+
}
|
|
582
|
+
catch (e) {
|
|
583
|
+
console.error("Error parsing position ".concat(i, ":"), e);
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
return [2 /*return*/, positions];
|
|
578
588
|
}
|
|
579
|
-
|
|
589
|
+
catch (e) {
|
|
590
|
+
console.error("Error parsing positions:", e);
|
|
591
|
+
return [2 /*return*/, []];
|
|
592
|
+
}
|
|
593
|
+
return [2 /*return*/];
|
|
580
594
|
}
|
|
581
595
|
});
|
|
582
596
|
});
|
package/dist/src/index.js
CHANGED
|
@@ -30,7 +30,7 @@ exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
|
|
|
30
30
|
? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
|
|
31
31
|
: "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
|
|
32
32
|
exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET"
|
|
33
|
-
? "
|
|
33
|
+
? "0xb7e4416296bb3629547b5a0ab24dec17851760eca393c58fb62edbab71c76fa2"
|
|
34
34
|
: "0x15844f80fb085bb8fd7cc688ade6282cd6991209eae78934ca001dced8b1b7de";
|
|
35
35
|
exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
|
|
36
36
|
? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
|