@typus/typus-sdk 1.1.57 → 1.2.0
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/nft-staking/authorized-entry.d.ts +2 -2
- package/lib/utils/nft-staking/authorized-entry.js +29 -9
- package/lib/utils/nft-staking/user-entry.d.ts +3 -3
- package/lib/utils/nft-staking/user-entry.js +6 -6
- package/lib/utils/tails-exp-dice/fetch.d.ts +1 -0
- package/lib/utils/tails-exp-dice/fetch.js +9 -6
- package/lib/utils/token.js +4 -0
- package/lib/utils/typus-dov-single-v2/authorized-entry.d.ts +1 -0
- package/lib/utils/typus-dov-single-v2/authorized-entry.js +1 -0
- package/lib/utils/typus-dov-single-v2/mfud-user-entry.d.ts +125 -0
- package/lib/utils/typus-dov-single-v2/mfud-user-entry.js +270 -0
- package/lib/utils/typus-dov-single-v2/user-entry.d.ts +133 -30
- package/lib/utils/typus-dov-single-v2/user-entry.js +333 -253
- 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;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
2
|
-
export declare function getSetProfitSharingTx(gasBudget: number, packageId: string, registry: string, level_profits: number[], amount: number): Promise<TransactionBlock>;
|
|
3
|
-
export declare function getAllocateProfitSharingTx(gasBudget: number, packageId: string, registry: string, users: string[]): Promise<TransactionBlock>;
|
|
2
|
+
export declare function getSetProfitSharingTx(gasBudget: number, packageId: string, registry: string, level_profits: number[], amount: number, coins: string[], typeArguments: string[], typeArgumentsRemove: string[]): Promise<TransactionBlock>;
|
|
3
|
+
export declare function getAllocateProfitSharingTx(gasBudget: number, packageId: string, registry: string, users: string[], typeArguments: string[]): Promise<TransactionBlock>;
|
|
@@ -54,31 +54,51 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
55
|
exports.getAllocateProfitSharingTx = exports.getSetProfitSharingTx = void 0;
|
|
56
56
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
57
|
-
function getSetProfitSharingTx(gasBudget, packageId, registry, level_profits, amount) {
|
|
57
|
+
function getSetProfitSharingTx(gasBudget, packageId, registry, level_profits, amount, coins, typeArguments, typeArgumentsRemove) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
|
-
var tx, _a, coin;
|
|
60
|
-
return __generator(this, function (
|
|
59
|
+
var tx, _a, input_coin, coin, _b, input_coin;
|
|
60
|
+
return __generator(this, function (_c) {
|
|
61
61
|
tx = new transactions_1.TransactionBlock();
|
|
62
|
-
_a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), coin = _a[0];
|
|
63
62
|
tx.moveCall({
|
|
64
|
-
target: "".concat(packageId, "::tails_staking::
|
|
65
|
-
typeArguments:
|
|
66
|
-
arguments: [tx.object(registry)
|
|
63
|
+
target: "".concat(packageId, "::tails_staking::remove_profit_sharing"),
|
|
64
|
+
typeArguments: typeArgumentsRemove,
|
|
65
|
+
arguments: [tx.object(registry)],
|
|
67
66
|
});
|
|
67
|
+
if (typeArguments[0] == "0x2::sui::SUI" ||
|
|
68
|
+
typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
69
|
+
_a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), input_coin = _a[0];
|
|
70
|
+
tx.moveCall({
|
|
71
|
+
target: "".concat(packageId, "::tails_staking::set_profit_sharing"),
|
|
72
|
+
typeArguments: typeArguments,
|
|
73
|
+
arguments: [tx.object(registry), tx.pure(level_profits), input_coin],
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
coin = coins.pop();
|
|
78
|
+
if (coins.length > 0) {
|
|
79
|
+
tx.mergeCoins(tx.object(coin), coins.map(function (id) { return tx.object(id); }));
|
|
80
|
+
}
|
|
81
|
+
_b = __read(tx.splitCoins(tx.object(coin), [tx.pure(amount)]), 1), input_coin = _b[0];
|
|
82
|
+
tx.moveCall({
|
|
83
|
+
target: "".concat(packageId, "::tails_staking::set_profit_sharing"),
|
|
84
|
+
typeArguments: typeArguments,
|
|
85
|
+
arguments: [tx.object(registry), tx.pure(level_profits), input_coin],
|
|
86
|
+
});
|
|
87
|
+
}
|
|
68
88
|
tx.setGasBudget(gasBudget);
|
|
69
89
|
return [2 /*return*/, tx];
|
|
70
90
|
});
|
|
71
91
|
});
|
|
72
92
|
}
|
|
73
93
|
exports.getSetProfitSharingTx = getSetProfitSharingTx;
|
|
74
|
-
function getAllocateProfitSharingTx(gasBudget, packageId, registry, users) {
|
|
94
|
+
function getAllocateProfitSharingTx(gasBudget, packageId, registry, users, typeArguments) {
|
|
75
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
76
96
|
var tx;
|
|
77
97
|
return __generator(this, function (_a) {
|
|
78
98
|
tx = new transactions_1.TransactionBlock();
|
|
79
99
|
tx.moveCall({
|
|
80
100
|
target: "".concat(packageId, "::tails_staking::allocate_profit_sharing"),
|
|
81
|
-
typeArguments:
|
|
101
|
+
typeArguments: typeArguments,
|
|
82
102
|
arguments: [tx.object(registry), tx.pure(users)],
|
|
83
103
|
});
|
|
84
104
|
tx.setGasBudget(gasBudget);
|
|
@@ -23,7 +23,7 @@ export declare function getTransferNftsTx(gasBudget: number, nftPackageId: strin
|
|
|
23
23
|
)
|
|
24
24
|
*/
|
|
25
25
|
export declare function getStakeNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string): Promise<TransactionBlock>;
|
|
26
|
-
export declare function getSwitchNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string): Promise<TransactionBlock>;
|
|
26
|
+
export declare function getSwitchNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, nft_id: string, typeArguments: string[]): Promise<TransactionBlock>;
|
|
27
27
|
export declare function getCreateKioskAndLockNftTx(kioskClient: KioskClient, gasBudget: number, nftPackageId: string, policy: string, nft_id: string, singer: string): Promise<TransactionBlock>;
|
|
28
28
|
/**
|
|
29
29
|
public fun unstake_nft(
|
|
@@ -34,7 +34,7 @@ export declare function getCreateKioskAndLockNftTx(kioskClient: KioskClient, gas
|
|
|
34
34
|
ctx: &mut TxContext
|
|
35
35
|
)
|
|
36
36
|
*/
|
|
37
|
-
export declare function getUnstakeNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string): Promise<TransactionBlock>;
|
|
37
|
+
export declare function getUnstakeNftTx(gasBudget: number, nftPackageId: string, registry: string, kiosk: string, kiosk_cap: string, typeArguments: string[]): Promise<TransactionBlock>;
|
|
38
38
|
/**
|
|
39
39
|
public fun daily_attend(
|
|
40
40
|
registry: &mut Registry,
|
|
@@ -83,4 +83,4 @@ export declare function consumeExpCoinUnstakedTx(gasBudget: number, nftPackageId
|
|
|
83
83
|
)
|
|
84
84
|
*/
|
|
85
85
|
export declare function consumeExpCoinStakedTx(gasBudget: number, nftPackageId: string, typeArguments: string[], registry: string, exp_coins: string[], amount: string): Promise<TransactionBlock>;
|
|
86
|
-
export declare function getClaimProfitSharingTx(gasBudget: number, packageId: string, registry: string): Promise<TransactionBlock>;
|
|
86
|
+
export declare function getClaimProfitSharingTx(gasBudget: number, packageId: string, registry: string, typeArguments: string[]): Promise<TransactionBlock>;
|
|
@@ -131,7 +131,7 @@ function getStakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
exports.getStakeNftTx = getStakeNftTx;
|
|
134
|
-
function getSwitchNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_id) {
|
|
134
|
+
function getSwitchNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft_id, typeArguments) {
|
|
135
135
|
return __awaiter(this, void 0, void 0, function () {
|
|
136
136
|
var tx, _a, coin;
|
|
137
137
|
return __generator(this, function (_b) {
|
|
@@ -144,7 +144,7 @@ function getSwitchNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, nft
|
|
|
144
144
|
});
|
|
145
145
|
tx.moveCall({
|
|
146
146
|
target: "".concat(nftPackageId, "::tails_staking::claim_profit_sharing"),
|
|
147
|
-
typeArguments:
|
|
147
|
+
typeArguments: typeArguments,
|
|
148
148
|
arguments: [tx.object(registry)],
|
|
149
149
|
});
|
|
150
150
|
tx.moveCall({
|
|
@@ -193,7 +193,7 @@ exports.getCreateKioskAndLockNftTx = getCreateKioskAndLockNftTx;
|
|
|
193
193
|
ctx: &mut TxContext
|
|
194
194
|
)
|
|
195
195
|
*/
|
|
196
|
-
function getUnstakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap) {
|
|
196
|
+
function getUnstakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap, typeArguments) {
|
|
197
197
|
return __awaiter(this, void 0, void 0, function () {
|
|
198
198
|
var tx;
|
|
199
199
|
return __generator(this, function (_a) {
|
|
@@ -205,7 +205,7 @@ function getUnstakeNftTx(gasBudget, nftPackageId, registry, kiosk, kiosk_cap) {
|
|
|
205
205
|
});
|
|
206
206
|
tx.moveCall({
|
|
207
207
|
target: "".concat(nftPackageId, "::tails_staking::claim_profit_sharing"),
|
|
208
|
-
typeArguments:
|
|
208
|
+
typeArguments: typeArguments,
|
|
209
209
|
arguments: [tx.object(registry)],
|
|
210
210
|
});
|
|
211
211
|
tx.moveCall({
|
|
@@ -495,14 +495,14 @@ function consumeExpCoinStakedTx(gasBudget, nftPackageId, typeArguments, registry
|
|
|
495
495
|
});
|
|
496
496
|
}
|
|
497
497
|
exports.consumeExpCoinStakedTx = consumeExpCoinStakedTx;
|
|
498
|
-
function getClaimProfitSharingTx(gasBudget, packageId, registry) {
|
|
498
|
+
function getClaimProfitSharingTx(gasBudget, packageId, registry, typeArguments) {
|
|
499
499
|
return __awaiter(this, void 0, void 0, function () {
|
|
500
500
|
var tx;
|
|
501
501
|
return __generator(this, function (_a) {
|
|
502
502
|
tx = new transactions_1.TransactionBlock();
|
|
503
503
|
tx.moveCall({
|
|
504
504
|
target: "".concat(packageId, "::tails_staking::claim_profit_sharing"),
|
|
505
|
-
typeArguments:
|
|
505
|
+
typeArguments: typeArguments,
|
|
506
506
|
arguments: [tx.object(registry)],
|
|
507
507
|
});
|
|
508
508
|
tx.setGasBudget(gasBudget);
|
|
@@ -54,6 +54,7 @@ export interface ProfitSharing {
|
|
|
54
54
|
pool: string;
|
|
55
55
|
remaining: string;
|
|
56
56
|
total: string;
|
|
57
|
+
tokenType: string;
|
|
57
58
|
}
|
|
58
59
|
export declare function getProfitSharing(provider: SuiClient, diceProfitSharing: string): Promise<ProfitSharing>;
|
|
59
60
|
export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];
|
|
@@ -246,18 +246,21 @@ function getLeaderBoard(drawDisplays) {
|
|
|
246
246
|
}
|
|
247
247
|
exports.getLeaderBoard = getLeaderBoard;
|
|
248
248
|
function getProfitSharing(provider, diceProfitSharing) {
|
|
249
|
-
var _a, _b;
|
|
249
|
+
var _a, _b, _c, _d;
|
|
250
250
|
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
-
var object, result;
|
|
252
|
-
return __generator(this, function (
|
|
253
|
-
switch (
|
|
251
|
+
var object, type, tokenType, result;
|
|
252
|
+
return __generator(this, function (_e) {
|
|
253
|
+
switch (_e.label) {
|
|
254
254
|
case 0: return [4 /*yield*/, provider.getObject({
|
|
255
255
|
id: diceProfitSharing,
|
|
256
256
|
options: { showContent: true },
|
|
257
257
|
})];
|
|
258
258
|
case 1:
|
|
259
|
-
object =
|
|
260
|
-
|
|
259
|
+
object = _e.sent();
|
|
260
|
+
type = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content.type;
|
|
261
|
+
tokenType = (_b = type.split("<").at(-1)) === null || _b === void 0 ? void 0 : _b.replace(">>", "");
|
|
262
|
+
result = (_d = (_c = object.data) === null || _c === void 0 ? void 0 : _c.content) === null || _d === void 0 ? void 0 : _d.fields.value.fields;
|
|
263
|
+
result.tokenType = tokenType;
|
|
261
264
|
return [2 /*return*/, result];
|
|
262
265
|
}
|
|
263
266
|
});
|
package/lib/utils/token.js
CHANGED
|
@@ -24,6 +24,10 @@ function typeArgToAsset(typeArg) {
|
|
|
24
24
|
return "TURBOS";
|
|
25
25
|
case "0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37":
|
|
26
26
|
return "APT";
|
|
27
|
+
case "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1":
|
|
28
|
+
return "FUD";
|
|
29
|
+
case "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc":
|
|
30
|
+
return "AFSUI";
|
|
27
31
|
default:
|
|
28
32
|
if (typeArgs[2] == "BTC") {
|
|
29
33
|
return "WBTC";
|
|
@@ -64,6 +64,7 @@ export interface UpdateConfigRequests {
|
|
|
64
64
|
capacity?: string;
|
|
65
65
|
leverage?: string;
|
|
66
66
|
riskLevel?: string;
|
|
67
|
+
depositIncentiveBpDivisorDecimal?: string;
|
|
67
68
|
};
|
|
68
69
|
}
|
|
69
70
|
export declare function getUpdateConfigTx(gasBudget: number, packageId: string, registry: string, requests: UpdateConfigRequests[]): Promise<TransactionBlock>;
|
|
@@ -156,6 +156,7 @@ function getUpdateConfigTx(gasBudget, packageId, registry, requests) {
|
|
|
156
156
|
tx.pure(request.config.capacity ? [request.config.capacity] : []),
|
|
157
157
|
tx.pure(request.config.leverage ? [request.config.leverage] : []),
|
|
158
158
|
tx.pure(request.config.riskLevel ? [request.config.riskLevel] : []),
|
|
159
|
+
tx.pure(request.config.depositIncentiveBpDivisorDecimal ? [request.config.depositIncentiveBpDivisorDecimal] : []),
|
|
159
160
|
],
|
|
160
161
|
});
|
|
161
162
|
});
|