@typus/typus-sdk 1.1.16 → 1.1.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.
|
@@ -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,79 +100,84 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
96
100
|
action = functionType[2];
|
|
97
101
|
if (event.parsedJson.index) {
|
|
98
102
|
v = vaults[event.parsedJson.index];
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
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
|
+
break;
|
|
154
|
+
case "3":
|
|
155
|
+
optionType = "Put Spread";
|
|
156
|
+
break;
|
|
157
|
+
case "4":
|
|
158
|
+
optionType = "Capped Call";
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
optionType = "";
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
switch (v.config.riskLevel) {
|
|
165
|
+
case "1":
|
|
166
|
+
RiskLevel = "Conservative";
|
|
167
|
+
break;
|
|
168
|
+
case "2":
|
|
169
|
+
RiskLevel = "Moderate";
|
|
170
|
+
break;
|
|
171
|
+
case "3":
|
|
172
|
+
RiskLevel = "Aggressive";
|
|
173
|
+
break;
|
|
174
|
+
default:
|
|
175
|
+
RiskLevel = "";
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
|
|
179
|
+
o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
|
|
169
180
|
}
|
|
170
|
-
Vault = "".concat(v.info.settlementBaseName, " ").concat(period, " ").concat(optionType);
|
|
171
|
-
o_token = (0, token_1.typeArgToAsset)("0x" + v.info.settlementBase);
|
|
172
181
|
}
|
|
173
182
|
switch (action) {
|
|
174
183
|
case "StakeNftEvent":
|
|
@@ -227,7 +236,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
227
236
|
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
228
237
|
amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
|
|
229
238
|
Action = action.slice(0, action.length - 5);
|
|
230
|
-
Amount = "".concat(amount, " ").concat(token);
|
|
239
|
+
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
231
240
|
if (i != -1) {
|
|
232
241
|
txHistory[i].Action = Action;
|
|
233
242
|
txHistory[i].Amount = Amount;
|
|
@@ -239,13 +248,13 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
239
248
|
case "TransferBidReceiptEvent":
|
|
240
249
|
amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
|
|
241
250
|
Action = "Transfer Receipt";
|
|
242
|
-
Amount = "".concat(amount, " ").concat(o_token);
|
|
251
|
+
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(o_token);
|
|
243
252
|
break;
|
|
244
253
|
case "ExerciseEvent":
|
|
245
254
|
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
246
255
|
amount = Number(event.parsedJson.amount) / Math.pow(10, Number(event.parsedJson.decimal));
|
|
247
256
|
Action = "Exercise";
|
|
248
|
-
Amount = "".concat(amount, " ").concat(token);
|
|
257
|
+
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
249
258
|
if (event.parsedJson.u64_padding[0]) {
|
|
250
259
|
size = Number(event.parsedJson.u64_padding[0]) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
|
|
251
260
|
Action = "Exercise ".concat(size, " ").concat(o_token);
|
|
@@ -255,7 +264,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
255
264
|
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.token.name);
|
|
256
265
|
amount = Number(event.parsedJson.amount) / Math.pow(10, (0, token_1.assetToDecimal)(token));
|
|
257
266
|
Action = "Rebate";
|
|
258
|
-
Amount = "".concat(amount, " ").concat(token);
|
|
267
|
+
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|
|
259
268
|
break;
|
|
260
269
|
case "NewBidEvent":
|
|
261
270
|
i = txHistory.findIndex(function (x) { return x.txDigest == event.id.txDigest; });
|
|
@@ -264,7 +273,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
264
273
|
size = Number(event.parsedJson.size) / Math.pow(10, (0, token_1.assetToDecimal)(o_token));
|
|
265
274
|
bidder_balance = Number(event.parsedJson.bidder_balance) / Math.pow(10, (0, token_1.assetToDecimal)(b_token));
|
|
266
275
|
Action = action.slice(0, action.length - 5) + " ".concat(size, " ").concat(o_token);
|
|
267
|
-
Amount = "".concat(bidder_balance, " ").concat(b_token);
|
|
276
|
+
Amount = "".concat((0, bignumber_js_1.default)(bidder_balance).toFixed(), " ").concat(b_token);
|
|
268
277
|
if (i != -1) {
|
|
269
278
|
txHistory[i].Action = Action;
|
|
270
279
|
txHistory[i].Amount = Amount;
|