@typus/typus-perp-sdk 1.0.40-fix-history-2 → 1.0.40-fix-history-5

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.
@@ -5,3 +5,4 @@ export interface Volume {
5
5
  timestamp: string;
6
6
  value: number;
7
7
  }
8
+ export declare function getTlpFeeFromSentio(): Promise<number>;
@@ -39,6 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.getFromSentio = getFromSentio;
40
40
  exports.getTlpAPRFromSentio = getTlpAPRFromSentio;
41
41
  exports.getVolumeFromSentio = getVolumeFromSentio;
42
+ exports.getTlpFeeFromSentio = getTlpFeeFromSentio;
42
43
  var src_1 = require("../../src");
43
44
  var headers = {
44
45
  "api-key": "ffJa6FwxeJNrQP8NZ5doEMXqdSA7XM6mT",
@@ -71,7 +72,13 @@ function getFromSentio(event, userAddress, startTimestamp) {
71
72
  case 2:
72
73
  data = _a.sent();
73
74
  // console.log(data);
74
- return [2 /*return*/, data.result.rows];
75
+ if (data.result) {
76
+ return [2 /*return*/, data.result.rows];
77
+ }
78
+ else {
79
+ return [2 /*return*/, []];
80
+ }
81
+ return [2 /*return*/];
75
82
  }
76
83
  });
77
84
  });
@@ -190,3 +197,59 @@ function getVolumeFromSentio() {
190
197
  });
191
198
  });
192
199
  }
200
+ function getTlpFeeFromSentio() {
201
+ return __awaiter(this, void 0, void 0, function () {
202
+ var apiUrl, requestData, jsonData, response, data, first, last, fee;
203
+ return __generator(this, function (_a) {
204
+ switch (_a.label) {
205
+ case 0:
206
+ apiUrl = src_1.NETWORK == "MAINNET"
207
+ ? "https://app.sentio.xyz/api/v1/insights/typus/typus_perp_mainnet/query"
208
+ : "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
209
+ requestData = {
210
+ timeRange: {
211
+ start: "now-7d",
212
+ end: "now",
213
+ step: 3600,
214
+ },
215
+ limit: 20,
216
+ queries: [
217
+ {
218
+ metricsQuery: {
219
+ query: "tlp_fee_usd",
220
+ alias: "",
221
+ id: "a",
222
+ labelSelector: {},
223
+ aggregate: null,
224
+ functions: [],
225
+ disabled: false,
226
+ },
227
+ dataSource: "METRICS",
228
+ sourceName: "",
229
+ },
230
+ ],
231
+ formulas: [],
232
+ };
233
+ jsonData = JSON.stringify(requestData);
234
+ return [4 /*yield*/, fetch(apiUrl, {
235
+ method: "POST",
236
+ headers: headers,
237
+ body: jsonData,
238
+ })];
239
+ case 1:
240
+ response = _a.sent();
241
+ return [4 /*yield*/, response.json()];
242
+ case 2:
243
+ data = _a.sent();
244
+ first = data.results[0].matrix.samples[0].values[0];
245
+ last = data.results[0].matrix.samples[0].values.at(-1);
246
+ fee = last.value - first.value;
247
+ // console.log(fee);
248
+ return [2 /*return*/, fee];
249
+ }
250
+ });
251
+ });
252
+ }
253
+ // getTlpAPRFromSentio();
254
+ // getVolumeFromSentio();
255
+ // getTlpFeeFromSentio();
@@ -20,6 +20,7 @@ export interface Event {
20
20
  realized_pnl: number | undefined;
21
21
  timestamp: string;
22
22
  tx_digest: string;
23
+ dov_index: string | undefined;
23
24
  }
24
25
  export declare function parseUserHistory(raw_events: any): Promise<Event[]>;
25
26
  export declare function getGraphQLEvents(module: string, sender: string, beforeCursor?: string | null): Promise<any>;
@@ -137,6 +137,7 @@ function parseUserHistory(raw_events) {
137
137
  realized_pnl: undefined,
138
138
  timestamp: timestamp,
139
139
  tx_digest: tx_digest,
140
+ dov_index: json.dov_index,
140
141
  };
141
142
  events.push(e);
142
143
  break;
@@ -178,6 +179,7 @@ function parseUserHistory(raw_events) {
178
179
  realized_pnl: realized_pnl,
179
180
  timestamp: timestamp,
180
181
  tx_digest: tx_digest,
182
+ dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
181
183
  };
182
184
  events.push(e);
183
185
  break;
@@ -213,6 +215,7 @@ function parseUserHistory(raw_events) {
213
215
  realized_pnl: undefined,
214
216
  timestamp: timestamp,
215
217
  tx_digest: tx_digest,
218
+ dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
216
219
  };
217
220
  events.push(e);
218
221
  break;
@@ -246,6 +249,7 @@ function parseUserHistory(raw_events) {
246
249
  realized_pnl: undefined,
247
250
  timestamp: timestamp,
248
251
  tx_digest: tx_digest,
252
+ dov_index: related === null || related === void 0 ? void 0 : related.dov_index,
249
253
  };
250
254
  events.push(e);
251
255
  break;
@@ -271,6 +275,7 @@ function parseUserHistory(raw_events) {
271
275
  realized_pnl: -Number(json.fee_amount_usd) / Math.pow(10, 9),
272
276
  timestamp: timestamp,
273
277
  tx_digest: tx_digest,
278
+ dov_index: undefined,
274
279
  };
275
280
  events.push(e);
276
281
  break;
@@ -333,7 +338,7 @@ function getLiquidateFromSentio(userAddress, startTimestamp, events) {
333
338
  side: undefined,
334
339
  order_type: "Market",
335
340
  status: "Filled",
336
- size: undefined,
341
+ size: x.position_size,
337
342
  base_token: base_token,
338
343
  collateral: collateral,
339
344
  collateral_token: x.collateral_token,
@@ -341,6 +346,7 @@ function getLiquidateFromSentio(userAddress, startTimestamp, events) {
341
346
  realized_pnl: -collateral * Number(x.collateral_price),
342
347
  timestamp: x.timestamp,
343
348
  tx_digest: x.transaction_hash,
349
+ dov_index: undefined,
344
350
  };
345
351
  return txHistory;
346
352
  });
@@ -349,8 +355,8 @@ function getLiquidateFromSentio(userAddress, startTimestamp, events) {
349
355
  // console.log(x);
350
356
  // console.log(related);
351
357
  if (related) {
352
- x.side = related.side == "Long" ? "Short" : "Long";
353
- x.size = related.size;
358
+ x.side = related.side;
359
+ x.dov_index = related.dov_index;
354
360
  }
355
361
  return x;
356
362
  });
@@ -389,6 +395,7 @@ function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
389
395
  realized_pnl: x.realized_pnl,
390
396
  timestamp: x.timestamp,
391
397
  tx_digest: x.transaction_hash,
398
+ dov_index: undefined,
392
399
  };
393
400
  return txHistory;
394
401
  });
@@ -400,6 +407,7 @@ function getOrderMatchFromSentio(userAddress, startTimestamp, events) {
400
407
  if (related) {
401
408
  x.order_type = related.order_type;
402
409
  x.collateral = related.collateral;
410
+ x.dov_index = related.dov_index;
403
411
  }
404
412
  else {
405
413
  x.order_type = "Market";
@@ -441,6 +449,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
441
449
  realized_pnl: Number(x.user_remaining_in_usd),
442
450
  timestamp: x.timestamp,
443
451
  tx_digest: x.transaction_hash,
452
+ dov_index: undefined,
444
453
  };
445
454
  // console.log(txHistory);
446
455
  return txHistory;
@@ -452,6 +461,7 @@ function getRealizeOptionFromSentio(userAddress, startTimestamp, events) {
452
461
  if (related) {
453
462
  x.side = related.side;
454
463
  x.size = related.size;
464
+ x.dov_index = related.dov_index;
455
465
  }
456
466
  return x;
457
467
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.40-fix-history-2",
3
+ "version": "1.0.40-fix-history-5",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",