@typus/typus-perp-sdk 1.0.57 → 1.0.59
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/dist/src/api/sentio.d.ts +10 -1
- package/dist/src/api/sentio.js +50 -22
- package/package.json +2 -2
package/dist/src/api/sentio.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
export declare function getFromSentio(event: string, userAddress: string, startTimestamp: string): Promise<any[]>;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Inputs:
|
|
4
|
+
* day: number (at least 1)
|
|
5
|
+
* interval: in hour
|
|
6
|
+
*
|
|
7
|
+
* Returns Map<string, Volume[]>
|
|
8
|
+
* key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
|
|
9
|
+
* value: Volume[]
|
|
10
|
+
*/
|
|
11
|
+
export declare function getTradingVolumeFromSentio(fromTimestamp: number, interval: number): Promise<Map<string, Volume[]>>;
|
|
3
12
|
export interface Volume {
|
|
4
13
|
timestamp: string;
|
|
5
14
|
value: number;
|
package/dist/src/api/sentio.js
CHANGED
|
@@ -37,7 +37,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getFromSentio = getFromSentio;
|
|
40
|
-
exports.
|
|
40
|
+
exports.getTradingVolumeFromSentio = getTradingVolumeFromSentio;
|
|
41
41
|
exports.getTlpFeeFromSentio = getTlpFeeFromSentio;
|
|
42
42
|
exports.getTotalVolumeFromSentio = getTotalVolumeFromSentio;
|
|
43
43
|
exports.getAccumulatedUser = getAccumulatedUser;
|
|
@@ -84,9 +84,18 @@ function getFromSentio(event, userAddress, startTimestamp) {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Inputs:
|
|
89
|
+
* day: number (at least 1)
|
|
90
|
+
* interval: in hour
|
|
91
|
+
*
|
|
92
|
+
* Returns Map<string, Volume[]>
|
|
93
|
+
* key: base_token {'APT','BTC','CETUS','DEEP','ETH','NAVX','NS','SOL','SUI','WAL'}
|
|
94
|
+
* value: Volume[]
|
|
95
|
+
*/
|
|
96
|
+
function getTradingVolumeFromSentio(fromTimestamp, interval) {
|
|
88
97
|
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
-
var apiUrl, requestData, jsonData, response, data,
|
|
98
|
+
var apiUrl, requestData, jsonData, response, data, samples, map;
|
|
90
99
|
return __generator(this, function (_a) {
|
|
91
100
|
switch (_a.label) {
|
|
92
101
|
case 0:
|
|
@@ -95,30 +104,39 @@ function getVolumeFromSentio() {
|
|
|
95
104
|
: "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
|
|
96
105
|
requestData = {
|
|
97
106
|
timeRange: {
|
|
98
|
-
start: "
|
|
107
|
+
start: "".concat(fromTimestamp),
|
|
99
108
|
end: "now",
|
|
100
|
-
step: 3600,
|
|
109
|
+
step: 3600 * interval,
|
|
101
110
|
},
|
|
102
|
-
limit:
|
|
111
|
+
limit: 30 * 24,
|
|
103
112
|
queries: [
|
|
104
113
|
{
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
name: "OrderFilled",
|
|
108
|
-
type: "EVENTS",
|
|
109
|
-
},
|
|
114
|
+
metricsQuery: {
|
|
115
|
+
query: "trading_volume_usd",
|
|
110
116
|
alias: "",
|
|
111
117
|
id: "a",
|
|
112
|
-
|
|
113
|
-
|
|
118
|
+
labelSelector: {},
|
|
119
|
+
aggregate: {
|
|
120
|
+
op: "SUM",
|
|
121
|
+
grouping: ["base_token"],
|
|
114
122
|
},
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
123
|
+
functions: [
|
|
124
|
+
{
|
|
125
|
+
name: "rollup_delta",
|
|
126
|
+
arguments: [
|
|
127
|
+
{
|
|
128
|
+
durationValue: {
|
|
129
|
+
value: interval,
|
|
130
|
+
unit: "h",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
],
|
|
134
|
+
},
|
|
135
|
+
],
|
|
118
136
|
color: "",
|
|
119
137
|
disabled: false,
|
|
120
138
|
},
|
|
121
|
-
dataSource: "
|
|
139
|
+
dataSource: "METRICS",
|
|
122
140
|
sourceName: "",
|
|
123
141
|
},
|
|
124
142
|
],
|
|
@@ -135,11 +153,20 @@ function getVolumeFromSentio() {
|
|
|
135
153
|
return [4 /*yield*/, response.json()];
|
|
136
154
|
case 2:
|
|
137
155
|
data = _a.sent();
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
156
|
+
samples = data.results[0].matrix.samples;
|
|
157
|
+
map = new Map();
|
|
158
|
+
samples.forEach(function (sample) {
|
|
159
|
+
// console.log(samples);
|
|
160
|
+
var base_token = sample.metric.labels.base_token;
|
|
161
|
+
var values = sample.values;
|
|
162
|
+
// console.log(base_token);
|
|
163
|
+
// console.log(values);
|
|
164
|
+
map.set(base_token, values);
|
|
165
|
+
});
|
|
166
|
+
// console.log(map);
|
|
167
|
+
// console.log(map.keys());
|
|
168
|
+
// console.log(map.get("SUI")?.length);
|
|
169
|
+
return [2 /*return*/, map];
|
|
143
170
|
}
|
|
144
171
|
});
|
|
145
172
|
});
|
|
@@ -323,3 +350,4 @@ function getAccumulatedUser() {
|
|
|
323
350
|
// getTlpFeeFromSentio();
|
|
324
351
|
// getAccumulatedUser();
|
|
325
352
|
// getTotalVolumeFromSentio();
|
|
353
|
+
// getTradingVolumeFromSentio(1745712000, 1);
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typus/typus-perp-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.59",
|
|
4
4
|
"repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
|
|
5
5
|
"author": "Typus",
|
|
6
6
|
"description": "typus perp sdk",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@typus/typus-sdk": "1.6.
|
|
9
|
+
"@typus/typus-sdk": "1.6.21"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
12
|
"@types/bs58": "^4.0.1",
|