@typus/typus-sdk 1.1.15 → 1.1.17

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.
@@ -35,9 +35,13 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
36
  }
37
37
  };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
38
41
  Object.defineProperty(exports, "__esModule", { value: true });
39
42
  exports.getUserHistory = void 0;
40
43
  var token_1 = require("../token");
44
+ var bignumber_js_1 = __importDefault(require("bignumber.js"));
41
45
  function getUserHistory(provider, originPackage, vaults, sender, startTimeMs) {
42
46
  return __awaiter(this, void 0, void 0, function () {
43
47
  var senderFilter, result, txHistory, nextPage;
@@ -96,73 +100,81 @@ function parseTxHistory(datas, originPackage, vaults) {
96
100
  action = functionType[2];
97
101
  if (event.parsedJson.index) {
98
102
  v = vaults[event.parsedJson.index];
99
- period = void 0;
100
- switch (v.info.period) {
101
- case "0":
102
- period = "Daily";
103
- break;
104
- case "1":
105
- period = "Weekly";
106
- break;
107
- case "2":
108
- period = "Monthly";
109
- break;
110
- default:
111
- period = "";
112
- break;
113
- }
114
- optionType = void 0;
115
- switch (v.info.optionType) {
116
- case "0":
117
- switch (action) {
118
- case "DepositEvent":
119
- case "WithdrawEvent":
120
- case "UnsubscribeEvent":
121
- case "ClaimEvent":
122
- case "CompoundEvent":
123
- case "HarvestEvent":
124
- optionType = "Covered Call";
125
- break;
126
- default:
127
- optionType = "Call";
128
- break;
129
- }
130
- break;
131
- case "1":
132
- switch (action) {
133
- case "DepositEvent":
134
- case "WithdrawEvent":
135
- case "UnsubscribeEvent":
136
- case "ClaimEvent":
137
- case "CompoundEvent":
138
- case "HarvestEvent":
139
- optionType = "Put Selling";
140
- break;
141
- default:
142
- optionType = "Put";
143
- break;
144
- }
145
- break;
146
- default:
147
- optionType = "";
148
- break;
149
- }
150
- switch (v.config.riskLevel) {
151
- case "1":
152
- RiskLevel = "Conservative";
153
- break;
154
- case "2":
155
- RiskLevel = "Moderate";
156
- break;
157
- case "3":
158
- RiskLevel = "Aggressive";
159
- break;
160
- default:
161
- RiskLevel = "";
162
- break;
103
+ if (v) {
104
+ period = void 0;
105
+ switch (v.info.period) {
106
+ case "0":
107
+ period = "Daily";
108
+ break;
109
+ case "1":
110
+ period = "Weekly";
111
+ break;
112
+ case "2":
113
+ period = "Monthly";
114
+ break;
115
+ default:
116
+ period = "";
117
+ break;
118
+ }
119
+ optionType = void 0;
120
+ switch (v.info.optionType) {
121
+ case "0":
122
+ switch (action) {
123
+ case "DepositEvent":
124
+ case "WithdrawEvent":
125
+ case "UnsubscribeEvent":
126
+ case "ClaimEvent":
127
+ case "CompoundEvent":
128
+ case "HarvestEvent":
129
+ optionType = "Covered Call";
130
+ break;
131
+ default:
132
+ optionType = "Call";
133
+ break;
134
+ }
135
+ break;
136
+ case "1":
137
+ switch (action) {
138
+ case "DepositEvent":
139
+ case "WithdrawEvent":
140
+ case "UnsubscribeEvent":
141
+ case "ClaimEvent":
142
+ case "CompoundEvent":
143
+ case "HarvestEvent":
144
+ optionType = "Put Selling";
145
+ break;
146
+ default:
147
+ optionType = "Put";
148
+ break;
149
+ }
150
+ break;
151
+ case "2":
152
+ optionType = "Call Spread";
153
+ case "3":
154
+ optionType = "Put Spread";
155
+ case "4":
156
+ optionType = "Capped Call";
157
+ default:
158
+ optionType = "";
159
+ break;
160
+ }
161
+ switch (v.config.riskLevel) {
162
+ case "1":
163
+ RiskLevel = "Conservative";
164
+ break;
165
+ case "2":
166
+ RiskLevel = "Moderate";
167
+ break;
168
+ case "3":
169
+ RiskLevel = "Aggressive";
170
+ break;
171
+ default:
172
+ RiskLevel = "";
173
+ break;
174
+ }
175
+ Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
176
+ o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
163
177
  }
164
- Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
165
- o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
166
178
  }
167
179
  switch (action) {
168
180
  case "StakeNftEvent":
@@ -221,7 +233,7 @@ function parseTxHistory(datas, originPackage, vaults) {
221
233
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
222
234
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
223
235
  Action = action.slice(0, action.length - 5);
224
- Amount = "".concat(amount, " ").concat(token);
236
+ Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
225
237
  if (i != -1) {
226
238
  txHistory[i].Action = Action;
227
239
  txHistory[i].Amount = Amount;
@@ -233,13 +245,13 @@ function parseTxHistory(datas, originPackage, vaults) {
233
245
  case "TransferBidReceiptEvent":
234
246
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
235
247
  Action = "Transfer Receipt";
236
- Amount = "".concat(amount, " ").concat(o_token);
248
+ Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(o_token);
237
249
  break;
238
250
  case "ExerciseEvent":
239
251
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
240
252
  amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
241
253
  Action = "Exercise";
242
- Amount = "".concat(amount, " ").concat(token);
254
+ Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
243
255
  if (event.parsedJson.u64_padding[0]) {
244
256
  size = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
245
257
  Action = "Exercise ".concat(size, " ").concat(o_token);
@@ -249,7 +261,7 @@ function parseTxHistory(datas, originPackage, vaults) {
249
261
  token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
250
262
  amount = Number(event.parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(token));
251
263
  Action = "Rebate";
252
- Amount = "".concat(amount, " ").concat(token);
264
+ Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
253
265
  break;
254
266
  case "NewBidEvent":
255
267
  i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
@@ -258,7 +270,7 @@ function parseTxHistory(datas, originPackage, vaults) {
258
270
  size = Number(event.parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
259
271
  bidder_balance = Number(event.parsedJson.bidder_balance) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
260
272
  Action = action.slice(0, action.length - 5) + " ".concat(size, " ").concat(o_token);
261
- Amount = "".concat(bidder_balance, " ").concat(b_token);
273
+ Amount = "".concat((0, bignumber_js_1.default)(bidder_balance).toFixed(), " ").concat(b_token);
262
274
  if (i != -1) {
263
275
  txHistory[i].Action = Action;
264
276
  txHistory[i].Amount = Amount;
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.1.15",
5
+ "version": "1.1.17",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.7.3",
8
8
  "@mysten/kiosk": "^0.3.3",