@typus/typus-perp-sdk 1.0.12 → 1.0.14
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 +1 -1
- package/dist/src/fetch.js +16 -4
- package/dist/src/typus_perp/index.js +1 -1
- package/dist/src/user/tlp.d.ts +3 -1
- package/dist/src/user/tlp.js +8 -5
- package/package.json +1 -1
package/dist/src/fetch.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare function getMarkets(config: TypusConfig, input: {
|
|
|
16
16
|
export declare function getUserOrders(config: TypusConfig, user: string): Promise<TradingOrder[]>;
|
|
17
17
|
export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
|
|
18
18
|
export declare function parseOptionBidReceipts(positions: Position[]): (TypusBidReceipt | null)[];
|
|
19
|
-
export declare function getUserStake(config: TypusConfig, user: string): Promise<LpUserShare[]>;
|
|
19
|
+
export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]][]>;
|
|
20
20
|
export declare function getLiquidationPriceAndPnl(config: TypusConfig, pythClient: PythClient, input: {
|
|
21
21
|
positions: Position[];
|
|
22
22
|
user: string;
|
package/dist/src/fetch.js
CHANGED
|
@@ -319,6 +319,12 @@ function getUserStake(config, user) {
|
|
|
319
319
|
case 0:
|
|
320
320
|
provider = new client_1.SuiClient({ url: config.rpcEndpoint });
|
|
321
321
|
tx = new transactions_1.Transaction();
|
|
322
|
+
(0, functions_2.allocateIncentive)(tx, {
|
|
323
|
+
version: _1.STAKE_POOL_VERSION,
|
|
324
|
+
registry: _1.STAKE_POOL,
|
|
325
|
+
index: BigInt(0),
|
|
326
|
+
clock: constants_1.CLOCK,
|
|
327
|
+
});
|
|
322
328
|
(0, functions_2.getUserShares)(tx, {
|
|
323
329
|
registry: _1.STAKE_POOL,
|
|
324
330
|
index: BigInt(0),
|
|
@@ -329,14 +335,20 @@ function getUserStake(config, user) {
|
|
|
329
335
|
res = _a.sent();
|
|
330
336
|
// console.log(res);
|
|
331
337
|
if (res.results) {
|
|
332
|
-
returnValues = res.results[
|
|
338
|
+
returnValues = res.results[1].returnValues[0][0];
|
|
333
339
|
reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
|
|
334
340
|
lpShares_1 = [];
|
|
335
341
|
reader.readVec(function (reader) {
|
|
336
342
|
var length = reader.readULEB();
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
343
|
+
// let bytes = reader.readBytes(length);
|
|
344
|
+
// let lpShare = LpUserShare.fromBcs(Uint8Array.from(Array.from(bytes)));
|
|
345
|
+
var lpShare = structs_4.LpUserShare.fromFields(structs_4.LpUserShare.bcs.read(reader));
|
|
346
|
+
var incentives = [];
|
|
347
|
+
reader.readVec(function (reader) {
|
|
348
|
+
var incentive = reader.read64();
|
|
349
|
+
incentives.push(incentive);
|
|
350
|
+
});
|
|
351
|
+
lpShares_1.push([lpShare, incentives]);
|
|
340
352
|
});
|
|
341
353
|
// let lpShares: LpUserShare[] = readVecShares(Uint8Array.from(returnValues));
|
|
342
354
|
// console.log(lpShares);
|
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PKG_V1 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
|
|
4
4
|
var index_1 = require("../index");
|
|
5
5
|
exports.PACKAGE_ID = index_1.NETWORK == "MAINNET" ? "" : "0x7c19f81d9d411e78305d7af8dad25317c56bb449fede8a78b6021232478f0509";
|
|
6
|
-
exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "
|
|
6
|
+
exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0xeb3331e74efa1e2e51d665fe1369c4f721eaabbb3974ffd75503a84ab4409c42";
|
|
7
7
|
exports.PKG_V1 = index_1.NETWORK == "MAINNET" ? "" : "0x7c19f81d9d411e78305d7af8dad25317c56bb449fede8a78b6021232478f0509";
|
package/dist/src/user/tlp.d.ts
CHANGED
|
@@ -30,6 +30,8 @@ export declare function unsubscribe(config: TypusConfig, tx: Transaction, input:
|
|
|
30
30
|
userShareId: string;
|
|
31
31
|
share: string | null;
|
|
32
32
|
}): Promise<Transaction>;
|
|
33
|
-
export declare function
|
|
33
|
+
export declare function harvestStakeReward(config: TypusConfig, tx: Transaction, input: {
|
|
34
34
|
userShareId: string;
|
|
35
|
+
user: string;
|
|
36
|
+
iTOKEN: TOKEN;
|
|
35
37
|
}): Promise<Transaction>;
|
package/dist/src/user/tlp.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.mintStakeLp = mintStakeLp;
|
|
|
67
67
|
exports.unstakeBurn = unstakeBurn;
|
|
68
68
|
exports.swap = swap;
|
|
69
69
|
exports.unsubscribe = unsubscribe;
|
|
70
|
-
exports.
|
|
70
|
+
exports.harvestStakeReward = harvestStakeReward;
|
|
71
71
|
var functions_1 = require("../typus_perp/lp-pool/functions");
|
|
72
72
|
var functions_2 = require("../typus_stake_pool/stake-pool/functions");
|
|
73
73
|
var utils_1 = require("@typus/typus-sdk/dist/src/utils");
|
|
@@ -118,7 +118,7 @@ function mintStakeLp(config, tx, pythClient, input) {
|
|
|
118
118
|
_c = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _c[0];
|
|
119
119
|
}
|
|
120
120
|
iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
|
|
121
|
-
console.log(iToken);
|
|
121
|
+
// console.log(iToken);
|
|
122
122
|
if (input.userShareId) {
|
|
123
123
|
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
124
124
|
version: __1.STAKE_POOL_VERSION,
|
|
@@ -186,7 +186,7 @@ function unstakeBurn(config, tx, pythClient, input) {
|
|
|
186
186
|
finally { if (e_2) throw e_2.error; }
|
|
187
187
|
}
|
|
188
188
|
iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
|
|
189
|
-
console.log(iToken);
|
|
189
|
+
// console.log(iToken);
|
|
190
190
|
if (input.userShareId) {
|
|
191
191
|
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
192
192
|
version: __1.STAKE_POOL_VERSION,
|
|
@@ -274,16 +274,19 @@ function unsubscribe(config, tx, input) {
|
|
|
274
274
|
});
|
|
275
275
|
});
|
|
276
276
|
}
|
|
277
|
-
function
|
|
277
|
+
function harvestStakeReward(config, tx, input) {
|
|
278
278
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
+
var iToken, iCoin;
|
|
279
280
|
return __generator(this, function (_a) {
|
|
280
|
-
|
|
281
|
+
iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
|
|
282
|
+
iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
|
|
281
283
|
version: __1.STAKE_POOL_VERSION,
|
|
282
284
|
registry: __1.STAKE_POOL,
|
|
283
285
|
index: BigInt(0),
|
|
284
286
|
userShareId: BigInt(input.userShareId),
|
|
285
287
|
clock: constants_1.CLOCK,
|
|
286
288
|
});
|
|
289
|
+
tx.transferObjects([iCoin], input.user);
|
|
287
290
|
return [2 /*return*/, tx];
|
|
288
291
|
});
|
|
289
292
|
});
|