@typus/typus-sdk 1.8.41 → 1.8.43-upgrade

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.
Files changed (50) hide show
  1. package/dist/src/auto-bid/view-function.d.ts +0 -2
  2. package/dist/src/auto-bid/view-function.js +7 -76
  3. package/dist/src/constants/constant.d.ts +0 -3
  4. package/dist/src/constants/constant.js +1 -8
  5. package/dist/src/constants/token.d.ts +1 -1
  6. package/dist/src/constants/token.js +12 -0
  7. package/dist/src/dice/fetch.d.ts +0 -4
  8. package/dist/src/dice/fetch.js +59 -116
  9. package/dist/src/typus/airdrop/view-function.js +5 -8
  10. package/dist/src/typus/leaderboard/view-function.js +5 -8
  11. package/dist/src/typus/tails-staking/view-function.js +10 -14
  12. package/dist/src/typus/user/view-function.js +5 -6
  13. package/dist/src/typus-dov-single-v2/function/bidding.d.ts +4 -3
  14. package/dist/src/typus-dov-single-v2/function/bidding.js +10 -11
  15. package/dist/src/typus-dov-single-v2/function/token.js +1 -1
  16. package/dist/src/typus-dov-single-v2/history/index.d.ts +0 -1
  17. package/dist/src/typus-dov-single-v2/history/index.js +0 -1
  18. package/dist/src/typus-dov-single-v2/history/user-history.d.ts +2 -3
  19. package/dist/src/typus-dov-single-v2/history/user-history.js +122 -184
  20. package/dist/src/typus-dov-single-v2/otc-entry.js +5 -6
  21. package/dist/src/typus-dov-single-v2/user-entry.d.ts +1 -1
  22. package/dist/src/typus-dov-single-v2/view-function.js +29 -27
  23. package/dist/src/typus-hedge/view-function.js +10 -10
  24. package/dist/src/typus-launch/airdrop/view-function.js +3 -5
  25. package/dist/src/typus-launch/auction/view-function.js +17 -16
  26. package/dist/src/typus-launch/funding-vault/view-function.js +20 -18
  27. package/dist/src/typus-launch/improvement-proposal/view-function.js +17 -18
  28. package/dist/src/typus-launch/ve-typus/view-function.js +15 -15
  29. package/dist/src/typus-safu/view-function.js +13 -13
  30. package/dist/src/utils/api/price.js +1 -1
  31. package/dist/src/utils/graphQl.d.ts +24 -0
  32. package/dist/src/utils/graphQl.js +129 -0
  33. package/dist/src/utils/index.d.ts +1 -0
  34. package/dist/src/utils/index.js +1 -0
  35. package/dist/src/utils/oracle.js +13 -14
  36. package/dist/src/utils/pyth/constant.js +4 -0
  37. package/dist/src/utils/sponsoredTx.d.ts +2 -2
  38. package/dist/src/utils/typusConfig.d.ts +4 -0
  39. package/dist/src/utils/typusConfig.js +33 -31
  40. package/package.json +9 -10
  41. package/dist/src/dice/view-function.d.ts +0 -1
  42. package/dist/src/dice/view-function.js +0 -20
  43. package/dist/src/typus-dov-single-v2/history/vault-history.d.ts +0 -123
  44. package/dist/src/typus-dov-single-v2/history/vault-history.js +0 -307
  45. package/dist/src/typus-nft/fetch.d.ts +0 -70
  46. package/dist/src/typus-nft/fetch.js +0 -631
  47. package/dist/src/typus-nft/index.d.ts +0 -2
  48. package/dist/src/typus-nft/index.js +0 -18
  49. package/dist/src/typus-nft/user-entry.d.ts +0 -57
  50. package/dist/src/typus-nft/user-entry.js +0 -161
@@ -68,7 +68,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
68
68
  Object.defineProperty(exports, "__esModule", { value: true });
69
69
  exports.getExerciseFromSentio = exports.getNewBidFromSentio = void 0;
70
70
  exports.getUserEvents = getUserEvents;
71
- exports.getAutoBidEvents = getAutoBidEvents;
72
71
  exports.parseTxHistory = parseTxHistory;
73
72
  exports.parseVaultInfo = parseVaultInfo;
74
73
  exports.getDepositorCashFlows = getDepositorCashFlows;
@@ -79,70 +78,17 @@ var events_1 = require("../../../src/utils/api/sentio/events");
79
78
  Object.defineProperty(exports, "getNewBidFromSentio", { enumerable: true, get: function () { return events_1.getNewBidFromSentio; } });
80
79
  Object.defineProperty(exports, "getExerciseFromSentio", { enumerable: true, get: function () { return events_1.getExerciseFromSentio; } });
81
80
  var valut_1 = require("../../../src/constants/valut");
82
- function getUserEvents(provider, sender, cursor) {
81
+ var graphQl_1 = require("../../../src/utils/graphQl");
82
+ function getUserEvents(graphQlClient, sender, cursor) {
83
83
  return __awaiter(this, void 0, void 0, function () {
84
- var senderFilter, hasNextPage, datas, result;
84
+ var events;
85
85
  return __generator(this, function (_a) {
86
86
  switch (_a.label) {
87
- case 0:
88
- senderFilter = {
89
- Sender: sender,
90
- };
91
- hasNextPage = true;
92
- datas = [];
93
- _a.label = 1;
87
+ case 0: return [4 /*yield*/, (0, graphQl_1.getEvents)(graphQlClient, null, sender, cursor)];
94
88
  case 1:
95
- if (!hasNextPage) return [3 /*break*/, 3];
96
- return [4 /*yield*/, provider.queryEvents({
97
- query: senderFilter,
98
- order: "ascending",
99
- cursor: cursor,
100
- })];
101
- case 2:
102
- result = _a.sent();
103
- // console.log(result);
104
- hasNextPage = result.hasNextPage;
105
- cursor = result.nextCursor;
106
- // @ts-ignore
107
- datas = datas.concat(result.data);
108
- return [3 /*break*/, 1];
109
- case 3: return [2 /*return*/, [datas, cursor]];
110
- }
111
- });
112
- });
113
- }
114
- function getAutoBidEvents(provider, originPackage, startTimeMs) {
115
- return __awaiter(this, void 0, void 0, function () {
116
- var moduleFilter, hasNextPage, cursor, datas, result;
117
- return __generator(this, function (_a) {
118
- switch (_a.label) {
119
- case 0:
120
- moduleFilter = {
121
- MoveModule: { package: originPackage, module: "auto_bid" },
122
- };
123
- hasNextPage = true;
124
- cursor = undefined;
125
- datas = [];
126
- _a.label = 1;
127
- case 1:
128
- if (!hasNextPage) return [3 /*break*/, 3];
129
- return [4 /*yield*/, provider.queryEvents({
130
- query: moduleFilter,
131
- order: "descending",
132
- cursor: cursor,
133
- })];
134
- case 2:
135
- result = _a.sent();
136
- // console.log(result);
137
- hasNextPage = result.hasNextPage;
138
- cursor = result.nextCursor;
139
- // @ts-ignore
140
- datas = datas.concat(result.data);
141
- if (hasNextPage && Number(result.data[result.data.length - 1].timestampMs) < startTimeMs) {
142
- return [3 /*break*/, 3];
143
- }
144
- return [3 /*break*/, 1];
145
- case 3: return [2 /*return*/, datas];
89
+ events = _a.sent();
90
+ // console.log(events.map(x => x.timestamp))
91
+ return [2 /*return*/, events.reverse()];
146
92
  }
147
93
  });
148
94
  });
@@ -155,25 +101,16 @@ function parseTxHistory(datas, vaults) {
155
101
  switch (_a.label) {
156
102
  case 0: return [4 /*yield*/, datas
157
103
  .filter(function (event) {
158
- var type = event.type;
159
- return (event.module == "tds_user_entry" ||
104
+ var type = event.contents.type.repr;
105
+ return (event.transactionModule == "tds_user_entry" ||
160
106
  type.includes("typus_dov_single") ||
161
107
  type.includes("auto_bid") ||
162
108
  type.includes("typus_nft::First") ||
163
109
  type.includes("typus_nft::ExpUpEvent") ||
164
110
  type.includes("tails_staking"));
165
- })
166
- .sort(function (a, b) {
167
- // From Old to New!
168
- if (a.timestampMs == b.timestampMs) {
169
- return Number(a.id.eventSeq) - Number(b.id.eventSeq);
170
- }
171
- else {
172
- return Number(a.timestampMs) - Number(b.timestampMs);
173
- }
174
111
  })
175
112
  .reduce(function (promise, event) { return __awaiter(_this, void 0, void 0, function () {
176
- var txHistory, functionType, action, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, d_token, b_token, o_token, token, amount, i, i, i, token, amount, token, amount, amount, token, amount, token, amount, token, amount, b_token_name, b_token_amount, i_token_name, i_token_amount, token, amount, token, amount, deposit_amount, deposit_amount, balance, balance, profit, profit, token, amount, amount, token, amount, size, token, amount, token, amount, size, bidder_balance;
113
+ var txHistory, functionType, action, json, Action, Amount, Index, Period, Vault, RiskLevel, Tails, Exp, d_token, b_token, o_token, token, amount, i, i, i, token, amount, token, amount, amount, token, amount, token, amount, token, amount, b_token_name, b_token_amount, i_token_name, i_token_amount, token, amount, token, amount, deposit_amount, deposit_amount, balance, balance, profit, profit, token, amount, amount, token, amount, size, token, amount, token, amount, size, bidder_balance;
177
114
  var _a, _b, _c;
178
115
  var _d;
179
116
  return __generator(this, function (_e) {
@@ -181,10 +118,11 @@ function parseTxHistory(datas, vaults) {
181
118
  case 0: return [4 /*yield*/, promise];
182
119
  case 1:
183
120
  txHistory = _e.sent();
184
- functionType = (_d = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.type)) === null || _d === void 0 ? void 0 : _d.slice(1, 4);
121
+ functionType = (_d = new RegExp("^([^::]+)::([^::]+)::([^<]+)").exec(event.contents.type.repr)) === null || _d === void 0 ? void 0 : _d.slice(1, 4);
185
122
  action = functionType[2];
123
+ json = event.contents.json;
186
124
  Tails = undefined;
187
- Index = event.parsedJson.index || event.parsedJson.vault_index;
125
+ Index = json.index || json.vault_index;
188
126
  if (Index) {
189
127
  _a = __read(parseVaultInfo(vaults, Index, action), 6), Period = _a[0], Vault = _a[1], RiskLevel = _a[2], d_token = _a[3], b_token = _a[4], o_token = _a[5];
190
128
  }
@@ -193,30 +131,30 @@ function parseTxHistory(datas, vaults) {
193
131
  case "StakeTailsEvent":
194
132
  Action = "Stake";
195
133
  Amount = "0.05 SUI";
196
- Tails = "#".concat(event.parsedJson.log[0]);
134
+ Tails = "#".concat(json.log[0]);
197
135
  break;
198
136
  case "UnstakeTailsEvent":
199
137
  Action = "Unstake";
200
- Tails = "#".concat(event.parsedJson.log[0]);
138
+ Tails = "#".concat(json.log[0]);
201
139
  break;
202
140
  case "DailySignUpEvent":
203
141
  Action = "Check In";
204
- if (event.parsedJson.log[1]) {
205
- Amount = "".concat(Number(event.parsedJson.log[1]) / Math.pow(10, 9), " SUI");
142
+ if (json.log[1]) {
143
+ Amount = "".concat(Number(json.log[1]) / Math.pow(10, 9), " SUI");
206
144
  }
207
- Tails = event.parsedJson.tails.map(function (num) { return "#".concat(num); }).join(" ");
208
- Exp = event.parsedJson.log[0];
145
+ Tails = json.tails.map(function (num) { return "#".concat(num); }).join(" ");
146
+ Exp = json.log[0];
209
147
  break;
210
148
  case "TransferTailsEvent":
211
149
  Action = "Transfer";
212
150
  Amount = "0.01 SUI";
213
- Tails = "#".concat(event.parsedJson.log[0]);
151
+ Tails = "#".concat(json.log[0]);
214
152
  break;
215
153
  case "ExpUpEvent":
216
- if (event.parsedJson.log) {
154
+ if (json.log) {
217
155
  Action = "Train Tail";
218
- Tails = "#".concat(event.parsedJson.log[0]);
219
- Exp = event.parsedJson.log[1];
156
+ Tails = "#".concat(json.log[0]);
157
+ Exp = json.log[1];
220
158
  if (Number(Exp) == 0) {
221
159
  return [2 /*return*/, txHistory];
222
160
  }
@@ -224,21 +162,21 @@ function parseTxHistory(datas, vaults) {
224
162
  break;
225
163
  case "ExpDownEvent":
226
164
  Action = "Extract Exp";
227
- Tails = "#".concat(event.parsedJson.log[0]);
228
- Exp = event.parsedJson.log[1];
165
+ Tails = "#".concat(json.log[0]);
166
+ Exp = json.log[1];
229
167
  break;
230
168
  case "LevelUpEvent":
231
- if (event.parsedJson.log) {
232
- Action = "Level Up to Level ".concat(event.parsedJson.log[1]);
233
- Tails = "#".concat(event.parsedJson.log[0]);
169
+ if (json.log) {
170
+ Action = "Level Up to Level ".concat(json.log[1]);
171
+ Tails = "#".concat(json.log[0]);
234
172
  }
235
173
  break;
236
174
  case "ClaimProfitSharingEvent":
237
- if (event.parsedJson.profit_asset) {
238
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.profit_asset.name);
239
- amount = Number(event.parsedJson.log[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
175
+ if (json.profit_asset) {
176
+ token = (0, constants_1.typeArgToAsset)("0x" + json.profit_asset);
177
+ amount = Number(json.log[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
240
178
  Action = "Harvest Dice Profit";
241
- Tails = event.parsedJson.tails.map(function (num) { return "#".concat(num); }).join(" ");
179
+ Tails = json.tails.map(function (num) { return "#".concat(num); }).join(" ");
242
180
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
243
181
  }
244
182
  break;
@@ -246,23 +184,23 @@ function parseTxHistory(datas, vaults) {
246
184
  case "StakeNftEvent":
247
185
  Action = "Stake";
248
186
  Amount = "0.05 SUI";
249
- Tails = "#".concat(event.parsedJson.number);
187
+ Tails = "#".concat(json.number);
250
188
  break;
251
189
  case "UnstakeNftEvent":
252
190
  Action = "Unstake";
253
- Tails = "#".concat(event.parsedJson.number);
191
+ Tails = "#".concat(json.number);
254
192
  break;
255
193
  case "ExpUpEvent":
256
- i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest && x.Action != "First Deposit" && x.Action != "Stake"; });
194
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.transaction.digest && x.Action != "First Deposit" && x.Action != "Stake"; });
257
195
  if (i != -1 && txHistory[i].Tails == undefined) {
258
- txHistory[i].Tails = "#".concat(event.parsedJson.number);
259
- txHistory[i].Exp = event.parsedJson.exp_earn;
196
+ txHistory[i].Tails = "#".concat(json.number);
197
+ txHistory[i].Exp = json.exp_earn;
260
198
  return [2 /*return*/, txHistory];
261
199
  }
262
200
  else if (event.id.eventSeq == 0) {
263
201
  Action = "Collect EXP";
264
- Tails = "#".concat(event.parsedJson.number);
265
- Exp = event.parsedJson.exp_earn;
202
+ Tails = "#".concat(json.number);
203
+ Exp = json.exp_earn;
266
204
  }
267
205
  else {
268
206
  return [2 /*return*/, txHistory];
@@ -271,10 +209,10 @@ function parseTxHistory(datas, vaults) {
271
209
  case "TransferNftEvent":
272
210
  Action = "Transfer";
273
211
  Amount = "0.01 SUI";
274
- Tails = "#".concat(event.parsedJson.number);
212
+ Tails = "#".concat(json.number);
275
213
  break;
276
214
  case "DailyAttendEvent":
277
- i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest && x.Action == "Collect EXP"; });
215
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.transaction.digest && x.Action == "Collect EXP"; });
278
216
  if (i != -1) {
279
217
  txHistory[i].Action = "Check In";
280
218
  return [2 /*return*/, txHistory];
@@ -282,18 +220,18 @@ function parseTxHistory(datas, vaults) {
282
220
  break;
283
221
  case "FirstDepositEvent":
284
222
  Action = "First Deposit";
285
- Tails = "#".concat(event.parsedJson.number);
286
- Exp = event.parsedJson.exp_earn;
223
+ Tails = "#".concat(json.number);
224
+ Exp = json.exp_earn;
287
225
  break;
288
226
  case "FirstBidEvent":
289
227
  Action = "First Bid";
290
- Tails = "#".concat(event.parsedJson.number);
291
- Exp = event.parsedJson.exp_earn;
228
+ Tails = "#".concat(json.number);
229
+ Exp = json.exp_earn;
292
230
  break;
293
231
  case "LevelUpEvent":
294
- Action = "Level Up to Level ".concat(event.parsedJson.level);
295
- if (event.parsedJson.number) {
296
- Tails = "#".concat(event.parsedJson.number);
232
+ Action = "Level Up to Level ".concat(json.level);
233
+ if (json.number) {
234
+ Tails = "#".concat(json.number);
297
235
  break;
298
236
  }
299
237
  else {
@@ -305,9 +243,9 @@ function parseTxHistory(datas, vaults) {
305
243
  case "ClaimEvent":
306
244
  case "CompoundEvent":
307
245
  case "HarvestEvent":
308
- i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest && x.Action == "Collect EXP"; });
309
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
310
- amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
246
+ i = txHistory.findIndex(function (x) { return x.txDigest == event.transaction.digest && x.Action == "Collect EXP"; });
247
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
248
+ amount = Number(json.amount) / Math.pow(10, Number(json.decimal));
311
249
  Action = action.slice(0, action.length - 5);
312
250
  if (Action == "Harvest") {
313
251
  Action = "Harvest Reward";
@@ -324,30 +262,30 @@ function parseTxHistory(datas, vaults) {
324
262
  }
325
263
  break;
326
264
  case "RaiseFundEvent":
327
- Index = event.parsedJson.log[0];
265
+ Index = json.log[0];
328
266
  _b = __read(parseVaultInfo(vaults, Index, action), 6), Period = _b[0], Vault = _b[1], RiskLevel = _b[2], d_token = _b[3], b_token = _b[4], o_token = _b[5];
329
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
330
- if (event.parsedJson.log[4] > 0) {
267
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
268
+ if (json.log[4] > 0) {
331
269
  // deposit
332
270
  Action = "Deposit";
333
- amount = Number(event.parsedJson.log[4]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
271
+ amount = Number(json.log[4]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
334
272
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
335
273
  }
336
- else if (event.parsedJson.log[5] > 0) {
274
+ else if (json.log[5] > 0) {
337
275
  // compound
338
276
  Action = "Compound";
339
- amount = Number(event.parsedJson.log[5]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
277
+ amount = Number(json.log[5]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
340
278
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
341
279
  }
342
280
  break;
343
281
  case "ReduceFundEvent":
344
- Index = event.parsedJson.log[0];
282
+ Index = json.log[0];
345
283
  _c = __read(parseVaultInfo(vaults, Index, action), 6), Period = _c[0], Vault = _c[1], RiskLevel = _c[2], d_token = _c[3], b_token = _c[4], o_token = _c[5];
346
- if (event.parsedJson.log[4] > 0) {
284
+ if (json.log[4] > 0) {
347
285
  // withdraw
348
286
  Action = "Withdraw";
349
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.d_token.name);
350
- amount = Number(event.parsedJson.log[4]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
287
+ token = (0, constants_1.typeArgToAsset)("0x" + json.d_token);
288
+ amount = Number(json.log[4]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
351
289
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
352
290
  txHistory.push({
353
291
  Index: Index,
@@ -358,15 +296,15 @@ function parseTxHistory(datas, vaults) {
358
296
  RiskLevel: RiskLevel,
359
297
  Tails: Tails,
360
298
  Exp: Exp,
361
- Date: new Date(Number(event.timestampMs)),
362
- txDigest: event.id.txDigest,
299
+ Date: new Date(event.timestamp),
300
+ txDigest: event.transaction.digest,
363
301
  });
364
302
  }
365
- if (event.parsedJson.log[5] > 0) {
303
+ if (json.log[5] > 0) {
366
304
  // unsubscribe
367
305
  Action = "Unsubscribe";
368
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.d_token.name);
369
- amount = Number(event.parsedJson.log[5]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
306
+ token = (0, constants_1.typeArgToAsset)("0x" + json.d_token);
307
+ amount = Number(json.log[5]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
370
308
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
371
309
  txHistory.push({
372
310
  Index: Index,
@@ -377,15 +315,15 @@ function parseTxHistory(datas, vaults) {
377
315
  RiskLevel: RiskLevel,
378
316
  Tails: Tails,
379
317
  Exp: Exp,
380
- Date: new Date(Number(event.timestampMs)),
381
- txDigest: event.id.txDigest,
318
+ Date: new Date(event.timestamp),
319
+ txDigest: event.transaction.digest,
382
320
  });
383
321
  }
384
- if (event.parsedJson.log[9] > 0) {
322
+ if (json.log[9] > 0) {
385
323
  // claim
386
324
  Action = "Claim";
387
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.d_token.name);
388
- amount = Number(event.parsedJson.log[9]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
325
+ token = (0, constants_1.typeArgToAsset)("0x" + json.d_token);
326
+ amount = Number(json.log[9]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
389
327
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
390
328
  txHistory.push({
391
329
  Index: Index,
@@ -396,21 +334,21 @@ function parseTxHistory(datas, vaults) {
396
334
  RiskLevel: RiskLevel,
397
335
  Tails: Tails,
398
336
  Exp: Exp,
399
- Date: new Date(Number(event.timestampMs)),
400
- txDigest: event.id.txDigest,
337
+ Date: new Date(event.timestamp),
338
+ txDigest: event.transaction.digest,
401
339
  });
402
340
  }
403
- if (event.parsedJson.log[6] > 0 && event.parsedJson.log[10] > 0) {
341
+ if (json.log[6] > 0 && json.log[10] > 0) {
404
342
  // Harvest d token and i token
405
343
  Action = "Harvest Reward";
406
- b_token_name = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.b_token.name);
407
- b_token_amount = Number(event.parsedJson.log[6]) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token_name));
408
- i_token_name = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.i_token.name);
409
- i_token_amount = Number(event.parsedJson.log[10]) / Math.pow(10, (0, constants_1.assetToDecimal)(i_token_name));
344
+ b_token_name = (0, constants_1.typeArgToAsset)("0x" + json.b_token);
345
+ b_token_amount = Number(json.log[6]) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token_name));
346
+ i_token_name = (0, constants_1.typeArgToAsset)("0x" + json.i_token);
347
+ i_token_amount = Number(json.log[10]) / Math.pow(10, (0, constants_1.assetToDecimal)(i_token_name));
410
348
  Amount = "".concat((0, bignumber_js_1.default)(b_token_amount).toFixed(), " ").concat(b_token_name, "\n").concat((0, bignumber_js_1.default)(i_token_amount).toFixed(), " ").concat(i_token_name);
411
349
  // var amount =
412
- // Number(event.parsedJson!.log[6]) / 10 ** assetToDecimal(token)!
413
- // Number(event.parsedJson!.log[10]) / 10 ** assetToDecimal(token)!;
350
+ // Number(json.log[6]) / 10 ** assetToDecimal(token)!
351
+ // Number(json.log[10]) / 10 ** assetToDecimal(token)!;
414
352
  // Amount = `${BigNumber(amount).toFixed()} ${token}`;
415
353
  txHistory.push({
416
354
  Index: Index,
@@ -421,16 +359,16 @@ function parseTxHistory(datas, vaults) {
421
359
  RiskLevel: RiskLevel,
422
360
  Tails: Tails,
423
361
  Exp: Exp,
424
- Date: new Date(Number(event.timestampMs)),
425
- txDigest: event.id.txDigest,
362
+ Date: new Date(event.timestamp),
363
+ txDigest: event.transaction.digest,
426
364
  });
427
365
  }
428
366
  else {
429
- if (event.parsedJson.log[6] > 0) {
367
+ if (json.log[6] > 0) {
430
368
  // harvest
431
369
  Action = "Harvest Reward";
432
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.b_token.name);
433
- amount = Number(event.parsedJson.log[6]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
370
+ token = (0, constants_1.typeArgToAsset)("0x" + json.b_token);
371
+ amount = Number(json.log[6]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
434
372
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
435
373
  txHistory.push({
436
374
  Index: Index,
@@ -441,15 +379,15 @@ function parseTxHistory(datas, vaults) {
441
379
  RiskLevel: RiskLevel,
442
380
  Tails: Tails,
443
381
  Exp: Exp,
444
- Date: new Date(Number(event.timestampMs)),
445
- txDigest: event.id.txDigest,
382
+ Date: new Date(event.timestamp),
383
+ txDigest: event.transaction.digest,
446
384
  });
447
385
  }
448
- if (event.parsedJson.log[10] > 0) {
386
+ if (json.log[10] > 0) {
449
387
  // redeem
450
388
  Action = "Harvest Reward";
451
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.i_token.name);
452
- amount = Number(event.parsedJson.log[10]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
389
+ token = (0, constants_1.typeArgToAsset)("0x" + json.i_token);
390
+ amount = Number(json.log[10]) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
453
391
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
454
392
  txHistory.push({
455
393
  Index: Index,
@@ -460,87 +398,87 @@ function parseTxHistory(datas, vaults) {
460
398
  RiskLevel: RiskLevel,
461
399
  Tails: Tails,
462
400
  Exp: Exp,
463
- Date: new Date(Number(event.timestampMs)),
464
- txDigest: event.id.txDigest,
401
+ Date: new Date(event.timestamp),
402
+ txDigest: event.transaction.digest,
465
403
  });
466
404
  }
467
405
  }
468
406
  return [2 /*return*/, txHistory];
469
407
  case "NewStrategyEventV2":
470
408
  Action = "Create Strategy";
471
- deposit_amount = Number(event.parsedJson.deposit_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
409
+ deposit_amount = Number(json.deposit_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
472
410
  Amount = "".concat((0, bignumber_js_1.default)(deposit_amount).toFixed(), " ").concat(b_token);
473
411
  break;
474
412
  case "UpdateStrategyEvent":
475
413
  Action = "Update Strategy";
476
- deposit_amount = Number(event.parsedJson.deposit_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
414
+ deposit_amount = Number(json.deposit_amount) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
477
415
  Amount = "".concat((0, bignumber_js_1.default)(deposit_amount).toFixed(), " ").concat(b_token);
478
416
  break;
479
417
  case "CloseStrategyEventV2":
480
418
  Action = "Close Strategy";
481
419
  if (b_token == d_token) {
482
- balance = (Number(event.parsedJson.u64_padding[0]) + Number(event.parsedJson.u64_padding[1])) /
420
+ balance = (Number(json.u64_padding[0]) + Number(json.u64_padding[1])) /
483
421
  Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
484
422
  Amount = "".concat((0, bignumber_js_1.default)(balance).toFixed(), " ").concat(b_token);
485
423
  }
486
424
  else {
487
- balance = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
488
- profit = Number(event.parsedJson.u64_padding[1]) / Math.pow(10, (0, constants_1.assetToDecimal)(d_token));
425
+ balance = Number(json.u64_padding[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
426
+ profit = Number(json.u64_padding[1]) / Math.pow(10, (0, constants_1.assetToDecimal)(d_token));
489
427
  Amount = "".concat((0, bignumber_js_1.default)(balance).toFixed(), " ").concat(b_token, "\n").concat((0, bignumber_js_1.default)(profit).toFixed(), " ").concat(d_token);
490
428
  }
491
429
  break;
492
430
  case "WithdrawProfitEvent":
493
431
  Action = "Harvest Gain";
494
- profit = Number(event.parsedJson.profit) / Math.pow(10, (0, constants_1.assetToDecimal)(d_token));
432
+ profit = Number(json.profit) / Math.pow(10, (0, constants_1.assetToDecimal)(d_token));
495
433
  Amount = "".concat((0, bignumber_js_1.default)(profit).toFixed(), " ").concat(d_token);
496
434
  break;
497
435
  case "RedeemEvent":
498
436
  if (event.type == "0xc654c3634a10567b329de1226c2629cae39cdc16ec5d594897d87b250d46e958::typus_dov_single::RedeemEvent") {
499
437
  break;
500
438
  }
501
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
502
- amount = Number(event.parsedJson.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
439
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
440
+ amount = Number(json.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
503
441
  Action = "Harvest Reward";
504
442
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
505
443
  Index = Index;
506
444
  break;
507
445
  case "TransferBidReceiptEvent":
508
- amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
446
+ amount = Number(json.amount) / Math.pow(10, Number(json.decimal));
509
447
  Action = "Transfer Receipt";
510
448
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(o_token);
511
449
  break;
512
450
  case "ExerciseEvent":
513
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
514
- amount = Number(event.parsedJson.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
451
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
452
+ amount = Number(json.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
515
453
  Action = "Exercise";
516
454
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
517
- if (event.parsedJson.u64_padding[0]) {
518
- size = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
455
+ if (json.u64_padding[0]) {
456
+ size = Number(json.u64_padding[0]) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
519
457
  Action = "Exercise ".concat(size, " ").concat(o_token);
520
458
  }
521
- if (event.sender != event.parsedJson.signer) {
459
+ if (event.sender != json.signer) {
522
460
  Action = "Auto " + Action;
523
461
  }
524
462
  break;
525
463
  case "RefundEvent":
526
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
527
- amount = Number(event.parsedJson.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
464
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
465
+ amount = Number(json.amount) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
528
466
  Action = "Rebate";
529
467
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
530
468
  break;
531
469
  // case "ClaimProfitSharingEvent":
532
- // var token = typeArgToAsset("0x" + event.parsedJson!.token.name);
533
- // var amount = Number(event.parsedJson!.value) / 10 ** assetToDecimal(token)!;
470
+ // var token = typeArgToAsset("0x" + json.token);
471
+ // var amount = Number(json.value) / 10 ** assetToDecimal(token)!;
534
472
  // Action = "Claim Profit Sharing";
535
473
  // Amount = `${BigNumber(amount).toFixed()} ${token}`;
536
- // Tails = `#${event.parsedJson!.number}`;
474
+ // Tails = `#${json.number}`;
537
475
  // break;
538
476
  case "ClaimProfitSharingEventV2":
539
- token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
540
- amount = Number(event.parsedJson.value) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
477
+ token = (0, constants_1.typeArgToAsset)("0x" + json.token);
478
+ amount = Number(json.value) / Math.pow(10, (0, constants_1.assetToDecimal)(token));
541
479
  // dice_profit, exp_profit
542
480
  // TODO: filter amount != 0
543
- switch (event.parsedJson.name) {
481
+ switch (json) {
544
482
  case "dice_profit":
545
483
  Action = "Harvest Dice Profit";
546
484
  break;
@@ -549,16 +487,16 @@ function parseTxHistory(datas, vaults) {
549
487
  break;
550
488
  }
551
489
  Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
552
- Tails = "#".concat(event.parsedJson.number);
490
+ Tails = "#".concat(json.number);
553
491
  break;
554
492
  case "NewBidEvent":
555
- o_token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.o_token.name);
556
- b_token = (0, constants_1.typeArgToAsset)("0x" + event.parsedJson.b_token.name);
557
- size = Number(event.parsedJson.size) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
558
- bidder_balance = Number(event.parsedJson.bidder_balance) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
493
+ o_token = (0, constants_1.typeArgToAsset)("0x" + json.o_token);
494
+ b_token = (0, constants_1.typeArgToAsset)("0x" + json.b_token);
495
+ size = Number(json.size) / Math.pow(10, (0, constants_1.assetToDecimal)(o_token));
496
+ bidder_balance = Number(json.bidder_balance) / Math.pow(10, (0, constants_1.assetToDecimal)(b_token));
559
497
  Action = action.slice(0, action.length - 5) + " ".concat(size, " ").concat(o_token);
560
498
  Amount = "".concat((0, bignumber_js_1.default)(bidder_balance).toFixed(), " ").concat(b_token);
561
- if (event.sender != event.parsedJson.signer) {
499
+ if (event.sender != json.signer) {
562
500
  Action = "Auto " + Action;
563
501
  }
564
502
  break;
@@ -574,8 +512,8 @@ function parseTxHistory(datas, vaults) {
574
512
  RiskLevel: RiskLevel,
575
513
  Tails: Tails,
576
514
  Exp: Exp,
577
- Date: new Date(Number(event.timestampMs)),
578
- txDigest: event.id.txDigest,
515
+ Date: new Date(event.timestamp),
516
+ txDigest: event.transaction.digest,
579
517
  });
580
518
  return [2 /*return*/, txHistory];
581
519
  }