@typus/typus-sdk 1.0.33 → 1.0.34

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.
@@ -1,5 +1,5 @@
1
1
  export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
2
- export declare function getBidderLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
2
+ export declare function getBidderLeaderBoard(startTimestamp?: string, end?: string): Promise<LeaderBoard[]>;
3
3
  interface LeaderBoard {
4
4
  user: string;
5
5
  score: number;
@@ -37,52 +37,34 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getBidderLeaderBoard = exports.getDepositorLeaderBoard = void 0;
40
- var apiUrl = "https://app.sentio.xyz/api/v1/metrics/wayne/typus/query_range";
40
+ var apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
41
41
  var headers = {
42
42
  "api-key": "oBOW8DsO1izVrINCy6Tmxga9YcWeOL87O",
43
43
  "Content-Type": "application/json",
44
44
  };
45
45
  var depositorRequestData = {
46
+ timeRange: {
47
+ start: "-7d",
48
+ end: "now",
49
+ step: 3600,
50
+ },
51
+ limit: 200,
46
52
  queries: [
47
53
  {
48
- query: "callPortfolioHarvest",
49
- alias: "",
50
- id: "a",
51
- labelSelector: {},
52
- aggregate: {
53
- op: "SUM",
54
- grouping: ["user"],
55
- },
56
- functions: [],
57
- disabled: true,
58
- },
59
- {
60
- query: "callPortfolioCompound",
61
- alias: "",
62
- id: "b",
63
- labelSelector: {},
64
- aggregate: {
65
- op: "SUM",
66
- grouping: ["user"],
54
+ metricsQuery: {
55
+ query: "depositTvl",
56
+ alias: "",
57
+ id: "a",
58
+ labelSelector: {
59
+ // user: "0x823bd0c4d601d625b1b1555dbe17da495db71070a4365205467838aecc32cbad",
60
+ },
61
+ aggregate: {
62
+ op: "SUM",
63
+ grouping: ["user"],
64
+ },
67
65
  },
68
- functions: [],
69
- disabled: true,
70
66
  },
71
67
  ],
72
- formulas: [
73
- {
74
- expression: "a+b",
75
- alias: "Score",
76
- id: "A",
77
- disabled: false,
78
- },
79
- ],
80
- timeRange: {
81
- start: "now",
82
- end: "now",
83
- step: 1,
84
- },
85
- samplesLimit: 200,
86
68
  };
87
69
  function getDepositorLeaderBoard(start, end, step) {
88
70
  return __awaiter(this, void 0, void 0, function () {
@@ -112,11 +94,17 @@ function getDepositorLeaderBoard(start, end, step) {
112
94
  case 2:
113
95
  data = _a.sent();
114
96
  samples = data.results[0].matrix.samples;
115
- leader_board = samples.map(function (element) {
97
+ leader_board = samples
98
+ .map(function (element) {
116
99
  // console.log("metric:", element.metric, "values: ", element.values);
117
100
  // console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
118
- return { user: element.metric.labels.user, score: element.values.at(-1).value };
119
- });
101
+ var sum = element.values.reduce(function (acc, curr) { return acc + curr.value / 1000000000 / 24 / 7 / 2; }, 0);
102
+ return {
103
+ user: element.metric.labels.user,
104
+ score: sum,
105
+ };
106
+ })
107
+ .filter(function (element) { return element.score != 0; });
120
108
  leader_board.sort(function (a, b) { return b.score - a.score; });
121
109
  // console.log(leader_board);
122
110
  return [2 /*return*/, leader_board];
@@ -127,43 +115,42 @@ function getDepositorLeaderBoard(start, end, step) {
127
115
  }
128
116
  exports.getDepositorLeaderBoard = getDepositorLeaderBoard;
129
117
  var bidderRequestData = {
118
+ timeRange: {
119
+ start: "-7d",
120
+ end: "now",
121
+ step: 3600,
122
+ },
123
+ limit: 200,
130
124
  queries: [
131
125
  {
132
- query: "callPortfolioNewBid",
133
- alias: "Score",
134
- id: "a",
135
- labelSelector: {},
136
- aggregate: {
137
- op: "SUM",
138
- grouping: ["user"],
126
+ metricsQuery: {
127
+ query: "totalNewBid",
128
+ alias: "",
129
+ id: "a",
130
+ labelSelector: {},
131
+ aggregate: {
132
+ op: "SUM",
133
+ grouping: ["user"],
134
+ },
135
+ functions: [],
136
+ disabled: false,
139
137
  },
140
- functions: [],
141
- disabled: false,
138
+ dataSource: "METRICS",
142
139
  },
143
140
  ],
144
- formulas: [],
145
- timeRange: {
146
- start: "now",
147
- end: "now",
148
- step: 1,
149
- },
150
- samplesLimit: 200,
151
141
  };
152
- function getBidderLeaderBoard(start, end, step) {
142
+ function getBidderLeaderBoard(startTimestamp, end) {
153
143
  return __awaiter(this, void 0, void 0, function () {
154
144
  var jsonData, response, data, samples, leader_board;
155
145
  return __generator(this, function (_a) {
156
146
  switch (_a.label) {
157
147
  case 0:
158
- if (start) {
159
- bidderRequestData.timeRange.start = start;
148
+ if (startTimestamp) {
149
+ bidderRequestData.timeRange.start = startTimestamp;
160
150
  }
161
151
  if (end) {
162
152
  bidderRequestData.timeRange.end = end;
163
153
  }
164
- if (step) {
165
- bidderRequestData.timeRange.step = step;
166
- }
167
154
  jsonData = JSON.stringify(bidderRequestData);
168
155
  return [4 /*yield*/, fetch(apiUrl, {
169
156
  method: "POST",
@@ -177,11 +164,22 @@ function getBidderLeaderBoard(start, end, step) {
177
164
  case 2:
178
165
  data = _a.sent();
179
166
  samples = data.results[0].matrix.samples;
180
- leader_board = samples.map(function (element) {
167
+ leader_board = samples
168
+ .map(function (element) {
181
169
  // console.log("metric:", element.metric, "values: ", element.values);
182
170
  // console.log("user:", element.metric.labels.user, "score: ", element.values.at(-1).value);
183
- return { user: element.metric.labels.user, score: element.values.at(-1).value };
184
- });
171
+ var a = 0;
172
+ var log_0 = element.values.at(0);
173
+ if (log_0.timestamp == startTimestamp) {
174
+ a = log_0.value;
175
+ }
176
+ var b = element.values.at(-1).value;
177
+ return {
178
+ user: element.metric.labels.user,
179
+ score: (b - a) / 1000000000,
180
+ };
181
+ })
182
+ .filter(function (element) { return element.score != 0; });
185
183
  leader_board.sort(function (a, b) { return b.score - a.score; });
186
184
  // console.log(leader_board);
187
185
  return [2 /*return*/, leader_board];
@@ -191,7 +189,8 @@ function getBidderLeaderBoard(start, end, step) {
191
189
  });
192
190
  }
193
191
  exports.getBidderLeaderBoard = getBidderLeaderBoard;
194
- // (async () => {
195
- // console.log(await getDepositorLeaderBoard("1682434800"));
196
- // console.log(await getBidderLeaderBoard("1682434800"));
197
- // })();
192
+ (function () { return __awaiter(void 0, void 0, void 0, function () {
193
+ return __generator(this, function (_a) {
194
+ return [2 /*return*/];
195
+ });
196
+ }); })();
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.33",
6
- "dependencies": {
7
- "@mysten/sui.js": "^0.33.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.34",
6
+ "dependencies": {
7
+ "@mysten/sui.js": "^0.33.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
  }