@typus/typus-sdk 1.7.13 → 1.7.15

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.
@@ -20,6 +20,7 @@ exports.getNewStrategyTx = getNewStrategyTx;
20
20
  exports.getCloseStrategyTx = getCloseStrategyTx;
21
21
  exports.getWithdrawProfitStrategyTx = getWithdrawProfitStrategyTx;
22
22
  exports.getUpdateStrategyTx = getUpdateStrategyTx;
23
+ var utils_1 = require("../../src/utils");
23
24
  /**
24
25
  entry fun new_strategy<B_TOKEN>(
25
26
  strategy_pool: &mut StrategyPool,
@@ -34,49 +35,22 @@ exports.getUpdateStrategyTx = getUpdateStrategyTx;
34
35
  )
35
36
  */
36
37
  function getNewStrategyTx(config, tx, input) {
37
- if (
38
- // B_TOKEN
39
- input.typeArguments[1] == "0x2::sui::SUI" ||
40
- input.typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
41
- var _a = __read(tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)]), 1), input_coin = _a[0];
42
- tx.moveCall({
43
- target: "".concat(config.package.dovSingle, "::auto_bid::new_strategy"),
44
- typeArguments: input.typeArguments,
45
- arguments: [
46
- tx.object(config.registry.dov.dovSingle),
47
- tx.object(config.registry.dov.autoBid),
48
- tx.pure.u64(input.vaultIndex),
49
- tx.pure.u64(input.signalIndex),
50
- tx.pure.u64(input.size),
51
- tx.pure.u64(input.pricePercentage),
52
- tx.pure.u64(input.maxTimes),
53
- tx.pure.vector("u64", input.targetRounds),
54
- input_coin,
55
- ],
56
- });
57
- }
58
- else {
59
- var coin = input.coins.pop();
60
- if (input.coins.length > 0) {
61
- tx.mergeCoins(tx.object(coin), input.coins.map(function (coin) { return tx.object(coin); }));
62
- }
63
- var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure.u64(input.amount)]), 1), input_coin = _b[0];
64
- tx.moveCall({
65
- target: "".concat(config.package.dovSingle, "::auto_bid::new_strategy"),
66
- typeArguments: input.typeArguments,
67
- arguments: [
68
- tx.object(config.registry.dov.dovSingle),
69
- tx.object(config.registry.dov.autoBid),
70
- tx.pure.u64(input.vaultIndex),
71
- tx.pure.u64(input.signalIndex),
72
- tx.pure.u64(input.size),
73
- tx.pure.u64(input.pricePercentage),
74
- tx.pure.u64(input.maxTimes),
75
- tx.pure.vector("u64", input.targetRounds),
76
- input_coin,
77
- ],
78
- });
79
- }
38
+ var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
39
+ tx.moveCall({
40
+ target: "".concat(config.package.dovSingle, "::auto_bid::new_strategy"),
41
+ typeArguments: input.typeArguments,
42
+ arguments: [
43
+ tx.object(config.registry.dov.dovSingle),
44
+ tx.object(config.registry.dov.autoBid),
45
+ tx.pure.u64(input.vaultIndex),
46
+ tx.pure.u64(input.signalIndex),
47
+ tx.pure.u64(input.size),
48
+ tx.pure.u64(input.pricePercentage),
49
+ tx.pure.u64(input.maxTimes),
50
+ tx.pure.vector("u64", input.targetRounds),
51
+ input_coin,
52
+ ],
53
+ });
80
54
  return tx;
81
55
  }
82
56
  /**
@@ -133,70 +107,22 @@ function getWithdrawProfitStrategyTx(config, tx, input) {
133
107
  )
134
108
  */
135
109
  function getUpdateStrategyTx(config, tx, input) {
136
- if (
137
- // B_TOKEN
138
- input.typeArguments[1] == "0x2::sui::SUI" ||
139
- input.typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
140
- if (input.amount) {
141
- var _a = __read(tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)]), 1), input_coin = _a[0];
142
- tx.moveCall({
143
- target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
144
- typeArguments: input.typeArguments,
145
- arguments: [
146
- tx.object(config.registry.dov.dovSingle),
147
- tx.object(config.registry.dov.autoBid),
148
- tx.pure.u64(input.vaultIndex),
149
- tx.pure.u64(input.signalIndex),
150
- tx.pure.u64(input.strategyIndex),
151
- tx.pure.option("u64", input.size),
152
- tx.pure.option("u64", input.pricePercentage),
153
- tx.pure.option("u64", input.maxTimes),
154
- tx.pure.vector("u64", input.targetRounds),
155
- tx.makeMoveVec({ elements: [input_coin] }),
156
- ],
157
- });
158
- }
159
- else {
160
- tx.moveCall({
161
- target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
162
- typeArguments: input.typeArguments,
163
- arguments: [
164
- tx.object(config.registry.dov.dovSingle),
165
- tx.object(config.registry.dov.autoBid),
166
- tx.pure.u64(input.vaultIndex),
167
- tx.pure.u64(input.signalIndex),
168
- tx.pure.u64(input.strategyIndex),
169
- tx.pure.option("u64", input.size),
170
- tx.pure.option("u64", input.pricePercentage),
171
- tx.pure.option("u64", input.maxTimes),
172
- tx.pure.vector("u64", input.targetRounds),
173
- tx.makeMoveVec({ elements: [] }),
174
- ],
175
- });
176
- }
177
- }
178
- else {
179
- var coin = input.coins.pop();
180
- if (input.coins.length > 0) {
181
- tx.mergeCoins(tx.object(coin), input.coins.map(function (coin) { return tx.object(coin); }));
182
- }
183
- var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure.u64(input.amount)]), 1), input_coin = _b[0];
184
- tx.moveCall({
185
- target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
186
- typeArguments: input.typeArguments,
187
- arguments: [
188
- tx.object(config.registry.dov.dovSingle),
189
- tx.object(config.registry.dov.autoBid),
190
- tx.pure.u64(input.vaultIndex),
191
- tx.pure.u64(input.signalIndex),
192
- tx.pure.u64(input.strategyIndex),
193
- tx.pure.option("u64", input.size),
194
- tx.pure.option("u64", input.pricePercentage),
195
- tx.pure.option("u64", input.maxTimes),
196
- tx.pure.vector("u64", input.targetRounds),
197
- tx.makeMoveVec({ elements: [input_coin] }),
198
- ],
199
- });
200
- }
110
+ var input_coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.amount, config.sponsored);
111
+ tx.moveCall({
112
+ target: "".concat(config.package.dovSingle, "::auto_bid::update_strategy"),
113
+ typeArguments: input.typeArguments,
114
+ arguments: [
115
+ tx.object(config.registry.dov.dovSingle),
116
+ tx.object(config.registry.dov.autoBid),
117
+ tx.pure.u64(input.vaultIndex),
118
+ tx.pure.u64(input.signalIndex),
119
+ tx.pure.u64(input.strategyIndex),
120
+ tx.pure.option("u64", input.size),
121
+ tx.pure.option("u64", input.pricePercentage),
122
+ tx.pure.option("u64", input.maxTimes),
123
+ tx.pure.vector("u64", input.targetRounds),
124
+ tx.makeMoveVec({ elements: [input_coin] }),
125
+ ],
126
+ });
201
127
  return tx;
202
128
  }
@@ -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);
86
+ coin = (0, utils_1.splitCoins)(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);
154
+ coin = (0, utils_1.splitCoins)(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);
237
+ coin = (0, utils_1.splitCoins)(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,
@@ -35,25 +35,10 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
- var __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
38
  Object.defineProperty(exports, "__esModule", { value: true });
55
39
  exports.getRemoveAirdropTx = getRemoveAirdropTx;
56
40
  exports.getSetAirdropTx = getSetAirdropTx;
41
+ var utils_1 = require("../../../src/utils");
57
42
  /**
58
43
  public fun remove_airdrop<TOKEN>(
59
44
  version: &Version,
@@ -94,38 +79,21 @@ function getRemoveAirdropTx(config, tx, input) {
94
79
  */
95
80
  function getSetAirdropTx(config, tx, input) {
96
81
  return __awaiter(this, void 0, void 0, function () {
97
- var _a, coin;
98
- return __generator(this, function (_b) {
99
- if (input.typeArguments[0] == "0x2::sui::SUI" ||
100
- input.typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
101
- _a = __read(tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)]), 1), coin = _a[0];
102
- tx.moveCall({
103
- target: "".concat(config.package.typus, "::airdrop::set_airdrop"),
104
- typeArguments: input.typeArguments,
105
- arguments: [
106
- tx.object(config.version.typus),
107
- tx.object(config.registry.typus.airdrop),
108
- tx.pure.string(input.key),
109
- tx.makeMoveVec({ elements: [coin] }),
110
- tx.pure.vector("address", input.users),
111
- tx.pure.vector("u64", input.values),
112
- ],
113
- });
114
- }
115
- else {
116
- tx.moveCall({
117
- target: "".concat(config.package.typus, "::airdrop::set_airdrop"),
118
- typeArguments: input.typeArguments,
119
- arguments: [
120
- tx.object(config.version.typus),
121
- tx.object(config.registry.typus.airdrop),
122
- tx.pure.string(input.key),
123
- tx.makeMoveVec({ elements: input.coins.map(function (id) { return tx.object(id); }) }),
124
- tx.pure.vector("address", input.users),
125
- tx.pure.vector("u64", input.values),
126
- ],
127
- });
128
- }
82
+ var coin;
83
+ return __generator(this, function (_a) {
84
+ coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
85
+ tx.moveCall({
86
+ target: "".concat(config.package.typus, "::airdrop::set_airdrop"),
87
+ typeArguments: input.typeArguments,
88
+ arguments: [
89
+ tx.object(config.version.typus),
90
+ tx.object(config.registry.typus.airdrop),
91
+ tx.pure.string(input.key),
92
+ tx.makeMoveVec({ elements: [coin] }),
93
+ tx.pure.vector("address", input.users),
94
+ tx.pure.vector("u64", input.values),
95
+ ],
96
+ });
129
97
  return [2 /*return*/, tx];
130
98
  });
131
99
  });
@@ -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);
111
+ coin = (0, utils_1.splitCoins)(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]],
@@ -1,20 +1,4 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.getRaiseFundTx = getRaiseFundTx;
20
4
  exports.getReduceFundTx = getReduceFundTx;
@@ -45,7 +29,7 @@ var utils_1 = require("../../src/utils");
45
29
  ): (TypusDepositReceipt, vector<u64>) {
46
30
  */
47
31
  function getRaiseFundTx(config, tx, input) {
48
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount);
32
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.raiseCoins, input.raiseAmount, config.sponsored);
49
33
  var raiseBalance = tx.moveCall({
50
34
  target: "0x2::coin::into_balance",
51
35
  typeArguments: [input.typeArguments[0]],
@@ -176,56 +160,28 @@ function getRefreshDepositSnapshotTx(config, tx, input) {
176
160
  )
177
161
  */
178
162
  function getNewBidTx(config, tx, input) {
179
- if (!input.usingSponsoredGasCoin &&
180
- (input.typeArguments[1] == "0x2::sui::SUI" ||
181
- input.typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI")) {
182
- var _a = __read(tx.splitCoins(tx.gas, [tx.pure.u64(input.premium_required)]), 1), coin = _a[0];
183
- var result = tx.moveCall({
184
- target: "".concat(config.package.dovSingle, "::tds_user_entry::public_bid"),
185
- typeArguments: input.typeArguments,
186
- arguments: [
187
- tx.object(config.version.typus),
188
- tx.object(config.registry.typus.user),
189
- tx.object(config.registry.typus.tgld),
190
- tx.object(config.registry.typus.leaderboard),
191
- tx.object(config.registry.dov.dovSingle),
192
- tx.pure.u64(input.index),
193
- tx.makeMoveVec({ elements: [coin] }),
194
- tx.pure.u64(input.size),
195
- tx.object(constants_1.CLOCK),
196
- ],
197
- });
198
- tx.transferObjects([tx.object(result[0])], input.user);
199
- tx.moveCall({
200
- target: "".concat(config.package.framework, "::utils::transfer_coins"),
201
- typeArguments: [input.typeArguments[1]],
202
- arguments: [tx.makeMoveVec({ elements: [tx.object(result[1])] }), tx.pure.address(input.user)],
203
- });
204
- }
205
- else {
206
- var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.premium_required);
207
- var result = tx.moveCall({
208
- target: "".concat(config.package.dovSingle, "::tds_user_entry::public_bid"),
209
- typeArguments: input.typeArguments,
210
- arguments: [
211
- tx.object(config.version.typus),
212
- tx.object(config.registry.typus.user),
213
- tx.object(config.registry.typus.tgld),
214
- tx.object(config.registry.typus.leaderboard),
215
- tx.object(config.registry.dov.dovSingle),
216
- tx.pure.u64(input.index),
217
- tx.makeMoveVec({ elements: [coin] }),
218
- tx.pure.u64(input.size),
219
- tx.object(constants_1.CLOCK),
220
- ],
221
- });
222
- tx.transferObjects([tx.object(result[0])], input.user);
223
- tx.moveCall({
224
- target: "".concat(config.package.framework, "::utils::transfer_coins"),
225
- typeArguments: [input.typeArguments[1]],
226
- arguments: [tx.makeMoveVec({ elements: [tx.object(result[1])] }), tx.pure.address(input.user)],
227
- });
228
- }
163
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[1], input.coins, input.premium_required, config.sponsored);
164
+ var result = tx.moveCall({
165
+ target: "".concat(config.package.dovSingle, "::tds_user_entry::public_bid"),
166
+ typeArguments: input.typeArguments,
167
+ arguments: [
168
+ tx.object(config.version.typus),
169
+ tx.object(config.registry.typus.user),
170
+ tx.object(config.registry.typus.tgld),
171
+ tx.object(config.registry.typus.leaderboard),
172
+ tx.object(config.registry.dov.dovSingle),
173
+ tx.pure.u64(input.index),
174
+ tx.makeMoveVec({ elements: [coin] }),
175
+ tx.pure.u64(input.size),
176
+ tx.object(constants_1.CLOCK),
177
+ ],
178
+ });
179
+ tx.transferObjects([tx.object(result[0])], input.user);
180
+ tx.moveCall({
181
+ target: "".concat(config.package.framework, "::utils::transfer_coins"),
182
+ typeArguments: [input.typeArguments[1]],
183
+ arguments: [tx.makeMoveVec({ elements: [tx.object(result[1])] }), tx.pure.address(input.user)],
184
+ });
229
185
  return tx;
230
186
  }
231
187
  /**
@@ -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);
44
- var hedgeCoin = (0, utils_2.splitCoins)(tx, input.typeArguments[1], input.raiseHedgeCoins, input.raiseHedgeAmount);
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);
45
45
  var mainBalance = tx.moveCall({
46
46
  target: "0x2::coin::into_balance",
47
47
  typeArguments: [input.typeArguments[0]],
@@ -1,20 +1,4 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.newVault = newVault;
20
4
  exports.updateRegistrySetting = updateRegistrySetting;
@@ -26,6 +10,7 @@ exports.depositToDeepbookBalanceManager = depositToDeepbookBalanceManager;
26
10
  exports.withdrawFromDeepbookBalanceManager = withdrawFromDeepbookBalanceManager;
27
11
  exports.increaseFund = increaseFund;
28
12
  exports.decreaseFund = decreaseFund;
13
+ var utils_1 = require("../../../src/utils");
29
14
  /**
30
15
  entry fun new_vault<TOKEN>(
31
16
  version: &Version,
@@ -159,16 +144,7 @@ function withdrawFundFromDeepbookBalanceManager(config, tx, input) {
159
144
  ) {
160
145
  */
161
146
  function depositToDeepbookBalanceManager(config, tx, input) {
162
- var _a = __read(input.typeArguments[0] == "0x2::sui::SUI" ||
163
- input.typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
164
- ? tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)])
165
- : (function () {
166
- var coin = input.coins.pop();
167
- if (input.coins.length > 0) {
168
- tx.mergeCoins(tx.object(coin), input.coins.map(function (coin) { return tx.object(coin); }));
169
- }
170
- return tx.splitCoins(tx.object(coin), [tx.pure.u64(input.amount)]);
171
- })(), 1), coin = _a[0];
147
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
172
148
  tx.moveCall({
173
149
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::deposit_to_deepbook_balance_manager"),
174
150
  typeArguments: input.typeArguments,
@@ -213,16 +189,7 @@ function withdrawFromDeepbookBalanceManager(config, tx, input) {
213
189
  ) {
214
190
  */
215
191
  function increaseFund(config, tx, input) {
216
- var _a = __read(input.typeArguments[0] == "0x2::sui::SUI" ||
217
- input.typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
218
- ? tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)])
219
- : (function () {
220
- var coin = input.coins.pop();
221
- if (input.coins.length > 0) {
222
- tx.mergeCoins(tx.object(coin), input.coins.map(function (coin) { return tx.object(coin); }));
223
- }
224
- return tx.splitCoins(tx.object(coin), [tx.pure.u64(input.amount)]);
225
- })(), 1), coin = _a[0];
192
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
226
193
  tx.moveCall({
227
194
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::increase_fund"),
228
195
  typeArguments: input.typeArguments,
@@ -1,24 +1,9 @@
1
1
  "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
2
  Object.defineProperty(exports, "__esModule", { value: true });
19
3
  exports.raiseFund = raiseFund;
20
4
  exports.reduceFund = reduceFund;
21
5
  var constants_1 = require("../../../src/constants");
6
+ var utils_1 = require("../../../src/utils");
22
7
  /**
23
8
  public fun raise_fund<TOKEN>(
24
9
  version: &Version,
@@ -30,16 +15,7 @@ var constants_1 = require("../../../src/constants");
30
15
  ) {
31
16
  */
32
17
  function raiseFund(config, tx, input) {
33
- var _a = __read(input.typeArguments[0] == "0x2::sui::SUI" ||
34
- input.typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
35
- ? tx.splitCoins(tx.gas, [tx.pure.u64(input.amount)])
36
- : (function () {
37
- var coin = input.coins.pop();
38
- if (input.coins.length > 0) {
39
- tx.mergeCoins(tx.object(coin), input.coins.map(function (coin) { return tx.object(coin); }));
40
- }
41
- return tx.splitCoins(tx.object(coin), [tx.pure.u64(input.amount)]);
42
- })(), 1), coin = _a[0];
18
+ var coin = (0, utils_1.splitCoins)(tx, input.typeArguments[0], input.coins, input.amount);
43
19
  tx.moveCall({
44
20
  target: "".concat(config.package.launch.fundingVault, "::funding_vault::raise_fund"),
45
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);
26
+ var coin = (0, utils_1.splitCoins)(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)),
82
+ tx.object((0, utils_1.splitCoins)(tx, constants_1.tokenType.MAINNET.SUI, [], input.feeAmount, config.sponsored)),
83
83
  tx.object(constants_1.CLOCK),
84
84
  ],
85
85
  });
@@ -1,5 +1,5 @@
1
- import { SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
2
- import { Transaction } from "@mysten/sui/transactions";
1
+ import { HexString, SuiPriceServiceConnection, SuiPythClient } from "@pythnetwork/pyth-sui-js";
2
+ import { Argument, Transaction } from "@mysten/sui/transactions";
3
3
  import { TOKEN } from "../../../src/constants";
4
4
  import { ObjectId } from "@pythnetwork/pyth-sui-js/lib/client";
5
5
  export declare class PythClient {
@@ -11,5 +11,12 @@ export declare function createPythClient(provider: any, network: "MAINNET" | "TE
11
11
  /**
12
12
  * @returns priceInfoObjectIds
13
13
  */
14
- export declare function updatePyth(pythClient: PythClient, tx: Transaction, tokens: TOKEN[]): Promise<ObjectId[]>;
14
+ export declare function updatePyth(pythClient: PythClient, tx: Transaction, tokens: TOKEN[], suiCoin?: Argument): Promise<ObjectId[]>;
15
15
  export declare function updateOracleWithPythUsd(pythClient: PythClient, tx: Transaction, oraclePackage: string, baseToken: TOKEN): void;
16
+ /**
17
+ * Adds the necessary commands for updating the pyth price feeds to the transaction block.
18
+ * @param tx transaction block to add commands to
19
+ * @param updates array of price feed updates received from the price service
20
+ * @param feedIds array of feed ids to update (in hex format)
21
+ */
22
+ export declare function updatePriceFeeds(pythClient: PythClient, tx: Transaction, updates: Buffer[], feedIds: HexString[], suiCoin?: Argument): Promise<ObjectId[]>;
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.createPythClient = createPythClient;
40
40
  exports.updatePyth = updatePyth;
41
41
  exports.updateOracleWithPythUsd = updateOracleWithPythUsd;
42
+ exports.updatePriceFeeds = updatePriceFeeds;
42
43
  var pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
43
44
  var constant_1 = require("./constant");
44
45
  var constants_1 = require("../../../src/constants");
@@ -53,7 +54,7 @@ function createPythClient(provider, network) {
53
54
  /**
54
55
  * @returns priceInfoObjectIds
55
56
  */
56
- function updatePyth(pythClient, tx, tokens) {
57
+ function updatePyth(pythClient, tx, tokens, suiCoin) {
57
58
  return __awaiter(this, void 0, void 0, function () {
58
59
  var _priceIDs, priceFeedUpdateData, priceInfoObjectIds;
59
60
  return __generator(this, function (_a) {
@@ -63,7 +64,7 @@ function updatePyth(pythClient, tx, tokens) {
63
64
  return [4 /*yield*/, pythClient.connection.getPriceFeedsUpdateData(_priceIDs)];
64
65
  case 1:
65
66
  priceFeedUpdateData = _a.sent();
66
- return [4 /*yield*/, pythClient.client.updatePriceFeeds(tx, priceFeedUpdateData, _priceIDs)];
67
+ return [4 /*yield*/, updatePriceFeeds(pythClient, tx, priceFeedUpdateData, _priceIDs, suiCoin)];
67
68
  case 2:
68
69
  priceInfoObjectIds = _a.sent();
69
70
  return [2 /*return*/, priceInfoObjectIds];
@@ -83,3 +84,30 @@ function updateOracleWithPythUsd(pythClient, tx, oraclePackage, baseToken) {
83
84
  ],
84
85
  });
85
86
  }
87
+ /**
88
+ * Adds the necessary commands for updating the pyth price feeds to the transaction block.
89
+ * @param tx transaction block to add commands to
90
+ * @param updates array of price feed updates received from the price service
91
+ * @param feedIds array of feed ids to update (in hex format)
92
+ */
93
+ function updatePriceFeeds(pythClient, tx, updates, feedIds, suiCoin) {
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var packageId, priceUpdatesHotPotato, baseUpdateFee, coins;
96
+ return __generator(this, function (_a) {
97
+ switch (_a.label) {
98
+ case 0: return [4 /*yield*/, pythClient.client.getPythPackageId()];
99
+ case 1:
100
+ packageId = _a.sent();
101
+ return [4 /*yield*/, pythClient.client.verifyVaasAndGetHotPotato(tx, updates, packageId)];
102
+ case 2:
103
+ priceUpdatesHotPotato = _a.sent();
104
+ return [4 /*yield*/, pythClient.client.getBaseUpdateFee()];
105
+ case 3:
106
+ baseUpdateFee = _a.sent();
107
+ coins = tx.splitCoins(suiCoin !== null && suiCoin !== void 0 ? suiCoin : tx.gas, feedIds.map(function () { return tx.pure.u64(baseUpdateFee); }));
108
+ return [4 /*yield*/, pythClient.client.executePriceFeedUpdates(tx, packageId, feedIds, priceUpdatesHotPotato, coins)];
109
+ case 4: return [2 /*return*/, _a.sent()];
110
+ }
111
+ });
112
+ });
113
+ }
@@ -63,8 +63,11 @@ function getSponsoredTx(provider, sender, tx) {
63
63
  response = _a.sent();
64
64
  return [4 /*yield*/, response.json()];
65
65
  case 3:
66
- sponsoredResponse = (_a.sent());
66
+ sponsoredResponse = _a.sent();
67
67
  // console.log(sponsoredResponse);
68
+ if (sponsoredResponse.data) {
69
+ console.error("getSponsoredTx error: ", sponsoredResponse.data.details);
70
+ }
68
71
  return [2 /*return*/, sponsoredResponse];
69
72
  }
70
73
  });
@@ -7,9 +7,8 @@ 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): {
10
+ export declare function splitCoins(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 promptYesNo(question: string): Promise<boolean>;
15
14
  export declare function getNumberStringWithDecimal(input: string, decimal: number): string;
@@ -1,37 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  var __read = (this && this.__read) || function (o, n) {
36
3
  var m = typeof Symbol === "function" && o[Symbol.iterator];
37
4
  if (!m) return o;
@@ -56,11 +23,9 @@ exports.countFloating = exports.checkNumber = exports.insertAt = exports.prettif
56
23
  exports.U64FromBytes = U64FromBytes;
57
24
  exports.AddressFromBytes = AddressFromBytes;
58
25
  exports.splitCoins = splitCoins;
59
- exports.promptYesNo = promptYesNo;
60
26
  exports.getNumberStringWithDecimal = getNumberStringWithDecimal;
61
27
  var utils_1 = require("@mysten/sui/utils");
62
28
  var constants_1 = require("../../src/constants");
63
- var readline = __importStar(require("readline"));
64
29
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
65
30
  var sleep = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
66
31
  exports.sleep = sleep;
@@ -104,8 +69,9 @@ var countFloating = function (value) {
104
69
  return num.split(".")[1].length;
105
70
  };
106
71
  exports.countFloating = countFloating;
107
- function splitCoins(tx, token, coins, amount) {
72
+ function splitCoins(tx, token, coins, amount, sponsored) {
108
73
  var _a, _b;
74
+ if (sponsored === void 0) { sponsored = false; }
109
75
  var coin;
110
76
  if (coins.length == 0) {
111
77
  // support zero coin input for closing position
@@ -116,7 +82,7 @@ function splitCoins(tx, token, coins, amount) {
116
82
  }), 1), coin = _a[0];
117
83
  }
118
84
  else {
119
- _b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI
85
+ _b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
120
86
  ? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
121
87
  : (function () {
122
88
  var coin = coins.pop();
@@ -128,24 +94,6 @@ function splitCoins(tx, token, coins, amount) {
128
94
  }
129
95
  return coin;
130
96
  }
131
- function promptYesNo(question) {
132
- var rl = readline.createInterface({
133
- input: process.stdin,
134
- output: process.stdout,
135
- });
136
- return new Promise(function (resolve) {
137
- rl.question("".concat(question, " [y/N] "), function (answer) {
138
- var normalizedAnswer = answer.toLowerCase();
139
- if (normalizedAnswer === "y" || normalizedAnswer === "yes") {
140
- resolve(true);
141
- }
142
- else {
143
- resolve(false);
144
- }
145
- rl.close();
146
- });
147
- });
148
- }
149
97
  function getNumberStringWithDecimal(input, decimal) {
150
98
  input = input.padStart(decimal, "0");
151
99
  var integer = input.slice(0, input.length - decimal).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
@@ -6,6 +6,7 @@ export declare class TypusConfig {
6
6
  version: Version;
7
7
  registry: Registry;
8
8
  object: Object;
9
+ sponsored: boolean;
9
10
  static parse(json: any): TypusConfig;
10
11
  static local(path: any): TypusConfig;
11
12
  static default(network: "MAINNET" | "TESTNET", customRpcEndpoint: string | null, branch?: string): Promise<TypusConfig>;
@@ -77,6 +77,7 @@ var camelcase_keys_deep_1 = __importDefault(require("camelcase-keys-deep"));
77
77
  var fs = __importStar(require("fs"));
78
78
  var TypusConfig = /** @class */ (function () {
79
79
  function TypusConfig() {
80
+ this.sponsored = false;
80
81
  }
81
82
  TypusConfig.parse = function (json) {
82
83
  return JSON.parse(JSON.stringify((0, camelcase_keys_deep_1.default)(json)));
package/package.json CHANGED
@@ -2,12 +2,14 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.7.13",
5
+ "version": "1.7.15",
6
+ "resolutions": {
7
+ "@mysten/sui": "1.30.0"
8
+ },
6
9
  "dependencies": {
7
10
  "@mysten/bcs": "1.6.1",
8
11
  "@mysten/kiosk": "0.12.6",
9
- "@mysten/sui": "1.30.0",
10
- "@pythnetwork/pyth-sui-js": "^2.1.0",
12
+ "@pythnetwork/pyth-sui-js": "^2.2.0",
11
13
  "@shinami/clients": "^0.9.6",
12
14
  "@typemove/sui": "^1.6.1",
13
15
  "@types/node": "^20.5.7",