@typus/typus-sdk 1.9.2 → 1.9.3

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.
@@ -51,17 +51,6 @@ var __read = (this && this.__read) || function (o, n) {
51
51
  }
52
52
  return ar;
53
53
  };
54
- var __values = (this && this.__values) || function(o) {
55
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
56
- if (m) return m.call(o);
57
- if (o && typeof o.length === "number") return {
58
- next: function () {
59
- if (o && i >= o.length) o = void 0;
60
- return { value: o && o[i++], done: !o };
61
- }
62
- };
63
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
64
- };
65
54
  Object.defineProperty(exports, "__esModule", { value: true });
66
55
  exports.getPairPrices = getPairPrices;
67
56
  exports.getLatestPrice = getLatestPrice;
@@ -208,54 +197,13 @@ function getPythLatestPriceBySymbols(symbols) {
208
197
  }
209
198
  function getLatestPriceUSD() {
210
199
  return __awaiter(this, void 0, void 0, function () {
211
- var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, result, e_2_1;
212
- var e_2, _c;
213
- return __generator(this, function (_d) {
214
- switch (_d.label) {
200
+ var prices;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
215
203
  case 0: return [4 /*yield*/, getPythLatestPrice()];
216
204
  case 1:
217
- prices = (_d.sent());
218
- _d.label = 2;
219
- case 2:
220
- _d.trys.push([2, 7, 8, 9]);
221
- _a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI", "SCASUI", "USDYUSDC"]), _b = _a.next();
222
- _d.label = 3;
223
- case 3:
224
- if (!!_b.done) return [3 /*break*/, 6];
225
- pair = _b.value;
226
- currentTimestampInSeconds = Math.floor(new Date().getTime() / 1000);
227
- minuteAgo = currentTimestampInSeconds - 300;
228
- return [4 /*yield*/, getPairPrices(pair, minuteAgo.toString(), currentTimestampInSeconds.toString())];
229
- case 4:
230
- res = _d.sent();
231
- price = res.at(-1).price;
232
- result = void 0;
233
- if (pair.startsWith("SUI")) {
234
- result = prices.get("SUI") / Number(price);
235
- }
236
- else if (pair.endsWith("SUI")) {
237
- result = prices.get("SUI") * Number(price);
238
- }
239
- else {
240
- result = Number(price);
241
- }
242
- prices.set(pair.replace("SUI", ""), result);
243
- _d.label = 5;
244
- case 5:
245
- _b = _a.next();
246
- return [3 /*break*/, 3];
247
- case 6: return [3 /*break*/, 9];
248
- case 7:
249
- e_2_1 = _d.sent();
250
- e_2 = { error: e_2_1 };
251
- return [3 /*break*/, 9];
252
- case 8:
253
- try {
254
- if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
255
- }
256
- finally { if (e_2) throw e_2.error; }
257
- return [7 /*endfinally*/];
258
- case 9: return [2 /*return*/, prices];
205
+ prices = (_a.sent());
206
+ return [2 /*return*/, prices];
259
207
  }
260
208
  });
261
209
  });
@@ -59,7 +59,7 @@ exports.getExerciseFromSentio = getExerciseFromSentio;
59
59
  var typus_dov_single_v2_1 = require("../../../../src/typus-dov-single-v2");
60
60
  var constants_1 = require("../../../../src/constants");
61
61
  var headers = {
62
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
62
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
63
63
  "Content-Type": "application/json",
64
64
  };
65
65
  function getFromSentio(event, userAddress, startTimestamp) {
@@ -71,7 +71,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
71
71
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
72
72
  requestData = {
73
73
  sqlQuery: {
74
- sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinct_id = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
74
+ sql: "\n SELECT *\n FROM ".concat(event, "\n WHERE distinctId = '").concat(userAddress, "' AND timestamp >= ").concat(startTimestamp, "\n ORDER BY timestamp DESC;\n "),
75
75
  size: 1000,
76
76
  },
77
77
  };
@@ -86,7 +86,7 @@ function getFromSentio(event, userAddress, startTimestamp) {
86
86
  return [4 /*yield*/, response.json()];
87
87
  case 2:
88
88
  data = _a.sent();
89
- // console.log(data);
89
+ console.log(data);
90
90
  return [2 /*return*/, data.result.rows];
91
91
  }
92
92
  });
@@ -101,7 +101,7 @@ function getFromSentioWithExpUp(event, userAddress, startTimestamp) {
101
101
  apiUrl = "https://app.sentio.xyz/api/v1/analytics/typus/typus_v2/sql/execute";
102
102
  requestData = {
103
103
  sqlQuery: {
104
- sql: "\n SELECT *\n FROM ".concat(event, " 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 AND N.log_index + 1 = S.log_index\n WHERE N.distinct_id = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
104
+ sql: "\n SELECT *\n FROM ".concat(event, " N\n LEFT JOIN (\n SELECT number, distinctId, exp_earn, transaction_hash, log_index\n FROM ExpUp\n ) S ON N.transaction_hash = S.transaction_hash AND N.log_index + 1 = S.log_index\n WHERE N.distinctId = '").concat(userAddress, "' AND N.timestamp >= ").concat(startTimestamp, "\n ORDER BY N.timestamp DESC;\n "),
105
105
  size: 1000,
106
106
  },
107
107
  };
@@ -50,7 +50,7 @@ function getExpLeaderBoardWithOwner(expLeaderBoard, ownerMap) {
50
50
  });
51
51
  }
52
52
  var headers = {
53
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
53
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
54
54
  "Content-Type": "application/json",
55
55
  };
56
56
  function getExpLeaderBoard(startTimestamp, endTimestamp) {
@@ -55,7 +55,7 @@ exports.getAccumulatedUser = getAccumulatedUser;
55
55
  exports.getAccumulatedNotionalVolumeUSD = getAccumulatedNotionalVolumeUSD;
56
56
  exports.getSafuAccumulatedRewardGeneratedUSD = getSafuAccumulatedRewardGeneratedUSD;
57
57
  var headers = {
58
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
58
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
59
59
  "Content-Type": "application/json",
60
60
  };
61
61
  function getTotalDepositorIncentive() {
@@ -96,7 +96,7 @@ function getTotalPremium() {
96
96
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
97
97
  requestData = {
98
98
  timeRange: {
99
- start: "now",
99
+ start: "now-1h",
100
100
  end: "now",
101
101
  step: 3600,
102
102
  timezone: "Europe/Paris",
@@ -148,7 +148,7 @@ function getAccumulatedRewardGeneratedUSD() {
148
148
  apiUrlV1 = "https://app.sentio.xyz/api/v1/insights/typus/typus_v1/query";
149
149
  requestDataV1 = {
150
150
  timeRange: {
151
- start: "now",
151
+ start: "now-1h",
152
152
  end: "now",
153
153
  step: 3600,
154
154
  timezone: "Asia/Taipei",
@@ -188,7 +188,7 @@ function getAccumulatedRewardGeneratedUSD() {
188
188
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
189
189
  requestData = {
190
190
  timeRange: {
191
- start: "now",
191
+ start: "now-1h",
192
192
  end: "now",
193
193
  step: 3600,
194
194
  timezone: "Asia/Taipei",
@@ -283,12 +283,10 @@ function getAccumulatedUser() {
283
283
  apiUrl = apiUrls_1_1.value;
284
284
  requestData = {
285
285
  timeRange: {
286
- start: "now-1h",
286
+ start: "now-3d",
287
287
  end: "now",
288
- step: 3600,
289
- timezone: "Asia/Taipei",
288
+ step: 86400,
290
289
  },
291
- limit: 1,
292
290
  queries: [
293
291
  {
294
292
  eventsQuery: {
@@ -307,7 +305,7 @@ function getAccumulatedUser() {
307
305
  },
308
306
  },
309
307
  groupBy: [],
310
- limit: 1,
308
+ limit: 0,
311
309
  functions: [],
312
310
  disabled: false,
313
311
  },
@@ -328,8 +326,8 @@ function getAccumulatedUser() {
328
326
  return [4 /*yield*/, response.json()];
329
327
  case 4:
330
328
  data = _b.sent();
331
- // console.log(data.results[0].matrix.samples[0].values[0].value);
332
- result.push(data.results[0].matrix.samples[0].values[0].value);
329
+ // console.dir(data.results[0].matrix, { depth: null });
330
+ result.push(data.results[0].matrix.samples[0].values.at(-1).value);
333
331
  _b.label = 5;
334
332
  case 5:
335
333
  apiUrls_1_1 = apiUrls_1.next();
@@ -375,10 +373,9 @@ function getAccumulatedNotionalVolumeUSD() {
375
373
  apiUrl = apiUrls_2_1.value;
376
374
  requestData = {
377
375
  timeRange: {
378
- start: "now",
376
+ start: "now-1h",
379
377
  end: "now",
380
378
  step: 3600,
381
- timezone: "Asia/Taipei",
382
379
  },
383
380
  limit: 1,
384
381
  queries: [
@@ -446,7 +443,7 @@ function getSafuAccumulatedRewardGeneratedUSD() {
446
443
  apiUrl = "https://app.sentio.xyz/api/v1/insights/typus/typus_v2/query";
447
444
  requestData = {
448
445
  timeRange: {
449
- start: "now",
446
+ start: "now-1h",
450
447
  end: "now",
451
448
  step: 3600,
452
449
  timezone: "Asia/Taipei",
@@ -489,5 +486,8 @@ function getSafuAccumulatedRewardGeneratedUSD() {
489
486
  });
490
487
  });
491
488
  }
492
- // getAccumulatedNotionalVolumeUSD();
493
- // getAccumulatedUser();
489
+ // getTotalDepositorIncentive().then((res) => console.log(res));
490
+ // getTotalPremium().then((res) => console.log(res));
491
+ // getAccumulatedNotionalVolumeUSD().then((res) => console.log(res));
492
+ // getAccumulatedUser().then((res) => console.log(res));
493
+ // getAccumulatedRewardGeneratedUSD().then((res) => console.log(res));
@@ -40,7 +40,7 @@ exports.getVaultHistorySummary = getVaultHistorySummary;
40
40
  exports.getFilledSummary = getFilledSummary;
41
41
  exports.getVaultHistory = getVaultHistory;
42
42
  var headers = {
43
- "api-key": "RIobs1PpAZ4SmHxY2InErtz0pL5LqHTtY",
43
+ "api-key": "g8vRPVCM3CScaTVGVT5X9Eh4fyEJDbmAE",
44
44
  "Content-Type": "application/json",
45
45
  };
46
46
  function getVaultHistorySummary(startTimestamp) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@typus/typus-sdk",
3
3
  "author": "Typus",
4
4
  "description": "typus sdk",
5
- "version": "1.9.2",
5
+ "version": "1.9.3",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "2.0.3",
8
8
  "@mysten/kiosk": "1.2.0",
@@ -1,88 +0,0 @@
1
- import { Auction, BidShare, Vault } from "../../../src/typus-dov-single-v2";
2
- import BigNumber from "bignumber.js";
3
- import { TypusConfig } from "../../../src/utils";
4
- export declare const tokenOrder: {
5
- [key: string]: number;
6
- };
7
- export declare const optionTypeOrder: {
8
- [key: string]: number;
9
- };
10
- export declare const periodOrder: {
11
- [key: string]: number;
12
- };
13
- export type Receipt = {
14
- id: string;
15
- index: string;
16
- name: string;
17
- description: string;
18
- vid: string;
19
- };
20
- export type TokenAmount = {
21
- value: string;
22
- token: string;
23
- };
24
- export type BidVaultInfo = {
25
- vaultInfo: Vault;
26
- receipt: Receipt;
27
- };
28
- export interface Bid {
29
- vaultIndex: string;
30
- expiry: string;
31
- auctionName: string;
32
- strikes: string[];
33
- bidSize: TokenAmount;
34
- breakEvenPrice: string;
35
- estPnls: TokenAmount[];
36
- receiptsId: string[];
37
- receiptsVid: string[];
38
- settlePrice: string;
39
- isAutoBid: boolean;
40
- }
41
- export interface OrderBy {
42
- tokenOrder: number;
43
- optionTypeOrder: number;
44
- periodOrder: number;
45
- }
46
- export interface CoinInfo {
47
- price: string;
48
- decimal: string;
49
- quote: string;
50
- }
51
- export declare const IncentiveRateBp = 4;
52
- export declare const calcIncentiveRate: (incentiveBp: any) => number;
53
- export declare const calcDeliveryPrice: (bidShare: BidShare, vaultInfo: Vault) => BigNumber;
54
- export declare const calcBreakEvenPrice: (optionType: string, period: string, strikes: string[], bToken: string, price: string, incentive: number) => number;
55
- export declare const calcEstPnl: (live: boolean, incentive: number, bidSize: string, optionType: string, assets: string[], strikes: string[], bidShare: BidShare, deliveryPrice: string, oTokenPrice: string) => TokenAmount[];
56
- export declare const parseStrikes: (period: string, optionType: string, metadata: string) => string[];
57
- export declare const parseBidReceipt: (vaults: Vault[], bidReceipts: {
58
- [key: string]: Receipt[];
59
- }) => {
60
- sortedBidReceipts: string[];
61
- bidVaultsInfo: BidVaultInfo[];
62
- };
63
- export declare const parseBid: (bidVaultInfo: BidVaultInfo, bidShare: BidShare, auction: Auction | null, oTokenPrice: string, isAutoBid: boolean) => Bid & OrderBy;
64
- export declare function getUserOwnedObjects(config: TypusConfig, user: string): Promise<import("@mysten/sui/client", { with: { "resolution-mode": "import" } }).SuiClientTypes.Object<{
65
- content: true;
66
- }>[]>;
67
- export declare const getUserBidReceipts: (config: TypusConfig, data: any) => Promise<{
68
- [key: string]: Receipt[];
69
- }>;
70
- /**
71
- * Fetch user's bids info
72
- *
73
- * @param provider - Sui Client instance.
74
- * @param network - network type in lowercase.
75
- * @param packageAddress - Typus main package address.
76
- * @param framworkAddress - Typus framwork package address.
77
- * @param originFramworkAddress - Typus intial framwork package address.
78
- * @param registryAddress - Typus registry package address.
79
- * @param strategyPoolAddress - strategy pool package address.
80
- * @param user - user's wallet address.
81
- * @param prices - tokens prices (usd pair on Pyth)
82
- * @return User Bids.
83
- */
84
- export declare function fetchUserBids(config: TypusConfig, user: string, vaultsInfo: {
85
- [key: string]: Vault;
86
- }, userReceipts: {
87
- [key: string]: Receipt[];
88
- }): Promise<any>;