@typus/typus-sdk 1.0.46 → 1.0.48
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/leader-board.js +62 -15
- package/package.json +82 -82
|
@@ -55,20 +55,45 @@ var depositorRequestData = {
|
|
|
55
55
|
query: "depositTvl",
|
|
56
56
|
alias: "",
|
|
57
57
|
id: "a",
|
|
58
|
-
labelSelector: {
|
|
59
|
-
// user: "0x823bd0c4d601d625b1b1555dbe17da495db71070a4365205467838aecc32cbad",
|
|
60
|
-
},
|
|
58
|
+
labelSelector: {},
|
|
61
59
|
aggregate: {
|
|
62
60
|
op: "SUM",
|
|
63
|
-
grouping: ["user"],
|
|
61
|
+
grouping: ["user", "coin_symbol"],
|
|
64
62
|
},
|
|
63
|
+
functions: [],
|
|
64
|
+
disabled: true,
|
|
65
|
+
},
|
|
66
|
+
dataSource: "METRICS",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
priceQuery: {
|
|
70
|
+
id: "b",
|
|
71
|
+
alias: "",
|
|
72
|
+
coinId: [
|
|
73
|
+
{
|
|
74
|
+
symbol: "SUI",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
symbol: "USDC",
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
disabled: true,
|
|
65
81
|
},
|
|
82
|
+
dataSource: "PRICE",
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
formulas: [
|
|
86
|
+
{
|
|
87
|
+
expression: "a*b",
|
|
88
|
+
alias: "{{user}}",
|
|
89
|
+
id: "A",
|
|
90
|
+
disabled: false,
|
|
66
91
|
},
|
|
67
92
|
],
|
|
68
93
|
};
|
|
69
94
|
function getDepositorLeaderBoard(start, end, step) {
|
|
70
95
|
return __awaiter(this, void 0, void 0, function () {
|
|
71
|
-
var jsonData, response, data, samples, len_1, leader_board;
|
|
96
|
+
var jsonData, response, data, samples, len_1, leader_board, e_1;
|
|
72
97
|
return __generator(this, function (_a) {
|
|
73
98
|
switch (_a.label) {
|
|
74
99
|
case 0:
|
|
@@ -89,9 +114,11 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
89
114
|
})];
|
|
90
115
|
case 1:
|
|
91
116
|
response = _a.sent();
|
|
92
|
-
|
|
93
|
-
return [4 /*yield*/, response.json()];
|
|
117
|
+
_a.label = 2;
|
|
94
118
|
case 2:
|
|
119
|
+
_a.trys.push([2, 4, , 5]);
|
|
120
|
+
return [4 /*yield*/, response.json()];
|
|
121
|
+
case 3:
|
|
95
122
|
data = _a.sent();
|
|
96
123
|
samples = data.results[0].matrix.samples;
|
|
97
124
|
len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0);
|
|
@@ -99,7 +126,7 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
99
126
|
.map(function (element) {
|
|
100
127
|
// console.log("metric:", element.metric, "values: ", element.values);
|
|
101
128
|
// console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
|
|
102
|
-
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value /
|
|
129
|
+
var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / len_1; }, 0);
|
|
103
130
|
return {
|
|
104
131
|
user: element.metric.labels.user,
|
|
105
132
|
score: sum,
|
|
@@ -109,7 +136,10 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
109
136
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
110
137
|
// console.log(leader_board);
|
|
111
138
|
return [2 /*return*/, leader_board];
|
|
112
|
-
case
|
|
139
|
+
case 4:
|
|
140
|
+
e_1 = _a.sent();
|
|
141
|
+
return [2 /*return*/, []];
|
|
142
|
+
case 5: return [2 /*return*/];
|
|
113
143
|
}
|
|
114
144
|
});
|
|
115
145
|
});
|
|
@@ -142,7 +172,7 @@ var bidderRequestData = {
|
|
|
142
172
|
};
|
|
143
173
|
function getBidderLeaderBoard(startTimestamp, end) {
|
|
144
174
|
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
var jsonData, response, data, samples, leader_board;
|
|
175
|
+
var jsonData, response, data, samples, leader_board, e_2;
|
|
146
176
|
return __generator(this, function (_a) {
|
|
147
177
|
switch (_a.label) {
|
|
148
178
|
case 0:
|
|
@@ -160,9 +190,11 @@ function getBidderLeaderBoard(startTimestamp, end) {
|
|
|
160
190
|
})];
|
|
161
191
|
case 1:
|
|
162
192
|
response = _a.sent();
|
|
163
|
-
|
|
164
|
-
return [4 /*yield*/, response.json()];
|
|
193
|
+
_a.label = 2;
|
|
165
194
|
case 2:
|
|
195
|
+
_a.trys.push([2, 4, , 5]);
|
|
196
|
+
return [4 /*yield*/, response.json()];
|
|
197
|
+
case 3:
|
|
166
198
|
data = _a.sent();
|
|
167
199
|
samples = data.results[0].matrix.samples;
|
|
168
200
|
leader_board = samples
|
|
@@ -184,14 +216,29 @@ function getBidderLeaderBoard(startTimestamp, end) {
|
|
|
184
216
|
leader_board.sort(function (a, b) { return b.score - a.score; });
|
|
185
217
|
// console.log(leader_board);
|
|
186
218
|
return [2 /*return*/, leader_board];
|
|
187
|
-
case
|
|
219
|
+
case 4:
|
|
220
|
+
e_2 = _a.sent();
|
|
221
|
+
return [2 /*return*/, []];
|
|
222
|
+
case 5: return [2 /*return*/];
|
|
188
223
|
}
|
|
189
224
|
});
|
|
190
225
|
});
|
|
191
226
|
}
|
|
192
227
|
exports.getBidderLeaderBoard = getBidderLeaderBoard;
|
|
193
228
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
194
|
-
|
|
195
|
-
|
|
229
|
+
var _a, _b, _c, _d;
|
|
230
|
+
return __generator(this, function (_e) {
|
|
231
|
+
switch (_e.label) {
|
|
232
|
+
case 0:
|
|
233
|
+
_b = (_a = console).log;
|
|
234
|
+
return [4 /*yield*/, getDepositorLeaderBoard("1684922400")];
|
|
235
|
+
case 1:
|
|
236
|
+
_b.apply(_a, [_e.sent()]);
|
|
237
|
+
_d = (_c = console).log;
|
|
238
|
+
return [4 /*yield*/, getBidderLeaderBoard("1684922400")];
|
|
239
|
+
case 2:
|
|
240
|
+
_d.apply(_c, [_e.sent()]);
|
|
241
|
+
return [2 /*return*/];
|
|
242
|
+
}
|
|
196
243
|
});
|
|
197
244
|
}); })();
|
package/package.json
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
2
|
+
"name": "@typus/typus-sdk",
|
|
3
|
+
"author": "Typus",
|
|
4
|
+
"description": "typus sdk",
|
|
5
|
+
"version": "1.0.48",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@mysten/sui.js": "^0.34.0",
|
|
8
|
+
"@types/node": "^17.0.0",
|
|
9
|
+
"bignumber.js": "^9.1.1",
|
|
10
|
+
"bs58": "^4.0.1",
|
|
11
|
+
"builtin-modules": "^1.1.1",
|
|
12
|
+
"chai": "^4.3.7",
|
|
13
|
+
"decimal.js": "^10.3.1",
|
|
14
|
+
"diff": "^4.0.2",
|
|
15
|
+
"dotenv": "^10.0.0",
|
|
16
|
+
"encrypt-with-password": "^1.0.0",
|
|
17
|
+
"escape-string-regexp": "^1.0.5",
|
|
18
|
+
"esprima": "^4.0.1",
|
|
19
|
+
"fetch": "^1.1.0",
|
|
20
|
+
"fs.realpath": "^1.0.0",
|
|
21
|
+
"function-bind": "^1.1.1",
|
|
22
|
+
"glob": "^7.2.0",
|
|
23
|
+
"has": "^1.0.3",
|
|
24
|
+
"has-flag": "^3.0.0",
|
|
25
|
+
"inflight": "^1.0.6",
|
|
26
|
+
"inherits": "^2.0.4",
|
|
27
|
+
"is-core-module": "^2.8.0",
|
|
28
|
+
"js-sha3": "^0.8.0",
|
|
29
|
+
"js-tokens": "^4.0.0",
|
|
30
|
+
"js-yaml": "^3.14.1",
|
|
31
|
+
"math-erf": "^1.0.0",
|
|
32
|
+
"minimatch": "^3.0.4",
|
|
33
|
+
"minimist": "^1.2.5",
|
|
34
|
+
"mkdirp": "^0.5.5",
|
|
35
|
+
"mocha": "^10.1.0",
|
|
36
|
+
"moment": "^2.29.4",
|
|
37
|
+
"node-cron": "^3.0.2",
|
|
38
|
+
"once": "^1.4.0",
|
|
39
|
+
"path-is-absolute": "^1.0.1",
|
|
40
|
+
"path-parse": "^1.0.7",
|
|
41
|
+
"random-bigint": "^0.0.1",
|
|
42
|
+
"resolve": "^1.20.0",
|
|
43
|
+
"rxjs": "^7.5.5",
|
|
44
|
+
"semver": "^5.7.1",
|
|
45
|
+
"sprintf-js": "^1.0.3",
|
|
46
|
+
"superstruct": "^0.16.0",
|
|
47
|
+
"supports-color": "^5.5.0",
|
|
48
|
+
"ts-mocha": "^10.0.0",
|
|
49
|
+
"tslib": "^1.14.1",
|
|
50
|
+
"tsutils": "^2.29.0",
|
|
51
|
+
"typed-rpc": "^3.0.0",
|
|
52
|
+
"wrappy": "^1.0.2",
|
|
53
|
+
"ws": "^8.11.0",
|
|
54
|
+
"xmlhttprequest": "^1.8.0"
|
|
55
|
+
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@types/bs58": "^4.0.1",
|
|
58
|
+
"@types/expect": "^24.3.0",
|
|
59
|
+
"@types/mocha": "^9.0.0",
|
|
60
|
+
"@types/rx": "^4.1.2",
|
|
61
|
+
"prettier": "^2.5.1",
|
|
62
|
+
"tslint": "^6.1.3",
|
|
63
|
+
"tslint-config-prettier": "^1.18.0",
|
|
64
|
+
"typescript": "^4.5.4"
|
|
65
|
+
},
|
|
66
|
+
"main": "lib/index.js",
|
|
67
|
+
"files": [
|
|
68
|
+
"lib"
|
|
69
|
+
],
|
|
70
|
+
"types": "lib/index.d.ts",
|
|
71
|
+
"scripts": {
|
|
72
|
+
"test": "rm -rf lib && tsc && ts-mocha test/test*.ts",
|
|
73
|
+
"build": "rm -rf lib && tsc"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "git+https://github.com/Typus-Lab/typus-sdk.git"
|
|
78
|
+
},
|
|
79
|
+
"license": "ISC",
|
|
80
|
+
"bugs": {
|
|
81
|
+
"url": "https://github.com/Typus-Lab/typus-sdk/issues"
|
|
82
|
+
},
|
|
83
|
+
"homepage": "https://github.com/Typus-Lab/typus-sdk#readme"
|
|
84
84
|
}
|