@typus/typus-sdk 1.7.15 → 1.7.17

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.
@@ -35,7 +35,7 @@ var utils_1 = require("../../src/utils");
35
35
  )
36
36
  */
37
37
  function getNewStrategyTx(config, tx, input) {
38
- var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
38
+ var input_coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
39
39
  tx.moveCall({
40
40
  target: "".concat(config.package.dovSingle, "::auto_bid::new_strategy"),
41
41
  typeArguments: input.typeArguments,
@@ -107,7 +107,7 @@ function getWithdrawProfitStrategyTx(config, tx, input) {
107
107
  )
108
108
  */
109
109
  function getUpdateStrategyTx(config, tx, input) {
110
- var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
110
+ var input_coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
111
111
  tx.moveCall({
112
112
  target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
113
113
  typeArguments: input.typeArguments,
@@ -83,7 +83,7 @@ function newGameTx(config, tx, input) {
83
83
  default:
84
84
  break;
85
85
  }
86
- coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
86
+ coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
87
87
  tx.moveCall({
88
88
  target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
89
89
  typeArguments: input.typeArguments,
@@ -151,7 +151,7 @@ function newGamePlayGuessTx(config, tx, input) {
151
151
  default:
152
152
  break;
153
153
  }
154
- coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
154
+ coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
155
155
  tx.moveCall({
156
156
  target: "".concat(config.package.dice, "::").concat(input.module, "::new_game"),
157
157
  typeArguments: input.typeArguments,
@@ -234,7 +234,7 @@ function playTx(config, tx, input) {
234
234
  default:
235
235
  break;
236
236
  }
237
- coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount, false);
237
+ coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount, false);
238
238
  tx.moveCall({
239
239
  target: "".concat(config.package.dice, "::").concat(input.module, "::play"),
240
240
  typeArguments: input.typeArguments,
@@ -81,7 +81,7 @@ function getSetAirdropTx(config, tx, input) {
81
81
  return __awaiter(this, void 0, void 0, function () {
82
82
  var coin;
83
83
  return __generator(this, function (_a) {
84
- coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
84
+ coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
85
85
  tx.moveCall({
86
86
  target: "".concat(config.package.typus, "::airdrop::set_airdrop"),
87
87
  typeArguments: input.typeArguments,
@@ -119,7 +119,7 @@ function getUpdateConfigTx(config, tx, requests) {
119
119
  ) {
120
120
  */
121
121
  function depositCollateralNavi(config, tx, input) {
122
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
122
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
123
123
  tx.moveCall({
124
124
  target: "".concat(config.package.dovSingle, "::tds_authorized_entry::deposit_collateral_navi"),
125
125
  typeArguments: input.typeArguments,
@@ -108,7 +108,7 @@ function otc(config, tx, input) {
108
108
  return __awaiter(this, void 0, void 0, function () {
109
109
  var coin, balance;
110
110
  return __generator(this, function (_a) {
111
- coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
111
+ coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
112
112
  balance = tx.moveCall({
113
113
  target: "0x2::coin::into_balance",
114
114
  typeArguments: [input.typeArguments[1]],
@@ -29,7 +29,7 @@ var utils_1 = require("../../src/utils");
29
29
  ): (TypusDepositReceipt, vector<u64>) {
30
30
  */
31
31
  function getRaiseFundTx(config, tx, input) {
32
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
32
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
33
33
  var raiseBalance = tx.moveCall({
34
34
  target: "0x2::coin::into_balance",
35
35
  typeArguments: [input.typeArguments[0]],
@@ -160,7 +160,7 @@ function getRefreshDepositSnapshotTx(config, tx, input) {
160
160
  )
161
161
  */
162
162
  function getNewBidTx(config, tx, input) {
163
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.premium_required, config.sponsored);
163
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[1], input.coins, input.premium_required, config.sponsored);
164
164
  var result = tx.moveCall({
165
165
  target: "".concat(config.package.dovSingle, "::tds_user_entry::public_bid"),
166
166
  typeArguments: input.typeArguments,
@@ -40,8 +40,8 @@ var utils_2 = require("../../src/utils");
40
40
  ) {
41
41
  */
42
42
  function raiseFund(config, tx, input) {
43
- var mainCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[0], input.raiseMainCoins, input.raiseMainAmount, config.sponsored);
44
- var hedgeCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount, config.sponsored);
43
+ var mainCoin = (0, utils_2.splitCoin)(tx, input.typeArguments[0], input.raiseMainCoins, input.raiseMainAmount, config.sponsored);
44
+ var hedgeCoin = (0, utils_2.splitCoin)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount, config.sponsored);
45
45
  var mainBalance = tx.moveCall({
46
46
  target: "0x2::coin::into_balance",
47
47
  typeArguments: [input.typeArguments[0]],
@@ -60,7 +60,7 @@ function setAirdrop(config, tx, input) {
60
60
  tx.object(config.version.launch.airdrop),
61
61
  tx.object(config.registry.launch.airdrop),
62
62
  tx.pure.string(input.key),
63
- tx.object((0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount)),
63
+ tx.object((0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount)),
64
64
  tx.pure.vector("address", input.users),
65
65
  tx.pure.vector("u64", input.values),
66
66
  ],
@@ -144,7 +144,7 @@ function withdrawFundFromDeepbookBalanceManager(config, tx, input) {
144
144
  ) {
145
145
  */
146
146
  function depositToDeepbookBalanceManager(config, tx, input) {
147
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
147
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
148
148
  tx.moveCall({
149
149
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::deposit_to_deepbook_balance_manager"),
150
150
  typeArguments: input.typeArguments,
@@ -189,7 +189,7 @@ function withdrawFromDeepbookBalanceManager(config, tx, input) {
189
189
  ) {
190
190
  */
191
191
  function increaseFund(config, tx, input) {
192
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
192
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
193
193
  tx.moveCall({
194
194
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::increase_fund"),
195
195
  typeArguments: input.typeArguments,
@@ -15,7 +15,7 @@ var utils_1 = require("../../../src/utils");
15
15
  ) {
16
16
  */
17
17
  function raiseFund(config, tx, input) {
18
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
18
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.coins, input.amount);
19
19
  tx.moveCall({
20
20
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::raise_fund"),
21
21
  typeArguments: input.typeArguments,
@@ -23,7 +23,7 @@ var utils_1 = require("../../src/utils");
23
23
  ) {
24
24
  */
25
25
  function getRaiseFundTx(config, tx, input) {
26
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
26
+ var coin = (0, utils_1.splitCoin)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
27
27
  var raiseBalance = tx.moveCall({
28
28
  target: "0x2::coin::into_balance",
29
29
  typeArguments: [input.typeArguments[0]],
@@ -79,7 +79,7 @@ function getReduceFundTx(config, tx, input) {
79
79
  tx.pure.u64(input.reduceFromWarmup),
80
80
  tx.pure.u64(input.reduceFromActive),
81
81
  tx.pure.u64(input.reduceFromInactive),
82
- tx.object((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, [], input.feeAmount, config.sponsored)),
82
+ tx.object((0, utils_1.splitCoin)(tx, constants_1.tokenType.MAINNET.SUI, [], input.feeAmount, config.sponsored)),
83
83
  tx.object(constants_1.CLOCK),
84
84
  ],
85
85
  });
@@ -105,6 +105,9 @@ function updatePriceFeeds(pythClient, tx, updates, feedIds, suiCoin) {
105
105
  case 3:
106
106
  baseUpdateFee = _a.sent();
107
107
  coins = tx.splitCoins(suiCoin !== null && suiCoin !== void 0 ? suiCoin : tx.gas, feedIds.map(function () { return tx.pure.u64(baseUpdateFee); }));
108
+ if (suiCoin) {
109
+ tx.moveCall({ target: "0x2::coin::destroy_zero", arguments: [suiCoin], typeArguments: [constants_1.tokenType.MAINNET.SUI] });
110
+ }
108
111
  return [4 /*yield*/, pythClient.client.executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins)];
109
112
  case 4: return [2 /*return*/, _a.sent()];
110
113
  }
@@ -7,8 +7,12 @@ export declare function AddressFromBytes(x: any): string;
7
7
  export declare const insertAt: (str: string, sub: string, pos: number) => string;
8
8
  export declare const checkNumber: (str: any) => boolean;
9
9
  export declare const countFloating: (value: number | BigNumber) => number;
10
- export declare function splitCoins(tx: Transaction, token: string, coins: string[], amount: string, sponsored?: boolean): {
10
+ export declare function splitCoin(tx: Transaction, token: string, coins: string[], amount: string, sponsored?: boolean): {
11
11
  $kind: "NestedResult";
12
12
  NestedResult: [number, number];
13
13
  };
14
+ export declare function splitCoins(tx: Transaction, token: string, coins: string[], amounts: string[], sponsored?: boolean): {
15
+ $kind: "NestedResult";
16
+ NestedResult: [number, number];
17
+ }[];
14
18
  export declare function getNumberStringWithDecimal(input: string, decimal: number): string;
@@ -22,6 +22,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.countFloating = exports.checkNumber = exports.insertAt = exports.prettify_big_number = exports.sleep = void 0;
23
23
  exports.U64FromBytes = U64FromBytes;
24
24
  exports.AddressFromBytes = AddressFromBytes;
25
+ exports.splitCoin = splitCoin;
25
26
  exports.splitCoins = splitCoins;
26
27
  exports.getNumberStringWithDecimal = getNumberStringWithDecimal;
27
28
  var utils_1 = require("@mysten/sui/utils");
@@ -69,30 +70,35 @@ var countFloating = function (value) {
69
70
  return num.split(".")[1].length;
70
71
  };
71
72
  exports.countFloating = countFloating;
72
- function splitCoins(tx, token, coins, amount, sponsored) {
73
- var _a, _b;
73
+ function splitCoin(tx, token, coins, amount, sponsored) {
74
74
  if (sponsored === void 0) { sponsored = false; }
75
- var coin;
75
+ var _a = __read(splitCoins(tx, token, coins, [amount], sponsored), 1), coin = _a[0];
76
+ return coin;
77
+ }
78
+ function splitCoins(tx, token, coins, amounts, sponsored) {
79
+ if (sponsored === void 0) { sponsored = false; }
80
+ var coinArgs;
76
81
  if (coins.length == 0) {
77
82
  // support zero coin input for closing position
78
- _a = __read(tx.moveCall({
83
+ coinArgs = tx.moveCall({
79
84
  target: "0x2::coin::zero",
80
85
  typeArguments: [token],
81
86
  arguments: [],
82
- }), 1), coin = _a[0];
87
+ });
83
88
  }
84
89
  else {
85
- _b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
86
- ? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
87
- : (function () {
88
- var coin = coins.pop();
89
- if (coins.length > 0) {
90
- tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
91
- }
92
- return tx.splitCoins(tx.object(coin), [tx.pure.u64(amount)]);
93
- })(), 1), coin = _b[0];
90
+ coinArgs =
91
+ (0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
92
+ ? tx.splitCoins(tx.gas, amounts.map(function (amount) { return tx.pure.u64(amount); }))
93
+ : (function () {
94
+ var coin = coins.pop();
95
+ if (coins.length > 0) {
96
+ tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
97
+ }
98
+ return tx.splitCoins(tx.object(coin), amounts.map(function (amount) { return tx.pure.u64(amount); }));
99
+ })();
94
100
  }
95
- return coin;
101
+ return coinArgs;
96
102
  }
97
103
  function getNumberStringWithDecimal(input, decimal) {
98
104
  input = input.padStart(decimal, "0");
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.7.15",
5
+ "version": "1.7.17",
6
6
  "resolutions": {
7
7
  "@mysten/sui": "1.30.0"
8
8
  },