@gearbox-protocol/deploy-tools 5.2.0 → 5.2.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 (2) hide show
  1. package/dist/index.mjs +116 -113
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -361571,13 +361571,18 @@ var PriceFeedRegister = class extends SDKConstruct {
361571
361571
  AP_MARKET_COMPRESSOR,
361572
361572
  310
361573
361573
  );
361574
+ const configurators = marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address);
361575
+ this.logger?.debug(
361576
+ { configurators, pools },
361577
+ "calling getUpdatablePriceFeeds"
361578
+ );
361574
361579
  const result = await this.provider.publicClient.readContract({
361575
361580
  address: marketCompressorAddress,
361576
361581
  abi: iMarketCompressorAbi,
361577
361582
  functionName: "getUpdatablePriceFeeds",
361578
361583
  args: [
361579
361584
  {
361580
- configurators: marketConfigurators ?? this.sdk.marketRegister.marketConfigurators.map((mc) => mc.address),
361585
+ configurators,
361581
361586
  pools: pools ?? [],
361582
361587
  underlying: ADDRESS_0X0
361583
361588
  }
@@ -362296,7 +362301,7 @@ var MarketRegister = class extends SDKConstruct {
362296
362301
  await this.#loadMarkets([], pools);
362297
362302
  }
362298
362303
  }
362299
- async #loadMarkets(marketConfigurators, pools, ignoreUpdateablePrices) {
362304
+ async #loadMarkets(configurators, pools, ignoreUpdateablePrices) {
362300
362305
  const marketCompressorAddress = this.sdk.addressProvider.getAddress(
362301
362306
  AP_MARKET_COMPRESSOR,
362302
362307
  310
@@ -362304,12 +362309,13 @@ var MarketRegister = class extends SDKConstruct {
362304
362309
  let txs = [];
362305
362310
  if (!ignoreUpdateablePrices) {
362306
362311
  await this.sdk.priceFeeds.preloadUpdatablePriceFeeds(
362307
- marketConfigurators,
362312
+ configurators,
362308
362313
  pools
362309
362314
  );
362310
362315
  const updates = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
362311
362316
  txs = updates.txs;
362312
362317
  }
362318
+ this.#logger?.debug({ configurators, pools }, "calling getMarkets");
362313
362319
  const resp = await simulateMulticall(this.provider.publicClient, {
362314
362320
  contracts: [
362315
362321
  ...txs.map(rawTxToMulticallPriceUpdate),
@@ -362319,7 +362325,7 @@ var MarketRegister = class extends SDKConstruct {
362319
362325
  functionName: "getMarkets",
362320
362326
  args: [
362321
362327
  {
362322
- configurators: marketConfigurators,
362328
+ configurators,
362323
362329
  pools,
362324
362330
  underlying: ADDRESS_0X0
362325
362331
  }
@@ -363865,7 +363871,7 @@ var GearboxSDK = class _GearboxSDK {
363865
363871
  networkType
363866
363872
  });
363867
363873
  logger2?.debug(
363868
- { networkType, chainId, addressProvider },
363874
+ { networkType, chainId, addressProvider, marketConfigurators },
363869
363875
  "attaching gearbox sdk"
363870
363876
  );
363871
363877
  return new _GearboxSDK({
@@ -382244,7 +382250,7 @@ var container = new Container();
382244
382250
 
382245
382251
  // ../../packages/node/dist/EtherscanVerifier.js
382246
382252
  import { mkdirSync as mkdirSync2 } from "node:fs";
382247
- import { readFile as readFile4, writeFile as writeFile2 } from "node:fs/promises";
382253
+ import { readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
382248
382254
  import path4 from "node:path";
382249
382255
 
382250
382256
  // ../../packages/shared/dist/etherscan.js
@@ -388267,7 +388273,7 @@ async function pRetry(input, options) {
388267
388273
  }
388268
388274
 
388269
388275
  // ../../packages/node/dist/ProviderBase.js
388270
- import { readFile as readFile3 } from "node:fs/promises";
388276
+ import { readFile as readFile4 } from "node:fs/promises";
388271
388277
  import { setTimeout as setTimeout2 } from "node:timers/promises";
388272
388278
 
388273
388279
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/dev/index.mjs
@@ -388414,6 +388420,7 @@ function privateKeyToAccount(privateKey, options = {}) {
388414
388420
  }
388415
388421
 
388416
388422
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/dev/index.mjs
388423
+ import { writeFile as writeFile2, readFile as readFile3 } from "node:fs/promises";
388417
388424
  function createAnvilClient({
388418
388425
  chain,
388419
388426
  transport
@@ -388727,6 +388734,94 @@ var AccountOpener = class {
388727
388734
  return this.#service.sdk;
388728
388735
  }
388729
388736
  };
388737
+ var SDKExample = class {
388738
+ #sdk;
388739
+ #logger;
388740
+ constructor(logger2) {
388741
+ this.#logger = logger2;
388742
+ }
388743
+ async run(opts) {
388744
+ const {
388745
+ addressProvider: ap,
388746
+ addressProviderJson,
388747
+ marketConfigurator: mc,
388748
+ marketConfiguratorJson,
388749
+ anvilUrl = "http://127.0.0.1:8545",
388750
+ outFile
388751
+ } = opts;
388752
+ const addressProvider = await this.#readConfigAddress(
388753
+ "addressProvider",
388754
+ ap,
388755
+ addressProviderJson
388756
+ );
388757
+ const marketConfigurator = await this.#readConfigAddress(
388758
+ "marketConfigurator",
388759
+ mc,
388760
+ marketConfiguratorJson
388761
+ );
388762
+ this.#sdk = await GearboxSDK.attach({
388763
+ rpcURLs: [anvilUrl],
388764
+ timeout: 48e4,
388765
+ addressProvider,
388766
+ logger: this.#logger,
388767
+ ignoreUpdateablePrices: true,
388768
+ marketConfigurators: [marketConfigurator]
388769
+ });
388770
+ const puTx = await this.#sdk.priceFeeds.getUpdatePriceFeedsTx([
388771
+ marketConfigurator
388772
+ ]);
388773
+ const updater = createWalletClient({
388774
+ account: privateKeyToAccount(
388775
+ "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
388776
+ // well-known anvil private key
388777
+ ),
388778
+ transport: http(anvilUrl)
388779
+ });
388780
+ const publicClient = createPublicClient({
388781
+ transport: http(anvilUrl)
388782
+ });
388783
+ const hash2 = await sendRawTx(updater, { tx: puTx });
388784
+ await publicClient.waitForTransactionReceipt({ hash: hash2 });
388785
+ await this.#sdk.marketRegister.loadMarkets([marketConfigurator], true);
388786
+ this.#logger?.info("attached sdk");
388787
+ if (outFile) {
388788
+ try {
388789
+ await writeFile2(
388790
+ outFile,
388791
+ json_stringify(this.#sdk.stateHuman()),
388792
+ "utf-8"
388793
+ );
388794
+ } catch (e) {
388795
+ this.#logger?.error(`failed to write to ${outFile}: ${e}`);
388796
+ }
388797
+ }
388798
+ }
388799
+ async #readConfigAddress(name, value, file) {
388800
+ let result = value;
388801
+ if (!result) {
388802
+ if (!file) {
388803
+ throw new Error(`${name} is not specified`);
388804
+ }
388805
+ this.#logger?.debug(`reading ${name} json ${file}`);
388806
+ const apFile = await readFile3(file, "utf-8").then(JSON.parse);
388807
+ result = apFile[name];
388808
+ }
388809
+ if (!result) {
388810
+ throw new Error(`${name} is not specified`);
388811
+ }
388812
+ if (!isAddress(result)) {
388813
+ throw new Error(`${name} is not a valid address: ${result}`);
388814
+ }
388815
+ this.#logger?.info(`using ${name} ${result}`);
388816
+ return result;
388817
+ }
388818
+ get sdk() {
388819
+ if (!this.#sdk) {
388820
+ throw new Error("sdk is not attached");
388821
+ }
388822
+ return this.#sdk;
388823
+ }
388824
+ };
388730
388825
  var iaclAbi2 = [
388731
388826
  {
388732
388827
  type: "function",
@@ -390242,7 +390337,7 @@ var ProviderBase = class {
390242
390337
  if (this.#options.addressProviderJson) {
390243
390338
  try {
390244
390339
  this.logger.debug(`reading address provider json ${this.#options.addressProviderJson}`);
390245
- const gov = await readFile3(this.#options.addressProviderJson, "utf-8").then(JSON.parse);
390340
+ const gov = await readFile4(this.#options.addressProviderJson, "utf-8").then(JSON.parse);
390246
390341
  if (gov.network !== this.#network) {
390247
390342
  throw new NetworkMismatchError(this.#network, gov.network);
390248
390343
  }
@@ -390261,7 +390356,7 @@ var ProviderBase = class {
390261
390356
  if (this.#options.governanceJson) {
390262
390357
  try {
390263
390358
  this.logger.debug(`reading governance json ${this.#options.governanceJson}`);
390264
- const gov = await readFile3(this.#options.governanceJson, "utf-8").then(JSON.parse);
390359
+ const gov = await readFile4(this.#options.governanceJson, "utf-8").then(JSON.parse);
390265
390360
  if (gov.network !== this.#network) {
390266
390361
  throw new NetworkMismatchError(this.#network, gov.network);
390267
390362
  }
@@ -390438,7 +390533,7 @@ var EtherscanVerifier = class extends ProviderBase {
390438
390533
  async #getCached(address) {
390439
390534
  try {
390440
390535
  const cacheFile = path4.resolve(this.cacheDir, `${address.toLowerCase()}.json`);
390441
- const content = await readFile4(cacheFile, "utf8");
390536
+ const content = await readFile5(cacheFile, "utf8");
390442
390537
  const resp = json_parse(content);
390443
390538
  this.#logger.trace(`cache hit for ${address}`);
390444
390539
  return resp;
@@ -390451,7 +390546,7 @@ var EtherscanVerifier = class extends ProviderBase {
390451
390546
  }
390452
390547
  async #saveCached(address, result) {
390453
390548
  const cacheFile = path4.resolve(this.cacheDir, `${address.toLowerCase()}.json`);
390454
- await writeFile2(cacheFile, json_stringify(result));
390549
+ await writeFile3(cacheFile, json_stringify(result));
390455
390550
  }
390456
390551
  async #fetch(address) {
390457
390552
  const url = `${this.etherscanBase}/api?module=contract&action=getsourcecode&address=${address}&apikey=${this.etherscanApiKey}`;
@@ -390487,7 +390582,7 @@ var EtherscanVerifier = class extends ProviderBase {
390487
390582
 
390488
390583
  // ../../packages/node/dist/tree/GearboxAddressTree.js
390489
390584
  import { mkdirSync as mkdirSync3 } from "node:fs";
390490
- import { readFile as readFile5, writeFile as writeFile3 } from "node:fs/promises";
390585
+ import { readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
390491
390586
  import path5 from "node:path";
390492
390587
 
390493
390588
  // ../../packages/types/dist/addresses.js
@@ -392834,7 +392929,7 @@ var GearboxAddressTree = class _GearboxAddressTree extends ProviderBase {
392834
392929
  return [];
392835
392930
  }
392836
392931
  try {
392837
- const content = await readFile5(this.outFile, "utf-8").then(json_parse);
392932
+ const content = await readFile6(this.outFile, "utf-8").then(json_parse);
392838
392933
  if (content.version !== _GearboxAddressTree.version) {
392839
392934
  this.logger.warn(`ignoring cache file because it has version ${content.version}, but we need ${_GearboxAddressTree.version}`);
392840
392935
  return [];
@@ -392859,7 +392954,7 @@ var GearboxAddressTree = class _GearboxAddressTree extends ProviderBase {
392859
392954
  version: _GearboxAddressTree.version,
392860
392955
  tree: Object.fromEntries(this.#visited)
392861
392956
  };
392862
- await writeFile3(this.outFile, json_stringify(content), "utf-8");
392957
+ await writeFile4(this.outFile, json_stringify(content), "utf-8");
392863
392958
  this.logger.trace(`saved to ${this.#outFile}`);
392864
392959
  }
392865
392960
  async #process(entry, block) {
@@ -392945,7 +393040,7 @@ import path7 from "node:path";
392945
393040
 
392946
393041
  // ../../packages/node/dist/meta/MetaRepo.js
392947
393042
  import { mkdirSync as mkdirSync4 } from "node:fs";
392948
- import { readFile as readFile6 } from "node:fs/promises";
393043
+ import { readFile as readFile7 } from "node:fs/promises";
392949
393044
  import path6 from "node:path";
392950
393045
  var META_REPO = "deploy-v3";
392951
393046
  var MetaRepo = class {
@@ -392987,7 +393082,7 @@ var MetaRepo = class {
392987
393082
  for (const f of files) {
392988
393083
  const fname = path6.basename(f, `.json`);
392989
393084
  if (isAddress(fname)) {
392990
- const meta2 = await readFile6(path6.resolve(metaRoot, f), "utf-8").then(json_parse);
393085
+ const meta2 = await readFile7(path6.resolve(metaRoot, f), "utf-8").then(json_parse);
392991
393086
  if (!meta2.encodedConstructorArgs.startsWith("0x")) {
392992
393087
  throw new Error(`expect encodedConstructorArgs for ${fname} to start with '0x'`);
392993
393088
  }
@@ -395884,6 +395979,7 @@ var ZeroLT = class extends ProviderBase {
395884
395979
  for (const cm of cms) {
395885
395980
  await setLTZero(this.client, {
395886
395981
  ...cm,
395982
+ // fake v3.0 to v3.1 compatibility
395887
395983
  baseParams: {
395888
395984
  addr: cm.addr
395889
395985
  }
@@ -396971,99 +397067,6 @@ function audit() {
396971
397067
  // src/commands/open-accounts.ts
396972
397068
  import { writeFile as writeFile5 } from "node:fs/promises";
396973
397069
  import path8 from "node:path";
396974
-
396975
- // src/commands/sdk/SdkExample.ts
396976
- import { readFile as readFile7, writeFile as writeFile4 } from "node:fs/promises";
396977
- var SdkExample = class {
396978
- #sdk;
396979
- async run(opts) {
396980
- let {
396981
- addressProvider,
396982
- addressProviderJson,
396983
- marketConfiguratorJson,
396984
- anvilUrl = "http://127.0.0.1:8545",
396985
- outFile
396986
- } = opts;
396987
- let marketConfigurator;
396988
- try {
396989
- const mc = await readFile7(marketConfiguratorJson, "utf-8").then(
396990
- JSON.parse
396991
- );
396992
- marketConfigurator = mc.marketConfigurator;
396993
- if (!isAddress(marketConfigurator)) {
396994
- throw new Error("marketConfigurator is not a valid address");
396995
- }
396996
- } catch (e) {
396997
- throw new Error(
396998
- `cannot read market configurator json ${marketConfiguratorJson}: ${e}`
396999
- );
397000
- }
397001
- if (!addressProvider) {
397002
- if (!addressProviderJson) {
397003
- throw new Error("addressProvider is not specified");
397004
- }
397005
- log_default.debug(`reading address provider json ${addressProviderJson}`);
397006
- const apFile = await readFile7(addressProviderJson, "utf-8").then(
397007
- JSON.parse
397008
- );
397009
- addressProvider = apFile.addressProvider;
397010
- }
397011
- if (!addressProvider) {
397012
- throw new Error("addressProvider is not specified");
397013
- }
397014
- log_default.info(`using address provider ${addressProvider}`);
397015
- if (!isAddress(addressProvider)) {
397016
- throw new Error("addressProvider is not a valid address");
397017
- }
397018
- this.#sdk = await GearboxSDK.attach({
397019
- rpcURLs: [anvilUrl],
397020
- timeout: 48e4,
397021
- addressProvider,
397022
- logger: log_default,
397023
- ignoreUpdateablePrices: true,
397024
- marketConfigurators: [marketConfigurator]
397025
- });
397026
- const puTx = await this.#sdk.priceFeeds.getUpdatePriceFeedsTx(
397027
- GEARBOX_RISK_CURATORS[this.#sdk.provider.networkType]
397028
- );
397029
- const updater = createWalletClient({
397030
- account: privateKeyToAccount(
397031
- "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
397032
- // well-known anvil private key
397033
- ),
397034
- transport: http(anvilUrl)
397035
- });
397036
- const publicClient = createPublicClient({
397037
- transport: http(anvilUrl)
397038
- });
397039
- const hash2 = await sendRawTx(updater, { tx: puTx });
397040
- await publicClient.waitForTransactionReceipt({ hash: hash2 });
397041
- await this.#sdk.marketRegister.loadMarkets(
397042
- GEARBOX_RISK_CURATORS[this.#sdk.provider.networkType],
397043
- true
397044
- );
397045
- log_default.info("attached sdk");
397046
- if (outFile) {
397047
- try {
397048
- await writeFile4(
397049
- outFile,
397050
- json_stringify(this.#sdk.stateHuman()),
397051
- "utf-8"
397052
- );
397053
- } catch (e) {
397054
- log_default.error(`failed to write to ${outFile}: ${e}`);
397055
- }
397056
- }
397057
- }
397058
- get sdk() {
397059
- if (!this.#sdk) {
397060
- throw new Error("sdk is not attached");
397061
- }
397062
- return this.#sdk;
397063
- }
397064
- };
397065
-
397066
- // src/commands/open-accounts.ts
397067
397070
  function openAccounts() {
397068
397071
  return newCommand().name("open-accounts").description("Script to open accounts in v3.1").addOption(
397069
397072
  new Option(
@@ -397084,7 +397087,7 @@ function openAccounts() {
397084
397087
  anvilUrl = "http://127.0.0.1:8545",
397085
397088
  sharedDir = "."
397086
397089
  } = opts;
397087
- const sdkExample2 = new SdkExample();
397090
+ const sdkExample2 = new SDKExample(log_default);
397088
397091
  await sdkExample2.run({
397089
397092
  addressProvider,
397090
397093
  addressProviderJson,
@@ -397196,7 +397199,7 @@ function getRenderer(opts) {
397196
397199
  var package_default = {
397197
397200
  name: "@gearbox-protocol/deploy-tools",
397198
397201
  description: "Gearbox deploy tools",
397199
- version: "5.2.0",
397202
+ version: "5.2.2",
397200
397203
  homepage: "https://gearbox.fi",
397201
397204
  keywords: [
397202
397205
  "gearbox"
@@ -397239,7 +397242,7 @@ var package_default = {
397239
397242
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
397240
397243
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
397241
397244
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
397242
- "@gearbox-protocol/sdk": "^3.0.0-vfour.131",
397245
+ "@gearbox-protocol/sdk": "^3.0.0-vfour.134",
397243
397246
  "@gearbox-protocol/sdk-gov": "^2.33.1",
397244
397247
  "@types/lodash-es": "^4.17.12",
397245
397248
  "@types/node": "^22.10.2",
@@ -397360,7 +397363,7 @@ function sdkExample() {
397360
397363
  anvilUrl = "http://127.0.0.1:8545",
397361
397364
  sharedDir = "."
397362
397365
  } = opts;
397363
- const sdkExample2 = new SdkExample();
397366
+ const sdkExample2 = new SDKExample(log_default);
397364
397367
  await sdkExample2.run({
397365
397368
  addressProvider,
397366
397369
  addressProviderJson,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "5.2.0",
4
+ "version": "5.2.2",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"
@@ -44,7 +44,7 @@
44
44
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
45
45
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
46
46
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
47
- "@gearbox-protocol/sdk": "^3.0.0-vfour.131",
47
+ "@gearbox-protocol/sdk": "^3.0.0-vfour.134",
48
48
  "@gearbox-protocol/sdk-gov": "^2.33.1",
49
49
  "@types/lodash-es": "^4.17.12",
50
50
  "@types/node": "^22.10.2",