@typus/typus-sdk 1.7.12 → 1.7.14
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.
- package/dist/src/auto-bid/user-entry.js +34 -108
- package/dist/src/dice/user-entry.js +3 -3
- package/dist/src/typus/airdrop/authority-entry.js +16 -48
- package/dist/src/typus-dov-single-v2/otc-entry.js +1 -1
- package/dist/src/typus-dov-single-v2/user-entry.js +23 -67
- package/dist/src/typus-hedge/user-entry.js +2 -2
- package/dist/src/typus-launch/funding-vault/authority-entry.js +3 -36
- package/dist/src/typus-launch/funding-vault/user-entry.js +2 -26
- package/dist/src/typus-safu/user-entry.js +2 -2
- package/dist/src/utils/api/price.js +2 -3
- package/dist/src/utils/sponsoredTx.d.ts +8 -0
- package/dist/src/utils/sponsoredTx.js +75 -0
- package/dist/src/utils/tools.d.ts +4 -2
- package/dist/src/utils/tools.js +32 -4
- package/dist/src/utils/typusConfig.d.ts +1 -0
- package/dist/src/utils/typusConfig.js +1 -0
- package/package.json +2 -1
|
@@ -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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
input.typeArguments
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
input.typeArguments
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
tx.
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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
|
|
98
|
-
return __generator(this, function (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
tx.
|
|
200
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
});
|
|
@@ -150,7 +150,6 @@ function getPythLatestPrice() {
|
|
|
150
150
|
var price = p.price.price / Math.pow(10, -p.price.expo);
|
|
151
151
|
map.set(token, price);
|
|
152
152
|
});
|
|
153
|
-
console.log(map);
|
|
154
153
|
return [2 /*return*/, map];
|
|
155
154
|
case 3: return [2 /*return*/];
|
|
156
155
|
}
|
|
@@ -288,8 +287,8 @@ var pythId = {
|
|
|
288
287
|
"04cfeb7b143eb9c48e9b074125c1a3447b85f59c31164dc20c1beaa6f21f2b6b": "BLUE",
|
|
289
288
|
"5fc11ffe4975b624be495be038da30e30bee2004d8ae6282b5364577ef4ca92c": "BLUB",
|
|
290
289
|
"765d2ba906dbc32ca17cc11f5310a89e9ee1f6420508c63861f2f8ba4ee34bb2": "XAU",
|
|
291
|
-
|
|
290
|
+
eba0732395fae9dec4bae12e52760b35fc1c5671e2da8b449c9af4efe5d54341: "WAL",
|
|
292
291
|
"4279e31cc369bbcc2faf022b382b080e32a8e689ff20fbc530d2a603eb6cd98b": "HYPE",
|
|
293
|
-
|
|
292
|
+
ec5d399846a9209f3fe5881d70aae9268c94339ff9817e8d18ff19fa05eea1c8: "XRP",
|
|
294
293
|
};
|
|
295
294
|
// getPythLatestPrice();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import { SuiClient } from "@mysten/sui/client";
|
|
3
|
+
export declare function getSponsoredTx(provider: SuiClient, sender: string, tx: Transaction): Promise<sponsoredResponse>;
|
|
4
|
+
interface sponsoredResponse {
|
|
5
|
+
txBytes: string;
|
|
6
|
+
sponsorSig: string;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getSponsoredTx = getSponsoredTx;
|
|
40
|
+
var sui_1 = require("@shinami/clients/sui");
|
|
41
|
+
function getSponsoredTx(provider, sender, tx) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
var gaslessTx, body, apiUrl, headers, response, sponsoredResponse;
|
|
44
|
+
return __generator(this, function (_a) {
|
|
45
|
+
switch (_a.label) {
|
|
46
|
+
case 0: return [4 /*yield*/, (0, sui_1.buildGaslessTransaction)(tx, {
|
|
47
|
+
sui: provider,
|
|
48
|
+
sender: sender,
|
|
49
|
+
})];
|
|
50
|
+
case 1:
|
|
51
|
+
gaslessTx = _a.sent();
|
|
52
|
+
body = JSON.stringify(gaslessTx);
|
|
53
|
+
apiUrl = "https://sponsored-gas-752051381467.asia-southeast1.run.app";
|
|
54
|
+
headers = {
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
};
|
|
57
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: headers,
|
|
60
|
+
body: body,
|
|
61
|
+
})];
|
|
62
|
+
case 2:
|
|
63
|
+
response = _a.sent();
|
|
64
|
+
return [4 /*yield*/, response.json()];
|
|
65
|
+
case 3:
|
|
66
|
+
sponsoredResponse = _a.sent();
|
|
67
|
+
// console.log(sponsoredResponse);
|
|
68
|
+
if (sponsoredResponse.data) {
|
|
69
|
+
console.error("getSponsoredTx error: ", sponsoredResponse.data.details);
|
|
70
|
+
}
|
|
71
|
+
return [2 /*return*/, sponsoredResponse];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
1
|
import { Transaction } from "@mysten/sui/transactions";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
3
|
export declare const sleep: (ms: number) => Promise<unknown>;
|
|
4
4
|
export declare const prettify_big_number: (value: any, decimal: any) => string;
|
|
5
5
|
export declare function U64FromBytes(x: any): bigint;
|
|
@@ -7,7 +7,9 @@ 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
|
+
export declare function getNumberStringWithDecimal(input: string, decimal: number): string;
|
package/dist/src/utils/tools.js
CHANGED
|
@@ -23,9 +23,12 @@ exports.countFloating = exports.checkNumber = exports.insertAt = exports.prettif
|
|
|
23
23
|
exports.U64FromBytes = U64FromBytes;
|
|
24
24
|
exports.AddressFromBytes = AddressFromBytes;
|
|
25
25
|
exports.splitCoins = splitCoins;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
exports.promptYesNo = promptYesNo;
|
|
27
|
+
exports.getNumberStringWithDecimal = getNumberStringWithDecimal;
|
|
28
28
|
var utils_1 = require("@mysten/sui/utils");
|
|
29
|
+
var constants_1 = require("../../src/constants");
|
|
30
|
+
// import * as readline from "readline";
|
|
31
|
+
var bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
29
32
|
var sleep = function (ms) { return new Promise(function (resolve) { return setTimeout(resolve, ms); }); };
|
|
30
33
|
exports.sleep = sleep;
|
|
31
34
|
var prettify_big_number = function (value, decimal) {
|
|
@@ -68,8 +71,9 @@ var countFloating = function (value) {
|
|
|
68
71
|
return num.split(".")[1].length;
|
|
69
72
|
};
|
|
70
73
|
exports.countFloating = countFloating;
|
|
71
|
-
function splitCoins(tx, token, coins, amount) {
|
|
74
|
+
function splitCoins(tx, token, coins, amount, sponsored) {
|
|
72
75
|
var _a, _b;
|
|
76
|
+
if (sponsored === void 0) { sponsored = false; }
|
|
73
77
|
var coin;
|
|
74
78
|
if (coins.length == 0) {
|
|
75
79
|
// support zero coin input for closing position
|
|
@@ -80,7 +84,7 @@ function splitCoins(tx, token, coins, amount) {
|
|
|
80
84
|
}), 1), coin = _a[0];
|
|
81
85
|
}
|
|
82
86
|
else {
|
|
83
|
-
_b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI
|
|
87
|
+
_b = __read((0, utils_1.normalizeStructTag)(token) == constants_1.tokenType.MAINNET.SUI && !sponsored
|
|
84
88
|
? tx.splitCoins(tx.gas, [tx.pure.u64(amount)])
|
|
85
89
|
: (function () {
|
|
86
90
|
var coin = coins.pop();
|
|
@@ -92,3 +96,27 @@ function splitCoins(tx, token, coins, amount) {
|
|
|
92
96
|
}
|
|
93
97
|
return coin;
|
|
94
98
|
}
|
|
99
|
+
function promptYesNo(question) {
|
|
100
|
+
// const rl = readline.createInterface({
|
|
101
|
+
// input: process.stdin,
|
|
102
|
+
// output: process.stdout,
|
|
103
|
+
// });
|
|
104
|
+
// return new Promise((resolve) => {
|
|
105
|
+
// rl.question(`${question} [y/N] `, (answer) => {
|
|
106
|
+
// const normalizedAnswer = answer.toLowerCase();
|
|
107
|
+
// if (normalizedAnswer === "y" || normalizedAnswer === "yes") {
|
|
108
|
+
// resolve(true);
|
|
109
|
+
// } else {
|
|
110
|
+
// resolve(false);
|
|
111
|
+
// }
|
|
112
|
+
// rl.close();
|
|
113
|
+
// });
|
|
114
|
+
// });
|
|
115
|
+
return new Promise(function (resolve) { return resolve(true); });
|
|
116
|
+
}
|
|
117
|
+
function getNumberStringWithDecimal(input, decimal) {
|
|
118
|
+
input = input.padStart(decimal, "0");
|
|
119
|
+
var integer = input.slice(0, input.length - decimal).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
120
|
+
var float = input.slice(input.length - decimal, input.length);
|
|
121
|
+
return "".concat(integer == "" ? "0" : integer, ".").concat(float);
|
|
122
|
+
}
|
|
@@ -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,13 @@
|
|
|
2
2
|
"name": "@typus/typus-sdk",
|
|
3
3
|
"author": "Typus",
|
|
4
4
|
"description": "typus sdk",
|
|
5
|
-
"version": "1.7.
|
|
5
|
+
"version": "1.7.14",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@mysten/bcs": "1.6.1",
|
|
8
8
|
"@mysten/kiosk": "0.12.6",
|
|
9
9
|
"@mysten/sui": "1.30.0",
|
|
10
10
|
"@pythnetwork/pyth-sui-js": "^2.1.0",
|
|
11
|
+
"@shinami/clients": "^0.9.6",
|
|
11
12
|
"@typemove/sui": "^1.6.1",
|
|
12
13
|
"@types/node": "^20.5.7",
|
|
13
14
|
"bignumber.js": "^9.1.2",
|