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