@typus/typus-sdk 1.2.66 → 1.2.67
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/mainnet.json +2 -2
- package/lib/utils/api/defillama/tvl.d.ts +1 -0
- package/lib/utils/api/defillama/tvl.js +59 -0
- package/lib/utils/{leader-board.d.ts → api/sentio/leader-board.d.ts} +0 -7
- package/lib/utils/api/sentio/leader-board.js +104 -0
- package/lib/utils/api/sentio/reward-generated.d.ts +8 -0
- package/lib/utils/api/sentio/reward-generated.js +175 -0
- package/lib/utils/locked-period-vault/user-entry.d.ts +81 -0
- package/lib/utils/locked-period-vault/user-entry.js +101 -0
- package/lib/utils/typus-dov-single-v2/user-history.js +22 -3
- package/package.json +1 -1
- package/lib/utils/leader-board.js +0 -333
package/lib/mainnet.json
CHANGED
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"SCALLOP_MARKET": "0xa757975255146dc9686aa823b7838b507f315d704f428cbadad2f4ea061939d9",
|
|
31
31
|
"SCALLOP_REWARD_POOL_FOR_SUI": "0x162250ef72393a4ad3d46294c4e1bdfcb03f04c869d390e7efbfc995353a7ee9",
|
|
32
32
|
"SCALLOP_REWARD_POOL_FOR_USDC": "0xf4268cc9b9413b9bfe09e8966b8de650494c9e5784bf0930759cfef4904daff8",
|
|
33
|
-
"VERSION": "2.
|
|
33
|
+
"VERSION": "2.22.3",
|
|
34
34
|
"EXP_GUESS_PACKAGE": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
|
|
35
35
|
"EXP_GUESS_PACKAGE_ORIGIN": "0x32d670520a10a87b8c042d2259c2d1f7c319329bafcf6f893ad9aaf01a43db8b",
|
|
36
36
|
"EXP_GUESS_REGISTRY": "0x70c6cbe6764b315cee1b24f483a0fc8307f047f1fab2a0d4438624845e6ba3f2",
|
|
37
37
|
"FRAMEWORK_PACKAGE": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
|
|
38
|
-
"SINGLE_COLLATERAL_PACKAGE": "
|
|
38
|
+
"SINGLE_COLLATERAL_PACKAGE": "0x1ee07392805d5b26a1c248b5739b768d426579ac1f4aeb50152f7ca06d3e2a00",
|
|
39
39
|
"SINGLE_COLLATERAL_PACKAGE_ORIGIN": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
|
|
40
40
|
"SINGLE_COLLATERAL_REGISTRY": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
|
|
41
41
|
"SINGLE_COLLATERAL_PORTFOLIO_VAULT_REGISTRY": "0xa1a186d050e3172ef4701c16048c99b11f785969874fa2642b9cbcf59cde7fc0",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getTvl(): Promise<number>;
|
|
@@ -0,0 +1,59 @@
|
|
|
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.getTvl = void 0;
|
|
40
|
+
function getTvl() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
42
|
+
var response, data;
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
switch (_a.label) {
|
|
45
|
+
case 0: return [4 /*yield*/, fetch("https://api.llama.fi/tvl/typus-finance", {
|
|
46
|
+
method: "GET",
|
|
47
|
+
})];
|
|
48
|
+
case 1:
|
|
49
|
+
response = _a.sent();
|
|
50
|
+
return [4 /*yield*/, response.json()];
|
|
51
|
+
case 2:
|
|
52
|
+
data = _a.sent();
|
|
53
|
+
// console.log(data);
|
|
54
|
+
return [2 /*return*/, data];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.getTvl = getTvl;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
export declare function getDepositorLeaderBoard(start?: string, end?: string, step?: number): Promise<LeaderBoard[]>;
|
|
2
|
-
export declare function getBidderLeaderBoard(startTimestamp?: string, end?: string): Promise<LeaderBoard[]>;
|
|
3
|
-
interface LeaderBoard {
|
|
4
|
-
user: string;
|
|
5
|
-
score: number;
|
|
6
|
-
}
|
|
7
1
|
export interface ExpLeaderBoard {
|
|
8
2
|
nft_id: string;
|
|
9
3
|
total_exp_earn: number;
|
|
@@ -11,4 +5,3 @@ export interface ExpLeaderBoard {
|
|
|
11
5
|
}
|
|
12
6
|
export declare function getExpLeaderBoardWithOwner(expLeaderBoard: ExpLeaderBoard[], ownerMap: Map<string, string>): Promise<ExpLeaderBoard[]>;
|
|
13
7
|
export declare function getExpLeaderBoard(startTimestamp: string, endTimestamp?: string): Promise<ExpLeaderBoard[]>;
|
|
14
|
-
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// const apiUrl = "https://app.sentio.xyz/api/v1/insights/wayne/typus/query";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
14
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
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;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.getExpLeaderBoard = exports.getExpLeaderBoardWithOwner = void 0;
|
|
41
|
+
function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
+
return __generator(this, function (_a) {
|
|
44
|
+
return [2 /*return*/, expLeaderBoard.map(function (l) {
|
|
45
|
+
l.owner = ownerMap.get(l.nft_id);
|
|
46
|
+
return l;
|
|
47
|
+
})];
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.getExpLeaderBoardWithOwner = getExpLeaderBoardWithOwner;
|
|
52
|
+
var headers = {
|
|
53
|
+
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
54
|
+
"Content-Type": "application/json",
|
|
55
|
+
};
|
|
56
|
+
function getExpLeaderBoard(startTimestamp, endTimestamp) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var apiUrl, _endTimestamp, requestData, jsonData, response, data;
|
|
59
|
+
return __generator(this, function (_a) {
|
|
60
|
+
switch (_a.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
63
|
+
_endTimestamp = endTimestamp ? endTimestamp : "9999999999";
|
|
64
|
+
requestData = {
|
|
65
|
+
sqlQuery: {
|
|
66
|
+
// sql: `SELECT S.distinct_id AS owner, SUM(E.exp_earn) AS total_exp_earn
|
|
67
|
+
// FROM ExpUp E
|
|
68
|
+
// JOIN (
|
|
69
|
+
// SELECT number, distinct_id
|
|
70
|
+
// FROM StakeNft
|
|
71
|
+
// WHERE (number, timestamp) IN (
|
|
72
|
+
// SELECT number, MAX(timestamp) AS max_timestamp
|
|
73
|
+
// FROM StakeNft
|
|
74
|
+
// GROUP BY number
|
|
75
|
+
// )
|
|
76
|
+
// ) S ON E.number = S.number
|
|
77
|
+
// WHERE E.timestamp >= ${startTimestamp} && E.timestamp < ${_endTimestamp}
|
|
78
|
+
// GROUP BY owner
|
|
79
|
+
// ORDER BY total_exp_earn DESC;`,
|
|
80
|
+
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 "),
|
|
81
|
+
size: 200,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
jsonData = JSON.stringify(requestData);
|
|
85
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
86
|
+
method: "POST",
|
|
87
|
+
headers: headers,
|
|
88
|
+
body: jsonData,
|
|
89
|
+
})];
|
|
90
|
+
case 1:
|
|
91
|
+
response = _a.sent();
|
|
92
|
+
return [4 /*yield*/, response.json()];
|
|
93
|
+
case 2:
|
|
94
|
+
data = _a.sent();
|
|
95
|
+
return [2 /*return*/, data.result.rows];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
exports.getExpLeaderBoard = getExpLeaderBoard;
|
|
101
|
+
// (async () => {
|
|
102
|
+
// const res1 = await getExpLeaderBoard("0");
|
|
103
|
+
// console.log(res1);
|
|
104
|
+
// })();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare function getTotalDepositorIncentive(): Promise<TokenAmount>;
|
|
2
|
+
export declare function getTotalPremium(): Promise<number>;
|
|
3
|
+
export declare function getTotalProfitSharing(): Promise<TokenAmount[]>;
|
|
4
|
+
interface TokenAmount {
|
|
5
|
+
token: string;
|
|
6
|
+
total_amount: string;
|
|
7
|
+
}
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,175 @@
|
|
|
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.getTotalProfitSharing = exports.getTotalPremium = exports.getTotalDepositorIncentive = void 0;
|
|
40
|
+
var headers = {
|
|
41
|
+
"api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
|
|
42
|
+
"Content-Type": "application/json",
|
|
43
|
+
};
|
|
44
|
+
function getTotalDepositorIncentive() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0:
|
|
50
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
51
|
+
requestData = {
|
|
52
|
+
sqlQuery: {
|
|
53
|
+
sql: "\n SELECT SUM(E.depositor_incentive_value) as incentive\n FROM Delivery E\n ",
|
|
54
|
+
size: 2000000,
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
jsonData = JSON.stringify(requestData);
|
|
58
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: headers,
|
|
61
|
+
body: jsonData,
|
|
62
|
+
})];
|
|
63
|
+
case 1:
|
|
64
|
+
response = _a.sent();
|
|
65
|
+
return [4 /*yield*/, response.json()];
|
|
66
|
+
case 2:
|
|
67
|
+
data = _a.sent();
|
|
68
|
+
return [2 /*return*/, { token: "SUI", total_amount: data.result.rows[0].incentive }];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.getTotalDepositorIncentive = getTotalDepositorIncentive;
|
|
74
|
+
function getTotalPremium() {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
|
|
81
|
+
requestData = {
|
|
82
|
+
timeRange: {
|
|
83
|
+
start: "now",
|
|
84
|
+
end: "now",
|
|
85
|
+
step: 3600,
|
|
86
|
+
timezone: "Europe/Paris",
|
|
87
|
+
},
|
|
88
|
+
limit: 1,
|
|
89
|
+
queries: [
|
|
90
|
+
{
|
|
91
|
+
metricsQuery: {
|
|
92
|
+
query: "PremiumUSD",
|
|
93
|
+
alias: "",
|
|
94
|
+
id: "a",
|
|
95
|
+
labelSelector: {},
|
|
96
|
+
aggregate: {
|
|
97
|
+
op: "SUM",
|
|
98
|
+
grouping: ["chain"],
|
|
99
|
+
},
|
|
100
|
+
functions: [
|
|
101
|
+
{
|
|
102
|
+
name: "sum_over_time",
|
|
103
|
+
arguments: [
|
|
104
|
+
{
|
|
105
|
+
durationValue: {
|
|
106
|
+
value: 520,
|
|
107
|
+
unit: "w",
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
],
|
|
111
|
+
},
|
|
112
|
+
],
|
|
113
|
+
disabled: false,
|
|
114
|
+
},
|
|
115
|
+
dataSource: "METRICS",
|
|
116
|
+
sourceName: "",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
formulas: [],
|
|
120
|
+
};
|
|
121
|
+
jsonData = JSON.stringify(requestData);
|
|
122
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
123
|
+
method: "POST",
|
|
124
|
+
headers: headers,
|
|
125
|
+
body: jsonData,
|
|
126
|
+
})];
|
|
127
|
+
case 1:
|
|
128
|
+
response = _a.sent();
|
|
129
|
+
return [4 /*yield*/, response.json()];
|
|
130
|
+
case 2:
|
|
131
|
+
data = _a.sent();
|
|
132
|
+
return [2 /*return*/, data.results[0].matrix.samples[0].values[0].value];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
exports.getTotalPremium = getTotalPremium;
|
|
138
|
+
function getTotalProfitSharing() {
|
|
139
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
140
|
+
var apiUrl, requestData, jsonData, response, data;
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0:
|
|
144
|
+
apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
|
|
145
|
+
requestData = {
|
|
146
|
+
sqlQuery: {
|
|
147
|
+
sql: "\n SELECT token, SUM(amount) AS total_amount\n FROM ClaimProfitSharing\n GROUP BY token;\n ",
|
|
148
|
+
size: 2000000,
|
|
149
|
+
},
|
|
150
|
+
};
|
|
151
|
+
jsonData = JSON.stringify(requestData);
|
|
152
|
+
return [4 /*yield*/, fetch(apiUrl, {
|
|
153
|
+
method: "POST",
|
|
154
|
+
headers: headers,
|
|
155
|
+
body: jsonData,
|
|
156
|
+
})];
|
|
157
|
+
case 1:
|
|
158
|
+
response = _a.sent();
|
|
159
|
+
return [4 /*yield*/, response.json()];
|
|
160
|
+
case 2:
|
|
161
|
+
data = _a.sent();
|
|
162
|
+
return [2 /*return*/, data.result.rows];
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
exports.getTotalProfitSharing = getTotalProfitSharing;
|
|
168
|
+
// (async () => {
|
|
169
|
+
// const res1 = await getTotalDepositorIncentive();
|
|
170
|
+
// console.log(res1);
|
|
171
|
+
// const res2 = await getTotalPremium();
|
|
172
|
+
// console.log(res2);
|
|
173
|
+
// const res3 = await getTotalProfitSharing();
|
|
174
|
+
// console.log(res3);
|
|
175
|
+
// })();
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { TransactionBlock, TransactionObjectArgument } from "@mysten/sui.js/transactions";
|
|
2
|
+
/**
|
|
3
|
+
public fun lock_receipt(
|
|
4
|
+
registry: &mut Registry,
|
|
5
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
6
|
+
index: u64,
|
|
7
|
+
receipt: TypusDepositReceipt, // from tails_staking::deposit result or owned
|
|
8
|
+
split_active_share: u64,
|
|
9
|
+
split_warmup_share: u64,
|
|
10
|
+
clock: &Clock,
|
|
11
|
+
ctx: &mut TxContext
|
|
12
|
+
): TypusDepositReceipt
|
|
13
|
+
*/
|
|
14
|
+
export declare function getLockReceiptTx(input: {
|
|
15
|
+
tx: TransactionBlock;
|
|
16
|
+
lockedVaultPackageId: string;
|
|
17
|
+
typusDovSingleRegistry: string;
|
|
18
|
+
lockedVaultRegistry: string;
|
|
19
|
+
index: string;
|
|
20
|
+
receipt: TransactionObjectArgument;
|
|
21
|
+
split_active_share: string;
|
|
22
|
+
split_warmup_share: string;
|
|
23
|
+
}): TransactionBlock;
|
|
24
|
+
/**
|
|
25
|
+
public fun leave(
|
|
26
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
27
|
+
index: u64,
|
|
28
|
+
clock: &Clock,
|
|
29
|
+
ctx: &mut TxContext
|
|
30
|
+
)
|
|
31
|
+
*/
|
|
32
|
+
export declare function getLeaveTx(input: {
|
|
33
|
+
tx: TransactionBlock;
|
|
34
|
+
lockedVaultPackageId: string;
|
|
35
|
+
lockedVaultRegistry: string;
|
|
36
|
+
index: string;
|
|
37
|
+
}): TransactionBlock;
|
|
38
|
+
/**
|
|
39
|
+
public fun unlock_receipt(
|
|
40
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
41
|
+
index: u64,
|
|
42
|
+
ctx: &mut TxContext
|
|
43
|
+
)
|
|
44
|
+
*/
|
|
45
|
+
export declare function getUnlockReceiptTx(input: {
|
|
46
|
+
tx: TransactionBlock;
|
|
47
|
+
lockedVaultPackageId: string;
|
|
48
|
+
lockedVaultRegistry: string;
|
|
49
|
+
index: string;
|
|
50
|
+
}): TransactionBlock;
|
|
51
|
+
/**
|
|
52
|
+
public fun withdraw_incentive<T>(
|
|
53
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
54
|
+
index: u64,
|
|
55
|
+
ctx: &mut TxContext
|
|
56
|
+
): Coin<T>
|
|
57
|
+
*/
|
|
58
|
+
export declare function getWithdrawIncentiveTx(input: {
|
|
59
|
+
tx: TransactionBlock;
|
|
60
|
+
lockedVaultPackageId: string;
|
|
61
|
+
lockedVaultRegistry: string;
|
|
62
|
+
index: string;
|
|
63
|
+
sender: string;
|
|
64
|
+
}): TransactionBlock;
|
|
65
|
+
/**
|
|
66
|
+
public fun withdraw_premium<D_TOKEN, B_TOKEN>(
|
|
67
|
+
registry: &mut Registry,
|
|
68
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
69
|
+
index: u64,
|
|
70
|
+
ctx: &mut TxContext
|
|
71
|
+
): Coin<B_TOKEN>
|
|
72
|
+
*/
|
|
73
|
+
export declare function getWithdrawPremiumTx(input: {
|
|
74
|
+
tx: TransactionBlock;
|
|
75
|
+
lockedVaultPackageId: string;
|
|
76
|
+
typusDovSingleRegistry: string;
|
|
77
|
+
lockedVaultRegistry: string;
|
|
78
|
+
index: string;
|
|
79
|
+
sender: string;
|
|
80
|
+
typeArguments: string[];
|
|
81
|
+
}): TransactionBlock;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getWithdrawPremiumTx = exports.getWithdrawIncentiveTx = exports.getUnlockReceiptTx = exports.getLeaveTx = exports.getLockReceiptTx = void 0;
|
|
4
|
+
var constants_1 = require("../../constants");
|
|
5
|
+
/**
|
|
6
|
+
public fun lock_receipt(
|
|
7
|
+
registry: &mut Registry,
|
|
8
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
9
|
+
index: u64,
|
|
10
|
+
receipt: TypusDepositReceipt, // from tails_staking::deposit result or owned
|
|
11
|
+
split_active_share: u64,
|
|
12
|
+
split_warmup_share: u64,
|
|
13
|
+
clock: &Clock,
|
|
14
|
+
ctx: &mut TxContext
|
|
15
|
+
): TypusDepositReceipt
|
|
16
|
+
*/
|
|
17
|
+
function getLockReceiptTx(input) {
|
|
18
|
+
input.tx.moveCall({
|
|
19
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::lock_receipt"),
|
|
20
|
+
typeArguments: [],
|
|
21
|
+
arguments: [
|
|
22
|
+
input.tx.object(input.typusDovSingleRegistry),
|
|
23
|
+
input.tx.object(input.lockedVaultRegistry),
|
|
24
|
+
input.tx.pure(input.index),
|
|
25
|
+
input.receipt,
|
|
26
|
+
input.tx.pure(input.split_active_share),
|
|
27
|
+
input.tx.pure(input.split_warmup_share),
|
|
28
|
+
input.tx.pure(constants_1.CLOCK),
|
|
29
|
+
],
|
|
30
|
+
});
|
|
31
|
+
return input.tx;
|
|
32
|
+
}
|
|
33
|
+
exports.getLockReceiptTx = getLockReceiptTx;
|
|
34
|
+
/**
|
|
35
|
+
public fun leave(
|
|
36
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
37
|
+
index: u64,
|
|
38
|
+
clock: &Clock,
|
|
39
|
+
ctx: &mut TxContext
|
|
40
|
+
)
|
|
41
|
+
*/
|
|
42
|
+
function getLeaveTx(input) {
|
|
43
|
+
input.tx.moveCall({
|
|
44
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::leave"),
|
|
45
|
+
typeArguments: [],
|
|
46
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index), input.tx.pure(constants_1.CLOCK)],
|
|
47
|
+
});
|
|
48
|
+
return input.tx;
|
|
49
|
+
}
|
|
50
|
+
exports.getLeaveTx = getLeaveTx;
|
|
51
|
+
/**
|
|
52
|
+
public fun unlock_receipt(
|
|
53
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
54
|
+
index: u64,
|
|
55
|
+
ctx: &mut TxContext
|
|
56
|
+
)
|
|
57
|
+
*/
|
|
58
|
+
function getUnlockReceiptTx(input) {
|
|
59
|
+
input.tx.moveCall({
|
|
60
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::unlock_receipt"),
|
|
61
|
+
typeArguments: [],
|
|
62
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
63
|
+
});
|
|
64
|
+
return input.tx;
|
|
65
|
+
}
|
|
66
|
+
exports.getUnlockReceiptTx = getUnlockReceiptTx;
|
|
67
|
+
/**
|
|
68
|
+
public fun withdraw_incentive<T>(
|
|
69
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
70
|
+
index: u64,
|
|
71
|
+
ctx: &mut TxContext
|
|
72
|
+
): Coin<T>
|
|
73
|
+
*/
|
|
74
|
+
function getWithdrawIncentiveTx(input) {
|
|
75
|
+
var coin = input.tx.moveCall({
|
|
76
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::withdraw_incentive"),
|
|
77
|
+
typeArguments: ["0x2::sui::SUI"],
|
|
78
|
+
arguments: [input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
79
|
+
});
|
|
80
|
+
input.tx.transferObjects([coin], input.sender);
|
|
81
|
+
return input.tx;
|
|
82
|
+
}
|
|
83
|
+
exports.getWithdrawIncentiveTx = getWithdrawIncentiveTx;
|
|
84
|
+
/**
|
|
85
|
+
public fun withdraw_premium<D_TOKEN, B_TOKEN>(
|
|
86
|
+
registry: &mut Registry,
|
|
87
|
+
locked_vault_registry: &mut LockedVaultRegistry,
|
|
88
|
+
index: u64,
|
|
89
|
+
ctx: &mut TxContext
|
|
90
|
+
): Coin<B_TOKEN>
|
|
91
|
+
*/
|
|
92
|
+
function getWithdrawPremiumTx(input) {
|
|
93
|
+
var coin = input.tx.moveCall({
|
|
94
|
+
target: "".concat(input.lockedVaultPackageId, "::locked_period_vault::withdraw_premium"),
|
|
95
|
+
typeArguments: input.typeArguments,
|
|
96
|
+
arguments: [input.tx.object(input.typusDovSingleRegistry), input.tx.object(input.lockedVaultRegistry), input.tx.pure(input.index)],
|
|
97
|
+
});
|
|
98
|
+
input.tx.transferObjects([coin], input.sender);
|
|
99
|
+
return input.tx;
|
|
100
|
+
}
|
|
101
|
+
exports.getWithdrawPremiumTx = getWithdrawPremiumTx;
|
|
@@ -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
|
-
|
|
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,
|
package/package.json
CHANGED
|
@@ -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
|
-
// })();
|