@typus/typus-perp-sdk 1.0.11 → 1.0.13

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.
@@ -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
@@ -334,9 +334,15 @@ function getUserStake(config, user) {
334
334
  lpShares_1 = [];
335
335
  reader.readVec(function (reader) {
336
336
  var length = reader.readULEB();
337
- var bytes = reader.readBytes(length);
338
- var lpShare = structs_4.LpUserShare.fromBcs(Uint8Array.from(Array.from(bytes)));
339
- lpShares_1.push(lpShare);
337
+ // let bytes = reader.readBytes(length);
338
+ // let lpShare = LpUserShare.fromBcs(Uint8Array.from(Array.from(bytes)));
339
+ var lpShare = structs_4.LpUserShare.fromFields(structs_4.LpUserShare.bcs.read(reader));
340
+ var incentives = [];
341
+ reader.readVec(function (reader) {
342
+ var incentive = reader.read64();
343
+ incentives.push(incentive);
344
+ });
345
+ lpShares_1.push([lpShare, incentives]);
340
346
  });
341
347
  // let lpShares: LpUserShare[] = readVecShares(Uint8Array.from(returnValues));
342
348
  // 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" ? "" : "0x16075533726388ef93a1d036fe192a9a367ce6f80e3cb4d462019a8b5c8bbe0e";
6
+ exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0xeb3331e74efa1e2e51d665fe1369c4f721eaabbb3974ffd75503a84ab4409c42";
7
7
  exports.PKG_V1 = index_1.NETWORK == "MAINNET" ? "" : "0x7c19f81d9d411e78305d7af8dad25317c56bb449fede8a78b6021232478f0509";
@@ -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" ? "" : "0x6db1e799c84de3665b86c7db8db3478b76fef05b194bbe53b479207d85776895";
6
- exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0x6db1e799c84de3665b86c7db8db3478b76fef05b194bbe53b479207d85776895";
6
+ exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0x1b3d24935e153596e86fc28ce2877885495635f9ed871e5eca4e0e9454a36263";
7
7
  exports.PKG_V1 = index_1.NETWORK == "MAINNET" ? "" : "0x6db1e799c84de3665b86c7db8db3478b76fef05b194bbe53b479207d85776895";
@@ -6,12 +6,15 @@ export declare function mintStakeLp(config: TypusConfig, tx: Transaction, pythCl
6
6
  lpPool: LiquidityPool;
7
7
  coins: string[];
8
8
  cTOKEN: TOKEN;
9
+ iTOKEN: TOKEN;
9
10
  amount: string;
10
11
  userShareId: string | null;
12
+ user: string;
11
13
  }): Promise<Transaction>;
12
14
  export declare function unstakeBurn(config: TypusConfig, tx: Transaction, pythClient: PythClient, input: {
13
15
  lpPool: LiquidityPool;
14
16
  cTOKEN: TOKEN;
17
+ iTOKEN: TOKEN;
15
18
  userShareId: string;
16
19
  share: string | null;
17
20
  user: string;
@@ -27,6 +30,8 @@ export declare function unsubscribe(config: TypusConfig, tx: Transaction, input:
27
30
  userShareId: string;
28
31
  share: string | null;
29
32
  }): Promise<Transaction>;
30
- export declare function harvest(config: TypusConfig, tx: Transaction, input: {
33
+ export declare function harvestStakeReward(config: TypusConfig, tx: Transaction, input: {
31
34
  userShareId: string;
35
+ user: string;
36
+ iTOKEN: TOKEN;
32
37
  }): Promise<Transaction>;
@@ -67,7 +67,7 @@ exports.mintStakeLp = mintStakeLp;
67
67
  exports.unstakeBurn = unstakeBurn;
68
68
  exports.swap = swap;
69
69
  exports.unsubscribe = unsubscribe;
70
- exports.harvest = harvest;
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");
@@ -75,7 +75,7 @@ var constants_1 = require("@typus/typus-sdk/dist/src/constants");
75
75
  var __1 = require("..");
76
76
  function mintStakeLp(config, tx, pythClient, input) {
77
77
  return __awaiter(this, void 0, void 0, function () {
78
- var tokens, cToken, tokens_1, tokens_1_1, token, coin, destination, lpCoin;
78
+ var tokens, cToken, tokens_1, tokens_1_1, token, coin, destination, iToken, iCoin, lpCoin;
79
79
  var e_1, _a, _b, _c;
80
80
  return __generator(this, function (_d) {
81
81
  switch (_d.label) {
@@ -117,6 +117,18 @@ function mintStakeLp(config, tx, pythClient, input) {
117
117
  }
118
118
  _c = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _c[0];
119
119
  }
120
+ iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
121
+ // console.log(iToken);
122
+ if (input.userShareId) {
123
+ iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
124
+ version: __1.STAKE_POOL_VERSION,
125
+ registry: __1.STAKE_POOL,
126
+ index: BigInt(0),
127
+ userShareId: BigInt(input.userShareId),
128
+ clock: constants_1.CLOCK,
129
+ });
130
+ tx.transferObjects([iCoin], input.user);
131
+ }
120
132
  lpCoin = (0, functions_1.mintLp)(tx, [cToken, __1.TLP_TOKEN], {
121
133
  version: __1.PERP_VERSION,
122
134
  registry: __1.LP_POOL,
@@ -142,7 +154,7 @@ function mintStakeLp(config, tx, pythClient, input) {
142
154
  }
143
155
  function unstakeBurn(config, tx, pythClient, input) {
144
156
  return __awaiter(this, void 0, void 0, function () {
145
- var tokens, cToken, oracle, tokens_2, tokens_2_1, token, lpCoin, coin;
157
+ var tokens, cToken, oracle, tokens_2, tokens_2_1, token, iToken, iCoin, lpCoin, coin;
146
158
  var e_2, _a;
147
159
  return __generator(this, function (_b) {
148
160
  switch (_b.label) {
@@ -173,6 +185,18 @@ function unstakeBurn(config, tx, pythClient, input) {
173
185
  }
174
186
  finally { if (e_2) throw e_2.error; }
175
187
  }
188
+ iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
189
+ // console.log(iToken);
190
+ if (input.userShareId) {
191
+ iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
192
+ version: __1.STAKE_POOL_VERSION,
193
+ registry: __1.STAKE_POOL,
194
+ index: BigInt(0),
195
+ userShareId: BigInt(input.userShareId),
196
+ clock: constants_1.CLOCK,
197
+ });
198
+ tx.transferObjects([iCoin], input.user);
199
+ }
176
200
  lpCoin = (0, functions_2.unstake)(tx, __1.TLP_TOKEN, {
177
201
  version: __1.STAKE_POOL_VERSION,
178
202
  registry: __1.STAKE_POOL,
@@ -250,16 +274,19 @@ function unsubscribe(config, tx, input) {
250
274
  });
251
275
  });
252
276
  }
253
- function harvest(config, tx, input) {
277
+ function harvestStakeReward(config, tx, input) {
254
278
  return __awaiter(this, void 0, void 0, function () {
279
+ var iToken, iCoin;
255
280
  return __generator(this, function (_a) {
256
- (0, functions_2.harvestPerUserShare)(tx, "0x2::sui::SUI", {
281
+ iToken = constants_1.tokenType[__1.NETWORK][input.iTOKEN];
282
+ iCoin = (0, functions_2.harvestPerUserShare)(tx, iToken, {
257
283
  version: __1.STAKE_POOL_VERSION,
258
284
  registry: __1.STAKE_POOL,
259
285
  index: BigInt(0),
260
286
  userShareId: BigInt(input.userShareId),
261
287
  clock: constants_1.CLOCK,
262
288
  });
289
+ tx.transferObjects([iCoin], input.user);
263
290
  return [2 /*return*/, tx];
264
291
  });
265
292
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",