@typus/typus-perp-sdk 1.0.61-ut-upgrade-c → 1.0.61-ut-upgrade-d

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.
@@ -1,9 +1,10 @@
1
1
  import { Markets, SymbolMarket } from "./typus_perp/trading/structs";
2
- import { LiquidityPool } from "./typus_perp/lp-pool/structs";
2
+ import { DeactivatingShares, LiquidityPool } from "./typus_perp/lp-pool/structs";
3
3
  import { TradingOrder, Position } from "./typus_perp/position/structs";
4
4
  import { LpUserShare, StakePool } from "./typus_stake_pool/stake-pool/structs";
5
5
  import { TOKEN } from "@typus/typus-sdk/dist/src/constants";
6
6
  import { PythClient, TypusConfig } from "@typus/typus-sdk/dist/src/utils";
7
+ import { TLP_TOKEN } from ".";
7
8
  import { TypusBidReceipt } from "./_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs";
8
9
  export declare function getLpPools(config: TypusConfig): Promise<LiquidityPool[]>;
9
10
  export declare function getLpPool(config: TypusConfig, objectId?: string): Promise<LiquidityPool>;
@@ -20,9 +21,9 @@ export declare function getUserOrders(config: TypusConfig, user: string): Promis
20
21
  export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
21
22
  export declare function parseOptionBidReceipts(positions: Position[]): (TypusBidReceipt | null)[];
22
23
  /**
23
- * @returns [lpShare, incentives]
24
+ * @returns [[lpShare, incentives][], deactivatingShares[]]
24
25
  */
25
- export declare function getUserStake(config: TypusConfig, user: string): Promise<[LpUserShare, string[]][]>;
26
+ export declare function getUserStake(config: TypusConfig, user: string): Promise<[[LpUserShare, string[]][], DeactivatingShares<typeof TLP_TOKEN>[]]>;
26
27
  /**
27
28
  * @returns [liquidationPrice, pnl(in USD)]
28
29
  */
package/dist/src/fetch.js CHANGED
@@ -74,6 +74,7 @@ var utils_1 = require("@typus/typus-sdk/dist/src/utils");
74
74
  var _1 = require(".");
75
75
  var structs_5 = require("./_dependencies/source/0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274/vault/structs");
76
76
  var typus_perp_1 = require("./typus_perp");
77
+ var functions_3 = require("./typus_perp/lp-pool/functions");
77
78
  function getLpPools(config) {
78
79
  return __awaiter(this, void 0, void 0, function () {
79
80
  var provider, dynamicFields, lpPools, _a, _b, field, lpPool, e_1_1;
@@ -349,11 +350,11 @@ function parseOptionBidReceipts(positions) {
349
350
  });
350
351
  }
351
352
  /**
352
- * @returns [lpShare, incentives]
353
+ * @returns [[lpShare, incentives][], deactivatingShares[]]
353
354
  */
354
355
  function getUserStake(config, user) {
355
356
  return __awaiter(this, void 0, void 0, function () {
356
- var provider, tx, res, returnValues, reader, lpShares_1;
357
+ var provider, tx, res, returnValues, reader, lpShares_1, returnValues, reader, deactivatingShares_1;
357
358
  return __generator(this, function (_a) {
358
359
  switch (_a.label) {
359
360
  case 0:
@@ -370,6 +371,11 @@ function getUserStake(config, user) {
370
371
  index: BigInt(0),
371
372
  user: user,
372
373
  });
374
+ (0, functions_3.getUserDeactivatingShares)(tx, _1.TLP_TOKEN, {
375
+ registry: _1.LP_POOL,
376
+ index: BigInt(0),
377
+ user: user,
378
+ });
373
379
  return [4 /*yield*/, provider.devInspectTransactionBlock({ sender: user, transactionBlock: tx })];
374
380
  case 1:
375
381
  res = _a.sent();
@@ -390,14 +396,20 @@ function getUserStake(config, user) {
390
396
  });
391
397
  lpShares_1.push([lpShare, incentives]);
392
398
  });
393
- // let lpShares: LpUserShare[] = readVecShares(Uint8Array.from(returnValues));
394
- // console.log(lpShares);
395
- // console.log(lpShares[0].deactivatingShares);
396
- // console.log(lpShares[0].lastIncentivePriceIndex);
397
- return [2 /*return*/, lpShares_1];
399
+ returnValues = res.results[2].returnValues[0][0];
400
+ reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
401
+ deactivatingShares_1 = [];
402
+ reader.readVec(function (reader) {
403
+ var length = reader.readULEB();
404
+ var lpShare = structs_2.DeactivatingShares.bcs.read(reader);
405
+ // @ts-ignore
406
+ deactivatingShares_1.push(lpShare);
407
+ });
408
+ // console.log(deactivatingShares);
409
+ return [2 /*return*/, [lpShares_1, deactivatingShares_1]];
398
410
  }
399
411
  else {
400
- return [2 /*return*/, []];
412
+ return [2 /*return*/, [[], []]];
401
413
  }
402
414
  return [2 /*return*/];
403
415
  }
package/dist/src/index.js CHANGED
@@ -30,8 +30,8 @@ exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
30
30
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
31
31
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
32
32
  exports.PERP_PUBLISHED_AT = exports.NETWORK == "MAINNET"
33
- ? "0xeb018055af198e99a368ccda030e9aef07ffb86aa5de83e98734913064b0cff4"
34
- : "0x102c88cd633046520d1a5bc77f7e90bcf466e5a74660cead86710d60696eb997";
33
+ ? "0xb7e4416296bb3629547b5a0ab24dec17851760eca393c58fb62edbab71c76fa2"
34
+ : "0x910c7a8acc7e91be7a1e3952ce4ee2d443d8ef30236b08fbebcb6cf1ce9f3737";
35
35
  exports.PERP_PKG_V1 = exports.NETWORK == "MAINNET"
36
36
  ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
37
37
  : "0x585924f160f83ef16f8927ec117e4d740abb6f4e571ecfa89ff3e973042cb1b9";
@@ -58,6 +58,7 @@ exports.LIQUIDITY_POOL_0 = exports.NETWORK == "MAINNET"
58
58
  exports.MARKET = exports.NETWORK == "MAINNET"
59
59
  ? "0xc969d946a2b6b917a83b5fb71765793c4a52149e50d2c8cf5c01d7421fc7cd73"
60
60
  : "0xed48f046dc88c49eb01d59669e29eb3006173b66445facb88de277bec2913687";
61
+ // MARKET_0 = 0x442cc2c27cadaf287a5f4413967b4dacc6532bc9063875efbc7b178e5add3e4e
61
62
  exports.PERP_VERSION = exports.NETWORK == "MAINNET"
62
63
  ? "0xa12c282a068328833ec4a9109fc77803ec1f523f8da1bb0f82bac8450335f0c9"
63
64
  : "0x80f739d013b365055540346d3b081b19369d6ba83d1ed6291be7a066e0a3c25f";
@@ -190,7 +190,27 @@ export interface GetTokenPoolStateArgs {
190
190
  }
191
191
  export declare function getTokenPoolState(tx: Transaction, args: GetTokenPoolStateArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
192
192
  export declare function getTvlUsd(tx: Transaction, liquidityPool: TransactionObjectInput, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
193
+ export interface GetUserDeactivatingSharesArgs {
194
+ registry: TransactionObjectInput;
195
+ index: bigint | TransactionArgument;
196
+ user: string | TransactionArgument;
197
+ }
198
+ export declare function getUserDeactivatingShares(tx: Transaction, typeArg: string, args: GetUserDeactivatingSharesArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
193
199
  export declare function init(tx: Transaction, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
200
+ export interface ManagerEmergencyDepositArgs {
201
+ version: TransactionObjectInput;
202
+ registry: TransactionObjectInput;
203
+ index: bigint | TransactionArgument;
204
+ coin: TransactionObjectInput;
205
+ }
206
+ export declare function managerEmergencyDeposit(tx: Transaction, typeArgs: [string, string], args: ManagerEmergencyDepositArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
207
+ export interface ManagerEmergencyWithdrawArgs {
208
+ version: TransactionObjectInput;
209
+ registry: TransactionObjectInput;
210
+ index: bigint | TransactionArgument;
211
+ receipt: TransactionObjectInput;
212
+ }
213
+ export declare function managerEmergencyWithdraw(tx: Transaction, typeArgs: [string, string], args: ManagerEmergencyWithdrawArgs, published_at?: string): import("@mysten/sui/transactions").TransactionResult;
194
214
  export interface ManagerFlashRemoveLiquidityArgs {
195
215
  version: TransactionObjectInput;
196
216
  registry: TransactionObjectInput;
@@ -30,7 +30,10 @@ exports.getRemoveLiquidityTokenProcessToken = getRemoveLiquidityTokenProcessToke
30
30
  exports.getTokenPool = getTokenPool;
31
31
  exports.getTokenPoolState = getTokenPoolState;
32
32
  exports.getTvlUsd = getTvlUsd;
33
+ exports.getUserDeactivatingShares = getUserDeactivatingShares;
33
34
  exports.init = init;
35
+ exports.managerEmergencyDeposit = managerEmergencyDeposit;
36
+ exports.managerEmergencyWithdraw = managerEmergencyWithdraw;
34
37
  exports.managerFlashRemoveLiquidity = managerFlashRemoveLiquidity;
35
38
  exports.managerFlashRepayLiquidity = managerFlashRepayLiquidity;
36
39
  exports.managerHotfixBurnLp = managerHotfixBurnLp;
@@ -342,10 +345,34 @@ function getTvlUsd(tx, liquidityPool, published_at) {
342
345
  if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
343
346
  return tx.moveCall({ target: "".concat(published_at, "::lp_pool::get_tvl_usd"), arguments: [(0, util_1.obj)(tx, liquidityPool)] });
344
347
  }
348
+ function getUserDeactivatingShares(tx, typeArg, args, published_at) {
349
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
350
+ return tx.moveCall({
351
+ target: "".concat(published_at, "::lp_pool::get_user_deactivating_shares"),
352
+ typeArguments: [typeArg],
353
+ arguments: [(0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.index, "u64"), (0, util_1.pure)(tx, args.user, "address")],
354
+ });
355
+ }
345
356
  function init(tx, published_at) {
346
357
  if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
347
358
  return tx.moveCall({ target: "".concat(published_at, "::lp_pool::init"), arguments: [] });
348
359
  }
360
+ function managerEmergencyDeposit(tx, typeArgs, args, published_at) {
361
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
362
+ return tx.moveCall({
363
+ target: "".concat(published_at, "::lp_pool::manager_emergency_deposit"),
364
+ typeArguments: typeArgs,
365
+ arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.index, "u64"), (0, util_1.obj)(tx, args.coin)],
366
+ });
367
+ }
368
+ function managerEmergencyWithdraw(tx, typeArgs, args, published_at) {
369
+ if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
370
+ return tx.moveCall({
371
+ target: "".concat(published_at, "::lp_pool::manager_emergency_withdraw"),
372
+ typeArguments: typeArgs,
373
+ arguments: [(0, util_1.obj)(tx, args.version), (0, util_1.obj)(tx, args.registry), (0, util_1.pure)(tx, args.index, "u64"), (0, util_1.obj)(tx, args.receipt)],
374
+ });
375
+ }
349
376
  function managerFlashRemoveLiquidity(tx, typeArg, args, published_at) {
350
377
  if (published_at === void 0) { published_at = __1.PUBLISHED_AT; }
351
378
  return tx.moveCall({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.61-ut-upgrade-c",
3
+ "version": "1.0.61-ut-upgrade-d",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",