@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, e_3, _c;
33
- var _d, _e, _f, _g, _h;
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 historyAmounts = (_d = history_1.Amount) === null || _d === void 0 ? void 0 : _d.split("\n");
41
- try {
42
- for (var historyAmounts_1 = (e_2 = void 0, __values(historyAmounts)), historyAmounts_1_1 = historyAmounts_1.next(); !historyAmounts_1_1.done; historyAmounts_1_1 = historyAmounts_1.next()) {
43
- var historyAmount = historyAmounts_1_1.value;
44
- var _j = __read(historyAmount.split(" "), 2), amount = _j[0], token = _j[1];
45
- if (depositorCashFlows.has(index)) {
46
- var depositorCashFlow = depositorCashFlows.get(index);
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
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
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
- finally { if (e_2) throw e_2.error; }
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 _k = __read((_e = history_1.Amount) === null || _e === void 0 ? void 0 : _e.split(" "), 2), amount = _k[0], token = _k[1];
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 _l = __read((_f = history_1.Amount) === null || _f === void 0 ? void 0 : _f.split(" "), 2), amount = _l[0], token = _l[1];
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 _m = __read((_g = history_1.Amount) === null || _g === void 0 ? void 0 : _g.split(" "), 2), amount = _m[0], token = _m[1];
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 _o = __read((_h = history_1.Amount) === null || _h === void 0 ? void 0 : _h.split(" "), 2), amount = _o[0], token = _o[1];
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 _p = __values(depositorCashFlows.entries()), _q = _p.next(); !_q.done; _q = _p.next()) {
178
- var _r = __read(_q.value, 2), index = _r[0], share = _r[1];
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 (e_3_1) { e_3 = { error: e_3_1 }; }
170
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
184
171
  finally {
185
172
  try {
186
- if (_q && !_q.done && (_c = _p.return)) _c.call(_p);
173
+ if (_p && !_p.done && (_b = _o.return)) _b.call(_o);
187
174
  }
188
- finally { if (e_3) throw e_3.error; }
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 Reward";
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);
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.100",
5
+ "version": "1.3.1",
6
6
  "dependencies": {
7
7
  "@mysten/bcs": "^0.11.1",
8
8
  "@mysten/kiosk": "0.8.10",