@gearbox-protocol/sdk 1.15.17 → 1.15.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.
|
@@ -52,9 +52,9 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
52
52
|
*/
|
|
53
53
|
CreditAccountWatcher.getOpenAccounts = function (creditManager, provider, toBlock) {
|
|
54
54
|
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var eventsByDate, addToEvents, accounts, creditConfigurator, cc, cfUpgraded, _i, cfUpgraded_1, creditFacade
|
|
56
|
-
return __generator(this, function (
|
|
57
|
-
switch (
|
|
55
|
+
var eventsByDate, addToEvents, accounts, creditConfigurator, cc, cfUpgraded, _loop_1, _i, cfUpgraded_1, creditFacade;
|
|
56
|
+
return __generator(this, function (_a) {
|
|
57
|
+
switch (_a.label) {
|
|
58
58
|
case 0:
|
|
59
59
|
if (creditManager.version !== 2)
|
|
60
60
|
throw new Error("Works for V2 only");
|
|
@@ -71,59 +71,60 @@ var CreditAccountWatcher = /** @class */ (function () {
|
|
|
71
71
|
cc = types_1.ICreditConfigurator__factory.connect(creditConfigurator, provider);
|
|
72
72
|
return [4 /*yield*/, cc.queryFilter(cc.filters.CreditFacadeUpgraded(), undefined, toBlock)];
|
|
73
73
|
case 1:
|
|
74
|
-
cfUpgraded = (
|
|
74
|
+
cfUpgraded = (_a.sent()).map(function (e) { return e.args.newCreditFacade; });
|
|
75
|
+
_loop_1 = function (creditFacade) {
|
|
76
|
+
var cf, topics, logs;
|
|
77
|
+
return __generator(this, function (_b) {
|
|
78
|
+
switch (_b.label) {
|
|
79
|
+
case 0:
|
|
80
|
+
cf = types_1.ICreditFacade__factory.connect(creditFacade, provider);
|
|
81
|
+
topics = {
|
|
82
|
+
OpenCreditAccount: cf.interface.getEventTopic("OpenCreditAccount"),
|
|
83
|
+
CloseCreditAccount: cf.interface.getEventTopic("CloseCreditAccount"),
|
|
84
|
+
LiquidateCreditAccount: cf.interface.getEventTopic("LiquidateCreditAccount"),
|
|
85
|
+
LiquidateExpiredCreditAccount: cf.interface.getEventTopic("LiquidateExpiredCreditAccount"),
|
|
86
|
+
TransferAccount: cf.interface.getEventTopic("TransferAccount"),
|
|
87
|
+
};
|
|
88
|
+
return [4 /*yield*/, cf.queryFilter({
|
|
89
|
+
address: cf.address,
|
|
90
|
+
topics: [Object.values(topics)],
|
|
91
|
+
}, undefined, toBlock)];
|
|
92
|
+
case 1:
|
|
93
|
+
logs = _b.sent();
|
|
94
|
+
logs.forEach(function (log) {
|
|
95
|
+
var e = cf.interface.parseLog(log);
|
|
96
|
+
switch (log.topics[0]) {
|
|
97
|
+
case topics.OpenCreditAccount:
|
|
98
|
+
addToEvents(log, e.args.onBehalfOf, "add");
|
|
99
|
+
break;
|
|
100
|
+
case topics.CloseCreditAccount:
|
|
101
|
+
case topics.LiquidateCreditAccount:
|
|
102
|
+
case topics.LiquidateExpiredCreditAccount:
|
|
103
|
+
addToEvents(log, e.args.borrower, "delete");
|
|
104
|
+
break;
|
|
105
|
+
case topics.TransferAccount:
|
|
106
|
+
addToEvents(log, e.args.oldOwner, "delete");
|
|
107
|
+
addToEvents(log, log.args.newOwner, "add");
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
return [2 /*return*/];
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
75
115
|
_i = 0, cfUpgraded_1 = cfUpgraded;
|
|
76
|
-
|
|
116
|
+
_a.label = 2;
|
|
77
117
|
case 2:
|
|
78
|
-
if (!(_i < cfUpgraded_1.length)) return [3 /*break*/,
|
|
118
|
+
if (!(_i < cfUpgraded_1.length)) return [3 /*break*/, 5];
|
|
79
119
|
creditFacade = cfUpgraded_1[_i];
|
|
80
|
-
|
|
81
|
-
return [4 /*yield*/, cf.queryFilter(cf.filters.OpenCreditAccount(), undefined, toBlock)];
|
|
120
|
+
return [5 /*yield**/, _loop_1(creditFacade)];
|
|
82
121
|
case 3:
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
];
|
|
86
|
-
return [4 /*yield*/, cf.queryFilter(cf.filters.CloseCreditAccount(), undefined, toBlock)];
|
|
122
|
+
_a.sent();
|
|
123
|
+
_a.label = 4;
|
|
87
124
|
case 4:
|
|
88
|
-
_b = _b.concat([
|
|
89
|
-
_c.sent()
|
|
90
|
-
]);
|
|
91
|
-
return [4 /*yield*/, cf.queryFilter(cf.filters.LiquidateCreditAccount(), undefined, toBlock)];
|
|
92
|
-
case 5:
|
|
93
|
-
_b = _b.concat([
|
|
94
|
-
_c.sent()
|
|
95
|
-
]);
|
|
96
|
-
return [4 /*yield*/, cf.queryFilter(cf.filters.LiquidateExpiredCreditAccount(), undefined, toBlock)];
|
|
97
|
-
case 6:
|
|
98
|
-
_b = _b.concat([
|
|
99
|
-
_c.sent()
|
|
100
|
-
]);
|
|
101
|
-
return [4 /*yield*/, cf.queryFilter(cf.filters.TransferAccount(), undefined, toBlock)];
|
|
102
|
-
case 7:
|
|
103
|
-
_a = _b.concat([
|
|
104
|
-
_c.sent()
|
|
105
|
-
]), openEvents = _a[0], closeEvents = _a[1], liquidateEvents = _a[2], liquidateExpiredEvents = _a[3], transferEvents = _a[4];
|
|
106
|
-
openEvents.forEach(function (e) {
|
|
107
|
-
addToEvents(e, e.args.onBehalfOf, "add");
|
|
108
|
-
});
|
|
109
|
-
closeEvents.forEach(function (e) {
|
|
110
|
-
addToEvents(e, e.args.borrower, "delete");
|
|
111
|
-
});
|
|
112
|
-
liquidateEvents.forEach(function (e) {
|
|
113
|
-
addToEvents(e, e.args.borrower, "delete");
|
|
114
|
-
});
|
|
115
|
-
liquidateExpiredEvents.forEach(function (e) {
|
|
116
|
-
addToEvents(e, e.args.borrower, "delete");
|
|
117
|
-
});
|
|
118
|
-
transferEvents.forEach(function (e) {
|
|
119
|
-
addToEvents(e, e.args.oldOwner, "delete");
|
|
120
|
-
addToEvents(e, e.args.newOwner, "add");
|
|
121
|
-
});
|
|
122
|
-
_c.label = 8;
|
|
123
|
-
case 8:
|
|
124
125
|
_i++;
|
|
125
126
|
return [3 /*break*/, 2];
|
|
126
|
-
case
|
|
127
|
+
case 5:
|
|
127
128
|
eventsByDate
|
|
128
129
|
.sort(function (a, b) {
|
|
129
130
|
return a.time > b.time ? 1 : -1;
|