@typus/typus-sdk 1.2.43 → 1.2.45

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.
@@ -138,7 +138,7 @@ function getPythLatestPrice() {
138
138
  exports.getPythLatestPrice = getPythLatestPrice;
139
139
  function getLatestPriceUSD() {
140
140
  return __awaiter(this, void 0, void 0, function () {
141
- var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, e_2_1;
141
+ var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, result, e_2_1;
142
142
  var e_2, _c;
143
143
  return __generator(this, function (_d) {
144
144
  switch (_d.label) {
@@ -148,7 +148,7 @@ function getLatestPriceUSD() {
148
148
  _d.label = 2;
149
149
  case 2:
150
150
  _d.trys.push([2, 7, 8, 9]);
151
- _a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI"]), _b = _a.next();
151
+ _a = __values(["SUIFUD", "SUIBUCK", "SUIAFSUI", "SCASUI", "USDYUSDC"]), _b = _a.next();
152
152
  _d.label = 3;
153
153
  case 3:
154
154
  if (!!_b.done) return [3 /*break*/, 6];
@@ -159,7 +159,17 @@ function getLatestPriceUSD() {
159
159
  case 4:
160
160
  res = _d.sent();
161
161
  price = res.at(-1).price;
162
- prices.set(pair.replace("SUI", ""), prices.get("SUI") / Number(price));
162
+ result = void 0;
163
+ if (pair.startsWith("SUI")) {
164
+ result = prices.get("SUI") / Number(price);
165
+ }
166
+ else if (pair.endsWith("SUI")) {
167
+ result = prices.get("SUI") * Number(price);
168
+ }
169
+ else {
170
+ result = Number(price);
171
+ }
172
+ prices.set(pair.replace("SUI", ""), result);
163
173
  _d.label = 5;
164
174
  case 5:
165
175
  _b = _a.next();
@@ -32,7 +32,27 @@ export interface Game {
32
32
  export declare function getHistory(provider: SuiClient, dicePackage: string, playgrounds: Playground[]): Promise<DrawDisplay[]>;
33
33
  export declare function waitHistory(provider: SuiClient, dicePackage: string, onMessage: any): Promise<import("@mysten/sui.js/client").Unsubscribe>;
34
34
  export declare function parseHistory(datas: any, playgrounds: Playground[]): Promise<DrawDisplay[]>;
35
- interface DrawDisplay {
35
+ export interface DrawEvent {
36
+ answer_1: string;
37
+ answer_2: string;
38
+ exp: string;
39
+ game_id: string;
40
+ guess_1: string;
41
+ guess_2: string;
42
+ index: string;
43
+ larger_than_1: boolean;
44
+ larger_than_2: boolean;
45
+ player: string;
46
+ public_key: number[];
47
+ result_1: string;
48
+ result_2: string;
49
+ signature_1: number[];
50
+ signature_2: number[];
51
+ signer: string;
52
+ stake_amount: string;
53
+ timestampMs: string;
54
+ }
55
+ export interface DrawDisplay {
36
56
  game_id: string;
37
57
  player: string;
38
58
  guess_1: string;
@@ -41,6 +61,7 @@ interface DrawDisplay {
41
61
  result_2: string;
42
62
  bet_amount: string;
43
63
  exp: string;
64
+ timestampMs: string;
44
65
  }
45
66
  export interface LeaderBoard {
46
67
  player: string;
@@ -58,4 +79,3 @@ export interface ProfitSharing {
58
79
  }
59
80
  export declare function getProfitSharing(provider: SuiClient, diceProfitSharing: string): Promise<ProfitSharing>;
60
81
  export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];
61
- export {};
@@ -158,6 +158,7 @@ function parseHistory(datas, playgrounds) {
158
158
  return __generator(this, function (_a) {
159
159
  result = datas.map(function (event) {
160
160
  var drawEvent = event.parsedJson;
161
+ drawEvent.timestampMs = event.timestampMs;
161
162
  var playground = playgrounds[Number(drawEvent.index)];
162
163
  var coinType = "0x" + playground.stake_token;
163
164
  var asset = (0, token_1.typeArgToAsset)(coinType);
@@ -199,6 +200,7 @@ function parseHistory(datas, playgrounds) {
199
200
  result_2: result_2,
200
201
  bet_amount: "".concat(amount, " ").concat(asset),
201
202
  exp: "".concat(Number(drawEvent.exp), " EXP"),
203
+ timestampMs: drawEvent.timestampMs,
202
204
  };
203
205
  return display;
204
206
  });
@@ -51,6 +51,7 @@ interface DrawDisplay {
51
51
  bet_amount: string;
52
52
  reward: string;
53
53
  exp: string;
54
+ timestampMs: string;
54
55
  }
55
56
  export interface LeaderBoard {
56
57
  player: string;
@@ -158,6 +158,8 @@ function parseHistory(datas, playgrounds) {
158
158
  return __generator(this, function (_a) {
159
159
  result = datas.map(function (event) {
160
160
  var drawEvent = event.parsedJson;
161
+ drawEvent.timestampMs = event.timestampMs;
162
+ // console.log(drawEvent);
161
163
  var playground = playgrounds[Number(drawEvent.index)];
162
164
  var coinType = "0x" + playground.stake_token;
163
165
  var asset = (0, token_1.typeArgToAsset)(coinType);
@@ -201,6 +203,7 @@ function parseHistory(datas, playgrounds) {
201
203
  bet_amount: "".concat(amount, " ").concat(asset),
202
204
  reward: "".concat(reward, " ").concat(asset),
203
205
  exp: "".concat(Number(drawEvent.exp_amount), " EXP"),
206
+ timestampMs: drawEvent.timestampMs,
204
207
  };
205
208
  return display;
206
209
  });
@@ -3,7 +3,7 @@ import { OracleInfo, VaultConfig } from "./view-function";
3
3
  export declare function getVaultHistoryEvents(provider: SuiClient, originPackage: string, startTimeMs: number): Promise<SuiEvent[]>;
4
4
  export declare function parseGroupEvents(datas: SuiEvent[]): Promise<Map<string, Map<string, GroupEvent>>>;
5
5
  export declare function parseVaultHistory(inputMap: Map<string, Map<string, GroupEvent>>): Promise<Map<string, Map<string, VaultHistory | undefined>>>;
6
- export declare function getVaultHistoryFromDB(index?: string, startTs?: string, endTs?: string): Promise<Map<string, Map<string, VaultHistory | undefined>> | undefined>;
6
+ export declare function getVaultHistoryFromDB(index?: string, startTs?: string, endTs?: string, rounds?: number[]): Promise<Map<string, Map<string, VaultHistory | undefined>> | undefined>;
7
7
  export declare function convertGroupEventToVaultHistory(groupEvent: GroupEvent): Promise<VaultHistory | undefined>;
8
8
  export interface VaultHistory {
9
9
  vaultIndex: string;
@@ -211,9 +211,9 @@ function parseVaultHistory(inputMap) {
211
211
  });
212
212
  }
213
213
  exports.parseVaultHistory = parseVaultHistory;
214
- function getVaultHistoryFromDB(index, startTs, endTs) {
214
+ function getVaultHistoryFromDB(index, startTs, endTs, rounds) {
215
215
  return __awaiter(this, void 0, void 0, function () {
216
- var apiUrl, queryParams, apiUrlWithParams, response, map, datas, datas_1, datas_1_1, data, index_1, round, vaultHistory, round_events, round_events;
216
+ var apiUrl, queryParams, apiUrlWithParams, _rounds, response, map, datas, datas_1, datas_1_1, data, index_1, round, vaultHistory, round_events, round_events;
217
217
  var e_1, _a;
218
218
  return __generator(this, function (_b) {
219
219
  switch (_b.label) {
@@ -230,6 +230,11 @@ function getVaultHistoryFromDB(index, startTs, endTs) {
230
230
  queryParams.append("endTs", endTs);
231
231
  }
232
232
  apiUrlWithParams = "".concat(apiUrl, "?").concat(queryParams.toString());
233
+ if (rounds) {
234
+ _rounds = JSON.stringify(rounds);
235
+ apiUrlWithParams += "&rounds=".concat(_rounds);
236
+ }
237
+ console.log(apiUrlWithParams);
233
238
  return [4 /*yield*/, fetch(apiUrlWithParams, {
234
239
  method: "GET",
235
240
  headers: { "Content-Type": "application/json" },
@@ -249,9 +254,9 @@ function getVaultHistoryFromDB(index, startTs, endTs) {
249
254
  vaultHistory = {
250
255
  vaultIndex: index_1,
251
256
  round: round,
252
- ActivationDate: new Date(Number(data.activation_date) / 1000),
257
+ ActivationDate: new Date(Number(data.activation_date)),
253
258
  MaxSize: data.max_size,
254
- SettlementTime: new Date(Number(data.settle_date) / 1000),
259
+ SettlementTime: new Date(Number(data.settle_date)),
255
260
  StrikePrice: data.strikes || undefined,
256
261
  SettlePrice: data.settle_price,
257
262
  Return: data.return,
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.2.43",
5
+ "version": "1.2.45",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "0.7.12",