@typus/typus-sdk 1.2.100 → 1.3.1
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.
|
@@ -29,58 +29,45 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.getDepositorCashFlows = void 0;
|
|
31
31
|
function getDepositorCashFlows(userHistory) {
|
|
32
|
-
var e_1, _a, e_2, _b
|
|
33
|
-
var _d, _e, _f, _g
|
|
32
|
+
var e_1, _a, e_2, _b;
|
|
33
|
+
var _c, _d, _e, _f, _g;
|
|
34
34
|
var depositorCashFlows = new Map();
|
|
35
35
|
try {
|
|
36
36
|
for (var userHistory_1 = __values(userHistory), userHistory_1_1 = userHistory_1.next(); !userHistory_1_1.done; userHistory_1_1 = userHistory_1.next()) {
|
|
37
37
|
var history_1 = userHistory_1_1.value;
|
|
38
38
|
var index = history_1.Index;
|
|
39
39
|
if (history_1.Action.startsWith("Harvest Reward")) {
|
|
40
|
-
var
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var totalHarvest = depositorCashFlow.totalHarvest;
|
|
48
|
-
if (totalHarvest.has(token)) {
|
|
49
|
-
var sum = totalHarvest.get(token);
|
|
50
|
-
totalHarvest.set(token, sum + Number(amount));
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
totalHarvest.set(token, Number(amount));
|
|
54
|
-
}
|
|
55
|
-
depositorCashFlow.totalHarvest = totalHarvest;
|
|
56
|
-
depositorCashFlows.set(index, depositorCashFlow);
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
var totalHarvest = new Map();
|
|
60
|
-
totalHarvest.set(token, Number(amount));
|
|
61
|
-
var depositorCashFlow = {
|
|
62
|
-
D_TOKEN: undefined,
|
|
63
|
-
totalDeposit: 0,
|
|
64
|
-
totalWithdraw: 0,
|
|
65
|
-
totalClaim: 0,
|
|
66
|
-
totalCompound: 0,
|
|
67
|
-
netDeposit: undefined,
|
|
68
|
-
totalHarvest: totalHarvest,
|
|
69
|
-
};
|
|
70
|
-
depositorCashFlows.set(index, depositorCashFlow);
|
|
71
|
-
}
|
|
40
|
+
var _h = __read((_c = history_1.Amount) === null || _c === void 0 ? void 0 : _c.split(" "), 2), amount = _h[0], token = _h[1];
|
|
41
|
+
if (depositorCashFlows.has(index)) {
|
|
42
|
+
var depositorCashFlow = depositorCashFlows.get(index);
|
|
43
|
+
var totalHarvest = depositorCashFlow.totalHarvest;
|
|
44
|
+
if (totalHarvest.has(token)) {
|
|
45
|
+
var sum = totalHarvest.get(token);
|
|
46
|
+
totalHarvest.set(token, sum + Number(amount));
|
|
72
47
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
finally {
|
|
76
|
-
try {
|
|
77
|
-
if (historyAmounts_1_1 && !historyAmounts_1_1.done && (_b = historyAmounts_1.return)) _b.call(historyAmounts_1);
|
|
48
|
+
else {
|
|
49
|
+
totalHarvest.set(token, Number(amount));
|
|
78
50
|
}
|
|
79
|
-
|
|
51
|
+
depositorCashFlow.totalHarvest = totalHarvest;
|
|
52
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
var totalHarvest = new Map();
|
|
56
|
+
totalHarvest.set(token, Number(amount));
|
|
57
|
+
var depositorCashFlow = {
|
|
58
|
+
D_TOKEN: undefined,
|
|
59
|
+
totalDeposit: 0,
|
|
60
|
+
totalWithdraw: 0,
|
|
61
|
+
totalClaim: 0,
|
|
62
|
+
totalCompound: 0,
|
|
63
|
+
netDeposit: undefined,
|
|
64
|
+
totalHarvest: totalHarvest,
|
|
65
|
+
};
|
|
66
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
80
67
|
}
|
|
81
68
|
}
|
|
82
69
|
else if (history_1.Action.startsWith("Deposit")) {
|
|
83
|
-
var
|
|
70
|
+
var _j = __read((_d = history_1.Amount) === null || _d === void 0 ? void 0 : _d.split(" "), 2), amount = _j[0], token = _j[1];
|
|
84
71
|
if (depositorCashFlows.has(index)) {
|
|
85
72
|
var depositorCashFlow = depositorCashFlows.get(index);
|
|
86
73
|
depositorCashFlow.D_TOKEN = token;
|
|
@@ -101,7 +88,7 @@ function getDepositorCashFlows(userHistory) {
|
|
|
101
88
|
}
|
|
102
89
|
}
|
|
103
90
|
else if (history_1.Action.startsWith("Withdraw")) {
|
|
104
|
-
var
|
|
91
|
+
var _k = __read((_e = history_1.Amount) === null || _e === void 0 ? void 0 : _e.split(" "), 2), amount = _k[0], token = _k[1];
|
|
105
92
|
if (depositorCashFlows.has(index)) {
|
|
106
93
|
var depositorCashFlow = depositorCashFlows.get(index);
|
|
107
94
|
depositorCashFlow.D_TOKEN = token;
|
|
@@ -122,7 +109,7 @@ function getDepositorCashFlows(userHistory) {
|
|
|
122
109
|
}
|
|
123
110
|
}
|
|
124
111
|
else if (history_1.Action == "Claim") {
|
|
125
|
-
var
|
|
112
|
+
var _l = __read((_f = history_1.Amount) === null || _f === void 0 ? void 0 : _f.split(" "), 2), amount = _l[0], token = _l[1];
|
|
126
113
|
if (depositorCashFlows.has(index)) {
|
|
127
114
|
var depositorCashFlow = depositorCashFlows.get(index);
|
|
128
115
|
depositorCashFlow.D_TOKEN = token;
|
|
@@ -143,7 +130,7 @@ function getDepositorCashFlows(userHistory) {
|
|
|
143
130
|
}
|
|
144
131
|
}
|
|
145
132
|
else if (history_1.Action == "Compound") {
|
|
146
|
-
var
|
|
133
|
+
var _m = __read((_g = history_1.Amount) === null || _g === void 0 ? void 0 : _g.split(" "), 2), amount = _m[0], token = _m[1];
|
|
147
134
|
if (depositorCashFlows.has(index)) {
|
|
148
135
|
var depositorCashFlow = depositorCashFlows.get(index);
|
|
149
136
|
depositorCashFlow.D_TOKEN = token;
|
|
@@ -174,18 +161,18 @@ function getDepositorCashFlows(userHistory) {
|
|
|
174
161
|
}
|
|
175
162
|
try {
|
|
176
163
|
// console.log(depositorCashFlows);
|
|
177
|
-
for (var
|
|
178
|
-
var
|
|
164
|
+
for (var _o = __values(depositorCashFlows.entries()), _p = _o.next(); !_p.done; _p = _o.next()) {
|
|
165
|
+
var _q = __read(_p.value, 2), index = _q[0], share = _q[1];
|
|
179
166
|
share.netDeposit = share.totalDeposit + share.totalCompound - share.totalWithdraw - share.totalClaim;
|
|
180
167
|
depositorCashFlows.set(index, share);
|
|
181
168
|
}
|
|
182
169
|
}
|
|
183
|
-
catch (
|
|
170
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
184
171
|
finally {
|
|
185
172
|
try {
|
|
186
|
-
if (
|
|
173
|
+
if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
|
|
187
174
|
}
|
|
188
|
-
finally { if (
|
|
175
|
+
finally { if (e_2) throw e_2.error; }
|
|
189
176
|
}
|
|
190
177
|
return depositorCashFlows;
|
|
191
178
|
}
|
|
@@ -350,7 +350,7 @@ function parseTxHistory(datas, originPackage, vaults) {
|
|
|
350
350
|
else {
|
|
351
351
|
if (event.parsedJson.log[6] > 0) {
|
|
352
352
|
// harvest
|
|
353
|
-
Action = "Harvest
|
|
353
|
+
Action = "Harvest";
|
|
354
354
|
token = (0, token_1.typeArgToAsset)("0x" + event.parsedJson.b_token.name);
|
|
355
355
|
amount = Number(event.parsedJson.log[6]) / Math.pow(10, (0, token_1.assetToDecimal)(token));
|
|
356
356
|
Amount = "".concat((0, bignumber_js_1.default)(amount).toFixed(), " ").concat(token);
|