@typus/typus-sdk 1.2.12 → 1.2.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/lib/utils/auto-bid/user-entry.d.ts +16 -0
- package/lib/utils/auto-bid/user-entry.js +65 -1
- package/lib/utils/auto-bid/view-function.js +2 -2
- package/lib/utils/token.js +1 -1
- package/lib/utils/typus-dov-single-v2/user-entry.d.ts +1 -0
- package/lib/utils/typus-dov-single-v2/user-entry.js +14 -1
- package/lib/utils/typus-dov-single-v2/user-history.js +12 -6
- package/package.json +1 -1
|
@@ -25,3 +25,19 @@ strategy_pool: string, vault_index: string, signal_index: string, coins: string[
|
|
|
25
25
|
*/
|
|
26
26
|
export declare function getCloseStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
|
|
27
27
|
strategy_pool: string, vault_index: string, signal_index: string, strategy_index: string): TransactionBlock;
|
|
28
|
+
/**
|
|
29
|
+
entry fun update_strategy<D_TOKEN, B_TOKEN>(
|
|
30
|
+
strategy_pool: &mut StrategyPoolV2,
|
|
31
|
+
vault_index: u64,
|
|
32
|
+
signal_index: u64,
|
|
33
|
+
strategy_index: u64,
|
|
34
|
+
size: Option<u64>,
|
|
35
|
+
price_percentage: Option<u64>,
|
|
36
|
+
max_times: Option<u64>,
|
|
37
|
+
target_rounds: vector<u64>,
|
|
38
|
+
coins: vector<Coin<B_TOKEN>>,
|
|
39
|
+
ctx: & TxContext
|
|
40
|
+
)
|
|
41
|
+
*/
|
|
42
|
+
export declare function getUpdateStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
|
|
43
|
+
strategy_pool: string, vault_index: string, signal_index: string, strategy_index: string, coins: string[], amount: string, size: string | null, price_percentage: string | null, max_times: string | null, target_rounds: string[]): TransactionBlock;
|
|
@@ -16,7 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.getCloseStrategyTx = exports.getNewStrategyTx = void 0;
|
|
19
|
+
exports.getUpdateStrategyTx = exports.getCloseStrategyTx = exports.getNewStrategyTx = void 0;
|
|
20
20
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
21
21
|
/**
|
|
22
22
|
entry fun new_strategy<B_TOKEN>(
|
|
@@ -100,3 +100,67 @@ strategy_pool, vault_index, signal_index, strategy_index) {
|
|
|
100
100
|
return tx;
|
|
101
101
|
}
|
|
102
102
|
exports.getCloseStrategyTx = getCloseStrategyTx;
|
|
103
|
+
/**
|
|
104
|
+
entry fun update_strategy<D_TOKEN, B_TOKEN>(
|
|
105
|
+
strategy_pool: &mut StrategyPoolV2,
|
|
106
|
+
vault_index: u64,
|
|
107
|
+
signal_index: u64,
|
|
108
|
+
strategy_index: u64,
|
|
109
|
+
size: Option<u64>,
|
|
110
|
+
price_percentage: Option<u64>,
|
|
111
|
+
max_times: Option<u64>,
|
|
112
|
+
target_rounds: vector<u64>,
|
|
113
|
+
coins: vector<Coin<B_TOKEN>>,
|
|
114
|
+
ctx: & TxContext
|
|
115
|
+
)
|
|
116
|
+
*/
|
|
117
|
+
function getUpdateStrategyTx(gasBudget, packageId, typeArguments, // D_TOKEN, B_TOKEN
|
|
118
|
+
strategy_pool, vault_index, signal_index, strategy_index, coins, amount, size, price_percentage, max_times, target_rounds) {
|
|
119
|
+
var tx = new transactions_1.TransactionBlock();
|
|
120
|
+
if (
|
|
121
|
+
// B_TOKEN
|
|
122
|
+
typeArguments[1] == "0x2::sui::SUI" ||
|
|
123
|
+
typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
124
|
+
var _a = __read(amount ? tx.splitCoins(tx.gas, [tx.pure(amount)]) : [tx.pure([])], 1), input_coin = _a[0];
|
|
125
|
+
tx.moveCall({
|
|
126
|
+
target: "".concat(packageId, "::auto_bid::update_strategy"),
|
|
127
|
+
typeArguments: typeArguments,
|
|
128
|
+
arguments: [
|
|
129
|
+
tx.object(strategy_pool),
|
|
130
|
+
tx.pure(vault_index),
|
|
131
|
+
tx.pure(signal_index),
|
|
132
|
+
tx.pure(strategy_index),
|
|
133
|
+
tx.pure(size ? [size] : []),
|
|
134
|
+
tx.pure(price_percentage ? [price_percentage] : []),
|
|
135
|
+
tx.pure(max_times ? [max_times] : []),
|
|
136
|
+
tx.pure(target_rounds),
|
|
137
|
+
input_coin,
|
|
138
|
+
],
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
var coin = coins.pop();
|
|
143
|
+
if (coins.length > 0) {
|
|
144
|
+
tx.mergeCoins(tx.object(coin), coins.map(function (coin) { return tx.object(coin); }));
|
|
145
|
+
}
|
|
146
|
+
var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure(amount)]), 1), input_coin = _b[0];
|
|
147
|
+
tx.moveCall({
|
|
148
|
+
target: "".concat(packageId, "::auto_bid::update_strategy"),
|
|
149
|
+
typeArguments: typeArguments,
|
|
150
|
+
arguments: [
|
|
151
|
+
tx.object(strategy_pool),
|
|
152
|
+
tx.pure(vault_index),
|
|
153
|
+
tx.pure(signal_index),
|
|
154
|
+
tx.pure(strategy_index),
|
|
155
|
+
tx.pure(size ? [size] : []),
|
|
156
|
+
tx.pure(price_percentage ? [price_percentage] : []),
|
|
157
|
+
tx.pure(max_times ? [max_times] : []),
|
|
158
|
+
tx.pure(target_rounds),
|
|
159
|
+
tx.makeMoveVec({ objects: [input_coin] }),
|
|
160
|
+
],
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
tx.setGasBudget(gasBudget);
|
|
164
|
+
return tx;
|
|
165
|
+
}
|
|
166
|
+
exports.getUpdateStrategyTx = getUpdateStrategyTx;
|
|
@@ -177,12 +177,12 @@ function getVaults(provider, strategyPool) {
|
|
|
177
177
|
pool = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a.content.fields;
|
|
178
178
|
console.log(pool);
|
|
179
179
|
vaults = pool.strategies.fields.contents;
|
|
180
|
-
console.log(vaults);
|
|
181
180
|
try {
|
|
182
181
|
for (vaults_1 = __values(vaults), vaults_1_1 = vaults_1.next(); !vaults_1_1.done; vaults_1_1 = vaults_1.next()) {
|
|
183
182
|
vault = vaults_1_1.value;
|
|
184
183
|
signals = vault.fields.value.fields.contents;
|
|
185
|
-
console.log(
|
|
184
|
+
console.log("vault: ", vault);
|
|
185
|
+
console.log("signals: ", signals);
|
|
186
186
|
try {
|
|
187
187
|
for (signals_1 = (e_2 = void 0, __values(signals)), signals_1_1 = signals_1.next(); !signals_1_1.done; signals_1_1 = signals_1.next()) {
|
|
188
188
|
signal = signals_1_1.value;
|
package/lib/utils/token.js
CHANGED
|
@@ -173,6 +173,7 @@ export declare function getWithdrawHarvestClaimTx(input: {
|
|
|
173
173
|
*/
|
|
174
174
|
export declare function getNewBidTx(input: {
|
|
175
175
|
tx: TransactionBlock;
|
|
176
|
+
typusFrameworkPackageId: string;
|
|
176
177
|
typusDovSinglePackageId: string;
|
|
177
178
|
typusDovSingleRegistry: string;
|
|
178
179
|
typeArguments: string[];
|
|
@@ -455,13 +455,26 @@ function getNewBidTx(input) {
|
|
|
455
455
|
input.tx.transferObjects([input.tx.object(result[0])], input.user);
|
|
456
456
|
}
|
|
457
457
|
else {
|
|
458
|
+
var balance = input.tx.moveCall({
|
|
459
|
+
target: "".concat(input.typusFrameworkPackageId, "::utils::extract_balance"),
|
|
460
|
+
typeArguments: [input.typeArguments[1]],
|
|
461
|
+
arguments: [
|
|
462
|
+
input.tx.makeMoveVec({ objects: input.coins.map(function (coin) { return input.tx.object(coin); }) }),
|
|
463
|
+
input.tx.pure(input.premium_required),
|
|
464
|
+
],
|
|
465
|
+
});
|
|
466
|
+
var coin = input.tx.moveCall({
|
|
467
|
+
target: "0x2::coin::from_balance",
|
|
468
|
+
typeArguments: [input.typeArguments[1]],
|
|
469
|
+
arguments: [input.tx.object(balance)],
|
|
470
|
+
});
|
|
458
471
|
var result = input.tx.moveCall({
|
|
459
472
|
target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid"),
|
|
460
473
|
typeArguments: input.typeArguments,
|
|
461
474
|
arguments: [
|
|
462
475
|
input.tx.object(input.typusDovSingleRegistry),
|
|
463
476
|
input.tx.pure(input.index),
|
|
464
|
-
input.tx.makeMoveVec({ objects:
|
|
477
|
+
input.tx.makeMoveVec({ objects: [coin] }),
|
|
465
478
|
input.tx.pure(input.size),
|
|
466
479
|
input.tx.pure("0x6"),
|
|
467
480
|
],
|
|
@@ -67,10 +67,7 @@ function getUserHistory(provider, originPackage, vaults, sender, startTimeMs) {
|
|
|
67
67
|
case 5:
|
|
68
68
|
nextPage = _a.sent();
|
|
69
69
|
txHistory = txHistory.concat(nextPage);
|
|
70
|
-
|
|
71
|
-
return [3 /*break*/, 6];
|
|
72
|
-
}
|
|
73
|
-
return [3 /*break*/, 3];
|
|
70
|
+
return [3 /*break*/, 6];
|
|
74
71
|
case 6: return [2 /*return*/, txHistory];
|
|
75
72
|
}
|
|
76
73
|
});
|
|
@@ -86,10 +83,10 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
86
83
|
case 0: return [4 /*yield*/, datas
|
|
87
84
|
.filter(function (event) {
|
|
88
85
|
var type = event.type;
|
|
89
|
-
return
|
|
86
|
+
return event.packageId == originPackage || type.includes("typus_nft::First") || type.includes("typus_nft::ExpUpEvent");
|
|
90
87
|
})
|
|
91
88
|
.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
92
|
-
var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, o_token, v, period, optionType, i, i, token, amount, amount, token, amount, size, token, amount, token, amount, i, b_token, size, bidder_balance;
|
|
89
|
+
var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, o_token, v, period, optionType, i, i, token, amount, token, amount, amount, token, amount, size, token, amount, token, amount, i, b_token, size, bidder_balance;
|
|
93
90
|
var _a;
|
|
94
91
|
return __generator(this, function (_b) {
|
|
95
92
|
switch (_b.label) {
|
|
@@ -134,6 +131,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
134
131
|
case "ClaimEvent":
|
|
135
132
|
case "CompoundEvent":
|
|
136
133
|
case "HarvestEvent":
|
|
134
|
+
case "RedeemEvent":
|
|
137
135
|
optionType = "Covered Call";
|
|
138
136
|
break;
|
|
139
137
|
default:
|
|
@@ -149,6 +147,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
149
147
|
case "ClaimEvent":
|
|
150
148
|
case "CompoundEvent":
|
|
151
149
|
case "HarvestEvent":
|
|
150
|
+
case "RedeemEvent":
|
|
152
151
|
optionType = "Put Selling";
|
|
153
152
|
break;
|
|
154
153
|
default:
|
|
@@ -261,6 +260,13 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
261
260
|
return [2 /*return*/, txHistory];
|
|
262
261
|
}
|
|
263
262
|
break;
|
|
263
|
+
case "RedeemEvent":
|
|
264
|
+
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
265
|
+
amount = Number(event.parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(token));
|
|
266
|
+
Action = "Harvest";
|
|
267
|
+
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
268
|
+
Index = event.parsedJson.index;
|
|
269
|
+
break;
|
|
264
270
|
case "TransferBidReceiptEvent":
|
|
265
271
|
amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
|
|
266
272
|
Action = "Transfer Receipt";
|