@typus/typus-sdk 1.0.74 → 1.0.75
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.d.ts +1 -1
- package/lib/utils/leader-board.js +77 -42
- package/lib/utils/token.js +5 -5
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<
|
|
1
|
+
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
2
2
|
export declare function getBidderLeaderBoard(startTimestamp?: string, end?: string): Promise<LeaderBoard[]>;
|
|
3
3
|
interface LeaderBoard {
|
|
4
4
|
user: string;
|
|
@@ -55,64 +55,74 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
|
|
56
56
|
var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
|
|
57
57
|
var headers = {
|
|
58
|
-
"api-key": "
|
|
58
|
+
"api-key": "oBOW8DsO1izVrINCy6Tmxga9YcWeOL87O",
|
|
59
59
|
"Content-Type": "application/json",
|
|
60
60
|
};
|
|
61
|
-
var
|
|
61
|
+
var depositorRequestData = {
|
|
62
62
|
timeRange: {
|
|
63
|
-
start: "-
|
|
63
|
+
start: "-7d",
|
|
64
64
|
end: "now",
|
|
65
|
-
step:
|
|
66
|
-
timezone: "UTC",
|
|
65
|
+
step: 3600,
|
|
67
66
|
},
|
|
68
|
-
limit:
|
|
67
|
+
limit: 200,
|
|
69
68
|
queries: [
|
|
70
69
|
{
|
|
71
70
|
metricsQuery: {
|
|
72
|
-
query: "
|
|
71
|
+
query: "depositTvl",
|
|
72
|
+
alias: "",
|
|
73
73
|
id: "a",
|
|
74
74
|
labelSelector: {},
|
|
75
75
|
aggregate: {
|
|
76
76
|
op: "SUM",
|
|
77
|
-
grouping: ["coin_symbol"],
|
|
77
|
+
grouping: ["user", "coin_symbol"],
|
|
78
78
|
},
|
|
79
|
-
functions: [
|
|
79
|
+
functions: [],
|
|
80
|
+
disabled: true,
|
|
81
|
+
},
|
|
82
|
+
dataSource: "METRICS",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
priceQuery: {
|
|
86
|
+
id: "b",
|
|
87
|
+
alias: "",
|
|
88
|
+
coinId: [
|
|
80
89
|
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
value: 1,
|
|
86
|
-
unit: "d",
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
],
|
|
90
|
+
symbol: "SUI",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
symbol: "USDC",
|
|
90
94
|
},
|
|
91
95
|
],
|
|
92
|
-
disabled:
|
|
96
|
+
disabled: true,
|
|
93
97
|
},
|
|
94
|
-
dataSource: "
|
|
95
|
-
|
|
98
|
+
dataSource: "PRICE",
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
formulas: [
|
|
102
|
+
{
|
|
103
|
+
expression: "a*b",
|
|
104
|
+
alias: "{{user}}",
|
|
105
|
+
id: "A",
|
|
106
|
+
disabled: false,
|
|
96
107
|
},
|
|
97
108
|
],
|
|
98
|
-
formulas: [],
|
|
99
109
|
};
|
|
100
110
|
function getDepositorLeaderBoard(start, end, step) {
|
|
101
111
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
-
var jsonData, response, data, samples;
|
|
112
|
+
var jsonData, response, data, samples, len_1, leader_board, userScoreMap, result, e_1;
|
|
103
113
|
return __generator(this, function (_a) {
|
|
104
114
|
switch (_a.label) {
|
|
105
115
|
case 0:
|
|
106
116
|
if (start) {
|
|
107
|
-
|
|
117
|
+
depositorRequestData.timeRange.start = start;
|
|
108
118
|
}
|
|
109
119
|
if (end) {
|
|
110
|
-
|
|
120
|
+
depositorRequestData.timeRange.end = end;
|
|
111
121
|
}
|
|
112
122
|
if (step) {
|
|
113
|
-
|
|
123
|
+
depositorRequestData.timeRange.step = step;
|
|
114
124
|
}
|
|
115
|
-
jsonData = JSON.stringify(
|
|
125
|
+
jsonData = JSON.stringify(depositorRequestData);
|
|
116
126
|
return [4 /*yield*/, fetch(apiUrl, {
|
|
117
127
|
method: "POST",
|
|
118
128
|
headers: headers,
|
|
@@ -120,12 +130,45 @@ function getDepositorLeaderBoard(start, end, step) {
|
|
|
120
130
|
})];
|
|
121
131
|
case 1:
|
|
122
132
|
response = _a.sent();
|
|
123
|
-
|
|
133
|
+
_a.label = 2;
|
|
124
134
|
case 2:
|
|
135
|
+
_a.trys.push([2, 4, , 5]);
|
|
136
|
+
return [4 /*yield*/, response.json()];
|
|
137
|
+
case 3:
|
|
125
138
|
data = _a.sent();
|
|
126
139
|
samples = data.results[0].matrix.samples;
|
|
127
|
-
|
|
128
|
-
|
|
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*/];
|
|
129
172
|
}
|
|
130
173
|
});
|
|
131
174
|
});
|
|
@@ -158,7 +201,7 @@ var bidderRequestData = {
|
|
|
158
201
|
};
|
|
159
202
|
function getBidderLeaderBoard(startTimestamp, end) {
|
|
160
203
|
return __awaiter(this, void 0, void 0, function () {
|
|
161
|
-
var jsonData, response, data, samples, leader_board, userScoreMap, result,
|
|
204
|
+
var jsonData, response, data, samples, leader_board, userScoreMap, result, e_2;
|
|
162
205
|
return __generator(this, function (_a) {
|
|
163
206
|
switch (_a.label) {
|
|
164
207
|
case 0:
|
|
@@ -216,7 +259,7 @@ function getBidderLeaderBoard(startTimestamp, end) {
|
|
|
216
259
|
// console.log(result);
|
|
217
260
|
return [2 /*return*/, result];
|
|
218
261
|
case 4:
|
|
219
|
-
|
|
262
|
+
e_2 = _a.sent();
|
|
220
263
|
return [2 /*return*/, []];
|
|
221
264
|
case 5: return [2 /*return*/];
|
|
222
265
|
}
|
|
@@ -225,15 +268,7 @@ function getBidderLeaderBoard(startTimestamp, end) {
|
|
|
225
268
|
}
|
|
226
269
|
exports.getBidderLeaderBoard = getBidderLeaderBoard;
|
|
227
270
|
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
switch (_c.label) {
|
|
231
|
-
case 0:
|
|
232
|
-
_b = (_a = console).log;
|
|
233
|
-
return [4 /*yield*/, getDepositorLeaderBoard("1684886400")];
|
|
234
|
-
case 1:
|
|
235
|
-
_b.apply(_a, [_c.sent()]);
|
|
236
|
-
return [2 /*return*/];
|
|
237
|
-
}
|
|
271
|
+
return __generator(this, function (_a) {
|
|
272
|
+
return [2 /*return*/];
|
|
238
273
|
});
|
|
239
274
|
}); })();
|
package/lib/utils/token.js
CHANGED
|
@@ -11,21 +11,21 @@ function typeArgsToAssets(typeArgs) {
|
|
|
11
11
|
var typeArgs = x.split("::");
|
|
12
12
|
switch ((0, sui_js_1.normalizeSuiAddress)(typeArgs[0])) {
|
|
13
13
|
case "0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881":
|
|
14
|
-
return "
|
|
14
|
+
return "BTC";
|
|
15
15
|
case "0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5":
|
|
16
|
-
return "
|
|
16
|
+
return "ETH";
|
|
17
17
|
case "0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8":
|
|
18
|
-
return "
|
|
18
|
+
return "SOL";
|
|
19
19
|
case "0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf":
|
|
20
20
|
return "USDC";
|
|
21
21
|
case "0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c":
|
|
22
22
|
return "USDT";
|
|
23
23
|
case config_json_1.default.TOKEN_PACKAGE:
|
|
24
24
|
if (typeArgs[2] == "BTC") {
|
|
25
|
-
return "
|
|
25
|
+
return "BTC";
|
|
26
26
|
}
|
|
27
27
|
else if (typeArgs[2] == "ETH") {
|
|
28
|
-
return "
|
|
28
|
+
return "ETH";
|
|
29
29
|
}
|
|
30
30
|
return typeArgs[2];
|
|
31
31
|
default:
|