@typus/typus-perp-sdk 1.0.16 → 1.0.18

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 +1,2 @@
1
1
  export declare function getFromSentio(event: string, userAddress: string, startTimestamp: string): Promise<any[]>;
2
+ export declare function getTlpAPRFromSentio(): Promise<number>;
@@ -37,8 +37,9 @@ 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.getTlpAPRFromSentio = getTlpAPRFromSentio;
40
41
  var headers = {
41
- "api-key": "tz3JJ6stG7Fux6ueRSRA5mdpC9U0lozI3",
42
+ "api-key": "vQCQ6ZvvFesph3Q8usDLKfc7Wx2D8AX5M",
42
43
  "Content-Type": "application/json",
43
44
  };
44
45
  function getFromSentio(event, userAddress, startTimestamp) {
@@ -47,7 +48,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
47
48
  return __generator(this, function (_a) {
48
49
  switch (_a.label) {
49
50
  case 0:
50
- apiUrl = "https://app.sentio.xyz/api/v1/analytics/wayne/typus_perp/sql/execute";
51
+ apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_perp/sql/execute";
51
52
  requestData = {
52
53
  sqlQuery: {
53
54
  sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
@@ -71,3 +72,56 @@ function getFromSentio(event, userAddress, startTimestamp) {
71
72
  });
72
73
  });
73
74
  }
75
+ function getTlpAPRFromSentio() {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var apiUrl, requestData, jsonData, response, data, first, last, r, apr;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0:
81
+ apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_perp/query";
82
+ requestData = {
83
+ timeRange: {
84
+ start: "now-7d",
85
+ end: "now",
86
+ step: 3600,
87
+ },
88
+ limit: 20,
89
+ queries: [
90
+ {
91
+ metricsQuery: {
92
+ query: "tlp_price",
93
+ alias: "",
94
+ id: "a",
95
+ labelSelector: {},
96
+ aggregate: null,
97
+ functions: [],
98
+ disabled: false,
99
+ },
100
+ dataSource: "METRICS",
101
+ sourceName: "",
102
+ },
103
+ ],
104
+ formulas: [],
105
+ };
106
+ jsonData = JSON.stringify(requestData);
107
+ return [4 /*yield*/, fetch(apiUrl, {
108
+ method: "POST",
109
+ headers: headers,
110
+ body: jsonData,
111
+ })];
112
+ case 1:
113
+ response = _a.sent();
114
+ return [4 /*yield*/, response.json()];
115
+ case 2:
116
+ data = _a.sent();
117
+ first = data.results[0].matrix.samples[0].values[0];
118
+ last = data.results[0].matrix.samples[0].values.at(-1);
119
+ r = last.value / first.value - 1;
120
+ apr = (365 / 7) * r;
121
+ // console.log(apr);
122
+ return [2 /*return*/, apr];
123
+ }
124
+ });
125
+ });
126
+ }
127
+ // getTlpPriceFromSentio();
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.PKG_V1 = exports.PUBLISHED_AT = exports.PACKAGE_ID = void 0;
4
4
  var index_1 = require("../index");
5
5
  exports.PACKAGE_ID = index_1.NETWORK == "MAINNET" ? "" : "0x7c19f81d9d411e78305d7af8dad25317c56bb449fede8a78b6021232478f0509";
6
- exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0xbeb23d2d58881dbe45c2493d20d86e079600e367d7b5de5a28e5ec10acd28793";
6
+ exports.PUBLISHED_AT = index_1.NETWORK == "MAINNET" ? "" : "0xbaae1453492e8d0ade225f360a5a24f8ee466f4ee66488fecf26e40f6d87fadd";
7
7
  exports.PKG_V1 = index_1.NETWORK == "MAINNET" ? "" : "0x7c19f81d9d411e78305d7af8dad25317c56bb449fede8a78b6021232478f0509";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typus/typus-perp-sdk",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "repository": "https://github.com/Typus-Lab/typus-perp-sdk.git",
5
5
  "author": "Typus",
6
6
  "description": "typus perp sdk",