@typus/typus-sdk 1.9.2 → 1.9.3
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/view-function.js +1 -1
- package/dist/src/dice/fetch.js +2 -2
- package/dist/src/typus/airdrop/view-function.js +2 -0
- package/dist/src/typus/leaderboard/view-function.js +2 -0
- package/dist/src/typus/tails-staking/view-function.js +4 -0
- package/dist/src/typus-dov-single-v2/function/index.d.ts +0 -1
- package/dist/src/typus-dov-single-v2/function/index.js +0 -1
- package/dist/src/typus-dov-single-v2/view-function.d.ts +3 -0
- package/dist/src/typus-dov-single-v2/view-function.js +45 -1
- package/dist/src/typus-launch/airdrop/view-function.js +5 -1
- package/dist/src/typus-launch/funding-vault/view-function.js +1 -1
- package/dist/src/typus-launch/improvement-proposal/view-function.js +20 -4
- package/dist/src/typus-launch/ve-typus/view-function.js +5 -1
- package/dist/src/typus-nft/fetch.d.ts +36 -0
- package/dist/src/typus-nft/fetch.js +269 -0
- package/dist/src/typus-nft/index.d.ts +1 -0
- package/dist/src/typus-nft/index.js +17 -0
- package/dist/src/utils/api/price.js +5 -57
- package/dist/src/utils/api/sentio/events.js +4 -4
- package/dist/src/utils/api/sentio/leader-board.js +1 -1
- package/dist/src/utils/api/sentio/reward-generated.js +16 -16
- package/dist/src/utils/api/sentio/vault-history.js +1 -1
- package/package.json +1 -1
- package/dist/src/typus-dov-single-v2/function/bidding.d.ts +0 -88
- package/dist/src/typus-dov-single-v2/function/bidding.js +0 -652
|
@@ -200,7 +200,7 @@ function getStrategyPool(config) {
|
|
|
200
200
|
switch (_f.label) {
|
|
201
201
|
case 0:
|
|
202
202
|
provider = config.gRpcClient();
|
|
203
|
-
return [4 /*yield*/, provider.getObject({
|
|
203
|
+
return [4 /*yield*/, provider.getObject({ objectId: config.registry.dov.autoBid, include: { content: true } })];
|
|
204
204
|
case 1:
|
|
205
205
|
pool = (_e = (_f.sent()).data) === null || _e === void 0 ? void 0 : _e.content.fields;
|
|
206
206
|
vaults = pool.strategies.fields.contents;
|
package/dist/src/dice/fetch.js
CHANGED
|
@@ -114,7 +114,7 @@ function getHistory(config, input) {
|
|
|
114
114
|
return [4 /*yield*/, (0, graphQl_1.getEvents)(graphQlClient, MoveEventType, null, null, false)];
|
|
115
115
|
case 1:
|
|
116
116
|
events = _a.sent();
|
|
117
|
-
return [4 /*yield*/, parseHistory(events, input.playgrounds)];
|
|
117
|
+
return [4 /*yield*/, parseHistory(events.events, input.playgrounds)];
|
|
118
118
|
case 2:
|
|
119
119
|
history = _a.sent();
|
|
120
120
|
return [2 /*return*/, history];
|
|
@@ -228,7 +228,7 @@ function parseHistory(datas, playgrounds) {
|
|
|
228
228
|
// }
|
|
229
229
|
// export async function getProfitSharing(provider: SuiClient, diceProfitSharing: string) {
|
|
230
230
|
// let object = await provider.getObject({
|
|
231
|
-
//
|
|
231
|
+
// objectId: diceProfitSharing,
|
|
232
232
|
// include: { content: true },
|
|
233
233
|
// });
|
|
234
234
|
// // @ts-ignore
|
|
@@ -60,6 +60,8 @@ function getStakingInfo(config, input) {
|
|
|
60
60
|
});
|
|
61
61
|
return [4 /*yield*/, provider.simulateTransaction({
|
|
62
62
|
transaction: transaction,
|
|
63
|
+
checksEnabled: false,
|
|
64
|
+
include: { commandResults: true },
|
|
63
65
|
})];
|
|
64
66
|
case 1:
|
|
65
67
|
results = (_a.sent()).commandResults;
|
|
@@ -108,6 +110,8 @@ function getLevelCounts(config) {
|
|
|
108
110
|
});
|
|
109
111
|
return [4 /*yield*/, provider.simulateTransaction({
|
|
110
112
|
transaction: transaction,
|
|
113
|
+
checksEnabled: false,
|
|
114
|
+
include: { commandResults: true },
|
|
111
115
|
})];
|
|
112
116
|
case 1:
|
|
113
117
|
results = (_a.sent()).commandResults;
|
|
@@ -14,6 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./bidding"), exports);
|
|
18
17
|
__exportStar(require("./token"), exports);
|
|
19
18
|
__exportStar(require("./vault"), exports);
|
|
@@ -224,3 +224,6 @@ export declare function getRefundShares(config: TypusConfig, input: {
|
|
|
224
224
|
}): Promise<{
|
|
225
225
|
[key: string]: string;
|
|
226
226
|
}>;
|
|
227
|
+
export declare function getUserOwnedObjects(config: TypusConfig, user: string): Promise<import("@mysten/sui/client", { with: { "resolution-mode": "import" } }).SuiClientTypes.Object<{
|
|
228
|
+
content: true;
|
|
229
|
+
}>[]>;
|
|
@@ -51,6 +51,15 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
51
51
|
}
|
|
52
52
|
return ar;
|
|
53
53
|
};
|
|
54
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
+
if (ar || !(i in from)) {
|
|
57
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
+
ar[i] = from[i];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
+
};
|
|
54
63
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
55
64
|
exports.getVaults = getVaults;
|
|
56
65
|
exports.getAuctions = getAuctions;
|
|
@@ -58,6 +67,7 @@ exports.getAuctionBids = getAuctionBids;
|
|
|
58
67
|
exports.getDepositShares = getDepositShares;
|
|
59
68
|
exports.getMyBids = getMyBids;
|
|
60
69
|
exports.getRefundShares = getRefundShares;
|
|
70
|
+
exports.getUserOwnedObjects = getUserOwnedObjects;
|
|
61
71
|
var transactions_1 = require("@mysten/sui/transactions");
|
|
62
72
|
var bcs_1 = require("@mysten/bcs");
|
|
63
73
|
var utils_1 = require("../../src/utils");
|
|
@@ -503,7 +513,7 @@ function getMyBids(config, input) {
|
|
|
503
513
|
// early return if no results
|
|
504
514
|
return [2 /*return*/, {}];
|
|
505
515
|
}
|
|
506
|
-
bytes = results[results.length - 1].returnValues[0]
|
|
516
|
+
bytes = results[results.length - 1].returnValues[0].bcs;
|
|
507
517
|
reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
508
518
|
result = Array.from(new Map()).reduce(function (map, _a) {
|
|
509
519
|
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
@@ -561,6 +571,8 @@ function getRefundShares(config, input) {
|
|
|
561
571
|
});
|
|
562
572
|
return [4 /*yield*/, provider.simulateTransaction({
|
|
563
573
|
transaction: transaction,
|
|
574
|
+
checksEnabled: false,
|
|
575
|
+
include: { commandResults: true },
|
|
564
576
|
})];
|
|
565
577
|
case 1:
|
|
566
578
|
results = (_a.sent()).commandResults;
|
|
@@ -583,3 +595,35 @@ function getRefundShares(config, input) {
|
|
|
583
595
|
});
|
|
584
596
|
});
|
|
585
597
|
}
|
|
598
|
+
function getUserOwnedObjects(config, user) {
|
|
599
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
600
|
+
var provider, result, hasNextPage, data, cursor;
|
|
601
|
+
return __generator(this, function (_a) {
|
|
602
|
+
switch (_a.label) {
|
|
603
|
+
case 0:
|
|
604
|
+
provider = config.gRpcClient();
|
|
605
|
+
return [4 /*yield*/, provider.listOwnedObjects({ owner: user, include: { content: true } })];
|
|
606
|
+
case 1:
|
|
607
|
+
result = _a.sent();
|
|
608
|
+
hasNextPage = result.hasNextPage;
|
|
609
|
+
data = result.objects;
|
|
610
|
+
cursor = result.cursor;
|
|
611
|
+
_a.label = 2;
|
|
612
|
+
case 2:
|
|
613
|
+
if (!hasNextPage) return [3 /*break*/, 4];
|
|
614
|
+
return [4 /*yield*/, provider.listOwnedObjects({
|
|
615
|
+
owner: user,
|
|
616
|
+
cursor: cursor,
|
|
617
|
+
include: { content: true },
|
|
618
|
+
})];
|
|
619
|
+
case 3:
|
|
620
|
+
result = _a.sent();
|
|
621
|
+
data = __spreadArray(__spreadArray([], __read(data), false), __read(result.objects), false);
|
|
622
|
+
hasNextPage = result.hasNextPage;
|
|
623
|
+
cursor = result.cursor;
|
|
624
|
+
return [3 /*break*/, 2];
|
|
625
|
+
case 4: return [2 /*return*/, data];
|
|
626
|
+
}
|
|
627
|
+
});
|
|
628
|
+
});
|
|
629
|
+
}
|
|
@@ -57,7 +57,11 @@ function getAirdrop(config, input) {
|
|
|
57
57
|
target: "".concat(config.package.launch.airdrop, "::airdrop::get_airdrop_bcs"),
|
|
58
58
|
arguments: [transaction.object(config.registry.launch.airdrop), transaction.pure.address(input.user)],
|
|
59
59
|
});
|
|
60
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
60
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
61
|
+
transaction: transaction,
|
|
62
|
+
checksEnabled: false,
|
|
63
|
+
include: { commandResults: true },
|
|
64
|
+
})];
|
|
61
65
|
case 1:
|
|
62
66
|
devInspectTransactionBlockResult = _a.sent();
|
|
63
67
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -118,11 +118,11 @@ function getFund(config, input) {
|
|
|
118
118
|
results = (_a.sent())
|
|
119
119
|
.commandResults;
|
|
120
120
|
funds = {};
|
|
121
|
+
// console.log(results);
|
|
121
122
|
results === null || results === void 0 ? void 0 : results.forEach(function (result, i) {
|
|
122
123
|
// @ts-ignore
|
|
123
124
|
var bytes = result.returnValues[0].bcs;
|
|
124
125
|
var reader = new bcs_1.BcsReader(new Uint8Array(bytes));
|
|
125
|
-
reader.readULEB();
|
|
126
126
|
var fund = reader.readVec(function (reader) {
|
|
127
127
|
return {
|
|
128
128
|
balance: reader.read64(),
|
|
@@ -133,7 +133,11 @@ function getEndedTips(config) {
|
|
|
133
133
|
target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tips_bcs"),
|
|
134
134
|
arguments: [transaction.object(config.registry.launch.improvementProposal)],
|
|
135
135
|
});
|
|
136
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
136
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
137
|
+
transaction: transaction,
|
|
138
|
+
checksEnabled: false,
|
|
139
|
+
include: { commandResults: true },
|
|
140
|
+
})];
|
|
137
141
|
case 1:
|
|
138
142
|
devInspectTransactionBlockResult = _a.sent();
|
|
139
143
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -198,7 +202,11 @@ function getOngoingTipVotes(config, input) {
|
|
|
198
202
|
target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ongoing_tip_votes_bcs"),
|
|
199
203
|
arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
|
|
200
204
|
});
|
|
201
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
205
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
206
|
+
transaction: transaction,
|
|
207
|
+
checksEnabled: false,
|
|
208
|
+
include: { commandResults: true },
|
|
209
|
+
})];
|
|
202
210
|
case 1:
|
|
203
211
|
devInspectTransactionBlockResult = _a.sent();
|
|
204
212
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -235,7 +243,11 @@ function getEndedTipVotes(config, input) {
|
|
|
235
243
|
target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_ended_tip_votes_bcs"),
|
|
236
244
|
arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.address(input.user)],
|
|
237
245
|
});
|
|
238
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
246
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
247
|
+
transaction: transaction,
|
|
248
|
+
checksEnabled: false,
|
|
249
|
+
include: { commandResults: true },
|
|
250
|
+
})];
|
|
239
251
|
case 1:
|
|
240
252
|
devInspectTransactionBlockResult = _a.sent();
|
|
241
253
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -272,7 +284,11 @@ function getTipVotes(config, input) {
|
|
|
272
284
|
target: "".concat(config.package.launch.improvementProposal, "::improvement_proposal::get_tip_votes_bcs"),
|
|
273
285
|
arguments: [transaction.object(config.registry.launch.improvementProposal), transaction.pure.u64(input.index)],
|
|
274
286
|
});
|
|
275
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
287
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
288
|
+
transaction: transaction,
|
|
289
|
+
checksEnabled: false,
|
|
290
|
+
include: { commandResults: true },
|
|
291
|
+
})];
|
|
276
292
|
case 1:
|
|
277
293
|
devInspectTransactionBlockResult = _a.sent();
|
|
278
294
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -54,7 +54,11 @@ function getVeTypus(config, input) {
|
|
|
54
54
|
target: "".concat(config.package.launch.veTypus, "::ve_typus::get_ve_typus_bcs"),
|
|
55
55
|
arguments: [transaction.object(config.registry.launch.veTypus), transaction.pure.address(input.user)],
|
|
56
56
|
});
|
|
57
|
-
return [4 /*yield*/, provider.simulateTransaction({
|
|
57
|
+
return [4 /*yield*/, provider.simulateTransaction({
|
|
58
|
+
transaction: transaction,
|
|
59
|
+
checksEnabled: false,
|
|
60
|
+
include: { commandResults: true },
|
|
61
|
+
})];
|
|
58
62
|
case 1:
|
|
59
63
|
devInspectTransactionBlockResult = _a.sent();
|
|
60
64
|
bytes = devInspectTransactionBlockResult.commandResults[0].returnValues[0].bcs;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { KioskClient, KioskListing } from "@mysten/kiosk";
|
|
2
|
+
import { SuiGraphQLClient } from "@mysten/sui/graphql";
|
|
3
|
+
export interface TailsId {
|
|
4
|
+
nftId: string;
|
|
5
|
+
kiosk: string;
|
|
6
|
+
kioskCap: string;
|
|
7
|
+
tails: Tails | undefined;
|
|
8
|
+
isPersonal: boolean;
|
|
9
|
+
listing?: KioskListing;
|
|
10
|
+
}
|
|
11
|
+
export interface kioskOwnerCap {
|
|
12
|
+
kioskId: string;
|
|
13
|
+
objectId: string;
|
|
14
|
+
isPersonal: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare function getTailsIds(kioskClient: KioskClient, NFT_PACKAGE_ORIGIN: string, kioskOwnerCaps: kioskOwnerCap[]): Promise<TailsId[]>;
|
|
17
|
+
export interface TailsWithType extends Tails {
|
|
18
|
+
type: string | null | undefined;
|
|
19
|
+
}
|
|
20
|
+
export declare function getTails(provider: SuiGraphQLClient, tailsIds: string[]): Promise<TailsWithType[]>;
|
|
21
|
+
export interface Tails {
|
|
22
|
+
id: string;
|
|
23
|
+
name: string;
|
|
24
|
+
number: string;
|
|
25
|
+
url: string;
|
|
26
|
+
level: string;
|
|
27
|
+
exp: string;
|
|
28
|
+
first_bid: string;
|
|
29
|
+
first_deposit: string;
|
|
30
|
+
first_deposit_nft: string;
|
|
31
|
+
attributes: Map<string, string>;
|
|
32
|
+
u64_padding: Map<string, string>;
|
|
33
|
+
}
|
|
34
|
+
export declare function getLevelExp(level: number): number | undefined;
|
|
35
|
+
export declare const LevelExpVec: number[];
|
|
36
|
+
export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __values = (this && this.__values) || function(o) {
|
|
50
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
51
|
+
if (m) return m.call(o);
|
|
52
|
+
if (o && typeof o.length === "number") return {
|
|
53
|
+
next: function () {
|
|
54
|
+
if (o && i >= o.length) o = void 0;
|
|
55
|
+
return { value: o && o[i++], done: !o };
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
59
|
+
};
|
|
60
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
61
|
+
exports.LevelExpVec = void 0;
|
|
62
|
+
exports.getTailsIds = getTailsIds;
|
|
63
|
+
exports.getTails = getTails;
|
|
64
|
+
exports.getLevelExp = getLevelExp;
|
|
65
|
+
exports.calculateLevelReward = calculateLevelReward;
|
|
66
|
+
function getTailsIds(kioskClient, NFT_PACKAGE_ORIGIN, kioskOwnerCaps) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var Tails, _loop_1, kioskOwnerCaps_1, kioskOwnerCaps_1_1, kioskOwnerCap, e_1_1;
|
|
69
|
+
var e_1, _a;
|
|
70
|
+
return __generator(this, function (_b) {
|
|
71
|
+
switch (_b.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
Tails = [];
|
|
74
|
+
_loop_1 = function (kioskOwnerCap) {
|
|
75
|
+
var res, tails;
|
|
76
|
+
return __generator(this, function (_c) {
|
|
77
|
+
switch (_c.label) {
|
|
78
|
+
case 0: return [4 /*yield*/, kioskClient.getKiosk({ id: kioskOwnerCap.kioskId })];
|
|
79
|
+
case 1:
|
|
80
|
+
res = _c.sent();
|
|
81
|
+
tails = res.items
|
|
82
|
+
.filter(function (item) { return item.type == "".concat(NFT_PACKAGE_ORIGIN, "::typus_nft::Tails"); })
|
|
83
|
+
.map(function (item) {
|
|
84
|
+
// console.log(item);
|
|
85
|
+
// @ts-ignore
|
|
86
|
+
var tails = item.data;
|
|
87
|
+
var t = {
|
|
88
|
+
kiosk: kioskOwnerCap.kioskId,
|
|
89
|
+
kioskCap: kioskOwnerCap.objectId,
|
|
90
|
+
isPersonal: kioskOwnerCap.isPersonal,
|
|
91
|
+
nftId: item.objectId,
|
|
92
|
+
listing: item.listing,
|
|
93
|
+
tails: tails,
|
|
94
|
+
};
|
|
95
|
+
return t;
|
|
96
|
+
});
|
|
97
|
+
// console.log(tails);
|
|
98
|
+
Tails = Tails.concat(tails);
|
|
99
|
+
return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
_b.label = 1;
|
|
104
|
+
case 1:
|
|
105
|
+
_b.trys.push([1, 6, 7, 8]);
|
|
106
|
+
kioskOwnerCaps_1 = __values(kioskOwnerCaps), kioskOwnerCaps_1_1 = kioskOwnerCaps_1.next();
|
|
107
|
+
_b.label = 2;
|
|
108
|
+
case 2:
|
|
109
|
+
if (!!kioskOwnerCaps_1_1.done) return [3 /*break*/, 5];
|
|
110
|
+
kioskOwnerCap = kioskOwnerCaps_1_1.value;
|
|
111
|
+
return [5 /*yield**/, _loop_1(kioskOwnerCap)];
|
|
112
|
+
case 3:
|
|
113
|
+
_b.sent();
|
|
114
|
+
_b.label = 4;
|
|
115
|
+
case 4:
|
|
116
|
+
kioskOwnerCaps_1_1 = kioskOwnerCaps_1.next();
|
|
117
|
+
return [3 /*break*/, 2];
|
|
118
|
+
case 5: return [3 /*break*/, 8];
|
|
119
|
+
case 6:
|
|
120
|
+
e_1_1 = _b.sent();
|
|
121
|
+
e_1 = { error: e_1_1 };
|
|
122
|
+
return [3 /*break*/, 8];
|
|
123
|
+
case 7:
|
|
124
|
+
try {
|
|
125
|
+
if (kioskOwnerCaps_1_1 && !kioskOwnerCaps_1_1.done && (_a = kioskOwnerCaps_1.return)) _a.call(kioskOwnerCaps_1);
|
|
126
|
+
}
|
|
127
|
+
finally { if (e_1) throw e_1.error; }
|
|
128
|
+
return [7 /*endfinally*/];
|
|
129
|
+
case 8: return [2 /*return*/, Tails];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
function getTails(provider, tailsIds) {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
136
|
+
var Tails, len, results, _loop_2, _a, _b, result;
|
|
137
|
+
var e_2, _c;
|
|
138
|
+
return __generator(this, function (_d) {
|
|
139
|
+
switch (_d.label) {
|
|
140
|
+
case 0:
|
|
141
|
+
Tails = [];
|
|
142
|
+
_d.label = 1;
|
|
143
|
+
case 1:
|
|
144
|
+
if (!(tailsIds.length > 0)) return [3 /*break*/, 3];
|
|
145
|
+
len = tailsIds.length > 50 ? 50 : tailsIds.length;
|
|
146
|
+
return [4 /*yield*/, provider.getObjects({ objectIds: tailsIds.splice(0, len), include: { json: true } })];
|
|
147
|
+
case 2:
|
|
148
|
+
results = _d.sent();
|
|
149
|
+
_loop_2 = function (result) {
|
|
150
|
+
if (result instanceof Error) {
|
|
151
|
+
console.error(result.cause);
|
|
152
|
+
return "continue";
|
|
153
|
+
}
|
|
154
|
+
var json = result.json;
|
|
155
|
+
// @ts-ignore
|
|
156
|
+
var tails = json;
|
|
157
|
+
var attributes = new Map();
|
|
158
|
+
// @ts-ignore
|
|
159
|
+
json.attributes.contents.forEach(function (f) { return attributes.set(f.key, f.value); });
|
|
160
|
+
var u64_padding = new Map();
|
|
161
|
+
// @ts-ignore
|
|
162
|
+
json.u64_padding.contents.forEach(function (f) { return u64_padding.set(f.key, f.value); });
|
|
163
|
+
tails.attributes = attributes;
|
|
164
|
+
tails.u64_padding = u64_padding;
|
|
165
|
+
// @ts-ignore
|
|
166
|
+
Tails.push(__assign(__assign({}, tails), { type: result.type }));
|
|
167
|
+
};
|
|
168
|
+
try {
|
|
169
|
+
for (_a = (e_2 = void 0, __values(results.objects)), _b = _a.next(); !_b.done; _b = _a.next()) {
|
|
170
|
+
result = _b.value;
|
|
171
|
+
_loop_2(result);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
175
|
+
finally {
|
|
176
|
+
try {
|
|
177
|
+
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
178
|
+
}
|
|
179
|
+
finally { if (e_2) throw e_2.error; }
|
|
180
|
+
}
|
|
181
|
+
return [3 /*break*/, 1];
|
|
182
|
+
case 3: return [2 /*return*/, Tails];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
function getLevelExp(level) {
|
|
188
|
+
switch (level) {
|
|
189
|
+
case 1:
|
|
190
|
+
return exports.LevelExpVec[1];
|
|
191
|
+
case 2:
|
|
192
|
+
return exports.LevelExpVec[2];
|
|
193
|
+
case 3:
|
|
194
|
+
return exports.LevelExpVec[3];
|
|
195
|
+
case 4:
|
|
196
|
+
return exports.LevelExpVec[4];
|
|
197
|
+
case 5:
|
|
198
|
+
return exports.LevelExpVec[5];
|
|
199
|
+
case 6:
|
|
200
|
+
return exports.LevelExpVec[6];
|
|
201
|
+
case 7:
|
|
202
|
+
return exports.LevelExpVec[7];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
exports.LevelExpVec = [0, 0, 1000, 50000, 250000, 1000000, 5000000, 20000000];
|
|
206
|
+
function calculateLevelReward(totalRewards, levelShares, numOfHolders) {
|
|
207
|
+
// Step 1: Calculate original level rewards (per holder)
|
|
208
|
+
var totalShares = levelShares.reduce(function (acc, share) { return acc + share; }, 0);
|
|
209
|
+
var originalRewardPerHolder = levelShares.map(function (levelShare, index) {
|
|
210
|
+
var num = numOfHolders[index];
|
|
211
|
+
var levelRewardPerHolder = num > 0 ? (totalRewards * levelShare) / totalShares / num : 0;
|
|
212
|
+
return Math.floor(levelRewardPerHolder);
|
|
213
|
+
});
|
|
214
|
+
var originalLevelRewards = originalRewardPerHolder.map(function (reward, index) { return reward * numOfHolders[index]; });
|
|
215
|
+
var distributedRewards = originalLevelRewards.reduce(function (acc, reward) { return acc + reward; }, 0);
|
|
216
|
+
var emptyLevelRewards = totalRewards - distributedRewards;
|
|
217
|
+
// Step 2: Distribute rewards from empty levels
|
|
218
|
+
var reversedOriginalRewardPerHolder = originalRewardPerHolder.slice().reverse();
|
|
219
|
+
var reversedNumOfHolders = numOfHolders.slice().reverse();
|
|
220
|
+
var reversedScaledRewardPerHolder = [];
|
|
221
|
+
if (emptyLevelRewards > 0) {
|
|
222
|
+
var undistributedRewards_1 = emptyLevelRewards;
|
|
223
|
+
var uncalculatedDistributedRewards_1 = distributedRewards;
|
|
224
|
+
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
225
|
+
var num = reversedNumOfHolders[index];
|
|
226
|
+
var scaledRewardPerHolder = num > 0
|
|
227
|
+
? uncalculatedDistributedRewards_1 > 0
|
|
228
|
+
? (rewardPerHolder * (uncalculatedDistributedRewards_1 + undistributedRewards_1)) / uncalculatedDistributedRewards_1
|
|
229
|
+
: rewardPerHolder
|
|
230
|
+
: 0;
|
|
231
|
+
undistributedRewards_1 -= (scaledRewardPerHolder - rewardPerHolder) * num;
|
|
232
|
+
uncalculatedDistributedRewards_1 -= rewardPerHolder * num;
|
|
233
|
+
return Math.floor(scaledRewardPerHolder);
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.slice();
|
|
238
|
+
}
|
|
239
|
+
// Step 3: Capped level reward
|
|
240
|
+
var reversedCappedRewardPerHolder = [reversedOriginalRewardPerHolder[0]];
|
|
241
|
+
var tempHighLevelReward = 0;
|
|
242
|
+
reversedScaledRewardPerHolder.forEach(function (highLevelReward, index) {
|
|
243
|
+
var lowLevelReward = reversedScaledRewardPerHolder[index + 1] || 0;
|
|
244
|
+
tempHighLevelReward =
|
|
245
|
+
highLevelReward > 0
|
|
246
|
+
? tempHighLevelReward > 0
|
|
247
|
+
? Math.min(highLevelReward, tempHighLevelReward)
|
|
248
|
+
: highLevelReward
|
|
249
|
+
: tempHighLevelReward;
|
|
250
|
+
reversedCappedRewardPerHolder.push(tempHighLevelReward > 0 ? Math.min(lowLevelReward, tempHighLevelReward) : lowLevelReward);
|
|
251
|
+
});
|
|
252
|
+
reversedCappedRewardPerHolder.pop();
|
|
253
|
+
var cappedRewardPerHolder = reversedCappedRewardPerHolder.slice().reverse();
|
|
254
|
+
// Step 4: Distribute capped reward from Step 3 into each level
|
|
255
|
+
var distributedRewardsStep4 = reversedCappedRewardPerHolder.reduce(function (acc, reward, index) { return acc + reward * reversedNumOfHolders[index]; }, 0);
|
|
256
|
+
var undistributedRewardsStep4 = totalRewards - distributedRewardsStep4;
|
|
257
|
+
var uncalculatedDistributedRewardsStep4 = distributedRewardsStep4;
|
|
258
|
+
var levelReward = cappedRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
259
|
+
var num = reversedNumOfHolders[index];
|
|
260
|
+
var scaledRewardPerHolder = uncalculatedDistributedRewardsStep4 > 0
|
|
261
|
+
? (rewardPerHolder * (uncalculatedDistributedRewardsStep4 + undistributedRewardsStep4)) /
|
|
262
|
+
uncalculatedDistributedRewardsStep4
|
|
263
|
+
: rewardPerHolder;
|
|
264
|
+
undistributedRewardsStep4 -= (scaledRewardPerHolder - rewardPerHolder) * num;
|
|
265
|
+
uncalculatedDistributedRewardsStep4 -= rewardPerHolder * num;
|
|
266
|
+
return Math.floor(scaledRewardPerHolder);
|
|
267
|
+
});
|
|
268
|
+
return levelReward;
|
|
269
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./fetch";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./fetch"), exports);
|