@gearbox-protocol/sdk 12.3.1 → 12.3.2
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.
|
@@ -212,9 +212,9 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
212
212
|
* @returns call result of getConnectedBots for each credit account
|
|
213
213
|
*/
|
|
214
214
|
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
const allResp = await this.client.multicall({
|
|
216
|
+
contracts: [
|
|
217
|
+
...accountsToCheck.map((o) => {
|
|
218
218
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
219
219
|
o.creditManager
|
|
220
220
|
);
|
|
@@ -225,32 +225,71 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
225
225
|
args: [pool.configurator.address, o.creditAccount]
|
|
226
226
|
};
|
|
227
227
|
}),
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
]);
|
|
233
|
-
return {
|
|
234
|
-
legacy: resp,
|
|
235
|
-
additionalBots: additional,
|
|
236
|
-
legacyMigration: migration
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
async getActiveBots(accountsToCheck, bots) {
|
|
240
|
-
const result = await this.client.multicall({
|
|
241
|
-
contracts: accountsToCheck.flatMap((ca) => {
|
|
242
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
243
|
-
return bots.map((bot) => {
|
|
228
|
+
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
229
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
230
|
+
ca.creditManager
|
|
231
|
+
);
|
|
244
232
|
return {
|
|
245
233
|
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
234
|
address: cm.creditFacade.botList,
|
|
247
235
|
functionName: "getBotStatus",
|
|
248
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [
|
|
236
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
|
|
249
237
|
};
|
|
250
|
-
})
|
|
251
|
-
|
|
238
|
+
}) : [],
|
|
239
|
+
...accountsToCheck.flatMap((ca) => {
|
|
240
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
241
|
+
ca.creditManager
|
|
242
|
+
);
|
|
243
|
+
return additionalBots.map((bot) => {
|
|
244
|
+
return {
|
|
245
|
+
abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
|
|
246
|
+
address: cm.creditFacade.botList,
|
|
247
|
+
functionName: "getBotStatus",
|
|
248
|
+
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
249
|
+
};
|
|
250
|
+
});
|
|
251
|
+
})
|
|
252
|
+
],
|
|
252
253
|
allowFailure: true
|
|
253
254
|
});
|
|
255
|
+
const legacyStart = 0;
|
|
256
|
+
const legacyEnd = accountsToCheck.length;
|
|
257
|
+
const legacy = allResp.slice(
|
|
258
|
+
legacyStart,
|
|
259
|
+
legacyEnd
|
|
260
|
+
);
|
|
261
|
+
const migrationStart = legacyEnd;
|
|
262
|
+
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
263
|
+
const migrationResp = allResp.slice(
|
|
264
|
+
migrationStart,
|
|
265
|
+
migrationEnd
|
|
266
|
+
);
|
|
267
|
+
const additionalStart = migrationEnd;
|
|
268
|
+
const additionalResp = allResp.slice(
|
|
269
|
+
additionalStart
|
|
270
|
+
);
|
|
271
|
+
return {
|
|
272
|
+
legacy,
|
|
273
|
+
additionalBots: this.getActiveBots(
|
|
274
|
+
accountsToCheck,
|
|
275
|
+
additionalBots,
|
|
276
|
+
additionalResp
|
|
277
|
+
),
|
|
278
|
+
legacyMigration: this.getActiveMigrationBots(
|
|
279
|
+
accountsToCheck,
|
|
280
|
+
legacyMigrationBot,
|
|
281
|
+
migrationResp
|
|
282
|
+
)
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
getActiveBots(accountsToCheck, bots, result) {
|
|
286
|
+
if (result.length !== bots.length * accountsToCheck.length) {
|
|
287
|
+
console.error(
|
|
288
|
+
"result length mismatch",
|
|
289
|
+
result.length,
|
|
290
|
+
bots.length * accountsToCheck.length
|
|
291
|
+
);
|
|
292
|
+
}
|
|
254
293
|
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
255
294
|
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
256
295
|
acc.push({
|
|
@@ -260,22 +299,15 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
260
299
|
}, []);
|
|
261
300
|
return botsByCAIndex;
|
|
262
301
|
}
|
|
263
|
-
|
|
302
|
+
getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
264
303
|
if (bot) {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
address: cm.creditFacade.botList,
|
|
273
|
-
functionName: "getBotStatus",
|
|
274
|
-
args: (0, import_constants.isV300)(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
275
|
-
};
|
|
276
|
-
}),
|
|
277
|
-
allowFailure: true
|
|
278
|
-
});
|
|
304
|
+
if (result.length !== accountsToCheck.length) {
|
|
305
|
+
console.error(
|
|
306
|
+
"result length mismatch for migration bots",
|
|
307
|
+
result.length,
|
|
308
|
+
accountsToCheck.length
|
|
309
|
+
);
|
|
310
|
+
}
|
|
279
311
|
return { result, botAddress: bot };
|
|
280
312
|
}
|
|
281
313
|
return void 0;
|
|
@@ -202,9 +202,9 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
202
202
|
* @returns call result of getConnectedBots for each credit account
|
|
203
203
|
*/
|
|
204
204
|
async getConnectedBots(accountsToCheck, legacyMigrationBot, additionalBots) {
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
205
|
+
const allResp = await this.client.multicall({
|
|
206
|
+
contracts: [
|
|
207
|
+
...accountsToCheck.map((o) => {
|
|
208
208
|
const pool = this.sdk.marketRegister.findByCreditManager(
|
|
209
209
|
o.creditManager
|
|
210
210
|
);
|
|
@@ -215,32 +215,71 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
215
215
|
args: [pool.configurator.address, o.creditAccount]
|
|
216
216
|
};
|
|
217
217
|
}),
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
]);
|
|
223
|
-
return {
|
|
224
|
-
legacy: resp,
|
|
225
|
-
additionalBots: additional,
|
|
226
|
-
legacyMigration: migration
|
|
227
|
-
};
|
|
228
|
-
}
|
|
229
|
-
async getActiveBots(accountsToCheck, bots) {
|
|
230
|
-
const result = await this.client.multicall({
|
|
231
|
-
contracts: accountsToCheck.flatMap((ca) => {
|
|
232
|
-
const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
|
|
233
|
-
return bots.map((bot) => {
|
|
218
|
+
...legacyMigrationBot ? accountsToCheck.map((ca) => {
|
|
219
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
220
|
+
ca.creditManager
|
|
221
|
+
);
|
|
234
222
|
return {
|
|
235
223
|
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
236
224
|
address: cm.creditFacade.botList,
|
|
237
225
|
functionName: "getBotStatus",
|
|
238
|
-
args: isV300(cm.creditFacade.version) ? [
|
|
226
|
+
args: isV300(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
|
|
239
227
|
};
|
|
240
|
-
})
|
|
241
|
-
|
|
228
|
+
}) : [],
|
|
229
|
+
...accountsToCheck.flatMap((ca) => {
|
|
230
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
231
|
+
ca.creditManager
|
|
232
|
+
);
|
|
233
|
+
return additionalBots.map((bot) => {
|
|
234
|
+
return {
|
|
235
|
+
abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
|
|
236
|
+
address: cm.creditFacade.botList,
|
|
237
|
+
functionName: "getBotStatus",
|
|
238
|
+
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
239
|
+
};
|
|
240
|
+
});
|
|
241
|
+
})
|
|
242
|
+
],
|
|
242
243
|
allowFailure: true
|
|
243
244
|
});
|
|
245
|
+
const legacyStart = 0;
|
|
246
|
+
const legacyEnd = accountsToCheck.length;
|
|
247
|
+
const legacy = allResp.slice(
|
|
248
|
+
legacyStart,
|
|
249
|
+
legacyEnd
|
|
250
|
+
);
|
|
251
|
+
const migrationStart = legacyEnd;
|
|
252
|
+
const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
|
|
253
|
+
const migrationResp = allResp.slice(
|
|
254
|
+
migrationStart,
|
|
255
|
+
migrationEnd
|
|
256
|
+
);
|
|
257
|
+
const additionalStart = migrationEnd;
|
|
258
|
+
const additionalResp = allResp.slice(
|
|
259
|
+
additionalStart
|
|
260
|
+
);
|
|
261
|
+
return {
|
|
262
|
+
legacy,
|
|
263
|
+
additionalBots: this.getActiveBots(
|
|
264
|
+
accountsToCheck,
|
|
265
|
+
additionalBots,
|
|
266
|
+
additionalResp
|
|
267
|
+
),
|
|
268
|
+
legacyMigration: this.getActiveMigrationBots(
|
|
269
|
+
accountsToCheck,
|
|
270
|
+
legacyMigrationBot,
|
|
271
|
+
migrationResp
|
|
272
|
+
)
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
getActiveBots(accountsToCheck, bots, result) {
|
|
276
|
+
if (result.length !== bots.length * accountsToCheck.length) {
|
|
277
|
+
console.error(
|
|
278
|
+
"result length mismatch",
|
|
279
|
+
result.length,
|
|
280
|
+
bots.length * accountsToCheck.length
|
|
281
|
+
);
|
|
282
|
+
}
|
|
244
283
|
const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
|
|
245
284
|
const r = result.slice(index * bots.length, (index + 1) * bots.length);
|
|
246
285
|
acc.push({
|
|
@@ -250,22 +289,15 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
250
289
|
}, []);
|
|
251
290
|
return botsByCAIndex;
|
|
252
291
|
}
|
|
253
|
-
|
|
292
|
+
getActiveMigrationBots(accountsToCheck, bot, result) {
|
|
254
293
|
if (bot) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
address: cm.creditFacade.botList,
|
|
263
|
-
functionName: "getBotStatus",
|
|
264
|
-
args: isV300(cm.creditFacade.version) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
|
|
265
|
-
};
|
|
266
|
-
}),
|
|
267
|
-
allowFailure: true
|
|
268
|
-
});
|
|
294
|
+
if (result.length !== accountsToCheck.length) {
|
|
295
|
+
console.error(
|
|
296
|
+
"result length mismatch for migration bots",
|
|
297
|
+
result.length,
|
|
298
|
+
accountsToCheck.length
|
|
299
|
+
);
|
|
300
|
+
}
|
|
269
301
|
return { result, botAddress: bot };
|
|
270
302
|
}
|
|
271
303
|
return void 0;
|