@typus/typus-sdk 1.2.15 → 1.2.16
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/nft-staking/authorized-entry.d.ts +2 -1
- package/lib/utils/nft-staking/authorized-entry.js +18 -7
- package/lib/utils/token.js +2 -0
- package/lib/utils/typus-dov-single-v2/vault-history.d.ts +9 -0
- package/lib/utils/typus-dov-single-v2/vault-history.js +53 -1
- package/lib/utils/typus-nft/fetch.d.ts +2 -0
- package/lib/utils/typus-nft/fetch.js +42 -2
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
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, coins: string[], typeArguments: string[]
|
|
2
|
+
export declare function getSetProfitSharingTx(gasBudget: number, packageId: string, registry: string, level_profits: number[], amount: number, coins: string[], typeArguments: string[]): Promise<TransactionBlock>;
|
|
3
3
|
export declare function getAllocateProfitSharingTx(gasBudget: number, packageId: string, registry: string, users: string[], typeArguments: string[]): Promise<TransactionBlock>;
|
|
4
|
+
export declare function getRemoveProfitSharingTx(gasBudget: number, packageId: string, registry: string, typeArgumentsRemove: string[]): Promise<TransactionBlock>;
|
|
@@ -52,18 +52,13 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
54
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
|
-
exports.getAllocateProfitSharingTx = exports.getSetProfitSharingTx = void 0;
|
|
55
|
+
exports.getRemoveProfitSharingTx = 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, coins, typeArguments
|
|
57
|
+
function getSetProfitSharingTx(gasBudget, packageId, registry, level_profits, amount, coins, typeArguments) {
|
|
58
58
|
return __awaiter(this, void 0, void 0, function () {
|
|
59
59
|
var tx, _a, input_coin, coin, _b, input_coin;
|
|
60
60
|
return __generator(this, function (_c) {
|
|
61
61
|
tx = new transactions_1.TransactionBlock();
|
|
62
|
-
tx.moveCall({
|
|
63
|
-
target: "".concat(packageId, "::tails_staking::remove_profit_sharing"),
|
|
64
|
-
typeArguments: typeArgumentsRemove,
|
|
65
|
-
arguments: [tx.object(registry)],
|
|
66
|
-
});
|
|
67
62
|
if (typeArguments[0] == "0x2::sui::SUI" ||
|
|
68
63
|
typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
69
64
|
_a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), input_coin = _a[0];
|
|
@@ -107,3 +102,19 @@ function getAllocateProfitSharingTx(gasBudget, packageId, registry, users, typeA
|
|
|
107
102
|
});
|
|
108
103
|
}
|
|
109
104
|
exports.getAllocateProfitSharingTx = getAllocateProfitSharingTx;
|
|
105
|
+
function getRemoveProfitSharingTx(gasBudget, packageId, registry, typeArgumentsRemove) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
+
var tx;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
tx = new transactions_1.TransactionBlock();
|
|
110
|
+
tx.moveCall({
|
|
111
|
+
target: "".concat(packageId, "::tails_staking::remove_profit_sharing"),
|
|
112
|
+
typeArguments: typeArgumentsRemove,
|
|
113
|
+
arguments: [tx.object(registry)],
|
|
114
|
+
});
|
|
115
|
+
tx.setGasBudget(gasBudget);
|
|
116
|
+
return [2 /*return*/, tx];
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
exports.getRemoveProfitSharingTx = getRemoveProfitSharingTx;
|
package/lib/utils/token.js
CHANGED
|
@@ -110,4 +110,13 @@ interface SettleEvent {
|
|
|
110
110
|
timestampMs: string | null | undefined;
|
|
111
111
|
txDigest: string;
|
|
112
112
|
}
|
|
113
|
+
export declare function parseBidEvents(datas: SuiEvent[], end_ts_ms: any): Promise<Map<string, NewBidEvent[]>>;
|
|
114
|
+
interface NewBidEvent {
|
|
115
|
+
signer: string;
|
|
116
|
+
index: string;
|
|
117
|
+
size: string;
|
|
118
|
+
ts_ms: string;
|
|
119
|
+
timestampMs: string | null | undefined;
|
|
120
|
+
txDigest: string;
|
|
121
|
+
}
|
|
113
122
|
export {};
|
|
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.convertGroupEventToVaultHistory = exports.parseVaultHistory = exports.parseGroupEvents = exports.getVaultHistoryEvents = void 0;
|
|
39
|
+
exports.parseBidEvents = exports.convertGroupEventToVaultHistory = exports.parseVaultHistory = exports.parseGroupEvents = exports.getVaultHistoryEvents = void 0;
|
|
40
40
|
var token_1 = require("../token");
|
|
41
41
|
function getVaultHistoryEvents(provider, originPackage, startTimeMs) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -252,3 +252,55 @@ function convertGroupEventToVaultHistory(groupEvent) {
|
|
|
252
252
|
});
|
|
253
253
|
}
|
|
254
254
|
exports.convertGroupEventToVaultHistory = convertGroupEventToVaultHistory;
|
|
255
|
+
function parseBidEvents(datas, end_ts_ms) {
|
|
256
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
+
var results;
|
|
258
|
+
var _this = this;
|
|
259
|
+
return __generator(this, function (_a) {
|
|
260
|
+
switch (_a.label) {
|
|
261
|
+
case 0: return [4 /*yield*/, datas.reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
|
|
262
|
+
var map, functionType, action, parsedJson, index, bid_event, o_token, size, bid_events;
|
|
263
|
+
return __generator(this, function (_a) {
|
|
264
|
+
switch (_a.label) {
|
|
265
|
+
case 0: return [4 /*yield*/, promise];
|
|
266
|
+
case 1:
|
|
267
|
+
map = _a.sent();
|
|
268
|
+
functionType = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.type);
|
|
269
|
+
action = functionType[3];
|
|
270
|
+
// console.log(action);
|
|
271
|
+
if (action != "NewBidEvent") {
|
|
272
|
+
return [2 /*return*/, map];
|
|
273
|
+
}
|
|
274
|
+
parsedJson = event.parsedJson;
|
|
275
|
+
// console.log(parsedJson);
|
|
276
|
+
parsedJson.timestampMs = event.timestampMs;
|
|
277
|
+
parsedJson.txDigest = event.id.txDigest;
|
|
278
|
+
index = parsedJson.index.toString();
|
|
279
|
+
bid_event = parsedJson;
|
|
280
|
+
o_token = (0, token_1.typeArgToAsset)("0x" + parsedJson.o_token.name);
|
|
281
|
+
size = Number(parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
|
|
282
|
+
bid_event.size = size.toString();
|
|
283
|
+
if (Number(bid_event.ts_ms) > end_ts_ms) {
|
|
284
|
+
return [2 /*return*/, map];
|
|
285
|
+
}
|
|
286
|
+
if (map.has(index)) {
|
|
287
|
+
bid_events = map.get(index);
|
|
288
|
+
bid_events.push(bid_event);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
bid_events = [bid_event];
|
|
292
|
+
}
|
|
293
|
+
map.set(index, bid_events);
|
|
294
|
+
return [2 /*return*/, map];
|
|
295
|
+
}
|
|
296
|
+
});
|
|
297
|
+
}); }, Promise.resolve(new Map()))];
|
|
298
|
+
case 1:
|
|
299
|
+
results = _a.sent();
|
|
300
|
+
// console.log(results);
|
|
301
|
+
return [2 /*return*/, results];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
exports.parseBidEvents = parseBidEvents;
|
|
@@ -7,6 +7,7 @@ export interface PoolData {
|
|
|
7
7
|
start_ms: string;
|
|
8
8
|
num: number;
|
|
9
9
|
remaining: number;
|
|
10
|
+
table: string;
|
|
10
11
|
}
|
|
11
12
|
export declare const necklaces: string[];
|
|
12
13
|
export declare function getPoolMap(provider: SuiClient, nftConfig: any): Promise<Map<string, PoolData>>;
|
|
@@ -35,4 +36,5 @@ export interface Tails {
|
|
|
35
36
|
}
|
|
36
37
|
export declare function getLevelExp(level: number): number | undefined;
|
|
37
38
|
export declare const LevelExpVec: number[];
|
|
39
|
+
export declare function getTableTails(provider: SuiClient, parentId: string): Promise<Tails[]>;
|
|
38
40
|
export {};
|
|
@@ -47,7 +47,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
47
47
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
48
|
};
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.LevelExpVec = exports.getLevelExp = exports.fieldsToTails = exports.getTails = exports.getTailsIds = exports.getWhitelistMap = exports.getPoolMap = exports.necklaces = exports.getPool = void 0;
|
|
50
|
+
exports.getTableTails = exports.LevelExpVec = exports.getLevelExp = exports.fieldsToTails = exports.getTails = exports.getTailsIds = exports.getWhitelistMap = exports.getPoolMap = exports.necklaces = exports.getPool = void 0;
|
|
51
51
|
function getPool(provider, pool) {
|
|
52
52
|
var _a;
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
@@ -64,6 +64,7 @@ function getPool(provider, pool) {
|
|
|
64
64
|
start_ms: fields.start_ms,
|
|
65
65
|
num: Number(fields.num),
|
|
66
66
|
remaining: Number(fields.tails.fields.contents.fields.size),
|
|
67
|
+
table: fields.tails.fields.contents.fields.id.id,
|
|
67
68
|
};
|
|
68
69
|
return [2 /*return*/, poolData];
|
|
69
70
|
}
|
|
@@ -111,6 +112,7 @@ function getPoolMap(provider, nftConfig) {
|
|
|
111
112
|
start_ms: fields.start_ms,
|
|
112
113
|
num: Number(fields.num),
|
|
113
114
|
remaining: Number(fields.tails.fields.contents.fields.size),
|
|
115
|
+
table: fields.tails.fields.contents.fields.id.id,
|
|
114
116
|
};
|
|
115
117
|
poolMap.set(necklace, poolData);
|
|
116
118
|
return [2 /*return*/];
|
|
@@ -252,13 +254,17 @@ function getTails(provider, tailsIds) {
|
|
|
252
254
|
}
|
|
253
255
|
exports.getTails = getTails;
|
|
254
256
|
function fieldsToTails(fields) {
|
|
257
|
+
var id = fields.id.id;
|
|
258
|
+
if (fields.value) {
|
|
259
|
+
fields = fields.value.fields;
|
|
260
|
+
}
|
|
255
261
|
// console.log(fields.attributes.fields.contents);
|
|
256
262
|
var attributes = new Map();
|
|
257
263
|
fields.attributes.fields.contents.forEach(function (f) { return attributes.set(f.fields.key, f.fields.value); });
|
|
258
264
|
var u64_padding = new Map();
|
|
259
265
|
fields.u64_padding.fields.contents.forEach(function (f) { return u64_padding.set(f.fields.key, f.fields.value); });
|
|
260
266
|
var tails = {
|
|
261
|
-
id:
|
|
267
|
+
id: id,
|
|
262
268
|
name: fields.name,
|
|
263
269
|
number: fields.number,
|
|
264
270
|
url: fields.url,
|
|
@@ -293,3 +299,37 @@ function getLevelExp(level) {
|
|
|
293
299
|
}
|
|
294
300
|
exports.getLevelExp = getLevelExp;
|
|
295
301
|
exports.LevelExpVec = [0, 0, 1000, 50000, 250000, 1000000, 5000000, 20000000];
|
|
302
|
+
function getTableTails(provider, parentId) {
|
|
303
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
304
|
+
var result, datas, tails, levelUsers;
|
|
305
|
+
return __generator(this, function (_a) {
|
|
306
|
+
switch (_a.label) {
|
|
307
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({
|
|
308
|
+
parentId: parentId,
|
|
309
|
+
})];
|
|
310
|
+
case 1:
|
|
311
|
+
result = _a.sent();
|
|
312
|
+
datas = result.data;
|
|
313
|
+
_a.label = 2;
|
|
314
|
+
case 2:
|
|
315
|
+
if (!result.hasNextPage) return [3 /*break*/, 4];
|
|
316
|
+
return [4 /*yield*/, provider.getDynamicFields({
|
|
317
|
+
parentId: parentId,
|
|
318
|
+
cursor: result.nextCursor,
|
|
319
|
+
})];
|
|
320
|
+
case 3:
|
|
321
|
+
result = _a.sent();
|
|
322
|
+
datas = datas.concat(result.data);
|
|
323
|
+
return [3 /*break*/, 2];
|
|
324
|
+
case 4: return [4 /*yield*/, getTails(provider, datas.map(function (data) { return data.objectId; }))];
|
|
325
|
+
case 5:
|
|
326
|
+
tails = _a.sent();
|
|
327
|
+
levelUsers = [0, 0, 0, 0, 0, 0, 0];
|
|
328
|
+
tails.forEach(function (tail) { return (levelUsers[Number(tail.level) - 1] += 1); });
|
|
329
|
+
console.log("Level Users: ", levelUsers);
|
|
330
|
+
return [2 /*return*/, tails];
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
exports.getTableTails = getTableTails;
|