@gearbox-protocol/sdk 9.16.1 → 10.0.0-next.1

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 (96) hide show
  1. package/dist/cjs/dev/AccountOpener.js +2 -5
  2. package/dist/cjs/dev/createAnvilClient.js +16 -13
  3. package/dist/cjs/dev/migrateFaucet.js +3 -6
  4. package/dist/cjs/permissionless/bindings/instance-manager.js +1 -1
  5. package/dist/cjs/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
  6. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +1 -1
  7. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +2 -2
  8. package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -2
  9. package/dist/cjs/sdk/GearboxSDK.js +70 -39
  10. package/dist/cjs/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +1 -1
  11. package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +1 -1
  12. package/dist/cjs/sdk/accounts/CreditAccountsServiceV300.js +1 -1
  13. package/dist/cjs/sdk/base/BaseContract.js +6 -9
  14. package/dist/cjs/sdk/base/SDKConstruct.js +4 -7
  15. package/dist/cjs/sdk/chain/chains.js +1 -1
  16. package/dist/cjs/sdk/chain/index.js +1 -3
  17. package/dist/cjs/sdk/core/BotListV3Contract.js +5 -5
  18. package/dist/cjs/sdk/core/GearStakingV3Contract.js +1 -1
  19. package/dist/cjs/sdk/core/address-provider/AbstractAddressProviderContract.js +1 -1
  20. package/dist/cjs/sdk/core/address-provider/AddressProviderV300Contract.js +2 -2
  21. package/dist/cjs/sdk/core/address-provider/createAddressProvider.js +1 -1
  22. package/dist/cjs/sdk/gauges/GaugeStakingService.js +1 -1
  23. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +3 -3
  24. package/dist/cjs/sdk/market/MarketRegister.js +20 -26
  25. package/dist/cjs/sdk/market/MarketSuite.js +1 -1
  26. package/dist/cjs/sdk/market/credit/CreditConfiguratorV300Contract.js +2 -2
  27. package/dist/cjs/sdk/market/credit/CreditConfiguratorV310Contract.js +2 -2
  28. package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
  29. package/dist/cjs/sdk/market/oracle/PriceOracleV300Contract.js +1 -1
  30. package/dist/cjs/sdk/market/pricefeeds/AbstractLPPriceFeed.js +1 -1
  31. package/dist/cjs/sdk/market/pricefeeds/BalancerStablePriceFeed.js +1 -1
  32. package/dist/cjs/sdk/market/pricefeeds/BalancerWeightedPriceFeed.js +1 -1
  33. package/dist/cjs/sdk/market/pricefeeds/CurveCryptoPriceFeed.js +1 -1
  34. package/dist/cjs/sdk/market/pricefeeds/CurveStablePriceFeed.js +1 -1
  35. package/dist/cjs/sdk/market/pricefeeds/CurveUSDPriceFeed.js +1 -1
  36. package/dist/cjs/sdk/market/pricefeeds/Erc4626PriceFeed.js +2 -2
  37. package/dist/cjs/sdk/market/pricefeeds/MellowLRTPriceFeed.js +1 -1
  38. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -2
  39. package/dist/cjs/sdk/market/pricefeeds/WstETHPriceFeed.js +1 -1
  40. package/dist/cjs/sdk/market/pricefeeds/YearnPriceFeed.js +1 -1
  41. package/dist/cjs/sdk/plugins/BasePlugin.js +3 -6
  42. package/dist/cjs/sdk/plugins/V300StalenessPeriodPlugin.js +1 -1
  43. package/dist/cjs/sdk/router/RouterV300Contract.js +4 -4
  44. package/dist/esm/dev/AccountOpener.js +3 -6
  45. package/dist/esm/dev/createAnvilClient.js +21 -14
  46. package/dist/esm/dev/migrateFaucet.js +4 -7
  47. package/dist/esm/permissionless/bindings/instance-manager.js +1 -1
  48. package/dist/esm/plugins/accounts-counter/AccountsCounterPlugin.js +1 -1
  49. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +1 -1
  50. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +2 -2
  51. package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -2
  52. package/dist/esm/sdk/GearboxSDK.js +78 -46
  53. package/dist/esm/sdk/accountMigration/AbstractMigrateCreditAccountsService.js +1 -1
  54. package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +1 -1
  55. package/dist/esm/sdk/accounts/CreditAccountsServiceV300.js +1 -1
  56. package/dist/esm/sdk/base/BaseContract.js +6 -9
  57. package/dist/esm/sdk/base/SDKConstruct.js +4 -7
  58. package/dist/esm/sdk/chain/chains.js +1 -1
  59. package/dist/esm/sdk/chain/index.js +0 -1
  60. package/dist/esm/sdk/core/BotListV3Contract.js +5 -5
  61. package/dist/esm/sdk/core/GearStakingV3Contract.js +1 -1
  62. package/dist/esm/sdk/core/address-provider/AbstractAddressProviderContract.js +1 -1
  63. package/dist/esm/sdk/core/address-provider/AddressProviderV300Contract.js +2 -2
  64. package/dist/esm/sdk/core/address-provider/createAddressProvider.js +1 -1
  65. package/dist/esm/sdk/gauges/GaugeStakingService.js +1 -1
  66. package/dist/esm/sdk/market/MarketConfiguratorContract.js +3 -3
  67. package/dist/esm/sdk/market/MarketRegister.js +20 -26
  68. package/dist/esm/sdk/market/MarketSuite.js +1 -1
  69. package/dist/esm/sdk/market/credit/CreditConfiguratorV300Contract.js +2 -2
  70. package/dist/esm/sdk/market/credit/CreditConfiguratorV310Contract.js +2 -2
  71. package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
  72. package/dist/esm/sdk/market/oracle/PriceOracleV300Contract.js +1 -1
  73. package/dist/esm/sdk/market/pricefeeds/AbstractLPPriceFeed.js +1 -1
  74. package/dist/esm/sdk/market/pricefeeds/BalancerStablePriceFeed.js +1 -1
  75. package/dist/esm/sdk/market/pricefeeds/BalancerWeightedPriceFeed.js +1 -1
  76. package/dist/esm/sdk/market/pricefeeds/CurveCryptoPriceFeed.js +1 -1
  77. package/dist/esm/sdk/market/pricefeeds/CurveStablePriceFeed.js +1 -1
  78. package/dist/esm/sdk/market/pricefeeds/CurveUSDPriceFeed.js +1 -1
  79. package/dist/esm/sdk/market/pricefeeds/Erc4626PriceFeed.js +2 -2
  80. package/dist/esm/sdk/market/pricefeeds/MellowLRTPriceFeed.js +1 -1
  81. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -2
  82. package/dist/esm/sdk/market/pricefeeds/WstETHPriceFeed.js +1 -1
  83. package/dist/esm/sdk/market/pricefeeds/YearnPriceFeed.js +1 -1
  84. package/dist/esm/sdk/plugins/BasePlugin.js +3 -6
  85. package/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js +1 -1
  86. package/dist/esm/sdk/router/RouterV300Contract.js +4 -4
  87. package/dist/types/dev/createAnvilClient.d.ts +1 -0
  88. package/dist/types/sdk/GearboxSDK.d.ts +51 -6
  89. package/dist/types/sdk/base/BaseContract.d.ts +0 -2
  90. package/dist/types/sdk/base/SDKConstruct.d.ts +2 -3
  91. package/dist/types/sdk/chain/index.d.ts +0 -1
  92. package/dist/types/sdk/plugins/BasePlugin.d.ts +1 -2
  93. package/package.json +1 -1
  94. package/dist/cjs/sdk/chain/Provider.js +0 -86
  95. package/dist/esm/sdk/chain/Provider.js +0 -61
  96. package/dist/types/sdk/chain/Provider.d.ts +0 -51
@@ -131,25 +131,22 @@ class MarketRegister extends import_base.SDKConstruct {
131
131
  );
132
132
  let markets = [];
133
133
  if (txs.length) {
134
- const [resp] = await (0, import_viem.simulateWithPriceUpdates)(
135
- this.provider.publicClient,
136
- {
137
- priceUpdates: txs,
138
- contracts: [
139
- {
140
- abi: import_marketCompressor.marketCompressorAbi,
141
- address: marketCompressorAddress,
142
- functionName: "getMarkets",
143
- args: [this.marketFilter]
144
- }
145
- ],
146
- blockNumber: this.sdk.currentBlock,
147
- gas: this.sdk.gasLimit
148
- }
149
- );
134
+ const [resp] = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
135
+ priceUpdates: txs,
136
+ contracts: [
137
+ {
138
+ abi: import_marketCompressor.marketCompressorAbi,
139
+ address: marketCompressorAddress,
140
+ functionName: "getMarkets",
141
+ args: [this.marketFilter]
142
+ }
143
+ ],
144
+ blockNumber: this.sdk.currentBlock,
145
+ gas: this.sdk.gasLimit
146
+ });
150
147
  markets = resp;
151
148
  } else {
152
- markets = await this.provider.publicClient.readContract({
149
+ markets = await this.client.readContract({
153
150
  abi: import_marketCompressor.marketCompressorAbi,
154
151
  address: marketCompressorAddress,
155
152
  functionName: "getMarkets",
@@ -190,15 +187,12 @@ class MarketRegister extends import_base.SDKConstruct {
190
187
  }
191
188
  this.#logger?.debug(`syncing prices on ${multicalls.length} oracles`);
192
189
  const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
193
- const oraclesStates = await (0, import_viem.simulateWithPriceUpdates)(
194
- this.provider.publicClient,
195
- {
196
- priceUpdates: txs,
197
- contracts: multicalls.map((mc) => mc.call),
198
- gas: this.sdk.gasLimit,
199
- blockNumber: this.sdk.currentBlock
200
- }
201
- );
190
+ const oraclesStates = await (0, import_viem.simulateWithPriceUpdates)(this.client, {
191
+ priceUpdates: txs,
192
+ contracts: multicalls.map((mc) => mc.call),
193
+ gas: this.sdk.gasLimit,
194
+ blockNumber: this.sdk.currentBlock
195
+ });
202
196
  for (let i = 0; i < multicalls.length; i++) {
203
197
  const handler = multicalls[i].onResult;
204
198
  const result = oraclesStates[i];
@@ -51,7 +51,7 @@ class MarketSuite extends import_base.SDKConstruct {
51
51
  this.treasury = marketData.treasury;
52
52
  for (const t of marketData.tokens) {
53
53
  sdk.tokensMeta.upsert(t.addr, t);
54
- sdk.provider.addressLabels.set(t.addr, t.symbol);
54
+ sdk.addressLabels.set(t.addr, t.symbol);
55
55
  }
56
56
  this.pool = new import_pool.PoolSuite(sdk, marketData);
57
57
  for (let i = 0; i < marketData.creditManagers.length; i++) {
@@ -71,9 +71,9 @@ class CreditConfiguratorV300Contract extends import_base.BaseContract {
71
71
  }
72
72
  }
73
73
  async checkRamps() {
74
- let fromBlock = this.sdk.currentBlock - import_constants.RAMP_DURATION_BY_NETWORK[this.sdk.provider.networkType];
74
+ let fromBlock = this.sdk.currentBlock - import_constants.RAMP_DURATION_BY_NETWORK[this.sdk.networkType];
75
75
  fromBlock = fromBlock < 0n ? 0n : fromBlock;
76
- const logs = await this.provider.publicClient.getContractEvents({
76
+ const logs = await this.client.getContractEvents({
77
77
  address: this.address,
78
78
  abi: this.abi,
79
79
  fromBlock,
@@ -58,9 +58,9 @@ class CreditConfiguratorV310Contract extends import_base.BaseContract {
58
58
  }
59
59
  }
60
60
  async checkRamps() {
61
- let fromBlock = this.sdk.currentBlock - import_constants.RAMP_DURATION_BY_NETWORK[this.sdk.provider.networkType];
61
+ let fromBlock = this.sdk.currentBlock - import_constants.RAMP_DURATION_BY_NETWORK[this.sdk.networkType];
62
62
  fromBlock = fromBlock < 0n ? 0n : fromBlock;
63
- const logs = await this.provider.publicClient.getContractEvents({
63
+ const logs = await this.client.getContractEvents({
64
64
  address: this.address,
65
65
  abi: this.abi,
66
66
  fromBlock,
@@ -263,7 +263,7 @@ class PriceOracleBaseContract extends import_base.BaseContract {
263
263
  this.dirty = false;
264
264
  }
265
265
  #labelPriceFeed(address, usage, token) {
266
- this.sdk.provider.addressLabels.set(address, (oldLabel) => {
266
+ this.sdk.addressLabels.set(address, (oldLabel) => {
267
267
  const symbol = this.sdk.tokensMeta.symbol(token);
268
268
  let pricefeedTag = `${symbol}.${usage}`;
269
269
  if (oldLabel) {
@@ -109,7 +109,7 @@ class PriceOracleV300Contract extends import_PriceOracleBaseContract.PriceOracle
109
109
  return [token, reserve];
110
110
  }
111
111
  const tickers = Object.values(
112
- import_sdk_gov_legacy.tickerInfoTokensByNetwork[this.sdk.provider.networkType]
112
+ import_sdk_gov_legacy.tickerInfoTokensByNetwork[this.sdk.networkType]
113
113
  ).flat();
114
114
  const ticker = tickers.find(
115
115
  (t) => t.priceFeed.toLowerCase() === priceFeed.toLowerCase()
@@ -92,7 +92,7 @@ class AbstractLPPriceFeedContract extends import_AbstractPriceFeed.AbstractPrice
92
92
  return lowerBound;
93
93
  }
94
94
  async currentLowerBound() {
95
- return await this.sdk.provider.publicClient.readContract({
95
+ return await this.sdk.client.readContract({
96
96
  abi: import_abi.ilpPriceFeedAbi,
97
97
  address: this.address,
98
98
  functionName: "lowerBound"
@@ -32,7 +32,7 @@ class BalancerStablePriceFeedContract extends import_AbstractLPPriceFeed.Abstrac
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iBalancerStablePoolAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "getRate"
@@ -52,7 +52,7 @@ class BalancerWeightedPriceFeedContract extends import_AbstractLPPriceFeed.Abstr
52
52
  this.weights = decoded[3];
53
53
  }
54
54
  async getValue() {
55
- return await this.sdk.provider.publicClient.readContract({
55
+ return await this.sdk.client.readContract({
56
56
  abi: import_abi.iBalancerWeightedPoolAbi,
57
57
  address: this.lpContract,
58
58
  functionName: "getRate"
@@ -32,7 +32,7 @@ class CurveCryptoPriceFeedContract extends import_AbstractLPPriceFeed.AbstractLP
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iCurvePoolAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "get_virtual_price"
@@ -32,7 +32,7 @@ class CurveStablePriceFeedContract extends import_AbstractLPPriceFeed.AbstractLP
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iCurvePoolAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "get_virtual_price"
@@ -32,7 +32,7 @@ class CurveUSDPriceFeedContract extends import_AbstractLPPriceFeed.AbstractLPPri
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iCurvePoolAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "get_virtual_price"
@@ -34,12 +34,12 @@ class Erc4626PriceFeedContract extends import_AbstractLPPriceFeed.AbstractLPPric
34
34
  });
35
35
  }
36
36
  async getValue() {
37
- const decimals = await this.sdk.provider.publicClient.readContract({
37
+ const decimals = await this.sdk.client.readContract({
38
38
  abi: import_iERC20.ierc20Abi,
39
39
  address: this.lpContract,
40
40
  functionName: "decimals"
41
41
  });
42
- const price = await this.sdk.provider.publicClient.readContract({
42
+ const price = await this.sdk.client.readContract({
43
43
  abi: import_viem.erc4626Abi,
44
44
  address: this.lpContract,
45
45
  functionName: "convertToAssets",
@@ -32,7 +32,7 @@ class MellowLRTPriceFeedContract extends import_AbstractLPPriceFeed.AbstractLPPr
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- const stack = await this.sdk.provider.publicClient.readContract({
35
+ const stack = await this.sdk.client.readContract({
36
36
  abi: import_abi.iMellowVaultAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "calculateStack"
@@ -168,7 +168,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
168
168
  import_constants.VERSION_RANGE_310
169
169
  );
170
170
  const blockParam = block ?? { blockNumber: this.sdk.currentBlock };
171
- const result = await this.provider.publicClient.readContract({
171
+ const result = await this.client.readContract({
172
172
  address: priceFeedCompressorAddress,
173
173
  abi: import_priceFeedCompressor.priceFeedCompressorAbi,
174
174
  functionName: "loadPriceFeedTree",
@@ -225,7 +225,7 @@ class PriceFeedRegister extends import_base.SDKConstruct {
225
225
  { configurators, pools },
226
226
  `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`
227
227
  );
228
- const result = await this.provider.publicClient.readContract({
228
+ const result = await this.client.readContract({
229
229
  address: priceFeedCompressorAddress,
230
230
  abi: import_priceFeedCompressor.priceFeedCompressorAbi,
231
231
  functionName: "getUpdatablePriceFeeds",
@@ -32,7 +32,7 @@ class WstETHPriceFeedContract extends import_AbstractLPPriceFeed.AbstractLPPrice
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iwstEthAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "stEthPerToken"
@@ -32,7 +32,7 @@ class YearnPriceFeedContract extends import_AbstractLPPriceFeed.AbstractLPPriceF
32
32
  });
33
33
  }
34
34
  async getValue() {
35
- return await this.sdk.provider.publicClient.readContract({
35
+ return await this.sdk.client.readContract({
36
36
  abi: import_abi.iyVaultAbi,
37
37
  address: this.lpContract,
38
38
  functionName: "pricePerShare"
@@ -50,17 +50,14 @@ class BasePlugin {
50
50
  async syncState() {
51
51
  await this.load(false);
52
52
  }
53
- get provider() {
54
- return this.sdk.provider;
55
- }
56
53
  get network() {
57
- return this.provider.networkType;
54
+ return this.sdk.networkType;
58
55
  }
59
56
  get client() {
60
- return this.provider.publicClient;
57
+ return this.sdk.client;
61
58
  }
62
59
  labelAddress(address) {
63
- return this.provider.addressLabels.get(address);
60
+ return this.sdk.labelAddress(address);
64
61
  }
65
62
  }
66
63
  // Annotate the CommonJS export names for ESM import in node:
@@ -34,7 +34,7 @@ class V300StalenessPeriodPlugin extends import_BasePlugin.BasePlugin {
34
34
  #events = [];
35
35
  set sdk(sdk) {
36
36
  super.sdk = sdk;
37
- this.#syncedTo = (sdk.provider.chain.firstBlock ?? 1n) - 1n;
37
+ this.#syncedTo = (sdk.chain.firstBlock ?? 1n) - 1n;
38
38
  }
39
39
  get sdk() {
40
40
  return super.sdk;
@@ -54,7 +54,7 @@ class RouterV300Contract extends import_AbstractRouterContract.AbstractRouterCon
54
54
  abi: import_routerV300.iRouterV300Abi,
55
55
  version
56
56
  });
57
- this.#connectors = (0, import_sdk_gov_legacy.getConnectors)(sdk.provider.networkType);
57
+ this.#connectors = (0, import_sdk_gov_legacy.getConnectors)(sdk.networkType);
58
58
  }
59
59
  /**
60
60
  * Implements {@link IRouterContract.findAllSwaps}
@@ -282,7 +282,7 @@ class RouterV300Contract extends import_AbstractRouterContract.AbstractRouterCon
282
282
  }));
283
283
  const pathOptions = import_PathOptionFactory.PathOptionFactory.generatePathOptions(
284
284
  ca.tokens,
285
- this.provider.networkType,
285
+ this.networkType,
286
286
  LOOPS_PER_TX
287
287
  );
288
288
  const connectors = this.getAvailableConnectors(cm.collateralTokens);
@@ -335,12 +335,12 @@ class RouterV300Contract extends import_AbstractRouterContract.AbstractRouterCon
335
335
  Lisk: "0x0",
336
336
  Plasma: "0x0"
337
337
  };
338
- const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.provider.networkType];
338
+ const pendleRouter = PENDLE_ROUTER_BY_NETWORK[this.sdk.networkType];
339
339
  const pendleAdapter = cm.creditManager.adapters.mustGet(pendleRouter);
340
340
  const pendleSwapper = (0, import_viem.getContract)({
341
341
  address: pendleSwapperAddress,
342
342
  abi: import_routerV300.iSwapperV300Abi,
343
- client: this.sdk.provider.publicClient
343
+ client: this.sdk.client
344
344
  });
345
345
  const result = await pendleSwapper.simulate.getBestDirectPairSwap([
346
346
  {
@@ -21,7 +21,7 @@ import {
21
21
  } from "../sdk/index.js";
22
22
  import { iDegenNftv2Abi } from "./abi.js";
23
23
  import { claimFromFaucet } from "./claimFromFaucet.js";
24
- import { createAnvilClient } from "./createAnvilClient.js";
24
+ import { extendAnvilClient } from "./createAnvilClient.js";
25
25
  import { createMinter } from "./mint/index.js";
26
26
  const DIRECT_TRANSFERS_QUOTA = 10000n;
27
27
  class OpenTxRevertedError extends BaseError {
@@ -58,10 +58,7 @@ class AccountOpener extends SDKConstruct {
58
58
  this.#service = service;
59
59
  this.#allowMint = allowMint;
60
60
  this.#logger = childLogger("AccountOpener", service.sdk.logger);
61
- this.#anvil = createAnvilClient({
62
- chain: service.sdk.provider.chain,
63
- transport: service.sdk.provider.transport
64
- });
61
+ this.#anvil = extendAnvilClient(service.sdk.client);
65
62
  try {
66
63
  this.#faucet = faucet ?? service.sdk.addressProvider.getAddress("FAUCET");
67
64
  } catch (_e) {
@@ -405,7 +402,7 @@ class AccountOpener extends SDKConstruct {
405
402
  }
406
403
  async #depositToPool(pool, depositor, amount) {
407
404
  const { underlying, address } = pool;
408
- const poolName = this.sdk.provider.addressLabels.get(address);
405
+ const poolName = this.sdk.labelAddress(address);
409
406
  const poolData = {
410
407
  pool: address,
411
408
  token: underlying,
@@ -1,23 +1,29 @@
1
- import { createTestClient, publicActions, toHex, walletActions } from "viem";
1
+ import {
2
+ createPublicClient,
3
+ testActions,
4
+ toHex,
5
+ walletActions
6
+ } from "viem";
7
+ function extendAnvilClient(client) {
8
+ return client.extend(testActions({ mode: "anvil" })).extend(walletActions).extend((c) => ({
9
+ anvilNodeInfo: () => anvilNodeInfo(c),
10
+ isAnvil: () => isAnvil(c),
11
+ evmMineDetailed: (timestamp) => evmMineDetailed(c, timestamp)
12
+ }));
13
+ }
2
14
  function createAnvilClient({
3
15
  chain,
4
16
  transport,
5
17
  cacheTime = 0,
6
18
  pollingInterval = 50
7
19
  }) {
8
- return createTestClient(
9
- {
10
- chain,
11
- mode: "anvil",
12
- transport,
13
- cacheTime,
14
- pollingInterval
15
- }
16
- ).extend(publicActions).extend(walletActions).extend((client) => ({
17
- anvilNodeInfo: () => anvilNodeInfo(client),
18
- isAnvil: () => isAnvil(client),
19
- evmMineDetailed: (timestamp) => evmMineDetailed(client, timestamp)
20
- }));
20
+ const client = createPublicClient({
21
+ chain,
22
+ transport,
23
+ cacheTime,
24
+ pollingInterval
25
+ });
26
+ return extendAnvilClient(client);
21
27
  }
22
28
  async function isAnvil(client) {
23
29
  try {
@@ -51,5 +57,6 @@ export {
51
57
  anvilNodeInfo,
52
58
  createAnvilClient,
53
59
  evmMineDetailed,
60
+ extendAnvilClient,
54
61
  isAnvil
55
62
  };
@@ -2,12 +2,9 @@ import { formatEther, parseEther, stringToHex } from "viem";
2
2
  import { iAddressProviderV310Abi } from "../abi/310/generated.js";
3
3
  import { iAddressProviderV300Abi } from "../abi/v300.js";
4
4
  import { ADDRESS_PROVIDER } from "../sdk/index.js";
5
- import { createAnvilClient } from "./createAnvilClient.js";
5
+ import { extendAnvilClient } from "./createAnvilClient.js";
6
6
  async function unsafeMigrateFaucet(sdk, faucet) {
7
- const anvil = createAnvilClient({
8
- chain: sdk.provider.chain,
9
- transport: sdk.provider.transport
10
- });
7
+ const anvil = extendAnvilClient(sdk.client);
11
8
  let faucetAddr;
12
9
  let owner;
13
10
  if (faucet) {
@@ -23,7 +20,7 @@ async function unsafeMigrateFaucet(sdk, faucet) {
23
20
  contracts: [
24
21
  {
25
22
  abi: iAddressProviderV300Abi,
26
- address: ADDRESS_PROVIDER[sdk.provider.networkType],
23
+ address: ADDRESS_PROVIDER[sdk.networkType],
27
24
  functionName: "getAddressOrRevert",
28
25
  args: [stringToHex("FAUCET", { size: 32 }), 0n]
29
26
  },
@@ -76,7 +73,7 @@ async function migrateFaucet(sdk, faucet) {
76
73
  } catch (e) {
77
74
  sdk.logger?.error(`faucet migration failed: ${e}`);
78
75
  }
79
- return sdk.provider.publicClient.readContract({
76
+ return sdk.client.readContract({
80
77
  abi: iAddressProviderV310Abi,
81
78
  address: sdk.addressProvider.address,
82
79
  functionName: "getAddressOrRevert",
@@ -127,7 +127,7 @@ class InstanceManagerContract extends BaseContract {
127
127
  args: decoded ? {
128
128
  target,
129
129
  functionName: decoded.functionName,
130
- args: json_stringify(decoded.args)
130
+ data: json_stringify(decoded.args)
131
131
  } : {
132
132
  target,
133
133
  data
@@ -34,7 +34,7 @@ class AccountsCounterPlugin extends BasePlugin {
34
34
  VERSION_RANGE_310
35
35
  );
36
36
  const cms = this.sdk.marketRegister.creditManagers;
37
- const count = await this.sdk.provider.publicClient.multicall({
37
+ const count = await this.sdk.client.multicall({
38
38
  contracts: cms.flatMap(
39
39
  (cm) => [
40
40
  {
@@ -14,7 +14,7 @@ class DegenDistributorsPlugin extends BasePlugin {
14
14
  }, {})
15
15
  );
16
16
  this.sdk.logger?.debug(
17
- `loading degen distributors for ${this.sdk.provider.networkType}`
17
+ `loading degen distributors for ${this.sdk.networkType}`
18
18
  );
19
19
  const distributors = await Promise.allSettled(
20
20
  configurators.map((cfg) => cfg.getPeripheryContract("DEGEN_DISTRIBUTOR"))
@@ -14,7 +14,7 @@ class Pools7DAgoPlugin extends BasePlugin {
14
14
  if (!force && this.loaded) {
15
15
  return this.state;
16
16
  }
17
- const targetBlock = this.sdk.currentBlock - BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.provider.networkType];
17
+ const targetBlock = this.sdk.currentBlock - BLOCKS_PER_WEEK_BY_NETWORK[this.sdk.networkType];
18
18
  const [marketCompressorAddress] = this.sdk.addressProvider.mustGetLatest(
19
19
  AP_MARKET_COMPRESSOR,
20
20
  VERSION_RANGE_310
@@ -23,7 +23,7 @@ class Pools7DAgoPlugin extends BasePlugin {
23
23
  `loading pools 7d ago with market compressor ${marketCompressorAddress}`
24
24
  );
25
25
  const markets = this.sdk.marketRegister.markets;
26
- const resp = await this.provider.publicClient.multicall({
26
+ const resp = await this.client.multicall({
27
27
  allowFailure: true,
28
28
  contracts: markets.map(
29
29
  (m) => ({
@@ -25,7 +25,7 @@ class ZappersPlugin extends BasePlugin {
25
25
  `loading zappers with periphery compressor ${pcAddr}`
26
26
  );
27
27
  const markets = this.sdk.marketRegister.markets;
28
- const resp = await this.provider.publicClient.multicall({
28
+ const resp = await this.client.multicall({
29
29
  contracts: markets.map(
30
30
  (m) => ({
31
31
  abi: peripheryCompressorAbi,
@@ -115,7 +115,7 @@ class ZappersPlugin extends BasePlugin {
115
115
  const extraZappersTokens = this.extraZappers.values().flatMap((l) => l.flatMap((z) => [z.tokenIn, z.tokenOut]));
116
116
  for (const t of [...zappersTokens, ...extraZappersTokens]) {
117
117
  this.sdk.tokensMeta.upsert(t.addr, t);
118
- this.sdk.provider.addressLabels.set(t.addr, t.symbol);
118
+ this.sdk.addressLabels.set(t.addr, t.symbol);
119
119
  }
120
120
  }
121
121
  }