@typus/typus-perp-sdk 1.1.32-codegen-exp15-profit-vault → 1.1.32-codegen-exp16

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.
@@ -423,7 +423,6 @@ export declare function getDeactivatingShares(client: TypusClient, input: {
423
423
  * @returns [liquidationPrice, pnl(in USD)]
424
424
  */
425
425
  export declare function getLiquidationPriceAndPnl(client: TypusClient, input: {
426
- oracle?: string;
427
426
  positions: (typeof Position.$inferType)[];
428
427
  }): Promise<PositionInfo[]>;
429
428
  interface PositionInfo {
@@ -535,42 +534,4 @@ export declare function getAllPositionsWithTradingSymbol(client: TypusClient, in
535
534
  } | null;
536
535
  u64_padding: string[];
537
536
  }[]>;
538
- export type UserProfit = {
539
- collateral_token: {
540
- name: string;
541
- };
542
- base_token: {
543
- name: string;
544
- };
545
- position_id: string;
546
- order_id: string;
547
- amount: string;
548
- create_ts_ms: string;
549
- };
550
- export type LockedUserProfit = {
551
- user_profit: UserProfit;
552
- create_ts_ms: string;
553
- };
554
- export declare function fetchUserProfits(client: TypusClient, input: {
555
- profitVault: string;
556
- version: string;
557
- user: string;
558
- }): Promise<UserProfit[]>;
559
- export declare function fetchLockedUserProfits(client: TypusClient, input: {
560
- lockVault: string;
561
- version: string;
562
- user: string;
563
- }): Promise<LockedUserProfit[]>;
564
- export declare function fetchAllUserProfits(client: TypusClient, input?: {
565
- profitVault?: string;
566
- }): Promise<{
567
- user: string;
568
- profits: UserProfit[];
569
- }[]>;
570
- export declare function fetchAllLockedUserProfits(client: TypusClient, input?: {
571
- lockVault?: string;
572
- }): Promise<{
573
- user: string;
574
- lockedUserProfits: LockedUserProfit[];
575
- }[]>;
576
537
  export {};
package/dist/src/fetch.js CHANGED
@@ -13,16 +13,10 @@ exports.getDeactivatingShares = getDeactivatingShares;
13
13
  exports.getLiquidationPriceAndPnl = getLiquidationPriceAndPnl;
14
14
  exports.getAllPositions = getAllPositions;
15
15
  exports.getAllPositionsWithTradingSymbol = getAllPositionsWithTradingSymbol;
16
- exports.fetchUserProfits = fetchUserProfits;
17
- exports.fetchLockedUserProfits = fetchLockedUserProfits;
18
- exports.fetchAllUserProfits = fetchAllUserProfits;
19
- exports.fetchAllLockedUserProfits = fetchAllLockedUserProfits;
20
16
  const transactions_1 = require("@mysten/sui/transactions");
21
- const client_1 = require("@mysten/sui/client");
22
17
  const bcs_1 = require("@mysten/bcs");
23
18
  const constants_1 = require("@typus/typus-sdk/dist/src/constants");
24
19
  const utils_1 = require("@typus/typus-sdk/dist/src/utils");
25
- const utils_2 = require("@typus/typus-sdk/dist/src/utils");
26
20
  const _1 = require(".");
27
21
  const trading_1 = require("./generated/typus_perp/trading");
28
22
  const lp_pool_1 = require("./generated/typus_perp/lp_pool");
@@ -300,16 +294,10 @@ async function getLiquidationPriceAndPnl(client, input) {
300
294
  tokens.push(TOKEN);
301
295
  tokens.push(BASE_TOKEN);
302
296
  }
303
- const tokensWithoutTypus = tokens.filter((token) => token !== "TYPUS");
304
- await (0, utils_1.updatePyth)(client.pythClient, tx, Array.from(new Set(tokensWithoutTypus)));
305
- for (let token of Array.from(new Set(tokensWithoutTypus))) {
297
+ await (0, utils_1.updatePyth)(client.pythClient, tx, Array.from(new Set(tokens)));
298
+ for (let token of Array.from(new Set(tokens))) {
306
299
  (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
307
300
  }
308
- if (tokens.includes("TYPUS")) {
309
- // TODO: update oracle contract
310
- const oracleContract = input.oracle ?? "0x51fc5517f5ba4e3ba8862cd74c345e7294193c693ab41376694d1c516033e2e8";
311
- tx = await (0, utils_2.updateOracleWithSignatureTx)(_1.NETWORK, tx, oracleContract, constants_1.tokenType[_1.NETWORK]["TYPUS"]);
312
- }
313
301
  for (let position of input.positions) {
314
302
  // parse from Position
315
303
  let TOKEN = (0, constants_1.typeArgToAsset)(position.collateral_token.name);
@@ -433,171 +421,3 @@ async function getAllPositionsWithTradingSymbol(client, input) {
433
421
  }
434
422
  return positions;
435
423
  }
436
- const TypeNameBcs = bcs_1.bcs.struct("TypeName", {
437
- name: bcs_1.bcs.string(),
438
- });
439
- const UserProfitBcs = bcs_1.bcs.struct("UserProfit", {
440
- collateral_token: TypeNameBcs,
441
- base_token: TypeNameBcs,
442
- position_id: bcs_1.bcs.u64(),
443
- order_id: bcs_1.bcs.u64(),
444
- amount: bcs_1.bcs.u64(),
445
- create_ts_ms: bcs_1.bcs.u64(),
446
- });
447
- const LockedUserProfitBcs = bcs_1.bcs.struct("LockedUserProfit", {
448
- user_profit: UserProfitBcs,
449
- create_ts_ms: bcs_1.bcs.u64(),
450
- });
451
- async function fetchUserProfits(client, input) {
452
- let tx = new transactions_1.Transaction();
453
- tx.moveCall({
454
- target: `${_1.PERP_PACKAGE_ID}::profit_vault::get_user_profits`,
455
- arguments: [tx.object(input.version), tx.object(input.profitVault), tx.pure.address(input.user)],
456
- });
457
- const res = await client.devInspectTransactionBlock({
458
- sender: constants_1.SENDER,
459
- transactionBlock: tx,
460
- });
461
- if (!res.results?.[0]?.returnValues?.[0]?.[0]) {
462
- return [];
463
- }
464
- const returnValues = res.results[0].returnValues[0][0];
465
- const reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
466
- const profits = [];
467
- reader.readVec((reader) => {
468
- const length = reader.readULEB();
469
- const bytes = reader.readBytes(length);
470
- const profit = UserProfitBcs.parse(Uint8Array.from(Array.from(bytes)));
471
- profits.push(profit);
472
- });
473
- return profits;
474
- }
475
- async function fetchLockedUserProfits(client, input) {
476
- let tx = new transactions_1.Transaction();
477
- tx.moveCall({
478
- target: `${_1.PERP_PACKAGE_ID}::profit_vault::get_locked_user_profits`,
479
- arguments: [tx.object(_1.PERP_VERSION), tx.object(input.lockVault), tx.pure.address(input.user)],
480
- });
481
- const res = await client.devInspectTransactionBlock({
482
- sender: constants_1.SENDER,
483
- transactionBlock: tx,
484
- });
485
- if (!res.results?.[0]?.returnValues?.[0]?.[0]) {
486
- return [];
487
- }
488
- const returnValues = res.results[0].returnValues[0][0];
489
- const reader = new bcs_1.BcsReader(new Uint8Array(returnValues));
490
- const lockedUserProfits = [];
491
- reader.readVec((reader) => {
492
- const length = reader.readULEB();
493
- const bytes = reader.readBytes(length);
494
- const profit = LockedUserProfitBcs.parse(Uint8Array.from(Array.from(bytes)));
495
- lockedUserProfits.push(profit);
496
- });
497
- return lockedUserProfits;
498
- }
499
- async function fetchAllUserProfits(client, input) {
500
- const provider = new client_1.SuiClient({ url: client.config.rpcEndpoint });
501
- const profitVaultId = input?.profitVault ?? _1.PROFIT_VAULT;
502
- // 1. Read ProfitVault object to get user_profits Table ID
503
- const vaultResponse = await provider.getObject({
504
- id: profitVaultId,
505
- options: { showContent: true },
506
- });
507
- if (!vaultResponse.data?.content || vaultResponse.data.content.dataType !== "moveObject") {
508
- return [];
509
- }
510
- const fields = vaultResponse.data.content.fields;
511
- const tableId = fields?.user_profits?.fields?.id?.id;
512
- if (!tableId) {
513
- return [];
514
- }
515
- // 2. Get all dynamic fields (user addresses) from the Table
516
- let cursor = null;
517
- const allUsers = [];
518
- while (true) {
519
- const dynamicFields = await provider.getDynamicFields({
520
- parentId: tableId,
521
- cursor,
522
- limit: 50,
523
- });
524
- for (const field of dynamicFields.data) {
525
- const userAddress = field.name.value;
526
- if (userAddress) {
527
- allUsers.push(userAddress);
528
- }
529
- }
530
- if (!dynamicFields.hasNextPage) {
531
- break;
532
- }
533
- cursor = dynamicFields.nextCursor ?? null;
534
- }
535
- // 3. For each user, fetch their profits
536
- const fetchUserProfitsPromises = [];
537
- for (const user of allUsers) {
538
- try {
539
- const fetchUserProfitsWithUser = async () => {
540
- const profits = await fetchUserProfits(client, { profitVault: profitVaultId, version: _1.PERP_VERSION, user });
541
- return { user, profits };
542
- };
543
- fetchUserProfitsPromises.push(fetchUserProfitsWithUser());
544
- }
545
- catch (e) {
546
- console.error(`Failed to get profits for user ${user}:`, e);
547
- }
548
- }
549
- const results = await Promise.all(fetchUserProfitsPromises);
550
- return results;
551
- }
552
- async function fetchAllLockedUserProfits(client, input) {
553
- const provider = new client_1.SuiClient({ url: client.config.rpcEndpoint });
554
- // 1. Read LockVault object to get locked_user_profits Table ID
555
- const vaultResponse = await provider.getObject({
556
- id: input?.lockVault ?? _1.LOCK_VAULT,
557
- options: { showContent: true },
558
- });
559
- if (!vaultResponse.data?.content || vaultResponse.data.content.dataType !== "moveObject") {
560
- return [];
561
- }
562
- const fields = vaultResponse.data.content.fields;
563
- const tableId = fields?.locked_user_profits?.fields?.id?.id;
564
- if (!tableId) {
565
- return [];
566
- }
567
- // 2. Get all dynamic fields (user addresses) from the Table
568
- let cursor = null;
569
- const allUsers = [];
570
- while (true) {
571
- const dynamicFields = await provider.getDynamicFields({
572
- parentId: tableId,
573
- cursor,
574
- limit: 50,
575
- });
576
- for (const field of dynamicFields.data) {
577
- const userAddress = field.name.value;
578
- if (userAddress) {
579
- allUsers.push(userAddress);
580
- }
581
- }
582
- if (!dynamicFields.hasNextPage) {
583
- break;
584
- }
585
- cursor = dynamicFields.nextCursor ?? null;
586
- }
587
- // 3. For each user, fetch their locked profits
588
- const fetchLockedUserProfitsPromises = [];
589
- for (const user of allUsers) {
590
- try {
591
- const fetchLockedUserProfitsWithUser = async () => {
592
- const lockedUserProfits = await fetchLockedUserProfits(client, { lockVault: _1.LOCK_VAULT, version: _1.PERP_VERSION, user });
593
- return { user, lockedUserProfits };
594
- };
595
- fetchLockedUserProfitsPromises.push(fetchLockedUserProfitsWithUser());
596
- }
597
- catch (e) {
598
- console.error(`Failed to get locked profits for user ${user}:`, e);
599
- }
600
- }
601
- const results = await Promise.all(fetchLockedUserProfitsPromises);
602
- return results;
603
- }
@@ -11,5 +11,3 @@ export declare const TLP_TREASURY_CAP: string;
11
11
  export declare const STAKE_POOL: string;
12
12
  export declare const STAKE_POOL_VERSION: string;
13
13
  export declare const COMPETITION_CONFIG: string;
14
- export declare const PROFIT_VAULT: string;
15
- export declare const LOCK_VAULT: string;
package/dist/src/index.js CHANGED
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.LOCK_VAULT = exports.PROFIT_VAULT = exports.COMPETITION_CONFIG = exports.STAKE_POOL_VERSION = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PACKAGE_ID = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
20
+ exports.COMPETITION_CONFIG = exports.STAKE_POOL_VERSION = exports.STAKE_POOL = exports.TLP_TREASURY_CAP = exports.PERP_VERSION = exports.MARKET = exports.LIQUIDITY_POOL = exports.LP_POOL = exports.STAKE_PACKAGE_ID = exports.PERP_PACKAGE_ID = exports.NETWORK = void 0;
21
21
  __exportStar(require("./fetch"), exports);
22
22
  __exportStar(require("./user"), exports);
23
23
  const dotenv_1 = __importDefault(require("dotenv"));
@@ -26,42 +26,36 @@ dotenv_1.default.config();
26
26
  // default MAINNET
27
27
  exports.NETWORK = process.env.NEXT_PUBLIC_CLUSTER == "testnet" ? "TESTNET" : "MAINNET";
28
28
  exports.PERP_PACKAGE_ID = exports.NETWORK == "MAINNET"
29
- ? "0xe27969a70f93034de9ce16e6ad661b480324574e68d15a64b513fd90eb2423e5"
30
- : "0x7adddfb77658ff43ad0281e264fdb43403a1b97bc2f6328b55279dfb4253e1e0";
29
+ ? "0xcb1c8159eb40b02877c0ceed599cf019cc8e61e8ec19c4d64db15e20ff630f05"
30
+ : "0x94cd358f552e9dd5df837de85939a9d1d682e97480740a203121e6f4c0078853";
31
31
  exports.STAKE_PACKAGE_ID = exports.NETWORK == "MAINNET"
32
- ? "0xc427209145715a00a93d7e674a95c556a7147d79fda1bbaeb1a1cac5f9923966"
32
+ ? "0x6cf6c6cc05316e238a338ba82c018d38a1af7e6da26b85fffa433df98e8f1bdb"
33
33
  : "0x02b94b340a8810f6c451bc244dc2dd8d9d50cf86d727798969ca2c287c3186aa";
34
34
  // lp_pool::Registry
35
35
  exports.LP_POOL = exports.NETWORK == "MAINNET"
36
- ? "0xfee68e535bf24702be28fa38ea2d5946e617e0035027d5ca29dbed99efd82aaa"
36
+ ? "0xb4b5e5fff9c6036f5ba22434467df1d23c2a77709807c43c7c9200816edb7006"
37
37
  : "0x85fa3cc6dc0fa8b47dda95ba0335fe1cec61dde4a2a8486ccd040f94d399b4c3";
38
38
  // liquidity_pool_registry
39
39
  exports.LIQUIDITY_POOL = exports.NETWORK == "MAINNET"
40
- ? "0x9973b7dd68ab8ba18702d913191a4c62c597847d9cd9f0b5bd97f1b938fc9a0a"
40
+ ? "0x422d57052da4465c5cbed8270e815dd9bc943cba827865db44fa067c525de9d9"
41
41
  : "0xe034d157764f273df5a1e264a3c0f78d8f922c37f942c340dabb1d66244c72ba";
42
42
  // MarketRegistry
43
43
  exports.MARKET = exports.NETWORK == "MAINNET"
44
- ? "0xc969d946a2b6b917a83b5fb71765793c4a52149e50d2c8cf5c01d7421fc7cd73"
44
+ ? "0x09a1fb68e7b07ac48d8f370cec4b5dabc80eb9a3a548ba4d06fa8e5ce1cf03ad"
45
45
  : "0xd0685e3eca9530f0618625d4a617a80db09f000609285b32a85f863da6baf811";
46
46
  exports.PERP_VERSION = exports.NETWORK == "MAINNET"
47
- ? "0xa12c282a068328833ec4a9109fc77803ec1f523f8da1bb0f82bac8450335f0c9"
47
+ ? "0x6ed8676315014e829c89f56d95a88e35167ade69911f853aed8b92c25746ecbc"
48
48
  : "0xbb0615832168e64e301db2ebd6ad71b3fe170d7e217ccd0c08714de56b41676b";
49
49
  exports.TLP_TREASURY_CAP = exports.NETWORK == "MAINNET"
50
- ? "0x77c75fb1d78cca25b5e2d69decfe2837abf95c4ef44b809868e6ca20f42b63bc"
50
+ ? "0xf836ae7b9d53bddb9be877b4fbc3ebd93b01327ca76b437d8618940d5081d222"
51
51
  : "0x1b39c2a5bc109ac520787c62f924da9244343e869bad755157e6e3e22bd7b7ae";
52
52
  // StakePoolRegistry
53
53
  exports.STAKE_POOL = exports.NETWORK == "MAINNET"
54
- ? "0x2cdf93717f87a8a7aeb98b27777b3b643f0ae2b277f44e6bcda0fc655a47d3e0"
54
+ ? "0x60c771d32a7b7f0f5f58d7dc2e6d83f76a6512f58d79bded2ee458a1d79b786c"
55
55
  : "0x8e5e5435c3fcd77f07cf097c5fbd381af7c2b394420ea035685662215471e578";
56
56
  exports.STAKE_POOL_VERSION = exports.NETWORK == "MAINNET"
57
- ? "0xdf3ed1599218b2415b2cd7fa06296f7f647676019b2873ec18e55a626c584f1b"
57
+ ? "0x57ddf480a4649da5f92b4e607cf1fac75bc11d8b582816509989d66f8bc7e329"
58
58
  : "0x02b94b340a8810f6c451bc244dc2dd8d9d50cf86d727798969ca2c287c3186aa";
59
59
  exports.COMPETITION_CONFIG = exports.NETWORK == "MAINNET"
60
- ? "0x36056abf9adde86f81667dad680a8ac98868c9fc1cb4d519fd2222d5d4522906"
60
+ ? "0xf7fcb3dbabe52c0a7e3fe01e28bb0f7045e2e45463f62bfa739e8c14a911f4be"
61
61
  : "0x2b811b120177839555aabdc2c28b28078170e663e855d29aa9072013d4fc918d";
62
- exports.PROFIT_VAULT = exports.NETWORK == "MAINNET"
63
- ? "" // TODO: Add mainnet PROFIT_VAULT address
64
- : "0xb1d603139b24db2c46f6a423c8613ce677f329a0b159ff6e57672f3b663aec47"; // TODO: Add testnet PROFIT_VAULT address
65
- exports.LOCK_VAULT = exports.NETWORK == "MAINNET"
66
- ? "" // TODO: Add mainnet LOCK_VAULT address
67
- : "0x25dd9540f031b9a62b83784a727e1ef410f9aa91ecf7e3bb27a0c61f8ceecbfb"; // TODO: Add testnet LOCK_VAULT address
@@ -356,7 +356,7 @@ async function getGraphQLEvents(module, sender, beforeCursor = null) {
356
356
  }}
357
357
  `,
358
358
  });
359
- let response = await fetch(`https://graphql.${src_1.NETWORK.toLowerCase()}.sui.io/graphql`, {
359
+ let response = await fetch(`https://sui-${src_1.NETWORK.toLowerCase()}.mystenlabs.com/graphql`, {
360
360
  method: "POST",
361
361
  headers: { "Content-Type": "application/json" },
362
362
  body: graphql,
@@ -9,7 +9,6 @@ export declare function findMarketIndex(client: TypusClient, input: {
9
9
  }): number | undefined;
10
10
  export declare function createTradingOrder(client: TypusClient, tx: Transaction, input: {
11
11
  perpIndex: string;
12
- poolIndex: string;
13
12
  coins: string[];
14
13
  cToken: TOKEN;
15
14
  amount: string;
@@ -20,7 +19,6 @@ export declare function createTradingOrder(client: TypusClient, tx: Transaction,
20
19
  isStopOrder: boolean;
21
20
  reduceOnly: boolean;
22
21
  linkedPositionId: string | null;
23
- oracleContract?: string;
24
22
  suiCoins?: string[];
25
23
  }): Promise<Transaction>;
26
24
  export declare function zeroCoin(tx: Transaction, typeArgs: [string]): import("@mysten/sui/transactions").TransactionResult;
@@ -10,14 +10,13 @@ exports.collectPositionFundingFee = collectPositionFundingFee;
10
10
  const trading_1 = require("../../src/generated/typus_perp/trading");
11
11
  const __1 = require("..");
12
12
  const utils_1 = require("@typus/typus-sdk/dist/src/utils");
13
- const utils_2 = require("@typus/typus-sdk/dist/src/utils");
14
13
  const constants_1 = require("@typus/typus-sdk/dist/src/constants");
15
- const utils_3 = require("@mysten/sui/utils");
14
+ const utils_2 = require("@mysten/sui/utils");
16
15
  function findMarketIndex(client, input) {
17
16
  let target = constants_1.tokenType[client.config.network][input.tradingToken];
18
17
  for (let i = 0; i < input.markets.length; i++) {
19
18
  for (let symbol of input.markets[i].symbols) {
20
- if ((0, utils_3.normalizeStructTag)(symbol.name) == target) {
19
+ if ((0, utils_2.normalizeStructTag)(symbol.name) == target) {
21
20
  return i;
22
21
  }
23
22
  }
@@ -34,24 +33,19 @@ async function createTradingOrder(client, tx, input) {
34
33
  let suiCoin;
35
34
  if (TOKEN == "SUI" && client.config.sponsored) {
36
35
  // split together
37
- [coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
36
+ [coin, suiCoin] = (0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
38
37
  }
39
38
  else if (client.config.sponsored) {
40
- coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
41
- suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
39
+ coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
40
+ suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
42
41
  }
43
42
  else {
44
- coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
43
+ coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
45
44
  // no suiCoin
46
45
  }
47
- const tokensWithoutTypus = Array.from(new Set([TOKEN])).filter((token) => token !== "TYPUS");
48
- await (0, utils_2.updatePyth)(client.pythClient, tx, tokensWithoutTypus, suiCoin);
49
- for (let token of tokensWithoutTypus) {
50
- (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
51
- }
52
- if (tokens.includes("TYPUS")) {
53
- const oracleContract = input.oracleContract ?? "0x51fc5517f5ba4e3ba8862cd74c345e7294193c693ab41376694d1c516033e2e8";
54
- tx = await (0, utils_1.updateOracleWithSignatureTx)(__1.NETWORK, tx, oracleContract, constants_1.tokenType[__1.NETWORK]["TYPUS"]);
46
+ await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
47
+ for (let token of tokens) {
48
+ (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
55
49
  }
56
50
  tx.add((0, trading_1.createTradingOrder)({
57
51
  arguments: {
@@ -59,7 +53,7 @@ async function createTradingOrder(client, tx, input) {
59
53
  registry: __1.MARKET,
60
54
  poolRegistry: __1.LP_POOL,
61
55
  marketIndex: BigInt(input.perpIndex),
62
- poolIndex: BigInt(input.poolIndex),
56
+ poolIndex: BigInt(input.perpIndex),
63
57
  typusOracleCToken: constants_1.oracle[__1.NETWORK][TOKEN],
64
58
  typusOracleTradingSymbol: constants_1.oracle[__1.NETWORK][BASE_TOKEN],
65
59
  collateral: coin,
@@ -110,19 +104,19 @@ async function increaseCollateral(client, tx, input) {
110
104
  let suiCoin;
111
105
  if (TOKEN == "SUI" && client.config.sponsored) {
112
106
  // split together
113
- [coin, suiCoin] = (0, utils_2.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
107
+ [coin, suiCoin] = (0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, input.coins, [input.amount, tokens.length.toString()], client.config.sponsored);
114
108
  }
115
109
  else if (client.config.sponsored) {
116
- coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
117
- suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
110
+ coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
111
+ suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
118
112
  }
119
113
  else {
120
- coin = (0, utils_2.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
114
+ coin = (0, utils_1.splitCoin)(tx, cToken, input.coins, input.amount, client.config.sponsored);
121
115
  // no suiCoin
122
116
  }
123
- await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
117
+ await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
124
118
  for (let token of tokens) {
125
- (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
119
+ (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
126
120
  }
127
121
  // @ts-ignore
128
122
  let marketIndex = BigInt(input.position.marketIndex);
@@ -149,11 +143,11 @@ async function releaseCollateral(client, tx, input) {
149
143
  let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
150
144
  let suiCoin;
151
145
  if (client.config.sponsored) {
152
- suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
146
+ suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
153
147
  }
154
- await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
148
+ await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
155
149
  for (let token of tokens) {
156
- (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
150
+ (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
157
151
  }
158
152
  let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
159
153
  let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
@@ -183,11 +177,11 @@ async function collectPositionFundingFee(client, tx, input) {
183
177
  let tokens = Array.from(new Set([TOKEN, BASE_TOKEN]));
184
178
  let suiCoin;
185
179
  if (client.config.sponsored) {
186
- suiCoin = (0, utils_2.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
180
+ suiCoin = (0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, input.suiCoins, tokens.length.toString(), client.config.sponsored);
187
181
  }
188
- await (0, utils_2.updatePyth)(client.pythClient, tx, tokens, suiCoin);
182
+ await (0, utils_1.updatePyth)(client.pythClient, tx, tokens, suiCoin);
189
183
  for (let token of tokens) {
190
- (0, utils_2.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
184
+ (0, utils_1.updateOracleWithPythUsd)(client.pythClient, tx, client.config.package.oracle, token);
191
185
  }
192
186
  let cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
193
187
  let baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.1.32-codegen-exp15-profit-vault",
3
+ "version": "1.1.32-codegen-exp16",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",
@@ -8,7 +8,7 @@
8
8
  "dependencies": {
9
9
  "@mysten/bcs": "1.9.2",
10
10
  "@mysten/sui": "1.44.0",
11
- "@typus/typus-sdk": "1.8.31"
11
+ "@typus/typus-sdk": "1.8.30"
12
12
  },
13
13
  "resolutions": {
14
14
  "@mysten/bcs": "1.9.2",