@typus/typus-sdk 1.4.19 → 1.4.21

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 (51) hide show
  1. package/dist/src/auto-bid/index.d.ts +1 -0
  2. package/dist/src/auto-bid/index.js +1 -0
  3. package/dist/src/auto-bid/token-user-entry.d.ts +46 -8
  4. package/dist/src/auto-bid/token-user-entry.js +117 -74
  5. package/dist/src/auto-bid/user-entry.d.ts +42 -8
  6. package/dist/src/auto-bid/user-entry.js +92 -93
  7. package/dist/src/auto-bid/view-function.d.ts +8 -5
  8. package/dist/src/auto-bid/view-function.js +26 -15
  9. package/dist/src/constants/constant.d.ts +1 -0
  10. package/dist/src/constants/constant.js +2 -1
  11. package/dist/src/dice/api.d.ts +13 -1
  12. package/dist/src/dice/api.js +25 -14
  13. package/dist/src/dice/fetch.d.ts +8 -12
  14. package/dist/src/dice/fetch.js +77 -30
  15. package/dist/src/dice/user-entry.d.ts +29 -17
  16. package/dist/src/dice/user-entry.js +114 -79
  17. package/dist/src/dice/view-function.d.ts +14 -1
  18. package/dist/src/dice/view-function.js +34 -25
  19. package/dist/src/typus/airdrop/view-function.d.ts +1 -2
  20. package/dist/src/typus/airdrop/view-function.js +6 -3
  21. package/dist/src/typus/leaderboard/view-function.d.ts +1 -2
  22. package/dist/src/typus/leaderboard/view-function.js +6 -3
  23. package/dist/src/typus/tails-staking/authority-entry.js +2 -2
  24. package/dist/src/typus/tails-staking/view-function.d.ts +2 -3
  25. package/dist/src/typus/tails-staking/view-function.js +10 -6
  26. package/dist/src/typus/user/view-function.d.ts +1 -2
  27. package/dist/src/typus/user/view-function.js +6 -4
  28. package/dist/src/typus-dov-single-v2/authority-entry.d.ts +0 -25
  29. package/dist/src/typus-dov-single-v2/authority-entry.js +26 -0
  30. package/dist/src/typus-dov-single-v2/function/bidding.d.ts +5 -3
  31. package/dist/src/typus-dov-single-v2/function/bidding.js +17 -14
  32. package/dist/src/typus-dov-single-v2/history/vault-history.d.ts +3 -2
  33. package/dist/src/typus-dov-single-v2/history/vault-history.js +6 -4
  34. package/dist/src/typus-dov-single-v2/token-user-entry.js +10 -10
  35. package/dist/src/typus-dov-single-v2/view-function.d.ts +6 -7
  36. package/dist/src/typus-dov-single-v2/view-function.js +26 -19
  37. package/dist/src/typus-nft/user-entry.d.ts +25 -6
  38. package/dist/src/typus-nft/user-entry.js +24 -36
  39. package/dist/src/typus-perp/fetch.d.ts +7 -8
  40. package/dist/src/typus-perp/fetch.js +35 -24
  41. package/dist/src/typus-perp/user/order.d.ts +4 -11
  42. package/dist/src/typus-perp/user/order.js +23 -23
  43. package/dist/src/typus-perp/user/orderWithBidReceipt.d.ts +9 -9
  44. package/dist/src/typus-perp/user/orderWithBidReceipt.js +50 -49
  45. package/dist/src/typus-perp/user/tlp.d.ts +5 -13
  46. package/dist/src/typus-perp/user/tlp.js +30 -30
  47. package/dist/src/typus-safu/user-entry.d.ts +4 -8
  48. package/dist/src/typus-safu/user-entry.js +56 -56
  49. package/dist/src/typus-safu/view-function.d.ts +0 -3
  50. package/dist/src/typus-safu/view-function.js +10 -7
  51. package/package.json +1 -1
@@ -4,15 +4,14 @@ import { Markets, SymbolMarket } from "./trading/structs";
4
4
  import { TradingOrder, Position } from "./position/structs";
5
5
  import { LpUserShare, StakePool } from "./stake-pool/structs";
6
6
  import { PythClient, TypusConfig } from "../utils";
7
- export declare function getLpPools(provider: SuiClient, config: TypusConfig): Promise<LiquidityPool[]>;
8
- export declare function getStakePools(provider: SuiClient, config: TypusConfig): Promise<StakePool[]>;
9
- export declare function getMarkets(provider: SuiClient, config: TypusConfig): Promise<Markets[]>;
7
+ export declare function getLpPools(config: TypusConfig): Promise<LiquidityPool[]>;
8
+ export declare function getStakePools(config: TypusConfig): Promise<StakePool[]>;
9
+ export declare function getMarkets(config: TypusConfig): Promise<Markets[]>;
10
10
  export declare function getSymbolMarkets(provider: SuiClient, market: Markets): Promise<Map<string, SymbolMarket>>;
11
- export declare function getUserOrders(provider: SuiClient, config: TypusConfig, user: string): Promise<TradingOrder[]>;
12
- export declare function getUserPositions(provider: SuiClient, config: TypusConfig, user: string): Promise<Position[]>;
13
- export declare function getUserStake(provider: SuiClient, config: TypusConfig, user: string): Promise<LpUserShare[]>;
14
- export declare function getLiquidationPrice(provider: SuiClient, config: TypusConfig, input: {
15
- pythClient: PythClient;
11
+ export declare function getUserOrders(config: TypusConfig, user: string): Promise<TradingOrder[]>;
12
+ export declare function getUserPositions(config: TypusConfig, user: string): Promise<Position[]>;
13
+ export declare function getUserStake(config: TypusConfig, user: string): Promise<LpUserShare[]>;
14
+ export declare function getLiquidationPrice(config: TypusConfig, pythClient: PythClient, input: {
16
15
  positions: Position[];
17
16
  user: string;
18
17
  }): Promise<string[] | undefined>;
@@ -55,6 +55,7 @@ exports.getUserOrders = getUserOrders;
55
55
  exports.getUserPositions = getUserPositions;
56
56
  exports.getUserStake = getUserStake;
57
57
  exports.getLiquidationPrice = getLiquidationPrice;
58
+ var client_1 = require("@mysten/sui.js/client");
58
59
  var structs_1 = require("./lp-pool/structs");
59
60
  var structs_2 = require("./trading/structs");
60
61
  var functions_1 = require("./trading/functions");
@@ -67,15 +68,17 @@ var constants_2 = require("../constants");
67
68
  var utils_1 = require("../utils");
68
69
  var _1 = require(".");
69
70
  var bcs_1 = require("@mysten/bcs");
70
- function getLpPools(provider, config) {
71
+ function getLpPools(config) {
71
72
  return __awaiter(this, void 0, void 0, function () {
72
- var dynamicFields, lpPools, _a, _b, field, lpPool, e_1_1;
73
+ var provider, dynamicFields, lpPools, _a, _b, field, lpPool, e_1_1;
73
74
  var e_1, _c;
74
75
  return __generator(this, function (_d) {
75
76
  switch (_d.label) {
76
- case 0: return [4 /*yield*/, provider.getDynamicFields({
77
- parentId: config.registry.perp.liquidityPool,
78
- })];
77
+ case 0:
78
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
79
+ return [4 /*yield*/, provider.getDynamicFields({
80
+ parentId: config.registry.perp.liquidityPool,
81
+ })];
79
82
  case 1:
80
83
  dynamicFields = _d.sent();
81
84
  lpPools = [];
@@ -112,15 +115,17 @@ function getLpPools(provider, config) {
112
115
  });
113
116
  });
114
117
  }
115
- function getStakePools(provider, config) {
118
+ function getStakePools(config) {
116
119
  return __awaiter(this, void 0, void 0, function () {
117
- var dynamicFields, stakePools, _a, _b, field, stakePool, e_2_1;
120
+ var provider, dynamicFields, stakePools, _a, _b, field, stakePool, e_2_1;
118
121
  var e_2, _c;
119
122
  return __generator(this, function (_d) {
120
123
  switch (_d.label) {
121
- case 0: return [4 /*yield*/, provider.getDynamicFields({
122
- parentId: config.registry.perp.stakePool,
123
- })];
124
+ case 0:
125
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
126
+ return [4 /*yield*/, provider.getDynamicFields({
127
+ parentId: config.registry.perp.stakePool,
128
+ })];
124
129
  case 1:
125
130
  dynamicFields = _d.sent();
126
131
  stakePools = [];
@@ -157,15 +162,17 @@ function getStakePools(provider, config) {
157
162
  });
158
163
  });
159
164
  }
160
- function getMarkets(provider, config) {
165
+ function getMarkets(config) {
161
166
  return __awaiter(this, void 0, void 0, function () {
162
- var dynamicFields, markets, _a, _b, field, market, e_3_1;
167
+ var provider, dynamicFields, markets, _a, _b, field, market, e_3_1;
163
168
  var e_3, _c;
164
169
  return __generator(this, function (_d) {
165
170
  switch (_d.label) {
166
- case 0: return [4 /*yield*/, provider.getDynamicFields({
167
- parentId: config.registry.perp.market,
168
- })];
171
+ case 0:
172
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
173
+ return [4 /*yield*/, provider.getDynamicFields({
174
+ parentId: config.registry.perp.market,
175
+ })];
169
176
  case 1:
170
177
  dynamicFields = _d.sent();
171
178
  markets = [];
@@ -250,12 +257,13 @@ function getSymbolMarkets(provider, market) {
250
257
  });
251
258
  });
252
259
  }
253
- function getUserOrders(provider, config, user) {
260
+ function getUserOrders(config, user) {
254
261
  return __awaiter(this, void 0, void 0, function () {
255
- var tx, res, returnValues, orders;
262
+ var provider, tx, res, returnValues, orders;
256
263
  return __generator(this, function (_a) {
257
264
  switch (_a.label) {
258
265
  case 0:
266
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
259
267
  tx = new transactions_1.TransactionBlock();
260
268
  (0, functions_1.getUserOrders)(tx, {
261
269
  version: config.version.perp,
@@ -274,12 +282,13 @@ function getUserOrders(provider, config, user) {
274
282
  });
275
283
  });
276
284
  }
277
- function getUserPositions(provider, config, user) {
285
+ function getUserPositions(config, user) {
278
286
  return __awaiter(this, void 0, void 0, function () {
279
- var tx, res, returnValues, positions;
287
+ var provider, tx, res, returnValues, positions;
280
288
  return __generator(this, function (_a) {
281
289
  switch (_a.label) {
282
290
  case 0:
291
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
283
292
  tx = new transactions_1.TransactionBlock();
284
293
  (0, functions_1.getUserPositions)(tx, {
285
294
  version: config.version.perp,
@@ -298,12 +307,13 @@ function getUserPositions(provider, config, user) {
298
307
  });
299
308
  });
300
309
  }
301
- function getUserStake(provider, config, user) {
310
+ function getUserStake(config, user) {
302
311
  return __awaiter(this, void 0, void 0, function () {
303
- var tx, res, returnValues, stake;
312
+ var provider, tx, res, returnValues, stake;
304
313
  return __generator(this, function (_a) {
305
314
  switch (_a.label) {
306
315
  case 0:
316
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
307
317
  tx = new transactions_1.TransactionBlock();
308
318
  (0, functions_2.getUserShares)(tx, {
309
319
  registry: config.registry.perp.stakePool,
@@ -330,14 +340,15 @@ function getUserStake(provider, config, user) {
330
340
  });
331
341
  });
332
342
  }
333
- function getLiquidationPrice(provider, config, input) {
343
+ function getLiquidationPrice(config, pythClient, input) {
334
344
  return __awaiter(this, void 0, void 0, function () {
335
- var tx, pythTokens, _a, _b, position, TOKEN, BASE_TOKEN, _c, _d, position, TOKEN, BASE_TOKEN, cToken, baseToken, res, prices;
345
+ var provider, tx, pythTokens, _a, _b, position, TOKEN, BASE_TOKEN, _c, _d, position, TOKEN, BASE_TOKEN, cToken, baseToken, res, prices;
336
346
  var e_5, _e, e_6, _f;
337
347
  var _g;
338
348
  return __generator(this, function (_h) {
339
349
  switch (_h.label) {
340
350
  case 0:
351
+ provider = new client_1.SuiClient({ url: config.rpcEndpoint });
341
352
  tx = new transactions_1.TransactionBlock();
342
353
  pythTokens = [];
343
354
  try {
@@ -356,7 +367,7 @@ function getLiquidationPrice(provider, config, input) {
356
367
  }
357
368
  finally { if (e_5) throw e_5.error; }
358
369
  }
359
- return [4 /*yield*/, (0, utils_1.updatePyth)(input.pythClient, tx, Array.from(new Set(pythTokens)))];
370
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, Array.from(new Set(pythTokens)))];
360
371
  case 1:
361
372
  _h.sent();
362
373
  try {
@@ -2,9 +2,7 @@ import { Position, TradingOrder } from "../position/structs";
2
2
  import { PythClient, TypusConfig } from "../../utils";
3
3
  import { TOKEN } from "../../constants";
4
4
  import { TransactionBlock } from "@mysten/sui.js/transactions";
5
- export declare function createTradingOrder(config: TypusConfig, input: {
6
- pythClient: PythClient;
7
- tx: TransactionBlock;
5
+ export declare function createTradingOrder(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
8
6
  coins: string[];
9
7
  cToken: TOKEN;
10
8
  amount: string;
@@ -16,21 +14,16 @@ export declare function createTradingOrder(config: TypusConfig, input: {
16
14
  reduceOnly: boolean;
17
15
  linkedPositionId: string | null;
18
16
  }): Promise<TransactionBlock>;
19
- export declare function cancelTradingOrder(config: TypusConfig, input: {
20
- tx: TransactionBlock;
17
+ export declare function cancelTradingOrder(config: TypusConfig, tx: TransactionBlock, input: {
21
18
  order: TradingOrder;
22
19
  user: string;
23
20
  }): Promise<TransactionBlock>;
24
- export declare function increaseCollateral(config: TypusConfig, input: {
25
- pythClient: PythClient;
26
- tx: TransactionBlock;
21
+ export declare function increaseCollateral(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
27
22
  coins: string[];
28
23
  amount: string;
29
24
  position: Position;
30
25
  }): Promise<TransactionBlock>;
31
- export declare function releaseCollateral(config: TypusConfig, input: {
32
- pythClient: PythClient;
33
- tx: TransactionBlock;
26
+ export declare function releaseCollateral(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
34
27
  position: Position;
35
28
  amount: string;
36
29
  }): Promise<TransactionBlock>;
@@ -61,7 +61,7 @@ var constants_1 = require("../../constants");
61
61
  var __1 = require("..");
62
62
  var utils_1 = require("../../utils");
63
63
  var constants_2 = require("../../constants");
64
- function createTradingOrder(config, input) {
64
+ function createTradingOrder(config, tx, pythClient, input) {
65
65
  return __awaiter(this, void 0, void 0, function () {
66
66
  var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination;
67
67
  var _a, _b;
@@ -70,22 +70,22 @@ function createTradingOrder(config, input) {
70
70
  case 0:
71
71
  TOKEN = input.cToken;
72
72
  BASE_TOKEN = input.tradingToken;
73
- return [4 /*yield*/, (0, utils_1.updatePyth)(input.pythClient, input.tx, [TOKEN, BASE_TOKEN])];
73
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
74
74
  case 1:
75
75
  _c.sent();
76
76
  cToken = constants_2.tokenType[__1.NETWORK][TOKEN];
77
77
  baseToken = constants_2.tokenType[__1.NETWORK][BASE_TOKEN];
78
78
  if (TOKEN == "SUI") {
79
- _a = __read(input.tx.splitCoins(input.tx.gas, [input.amount]), 1), coin = _a[0];
79
+ _a = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _a[0];
80
80
  }
81
81
  else {
82
82
  destination = input.coins.pop();
83
83
  if (input.coins.length > 0) {
84
- input.tx.mergeCoins(destination, input.coins);
84
+ tx.mergeCoins(destination, input.coins);
85
85
  }
86
- _b = __read(input.tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
86
+ _b = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
87
87
  }
88
- (0, functions_1.createTradingOrder)(input.tx, [cToken, baseToken], {
88
+ (0, functions_1.createTradingOrder)(tx, [cToken, baseToken], {
89
89
  version: config.version.perp,
90
90
  registry: config.registry.perp.market,
91
91
  poolRegistry: config.registry.perp.lpPool,
@@ -106,30 +106,30 @@ function createTradingOrder(config, input) {
106
106
  reduceOnly: input.reduceOnly,
107
107
  linkedPositionId: input.linkedPositionId ? BigInt(input.linkedPositionId) : null,
108
108
  });
109
- return [2 /*return*/, input.tx];
109
+ return [2 /*return*/, tx];
110
110
  }
111
111
  });
112
112
  });
113
113
  }
114
- function cancelTradingOrder(config, input) {
114
+ function cancelTradingOrder(config, tx, input) {
115
115
  return __awaiter(this, void 0, void 0, function () {
116
116
  var cToken, BASE_TOKEN, coin;
117
117
  return __generator(this, function (_a) {
118
118
  cToken = "0x" + input.order.collateralToken.name;
119
119
  BASE_TOKEN = "0x" + input.order.symbol.baseToken.name;
120
- coin = (0, functions_1.cancelTradingOrder)(input.tx, [cToken, BASE_TOKEN], {
120
+ coin = (0, functions_1.cancelTradingOrder)(tx, [cToken, BASE_TOKEN], {
121
121
  version: config.version.perp,
122
122
  registry: config.registry.perp.market,
123
123
  marketIndex: BigInt(0),
124
124
  orderId: input.order.orderId,
125
125
  triggerPrice: input.order.triggerPrice,
126
126
  });
127
- input.tx.transferObjects([coin], input.user);
128
- return [2 /*return*/, input.tx];
127
+ tx.transferObjects([coin], input.user);
128
+ return [2 /*return*/, tx];
129
129
  });
130
130
  });
131
131
  }
132
- function increaseCollateral(config, input) {
132
+ function increaseCollateral(config, tx, pythClient, input) {
133
133
  return __awaiter(this, void 0, void 0, function () {
134
134
  var TOKEN, BASE_TOKEN, cToken, baseToken, coin, destination;
135
135
  var _a, _b;
@@ -138,22 +138,22 @@ function increaseCollateral(config, input) {
138
138
  case 0:
139
139
  TOKEN = (0, constants_2.typeArgToToken)(input.position.collateralToken.name);
140
140
  BASE_TOKEN = (0, constants_2.typeArgToToken)(input.position.symbol.baseToken.name);
141
- return [4 /*yield*/, (0, utils_1.updatePyth)(input.pythClient, input.tx, [TOKEN, BASE_TOKEN])];
141
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
142
142
  case 1:
143
143
  _c.sent();
144
144
  cToken = constants_2.tokenType[__1.NETWORK][TOKEN];
145
145
  baseToken = constants_2.tokenType[__1.NETWORK][BASE_TOKEN];
146
146
  if (TOKEN == "SUI") {
147
- _a = __read(input.tx.splitCoins(input.tx.gas, [input.amount]), 1), coin = _a[0];
147
+ _a = __read(tx.splitCoins(tx.gas, [input.amount]), 1), coin = _a[0];
148
148
  }
149
149
  else {
150
150
  destination = input.coins.pop();
151
151
  if (input.coins.length > 0) {
152
- input.tx.mergeCoins(destination, input.coins);
152
+ tx.mergeCoins(destination, input.coins);
153
153
  }
154
- _b = __read(input.tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
154
+ _b = __read(tx.splitCoins(destination, [input.amount]), 1), coin = _b[0];
155
155
  }
156
- (0, functions_1.increaseCollateral)(input.tx, [cToken, baseToken], {
156
+ (0, functions_1.increaseCollateral)(tx, [cToken, baseToken], {
157
157
  version: config.version.perp,
158
158
  registry: config.registry.perp.market,
159
159
  poolRegistry: config.registry.perp.lpPool,
@@ -166,12 +166,12 @@ function increaseCollateral(config, input) {
166
166
  positionId: BigInt(input.position.positionId),
167
167
  collateral: coin,
168
168
  });
169
- return [2 /*return*/, input.tx];
169
+ return [2 /*return*/, tx];
170
170
  }
171
171
  });
172
172
  });
173
173
  }
174
- function releaseCollateral(config, input) {
174
+ function releaseCollateral(config, tx, pythClient, input) {
175
175
  return __awaiter(this, void 0, void 0, function () {
176
176
  var TOKEN, BASE_TOKEN, cToken, baseToken, coin;
177
177
  return __generator(this, function (_a) {
@@ -179,12 +179,12 @@ function releaseCollateral(config, input) {
179
179
  case 0:
180
180
  TOKEN = (0, constants_2.typeArgToToken)(input.position.collateralToken.name);
181
181
  BASE_TOKEN = (0, constants_2.typeArgToToken)(input.position.symbol.baseToken.name);
182
- return [4 /*yield*/, (0, utils_1.updatePyth)(input.pythClient, input.tx, [TOKEN, BASE_TOKEN])];
182
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
183
183
  case 1:
184
184
  _a.sent();
185
185
  cToken = constants_2.tokenType[__1.NETWORK][TOKEN];
186
186
  baseToken = constants_2.tokenType[__1.NETWORK][BASE_TOKEN];
187
- coin = (0, functions_1.releaseCollateral)(input.tx, [cToken, baseToken], {
187
+ coin = (0, functions_1.releaseCollateral)(tx, [cToken, baseToken], {
188
188
  version: config.version.perp,
189
189
  registry: config.registry.perp.market,
190
190
  poolRegistry: config.registry.perp.lpPool,
@@ -197,8 +197,8 @@ function releaseCollateral(config, input) {
197
197
  positionId: BigInt(input.position.positionId),
198
198
  releaseAmount: BigInt(input.amount),
199
199
  });
200
- input.tx.transferObjects([coin], input.position.user);
201
- return [2 /*return*/, input.tx];
200
+ tx.transferObjects([coin], input.position.user);
201
+ return [2 /*return*/, tx];
202
202
  }
203
203
  });
204
204
  });
@@ -1,10 +1,7 @@
1
1
  import { TransactionBlock } from "@mysten/sui.js/transactions";
2
2
  import { PythClient, TypusConfig } from "../../utils";
3
3
  import { TOKEN } from "../../constants";
4
- import { Position } from "../position/structs";
5
- export declare function createTradingOrderWithBidReceipt(config: TypusConfig, input: {
6
- pythClient: PythClient;
7
- tx: TransactionBlock;
4
+ export declare function createTradingOrderWithBidReceipt(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
8
5
  cToken: TOKEN;
9
6
  tradingToken: TOKEN;
10
7
  isLong: boolean;
@@ -14,9 +11,12 @@ export declare function createTradingOrderWithBidReceipt(config: TypusConfig, in
14
11
  bidReceipt: string;
15
12
  share: string | null;
16
13
  }): Promise<TransactionBlock>;
17
- export declare function reduceOptionCollateralPositionSize(config: TypusConfig, input: {
18
- pythClient: PythClient;
19
- tx: TransactionBlock;
20
- position: Position;
21
- size: string | null;
14
+ export declare function reduceOptionCollateralPositionSize(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
15
+ cToken: TOKEN;
16
+ tradingToken: TOKEN;
17
+ bToken: string;
18
+ share: string | null;
19
+ index: string;
20
+ user: string;
21
+ bidReceipt: string;
22
22
  }): Promise<TransactionBlock>;
@@ -43,7 +43,7 @@ var utils_1 = require("../../utils");
43
43
  var constants_1 = require("../../constants");
44
44
  var __1 = require("..");
45
45
  var typus_dov_single_v2_1 = require("../../typus-dov-single-v2/");
46
- function createTradingOrderWithBidReceipt(config, input) {
46
+ function createTradingOrderWithBidReceipt(config, tx, pythClient, input) {
47
47
  return __awaiter(this, void 0, void 0, function () {
48
48
  var TOKEN, BASE_TOKEN, cToken, bToken, baseToken, collateralBidReceipt;
49
49
  return __generator(this, function (_a) {
@@ -51,15 +51,15 @@ function createTradingOrderWithBidReceipt(config, input) {
51
51
  case 0:
52
52
  TOKEN = input.cToken;
53
53
  BASE_TOKEN = input.tradingToken;
54
- return [4 /*yield*/, (0, utils_1.updatePyth)(input.pythClient, input.tx, [TOKEN, BASE_TOKEN])];
54
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
55
55
  case 1:
56
56
  _a.sent();
57
57
  cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
58
58
  bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
59
59
  baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
60
- (0, utils_1.updateOracleWithPyth)(input.pythClient, input.tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "USDC");
60
+ (0, utils_1.updateOracleWithPyth)(pythClient, tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "USDC");
61
61
  if (input.share) {
62
- collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, input.tx, {
62
+ collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, tx, {
63
63
  index: input.index,
64
64
  receipts: [input.bidReceipt],
65
65
  share: input.share,
@@ -69,7 +69,7 @@ function createTradingOrderWithBidReceipt(config, input) {
69
69
  else {
70
70
  collateralBidReceipt = input.bidReceipt;
71
71
  }
72
- (0, functions_1.createTradingOrderWithBidReceipt)(input.tx, [cToken, bToken, baseToken], {
72
+ (0, functions_1.createTradingOrderWithBidReceipt)(tx, [cToken, bToken, baseToken], {
73
73
  version: config.version.perp,
74
74
  registry: config.registry.perp.market,
75
75
  poolRegistry: config.registry.perp.lpPool,
@@ -88,56 +88,57 @@ function createTradingOrderWithBidReceipt(config, input) {
88
88
  collateralBidReceipt: collateralBidReceipt,
89
89
  user: input.user,
90
90
  });
91
- return [2 /*return*/, input.tx];
91
+ return [2 /*return*/, tx];
92
92
  }
93
93
  });
94
94
  });
95
95
  }
96
- function reduceOptionCollateralPositionSize(config, input) {
96
+ function reduceOptionCollateralPositionSize(config, tx, pythClient, input) {
97
97
  return __awaiter(this, void 0, void 0, function () {
98
+ var TOKEN, BASE_TOKEN, cToken, bToken, baseToken, collateralBidReceipt;
98
99
  return __generator(this, function (_a) {
99
- // const TOKEN = input.cToken;
100
- // const BASE_TOKEN = input.tradingToken;
101
- // await updatePyth(input.pythClient, input.tx, [TOKEN, BASE_TOKEN]);
102
- // const cToken = tokenType[NETWORK][TOKEN];
103
- // const bToken = tokenType[NETWORK][input.bToken];
104
- // const baseToken = tokenType[NETWORK][BASE_TOKEN];
105
- // updateOracleWithPyth(input.pythClient, input.tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "USDC");
106
- // // split bid receipt
107
- // var collateralBidReceipt;
108
- // if (input.share) {
109
- // collateralBidReceipt = getSplitBidReceiptTx({
110
- // tx: input.tx,
111
- // typusFrameworkOriginPackageId: config.packageOrigin.framework,
112
- // typusDovSinglePackageId: config.package.dovSingle,
113
- // typusDovSingleRegistry: config.registry.dov.dovSingle,
114
- // index: input.index,
115
- // receipts: [input.bidReceipt],
116
- // share: input.share,
117
- // recipient: input.user,
118
- // });
119
- // } else {
120
- // collateralBidReceipt = input.bidReceipt;
121
- // }
122
- // _reduceOptionCollateralPositionSize(input.tx, [cToken, bToken, baseToken], {
123
- // version: config.version.perp,
124
- // registry: config.registry.perp.market,
125
- // poolRegistry: config.registry.perp.lpPool,
126
- // marketIndex: BigInt(0),
127
- // poolIndex: BigInt(0),
128
- // pythState: pythStateId[NETWORK],
129
- // oracleCToken: priceInfoObjectIds[NETWORK][TOKEN],
130
- // oracleTradingSymbol: priceInfoObjectIds[NETWORK][BASE_TOKEN],
131
- // clock: CLOCK,
132
- // typusEcosystemVersion: config.version.typus,
133
- // typusUserRegistry: config.registry.typus.user,
134
- // typusLeaderboardRegistry: config.registry.typus.leaderboard,
135
- // dovRegistry: config.registry.dov.dovSingle,
136
- // typusOracle: config.oracle[BASE_TOKEN.toLocaleLowerCase()],
137
- // positionId: BigInt(123),
138
- // orderSize: null,
139
- // });
140
- return [2 /*return*/, input.tx];
100
+ switch (_a.label) {
101
+ case 0:
102
+ TOKEN = input.cToken;
103
+ BASE_TOKEN = input.tradingToken;
104
+ return [4 /*yield*/, (0, utils_1.updatePyth)(pythClient, tx, [TOKEN, BASE_TOKEN])];
105
+ case 1:
106
+ _a.sent();
107
+ cToken = constants_1.tokenType[__1.NETWORK][TOKEN];
108
+ bToken = constants_1.tokenType[__1.NETWORK][input.bToken];
109
+ baseToken = constants_1.tokenType[__1.NETWORK][BASE_TOKEN];
110
+ (0, utils_1.updateOracleWithPyth)(pythClient, tx, config.package.oracle, config.oracle[BASE_TOKEN.toLocaleLowerCase()], BASE_TOKEN, "USDC");
111
+ if (input.share) {
112
+ collateralBidReceipt = (0, typus_dov_single_v2_1.getSplitBidReceiptTx)(config, tx, {
113
+ index: input.index,
114
+ receipts: [input.bidReceipt],
115
+ share: input.share,
116
+ recipient: input.user,
117
+ });
118
+ }
119
+ else {
120
+ collateralBidReceipt = input.bidReceipt;
121
+ }
122
+ (0, functions_1.reduceOptionCollateralPositionSize)(tx, [cToken, bToken, baseToken], {
123
+ version: config.version.perp,
124
+ registry: config.registry.perp.market,
125
+ poolRegistry: config.registry.perp.lpPool,
126
+ marketIndex: BigInt(0),
127
+ poolIndex: BigInt(0),
128
+ pythState: utils_1.pythStateId[__1.NETWORK],
129
+ oracleCToken: utils_1.priceInfoObjectIds[__1.NETWORK][TOKEN],
130
+ oracleTradingSymbol: utils_1.priceInfoObjectIds[__1.NETWORK][BASE_TOKEN],
131
+ clock: constants_1.CLOCK,
132
+ typusEcosystemVersion: config.version.typus,
133
+ typusUserRegistry: config.registry.typus.user,
134
+ typusLeaderboardRegistry: config.registry.typus.leaderboard,
135
+ dovRegistry: config.registry.dov.dovSingle,
136
+ typusOracle: config.oracle[BASE_TOKEN.toLocaleLowerCase()],
137
+ positionId: BigInt(123),
138
+ orderSize: null,
139
+ });
140
+ return [2 /*return*/, tx];
141
+ }
141
142
  });
142
143
  });
143
144
  }
@@ -2,39 +2,31 @@ import { TransactionBlock } from "@mysten/sui.js/transactions";
2
2
  import { LiquidityPool } from "../lp-pool/structs";
3
3
  import { PythClient, TypusConfig } from "../../utils";
4
4
  import { TOKEN } from "../../constants";
5
- export declare function mintStakeLp(config: TypusConfig, input: {
6
- pythClient: PythClient;
7
- tx: TransactionBlock;
5
+ export declare function mintStakeLp(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
8
6
  lpPool: LiquidityPool;
9
7
  coins: string[];
10
8
  cTOKEN: TOKEN;
11
9
  amount: string;
12
10
  userShareId: string | null;
13
11
  }): Promise<TransactionBlock>;
14
- export declare function unstakeBurn(config: TypusConfig, input: {
15
- pythClient: PythClient;
16
- tx: TransactionBlock;
12
+ export declare function unstakeBurn(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
17
13
  lpPool: LiquidityPool;
18
14
  cTOKEN: TOKEN;
19
15
  userShareId: string;
20
16
  share: string | null;
21
17
  user: string;
22
18
  }): Promise<TransactionBlock>;
23
- export declare function swap(config: TypusConfig, input: {
24
- pythClient: PythClient;
25
- tx: TransactionBlock;
19
+ export declare function swap(config: TypusConfig, tx: TransactionBlock, pythClient: PythClient, input: {
26
20
  coins: string[];
27
21
  FROM_TOKEN: TOKEN;
28
22
  TO_TOKEN: TOKEN;
29
23
  amount: string;
30
24
  user: string;
31
25
  }): Promise<TransactionBlock>;
32
- export declare function unsubscribe(config: TypusConfig, input: {
33
- tx: TransactionBlock;
26
+ export declare function unsubscribe(config: TypusConfig, tx: TransactionBlock, input: {
34
27
  userShareId: string;
35
28
  share: string | null;
36
29
  }): Promise<TransactionBlock>;
37
- export declare function harvest(config: TypusConfig, input: {
38
- tx: TransactionBlock;
30
+ export declare function harvest(config: TypusConfig, tx: TransactionBlock, input: {
39
31
  userShareId: string;
40
32
  }): Promise<TransactionBlock>;