@typus/typus-sdk 1.1.58 → 1.2.1
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 +27 -0
- package/lib/utils/auto-bid/user-entry.js +102 -0
- package/lib/utils/auto-bid/view-function.d.ts +33 -0
- package/lib/utils/auto-bid/view-function.js +215 -0
- package/lib/utils/typus-dov-single-v2/mfud-user-entry.js +1 -0
- package/lib/utils/typus-dov-single-v2/user-entry.d.ts +15 -15
- package/lib/utils/typus-dov-single-v2/user-entry.js +100 -61
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
2
|
+
/**
|
|
3
|
+
entry fun new_strategy<B_TOKEN>(
|
|
4
|
+
strategy_pool: &mut StrategyPool,
|
|
5
|
+
vault_index: u64,
|
|
6
|
+
signal_index: u64,
|
|
7
|
+
size: u64,
|
|
8
|
+
price_percentage: u64,
|
|
9
|
+
max_times: u64,
|
|
10
|
+
target_rounds: vector<u64>,
|
|
11
|
+
coin: Coin<B_TOKEN>,
|
|
12
|
+
ctx: &mut TxContext
|
|
13
|
+
)
|
|
14
|
+
*/
|
|
15
|
+
export declare function getNewStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
|
|
16
|
+
strategy_pool: string, vault_index: string, signal_index: string, coins: string[], amount: string, size: string, price_percentage: string, max_times: string, target_rounds: string[]): TransactionBlock;
|
|
17
|
+
/**
|
|
18
|
+
entry fun close_strategy<D_TOKEN, B_TOKEN>(
|
|
19
|
+
strategy_pool: &mut StrategyPoolV2,
|
|
20
|
+
vault_index: u64,
|
|
21
|
+
signal_index: u64,
|
|
22
|
+
strategy_index: u64,
|
|
23
|
+
ctx: &mut TxContext
|
|
24
|
+
)
|
|
25
|
+
*/
|
|
26
|
+
export declare function getCloseStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // D_TOKEN, B_TOKEN
|
|
27
|
+
strategy_pool: string, vault_index: string, signal_index: string, strategy_index: string): TransactionBlock;
|
|
@@ -0,0 +1,102 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.getCloseStrategyTx = exports.getNewStrategyTx = void 0;
|
|
20
|
+
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
21
|
+
/**
|
|
22
|
+
entry fun new_strategy<B_TOKEN>(
|
|
23
|
+
strategy_pool: &mut StrategyPool,
|
|
24
|
+
vault_index: u64,
|
|
25
|
+
signal_index: u64,
|
|
26
|
+
size: u64,
|
|
27
|
+
price_percentage: u64,
|
|
28
|
+
max_times: u64,
|
|
29
|
+
target_rounds: vector<u64>,
|
|
30
|
+
coin: Coin<B_TOKEN>,
|
|
31
|
+
ctx: &mut TxContext
|
|
32
|
+
)
|
|
33
|
+
*/
|
|
34
|
+
function getNewStrategyTx(gasBudget, packageId, typeArguments, // D_TOKEN, B_TOKEN
|
|
35
|
+
strategy_pool, vault_index, signal_index, coins, amount, size, price_percentage, max_times, target_rounds) {
|
|
36
|
+
var tx = new transactions_1.TransactionBlock();
|
|
37
|
+
if (
|
|
38
|
+
// B_TOKEN
|
|
39
|
+
typeArguments[1] == "0x2::sui::SUI" ||
|
|
40
|
+
typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
41
|
+
var _a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), input_coin = _a[0];
|
|
42
|
+
tx.moveCall({
|
|
43
|
+
target: "".concat(packageId, "::auto_bid::new_strategy"),
|
|
44
|
+
typeArguments: typeArguments,
|
|
45
|
+
arguments: [
|
|
46
|
+
tx.object(strategy_pool),
|
|
47
|
+
tx.pure(vault_index),
|
|
48
|
+
tx.pure(signal_index),
|
|
49
|
+
tx.pure(size),
|
|
50
|
+
tx.pure(price_percentage),
|
|
51
|
+
tx.pure(max_times),
|
|
52
|
+
tx.pure(target_rounds),
|
|
53
|
+
input_coin,
|
|
54
|
+
],
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
var coin = coins.pop();
|
|
59
|
+
if (coins.length > 0) {
|
|
60
|
+
tx.mergeCoins(tx.object(coin), coins.map(function (coin) { return tx.object(coin); }));
|
|
61
|
+
}
|
|
62
|
+
var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure(amount)]), 1), input_coin = _b[0];
|
|
63
|
+
tx.moveCall({
|
|
64
|
+
target: "".concat(packageId, "::auto_bid::new_strategy"),
|
|
65
|
+
typeArguments: typeArguments,
|
|
66
|
+
arguments: [
|
|
67
|
+
tx.object(strategy_pool),
|
|
68
|
+
tx.pure(vault_index),
|
|
69
|
+
tx.pure(signal_index),
|
|
70
|
+
tx.pure(size),
|
|
71
|
+
tx.pure(price_percentage),
|
|
72
|
+
tx.pure(max_times),
|
|
73
|
+
tx.pure(target_rounds),
|
|
74
|
+
input_coin,
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
tx.setGasBudget(gasBudget);
|
|
79
|
+
return tx;
|
|
80
|
+
}
|
|
81
|
+
exports.getNewStrategyTx = getNewStrategyTx;
|
|
82
|
+
/**
|
|
83
|
+
entry fun close_strategy<D_TOKEN, B_TOKEN>(
|
|
84
|
+
strategy_pool: &mut StrategyPoolV2,
|
|
85
|
+
vault_index: u64,
|
|
86
|
+
signal_index: u64,
|
|
87
|
+
strategy_index: u64,
|
|
88
|
+
ctx: &mut TxContext
|
|
89
|
+
)
|
|
90
|
+
*/
|
|
91
|
+
function getCloseStrategyTx(gasBudget, packageId, typeArguments, // D_TOKEN, B_TOKEN
|
|
92
|
+
strategy_pool, vault_index, signal_index, strategy_index) {
|
|
93
|
+
var tx = new transactions_1.TransactionBlock();
|
|
94
|
+
tx.moveCall({
|
|
95
|
+
target: "".concat(packageId, "::auto_bid::close_strategy"),
|
|
96
|
+
typeArguments: typeArguments,
|
|
97
|
+
arguments: [tx.object(strategy_pool), tx.pure(vault_index), tx.pure(signal_index), tx.pure(strategy_index)],
|
|
98
|
+
});
|
|
99
|
+
tx.setGasBudget(gasBudget);
|
|
100
|
+
return tx;
|
|
101
|
+
}
|
|
102
|
+
exports.getCloseStrategyTx = getCloseStrategyTx;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SuiClient } from "@mysten/sui.js/client";
|
|
2
|
+
export declare function getUserStrategies(provider: SuiClient, packageId: string, strategyPool: string, user: string): Promise<StrategyV2[]>;
|
|
3
|
+
export declare function getVaults(provider: SuiClient, strategyPool: string): Promise<void>;
|
|
4
|
+
export interface StrategyPoolV2 {
|
|
5
|
+
id: string;
|
|
6
|
+
strategies: Map<string, Map<string, StrategyV2[]>>;
|
|
7
|
+
authority: string[];
|
|
8
|
+
}
|
|
9
|
+
export interface StrategyV2 {
|
|
10
|
+
id: string;
|
|
11
|
+
vault_index: string;
|
|
12
|
+
signal_index: string;
|
|
13
|
+
user: string;
|
|
14
|
+
price_percentage: string;
|
|
15
|
+
size: string;
|
|
16
|
+
max_times: string;
|
|
17
|
+
target_rounds: string[];
|
|
18
|
+
receipts: TypusBidReceipt[];
|
|
19
|
+
active: boolean;
|
|
20
|
+
string_padding: string[];
|
|
21
|
+
bid_times: string;
|
|
22
|
+
bid_round: string;
|
|
23
|
+
bid_ts_ms: string;
|
|
24
|
+
bid_rounds: string[];
|
|
25
|
+
accumulated_profit: string;
|
|
26
|
+
}
|
|
27
|
+
export interface TypusBidReceipt {
|
|
28
|
+
id: string;
|
|
29
|
+
vid: string;
|
|
30
|
+
index: string;
|
|
31
|
+
metadata: string;
|
|
32
|
+
u64_padding: string[];
|
|
33
|
+
}
|
|
@@ -0,0 +1,215 @@
|
|
|
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;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.getVaults = exports.getUserStrategies = void 0;
|
|
51
|
+
var bcs_1 = require("@mysten/bcs");
|
|
52
|
+
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
53
|
+
var tools_1 = require("../tools");
|
|
54
|
+
var bcs = new bcs_1.BCS((0, bcs_1.getSuiMoveConfig)());
|
|
55
|
+
bcs.registerStructType("StrategyV2", {
|
|
56
|
+
id: "address",
|
|
57
|
+
vault_index: "u64",
|
|
58
|
+
signal_index: "u64",
|
|
59
|
+
user: "address",
|
|
60
|
+
price_percentage: "u64",
|
|
61
|
+
size: "u64",
|
|
62
|
+
max_times: "u64",
|
|
63
|
+
target_rounds: "vector<u64>",
|
|
64
|
+
receipts: "vector<TypusBidReceipt>",
|
|
65
|
+
active: "bool",
|
|
66
|
+
u64_padding: "vector<u64>",
|
|
67
|
+
bid_times: "u64",
|
|
68
|
+
bid_round: "u64",
|
|
69
|
+
bid_ts_ms: "u64",
|
|
70
|
+
bid_rounds: "vector<u64>",
|
|
71
|
+
accumulated_profit: "u64",
|
|
72
|
+
strategy_index: "u64",
|
|
73
|
+
});
|
|
74
|
+
// struct StrategyV2 has key, store {
|
|
75
|
+
// id: UID,
|
|
76
|
+
// vault_index: u64,
|
|
77
|
+
// signal_index: u64,
|
|
78
|
+
// user: address,
|
|
79
|
+
// // balance: Balance<B_TOKEN>,
|
|
80
|
+
// // profit: Balance<D_TOKEN>,
|
|
81
|
+
// price_percentage: u64,
|
|
82
|
+
// size: u64,
|
|
83
|
+
// max_times: u64,
|
|
84
|
+
// target_rounds: vector<u64>,
|
|
85
|
+
// receipts: vector<TypusBidReceipt>,
|
|
86
|
+
// active: bool,
|
|
87
|
+
// u64_padding: vector<u64>,
|
|
88
|
+
// // log
|
|
89
|
+
// bid_times: u64,
|
|
90
|
+
// bid_round: u64,
|
|
91
|
+
// bid_ts_ms: u64,
|
|
92
|
+
// bid_rounds: vector<u64>,
|
|
93
|
+
// accumulated_profit: u64,
|
|
94
|
+
// }
|
|
95
|
+
bcs.registerStructType("TypusBidReceipt", {
|
|
96
|
+
id: "address",
|
|
97
|
+
vid: "address",
|
|
98
|
+
index: "u64",
|
|
99
|
+
metadata: "String",
|
|
100
|
+
u64_padding: "vector<u64>",
|
|
101
|
+
});
|
|
102
|
+
function getUserStrategies(provider, packageId, strategyPool, user) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
104
|
+
var transactionBlock, target, transactionBlockArguments, results, objBCS, reader, strategies;
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
transactionBlock = new transactions_1.TransactionBlock();
|
|
109
|
+
target = "".concat(packageId, "::auto_bid::get_user_strategies");
|
|
110
|
+
transactionBlockArguments = [transactionBlock.pure(strategyPool), transactionBlock.pure(user)];
|
|
111
|
+
transactionBlock.moveCall({
|
|
112
|
+
target: target,
|
|
113
|
+
typeArguments: [],
|
|
114
|
+
arguments: transactionBlockArguments,
|
|
115
|
+
});
|
|
116
|
+
return [4 /*yield*/, provider.devInspectTransactionBlock({ transactionBlock: transactionBlock, sender: user })];
|
|
117
|
+
case 1:
|
|
118
|
+
results = (_a.sent()).results;
|
|
119
|
+
objBCS = results[0].returnValues[0][0];
|
|
120
|
+
reader = new bcs_1.BcsReader(new Uint8Array(objBCS));
|
|
121
|
+
strategies = [];
|
|
122
|
+
reader.readVec(function (reader, i) {
|
|
123
|
+
reader.read16();
|
|
124
|
+
var strategy = {
|
|
125
|
+
id: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
|
|
126
|
+
vault_index: reader.read64(),
|
|
127
|
+
signal_index: reader.read64(),
|
|
128
|
+
user: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
|
|
129
|
+
price_percentage: reader.read64(),
|
|
130
|
+
size: reader.read64(),
|
|
131
|
+
max_times: reader.read64(),
|
|
132
|
+
target_rounds: reader.readVec(function (reader) {
|
|
133
|
+
return reader.read64();
|
|
134
|
+
}),
|
|
135
|
+
receipts: reader.readVec(function (reader) {
|
|
136
|
+
return {
|
|
137
|
+
id: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
|
|
138
|
+
vid: (0, tools_1.AddressFromBytes)(reader.readBytes(32)),
|
|
139
|
+
index: reader.read64(),
|
|
140
|
+
metadata: String.fromCharCode.apply(null, Array.from(reader.readBytes(reader.read8()))),
|
|
141
|
+
u64_padding: reader.readVec(function (reader) {
|
|
142
|
+
return reader.read64();
|
|
143
|
+
}),
|
|
144
|
+
};
|
|
145
|
+
}),
|
|
146
|
+
active: reader.read8(),
|
|
147
|
+
u64_padding: reader.readVec(function (reader) {
|
|
148
|
+
return reader.read64();
|
|
149
|
+
}),
|
|
150
|
+
bid_times: reader.read64(),
|
|
151
|
+
bid_round: reader.read64(),
|
|
152
|
+
bid_ts_ms: reader.read64(),
|
|
153
|
+
bid_rounds: reader.readVec(function (reader) {
|
|
154
|
+
return reader.read64();
|
|
155
|
+
}),
|
|
156
|
+
accumulated_profit: reader.read64(),
|
|
157
|
+
strategy_index: reader.read64(),
|
|
158
|
+
};
|
|
159
|
+
// console.log(strategy);
|
|
160
|
+
strategies.push(strategy);
|
|
161
|
+
});
|
|
162
|
+
return [2 /*return*/, strategies];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
exports.getUserStrategies = getUserStrategies;
|
|
168
|
+
function getVaults(provider, strategyPool) {
|
|
169
|
+
var _a;
|
|
170
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171
|
+
var pool, vaults, vaults_1, vaults_1_1, vault, signals, signals_1, signals_1_1, signal, strategyTable;
|
|
172
|
+
var e_1, _b, e_2, _c;
|
|
173
|
+
return __generator(this, function (_d) {
|
|
174
|
+
switch (_d.label) {
|
|
175
|
+
case 0: return [4 /*yield*/, provider.getObject({ id: strategyPool, options: { showContent: true } })];
|
|
176
|
+
case 1:
|
|
177
|
+
pool = (_a = (_d.sent()).data) === null || _a === void 0 ? void 0 : _a.content.fields;
|
|
178
|
+
console.log(pool);
|
|
179
|
+
vaults = pool.strategies.fields.contents;
|
|
180
|
+
console.log(vaults);
|
|
181
|
+
try {
|
|
182
|
+
for (vaults_1 = __values(vaults), vaults_1_1 = vaults_1.next(); !vaults_1_1.done; vaults_1_1 = vaults_1.next()) {
|
|
183
|
+
vault = vaults_1_1.value;
|
|
184
|
+
signals = vault.fields.value.fields.contents;
|
|
185
|
+
console.log(signals);
|
|
186
|
+
try {
|
|
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
|
+
signal = signals_1_1.value;
|
|
189
|
+
strategyTable = signal.fields.value.fields.contents;
|
|
190
|
+
console.log(strategyTable);
|
|
191
|
+
// dynamic fields
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
195
|
+
finally {
|
|
196
|
+
try {
|
|
197
|
+
if (signals_1_1 && !signals_1_1.done && (_c = signals_1.return)) _c.call(signals_1);
|
|
198
|
+
}
|
|
199
|
+
finally { if (e_2) throw e_2.error; }
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
204
|
+
finally {
|
|
205
|
+
try {
|
|
206
|
+
if (vaults_1_1 && !vaults_1_1.done && (_b = vaults_1.return)) _b.call(vaults_1);
|
|
207
|
+
}
|
|
208
|
+
finally { if (e_1) throw e_1.error; }
|
|
209
|
+
}
|
|
210
|
+
return [2 /*return*/];
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
exports.getVaults = getVaults;
|
|
@@ -252,6 +252,7 @@ function getRebateTx(input) {
|
|
|
252
252
|
});
|
|
253
253
|
var balance = input.tx.moveCall({
|
|
254
254
|
target: "0x1::option::destroy_some",
|
|
255
|
+
typeArguments: ["0x2::balance::Balance<".concat(input.typeArgument, ">")],
|
|
255
256
|
arguments: [input.tx.object(result[0])],
|
|
256
257
|
});
|
|
257
258
|
var mfud_coin = input.tx.moveCall({
|
|
@@ -146,6 +146,21 @@ export declare function getRedeemTx(input: {
|
|
|
146
146
|
receipts: string[] | TransactionObjectArgument[];
|
|
147
147
|
user: string;
|
|
148
148
|
}): TransactionBlock;
|
|
149
|
+
export declare function getWithdrawHarvestClaimTx(input: {
|
|
150
|
+
tx: TransactionBlock;
|
|
151
|
+
typusFrameworkOriginPackageId: string;
|
|
152
|
+
typusFrameworkPackageId: string;
|
|
153
|
+
typusDovSinglePackageId: string;
|
|
154
|
+
typusDovSingleRegistry: string;
|
|
155
|
+
typeArguments: string[];
|
|
156
|
+
index: string;
|
|
157
|
+
receipts: string[] | TransactionObjectArgument[];
|
|
158
|
+
user: string;
|
|
159
|
+
withdraw: boolean;
|
|
160
|
+
harvest: boolean;
|
|
161
|
+
claim: boolean;
|
|
162
|
+
incentiveToken?: string;
|
|
163
|
+
}): TransactionBlock;
|
|
149
164
|
/**
|
|
150
165
|
public(friend) entry fun new_bid<D_TOKEN, B_TOKEN>(
|
|
151
166
|
registry: &mut Registry,
|
|
@@ -222,18 +237,3 @@ export declare function getRebateTx(input: {
|
|
|
222
237
|
typeArgument: string;
|
|
223
238
|
user: string;
|
|
224
239
|
}): TransactionBlock;
|
|
225
|
-
/**
|
|
226
|
-
entry fun new_strategy<B_TOKEN>(
|
|
227
|
-
strategy_pool: &mut StrategyPool,
|
|
228
|
-
vault_index: u64,
|
|
229
|
-
signal_index: u64,
|
|
230
|
-
size: u64,
|
|
231
|
-
price_percentage: u64,
|
|
232
|
-
max_times: u64,
|
|
233
|
-
target_rounds: vector<u64>,
|
|
234
|
-
coin: Coin<B_TOKEN>,
|
|
235
|
-
ctx: &mut TxContext
|
|
236
|
-
)
|
|
237
|
-
*/
|
|
238
|
-
export declare function getNewStrategyTx(gasBudget: number, packageId: string, typeArguments: string[], // B_TOKEN
|
|
239
|
-
strategy_pool: string, vault_index: string, signal_index: string, coins: string[], amount: string, size: string, price_percentage: string, max_times: string, target_rounds: string[]): TransactionBlock;
|
|
@@ -16,8 +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.
|
|
20
|
-
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
19
|
+
exports.getRebateTx = exports.getTransferBidReceiptTx = exports.getExerciseTx = exports.getNewBidTx = exports.getWithdrawHarvestClaimTx = exports.getRedeemTx = exports.getHarvestTx = exports.getClaimTx = exports.getCompoundTx = exports.getUnsubscribeTx = exports.getWithdrawTx = exports.getDepositTx = void 0;
|
|
21
20
|
var constants_1 = require("../../constants");
|
|
22
21
|
/**
|
|
23
22
|
public fun deposit<D_TOKEN, B_TOKEN>(
|
|
@@ -255,6 +254,7 @@ function getHarvestTx(input) {
|
|
|
255
254
|
input.typeArguments.push(input.incentiveToken);
|
|
256
255
|
var receipt = input.tx.moveCall({
|
|
257
256
|
target: "0x1::option::destroy_some",
|
|
257
|
+
typeArguments: ["".concat(input.typusFrameworkOriginPackageId, "::vault::TypusDepositReceipt")],
|
|
258
258
|
arguments: [input.tx.object(result[1])],
|
|
259
259
|
});
|
|
260
260
|
input.tx = getRedeemTx({
|
|
@@ -311,6 +311,103 @@ function getRedeemTx(input) {
|
|
|
311
311
|
return input.tx;
|
|
312
312
|
}
|
|
313
313
|
exports.getRedeemTx = getRedeemTx;
|
|
314
|
+
function getWithdrawHarvestClaimTx(input) {
|
|
315
|
+
var result = input.withdraw
|
|
316
|
+
? input.tx.moveCall({
|
|
317
|
+
target: "".concat(input.typusDovSinglePackageId, "::tails_staking::withdraw"),
|
|
318
|
+
typeArguments: input.typeArguments,
|
|
319
|
+
arguments: [
|
|
320
|
+
input.tx.object(input.typusDovSingleRegistry),
|
|
321
|
+
input.tx.pure(input.index),
|
|
322
|
+
input.tx.makeMoveVec({
|
|
323
|
+
type: "".concat(input.typusFrameworkOriginPackageId, "::vault::TypusDepositReceipt"),
|
|
324
|
+
objects: input.receipts.map(function (receipt) { return input.tx.object(receipt); }),
|
|
325
|
+
}),
|
|
326
|
+
input.tx.pure([]),
|
|
327
|
+
input.tx.pure(constants_1.CLOCK),
|
|
328
|
+
],
|
|
329
|
+
})
|
|
330
|
+
: undefined;
|
|
331
|
+
if (input.withdraw) {
|
|
332
|
+
input.tx.moveCall({
|
|
333
|
+
target: "".concat(input.typusFrameworkPackageId, "::utils::transfer_balance"),
|
|
334
|
+
typeArguments: [input.typeArguments[0]],
|
|
335
|
+
arguments: [input.tx.object(result[0]), input.tx.pure(input.user)],
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
result = input.harvest
|
|
339
|
+
? input.tx.moveCall({
|
|
340
|
+
target: "".concat(input.typusDovSinglePackageId, "::tds_user_entry::harvest"),
|
|
341
|
+
typeArguments: input.typeArguments,
|
|
342
|
+
arguments: [
|
|
343
|
+
input.tx.object(input.typusDovSingleRegistry),
|
|
344
|
+
input.tx.pure(input.index),
|
|
345
|
+
input.tx.makeMoveVec({
|
|
346
|
+
type: "".concat(input.typusFrameworkOriginPackageId, "::vault::TypusDepositReceipt"),
|
|
347
|
+
objects: result ? [result[1]] : input.receipts.map(function (receipt) { return input.tx.object(receipt); }),
|
|
348
|
+
}),
|
|
349
|
+
],
|
|
350
|
+
})
|
|
351
|
+
: result;
|
|
352
|
+
if (input.harvest) {
|
|
353
|
+
input.tx.moveCall({
|
|
354
|
+
target: "".concat(input.typusFrameworkPackageId, "::utils::transfer_balance"),
|
|
355
|
+
typeArguments: [input.typeArguments[1]],
|
|
356
|
+
arguments: [input.tx.object(result[0]), input.tx.pure(input.user)],
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
result = input.claim
|
|
360
|
+
? input.tx.moveCall({
|
|
361
|
+
target: "".concat(input.typusDovSinglePackageId, "::tds_user_entry::claim"),
|
|
362
|
+
typeArguments: input.typeArguments,
|
|
363
|
+
arguments: [
|
|
364
|
+
input.tx.object(input.typusDovSingleRegistry),
|
|
365
|
+
input.tx.pure(input.index),
|
|
366
|
+
input.tx.makeMoveVec({
|
|
367
|
+
type: "".concat(input.typusFrameworkOriginPackageId, "::vault::TypusDepositReceipt"),
|
|
368
|
+
objects: result ? [result[1]] : input.receipts.map(function (receipt) { return input.tx.object(receipt); }),
|
|
369
|
+
}),
|
|
370
|
+
],
|
|
371
|
+
})
|
|
372
|
+
: result;
|
|
373
|
+
if (input.claim) {
|
|
374
|
+
input.tx.moveCall({
|
|
375
|
+
target: "".concat(input.typusFrameworkPackageId, "::utils::transfer_balance"),
|
|
376
|
+
typeArguments: [input.typeArguments[0]],
|
|
377
|
+
arguments: [input.tx.object(result[0]), input.tx.pure(input.user)],
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
if (input.incentiveToken) {
|
|
381
|
+
input.typeArguments.push(input.incentiveToken);
|
|
382
|
+
var receipts = result
|
|
383
|
+
? [
|
|
384
|
+
input.tx.object(input.tx.moveCall({
|
|
385
|
+
target: "0x1::option::destroy_some",
|
|
386
|
+
arguments: [input.tx.object(result[1])],
|
|
387
|
+
})),
|
|
388
|
+
]
|
|
389
|
+
: input.receipts.map(function (receipt) { return input.tx.object(receipt); });
|
|
390
|
+
input.tx = getRedeemTx({
|
|
391
|
+
tx: input.tx,
|
|
392
|
+
typusFrameworkOriginPackageId: input.typusFrameworkOriginPackageId,
|
|
393
|
+
typusFrameworkPackageId: input.typusFrameworkPackageId,
|
|
394
|
+
typusDovSinglePackageId: input.typusDovSinglePackageId,
|
|
395
|
+
typusDovSingleRegistry: input.typusDovSingleRegistry,
|
|
396
|
+
typeArguments: input.typeArguments,
|
|
397
|
+
index: input.index,
|
|
398
|
+
receipts: receipts,
|
|
399
|
+
user: input.user,
|
|
400
|
+
});
|
|
401
|
+
}
|
|
402
|
+
else {
|
|
403
|
+
input.tx.moveCall({
|
|
404
|
+
target: "".concat(input.typusFrameworkPackageId, "::vault::transfer_deposit_receipt"),
|
|
405
|
+
arguments: [input.tx.object(result[1]), input.tx.pure(input.user)],
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
return input.tx;
|
|
409
|
+
}
|
|
410
|
+
exports.getWithdrawHarvestClaimTx = getWithdrawHarvestClaimTx;
|
|
314
411
|
/**
|
|
315
412
|
public(friend) entry fun new_bid<D_TOKEN, B_TOKEN>(
|
|
316
413
|
registry: &mut Registry,
|
|
@@ -427,6 +524,7 @@ function getRebateTx(input) {
|
|
|
427
524
|
});
|
|
428
525
|
var balance = input.tx.moveCall({
|
|
429
526
|
target: "0x1::option::destroy_some",
|
|
527
|
+
typeArguments: ["0x2::balance::Balance<".concat(input.typeArgument, ">")],
|
|
430
528
|
arguments: [input.tx.object(result[0])],
|
|
431
529
|
});
|
|
432
530
|
input.tx.moveCall({
|
|
@@ -437,62 +535,3 @@ function getRebateTx(input) {
|
|
|
437
535
|
return input.tx;
|
|
438
536
|
}
|
|
439
537
|
exports.getRebateTx = getRebateTx;
|
|
440
|
-
/**
|
|
441
|
-
entry fun new_strategy<B_TOKEN>(
|
|
442
|
-
strategy_pool: &mut StrategyPool,
|
|
443
|
-
vault_index: u64,
|
|
444
|
-
signal_index: u64,
|
|
445
|
-
size: u64,
|
|
446
|
-
price_percentage: u64,
|
|
447
|
-
max_times: u64,
|
|
448
|
-
target_rounds: vector<u64>,
|
|
449
|
-
coin: Coin<B_TOKEN>,
|
|
450
|
-
ctx: &mut TxContext
|
|
451
|
-
)
|
|
452
|
-
*/
|
|
453
|
-
function getNewStrategyTx(gasBudget, packageId, typeArguments, // B_TOKEN
|
|
454
|
-
strategy_pool, vault_index, signal_index, coins, amount, size, price_percentage, max_times, target_rounds) {
|
|
455
|
-
var tx = new transactions_1.TransactionBlock();
|
|
456
|
-
if (typeArguments[0] == "0x2::sui::SUI" ||
|
|
457
|
-
typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
458
|
-
var _a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), input_coin = _a[0];
|
|
459
|
-
tx.moveCall({
|
|
460
|
-
target: "".concat(packageId, "::auto_bid::new_strategy"),
|
|
461
|
-
typeArguments: typeArguments,
|
|
462
|
-
arguments: [
|
|
463
|
-
tx.object(strategy_pool),
|
|
464
|
-
tx.pure(vault_index),
|
|
465
|
-
tx.pure(signal_index),
|
|
466
|
-
tx.pure(size),
|
|
467
|
-
tx.pure(price_percentage),
|
|
468
|
-
tx.pure(max_times),
|
|
469
|
-
tx.pure(target_rounds),
|
|
470
|
-
input_coin,
|
|
471
|
-
],
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
else {
|
|
475
|
-
var coin = coins.pop();
|
|
476
|
-
if (coins.length > 0) {
|
|
477
|
-
tx.mergeCoins(tx.object(coin), coins.map(function (coin) { return tx.object(coin); }));
|
|
478
|
-
}
|
|
479
|
-
var _b = __read(tx.splitCoins(tx.object(coin), [tx.pure(amount)]), 1), input_coin = _b[0];
|
|
480
|
-
tx.moveCall({
|
|
481
|
-
target: "".concat(packageId, "::auto_bid::new_strategy"),
|
|
482
|
-
typeArguments: typeArguments,
|
|
483
|
-
arguments: [
|
|
484
|
-
tx.object(strategy_pool),
|
|
485
|
-
tx.pure(vault_index),
|
|
486
|
-
tx.pure(signal_index),
|
|
487
|
-
tx.pure(size),
|
|
488
|
-
tx.pure(price_percentage),
|
|
489
|
-
tx.pure(max_times),
|
|
490
|
-
tx.pure(target_rounds),
|
|
491
|
-
input_coin,
|
|
492
|
-
],
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
tx.setGasBudget(gasBudget);
|
|
496
|
-
return tx;
|
|
497
|
-
}
|
|
498
|
-
exports.getNewStrategyTx = getNewStrategyTx;
|