@typus/typus-sdk 1.2.66 → 1.2.68-tgld

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.
Files changed (51) hide show
  1. package/lib/config.json +155 -0
  2. package/lib/mainnet.json +2 -2
  3. package/lib/utils/airdrop/authority-entry.d.ts +22 -0
  4. package/lib/utils/airdrop/authority-entry.js +138 -0
  5. package/lib/utils/airdrop/user-entry.d.ts +10 -0
  6. package/lib/utils/airdrop/user-entry.js +21 -0
  7. package/lib/utils/airdrop/view-functions.d.ts +10 -0
  8. package/lib/utils/airdrop/view-functions.js +72 -0
  9. package/lib/utils/api/defillama/tvl.d.ts +1 -0
  10. package/lib/utils/api/defillama/tvl.js +59 -0
  11. package/lib/utils/{leader-board.d.ts → api/sentio/leader-board.d.ts} +0 -7
  12. package/lib/utils/api/sentio/leader-board.js +104 -0
  13. package/lib/utils/api/sentio/reward-generated.d.ts +10 -0
  14. package/lib/utils/api/sentio/reward-generated.js +256 -0
  15. package/lib/utils/leaderboard/authority-entry.d.ts +22 -0
  16. package/lib/utils/leaderboard/authority-entry.js +91 -0
  17. package/lib/utils/leaderboard/view-function.d.ts +21 -0
  18. package/lib/utils/leaderboard/view-function.js +92 -0
  19. package/lib/utils/locked-period-vault/user-entry.d.ts +81 -0
  20. package/lib/utils/locked-period-vault/user-entry.js +101 -0
  21. package/lib/utils/typus-dov-single-v2/mfud-user-entry.d.ts +4 -0
  22. package/lib/utils/typus-dov-single-v2/mfud-user-entry.js +5 -1
  23. package/lib/utils/typus-dov-single-v2/user-entry.d.ts +4 -0
  24. package/lib/utils/typus-dov-single-v2/user-entry.js +10 -2
  25. package/lib/utils/typus-dov-single-v2/user-history.js +22 -3
  26. package/lib/utils/user/view-functions.d.ts +9 -0
  27. package/lib/utils/user/view-functions.js +71 -0
  28. package/package.json +1 -1
  29. package/lib/utils/leader-board.js +0 -333
  30. package/lib/utils/typus-dov-double/authorized-entry.d.ts +0 -102
  31. package/lib/utils/typus-dov-double/authorized-entry.js +0 -295
  32. package/lib/utils/typus-dov-double/manager-entry.d.ts +0 -219
  33. package/lib/utils/typus-dov-double/manager-entry.js +0 -584
  34. package/lib/utils/typus-dov-double/portfolio-vault.d.ts +0 -68
  35. package/lib/utils/typus-dov-double/portfolio-vault.js +0 -303
  36. package/lib/utils/typus-dov-double/user-entry.d.ts +0 -93
  37. package/lib/utils/typus-dov-double/user-entry.js +0 -280
  38. package/lib/utils/typus-dov-double/view-function.d.ts +0 -11
  39. package/lib/utils/typus-dov-double/view-function.js +0 -213
  40. package/lib/utils/typus-dov-single/db-data.d.ts +0 -19
  41. package/lib/utils/typus-dov-single/db-data.js +0 -226
  42. package/lib/utils/typus-dov-single/portfolio-vault.d.ts +0 -63
  43. package/lib/utils/typus-dov-single/portfolio-vault.js +0 -284
  44. package/lib/utils/typus-dov-single/registry.d.ts +0 -14
  45. package/lib/utils/typus-dov-single/registry.js +0 -126
  46. package/lib/utils/typus-dov-single/user-entry.d.ts +0 -103
  47. package/lib/utils/typus-dov-single/user-entry.js +0 -388
  48. package/lib/utils/typus-dov-single/user-history.d.ts +0 -17
  49. package/lib/utils/typus-dov-single/user-history.js +0 -146
  50. package/lib/utils/typus-dov-single/view-function.d.ts +0 -50
  51. package/lib/utils/typus-dov-single/view-function.js +0 -444
@@ -308,9 +308,13 @@ function getNewBidTx(input) {
308
308
  ],
309
309
  });
310
310
  var result = input.tx.moveCall({
311
- target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid_v2"),
311
+ target: "".concat(input.typusDovSinglePackageId, "::tails_staking::bid"),
312
312
  typeArguments: input.typeArguments,
313
313
  arguments: [
314
+ input.tx.object(input.typusEcosystemVersion),
315
+ input.tx.object(input.typusUserRegistry),
316
+ input.tx.object(input.tgldRegistry),
317
+ input.tx.object(input.typusLeaderboardRegistry),
314
318
  input.tx.object(input.typusDovSingleRegistry),
315
319
  input.tx.pure(input.index),
316
320
  input.tx.makeMoveVec({ objects: [mfud] }),
@@ -173,6 +173,10 @@ export declare function getWithdrawHarvestClaimTx(input: {
173
173
  */
174
174
  export declare function getNewBidTx(input: {
175
175
  tx: TransactionBlock;
176
+ typusEcosystemVersion: string;
177
+ typusUserRegistry: string;
178
+ tgldRegistry: string;
179
+ typusLeaderboardRegistry: string;
176
180
  typusFrameworkPackageId: string;
177
181
  typusDovSinglePackageId: string;
178
182
  typusDovSingleRegistry: string;
@@ -442,9 +442,13 @@ function getNewBidTx(input) {
442
442
  input.typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI")) {
443
443
  var _a = __read(input.tx.splitCoins(input.tx.gas, [input.tx.pure(input.premium_required)]), 1), coin = _a[0];
444
444
  var result = input.tx.moveCall({
445
- target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid_v2"),
445
+ target: "".concat(input.typusDovSinglePackageId, "::tails_staking::bid"),
446
446
  typeArguments: input.typeArguments,
447
447
  arguments: [
448
+ input.tx.object(input.typusEcosystemVersion),
449
+ input.tx.object(input.typusUserRegistry),
450
+ input.tx.object(input.tgldRegistry),
451
+ input.tx.object(input.typusLeaderboardRegistry),
448
452
  input.tx.object(input.typusDovSingleRegistry),
449
453
  input.tx.pure(input.index),
450
454
  input.tx.makeMoveVec({ objects: [coin] }),
@@ -474,9 +478,13 @@ function getNewBidTx(input) {
474
478
  arguments: [input.tx.object(balance)],
475
479
  });
476
480
  var result = input.tx.moveCall({
477
- target: "".concat(input.typusDovSinglePackageId, "::tails_staking::new_bid_v2"),
481
+ target: "".concat(input.typusDovSinglePackageId, "::tails_staking::bid"),
478
482
  typeArguments: input.typeArguments,
479
483
  arguments: [
484
+ input.tx.object(input.typusEcosystemVersion),
485
+ input.tx.object(input.typusUserRegistry),
486
+ input.tx.object(input.tgldRegistry),
487
+ input.tx.object(input.typusLeaderboardRegistry),
480
488
  input.tx.object(input.typusDovSingleRegistry),
481
489
  input.tx.pure(input.index),
482
490
  input.tx.makeMoveVec({ objects: [coin] }),
@@ -304,10 +304,25 @@ function parseTxHistory(datas, originPackage, vaults) {
304
304
  Action = "Rebate";
305
305
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
306
306
  break;
307
- case "ClaimProfitSharingEvent":
307
+ // case "ClaimProfitSharingEvent":
308
+ // var token = typeArgToAsset("0x" + event.parsedJson!.token.name);
309
+ // var amount = Number(event.parsedJson!.value) / 10 ** assetToDecimal(token)!;
310
+ // Action = "Claim Profit Sharing";
311
+ // Amount = `${BigNumber(amount).toFixed()} ${token}`;
312
+ // Tails = `#${event.parsedJson!.number}`;
313
+ // break;
314
+ case "ClaimProfitSharingEventV2":
308
315
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
309
316
  amount = Number(event.parsedJson.value) / Math.pow(10, (0, token_1.assetToDecimal)(token));
310
- Action = "Claim Profit Sharing";
317
+ // dice_profit, exp_profit
318
+ switch (event.parsedJson.name) {
319
+ case "dice_profit":
320
+ Action = "Harvest Dice Profit";
321
+ break;
322
+ case "exp_profit":
323
+ Action = "Harvest Leaderboard Prize";
324
+ break;
325
+ }
311
326
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
312
327
  Tails = "#".concat(event.parsedJson.number);
313
328
  break;
@@ -396,7 +411,7 @@ function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
396
411
  };
397
412
  requestData = {
398
413
  sqlQuery: {
399
- sql: "\n SELECT *\n FROM NewBid N\n JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
414
+ sql: "\n SELECT *\n FROM NewBid N\n LEFT JOIN (\n SELECT number, distinct_id, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash && N.log_index + 1 = S.log_index\n WHERE N.distinct_id = \"".concat(userAddress, "\" && N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
400
415
  size: 1000,
401
416
  },
402
417
  };
@@ -413,6 +428,10 @@ function getNewBidFromSentio(vaults, userAddress, startTimestamp) {
413
428
  data = _a.sent();
414
429
  return [2 /*return*/, data.result.rows.map(function (x) {
415
430
  var _a = __read(parseVaultInfo(vaults, x.index, "NewBidEvent"), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
431
+ if (x.number == "0" && x.exp_earn == "0") {
432
+ x.number = undefined;
433
+ x.exp_earn = undefined;
434
+ }
416
435
  var txHistory = {
417
436
  Index: x.index,
418
437
  Period: Period,
@@ -0,0 +1,9 @@
1
+ import { SuiClient } from "@mysten/sui.js/client";
2
+ export declare const SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
3
+ export declare function getAirdrop(input: {
4
+ provider: SuiClient;
5
+ typusPackageId: string;
6
+ typusEcosystemVersion: string;
7
+ typusUserRegistry: string;
8
+ user: string;
9
+ }): Promise<string[]>;
@@ -0,0 +1,71 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.getAirdrop = exports.SENDER = void 0;
40
+ var transactions_1 = require("@mysten/sui.js/transactions");
41
+ var bcs_1 = require("@mysten/bcs");
42
+ exports.SENDER = "0xAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
43
+ function getAirdrop(input) {
44
+ return __awaiter(this, void 0, void 0, function () {
45
+ var transactionBlock, results, bytes, reader;
46
+ return __generator(this, function (_a) {
47
+ switch (_a.label) {
48
+ case 0:
49
+ transactionBlock = new transactions_1.TransactionBlock();
50
+ transactionBlock.moveCall({
51
+ target: "".concat(input.typusPackageId, "::user::get_user_metadata"),
52
+ typeArguments: [],
53
+ arguments: [
54
+ transactionBlock.pure(input.typusEcosystemVersion),
55
+ transactionBlock.pure(input.typusUserRegistry),
56
+ transactionBlock.pure(input.user),
57
+ ],
58
+ });
59
+ return [4 /*yield*/, input.provider.devInspectTransactionBlock({ sender: exports.SENDER, transactionBlock: transactionBlock })];
60
+ case 1:
61
+ results = (_a.sent()).results;
62
+ bytes = results[results.length - 1].returnValues[0][0];
63
+ reader = new bcs_1.BcsReader(new Uint8Array(bytes));
64
+ return [2 /*return*/, reader.readVec(function (reader) {
65
+ return reader.read64();
66
+ })];
67
+ }
68
+ });
69
+ });
70
+ }
71
+ exports.getAirdrop = getAirdrop;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.2.66",
5
+ "version": "1.2.68-tgld",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.7.12",
@@ -1,333 +0,0 @@
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 __read = (this && this.__read) || function (o, n) {
39
- var m = typeof Symbol === "function" && o[Symbol.iterator];
40
- if (!m) return o;
41
- var i = m.call(o), r, ar = [], e;
42
- try {
43
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
44
- }
45
- catch (error) { e = { error: error }; }
46
- finally {
47
- try {
48
- if (r && !r.done && (m = i["return"])) m.call(i);
49
- }
50
- finally { if (e) throw e.error; }
51
- }
52
- return ar;
53
- };
54
- Object.defineProperty(exports, "__esModule", { value: true });
55
- exports.getExpLeaderBoard = exports.getExpLeaderBoardWithOwner = exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
56
- var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
57
- var headers = {
58
- "api-key": "oBOW8DsO1izVrINCy6Tmxga9YcWeOL87O",
59
- "Content-Type": "application/json",
60
- };
61
- var depositorRequestData = {
62
- timeRange: {
63
- start: "-7d",
64
- end: "now",
65
- step: 3600,
66
- },
67
- limit: 200,
68
- queries: [
69
- {
70
- metricsQuery: {
71
- query: "depositTvl",
72
- alias: "",
73
- id: "a",
74
- labelSelector: {},
75
- aggregate: {
76
- op: "SUM",
77
- grouping: ["user", "coin_symbol"],
78
- },
79
- functions: [],
80
- disabled: true,
81
- },
82
- dataSource: "METRICS",
83
- },
84
- {
85
- priceQuery: {
86
- id: "b",
87
- alias: "",
88
- coinId: [
89
- {
90
- symbol: "SUI",
91
- },
92
- {
93
- symbol: "USDC",
94
- },
95
- ],
96
- disabled: true,
97
- },
98
- dataSource: "PRICE",
99
- },
100
- ],
101
- formulas: [
102
- {
103
- expression: "a*b",
104
- alias: "{{user}}",
105
- id: "A",
106
- disabled: false,
107
- },
108
- ],
109
- };
110
- function getDepositorLeaderBoard(start, end, step) {
111
- return __awaiter(this, void 0, void 0, function () {
112
- var jsonData, response, data, samples, len_1, leader_board, userScoreMap, result, e_1;
113
- return __generator(this, function (_a) {
114
- switch (_a.label) {
115
- case 0:
116
- if (start) {
117
- depositorRequestData.timeRange.start = start;
118
- }
119
- if (end) {
120
- depositorRequestData.timeRange.end = end;
121
- }
122
- if (step) {
123
- depositorRequestData.timeRange.step = step;
124
- }
125
- jsonData = JSON.stringify(depositorRequestData);
126
- return [4 /*yield*/, fetch(apiUrl, {
127
- method: "POST",
128
- headers: headers,
129
- body: jsonData,
130
- })];
131
- case 1:
132
- response = _a.sent();
133
- _a.label = 2;
134
- case 2:
135
- _a.trys.push([2, 4, , 5]);
136
- return [4 /*yield*/, response.json()];
137
- case 3:
138
- data = _a.sent();
139
- samples = data.results[0].matrix.samples;
140
- len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0) - 1;
141
- leader_board = samples
142
- .map(function (element) {
143
- // console.log("metric:", element.metric, "values: ", element.values);
144
- // console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
145
- var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / len_1; }, 0);
146
- return {
147
- user: element.metric.labels.user,
148
- score: sum,
149
- };
150
- })
151
- .filter(function (element) { return element.score != 0; });
152
- userScoreMap = leader_board.reduce(function (map, obj) {
153
- if (map[obj.user]) {
154
- map[obj.user] += obj.score;
155
- }
156
- else {
157
- map[obj.user] = obj.score;
158
- }
159
- return map;
160
- }, {});
161
- result = Object.entries(userScoreMap).map(function (_a) {
162
- var _b = __read(_a, 2), user = _b[0], score = _b[1];
163
- return ({ user: user, score: score });
164
- });
165
- result.sort(function (a, b) { return b.score - a.score; });
166
- // console.log(result);
167
- return [2 /*return*/, result];
168
- case 4:
169
- e_1 = _a.sent();
170
- return [2 /*return*/, []];
171
- case 5: return [2 /*return*/];
172
- }
173
- });
174
- });
175
- }
176
- exports.getDepositorLeaderBoard = getDepositorLeaderBoard;
177
- var bidderRequestData = {
178
- timeRange: {
179
- start: "-7d",
180
- end: "now",
181
- step: 3600,
182
- },
183
- limit: 200,
184
- queries: [
185
- {
186
- metricsQuery: {
187
- query: "totalNewBid",
188
- alias: "",
189
- id: "a",
190
- labelSelector: {},
191
- aggregate: {
192
- op: "SUM",
193
- grouping: ["user"],
194
- },
195
- functions: [],
196
- disabled: false,
197
- },
198
- dataSource: "METRICS",
199
- },
200
- ],
201
- };
202
- function getBidderLeaderBoard(startTimestamp, end) {
203
- return __awaiter(this, void 0, void 0, function () {
204
- var jsonData, response, data, samples, leader_board, userScoreMap, result, e_2;
205
- return __generator(this, function (_a) {
206
- switch (_a.label) {
207
- case 0:
208
- if (startTimestamp) {
209
- bidderRequestData.timeRange.start = startTimestamp;
210
- }
211
- if (end) {
212
- bidderRequestData.timeRange.end = end;
213
- }
214
- jsonData = JSON.stringify(bidderRequestData);
215
- return [4 /*yield*/, fetch(apiUrl, {
216
- method: "POST",
217
- headers: headers,
218
- body: jsonData,
219
- })];
220
- case 1:
221
- response = _a.sent();
222
- _a.label = 2;
223
- case 2:
224
- _a.trys.push([2, 4, , 5]);
225
- return [4 /*yield*/, response.json()];
226
- case 3:
227
- data = _a.sent();
228
- samples = data.results[0].matrix.samples;
229
- leader_board = samples
230
- .map(function (element) {
231
- // console.log("metric:", element.metric, "values: ", element.values);
232
- // console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
233
- var a = 0;
234
- var log_0 = element.values.at(0);
235
- if (log_0.timestamp == startTimestamp) {
236
- a = log_0.value;
237
- }
238
- var b = element.values.at(-1).value;
239
- return {
240
- user: element.metric.labels.user,
241
- score: b - a,
242
- };
243
- })
244
- .filter(function (element) { return element.score != 0; });
245
- userScoreMap = leader_board.reduce(function (map, obj) {
246
- if (map[obj.user]) {
247
- map[obj.user] += obj.score;
248
- }
249
- else {
250
- map[obj.user] = obj.score;
251
- }
252
- return map;
253
- }, {});
254
- result = Object.entries(userScoreMap).map(function (_a) {
255
- var _b = __read(_a, 2), user = _b[0], score = _b[1];
256
- return ({ user: user, score: score });
257
- });
258
- result.sort(function (a, b) { return b.score - a.score; });
259
- // console.log(result);
260
- return [2 /*return*/, result];
261
- case 4:
262
- e_2 = _a.sent();
263
- return [2 /*return*/, []];
264
- case 5: return [2 /*return*/];
265
- }
266
- });
267
- });
268
- }
269
- exports.getBidderLeaderBoard = getBidderLeaderBoard;
270
- function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
271
- return __awaiter(this, void 0, void 0, function () {
272
- return __generator(this, function (_a) {
273
- return [2 /*return*/, expLeaderBoard.map(function (l) {
274
- l.owner = ownerMap.get(l.nft_id);
275
- return l;
276
- })];
277
- });
278
- });
279
- }
280
- exports.getExpLeaderBoardWithOwner = getExpLeaderBoardWithOwner;
281
- function getExpLeaderBoard(startTimestamp, endTimestamp) {
282
- return __awaiter(this, void 0, void 0, function () {
283
- var apiUrl, headers, _endTimestamp, requestData, jsonData, response, data;
284
- return __generator(this, function (_a) {
285
- switch (_a.label) {
286
- case 0:
287
- apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
288
- headers = {
289
- "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
290
- "Content-Type": "application/json",
291
- };
292
- _endTimestamp = endTimestamp ? endTimestamp : "9999999999";
293
- requestData = {
294
- sqlQuery: {
295
- // sql: `SELECT S.distinct_id AS owner, SUM(E.exp_earn) AS total_exp_earn
296
- // FROM ExpUp E
297
- // JOIN (
298
- // SELECT number, distinct_id
299
- // FROM StakeNft
300
- // WHERE (number, timestamp) IN (
301
- // SELECT number, MAX(timestamp) AS max_timestamp
302
- // FROM StakeNft
303
- // GROUP BY number
304
- // )
305
- // ) S ON E.number = S.number
306
- // WHERE E.timestamp >= ${startTimestamp} && E.timestamp < ${_endTimestamp}
307
- // GROUP BY owner
308
- // ORDER BY total_exp_earn DESC;`,
309
- sql: "\n SELECT E.nft_id as nft_id, SUM(E.exp_earn) as total_exp_earn\n FROM ExpUp E\n WHERE E.timestamp >= ".concat(startTimestamp, " && E.timestamp < ").concat(_endTimestamp, "\n GROUP BY nft_id\n ORDER BY total_exp_earn DESC;\n "),
310
- size: 200,
311
- },
312
- };
313
- jsonData = JSON.stringify(requestData);
314
- return [4 /*yield*/, fetch(apiUrl, {
315
- method: "POST",
316
- headers: headers,
317
- body: jsonData,
318
- })];
319
- case 1:
320
- response = _a.sent();
321
- return [4 /*yield*/, response.json()];
322
- case 2:
323
- data = _a.sent();
324
- return [2 /*return*/, data.result.rows];
325
- }
326
- });
327
- });
328
- }
329
- exports.getExpLeaderBoard = getExpLeaderBoard;
330
- // (async () => {
331
- // let res = await getExpLeaderBoard("1709539200", "1709625600");
332
- // console.log(res);
333
- // })();
@@ -1,102 +0,0 @@
1
- import { TransactionBlock } from "@mysten/sui.js/transactions";
2
- /**
3
- public(friend) entry fun authorized_add_portfolio_vault_authorized_user<O_TOKEN, U_TOKEN, B_TOKEN>(
4
- registry: &mut Registry,
5
- index: u64,
6
- users: vector<address>,
7
- ctx: &mut TxContext,
8
- )
9
- */
10
- export declare function getAuthorizedAddPortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, users: string[]): Promise<TransactionBlock>;
11
- /**
12
- public(friend) entry fun authorized_remove_portfolio_vault_authorized_user<O_TOKEN, U_TOKEN, B_TOKEN>(
13
- registry: &mut Registry,
14
- index: u64,
15
- users: vector<address>,
16
- ctx: &mut TxContext,
17
- )
18
- */
19
- export declare function getAuthorizedRemovePortfolioVaultAuthorizedUserTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, users: string[]): Promise<TransactionBlock>;
20
- /**
21
- public(friend) entry fun authorized_new_portfolio_vault<O_TOKEN, U_TOKEN, B_TOKEN>(
22
- registry: &mut Registry,
23
- price_oracle: &Oracle<O_TOKEN>,
24
- clock: &Clock,
25
- strategy_name: String,
26
- period: u8,
27
- activation_ts_ms: u64,
28
- expiration_ts_ms: u64,
29
- o_token_decimal: u64,
30
- u_token_decimal: u64,
31
- b_token_decimal: u64,
32
- capacity: u64,
33
- call_strike_pct: vector<u64>,
34
- call_weight: vector<u64>,
35
- call_is_buyer: vector<bool>,
36
- put_strike_pct: vector<u64>,
37
- put_weight: vector<u64>,
38
- put_is_buyer: vector<bool>,
39
- strike_increment: u64,
40
- lot_size: u64,
41
- decay_speed: u64,
42
- initial_price: u64,
43
- final_price: u64,
44
- auction_duration_in_ms: u64,
45
- leverage: u64,
46
- has_next: bool,
47
- whitelist: vector<address>,
48
- ctx: &mut TxContext
49
- )
50
- */
51
- export declare function getAuthorizedNewPortfolioVaultTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, priceOracle: string, strategy_name: String, period: string, activation_ts_ms: string, expiration_ts_ms: string, o_token_decimal: string, u_token_decimal: string, b_token_decimal: string, capacity: string, call_strike_pct: string[], call_weight: string[], call_is_buyer: boolean[], put_strike_pct: string[], put_weight: string[], put_is_buyer: boolean[], strike_increment: string, lot_size: string, decay_speed: string, initial_price: string, final_price: string, auction_duration_in_ms: string, leverage: string, has_next: boolean, whitelist: string[]): Promise<TransactionBlock>;
52
- /**
53
- public(friend) entry fun authorized_update_capacity<O_TOKEN, U_TOKEN, B_TOKEN>(
54
- registry: &mut Registry,
55
- index: u64,
56
- capacity: u64,
57
- ctx: &mut TxContext,
58
- )
59
- */
60
- export declare function getAuthorizedUpdateCapacityTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, capacity: string): Promise<TransactionBlock>;
61
- /**
62
- public(friend) entry fun authorized_update_warmup_vault_config<O_TOKEN, U_TOKEN, B_TOKEN>(
63
- registry: &mut Registry,
64
- index: u64,
65
- strike_increment: u64,
66
- decay_speed: u64,
67
- initial_price: u64,
68
- final_price: u64,
69
- auction_duration_in_ms: u64,
70
- ctx: &mut TxContext,
71
- )
72
- */
73
- export declare function getAuthorizedUpdateWarmupVaultConfigTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, strike_increment: string, decay_speed: string, initial_price: string, final_price: string, auction_duration_in_ms: string): Promise<TransactionBlock>;
74
- /**
75
- public(friend) entry fun authorized_update_upcoming_vault_config<O_TOKEN, U_TOKEN, B_TOKEN>(
76
- registry: &mut Registry,
77
- index: u64,
78
- call_strike_pct: vector<u64>,
79
- call_weight: vector<u64>,
80
- call_is_buyer: vector<bool>,
81
- put_strike_pct: vector<u64>,
82
- put_weight: vector<u64>,
83
- put_is_buyer: vector<bool>,
84
- strike_increment: u64,
85
- decay_speed: u64,
86
- initial_price: u64,
87
- final_price: u64,
88
- auction_duration_in_ms: u64,
89
- ctx: &mut TxContext,
90
- )
91
- */
92
- export declare function getAuthorizedUpdateUpcomingVaultConfigTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, call_strike_pct: string[], call_weight: string[], call_is_buyer: boolean[], put_strike_pct: string[], put_weight: string[], put_is_buyer: boolean[], strike_increment: string, decay_speed: string, initial_price: string, final_price: string, auction_duration_in_ms: string): Promise<TransactionBlock>;
93
- /**
94
- public(friend) entry fun authorized_delivery<O_TOKEN, U_TOKEN, B_TOKEN>(
95
- registry: &mut Registry,
96
- index: u64,
97
- price_oracle: &Oracle<O_TOKEN>,
98
- clock: &Clock,
99
- ctx: &mut TxContext
100
- )
101
- */
102
- export declare function getAuthorizedDeliveryTx(gasBudget: number, packageId: string, typeArguments: string[], registry: string, index: string, priceOracle: string): Promise<TransactionBlock>;