@typus/typus-sdk 1.2.31 → 1.2.33
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.
- package/lib/utils/auto-bid/user-entry.js +37 -17
- package/lib/utils/auto-bid/view-function.d.ts +3 -1
- package/lib/utils/auto-bid/view-function.js +70 -5
- package/lib/utils/leader-board.js +0 -13
- package/lib/utils/price.js +15 -7
- package/lib/utils/typus-dov-single-v2/depositorPnl.d.ts +12 -0
- package/lib/utils/typus-dov-single-v2/depositorPnl.js +220 -0
- package/package.json +1 -1
|
@@ -137,23 +137,43 @@ registry, strategy_pool, vault_index, signal_index, strategy_index, coins, amoun
|
|
|
137
137
|
// B_TOKEN
|
|
138
138
|
typeArguments[1] == "0x2::sui::SUI" ||
|
|
139
139
|
typeArguments[1] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
140
|
+
if (amount) {
|
|
141
|
+
var _a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), input_coin = _a[0];
|
|
142
|
+
tx.moveCall({
|
|
143
|
+
target: "".concat(packageId, "::auto_bid::update_strategy"),
|
|
144
|
+
typeArguments: typeArguments,
|
|
145
|
+
arguments: [
|
|
146
|
+
tx.object(registry),
|
|
147
|
+
tx.object(strategy_pool),
|
|
148
|
+
tx.pure(vault_index),
|
|
149
|
+
tx.pure(signal_index),
|
|
150
|
+
tx.pure(strategy_index),
|
|
151
|
+
tx.pure(size ? [size] : []),
|
|
152
|
+
tx.pure(price_percentage ? [price_percentage] : []),
|
|
153
|
+
tx.pure(max_times ? [max_times] : []),
|
|
154
|
+
tx.pure(target_rounds),
|
|
155
|
+
tx.makeMoveVec({ objects: [input_coin] }),
|
|
156
|
+
],
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
tx.moveCall({
|
|
161
|
+
target: "".concat(packageId, "::auto_bid::update_strategy"),
|
|
162
|
+
typeArguments: typeArguments,
|
|
163
|
+
arguments: [
|
|
164
|
+
tx.object(registry),
|
|
165
|
+
tx.object(strategy_pool),
|
|
166
|
+
tx.pure(vault_index),
|
|
167
|
+
tx.pure(signal_index),
|
|
168
|
+
tx.pure(strategy_index),
|
|
169
|
+
tx.pure(size ? [size] : []),
|
|
170
|
+
tx.pure(price_percentage ? [price_percentage] : []),
|
|
171
|
+
tx.pure(max_times ? [max_times] : []),
|
|
172
|
+
tx.pure(target_rounds),
|
|
173
|
+
tx.makeMoveVec({ objects: [] }),
|
|
174
|
+
],
|
|
175
|
+
});
|
|
176
|
+
}
|
|
157
177
|
}
|
|
158
178
|
else {
|
|
159
179
|
var coin = coins.pop();
|
|
@@ -4,7 +4,7 @@ export declare function getUserStrategies(provider: SuiClient, packageId: string
|
|
|
4
4
|
export declare function getVaults(provider: SuiClient, strategyPool: string): Promise<StrategyPoolV2>;
|
|
5
5
|
export interface StrategyPoolV2 {
|
|
6
6
|
id: string;
|
|
7
|
-
strategies: Map<string, Map<string,
|
|
7
|
+
strategies: Map<string, Map<string, string>>;
|
|
8
8
|
authority: string[];
|
|
9
9
|
}
|
|
10
10
|
export interface StrategyV2 {
|
|
@@ -38,3 +38,5 @@ export interface TypusBidReceipt {
|
|
|
38
38
|
metadata: string;
|
|
39
39
|
u64_padding: string[];
|
|
40
40
|
}
|
|
41
|
+
export declare function getStrategies(provider: SuiClient, strategyIds: string[]): Promise<Map<string, StrategyV2>>;
|
|
42
|
+
export declare function getStrategyIds(provider: SuiClient, parentId: string): Promise<string[]>;
|
|
@@ -63,7 +63,7 @@ var __values = (this && this.__values) || function(o) {
|
|
|
63
63
|
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
64
64
|
};
|
|
65
65
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
exports.getVaults = exports.getUserStrategies = void 0;
|
|
66
|
+
exports.getStrategyIds = exports.getStrategies = exports.getVaults = exports.getUserStrategies = void 0;
|
|
67
67
|
var bcs_1 = require("@mysten/bcs");
|
|
68
68
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
69
69
|
var tools_1 = require("../tools");
|
|
@@ -230,7 +230,7 @@ exports.getUserStrategies = getUserStrategies;
|
|
|
230
230
|
function getVaults(provider, strategyPool) {
|
|
231
231
|
var _a;
|
|
232
232
|
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
-
var pool, vaults, strategies, vaults_1, vaults_1_1, vault, signals, _b, _c, signal, strategy_pool;
|
|
233
|
+
var pool, vaults, strategies, vaults_1, vaults_1_1, vault, signals, _b, _c, signal, strategyTable, strategy_pool;
|
|
234
234
|
var e_1, _d, e_2, _e;
|
|
235
235
|
return __generator(this, function (_f) {
|
|
236
236
|
switch (_f.label) {
|
|
@@ -246,10 +246,9 @@ function getVaults(provider, strategyPool) {
|
|
|
246
246
|
try {
|
|
247
247
|
for (_b = (e_2 = void 0, __values(vault.fields.value.fields.contents)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
248
248
|
signal = _c.value;
|
|
249
|
-
|
|
249
|
+
strategyTable = signal.fields.value.fields.contents;
|
|
250
250
|
// console.log(strategyTable);
|
|
251
|
-
|
|
252
|
-
signals.set(signal.fields.key, []);
|
|
251
|
+
signals.set(signal.fields.key, strategyTable.fields.id.id);
|
|
253
252
|
}
|
|
254
253
|
}
|
|
255
254
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
@@ -280,3 +279,69 @@ function getVaults(provider, strategyPool) {
|
|
|
280
279
|
});
|
|
281
280
|
}
|
|
282
281
|
exports.getVaults = getVaults;
|
|
282
|
+
function getStrategies(provider, strategyIds) {
|
|
283
|
+
var _a;
|
|
284
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
285
|
+
var strategies, len, results, results_1, results_1_1, result, fields;
|
|
286
|
+
var e_3, _b;
|
|
287
|
+
return __generator(this, function (_c) {
|
|
288
|
+
switch (_c.label) {
|
|
289
|
+
case 0:
|
|
290
|
+
strategies = new Map();
|
|
291
|
+
_c.label = 1;
|
|
292
|
+
case 1:
|
|
293
|
+
if (!(strategyIds.length > 0)) return [3 /*break*/, 3];
|
|
294
|
+
len = strategyIds.length > 50 ? 50 : strategyIds.length;
|
|
295
|
+
return [4 /*yield*/, provider.multiGetObjects({ ids: strategyIds.splice(0, len), options: { showContent: true } })];
|
|
296
|
+
case 2:
|
|
297
|
+
results = _c.sent();
|
|
298
|
+
try {
|
|
299
|
+
for (results_1 = (e_3 = void 0, __values(results)), results_1_1 = results_1.next(); !results_1_1.done; results_1_1 = results_1.next()) {
|
|
300
|
+
result = results_1_1.value;
|
|
301
|
+
fields = (_a = result.data) === null || _a === void 0 ? void 0 : _a.content.fields;
|
|
302
|
+
// console.log(fields);
|
|
303
|
+
strategies.set(fields.name, fields.value.fields);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
307
|
+
finally {
|
|
308
|
+
try {
|
|
309
|
+
if (results_1_1 && !results_1_1.done && (_b = results_1.return)) _b.call(results_1);
|
|
310
|
+
}
|
|
311
|
+
finally { if (e_3) throw e_3.error; }
|
|
312
|
+
}
|
|
313
|
+
return [3 /*break*/, 1];
|
|
314
|
+
case 3: return [2 /*return*/, strategies];
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
exports.getStrategies = getStrategies;
|
|
320
|
+
function getStrategyIds(provider, parentId) {
|
|
321
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
+
var result, datas;
|
|
323
|
+
return __generator(this, function (_a) {
|
|
324
|
+
switch (_a.label) {
|
|
325
|
+
case 0: return [4 /*yield*/, provider.getDynamicFields({
|
|
326
|
+
parentId: parentId,
|
|
327
|
+
})];
|
|
328
|
+
case 1:
|
|
329
|
+
result = _a.sent();
|
|
330
|
+
datas = result.data;
|
|
331
|
+
_a.label = 2;
|
|
332
|
+
case 2:
|
|
333
|
+
if (!result.hasNextPage) return [3 /*break*/, 4];
|
|
334
|
+
return [4 /*yield*/, provider.getDynamicFields({
|
|
335
|
+
parentId: parentId,
|
|
336
|
+
cursor: result.nextCursor,
|
|
337
|
+
})];
|
|
338
|
+
case 3:
|
|
339
|
+
result = _a.sent();
|
|
340
|
+
datas = datas.concat(result.data);
|
|
341
|
+
return [3 /*break*/, 2];
|
|
342
|
+
case 4: return [2 /*return*/, datas.map(function (data) { return data.objectId; })];
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
exports.getStrategyIds = getStrategyIds;
|
|
@@ -302,16 +302,3 @@ function getExpLeaderBoard(startTimestamp, endTimestamp) {
|
|
|
302
302
|
});
|
|
303
303
|
}
|
|
304
304
|
exports.getExpLeaderBoard = getExpLeaderBoard;
|
|
305
|
-
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
306
|
-
var _a, _b;
|
|
307
|
-
return __generator(this, function (_c) {
|
|
308
|
-
switch (_c.label) {
|
|
309
|
-
case 0:
|
|
310
|
-
_b = (_a = console).log;
|
|
311
|
-
return [4 /*yield*/, getExpLeaderBoard("1707721200", "1708326000")];
|
|
312
|
-
case 1:
|
|
313
|
-
_b.apply(_a, [_c.sent()]);
|
|
314
|
-
return [2 /*return*/];
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
}); })();
|
package/lib/utils/price.js
CHANGED
|
@@ -80,19 +80,27 @@ function getPairPrices(pair, startTs, endTs) {
|
|
|
80
80
|
exports.getPairPrices = getPairPrices;
|
|
81
81
|
function getLatestPrice(pair) {
|
|
82
82
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
|
-
var currentTimestampInSeconds, minuteAgo, res;
|
|
83
|
+
var currentTimestampInSeconds, minuteAgo, res, e_1;
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
85
|
switch (_a.label) {
|
|
86
86
|
case 0:
|
|
87
87
|
currentTimestampInSeconds = Math.floor(new Date().getTime() / 1000);
|
|
88
88
|
minuteAgo = currentTimestampInSeconds - 60;
|
|
89
|
-
|
|
89
|
+
_a.label = 1;
|
|
90
90
|
case 1:
|
|
91
|
+
_a.trys.push([1, 3, , 4]);
|
|
92
|
+
return [4 /*yield*/, getPairPrices(pair, minuteAgo.toString(), currentTimestampInSeconds.toString())];
|
|
93
|
+
case 2:
|
|
91
94
|
res = _a.sent();
|
|
92
95
|
if (res.at(-1)) {
|
|
93
96
|
return [2 /*return*/, res.at(-1).price];
|
|
94
97
|
}
|
|
98
|
+
return [3 /*break*/, 4];
|
|
99
|
+
case 3:
|
|
100
|
+
e_1 = _a.sent();
|
|
101
|
+
console.log(e_1);
|
|
95
102
|
return [2 /*return*/, "0"];
|
|
103
|
+
case 4: return [2 /*return*/, "0"];
|
|
96
104
|
}
|
|
97
105
|
});
|
|
98
106
|
});
|
|
@@ -130,8 +138,8 @@ function getPythLatestPrice() {
|
|
|
130
138
|
exports.getPythLatestPrice = getPythLatestPrice;
|
|
131
139
|
function getLatestPriceUSD() {
|
|
132
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
133
|
-
var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price,
|
|
134
|
-
var
|
|
141
|
+
var prices, _a, _b, pair, currentTimestampInSeconds, minuteAgo, res, price, e_2_1;
|
|
142
|
+
var e_2, _c;
|
|
135
143
|
return __generator(this, function (_d) {
|
|
136
144
|
switch (_d.label) {
|
|
137
145
|
case 0: return [4 /*yield*/, getPythLatestPrice()];
|
|
@@ -158,14 +166,14 @@ function getLatestPriceUSD() {
|
|
|
158
166
|
return [3 /*break*/, 3];
|
|
159
167
|
case 6: return [3 /*break*/, 9];
|
|
160
168
|
case 7:
|
|
161
|
-
|
|
162
|
-
|
|
169
|
+
e_2_1 = _d.sent();
|
|
170
|
+
e_2 = { error: e_2_1 };
|
|
163
171
|
return [3 /*break*/, 9];
|
|
164
172
|
case 8:
|
|
165
173
|
try {
|
|
166
174
|
if (_b && !_b.done && (_c = _a.return)) _c.call(_a);
|
|
167
175
|
}
|
|
168
|
-
finally { if (
|
|
176
|
+
finally { if (e_2) throw e_2.error; }
|
|
169
177
|
return [7 /*endfinally*/];
|
|
170
178
|
case 9: return [2 /*return*/, prices];
|
|
171
179
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { TxHistory } from "../../utils/typus-dov-single-v2/user-history";
|
|
2
|
+
export declare function getDepositorCashFlows(userHistory: TxHistory[]): Promise<Map<string, DepositorCashFlow>>;
|
|
3
|
+
interface DepositorCashFlow {
|
|
4
|
+
D_TOKEN: string | undefined;
|
|
5
|
+
totalDeposit: number;
|
|
6
|
+
totalWithdraw: number;
|
|
7
|
+
totalClaim: number;
|
|
8
|
+
totalCompound: number;
|
|
9
|
+
netDeposit: number | undefined;
|
|
10
|
+
totalHarvest: Map<string, number>;
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __values = (this && this.__values) || function(o) {
|
|
39
|
+
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
40
|
+
if (m) return m.call(o);
|
|
41
|
+
if (o && typeof o.length === "number") return {
|
|
42
|
+
next: function () {
|
|
43
|
+
if (o && i >= o.length) o = void 0;
|
|
44
|
+
return { value: o && o[i++], done: !o };
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
48
|
+
};
|
|
49
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
+
if (!m) return o;
|
|
52
|
+
var i = m.call(o), r, ar = [], e;
|
|
53
|
+
try {
|
|
54
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
+
}
|
|
56
|
+
catch (error) { e = { error: error }; }
|
|
57
|
+
finally {
|
|
58
|
+
try {
|
|
59
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
+
}
|
|
61
|
+
finally { if (e) throw e.error; }
|
|
62
|
+
}
|
|
63
|
+
return ar;
|
|
64
|
+
};
|
|
65
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
+
exports.getDepositorCashFlows = void 0;
|
|
67
|
+
function getDepositorCashFlows(userHistory) {
|
|
68
|
+
var _a, _b, _c, _d, _e;
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var depositorCashFlows, userHistory_1, userHistory_1_1, history_1, index, _f, amount, token, depositorCashFlow, totalHarvest, sum, totalHarvest, depositorCashFlow, _g, amount, token, depositorCashFlow, depositorCashFlow, _h, amount, token, depositorCashFlow, depositorCashFlow, _j, amount, token, depositorCashFlow, depositorCashFlow, _k, amount, token, depositorCashFlow, depositorCashFlow, _l, _m, _o, index, share;
|
|
71
|
+
var e_1, _p, e_2, _q;
|
|
72
|
+
return __generator(this, function (_r) {
|
|
73
|
+
depositorCashFlows = new Map();
|
|
74
|
+
try {
|
|
75
|
+
for (userHistory_1 = __values(userHistory), userHistory_1_1 = userHistory_1.next(); !userHistory_1_1.done; userHistory_1_1 = userHistory_1.next()) {
|
|
76
|
+
history_1 = userHistory_1_1.value;
|
|
77
|
+
index = history_1.Index;
|
|
78
|
+
if (history_1.Action.startsWith("Harvest")) {
|
|
79
|
+
_f = __read((_a = history_1.Amount) === null || _a === void 0 ? void 0 : _a.split(" "), 2), amount = _f[0], token = _f[1];
|
|
80
|
+
if (depositorCashFlows.has(index)) {
|
|
81
|
+
depositorCashFlow = depositorCashFlows.get(index);
|
|
82
|
+
totalHarvest = depositorCashFlow.totalHarvest;
|
|
83
|
+
if (totalHarvest.has(token)) {
|
|
84
|
+
sum = totalHarvest.get(token);
|
|
85
|
+
totalHarvest.set(token, sum + Number(amount));
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
totalHarvest.set(token, Number(amount));
|
|
89
|
+
}
|
|
90
|
+
depositorCashFlow.totalHarvest = totalHarvest;
|
|
91
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
totalHarvest = new Map();
|
|
95
|
+
totalHarvest.set(token, Number(amount));
|
|
96
|
+
depositorCashFlow = {
|
|
97
|
+
D_TOKEN: undefined,
|
|
98
|
+
totalDeposit: 0,
|
|
99
|
+
totalWithdraw: 0,
|
|
100
|
+
totalClaim: 0,
|
|
101
|
+
totalCompound: 0,
|
|
102
|
+
netDeposit: undefined,
|
|
103
|
+
totalHarvest: totalHarvest,
|
|
104
|
+
};
|
|
105
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
else if (history_1.Action.startsWith("Deposit")) {
|
|
109
|
+
_g = __read((_b = history_1.Amount) === null || _b === void 0 ? void 0 : _b.split(" "), 2), amount = _g[0], token = _g[1];
|
|
110
|
+
if (depositorCashFlows.has(index)) {
|
|
111
|
+
depositorCashFlow = depositorCashFlows.get(index);
|
|
112
|
+
depositorCashFlow.D_TOKEN = token;
|
|
113
|
+
depositorCashFlow.totalDeposit += Number(amount);
|
|
114
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
depositorCashFlow = {
|
|
118
|
+
D_TOKEN: token,
|
|
119
|
+
totalDeposit: Number(amount),
|
|
120
|
+
totalWithdraw: 0,
|
|
121
|
+
totalClaim: 0,
|
|
122
|
+
totalCompound: 0,
|
|
123
|
+
netDeposit: undefined,
|
|
124
|
+
totalHarvest: new Map(),
|
|
125
|
+
};
|
|
126
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else if (history_1.Action.startsWith("Withdraw")) {
|
|
130
|
+
_h = __read((_c = history_1.Amount) === null || _c === void 0 ? void 0 : _c.split(" "), 2), amount = _h[0], token = _h[1];
|
|
131
|
+
if (depositorCashFlows.has(index)) {
|
|
132
|
+
depositorCashFlow = depositorCashFlows.get(index);
|
|
133
|
+
depositorCashFlow.D_TOKEN = token;
|
|
134
|
+
depositorCashFlow.totalWithdraw += Number(amount);
|
|
135
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
depositorCashFlow = {
|
|
139
|
+
D_TOKEN: token,
|
|
140
|
+
totalDeposit: 0,
|
|
141
|
+
totalWithdraw: Number(amount),
|
|
142
|
+
totalClaim: 0,
|
|
143
|
+
totalCompound: 0,
|
|
144
|
+
netDeposit: undefined,
|
|
145
|
+
totalHarvest: new Map(),
|
|
146
|
+
};
|
|
147
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
else if (history_1.Action == "Claim") {
|
|
151
|
+
_j = __read((_d = history_1.Amount) === null || _d === void 0 ? void 0 : _d.split(" "), 2), amount = _j[0], token = _j[1];
|
|
152
|
+
if (depositorCashFlows.has(index)) {
|
|
153
|
+
depositorCashFlow = depositorCashFlows.get(index);
|
|
154
|
+
depositorCashFlow.D_TOKEN = token;
|
|
155
|
+
depositorCashFlow.totalClaim += Number(amount);
|
|
156
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
depositorCashFlow = {
|
|
160
|
+
D_TOKEN: token,
|
|
161
|
+
totalDeposit: 0,
|
|
162
|
+
totalWithdraw: 0,
|
|
163
|
+
totalClaim: Number(amount),
|
|
164
|
+
totalCompound: 0,
|
|
165
|
+
netDeposit: undefined,
|
|
166
|
+
totalHarvest: new Map(),
|
|
167
|
+
};
|
|
168
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else if (history_1.Action == "Compound") {
|
|
172
|
+
_k = __read((_e = history_1.Amount) === null || _e === void 0 ? void 0 : _e.split(" "), 2), amount = _k[0], token = _k[1];
|
|
173
|
+
if (depositorCashFlows.has(index)) {
|
|
174
|
+
depositorCashFlow = depositorCashFlows.get(index);
|
|
175
|
+
depositorCashFlow.D_TOKEN = token;
|
|
176
|
+
depositorCashFlow.totalCompound += Number(amount);
|
|
177
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
depositorCashFlow = {
|
|
181
|
+
D_TOKEN: token,
|
|
182
|
+
totalDeposit: 0,
|
|
183
|
+
totalWithdraw: 0,
|
|
184
|
+
totalClaim: 0,
|
|
185
|
+
totalCompound: Number(amount),
|
|
186
|
+
netDeposit: undefined,
|
|
187
|
+
totalHarvest: new Map(),
|
|
188
|
+
};
|
|
189
|
+
depositorCashFlows.set(index, depositorCashFlow);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
195
|
+
finally {
|
|
196
|
+
try {
|
|
197
|
+
if (userHistory_1_1 && !userHistory_1_1.done && (_p = userHistory_1.return)) _p.call(userHistory_1);
|
|
198
|
+
}
|
|
199
|
+
finally { if (e_1) throw e_1.error; }
|
|
200
|
+
}
|
|
201
|
+
try {
|
|
202
|
+
// console.log(depositorCashFlows);
|
|
203
|
+
for (_l = __values(depositorCashFlows.entries()), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
204
|
+
_o = __read(_m.value, 2), index = _o[0], share = _o[1];
|
|
205
|
+
share.netDeposit = share.totalDeposit + share.totalCompound - share.totalWithdraw - share.totalClaim;
|
|
206
|
+
depositorCashFlows.set(index, share);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
210
|
+
finally {
|
|
211
|
+
try {
|
|
212
|
+
if (_m && !_m.done && (_q = _l.return)) _q.call(_l);
|
|
213
|
+
}
|
|
214
|
+
finally { if (e_2) throw e_2.error; }
|
|
215
|
+
}
|
|
216
|
+
return [2 /*return*/, depositorCashFlows];
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
exports.getDepositorCashFlows = getDepositorCashFlows;
|