@typus/typus-perp-sdk 1.1.40 → 1.1.42
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getRevenue(): Promise<Array<[string, number]>>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRevenue = getRevenue;
|
|
4
|
+
async function getRevenue() {
|
|
5
|
+
const apiUrl = "https://api.llama.fi/summary/fees/typus-finance?dataType=dailyRevenue";
|
|
6
|
+
const headers = {
|
|
7
|
+
Accept: "*/*",
|
|
8
|
+
};
|
|
9
|
+
const response = await fetch(apiUrl, {
|
|
10
|
+
method: "GET",
|
|
11
|
+
headers,
|
|
12
|
+
});
|
|
13
|
+
const data = await response.json();
|
|
14
|
+
const chart = Array.isArray(data?.totalDataChart) ? data.totalDataChart : [];
|
|
15
|
+
const monthly = aggregateMonthly(chart);
|
|
16
|
+
return monthly;
|
|
17
|
+
}
|
|
18
|
+
function aggregateMonthly(chart) {
|
|
19
|
+
const map = new Map();
|
|
20
|
+
for (const entry of chart) {
|
|
21
|
+
const ts = Number(entry[0]) || 0;
|
|
22
|
+
const val = Number(entry[1]) || 0;
|
|
23
|
+
const d = new Date(ts * 1000);
|
|
24
|
+
const ym = `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, "0")}`;
|
|
25
|
+
map.set(ym, (map.get(ym) || 0) + val);
|
|
26
|
+
}
|
|
27
|
+
return Array.from(map.entries()).sort((a, b) => a[0].localeCompare(b[0]));
|
|
28
|
+
}
|
|
29
|
+
// getRevenue().then((data) => {
|
|
30
|
+
// console.log("Monthly sums:", data);
|
|
31
|
+
// });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.42",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@mysten/bcs": "1.9.2",
|
|
10
10
|
"@mysten/sui": "1.44.0",
|
|
11
|
-
"@typus/typus-sdk": "1.8.
|
|
11
|
+
"@typus/typus-sdk": "1.8.40"
|
|
12
12
|
},
|
|
13
13
|
"resolutions": {
|
|
14
14
|
"@mysten/bcs": "1.9.2",
|