@gearbox-protocol/sdk 12.4.0-next.1 → 12.5.0

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 (104) hide show
  1. package/dist/cjs/abi/errors.js +10 -1
  2. package/dist/cjs/dev/AccountOpener.js +2 -1
  3. package/dist/cjs/dev/RevolverTransport.js +4 -6
  4. package/dist/cjs/dev/ltUtils.js +2 -1
  5. package/dist/cjs/dev/migrateFaucet.js +2 -1
  6. package/dist/cjs/dev/providers.js +6 -2
  7. package/dist/cjs/dev/transports.js +3 -3
  8. package/dist/cjs/permissionless/bindings/compressors/token-compressor.js +7 -4
  9. package/dist/cjs/permissionless/bindings/governance/governor.js +3 -4
  10. package/dist/cjs/permissionless/bindings/market-configurator.js +4 -2
  11. package/dist/cjs/permissionless/bindings/price-feed-store.js +2 -1
  12. package/dist/cjs/permissionless/bindings/treasury-splitter.js +12 -1
  13. package/dist/cjs/permissionless/utils/format.js +0 -8
  14. package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
  15. package/dist/cjs/plugins/bots/BotsPlugin.js +4 -2
  16. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
  17. package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
  18. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
  19. package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
  20. package/dist/cjs/sdk/GearboxSDK.js +9 -5
  21. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +71 -38
  22. package/dist/cjs/sdk/base/TokensMeta.js +2 -1
  23. package/dist/cjs/sdk/core/address-provider/AbstractAddressProviderContract.js +20 -3
  24. package/dist/cjs/sdk/core/address-provider/AddressProviderV300Contract.js +1 -1
  25. package/dist/cjs/sdk/core/address-provider/AddressProviderV310Contract.js +1 -1
  26. package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +29 -7
  27. package/dist/cjs/sdk/gauges/GaugeStakingService.js +2 -1
  28. package/dist/cjs/sdk/index.js +2 -0
  29. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +15 -0
  30. package/dist/cjs/sdk/market/credit/CreditFacadeV300Contract.js +1 -1
  31. package/dist/cjs/sdk/market/credit/CreditFacadeV310Contract.js +1 -1
  32. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
  33. package/dist/cjs/sdk/pools/AbstractPoolService.js +137 -0
  34. package/dist/cjs/sdk/pools/PoolServiceV300.js +30 -0
  35. package/dist/cjs/sdk/pools/PoolServiceV310.js +30 -0
  36. package/dist/cjs/sdk/pools/createPoolService.js +39 -0
  37. package/dist/cjs/sdk/pools/index.js +26 -0
  38. package/dist/cjs/sdk/pools/types.js +16 -0
  39. package/dist/cjs/sdk/sdk-legacy/core/endpoint.js +3 -9
  40. package/dist/cjs/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
  41. package/dist/cjs/sdk/utils/formatter.js +8 -0
  42. package/dist/esm/abi/errors.js +9 -1
  43. package/dist/esm/dev/AccountOpener.js +2 -1
  44. package/dist/esm/dev/RevolverTransport.js +5 -7
  45. package/dist/esm/dev/ltUtils.js +2 -1
  46. package/dist/esm/dev/migrateFaucet.js +2 -1
  47. package/dist/esm/dev/providers.js +4 -1
  48. package/dist/esm/dev/transports.js +2 -2
  49. package/dist/esm/permissionless/bindings/compressors/token-compressor.js +7 -4
  50. package/dist/esm/permissionless/bindings/governance/governor.js +5 -2
  51. package/dist/esm/permissionless/bindings/market-configurator.js +4 -2
  52. package/dist/esm/permissionless/bindings/price-feed-store.js +2 -1
  53. package/dist/esm/permissionless/bindings/treasury-splitter.js +13 -2
  54. package/dist/esm/permissionless/utils/format.js +0 -7
  55. package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +2 -1
  56. package/dist/esm/plugins/bots/BotsPlugin.js +4 -2
  57. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +13 -7
  58. package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +2 -1
  59. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +2 -1
  60. package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
  61. package/dist/esm/sdk/GearboxSDK.js +9 -5
  62. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +71 -38
  63. package/dist/esm/sdk/base/TokensMeta.js +2 -1
  64. package/dist/esm/sdk/core/address-provider/AbstractAddressProviderContract.js +20 -3
  65. package/dist/esm/sdk/core/address-provider/AddressProviderV300Contract.js +1 -1
  66. package/dist/esm/sdk/core/address-provider/AddressProviderV310Contract.js +1 -1
  67. package/dist/esm/sdk/core/address-provider/createAddressProvider.js +36 -8
  68. package/dist/esm/sdk/gauges/GaugeStakingService.js +2 -1
  69. package/dist/esm/sdk/index.js +1 -0
  70. package/dist/esm/sdk/market/MarketConfiguratorContract.js +15 -0
  71. package/dist/esm/sdk/market/credit/CreditFacadeV300Contract.js +6 -2
  72. package/dist/esm/sdk/market/credit/CreditFacadeV310Contract.js +6 -2
  73. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +6 -0
  74. package/dist/esm/sdk/pools/AbstractPoolService.js +113 -0
  75. package/dist/esm/sdk/pools/PoolServiceV300.js +6 -0
  76. package/dist/esm/sdk/pools/PoolServiceV310.js +6 -0
  77. package/dist/esm/sdk/pools/createPoolService.js +15 -0
  78. package/dist/esm/sdk/pools/index.js +3 -0
  79. package/dist/esm/sdk/pools/types.js +0 -0
  80. package/dist/esm/sdk/sdk-legacy/core/endpoint.js +3 -9
  81. package/dist/esm/sdk/sdk-legacy/gearboxRewards/api.js +2 -1
  82. package/dist/esm/sdk/utils/formatter.js +7 -0
  83. package/dist/types/abi/errors.d.ts +33 -0
  84. package/dist/types/dev/RevolverTransport.d.ts +2 -20
  85. package/dist/types/dev/providers.d.ts +8 -1
  86. package/dist/types/dev/transports.d.ts +1 -1
  87. package/dist/types/permissionless/utils/format.d.ts +0 -1
  88. package/dist/types/sdk/GearboxSDK.d.ts +1 -1
  89. package/dist/types/sdk/core/address-provider/AbstractAddressProviderContract.d.ts +2 -2
  90. package/dist/types/sdk/core/address-provider/AddressProviderV300Contract.d.ts +2 -2
  91. package/dist/types/sdk/core/address-provider/AddressProviderV310Contract.d.ts +2 -2
  92. package/dist/types/sdk/core/address-provider/types.d.ts +15 -0
  93. package/dist/types/sdk/index.d.ts +1 -0
  94. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
  95. package/dist/types/sdk/pools/AbstractPoolService.d.ts +9 -0
  96. package/dist/types/sdk/pools/PoolServiceV300.d.ts +4 -0
  97. package/dist/types/sdk/pools/PoolServiceV310.d.ts +4 -0
  98. package/dist/types/sdk/pools/createPoolService.d.ts +8 -0
  99. package/dist/types/sdk/pools/index.d.ts +3 -0
  100. package/dist/types/sdk/pools/types.d.ts +92 -0
  101. package/dist/types/sdk/sdk-legacy/core/endpoint.d.ts +1 -3
  102. package/dist/types/sdk/types/state-human.d.ts +1 -1
  103. package/dist/types/sdk/utils/formatter.d.ts +1 -0
  104. package/package.json +6 -6
@@ -21,6 +21,7 @@ __export(errors_exports, {
21
21
  errorAbis: () => errorAbis,
22
22
  iExceptionsV300Abi: () => iExceptionsV300Abi,
23
23
  iExceptionsV310Abi: () => iExceptionsV310Abi,
24
+ iPartialLiquidationBotV310ErrorsAbi: () => iPartialLiquidationBotV310ErrorsAbi,
24
25
  iRedstoneErrorsAbi: () => iRedstoneErrorsAbi,
25
26
  iRedstonePriceFeedExceptionsAbi: () => iRedstonePriceFeedExceptionsAbi,
26
27
  iRouterErrorsV300Abi: () => iRouterErrorsV300Abi,
@@ -399,6 +400,12 @@ const iExceptionsV310Abi = [
399
400
  { type: "error", name: "VotingContractNotAllowedException", inputs: [] },
400
401
  { type: "error", name: "ZeroAddressException", inputs: [] }
401
402
  ];
403
+ const iPartialLiquidationBotV310ErrorsAbi = [
404
+ { type: "error", name: "LiquidatedLessThanNeededException", inputs: [] },
405
+ { type: "error", name: "LiquidatedMoreThanNeededException", inputs: [] },
406
+ { type: "error", name: "SeizedLessThanRequiredException", inputs: [] },
407
+ { type: "error", name: "UnderlyingNotLiquidatableException", inputs: [] }
408
+ ];
402
409
  const errorAbis = [
403
410
  ...iExceptionsV300Abi,
404
411
  ...iExceptionsV310Abi,
@@ -406,13 +413,15 @@ const errorAbis = [
406
413
  ...iRedstoneErrorsAbi,
407
414
  ...ilpPriceFeedExceptionsAbi,
408
415
  ...iRouterErrorsV300Abi,
409
- ...iRouterErrorsV310Abi
416
+ ...iRouterErrorsV310Abi,
417
+ ...iPartialLiquidationBotV310ErrorsAbi
410
418
  ];
411
419
  // Annotate the CommonJS export names for ESM import in node:
412
420
  0 && (module.exports = {
413
421
  errorAbis,
414
422
  iExceptionsV300Abi,
415
423
  iExceptionsV310Abi,
424
+ iPartialLiquidationBotV310ErrorsAbi,
416
425
  iRedstoneErrorsAbi,
417
426
  iRedstonePriceFeedExceptionsAbi,
418
427
  iRouterErrorsV300Abi,
@@ -713,7 +713,8 @@ class AccountOpener extends import_sdk.SDKConstruct {
713
713
  args: [distributor.address]
714
714
  })
715
715
  ),
716
- allowFailure: false
716
+ allowFailure: false,
717
+ batchSize: 0
717
718
  });
718
719
  const tokensArr = tokens.asArray();
719
720
  for (let i = 0; i < tokensArr.length; i++) {
@@ -27,7 +27,6 @@ __export(RevolverTransport_exports, {
27
27
  module.exports = __toCommonJS(RevolverTransport_exports);
28
28
  var import_viem = require("viem");
29
29
  var import_v4 = require("zod/v4");
30
- var import_sdk = require("../sdk/index.js");
31
30
  var import_transports = require("./transports.js");
32
31
  const providerConfigSchema = import_v4.z.object({
33
32
  /**
@@ -45,11 +44,10 @@ const providerConfigSchema = import_v4.z.object({
45
44
  /**
46
45
  * HTTP transport options to use for this provider
47
46
  */
48
- httpClientOptions: import_transports.httpTransportConfigSchema.optional()
47
+ httpTransportOptions: import_transports.httpTransportOptionsSchema.optional()
49
48
  });
50
49
  const SelectionStrategy = import_v4.z.enum(["simple", "ordered"]);
51
50
  const revolverTransportConfigSchema = import_v4.z.object({
52
- network: import_sdk.NetworkType,
53
51
  /**
54
52
  * Providers to use
55
53
  */
@@ -66,7 +64,7 @@ const revolverTransportConfigSchema = import_v4.z.object({
66
64
  /**
67
65
  * Default HTTP options to use for all providers, can be overridden by provider config
68
66
  */
69
- defaultHTTPOptions: import_transports.httpTransportConfigSchema.optional(),
67
+ defaultHTTPOptions: import_transports.httpTransportOptionsSchema.optional(),
70
68
  /**
71
69
  * Default cooldown, in milliseconds, to wait before try this transport again
72
70
  */
@@ -107,11 +105,11 @@ class RevolverTransport {
107
105
  shouldRetry: config.shouldRetry ?? defaultShouldRetry
108
106
  };
109
107
  const transports = config.providers.map(
110
- ({ url, name, cooldown, httpClientOptions }) => ({
108
+ ({ url, name, cooldown, httpTransportOptions }) => ({
111
109
  name,
112
110
  transport: (0, import_viem.http)(url, {
113
111
  ...config.defaultHTTPOptions,
114
- ...httpClientOptions,
112
+ ...httpTransportOptions,
115
113
  key: name,
116
114
  name,
117
115
  onFetchRequest: this.#config.onRequest ? (...args) => this.#config.onRequest?.(name, ...args) : void 0,
@@ -185,7 +185,8 @@ async function logLTs(anvil, cm, tokens, logger) {
185
185
  address: t,
186
186
  args: []
187
187
  }
188
- ])
188
+ ]),
189
+ batchSize: 0
189
190
  });
190
191
  for (let i = 0; i < tokens.length; i++) {
191
192
  const lt = resp[i * 2]?.result ?? "error";
@@ -55,7 +55,8 @@ async function unsafeMigrateFaucet(sdk, faucet) {
55
55
  args: []
56
56
  }
57
57
  ],
58
- allowFailure: false
58
+ allowFailure: false,
59
+ batchSize: 0
59
60
  });
60
61
  }
61
62
  sdk.logger?.debug(`faucet address: ${faucetAddr}, owner: ${owner}`);
@@ -24,9 +24,11 @@ __export(providers_exports, {
24
24
  getDrpcUrl: () => getDrpcUrl,
25
25
  getErpcKey: () => getErpcKey,
26
26
  getRpcProviderUrl: () => getRpcProviderUrl,
27
- getThirdWebUrl: () => getThirdWebUrl
27
+ getThirdWebUrl: () => getThirdWebUrl,
28
+ rpcProvidersSchema: () => rpcProvidersSchema
28
29
  });
29
30
  module.exports = __toCommonJS(providers_exports);
31
+ var import_v4 = require("zod/v4");
30
32
  var import_sdk = require("../sdk/index.js");
31
33
  const SUPPORTED_RPC_PROVIDERS = [
32
34
  "alchemy",
@@ -34,6 +36,7 @@ const SUPPORTED_RPC_PROVIDERS = [
34
36
  "thirdweb",
35
37
  "ankr"
36
38
  ];
39
+ const rpcProvidersSchema = import_v4.z.enum(SUPPORTED_RPC_PROVIDERS);
37
40
  function getRpcProviderUrl(provider, network, apiKey, protocol = "http") {
38
41
  switch (provider) {
39
42
  case "alchemy":
@@ -158,5 +161,6 @@ function getErpcKey(network, projectId, urlBase) {
158
161
  getDrpcUrl,
159
162
  getErpcKey,
160
163
  getRpcProviderUrl,
161
- getThirdWebUrl
164
+ getThirdWebUrl,
165
+ rpcProvidersSchema
162
166
  });
@@ -18,11 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var transports_exports = {};
20
20
  __export(transports_exports, {
21
- httpTransportConfigSchema: () => httpTransportConfigSchema
21
+ httpTransportOptionsSchema: () => httpTransportOptionsSchema
22
22
  });
23
23
  module.exports = __toCommonJS(transports_exports);
24
24
  var import_v4 = require("zod/v4");
25
- const httpTransportConfigSchema = import_v4.z.object({
25
+ const httpTransportOptionsSchema = import_v4.z.object({
26
26
  /**
27
27
  * Whether to enable Batch JSON-RPC.
28
28
  * @link https://www.jsonrpc.org/specification#batch
@@ -67,5 +67,5 @@ const httpTransportConfigSchema = import_v4.z.object({
67
67
  });
68
68
  // Annotate the CommonJS export names for ESM import in node:
69
69
  0 && (module.exports = {
70
- httpTransportConfigSchema
70
+ httpTransportOptionsSchema
71
71
  });
@@ -45,7 +45,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
45
45
  args: []
46
46
  }));
47
47
  const results = await this.client.multicall({
48
- contracts
48
+ contracts,
49
+ batchSize: 0
49
50
  });
50
51
  const multivaultToToken = /* @__PURE__ */ new Map();
51
52
  const multivaults = [];
@@ -64,7 +65,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
64
65
  functionName: "symbol",
65
66
  args: []
66
67
  })),
67
- allowFailure: true
68
+ allowFailure: true,
69
+ batchSize: 0
68
70
  });
69
71
  const tokenToSymbol = /* @__PURE__ */ new Map();
70
72
  for (let i = 0; i < resultsSymbols.length; i++) {
@@ -86,7 +88,8 @@ class TokenCompressorContract extends import_sdk.BaseContract {
86
88
  abi,
87
89
  functionName: "getTokenInfo",
88
90
  args: [token]
89
- }))
91
+ })),
92
+ batchSize: 0
90
93
  });
91
94
  const tokenInfos = results.map((result, index) => {
92
95
  if (result.status === "failure") {
@@ -98,7 +101,7 @@ class TokenCompressorContract extends import_sdk.BaseContract {
98
101
  const postfix = multivaultSymbol ? `[${multivaultSymbol}]` : "";
99
102
  return {
100
103
  ...tokenInfo,
101
- symbol: `${tokenInfo.symbol} ${postfix}`
104
+ symbol: !postfix ? tokenInfo.symbol : `${tokenInfo.symbol} ${postfix}`
102
105
  };
103
106
  });
104
107
  return tokenInfos;
@@ -25,7 +25,6 @@ var import_viem = require("viem");
25
25
  var import_utils = require("viem/utils");
26
26
  var import_governor = require("../../../abi/governance/governor.js");
27
27
  var import_sdk = require("../../../sdk/index.js");
28
- var import_utils2 = require("../../utils/index.js");
29
28
  var import_market_configurator = require("../market-configurator.js");
30
29
  var import_treasury_splitter = require("../treasury-splitter.js");
31
30
  var import_batches_chain = require("./batches-chain.js");
@@ -177,7 +176,7 @@ class GovernorContract extends import_sdk.BaseContract {
177
176
  case "startBatch": {
178
177
  const [eta] = args;
179
178
  return {
180
- eta: (0, import_utils2.formatTimestamp)(Number(eta))
179
+ eta: (0, import_sdk.formatTimestamp)(Number(eta))
181
180
  };
182
181
  }
183
182
  case "queueTransaction": {
@@ -190,7 +189,7 @@ class GovernorContract extends import_sdk.BaseContract {
190
189
  data: (0, import_sdk.json_stringify)(
191
190
  this.#decodeFunctionData(target, calldata)?.args ?? calldata
192
191
  ),
193
- eta: (0, import_utils2.formatTimestamp)(Number(eta))
192
+ eta: (0, import_sdk.formatTimestamp)(Number(eta))
194
193
  };
195
194
  }
196
195
  case "executeBatch": {
@@ -207,7 +206,7 @@ class GovernorContract extends import_sdk.BaseContract {
207
206
  data: (0, import_sdk.json_stringify)(
208
207
  this.#decodeFunctionData(target, calldata)?.args ?? calldata
209
208
  ),
210
- eta: (0, import_utils2.formatTimestamp)(Number(eta))
209
+ eta: (0, import_sdk.formatTimestamp)(Number(eta))
211
210
  };
212
211
  })
213
212
  )
@@ -418,7 +418,8 @@ class MarketConfiguratorContract extends import_sdk.BaseContract {
418
418
  functionName: "getRoleHolders",
419
419
  args: [(0, import_viem.stringToHex)("EMERGENCY_LIQUIDATOR", { size: 32 })]
420
420
  }
421
- ]
421
+ ],
422
+ batchSize: 0
422
423
  });
423
424
  return {
424
425
  admin,
@@ -447,7 +448,8 @@ class MarketConfiguratorContract extends import_sdk.BaseContract {
447
448
  address: admin,
448
449
  abi: (0, import_viem.parseAbi)(["function contractType() view returns (bytes32)"]),
449
450
  functionName: "contractType"
450
- }))
451
+ })),
452
+ batchSize: 0
451
453
  });
452
454
  const pause = result.map((r, i) => ({
453
455
  ...r,
@@ -325,7 +325,8 @@ class PriceFeedStoreContract extends import_sdk.BaseContract {
325
325
  args: [priceFeed]
326
326
  }));
327
327
  const results = await this.client.multicall({
328
- contracts: multicallCalls
328
+ contracts: multicallCalls,
329
+ batchSize: 0
329
330
  });
330
331
  return results.map((result, index) => {
331
332
  if (result.status === "failure") {
@@ -99,7 +99,18 @@ class TreasurySplitterContract extends import_sdk.BaseContract {
99
99
  });
100
100
  return {
101
101
  functionName: decoded.functionName,
102
- ...super.parseFunctionParams(decoded)
102
+ ...this.parseFunctionParams(decoded)
103
+ };
104
+ }
105
+ case "setDefaultSplit": {
106
+ const [receivers, proportions] = args;
107
+ return {
108
+ receivers: (0, import_sdk.json_stringify)(receivers),
109
+ proportions: (0, import_sdk.json_stringify)(
110
+ proportions.map(
111
+ (proportion) => `${proportion / 100}% [${proportion}]`
112
+ )
113
+ )
103
114
  };
104
115
  }
105
116
  default:
@@ -22,7 +22,6 @@ __export(format_exports, {
22
22
  deepJsonParse: () => deepJsonParse,
23
23
  formatBytecodeSize: () => formatBytecodeSize,
24
24
  formatBytecodeVersion: () => formatBytecodeVersion,
25
- formatTimestamp: () => formatTimestamp,
26
25
  shortenHash: () => shortenHash,
27
26
  significantTrunc: () => significantTrunc
28
27
  });
@@ -38,12 +37,6 @@ function formatBytecodeVersion(version) {
38
37
  const patch = version % 10;
39
38
  return `v${major}.${minor}.${patch}`;
40
39
  }
41
- function formatTimestamp(timestamp) {
42
- return new Date(timestamp * 1e3).toLocaleString("en-GB", {
43
- dateStyle: "short",
44
- timeStyle: "short"
45
- });
46
- }
47
40
  function shortenHash(hash, chars = 4) {
48
41
  if (!hash) return "";
49
42
  const start = hash.slice(0, chars + 2);
@@ -91,7 +84,6 @@ function deepJsonParse(value) {
91
84
  deepJsonParse,
92
85
  formatBytecodeSize,
93
86
  formatBytecodeVersion,
94
- formatTimestamp,
95
87
  shortenHash,
96
88
  significantTrunc
97
89
  });
@@ -84,7 +84,8 @@ class AccountsCounterPlugin extends import_sdk.BasePlugin {
84
84
  }
85
85
  ]
86
86
  ),
87
- allowFailure: false
87
+ allowFailure: false,
88
+ batchSize: 0
88
89
  });
89
90
  this.#accounts = new import_sdk.AddressMap();
90
91
  for (let i = 0; i < cms.length; i++) {
@@ -70,7 +70,8 @@ class BotsPlugin extends import_sdk.BasePlugin {
70
70
  })
71
71
  ),
72
72
  allowFailure: true,
73
- blockNumber: this.sdk.currentBlock
73
+ blockNumber: this.sdk.currentBlock,
74
+ batchSize: 0
74
75
  });
75
76
  const expectedBots = new import_sdk.AddressMap();
76
77
  for (let i = 0; i < configs.length; i++) {
@@ -98,7 +99,8 @@ class BotsPlugin extends import_sdk.BasePlugin {
98
99
  })
99
100
  ),
100
101
  allowFailure: true,
101
- blockNumber: this.sdk.currentBlock
102
+ blockNumber: this.sdk.currentBlock,
103
+ batchSize: 0
102
104
  });
103
105
  for (let i = 0; i < botAddrs.length; i++) {
104
106
  const serialized = serializedBots[i];
@@ -22,6 +22,7 @@ __export(DegenDistributorsPlugin_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(DegenDistributorsPlugin_exports);
24
24
  var import_sdk = require("../../sdk/index.js");
25
+ var import_MarketConfiguratorContract = require("../../sdk/market/MarketConfiguratorContract.js");
25
26
  const MAP_LABEL = "degenDistributors";
26
27
  class DegenDistributorsPlugin extends import_sdk.BasePlugin {
27
28
  #distributors;
@@ -39,12 +40,15 @@ class DegenDistributorsPlugin extends import_sdk.BasePlugin {
39
40
  this.sdk.logger?.debug(
40
41
  `loading degen distributors for ${this.sdk.networkType}`
41
42
  );
42
- const distributors = await Promise.allSettled(
43
- configurators.map((cfg) => cfg.getPeripheryContract("DEGEN_DISTRIBUTOR"))
43
+ const distributors = await import_MarketConfiguratorContract.MarketConfiguratorContract.getPeripheryContractBatch(
44
+ Object.values(configurators),
45
+ this.sdk.client,
46
+ "DEGEN_DISTRIBUTOR"
44
47
  );
45
48
  const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
46
49
  const cfgLC = cfg.address.toLowerCase();
47
- acc[cfgLC] = distributors[index];
50
+ const distributor = distributors[index];
51
+ acc[cfgLC] = distributor;
48
52
  return acc;
49
53
  }, {});
50
54
  this.#distributors = new import_sdk.AddressMap(void 0, MAP_LABEL);
@@ -53,11 +57,13 @@ class DegenDistributorsPlugin extends import_sdk.BasePlugin {
53
57
  const cfg = m.configurator.address;
54
58
  const cfgLC = cfg.toLowerCase();
55
59
  const r = distributorByConfigurator?.[cfgLC];
56
- if (r.status === "fulfilled") {
57
- this.#distributors?.upsert(pool, r.value);
60
+ if (r.status === "success" && r.result.length > 0) {
61
+ this.#distributors?.upsert(pool, r.result[0]);
58
62
  } else {
59
- this.sdk.logger?.error(
60
- `failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.reason}`
63
+ this.sdk.logger?.warn(
64
+ `failed to load degen distributor for market configurator ${this.labelAddress(
65
+ cfg
66
+ )} and pool ${this.labelAddress(pool)}: ${r.error}`
61
67
  );
62
68
  }
63
69
  });
@@ -44,7 +44,8 @@ class DelayedWithdrawalPlugin extends import_sdk.BasePlugin {
44
44
  args: [cm.creditManager.address]
45
45
  })
46
46
  ) : [],
47
- allowFailure: true
47
+ allowFailure: true,
48
+ batchSize: 0
48
49
  });
49
50
  this.#withdrawableAssets = new import_sdk.AddressMap(void 0, MAP_LABEL);
50
51
  resp.forEach((r, index) => {
@@ -49,7 +49,8 @@ class Pools7DAgoPlugin extends import_sdk.BasePlugin {
49
49
  args: [m.pool.pool.address]
50
50
  })
51
51
  ),
52
- blockNumber: import_sdk.BigIntMath.max(0n, targetBlock)
52
+ blockNumber: import_sdk.BigIntMath.max(0n, targetBlock),
53
+ batchSize: 0
53
54
  });
54
55
  this.#pools7DAgo = new import_sdk.AddressMap(void 0, MAP_LABEL);
55
56
  resp.forEach((r, index) => {
@@ -51,7 +51,8 @@ class ZappersPlugin extends import_sdk.BasePlugin {
51
51
  args: [m.configurator.address, m.pool.pool.address]
52
52
  })
53
53
  ),
54
- allowFailure: true
54
+ allowFailure: true,
55
+ batchSize: 0
55
56
  });
56
57
  this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
57
58
  for (let i = 0; i < resp.length; i++) {
@@ -46,7 +46,7 @@ function createClient(opts, network) {
46
46
  } else {
47
47
  const rpcs = opts.rpcURLs.map(
48
48
  (url) => (0, import_viem.http)(url, {
49
- ...opts.httpClientOptions,
49
+ ...opts.httpTransportOptions,
50
50
  timeout: opts.timeout,
51
51
  retryCount: opts.retryCount
52
52
  })
@@ -62,11 +62,15 @@ function createClient(opts, network) {
62
62
  async function attachClient(options, network) {
63
63
  let { chainId, networkType } = network;
64
64
  const attachClient2 = createClient(options);
65
- if (!networkType) {
65
+ if (networkType) {
66
+ if (!chainId) {
67
+ chainId = (0, import_chain.getChain)(networkType).id;
68
+ }
69
+ } else {
66
70
  networkType = await (0, import_chain.detectNetwork)(attachClient2);
67
- }
68
- if (!chainId) {
69
- chainId = await attachClient2.getChainId();
71
+ if (!chainId) {
72
+ chainId = await attachClient2.getChainId();
73
+ }
70
74
  }
71
75
  return createClient(options, { networkType, chainId });
72
76
  }
@@ -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 [resp, migration, additional] = await Promise.all([
216
- this.client.multicall({
217
- contracts: accountsToCheck.map((o) => {
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,72 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
225
225
  args: [pool.configurator.address, o.creditAccount]
226
226
  };
227
227
  }),
228
- allowFailure: true
229
- }),
230
- this.getActiveMigrationBots(accountsToCheck, legacyMigrationBot),
231
- this.getActiveBots(accountsToCheck, additionalBots)
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) ? [bot, ca.creditManager, ca.creditAccount] : [bot, ca.creditAccount]
236
+ args: (0, import_constants.isV300)(cm.creditFacade.version) ? [legacyMigrationBot, ca.creditManager, ca.creditAccount] : [legacyMigrationBot, ca.creditAccount]
249
237
  };
250
- });
251
- }),
252
- allowFailure: true
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
+ ],
253
+ allowFailure: true,
254
+ batchSize: 0
253
255
  });
256
+ const legacyStart = 0;
257
+ const legacyEnd = accountsToCheck.length;
258
+ const legacy = allResp.slice(
259
+ legacyStart,
260
+ legacyEnd
261
+ );
262
+ const migrationStart = legacyEnd;
263
+ const migrationEnd = legacyMigrationBot ? migrationStart + accountsToCheck.length : migrationStart;
264
+ const migrationResp = allResp.slice(
265
+ migrationStart,
266
+ migrationEnd
267
+ );
268
+ const additionalStart = migrationEnd;
269
+ const additionalResp = allResp.slice(
270
+ additionalStart
271
+ );
272
+ return {
273
+ legacy,
274
+ additionalBots: this.getActiveBots(
275
+ accountsToCheck,
276
+ additionalBots,
277
+ additionalResp
278
+ ),
279
+ legacyMigration: this.getActiveMigrationBots(
280
+ accountsToCheck,
281
+ legacyMigrationBot,
282
+ migrationResp
283
+ )
284
+ };
285
+ }
286
+ getActiveBots(accountsToCheck, bots, result) {
287
+ if (result.length !== bots.length * accountsToCheck.length) {
288
+ console.error(
289
+ "result length mismatch",
290
+ result.length,
291
+ bots.length * accountsToCheck.length
292
+ );
293
+ }
254
294
  const botsByCAIndex = accountsToCheck.reduce((acc, _, index) => {
255
295
  const r = result.slice(index * bots.length, (index + 1) * bots.length);
256
296
  acc.push({
@@ -260,22 +300,15 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
260
300
  }, []);
261
301
  return botsByCAIndex;
262
302
  }
263
- async getActiveMigrationBots(accountsToCheck, bot) {
303
+ getActiveMigrationBots(accountsToCheck, bot, result) {
264
304
  if (bot) {
265
- const result = await this.client.multicall({
266
- contracts: accountsToCheck.map((ca) => {
267
- const cm = this.sdk.marketRegister.findCreditManager(
268
- ca.creditManager
269
- );
270
- return {
271
- abi: (0, import_constants.isV300)(cm.creditFacade.version) ? import_v300.iBotListV300Abi : import_generated.iBotListV310Abi,
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
- });
305
+ if (result.length !== accountsToCheck.length) {
306
+ console.error(
307
+ "result length mismatch for migration bots",
308
+ result.length,
309
+ accountsToCheck.length
310
+ );
311
+ }
279
312
  return { result, botAddress: bot };
280
313
  }
281
314
  return void 0;
@@ -92,7 +92,8 @@ class TokensMeta extends import_utils.AddressMap {
92
92
  functionName: "contractType"
93
93
  })
94
94
  ),
95
- allowFailure: true
95
+ allowFailure: true,
96
+ batchSize: 0
96
97
  });
97
98
  for (let i = 0; i < resp.length; i++) {
98
99
  if (resp[i].status === "success") {
@@ -26,10 +26,20 @@ var import_base = require("../../base/index.js");
26
26
  var import_constants = require("../../constants/index.js");
27
27
  var import_mappers = require("../../utils/mappers.js");
28
28
  class AbstractAddressProviderContract extends import_base.BaseContract {
29
- #addresses = {};
30
- constructor(options, args, addresses = {}) {
29
+ #addresses;
30
+ #overrides;
31
+ constructor(options, args, addresses) {
31
32
  super(options, args);
32
- this.#addresses = addresses;
33
+ this.#addresses = addresses?.addresses ?? {};
34
+ this.#overrides = addresses?.overrides ?? {};
35
+ for (const [contract, vs] of import_mappers.TypedObjectUtils.entries(this.#overrides)) {
36
+ for (const [version, address] of import_mappers.TypedObjectUtils.entries(vs)) {
37
+ this.#addresses[contract] = {
38
+ ...this.#addresses[contract],
39
+ [version]: address
40
+ };
41
+ }
42
+ }
33
43
  }
34
44
  setInternalAddress(key, address, version) {
35
45
  const k = (0, import_viem.isHex)(key) ? (0, import_viem.hexToString)(key, { size: 32 }) : key;
@@ -38,6 +48,13 @@ class AbstractAddressProviderContract extends import_base.BaseContract {
38
48
  }
39
49
  this.#addresses[k][version] = address;
40
50
  this.logger?.debug(`Set address for ${k}@${version} to ${address}`);
51
+ const overriden = this.#overrides[k]?.[version];
52
+ if (overriden) {
53
+ this.logger?.warn(
54
+ `address for ${k}@${version} was overriden, hardcode ${overriden} instead of ${address}`
55
+ );
56
+ this.#addresses[k][version] = overriden;
57
+ }
41
58
  }
42
59
  getAddress(contract, version = import_constants.NO_VERSION) {
43
60
  if (!this.#addresses[contract]) {
@@ -37,7 +37,7 @@ var import_viem2 = require("../../utils/viem/index.js");
37
37
  var import_AbstractAddressProviderContract = __toESM(require("./AbstractAddressProviderContract.js"));
38
38
  const abi = import_v300.iAddressProviderV300Abi;
39
39
  class AddressProviderV300Contract extends import_AbstractAddressProviderContract.default {
40
- constructor(options, address, version, addresses = {}) {
40
+ constructor(options, address, version, addresses) {
41
41
  super(
42
42
  options,
43
43
  {