@typus/typus-sdk 1.0.52 → 1.0.54

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.
@@ -35,22 +35,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
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
38
  Object.defineProperty(exports, "__esModule", { value: true });
55
39
  exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
56
40
  var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
@@ -71,45 +55,20 @@ var depositorRequestData = {
71
55
  query: "depositTvl",
72
56
  alias: "",
73
57
  id: "a",
74
- labelSelector: {},
58
+ labelSelector: {
59
+ // user: "0x823bd0c4d601d625b1b1555dbe17da495db71070a4365205467838aecc32cbad",
60
+ },
75
61
  aggregate: {
76
62
  op: "SUM",
77
- grouping: ["user", "coin_symbol"],
63
+ grouping: ["user"],
78
64
  },
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
65
  },
98
- dataSource: "PRICE",
99
- },
100
- ],
101
- formulas: [
102
- {
103
- expression: "a*b",
104
- alias: "{{user}}",
105
- id: "A",
106
- disabled: false,
107
66
  },
108
67
  ],
109
68
  };
110
69
  function getDepositorLeaderBoard(start, end, step) {
111
70
  return __awaiter(this, void 0, void 0, function () {
112
- var jsonData, response, data, samples, len_1, leader_board, userScoreMap, result, e_1;
71
+ var jsonData, response, data, samples, len_1, leader_board;
113
72
  return __generator(this, function (_a) {
114
73
  switch (_a.label) {
115
74
  case 0:
@@ -130,45 +89,27 @@ function getDepositorLeaderBoard(start, end, step) {
130
89
  })];
131
90
  case 1:
132
91
  response = _a.sent();
133
- _a.label = 2;
134
- case 2:
135
- _a.trys.push([2, 4, , 5]);
92
+ if (!response.ok) return [3 /*break*/, 3];
136
93
  return [4 /*yield*/, response.json()];
137
- case 3:
94
+ case 2:
138
95
  data = _a.sent();
139
96
  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;
97
+ len_1 = samples.reduce(function (acc, curr) { return (acc > curr.values.length ? acc : curr.values.length); }, 0);
141
98
  leader_board = samples
142
99
  .map(function (element) {
143
100
  // console.log("metric:", element.metric, "values: ", element.values);
144
101
  // 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);
102
+ var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / 1000000000 / len_1; }, 0);
146
103
  return {
147
104
  user: element.metric.labels.user,
148
105
  score: sum,
149
106
  };
150
107
  })
151
108
  .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*/];
109
+ leader_board.sort(function (a, b) { return b.score - a.score; });
110
+ // console.log(leader_board);
111
+ return [2 /*return*/, leader_board];
112
+ case 3: throw new Error("HTTP error! Status: ".concat(response.status));
172
113
  }
173
114
  });
174
115
  });
@@ -201,7 +142,7 @@ var bidderRequestData = {
201
142
  };
202
143
  function getBidderLeaderBoard(startTimestamp, end) {
203
144
  return __awaiter(this, void 0, void 0, function () {
204
- var jsonData, response, data, samples, leader_board, userScoreMap, result, e_2;
145
+ var jsonData, response, data, samples, leader_board;
205
146
  return __generator(this, function (_a) {
206
147
  switch (_a.label) {
207
148
  case 0:
@@ -219,11 +160,9 @@ function getBidderLeaderBoard(startTimestamp, end) {
219
160
  })];
220
161
  case 1:
221
162
  response = _a.sent();
222
- _a.label = 2;
223
- case 2:
224
- _a.trys.push([2, 4, , 5]);
163
+ if (!response.ok) return [3 /*break*/, 3];
225
164
  return [4 /*yield*/, response.json()];
226
- case 3:
165
+ case 2:
227
166
  data = _a.sent();
228
167
  samples = data.results[0].matrix.samples;
229
168
  leader_board = samples
@@ -238,30 +177,14 @@ function getBidderLeaderBoard(startTimestamp, end) {
238
177
  var b = element.values.at(-1).value;
239
178
  return {
240
179
  user: element.metric.labels.user,
241
- score: b - a,
180
+ score: (b - a) / 1000000000,
242
181
  };
243
182
  })
244
183
  .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*/];
184
+ leader_board.sort(function (a, b) { return b.score - a.score; });
185
+ // console.log(leader_board);
186
+ return [2 /*return*/, leader_board];
187
+ case 3: throw new Error("HTTP error! Status: ".concat(response.status));
265
188
  }
266
189
  });
267
190
  });
package/package.json CHANGED
@@ -1,84 +1,84 @@
1
1
  {
2
- "name": "@typus/typus-sdk",
3
- "author": "Typus",
4
- "description": "typus sdk",
5
- "version": "1.0.52",
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"
2
+ "name": "@typus/typus-sdk",
3
+ "author": "Typus",
4
+ "description": "typus sdk",
5
+ "version": "1.0.54",
6
+ "dependencies": {
7
+ "@mysten/sui.js": "^0.34.1",
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
  }