@gearbox-protocol/sdk 11.11.0 → 11.11.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.
Files changed (30) hide show
  1. package/dist/cjs/plugins/bots/BotsPlugin.js +5 -2
  2. package/dist/cjs/plugins/bots/config.js +23 -2
  3. package/dist/cjs/plugins/bots/types.js +5 -2
  4. package/dist/cjs/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +0 -21
  5. package/dist/cjs/sdk/accountMigration/types.js +0 -12
  6. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +6 -10
  7. package/dist/cjs/sdk/accounts/CreditAccountsServiceV310.js +2 -4
  8. package/dist/cjs/sdk/accounts/index.js +0 -2
  9. package/dist/esm/plugins/bots/BotsPlugin.js +7 -2
  10. package/dist/esm/plugins/bots/config.js +20 -1
  11. package/dist/esm/plugins/bots/types.js +3 -1
  12. package/dist/esm/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +0 -21
  13. package/dist/esm/sdk/accountMigration/types.js +0 -4
  14. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +6 -10
  15. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -4
  16. package/dist/esm/sdk/accounts/index.js +0 -1
  17. package/dist/types/plugins/bots/BotsPlugin.d.ts +2 -1
  18. package/dist/types/plugins/bots/config.d.ts +4 -2
  19. package/dist/types/plugins/bots/types.d.ts +9 -0
  20. package/dist/types/sdk/accountMigration/AbstractMigrateCreditAccountsService.d.ts +1 -8
  21. package/dist/types/sdk/accountMigration/types.d.ts +0 -11
  22. package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +1 -1
  23. package/dist/types/sdk/accounts/CreditAccountsServiceV310.d.ts +1 -1
  24. package/dist/types/sdk/accounts/index.d.ts +0 -1
  25. package/dist/types/sdk/accounts/types.d.ts +6 -26
  26. package/dist/types/sdk/sdk-legacy/core/creditAccount.d.ts +0 -10
  27. package/package.json +1 -1
  28. package/dist/cjs/sdk/accounts/constants.js +0 -36
  29. package/dist/esm/sdk/accounts/constants.js +0 -12
  30. package/dist/types/sdk/accounts/constants.d.ts +0 -2
@@ -116,11 +116,11 @@ class BotsPlugin extends import_sdk.BasePlugin {
116
116
  if (b.status === "success") {
117
117
  expectedBots.upsert(b.result, { ...configs[i], treasury });
118
118
  this.logger?.debug(
119
- `found bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`
119
+ `expected bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`
120
120
  );
121
121
  } else {
122
122
  this.logger?.error(
123
- `failed to find bot [${minHealthFactor}, ${maxHealthFactor}]`,
123
+ `failed compute address for bot [${minHealthFactor}, ${maxHealthFactor}]`,
124
124
  b.error
125
125
  );
126
126
  }
@@ -225,6 +225,9 @@ class BotsPlugin extends import_sdk.BasePlugin {
225
225
  throw new Error(`unsupported bot version: ${v}`);
226
226
  }
227
227
  }
228
+ static getMigrationBotData(chainId) {
229
+ return chainId === import_sdk.chains.Mainnet.id ? import_config.LEGACY_MIGRATION_BOT : void 0;
230
+ }
228
231
  }
229
232
  // Annotate the CommonJS export names for ESM import in node:
230
233
  0 && (module.exports = {
@@ -18,11 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var config_exports = {};
20
20
  __export(config_exports, {
21
+ LEGACY_MIGRATION_BOT: () => LEGACY_MIGRATION_BOT,
21
22
  PARTIAL_LIQUIDATION_BOT_CONFIGS: () => PARTIAL_LIQUIDATION_BOT_CONFIGS,
22
23
  PARTIAL_LIQUIDATION_BOT_DEPLOYER: () => PARTIAL_LIQUIDATION_BOT_DEPLOYER,
23
- PARTIAL_LIQUIDATION_BOT_SALT: () => PARTIAL_LIQUIDATION_BOT_SALT
24
+ PARTIAL_LIQUIDATION_BOT_SALT: () => PARTIAL_LIQUIDATION_BOT_SALT,
25
+ PERMISSION_BY_TYPE: () => PERMISSION_BY_TYPE
24
26
  });
25
27
  module.exports = __toCommonJS(config_exports);
28
+ var import_sdk = require("../../sdk/index.js");
26
29
  const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
27
30
  Mainnet: [
28
31
  {
@@ -51,9 +54,27 @@ const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
51
54
  };
52
55
  const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
53
56
  const PARTIAL_LIQUIDATION_BOT_DEPLOYER = "0xc93155E0a835Cf4E17a19463Fa67ed43c164d06a";
57
+ const ACCOUNT_MIGRATOR_BOT = "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase();
58
+ const ACCOUNT_MIGRATOR_PREVIEWER = "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase();
59
+ const LEGACY_MIGRATION_BOT = {
60
+ address: ACCOUNT_MIGRATOR_BOT,
61
+ previewer: ACCOUNT_MIGRATOR_PREVIEWER,
62
+ version: 310,
63
+ botType: "MIGRATION_BOT"
64
+ };
65
+ const PERMISSION_BY_TYPE = {
66
+ LIQUIDATION_PROTECTION: BigInt(
67
+ import_sdk.BotPermissions.ADD_COLLATERAL | import_sdk.BotPermissions.WITHDRAW_COLLATERAL | import_sdk.BotPermissions.DECREASE_DEBT
68
+ ),
69
+ MIGRATION: BigInt(
70
+ import_sdk.BotPermissions.EXTERNAL_CALLS | import_sdk.BotPermissions.UPDATE_QUOTA | import_sdk.BotPermissions.DECREASE_DEBT
71
+ )
72
+ };
54
73
  // Annotate the CommonJS export names for ESM import in node:
55
74
  0 && (module.exports = {
75
+ LEGACY_MIGRATION_BOT,
56
76
  PARTIAL_LIQUIDATION_BOT_CONFIGS,
57
77
  PARTIAL_LIQUIDATION_BOT_DEPLOYER,
58
- PARTIAL_LIQUIDATION_BOT_SALT
78
+ PARTIAL_LIQUIDATION_BOT_SALT,
79
+ PERMISSION_BY_TYPE
59
80
  });
@@ -19,7 +19,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
19
19
  var types_exports = {};
20
20
  __export(types_exports, {
21
21
  BOT_PARAMS_ABI: () => BOT_PARAMS_ABI,
22
- LIQUIDATION_BOT_TYPES: () => LIQUIDATION_BOT_TYPES
22
+ LIQUIDATION_BOT_TYPES: () => LIQUIDATION_BOT_TYPES,
23
+ MIGRATION_BOT_TYPES: () => MIGRATION_BOT_TYPES
23
24
  });
24
25
  module.exports = __toCommonJS(types_exports);
25
26
  const BOT_PARAMS_ABI = [
@@ -35,8 +36,10 @@ const LIQUIDATION_BOT_TYPES = [
35
36
  "DELEVERAGE_BOT_LV",
36
37
  "DELEVERAGE_BOT_HV"
37
38
  ];
39
+ const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
38
40
  // Annotate the CommonJS export names for ESM import in node:
39
41
  0 && (module.exports = {
40
42
  BOT_PARAMS_ABI,
41
- LIQUIDATION_BOT_TYPES
43
+ LIQUIDATION_BOT_TYPES,
44
+ MIGRATION_BOT_TYPES
42
45
  });
@@ -43,10 +43,6 @@ class AbstractMigrateCreditAccountsService extends import_base.SDKConstruct {
43
43
  ["0xcB5D10A57Aeb622b92784D53F730eE2210ab370E".toLowerCase()]: "0x00F7C0d39B05089e93858A82439EA17dE7160B5a".toLowerCase()
44
44
  }
45
45
  };
46
- // TODO: HARDCODED
47
- static accountMigratorBot = "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase();
48
- // TODO: HARDCODED
49
- static accountMigratorPreviewer = "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase();
50
46
  constructor(sdk, version) {
51
47
  super(sdk);
52
48
  this.#version = version;
@@ -127,23 +123,6 @@ class AbstractMigrateCreditAccountsService extends import_base.SDKConstruct {
127
123
  static getV310TargetTokenAddress(source, chainId) {
128
124
  return AbstractMigrateCreditAccountsService.V300_TO_V310_TOKENS_OVERRIDES[chainId]?.[source] ?? source;
129
125
  }
130
- static getMigrationBotAddress(chainId) {
131
- const botAddress = chainId === import_chains.chains.Mainnet.id ? AbstractMigrateCreditAccountsService.accountMigratorBot : void 0;
132
- const previewerAddress = chainId === import_chains.chains.Mainnet.id ? AbstractMigrateCreditAccountsService.accountMigratorPreviewer : void 0;
133
- return previewerAddress && botAddress ? { botAddress, previewerAddress } : void 0;
134
- }
135
- static getMigrationBotData(chainId) {
136
- const { botAddress } = AbstractMigrateCreditAccountsService.getMigrationBotAddress(chainId) || {};
137
- return botAddress ? {
138
- baseParams: {
139
- addr: botAddress,
140
- version: 310
141
- },
142
- address: botAddress,
143
- version: 310,
144
- botType: "MIGRATION_BOT"
145
- } : void 0;
146
- }
147
126
  static getTokensToMigrate(creditAccount) {
148
127
  const sourceTokensToMigrate = Object.values(creditAccount.tokens).filter(
149
128
  (t) => creditAccount.isTokenEnabled(t.token) && t.balance > 1n
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
6
  var __copyProps = (to, from, except, desc) => {
11
7
  if (from && typeof from === "object" || typeof from === "function") {
12
8
  for (let key of __getOwnPropNames(from))
@@ -17,12 +13,4 @@ var __copyProps = (to, from, except, desc) => {
17
13
  };
18
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
15
  var types_exports = {};
20
- __export(types_exports, {
21
- MIGRATION_BOT_TYPES: () => MIGRATION_BOT_TYPES
22
- });
23
16
  module.exports = __toCommonJS(types_exports);
24
- const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- MIGRATION_BOT_TYPES
28
- });
@@ -30,7 +30,6 @@ var import_rewardsCompressor = require("../../abi/compressors/rewardsCompressor.
30
30
  var import_IWithdrawalCompressorV310 = require("../../abi/IWithdrawalCompressorV310.js");
31
31
  var import_iBaseRewardPool = require("../../abi/iBaseRewardPool.js");
32
32
  var import_v300 = require("../../abi/v300.js");
33
- var import_AbstractMigrateCreditAccountsService = require("../accountMigration/AbstractMigrateCreditAccountsService.js");
34
33
  var import_base = require("../base/index.js");
35
34
  var import_constants = require("../constants/index.js");
36
35
  var import_router = require("../router/index.js");
@@ -210,7 +209,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
210
209
  and their credit managers to check connected bots on
211
210
  * @returns call result of getConnectedBots for each credit account
212
211
  */
213
- async getConnectedBots(accountsToCheck) {
212
+ async getConnectedBots(accountsToCheck, legacyMigrationBot) {
214
213
  const [resp, migration] = await Promise.all([
215
214
  this.client.multicall({
216
215
  contracts: accountsToCheck.map((o) => {
@@ -226,15 +225,12 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
226
225
  }),
227
226
  allowFailure: true
228
227
  }),
229
- this.getActiveMigrationBots(accountsToCheck)
228
+ this.getActiveMigrationBots(accountsToCheck, legacyMigrationBot)
230
229
  ]);
231
230
  return { legacy: resp, legacyMigration: migration };
232
231
  }
233
- async getActiveMigrationBots(accountsToCheck) {
234
- const migrationBot = import_AbstractMigrateCreditAccountsService.AbstractMigrateCreditAccountsService.getMigrationBotAddress(
235
- this.sdk.chainId
236
- );
237
- if (migrationBot) {
232
+ async getActiveMigrationBots(accountsToCheck, legacyMigrationBot) {
233
+ if (legacyMigrationBot) {
238
234
  const result = await this.client.multicall({
239
235
  contracts: accountsToCheck.map((ca) => {
240
236
  const cm = this.sdk.marketRegister.findCreditManager(
@@ -244,12 +240,12 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
244
240
  abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
245
241
  address: cm.creditFacade.botList,
246
242
  functionName: "getBotStatus",
247
- args: (0, import_constants.isV300)(cm.creditFacade.version) ? [migrationBot.botAddress, ca.creditManager, ca.creditAccount] : [migrationBot.botAddress, ca.creditAccount]
243
+ args: (0, import_constants.isV300)(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
248
244
  };
249
245
  }),
250
246
  allowFailure: true
251
247
  });
252
- return { result, migrationBot };
248
+ return { result, botAddress: legacyMigrationBot };
253
249
  }
254
250
  return void 0;
255
251
  }
@@ -25,15 +25,13 @@ var import_viem = require("viem");
25
25
  var import_generated = require("../../abi/310/generated.js");
26
26
  var import_math = require("../constants/math.js");
27
27
  var import_AbstractCreditAccountsService = require("./AbstractCreditAccountsService.js");
28
- var import_constants = require("./constants.js");
29
28
  class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.AbstractCreditAccountService {
30
29
  /**
31
30
  * Implements {@link ICreditAccountsService.setBot}
32
31
  */
33
32
  async setBot({
34
33
  botAddress,
35
- botBaseType,
36
- stopBot,
34
+ permissions,
37
35
  targetContract
38
36
  }) {
39
37
  const cm = this.sdk.marketRegister.findCreditManager(
@@ -48,7 +46,7 @@ class CreditAccountServiceV310 extends import_AbstractCreditAccountsService.Abst
48
46
  callData: (0, import_viem.encodeFunctionData)({
49
47
  abi: import_generated.iCreditFacadeMulticallV310Abi,
50
48
  functionName: "setBotPermissions",
51
- args: [botAddress, stopBot ? 0n : import_constants.PERMISSION_BY_TYPE[botBaseType]]
49
+ args: [botAddress, permissions]
52
50
  })
53
51
  };
54
52
  const calls = [...priceUpdatesCalls, addBotCall];
@@ -18,7 +18,6 @@ module.exports = __toCommonJS(accounts_exports);
18
18
  __reExport(accounts_exports, require("./AbstractCreditAccountsService.js"), module.exports);
19
19
  __reExport(accounts_exports, require("./CreditAccountsServiceV300.js"), module.exports);
20
20
  __reExport(accounts_exports, require("./CreditAccountsServiceV310.js"), module.exports);
21
- __reExport(accounts_exports, require("./constants.js"), module.exports);
22
21
  __reExport(accounts_exports, require("./createCreditAccountService.js"), module.exports);
23
22
  __reExport(accounts_exports, require("./types.js"), module.exports);
24
23
  // Annotate the CommonJS export names for ESM import in node:
@@ -26,7 +25,6 @@ __reExport(accounts_exports, require("./types.js"), module.exports);
26
25
  ...require("./AbstractCreditAccountsService.js"),
27
26
  ...require("./CreditAccountsServiceV300.js"),
28
27
  ...require("./CreditAccountsServiceV310.js"),
29
- ...require("./constants.js"),
30
28
  ...require("./createCreditAccountService.js"),
31
29
  ...require("./types.js")
32
30
  });
@@ -11,6 +11,7 @@ import {
11
11
  AP_PERIPHERY_COMPRESSOR,
12
12
  AP_TREASURY,
13
13
  BasePlugin,
14
+ chains as CHAINS,
14
15
  hexEq,
15
16
  isV300,
16
17
  isV310,
@@ -19,6 +20,7 @@ import {
19
20
  } from "../../sdk/index.js";
20
21
  import { iPartialLiquidationBotV310Abi } from "./abi/iPartialLiquidationBotV310.js";
21
22
  import {
23
+ LEGACY_MIGRATION_BOT,
22
24
  PARTIAL_LIQUIDATION_BOT_CONFIGS,
23
25
  PARTIAL_LIQUIDATION_BOT_DEPLOYER,
24
26
  PARTIAL_LIQUIDATION_BOT_SALT
@@ -114,11 +116,11 @@ class BotsPlugin extends BasePlugin {
114
116
  if (b.status === "success") {
115
117
  expectedBots.upsert(b.result, { ...configs[i], treasury });
116
118
  this.logger?.debug(
117
- `found bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`
119
+ `expected bot [${minHealthFactor}, ${maxHealthFactor}] at ${b.result}`
118
120
  );
119
121
  } else {
120
122
  this.logger?.error(
121
- `failed to find bot [${minHealthFactor}, ${maxHealthFactor}]`,
123
+ `failed compute address for bot [${minHealthFactor}, ${maxHealthFactor}]`,
122
124
  b.error
123
125
  );
124
126
  }
@@ -223,6 +225,9 @@ class BotsPlugin extends BasePlugin {
223
225
  throw new Error(`unsupported bot version: ${v}`);
224
226
  }
225
227
  }
228
+ static getMigrationBotData(chainId) {
229
+ return chainId === CHAINS.Mainnet.id ? LEGACY_MIGRATION_BOT : void 0;
230
+ }
226
231
  }
227
232
  export {
228
233
  BotsPlugin,
@@ -1,3 +1,4 @@
1
+ import { BotPermissions } from "../../sdk/index.js";
1
2
  const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
2
3
  Mainnet: [
3
4
  {
@@ -26,8 +27,26 @@ const PARTIAL_LIQUIDATION_BOT_CONFIGS = {
26
27
  };
27
28
  const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
28
29
  const PARTIAL_LIQUIDATION_BOT_DEPLOYER = "0xc93155E0a835Cf4E17a19463Fa67ed43c164d06a";
30
+ const ACCOUNT_MIGRATOR_BOT = "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase();
31
+ const ACCOUNT_MIGRATOR_PREVIEWER = "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase();
32
+ const LEGACY_MIGRATION_BOT = {
33
+ address: ACCOUNT_MIGRATOR_BOT,
34
+ previewer: ACCOUNT_MIGRATOR_PREVIEWER,
35
+ version: 310,
36
+ botType: "MIGRATION_BOT"
37
+ };
38
+ const PERMISSION_BY_TYPE = {
39
+ LIQUIDATION_PROTECTION: BigInt(
40
+ BotPermissions.ADD_COLLATERAL | BotPermissions.WITHDRAW_COLLATERAL | BotPermissions.DECREASE_DEBT
41
+ ),
42
+ MIGRATION: BigInt(
43
+ BotPermissions.EXTERNAL_CALLS | BotPermissions.UPDATE_QUOTA | BotPermissions.DECREASE_DEBT
44
+ )
45
+ };
29
46
  export {
47
+ LEGACY_MIGRATION_BOT,
30
48
  PARTIAL_LIQUIDATION_BOT_CONFIGS,
31
49
  PARTIAL_LIQUIDATION_BOT_DEPLOYER,
32
- PARTIAL_LIQUIDATION_BOT_SALT
50
+ PARTIAL_LIQUIDATION_BOT_SALT,
51
+ PERMISSION_BY_TYPE
33
52
  };
@@ -11,7 +11,9 @@ const LIQUIDATION_BOT_TYPES = [
11
11
  "DELEVERAGE_BOT_LV",
12
12
  "DELEVERAGE_BOT_HV"
13
13
  ];
14
+ const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
14
15
  export {
15
16
  BOT_PARAMS_ABI,
16
- LIQUIDATION_BOT_TYPES
17
+ LIQUIDATION_BOT_TYPES,
18
+ MIGRATION_BOT_TYPES
17
19
  };
@@ -23,10 +23,6 @@ class AbstractMigrateCreditAccountsService extends SDKConstruct {
23
23
  ["0xcB5D10A57Aeb622b92784D53F730eE2210ab370E".toLowerCase()]: "0x00F7C0d39B05089e93858A82439EA17dE7160B5a".toLowerCase()
24
24
  }
25
25
  };
26
- // TODO: HARDCODED
27
- static accountMigratorBot = "0x286Fe53994f5668D56538Aa10eaa3Ac36f878e9C".toLowerCase();
28
- // TODO: HARDCODED
29
- static accountMigratorPreviewer = "0x6523B8c9daB92eea7944a79b4Dbb598c7934DCca".toLowerCase();
30
26
  constructor(sdk, version) {
31
27
  super(sdk);
32
28
  this.#version = version;
@@ -107,23 +103,6 @@ class AbstractMigrateCreditAccountsService extends SDKConstruct {
107
103
  static getV310TargetTokenAddress(source, chainId) {
108
104
  return AbstractMigrateCreditAccountsService.V300_TO_V310_TOKENS_OVERRIDES[chainId]?.[source] ?? source;
109
105
  }
110
- static getMigrationBotAddress(chainId) {
111
- const botAddress = chainId === CHAINS.Mainnet.id ? AbstractMigrateCreditAccountsService.accountMigratorBot : void 0;
112
- const previewerAddress = chainId === CHAINS.Mainnet.id ? AbstractMigrateCreditAccountsService.accountMigratorPreviewer : void 0;
113
- return previewerAddress && botAddress ? { botAddress, previewerAddress } : void 0;
114
- }
115
- static getMigrationBotData(chainId) {
116
- const { botAddress } = AbstractMigrateCreditAccountsService.getMigrationBotAddress(chainId) || {};
117
- return botAddress ? {
118
- baseParams: {
119
- addr: botAddress,
120
- version: 310
121
- },
122
- address: botAddress,
123
- version: 310,
124
- botType: "MIGRATION_BOT"
125
- } : void 0;
126
- }
127
106
  static getTokensToMigrate(creditAccount) {
128
107
  const sourceTokensToMigrate = Object.values(creditAccount.tokens).filter(
129
108
  (t) => creditAccount.isTokenEnabled(t.token) && t.balance > 1n
@@ -1,4 +0,0 @@
1
- const MIGRATION_BOT_TYPES = ["MIGRATION_BOT"];
2
- export {
3
- MIGRATION_BOT_TYPES
4
- };
@@ -9,7 +9,6 @@ import {
9
9
  iBotListV300Abi,
10
10
  iCreditFacadeV300MulticallAbi
11
11
  } from "../../abi/v300.js";
12
- import { AbstractMigrateCreditAccountsService } from "../accountMigration/AbstractMigrateCreditAccountsService.js";
13
12
  import { SDKConstruct } from "../base/index.js";
14
13
  import {
15
14
  ADDRESS_0X0,
@@ -200,7 +199,7 @@ class AbstractCreditAccountService extends SDKConstruct {
200
199
  and their credit managers to check connected bots on
201
200
  * @returns call result of getConnectedBots for each credit account
202
201
  */
203
- async getConnectedBots(accountsToCheck) {
202
+ async getConnectedBots(accountsToCheck, legacyMigrationBot) {
204
203
  const [resp, migration] = await Promise.all([
205
204
  this.client.multicall({
206
205
  contracts: accountsToCheck.map((o) => {
@@ -216,15 +215,12 @@ class AbstractCreditAccountService extends SDKConstruct {
216
215
  }),
217
216
  allowFailure: true
218
217
  }),
219
- this.getActiveMigrationBots(accountsToCheck)
218
+ this.getActiveMigrationBots(accountsToCheck, legacyMigrationBot)
220
219
  ]);
221
220
  return { legacy: resp, legacyMigration: migration };
222
221
  }
223
- async getActiveMigrationBots(accountsToCheck) {
224
- const migrationBot = AbstractMigrateCreditAccountsService.getMigrationBotAddress(
225
- this.sdk.chainId
226
- );
227
- if (migrationBot) {
222
+ async getActiveMigrationBots(accountsToCheck, legacyMigrationBot) {
223
+ if (legacyMigrationBot) {
228
224
  const result = await this.client.multicall({
229
225
  contracts: accountsToCheck.map((ca) => {
230
226
  const cm = this.sdk.marketRegister.findCreditManager(
@@ -234,12 +230,12 @@ class AbstractCreditAccountService extends SDKConstruct {
234
230
  abi: isV300(cm.creditFacade.version) ? iBotListV300Abi : iBotListV310Abi,
235
231
  address: cm.creditFacade.botList,
236
232
  functionName: "getBotStatus",
237
- args: isV300(cm.creditFacade.version) ? [migrationBot.botAddress, ca.creditManager, ca.creditAccount] : [migrationBot.botAddress, ca.creditAccount]
233
+ args: isV300(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
238
234
  };
239
235
  }),
240
236
  allowFailure: true
241
237
  });
242
- return { result, migrationBot };
238
+ return { result, botAddress: legacyMigrationBot };
243
239
  }
244
240
  return void 0;
245
241
  }
@@ -2,15 +2,13 @@ import { encodeFunctionData } from "viem";
2
2
  import { iCreditFacadeMulticallV310Abi } from "../../abi/310/generated.js";
3
3
  import { MAX_UINT256 } from "../constants/math.js";
4
4
  import { AbstractCreditAccountService } from "./AbstractCreditAccountsService.js";
5
- import { PERMISSION_BY_TYPE } from "./constants.js";
6
5
  class CreditAccountServiceV310 extends AbstractCreditAccountService {
7
6
  /**
8
7
  * Implements {@link ICreditAccountsService.setBot}
9
8
  */
10
9
  async setBot({
11
10
  botAddress,
12
- botBaseType,
13
- stopBot,
11
+ permissions,
14
12
  targetContract
15
13
  }) {
16
14
  const cm = this.sdk.marketRegister.findCreditManager(
@@ -25,7 +23,7 @@ class CreditAccountServiceV310 extends AbstractCreditAccountService {
25
23
  callData: encodeFunctionData({
26
24
  abi: iCreditFacadeMulticallV310Abi,
27
25
  functionName: "setBotPermissions",
28
- args: [botAddress, stopBot ? 0n : PERMISSION_BY_TYPE[botBaseType]]
26
+ args: [botAddress, permissions]
29
27
  })
30
28
  };
31
29
  const calls = [...priceUpdatesCalls, addBotCall];
@@ -1,6 +1,5 @@
1
1
  export * from "./AbstractCreditAccountsService.js";
2
2
  export * from "./CreditAccountsServiceV300.js";
3
3
  export * from "./CreditAccountsServiceV310.js";
4
- export * from "./constants.js";
5
4
  export * from "./createCreditAccountService.js";
6
5
  export * from "./types.js";
@@ -3,7 +3,7 @@ import type { IGearboxSDKPlugin } from "../../sdk/index.js";
3
3
  import { AddressMap, BasePlugin } from "../../sdk/index.js";
4
4
  import { PartialLiquidationBotV300Contract } from "./PartialLiquidationBotV300Contract.js";
5
5
  import { PartialLiquidationBotV310Contract } from "./PartialLiquidationBotV310Contract.js";
6
- import { type BotParameters, type BotState, type BotsPluginState, type BotsPluginStateHuman } from "./types.js";
6
+ import { type BotParameters, type BotState, type BotsPluginState, type BotsPluginStateHuman, type MigrationBotState } from "./types.js";
7
7
  export declare class UnsupportedBotVersionError extends Error {
8
8
  readonly state: BotState;
9
9
  constructor(state: BotState);
@@ -20,4 +20,5 @@ export declare class BotsPlugin extends BasePlugin<BotsPluginState> implements I
20
20
  get allBots(): PartialLiquidationBotContract[];
21
21
  get state(): BotsPluginState;
22
22
  hydrate(state: BotsPluginState): void;
23
+ static getMigrationBotData(chainId: number): MigrationBotState | undefined;
23
24
  }
@@ -1,6 +1,8 @@
1
1
  import type { Address } from "viem";
2
- import type { NetworkType } from "../../sdk/index.js";
3
- import type { BotParameters } from "./types.js";
2
+ import { type NetworkType } from "../../sdk/index.js";
3
+ import type { BotBaseType, BotParameters, MigrationBotState } from "./types.js";
4
4
  export declare const PARTIAL_LIQUIDATION_BOT_CONFIGS: Partial<Record<NetworkType, Omit<BotParameters, "treasury">[]>>;
5
5
  export declare const PARTIAL_LIQUIDATION_BOT_SALT = "GEARBOX";
6
6
  export declare const PARTIAL_LIQUIDATION_BOT_DEPLOYER: Address;
7
+ export declare const LEGACY_MIGRATION_BOT: MigrationBotState;
8
+ export declare const PERMISSION_BY_TYPE: Record<BotBaseType, bigint>;
@@ -53,3 +53,12 @@ export interface BotsPluginState {
53
53
  */
54
54
  bots: Record<Address, BotState[]>;
55
55
  }
56
+ export type BotBaseType = "LIQUIDATION_PROTECTION" | "MIGRATION";
57
+ export declare const MIGRATION_BOT_TYPES: readonly ["MIGRATION_BOT"];
58
+ export type MigrationBotType = (typeof MIGRATION_BOT_TYPES)[number];
59
+ export type MigrationBotState = {
60
+ address: Address;
61
+ version: 310;
62
+ previewer: Address;
63
+ botType: MigrationBotType;
64
+ };
@@ -3,12 +3,10 @@ import { SDKConstruct } from "../base/index.js";
3
3
  import type { GearboxSDK } from "../GearboxSDK.js";
4
4
  import type { Asset } from "../router/types.js";
5
5
  import type { CreditAccountData_Legacy, CreditManagerData_Legacy } from "../sdk-legacy/index.js";
6
- import type { MigrateCreditAccountProps, MigrationBotState, PreviewCreditAccountMigrationProps, PreviewMigrationResult } from "./types.js";
6
+ import type { MigrateCreditAccountProps, PreviewCreditAccountMigrationProps, PreviewMigrationResult } from "./types.js";
7
7
  export declare abstract class AbstractMigrateCreditAccountsService extends SDKConstruct {
8
8
  #private;
9
9
  private static readonly V300_TO_V310_TOKENS_OVERRIDES;
10
- private static readonly accountMigratorBot;
11
- private static readonly accountMigratorPreviewer;
12
10
  constructor(sdk: GearboxSDK, version: number);
13
11
  /**
14
12
  * Preview delayed withdrawal for a given credit account
@@ -24,11 +22,6 @@ export declare abstract class AbstractMigrateCreditAccountsService extends SDKCo
24
22
  migrateCreditAccount({ accountMigratorBot, targetCreditManager, signer, preview, expectedTargetQuota, account, }: MigrateCreditAccountProps): Promise<Address>;
25
23
  private getPriceUpdatesForMigration;
26
24
  static getV310TargetTokenAddress(source: Address, chainId: number): Address;
27
- static getMigrationBotAddress(chainId: number): {
28
- botAddress: `0x${string}`;
29
- previewerAddress: `0x${string}`;
30
- } | undefined;
31
- static getMigrationBotData(chainId: number): MigrationBotState | undefined;
32
25
  static getTokensToMigrate(creditAccount: CreditAccountData_Legacy): {
33
26
  sourceTokensToMigrate: import("../index.js").CaTokenBalance[];
34
27
  targetTokensToMigrate: import("../index.js").CaTokenBalance[];
@@ -2,17 +2,6 @@ import type { Address, GetContractReturnType, PublicClient, WalletClient } from
2
2
  import type { accountMigratorPreviewerV310Abi } from "../../abi/migration.js";
3
3
  import type { SDKConstruct } from "../base/SDKConstruct.js";
4
4
  import type { Asset, RouterCASlice } from "../router/index.js";
5
- export type MigrationBotState = {
6
- baseParams: {
7
- addr: Address;
8
- version: number;
9
- };
10
- address: Address;
11
- version: number;
12
- botType: MigrationBotType;
13
- };
14
- export declare const MIGRATION_BOT_TYPES: readonly ["MIGRATION_BOT"];
15
- export type MigrationBotType = (typeof MIGRATION_BOT_TYPES)[number];
16
5
  export interface MigrateCreditAccountProps {
17
6
  /**
18
7
  * accountMigratorBot Address
@@ -46,7 +46,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
46
46
  getConnectedBots(accountsToCheck: Array<{
47
47
  creditAccount: Address;
48
48
  creditManager: Address;
49
- }>): Promise<{
49
+ }>, legacyMigrationBot: Address | undefined): Promise<{
50
50
  legacy: GetConnectedBotsResult;
51
51
  legacyMigration: GetConnectedMigrationBotsResult;
52
52
  }>;
@@ -4,7 +4,7 @@ export declare class CreditAccountServiceV310 extends AbstractCreditAccountServi
4
4
  /**
5
5
  * Implements {@link ICreditAccountsService.setBot}
6
6
  */
7
- setBot({ botAddress, botBaseType, stopBot, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
7
+ setBot({ botAddress, permissions, targetContract, }: SetBotProps): Promise<CreditAccountOperationResult | CreditManagerOperationResult>;
8
8
  /**
9
9
  * Implements {@link ICreditAccountsService.withdrawCollateral}
10
10
  */
@@ -1,6 +1,5 @@
1
1
  export * from "./AbstractCreditAccountsService.js";
2
2
  export * from "./CreditAccountsServiceV300.js";
3
3
  export * from "./CreditAccountsServiceV310.js";
4
- export * from "./constants.js";
5
4
  export * from "./createCreditAccountService.js";
6
5
  export * from "./types.js";
@@ -1,8 +1,6 @@
1
1
  import type { Address, ContractFunctionArgs, GetContractReturnType, Hex, PublicClient } from "viem";
2
2
  import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAccountCompressor.js";
3
3
  import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
4
- import type { LiquidationBotType as LiquidationBotTypeSDK } from "../../plugins/bots/types.js";
5
- import type { MigrationBotType } from "../accountMigration/types.js";
6
4
  import type { ConnectedBotData, CreditAccountData } from "../base/index.js";
7
5
  import type { SDKConstruct } from "../base/SDKConstruct.js";
8
6
  import type { CreditSuite, OnDemandPriceUpdates, PriceUpdateV300, PriceUpdateV310, UpdatePriceFeedsResult } from "../market/index.js";
@@ -365,19 +363,6 @@ export interface Rewards {
365
363
  calls: Array<MultiCall>;
366
364
  rewards: Array<Asset>;
367
365
  }
368
- /**
369
- It was planned that bots related to each other like
370
- {
371
- liquidationProtection: LiquidationBotType[]
372
- someOtherBaseType: someOtherDetailedType[ ... ]
373
- }
374
-
375
- BotBaseType = "liquidationProtection" | someOtherBaseType
376
- BotDetailedType = LiquidationBotType | someOtherDetailedType
377
- * */
378
- export type BotBaseType = "LIQUIDATION_PROTECTION" | "MIGRATION";
379
- export type LiquidationBotType = Exclude<LiquidationBotTypeSDK, "PARTIAL_LIQUIDATION_BOT">;
380
- export type { MigrationBotType };
381
366
  interface CMSlice {
382
367
  creditManager: Address;
383
368
  creditFacade: Address;
@@ -389,13 +374,9 @@ export interface SetBotProps {
389
374
  */
390
375
  botAddress: Address;
391
376
  /**
392
- * Bot base type (see comments above)
377
+ * Permissions to set for the bot
393
378
  */
394
- botBaseType: BotBaseType;
395
- /**
396
- * Either stop or enable bot
397
- */
398
- stopBot: boolean;
379
+ permissions: bigint;
399
380
  /**
400
381
  * Minimal credit account data {@link RouterCASlice} on which operation is performed; if omitted, credit manager data is used
401
382
  * Minimal credit manager data {@link CMSlice} on which operation is performed; used only if credit account is omitted
@@ -424,10 +405,7 @@ export type GetConnectedMigrationBotsResult = {
424
405
  result: readonly [bigint, boolean, boolean] | readonly [bigint, boolean];
425
406
  status: "success";
426
407
  })[];
427
- migrationBot: {
428
- botAddress: Address;
429
- previewerAddress: Address;
430
- };
408
+ botAddress: Address;
431
409
  } | undefined;
432
410
  export interface ICreditAccountsService extends SDKConstruct {
433
411
  /**
@@ -457,13 +435,14 @@ export interface ICreditAccountsService extends SDKConstruct {
457
435
  /**
458
436
  * Method to get all connected bots for credit account
459
437
  * @param {Array<{ creditAccount: Address; creditManager: Address }>} accountsToCheck - list of credit accounts
438
+ * @param {Address | undefined} legacyMigrationBot - address of the bot to check connected bots on
460
439
  * and their credit managers to check connected bots on
461
440
  * @returns call result of getConnectedBots for each credit account
462
441
  */
463
442
  getConnectedBots(accountsToCheck: Array<{
464
443
  creditAccount: Address;
465
444
  creditManager: Address;
466
- }>): Promise<{
445
+ }>, legacyMigrationBot: Address | undefined): Promise<{
467
446
  legacy: GetConnectedBotsResult;
468
447
  legacyMigration: GetConnectedMigrationBotsResult;
469
448
  }>;
@@ -630,3 +609,4 @@ export interface ICreditAccountsService extends SDKConstruct {
630
609
  */
631
610
  claimFarmRewards(props: ClaimFarmRewardsProps): Promise<CreditAccountOperationResult>;
632
611
  }
612
+ export {};
@@ -91,16 +91,6 @@ export interface TimeToLiquidationProps {
91
91
  totalBorrowRate_debt: bigint;
92
92
  healthFactor: number;
93
93
  }
94
- export interface BotDataLegacy {
95
- baseParams: {
96
- addr: Address;
97
- version: bigint;
98
- contractType: Address;
99
- serializedParams: Address;
100
- };
101
- permissions: bigint;
102
- forbidden: boolean;
103
- }
104
94
  export declare class CreditAccountData_Legacy {
105
95
  readonly isSuccessful: boolean;
106
96
  readonly chainId: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "11.11.0",
3
+ "version": "11.11.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -1,36 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var constants_exports = {};
20
- __export(constants_exports, {
21
- PERMISSION_BY_TYPE: () => PERMISSION_BY_TYPE
22
- });
23
- module.exports = __toCommonJS(constants_exports);
24
- var import_bot_permissions = require("../constants/bot-permissions.js");
25
- const PERMISSION_BY_TYPE = {
26
- LIQUIDATION_PROTECTION: BigInt(
27
- import_bot_permissions.BotPermissions.ADD_COLLATERAL | import_bot_permissions.BotPermissions.WITHDRAW_COLLATERAL | import_bot_permissions.BotPermissions.DECREASE_DEBT
28
- ),
29
- MIGRATION: BigInt(
30
- import_bot_permissions.BotPermissions.EXTERNAL_CALLS | import_bot_permissions.BotPermissions.UPDATE_QUOTA | import_bot_permissions.BotPermissions.DECREASE_DEBT
31
- )
32
- };
33
- // Annotate the CommonJS export names for ESM import in node:
34
- 0 && (module.exports = {
35
- PERMISSION_BY_TYPE
36
- });
@@ -1,12 +0,0 @@
1
- import { BotPermissions } from "../constants/bot-permissions.js";
2
- const PERMISSION_BY_TYPE = {
3
- LIQUIDATION_PROTECTION: BigInt(
4
- BotPermissions.ADD_COLLATERAL | BotPermissions.WITHDRAW_COLLATERAL | BotPermissions.DECREASE_DEBT
5
- ),
6
- MIGRATION: BigInt(
7
- BotPermissions.EXTERNAL_CALLS | BotPermissions.UPDATE_QUOTA | BotPermissions.DECREASE_DEBT
8
- )
9
- };
10
- export {
11
- PERMISSION_BY_TYPE
12
- };
@@ -1,2 +0,0 @@
1
- import type { BotBaseType } from "./types.js";
2
- export declare const PERMISSION_BY_TYPE: Record<BotBaseType, bigint>;