@typus/typus-perp-sdk 1.1.53 → 1.2.0

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.
Files changed (76) hide show
  1. package/dist/src/api/sentio.js +2 -2
  2. package/dist/src/client.d.ts +13 -12
  3. package/dist/src/client.js +24 -49
  4. package/dist/src/fetch.d.ts +15 -61
  5. package/dist/src/fetch.js +63 -163
  6. package/dist/src/generated/typus_perp/admin.d.ts +32 -42
  7. package/dist/src/generated/typus_perp/admin.js +41 -67
  8. package/dist/src/generated/typus_perp/competition.d.ts +22 -10
  9. package/dist/src/generated/typus_perp/competition.js +19 -54
  10. package/dist/src/generated/typus_perp/deps/std/type_name.d.ts +2 -2
  11. package/dist/src/generated/typus_perp/deps/std/type_name.js +2 -2
  12. package/dist/src/generated/typus_perp/deps/sui/balance.d.ts +3 -3
  13. package/dist/src/generated/typus_perp/deps/sui/balance.js +3 -3
  14. package/dist/src/generated/typus_perp/deps/sui/object_table.d.ts +4 -6
  15. package/dist/src/generated/typus_perp/deps/sui/object_table.js +4 -38
  16. package/dist/src/generated/typus_perp/deps/sui/table.d.ts +4 -6
  17. package/dist/src/generated/typus_perp/deps/sui/table.js +4 -38
  18. package/dist/src/generated/typus_perp/deps/sui/vec_set.d.ts +2 -2
  19. package/dist/src/generated/typus_perp/deps/sui/vec_set.js +2 -2
  20. package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.d.ts +7 -9
  21. package/dist/src/generated/typus_perp/deps/typus/keyed_big_vector.js +6 -6
  22. package/dist/src/generated/typus_perp/deps/typus/linked_object_table.d.ts +6 -10
  23. package/dist/src/generated/typus_perp/deps/typus/linked_object_table.js +5 -39
  24. package/dist/src/generated/typus_perp/deps/typus_framework/vault.d.ts +14 -8
  25. package/dist/src/generated/typus_perp/deps/typus_framework/vault.js +13 -39
  26. package/dist/src/generated/typus_perp/error.d.ts +97 -87
  27. package/dist/src/generated/typus_perp/error.js +18 -0
  28. package/dist/src/generated/typus_perp/escrow.d.ts +17 -21
  29. package/dist/src/generated/typus_perp/escrow.js +10 -22
  30. package/dist/src/generated/typus_perp/lending.d.ts +47 -0
  31. package/dist/src/generated/typus_perp/lending.js +40 -0
  32. package/dist/src/generated/typus_perp/lp_pool.d.ts +718 -397
  33. package/dist/src/generated/typus_perp/lp_pool.js +485 -365
  34. package/dist/src/generated/typus_perp/math.d.ts +18 -8
  35. package/dist/src/generated/typus_perp/math.js +24 -6
  36. package/dist/src/generated/typus_perp/position.d.ts +207 -185
  37. package/dist/src/generated/typus_perp/position.js +236 -277
  38. package/dist/src/generated/typus_perp/profit_vault.d.ts +64 -72
  39. package/dist/src/generated/typus_perp/profit_vault.js +48 -86
  40. package/dist/src/generated/typus_perp/symbol.d.ts +6 -6
  41. package/dist/src/generated/typus_perp/symbol.js +11 -13
  42. package/dist/src/generated/typus_perp/trading.d.ts +451 -558
  43. package/dist/src/generated/typus_perp/trading.js +429 -681
  44. package/dist/src/generated/typus_perp/treasury_caps.d.ts +5 -7
  45. package/dist/src/generated/typus_perp/treasury_caps.js +8 -45
  46. package/dist/src/generated/typus_stake_pool/admin.d.ts +13 -122
  47. package/dist/src/generated/typus_stake_pool/admin.js +19 -103
  48. package/dist/src/generated/typus_stake_pool/deps/std/type_name.d.ts +2 -2
  49. package/dist/src/generated/typus_stake_pool/deps/std/type_name.js +2 -2
  50. package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.d.ts +2 -2
  51. package/dist/src/generated/typus_stake_pool/deps/sui/vec_set.js +2 -2
  52. package/dist/src/generated/typus_stake_pool/stake_pool.d.ts +249 -240
  53. package/dist/src/generated/typus_stake_pool/stake_pool.js +159 -246
  54. package/dist/src/generated/utils/index.d.ts +21 -2
  55. package/dist/src/generated/utils/index.js +34 -10
  56. package/dist/src/index.js +4 -4
  57. package/dist/src/user/history.js +39 -23
  58. package/dist/src/user/order.d.ts +1 -1
  59. package/dist/src/user/orderWithBidReceipt.d.ts +1 -1
  60. package/package.json +8 -14
  61. package/dist/src/generated/typus_perp/deps/sui/object.d.ts +0 -8
  62. package/dist/src/generated/typus_perp/deps/sui/object.js +0 -16
  63. package/dist/src/generated/typus_perp/user_account.d.ts +0 -146
  64. package/dist/src/generated/typus_perp/user_account.js +0 -221
  65. package/dist/src/generated/typus_stake_pool/deps/sui/object.d.ts +0 -8
  66. package/dist/src/generated/typus_stake_pool/deps/sui/object.js +0 -16
  67. package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.d.ts +0 -30
  68. package/dist/src/generated/typus_stake_pool/deps/sui/vec_map.js +0 -37
  69. package/dist/src/grpc/graphql.d.ts +0 -26
  70. package/dist/src/grpc/graphql.js +0 -126
  71. package/dist/src/grpc/grpc.d.ts +0 -1
  72. package/dist/src/grpc/grpc.js +0 -38
  73. package/dist/src/grpc/ledgerService.d.ts +0 -0
  74. package/dist/src/grpc/ledgerService.js +0 -64
  75. package/dist/src/grpc/liveDataService.d.ts +0 -0
  76. package/dist/src/grpc/liveDataService.js +0 -49
package/dist/src/fetch.js CHANGED
@@ -15,10 +15,7 @@ exports.getAllPositions = getAllPositions;
15
15
  exports.getAllPositionsWithTradingSymbol = getAllPositionsWithTradingSymbol;
16
16
  exports.fetchUserProfits = fetchUserProfits;
17
17
  exports.fetchLockedUserProfits = fetchLockedUserProfits;
18
- exports.fetchAllUserProfits = fetchAllUserProfits;
19
- exports.fetchAllLockedUserProfits = fetchAllLockedUserProfits;
20
18
  const transactions_1 = require("@mysten/sui/transactions");
21
- const client_1 = require("@mysten/sui/client");
22
19
  const bcs_1 = require("@mysten/bcs");
23
20
  const constants_1 = require("@typus/typus-sdk/dist/src/constants");
24
21
  const utils_1 = require("@typus/typus-sdk/dist/src/utils");
@@ -31,6 +28,7 @@ const trading_2 = require("./generated/typus_perp/trading");
31
28
  const lp_pool_2 = require("./generated/typus_perp/lp_pool");
32
29
  const stake_pool_1 = require("./generated/typus_stake_pool/stake_pool");
33
30
  const vault_1 = require("./generated/typus_perp/deps/typus_framework/vault");
31
+ const utils_3 = require("@mysten/sui/utils");
34
32
  async function getLpPools(client) {
35
33
  // let dynamicFields = await client.getDynamicFields({
36
34
  // parentId: LIQUIDITY_POOL,
@@ -97,12 +95,12 @@ async function getMarkets(client, input) {
97
95
  let tx = new transactions_1.Transaction();
98
96
  tx.add((0, trading_1.getMarketsBcs)({ arguments: { registry: _1.MARKET, indexes: input.indexes.map((x) => BigInt(x)) } }));
99
97
  // tx.setSender(SENDER);
100
- // let bcs = await tx.build({ client: client.jsonRpcClient, onlyTransactionKind: true });
98
+ // let bcs = await tx.build({ client: client.gRpcClient, onlyTransactionKind: true });
101
99
  // // console.log("bcs", bcs);
102
100
  // let res = await client.simulateTransaction(bcs);
103
- let devInspectTransactionBlockResult = await client.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: tx });
101
+ let devInspectTransactionBlockResult = await client.devInspectTransactionBlock({ transaction: tx });
104
102
  // @ts-ignore
105
- let bytes = devInspectTransactionBlockResult.results[0].returnValues[0][0];
103
+ let bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
106
104
  let reader = new bcs_1.BcsReader(new Uint8Array(bytes));
107
105
  let marketIndex = 0;
108
106
  let results = [];
@@ -135,12 +133,12 @@ async function getUserOrders(client, input) {
135
133
  },
136
134
  }));
137
135
  }
138
- let res = await client.devInspectTransactionBlock({ sender: input.user, transactionBlock: tx });
136
+ let res = await client.devInspectTransactionBlock({ transaction: tx });
139
137
  // console.log(res);
140
138
  let orders = [];
141
139
  for (var x = 0; x < input.indexes.length; x++) {
142
140
  // @ts-ignore
143
- let returnValues = res.results[x].returnValues[0][0];
141
+ let returnValues = res.commandResults[x].returnValues[0].bcs;
144
142
  // console.log(returnValues);
145
143
  let reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
146
144
  reader.readVec((reader) => {
@@ -164,12 +162,12 @@ async function getUserPositions(client, input) {
164
162
  },
165
163
  }));
166
164
  }
167
- let res = await client.devInspectTransactionBlock({ sender: input.user, transactionBlock: tx });
165
+ let res = await client.devInspectTransactionBlock({ transaction: tx });
168
166
  // console.log(res);
169
167
  let positions = [];
170
168
  for (var x = 0; x < input.indexes.length; x++) {
171
169
  // @ts-ignore
172
- let returnValues = res.results[x].returnValues[0][0];
170
+ let returnValues = res.commandResults[x].returnValues[0].bcs;
173
171
  // console.log(returnValues);
174
172
  let reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
175
173
  reader.readVec((reader) => {
@@ -219,13 +217,16 @@ async function getUserStake(client, input) {
219
217
  },
220
218
  }));
221
219
  }
222
- let res = await client.devInspectTransactionBlock({ sender: input.user, transactionBlock: tx });
220
+ let res = await client.devInspectTransactionBlock({ transaction: tx });
223
221
  // console.log(res);
224
- if (res.results) {
222
+ if (res.FailedTransaction) {
223
+ console.error("Transaction failed with error: ", res.FailedTransaction.status.error);
224
+ }
225
+ if (res.commandResults) {
225
226
  let results = [];
226
227
  for (var x = 0; x < input.indexes.length; x++) {
227
228
  // @ts-ignore
228
- var returnValues = res.results[2 * x + 1].returnValues[0][0];
229
+ var returnValues = res.commandResults[2 * x + 1].returnValues[0].bcs;
229
230
  // console.log(returnValues);
230
231
  var reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
231
232
  let length = reader.readULEB();
@@ -263,13 +264,13 @@ async function getDeactivatingShares(client, input) {
263
264
  typeArguments: ["TLP_TOKEN"],
264
265
  }));
265
266
  }
266
- let res = await client.devInspectTransactionBlock({ sender: input.user, transactionBlock: tx });
267
+ let res = await client.devInspectTransactionBlock({ transaction: tx });
267
268
  // console.log(res);
268
- if (res.results) {
269
+ if (res.commandResults) {
269
270
  let deactivatingShares = [];
270
271
  for (var x = 0; x < input.indexes.length; x++) {
271
272
  // @ts-ignore
272
- var returnValues = res.results[0].returnValues[0][0];
273
+ var returnValues = res.commandResults[0].returnValues[0].bcs;
273
274
  // console.log(returnValues);
274
275
  var reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
275
276
  reader.readVec((reader) => {
@@ -325,10 +326,10 @@ async function getLiquidationPriceAndPnl(client, input) {
325
326
  positionId: BigInt(position.position_id),
326
327
  dovRegistry: client.config.registry.dov.dovSingle,
327
328
  },
328
- typeArguments: [position.collateral_token.name, position.symbol.base_token.name],
329
+ typeArguments: [(0, utils_3.normalizeStructTag)(position.collateral_token.name), (0, utils_3.normalizeStructTag)(position.symbol.base_token.name)],
329
330
  }));
330
331
  }
331
- let res = await client.devInspectTransactionBlock({ sender: constants_1.SENDER, transactionBlock: tx });
332
+ let res = await client.devInspectTransactionBlock({ transaction: tx });
332
333
  // console.log(res);
333
334
  // 0 estimated_liquidation_price,
334
335
  // 1 has_profit,
@@ -339,32 +340,33 @@ async function getLiquidationPriceAndPnl(client, input) {
339
340
  // 6 unrealized_funding_fee_usd,
340
341
  // 7 unrealized_borrow_fee_usd,
341
342
  // 8 close_fee_usd
342
- let results = res.results
343
- ? res.results.slice(-input.positions.length).map((x) => {
344
- // console.log(x);
345
- let liquidationPrice = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[0][0])));
346
- let isProfit = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[1][0]));
347
- var pnl = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[2][0])));
348
- pnl = isProfit ? pnl : -pnl;
349
- // including closeFee
350
- let isCost = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[3][0]));
351
- var cost = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[4][0])));
352
- cost = isCost ? cost : -cost;
353
- // cost = unrealized_loss + unrealized_trading_fee + unrealized_borrow_fee + unrealized_funding_fee;
354
- let fundingFeeSign = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[5][0]));
355
- var fundingFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[6][0])));
356
- fundingFee = fundingFeeSign ? fundingFee : -fundingFee;
357
- let borrowFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[7][0])));
358
- let closeFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[8][0])));
359
- return {
360
- liquidationPrice,
361
- pnl: pnl + closeFee,
362
- fundingFee,
363
- borrowFee,
364
- closeFee,
365
- pnlAfterFee: pnl - cost,
366
- };
367
- })
343
+ let results = res.commandResults
344
+ ? // @ts-ignore
345
+ res.commandResults.slice(-input.positions.length).map((x) => {
346
+ // console.log(x);
347
+ let liquidationPrice = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[0].bcs)));
348
+ let isProfit = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[1].bcs));
349
+ var pnl = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[2].bcs)));
350
+ pnl = isProfit ? pnl : -pnl;
351
+ // including closeFee
352
+ let isCost = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[3].bcs));
353
+ var cost = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[4].bcs)));
354
+ cost = isCost ? cost : -cost;
355
+ // cost = unrealized_loss + unrealized_trading_fee + unrealized_borrow_fee + unrealized_funding_fee;
356
+ let fundingFeeSign = bcs_1.bcs.bool().parse(Uint8Array.from(x.returnValues[5].bcs));
357
+ var fundingFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[6].bcs)));
358
+ fundingFee = fundingFeeSign ? fundingFee : -fundingFee;
359
+ let borrowFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[7].bcs)));
360
+ let closeFee = Number(bcs_1.bcs.u64().parse(Uint8Array.from(x.returnValues[8].bcs)));
361
+ return {
362
+ liquidationPrice,
363
+ pnl: pnl + closeFee,
364
+ fundingFee,
365
+ borrowFee,
366
+ closeFee,
367
+ pnlAfterFee: pnl - cost,
368
+ };
369
+ })
368
370
  : [];
369
371
  // console.log(results);
370
372
  return results;
@@ -382,14 +384,15 @@ async function getAllPositions(client, input) {
382
384
  typeArguments: [constants_1.tokenType[_1.NETWORK][input.baseToken]],
383
385
  }));
384
386
  let res = await client.devInspectTransactionBlock({
385
- sender: constants_1.SENDER,
386
- transactionBlock: tx,
387
+ transaction: tx,
387
388
  });
388
- if (!res.results?.[0]?.returnValues?.[0]?.[0]) {
389
+ // @ts-ignore
390
+ if (!res.commandResults?.[0]?.returnValues?.[0]?.bcs) {
389
391
  return { positions: [], maxPage: 0 };
390
392
  }
391
393
  // -- 解析回傳值 -------------------------------------------------
392
- const raw = new Uint8Array(res.results[0].returnValues[0][0]);
394
+ // @ts-ignore
395
+ const raw = new Uint8Array(res.commandResults[0].returnValues[0].bcs);
393
396
  // 1) 至少要有 8 bytes 的 max_page
394
397
  if (raw.length < 8)
395
398
  return { positions: [], maxPage: 0 };
@@ -449,16 +452,17 @@ async function fetchUserProfits(client, input) {
449
452
  let tx = new transactions_1.Transaction();
450
453
  tx.moveCall({
451
454
  target: `${_1.PERP_PACKAGE_ID}::profit_vault::get_user_profits`,
452
- arguments: [tx.object(input.version), tx.object(input.profitVault), tx.pure.address(input.user)],
455
+ arguments: [tx.object(_1.PERP_VERSION), tx.object(_1.PROFIT_VAULT), tx.pure.address(input.user)],
453
456
  });
454
457
  const res = await client.devInspectTransactionBlock({
455
- sender: constants_1.SENDER,
456
- transactionBlock: tx,
458
+ transaction: tx,
457
459
  });
458
- if (!res.results?.[0]?.returnValues?.[0]?.[0]) {
460
+ // @ts-ignore
461
+ if (!res.commandResults?.[0]?.returnValues?.[0].bcs) {
459
462
  return [];
460
463
  }
461
- const returnValues = res.results[0].returnValues[0][0];
464
+ // @ts-ignore
465
+ const returnValues = res.commandResults[0].returnValues[0].bcs;
462
466
  const reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
463
467
  const profits = [];
464
468
  reader.readVec((reader) => {
@@ -473,16 +477,17 @@ async function fetchLockedUserProfits(client, input) {
473
477
  let tx = new transactions_1.Transaction();
474
478
  tx.moveCall({
475
479
  target: `${_1.PERP_PACKAGE_ID}::profit_vault::get_locked_user_profits`,
476
- arguments: [tx.object(_1.PERP_VERSION), tx.object(input.lockVault), tx.pure.address(input.user)],
480
+ arguments: [tx.object(_1.PERP_VERSION), tx.object(_1.LOCK_VAULT), tx.pure.address(input.user)],
477
481
  });
478
482
  const res = await client.devInspectTransactionBlock({
479
- sender: constants_1.SENDER,
480
- transactionBlock: tx,
483
+ transaction: tx,
481
484
  });
482
- if (!res.results?.[0]?.returnValues?.[0]?.[0]) {
485
+ // @ts-ignore
486
+ if (!res.commandResults?.[0]?.returnValues?.[0].bcs) {
483
487
  return [];
484
488
  }
485
- const returnValues = res.results[0].returnValues[0][0];
489
+ // @ts-ignore
490
+ const returnValues = res.commandResults[0].returnValues[0].bcs;
486
491
  const reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
487
492
  const lockedUserProfits = [];
488
493
  reader.readVec((reader) => {
@@ -493,108 +498,3 @@ async function fetchLockedUserProfits(client, input) {
493
498
  });
494
499
  return lockedUserProfits;
495
500
  }
496
- async function fetchAllUserProfits(client, input) {
497
- const provider = new client_1.SuiClient({ url: client.config.rpcEndpoint });
498
- const profitVaultId = input?.profitVault ?? _1.PROFIT_VAULT;
499
- // 1. Read ProfitVault object to get user_profits Table ID
500
- const vaultResponse = await provider.getObject({
501
- id: profitVaultId,
502
- options: { showContent: true },
503
- });
504
- if (!vaultResponse.data?.content || vaultResponse.data.content.dataType !== "moveObject") {
505
- return [];
506
- }
507
- const fields = vaultResponse.data.content.fields;
508
- const tableId = fields?.user_profits?.fields?.id?.id;
509
- if (!tableId) {
510
- return [];
511
- }
512
- // 2. Get all dynamic fields (user addresses) from the Table
513
- let cursor = null;
514
- const allUsers = [];
515
- while (true) {
516
- const dynamicFields = await provider.getDynamicFields({
517
- parentId: tableId,
518
- cursor,
519
- limit: 50,
520
- });
521
- for (const field of dynamicFields.data) {
522
- const userAddress = field.name.value;
523
- if (userAddress) {
524
- allUsers.push(userAddress);
525
- }
526
- }
527
- if (!dynamicFields.hasNextPage) {
528
- break;
529
- }
530
- cursor = dynamicFields.nextCursor ?? null;
531
- }
532
- // 3. For each user, fetch their profits
533
- const fetchUserProfitsPromises = [];
534
- for (const user of allUsers) {
535
- try {
536
- const fetchUserProfitsWithUser = async () => {
537
- const profits = await fetchUserProfits(client, { profitVault: profitVaultId, version: _1.PERP_VERSION, user });
538
- return { user, profits };
539
- };
540
- fetchUserProfitsPromises.push(fetchUserProfitsWithUser());
541
- }
542
- catch (e) {
543
- console.error(`Failed to get profits for user ${user}:`, e);
544
- }
545
- }
546
- const results = await Promise.all(fetchUserProfitsPromises);
547
- return results;
548
- }
549
- async function fetchAllLockedUserProfits(client, input) {
550
- const provider = new client_1.SuiClient({ url: client.config.rpcEndpoint });
551
- // 1. Read LockVault object to get locked_user_profits Table ID
552
- const vaultResponse = await provider.getObject({
553
- id: input?.lockVault ?? _1.LOCK_VAULT,
554
- options: { showContent: true },
555
- });
556
- if (!vaultResponse.data?.content || vaultResponse.data.content.dataType !== "moveObject") {
557
- return [];
558
- }
559
- const fields = vaultResponse.data.content.fields;
560
- const tableId = fields?.locked_user_profits?.fields?.id?.id;
561
- if (!tableId) {
562
- return [];
563
- }
564
- // 2. Get all dynamic fields (user addresses) from the Table
565
- let cursor = null;
566
- const allUsers = [];
567
- while (true) {
568
- const dynamicFields = await provider.getDynamicFields({
569
- parentId: tableId,
570
- cursor,
571
- limit: 50,
572
- });
573
- for (const field of dynamicFields.data) {
574
- const userAddress = field.name.value;
575
- if (userAddress) {
576
- allUsers.push(userAddress);
577
- }
578
- }
579
- if (!dynamicFields.hasNextPage) {
580
- break;
581
- }
582
- cursor = dynamicFields.nextCursor ?? null;
583
- }
584
- // 3. For each user, fetch their locked profits
585
- const fetchLockedUserProfitsPromises = [];
586
- for (const user of allUsers) {
587
- try {
588
- const fetchLockedUserProfitsWithUser = async () => {
589
- const lockedUserProfits = await fetchLockedUserProfits(client, { lockVault: _1.LOCK_VAULT, version: _1.PERP_VERSION, user });
590
- return { user, lockedUserProfits };
591
- };
592
- fetchLockedUserProfitsPromises.push(fetchLockedUserProfitsWithUser());
593
- }
594
- catch (e) {
595
- console.error(`Failed to get locked profits for user ${user}:`, e);
596
- }
597
- }
598
- const results = await Promise.all(fetchLockedUserProfitsPromises);
599
- return results;
600
- }
@@ -6,22 +6,20 @@
6
6
  * Perpetual Protocol. It includes version management, authority control, and fee
7
7
  * handling.
8
8
  */
9
- import { MoveStruct, type RawTransactionArgument } from "../utils/index";
9
+ import { MoveStruct, type RawTransactionArgument } from "../utils/index.js";
10
10
  import { type Transaction } from "@mysten/sui/transactions";
11
11
  export declare const FeeInfo: MoveStruct<{
12
12
  /** The type name of the token. */
13
13
  token: MoveStruct<{
14
- name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
14
+ name: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string, "string">;
15
15
  }, "std::type_name::TypeName">;
16
16
  /** The amount of fees collected. */
17
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
17
+ value: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | number | bigint, "u64">;
18
18
  }, "@typus/perp::admin::FeeInfo">;
19
19
  export declare const FeePool: MoveStruct<{
20
- id: MoveStruct<{
21
- id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
22
- }, "0x2::object::UID">;
20
+ id: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
23
21
  /** A vector of `FeeInfo` structs. */
24
- fee_infos: import("@mysten/sui/bcs").BcsType<{
22
+ fee_infos: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<{
25
23
  token: {
26
24
  name: string;
27
25
  };
@@ -36,18 +34,14 @@ export declare const FeePool: MoveStruct<{
36
34
  }, string>;
37
35
  }, "@typus/perp::admin::FeePool">;
38
36
  export declare const Version: MoveStruct<{
39
- id: MoveStruct<{
40
- id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
41
- }, "0x2::object::UID">;
37
+ id: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
42
38
  /** The version number. */
43
- value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
39
+ value: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | number | bigint, "u64">;
44
40
  /** The fee pool for protocol fees. */
45
41
  fee_pool: MoveStruct<{
46
- id: MoveStruct<{
47
- id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
48
- }, "0x2::object::UID">;
42
+ id: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
49
43
  /** A vector of `FeeInfo` structs. */
50
- fee_infos: import("@mysten/sui/bcs").BcsType<{
44
+ fee_infos: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<{
51
45
  token: {
52
46
  name: string;
53
47
  };
@@ -63,11 +57,9 @@ export declare const Version: MoveStruct<{
63
57
  }, "@typus/perp::admin::FeePool">;
64
58
  /** The fee pool for liquidator fees. */
65
59
  liquidator_fee_pool: MoveStruct<{
66
- id: MoveStruct<{
67
- id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
68
- }, "0x2::object::UID">;
60
+ id: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
69
61
  /** A vector of `FeeInfo` structs. */
70
- fee_infos: import("@mysten/sui/bcs").BcsType<{
62
+ fee_infos: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<{
71
63
  token: {
72
64
  name: string;
73
65
  };
@@ -83,38 +75,38 @@ export declare const Version: MoveStruct<{
83
75
  }, "@typus/perp::admin::FeePool">;
84
76
  /** The list of authorized addresses. */
85
77
  authority: MoveStruct<{
86
- contents: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | Uint8Array<ArrayBufferLike>> & {
78
+ contents: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string[], Iterable<string | Uint8Array<ArrayBufferLike>> & {
87
79
  length: number;
88
80
  }, string>;
89
81
  }, "0x2::vec_set::VecSet<bytes[32]>">;
90
82
  /** Padding for future use. */
91
- u64_padding: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
83
+ u64_padding: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string[], Iterable<string | number | bigint> & {
92
84
  length: number;
93
85
  }, string>;
94
86
  }, "@typus/perp::admin::Version">;
95
87
  export declare const SendFeeEvent: MoveStruct<{
96
88
  /** The type name of the token. */
97
89
  token: MoveStruct<{
98
- name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
90
+ name: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string, "string">;
99
91
  }, "std::type_name::TypeName">;
100
92
  /** The amount of fees sent. */
101
- amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
93
+ amount: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | number | bigint, "u64">;
102
94
  }, "@typus/perp::admin::SendFeeEvent">;
103
95
  export declare const ProtocolFeeEvent: MoveStruct<{
104
96
  /** The type name of the token. */
105
97
  token: MoveStruct<{
106
- name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
98
+ name: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string, "string">;
107
99
  }, "std::type_name::TypeName">;
108
100
  /** The amount of fees charged. */
109
- amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
101
+ amount: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | number | bigint, "u64">;
110
102
  }, "@typus/perp::admin::ProtocolFeeEvent">;
111
103
  export declare const PutInsuranceFundEvent: MoveStruct<{
112
104
  /** The type name of the token. */
113
105
  token: MoveStruct<{
114
- name: import("@mysten/sui/bcs").BcsType<string, string, "string">;
106
+ name: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string, "string">;
115
107
  }, "std::type_name::TypeName">;
116
108
  /** The amount of funds put into the insurance fund. */
117
- amount: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
109
+ amount: import("@mysten/sui/bcs", { with: { "resolution-mode": "import" } }).BcsType<string, string | number | bigint, "u64">;
118
110
  }, "@typus/perp::admin::PutInsuranceFundEvent">;
119
111
  export interface VersionCheckArguments {
120
112
  version: RawTransactionArgument<string>;
@@ -124,7 +116,7 @@ export interface VersionCheckOptions {
124
116
  arguments: VersionCheckArguments | [version: RawTransactionArgument<string>];
125
117
  }
126
118
  /** Checks if the contract version is valid. */
127
- export declare function versionCheck(options: VersionCheckOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
119
+ export declare function versionCheck(options: VersionCheckOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
128
120
  export interface UpgradeArguments {
129
121
  version: RawTransactionArgument<string>;
130
122
  }
@@ -133,12 +125,12 @@ export interface UpgradeOptions {
133
125
  arguments: UpgradeArguments | [version: RawTransactionArgument<string>];
134
126
  }
135
127
  /** Upgrades the contract version. WARNING: no authority check inside */
136
- export declare function upgrade(options: UpgradeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
128
+ export declare function upgrade(options: UpgradeOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
137
129
  export interface InitOptions {
138
130
  package?: string;
139
131
  arguments?: [];
140
132
  }
141
- export declare function init(options?: InitOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
133
+ export declare function init(options?: InitOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
142
134
  export interface VerifyArguments {
143
135
  version: RawTransactionArgument<string>;
144
136
  }
@@ -147,7 +139,7 @@ export interface VerifyOptions {
147
139
  arguments: VerifyArguments | [version: RawTransactionArgument<string>];
148
140
  }
149
141
  /** [Authorized Function] Verifies if the sender is an authorized user. */
150
- export declare function verify(options: VerifyOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
142
+ export declare function verify(options: VerifyOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
151
143
  export interface AddAuthorizedUserArguments {
152
144
  version: RawTransactionArgument<string>;
153
145
  userAddress: RawTransactionArgument<string>;
@@ -156,8 +148,7 @@ export interface AddAuthorizedUserOptions {
156
148
  package?: string;
157
149
  arguments: AddAuthorizedUserArguments | [version: RawTransactionArgument<string>, userAddress: RawTransactionArgument<string>];
158
150
  }
159
- /** [Authorized Function] Adds an authorized user. */
160
- export declare function addAuthorizedUser(options: AddAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
151
+ export declare function addAuthorizedUser(options: AddAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
161
152
  export interface RemoveAuthorizedUserArguments {
162
153
  version: RawTransactionArgument<string>;
163
154
  userAddress: RawTransactionArgument<string>;
@@ -166,8 +157,7 @@ export interface RemoveAuthorizedUserOptions {
166
157
  package?: string;
167
158
  arguments: RemoveAuthorizedUserArguments | [version: RawTransactionArgument<string>, userAddress: RawTransactionArgument<string>];
168
159
  }
169
- /** [Authorized Function] Removes an authorized user. */
170
- export declare function removeAuthorizedUser(options: RemoveAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
160
+ export declare function removeAuthorizedUser(options: RemoveAuthorizedUserOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
171
161
  export interface InstallEcosystemManagerCapEntryArguments {
172
162
  version: RawTransactionArgument<string>;
173
163
  typusEcosystemVersion: RawTransactionArgument<string>;
@@ -180,7 +170,7 @@ export interface InstallEcosystemManagerCapEntryOptions {
180
170
  * [Authorized Function] Installs the ecosystem manager cap. TODO: can be remove
181
171
  * after install
182
172
  */
183
- export declare function installEcosystemManagerCapEntry(options: InstallEcosystemManagerCapEntryOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
173
+ export declare function installEcosystemManagerCapEntry(options: InstallEcosystemManagerCapEntryOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
184
174
  export interface AddTailsExpAndLeaderboardArguments {
185
175
  version: RawTransactionArgument<string>;
186
176
  typusEcosystemVersion: RawTransactionArgument<string>;
@@ -202,7 +192,7 @@ export interface AddTailsExpAndLeaderboardOptions {
202
192
  expMultiplier: RawTransactionArgument<number | bigint>
203
193
  ];
204
194
  }
205
- export declare function addTailsExpAndLeaderboard(options: AddTailsExpAndLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
195
+ export declare function addTailsExpAndLeaderboard(options: AddTailsExpAndLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
206
196
  export interface AddCompetitionLeaderboardArguments {
207
197
  version: RawTransactionArgument<string>;
208
198
  typusEcosystemVersion: RawTransactionArgument<string>;
@@ -223,7 +213,7 @@ export interface AddCompetitionLeaderboardOptions {
223
213
  ];
224
214
  }
225
215
  /** Adds a score to the competition leaderboard. */
226
- export declare function addCompetitionLeaderboard(options: AddCompetitionLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
216
+ export declare function addCompetitionLeaderboard(options: AddCompetitionLeaderboardOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
227
217
  export interface SendFeeArguments {
228
218
  version: RawTransactionArgument<string>;
229
219
  }
@@ -236,7 +226,7 @@ export interface SendFeeOptions {
236
226
  * Sends the collected fees to the fee address. Safe with constant address as
237
227
  * receiver
238
228
  */
239
- export declare function sendFee(options: SendFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
229
+ export declare function sendFee(options: SendFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
240
230
  export interface ChargeFeeArguments {
241
231
  version: RawTransactionArgument<string>;
242
232
  balance: RawTransactionArgument<string>;
@@ -247,7 +237,7 @@ export interface ChargeFeeOptions {
247
237
  typeArguments: [string];
248
238
  }
249
239
  /** Charges a protocol fee. */
250
- export declare function chargeFee(options: ChargeFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
240
+ export declare function chargeFee(options: ChargeFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
251
241
  export interface SendLiquidatorFeeArguments {
252
242
  version: RawTransactionArgument<string>;
253
243
  }
@@ -260,7 +250,7 @@ export interface SendLiquidatorFeeOptions {
260
250
  * Sends the liquidator fees to the fee address. Safe with constant address as
261
251
  * receiver
262
252
  */
263
- export declare function sendLiquidatorFee(options: SendLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
253
+ export declare function sendLiquidatorFee(options: SendLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;
264
254
  export interface ChargeLiquidatorFeeArguments {
265
255
  version: RawTransactionArgument<string>;
266
256
  balance: RawTransactionArgument<string>;
@@ -271,4 +261,4 @@ export interface ChargeLiquidatorFeeOptions {
271
261
  typeArguments: [string];
272
262
  }
273
263
  /** Charges a liquidator fee. */
274
- export declare function chargeLiquidatorFee(options: ChargeLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions").TransactionResult;
264
+ export declare function chargeLiquidatorFee(options: ChargeLiquidatorFeeOptions): (tx: Transaction) => import("@mysten/sui/transactions", { with: { "resolution-mode": "import" } }).TransactionResult;