@gearbox-protocol/deploy-tools 5.24.7 → 5.24.9

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 +111 -79
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -366906,13 +366906,56 @@ function withPublicNode(chain, subdomain) {
366906
366906
  });
366907
366907
  }
366908
366908
  var chains = {
366909
- Mainnet: withPublicNode(mainnet, "ethereum-rpc"),
366910
- Arbitrum: withPublicNode(arbitrum, "arbitrum-one-rpc"),
366911
- Optimism: withPublicNode(optimism, "optimism-rpc"),
366912
- Base: withPublicNode(base, "base-rpc"),
366909
+ Mainnet: withPublicNode(
366910
+ {
366911
+ ...mainnet,
366912
+ network: "Mainnet",
366913
+ defaultMarketConfigurators: {
366914
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
366915
+ },
366916
+ isPublic: true
366917
+ },
366918
+ "ethereum-rpc"
366919
+ ),
366920
+ Arbitrum: withPublicNode(
366921
+ {
366922
+ ...arbitrum,
366923
+ network: "Arbitrum",
366924
+ defaultMarketConfigurators: {
366925
+ "0x354fe9f450F60b8547f88BE042E4A45b46128a06": "Chaos Labs"
366926
+ },
366927
+ isPublic: true
366928
+ },
366929
+ "arbitrum-one-rpc"
366930
+ ),
366931
+ Optimism: withPublicNode(
366932
+ {
366933
+ ...optimism,
366934
+ network: "Optimism",
366935
+ defaultMarketConfigurators: {
366936
+ "0x2a15969CE5320868eb609680751cF8896DD92De5": "Chaos Labs"
366937
+ },
366938
+ isPublic: true
366939
+ },
366940
+ "optimism-rpc"
366941
+ ),
366942
+ Base: withPublicNode(
366943
+ {
366944
+ ...base,
366945
+ network: "Base",
366946
+ defaultMarketConfigurators: {},
366947
+ isPublic: true
366948
+ },
366949
+ "base-rpc"
366950
+ ),
366913
366951
  Sonic: withPublicNode(
366914
366952
  defineChain({
366915
366953
  ...sonic,
366954
+ network: "Sonic",
366955
+ defaultMarketConfigurators: {
366956
+ "0x8FFDd1F1433674516f83645a768E8900A2A5D076": "Chaos Labs"
366957
+ },
366958
+ isPublic: true,
366916
366959
  blockExplorers: {
366917
366960
  default: {
366918
366961
  name: "Sonic Explorer",
@@ -366924,13 +366967,6 @@ var chains = {
366924
366967
  "sonic-rpc"
366925
366968
  )
366926
366969
  };
366927
- var CHAINS_BY_ID = {
366928
- [mainnet.id]: "Mainnet",
366929
- [arbitrum.id]: "Arbitrum",
366930
- [optimism.id]: "Optimism",
366931
- [base.id]: "Base",
366932
- [sonic.id]: "Sonic"
366933
- };
366934
366970
  function getChain(chainIdOrNetworkType) {
366935
366971
  const network = typeof chainIdOrNetworkType === "string" ? chainIdOrNetworkType : getNetworkType(Number(chainIdOrNetworkType));
366936
366972
  const chain = chains[network];
@@ -366940,11 +366976,12 @@ function getChain(chainIdOrNetworkType) {
366940
366976
  return chain;
366941
366977
  }
366942
366978
  function getNetworkType(chainId) {
366943
- const chainType = CHAINS_BY_ID[chainId];
366944
- if (chainType) {
366945
- return chainType;
366979
+ for (const [network, chain] of TypedObjectUtils.entries(chains)) {
366980
+ if (chain.id === Number(chainId)) {
366981
+ return network;
366982
+ }
366946
366983
  }
366947
- throw new Error("Unsupported network");
366984
+ throw new Error(`Unsupported network with chainId ${chainId}`);
366948
366985
  }
366949
366986
 
366950
366987
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/abi/iERC20.js
@@ -368806,9 +368843,6 @@ function createAdapter(sdk, args) {
368806
368843
  );
368807
368844
  }
368808
368845
  }
368809
- sdk.logger?.warn(
368810
- `no class found for ${adapterType} v${args.baseParams.version}, falling back to placeholder`
368811
- );
368812
368846
  return new PlaceholderAdapterContract(sdk, args);
368813
368847
  }
368814
368848
 
@@ -385119,19 +385153,22 @@ var RedstoneUpdater = class extends SDKConstruct {
385119
385153
  group,
385120
385154
  uniqueSignersCount
385121
385155
  );
385122
- for (const { dataFeedId, data, timestamp } of payloads) {
385156
+ for (const { dataFeedId, data, timestamp, cached } of payloads) {
385123
385157
  const priceFeed = priceFeeds.get(dataFeedId);
385124
385158
  if (!priceFeed) {
385125
385159
  throw new Error(`cannot get price feed address for ${dataFeedId}`);
385126
385160
  }
385127
385161
  results.push({
385162
+ dataFeedId,
385163
+ dataServiceId,
385128
385164
  priceFeed: priceFeed.address.toLowerCase(),
385129
385165
  tx: priceFeed.createRawTx({
385130
385166
  functionName: "updatePrice",
385131
385167
  args: [data],
385132
385168
  description: `updating price for ${dataFeedId} [${this.sdk.provider.addressLabels.get(priceFeed.address)}]`
385133
385169
  }),
385134
- timestamp
385170
+ timestamp,
385171
+ cached
385135
385172
  });
385136
385173
  }
385137
385174
  }
@@ -385164,7 +385201,7 @@ var RedstoneUpdater = class extends SDKConstruct {
385164
385201
  );
385165
385202
  const cached = this.#cache.get(key);
385166
385203
  if (this.#historicalTimestampMs && !!cached) {
385167
- fromCache.push(cached);
385204
+ fromCache.push({ ...cached, cached: true });
385168
385205
  } else {
385169
385206
  uncached.push(dataFeedId);
385170
385207
  }
@@ -385281,7 +385318,8 @@ function getCalldataWithTimestamp(dataFeedId, packages, unsignedMetadata) {
385281
385318
  [{ type: "uint256" }, { type: "bytes" }],
385282
385319
  [BigInt(timestamp), `0x${payload}`]
385283
385320
  ),
385284
- timestamp
385321
+ timestamp,
385322
+ cached: false
385285
385323
  };
385286
385324
  }
385287
385325
 
@@ -385338,6 +385376,7 @@ var PriceFeedRegister = class extends SDKConstruct {
385338
385376
  logger;
385339
385377
  #hooks = new Hooks();
385340
385378
  #feeds = new AddressMap(void 0, "priceFeeds");
385379
+ #latestUpdate;
385341
385380
  redstoneUpdater;
385342
385381
  constructor(sdk) {
385343
385382
  super(sdk);
@@ -385403,42 +385442,13 @@ var PriceFeedRegister = class extends SDKConstruct {
385403
385442
  this.logger?.debug(`loaded ${result.length} partial updatable price feeds`);
385404
385443
  return result.map((baseParams) => this.#createUpdatableProxy({ baseParams }));
385405
385444
  }
385406
- /**
385407
- * Generates price update transaction via multicall3 without any market data knowledge
385408
- *
385409
- * @deprecated TODO: seems that it's not used anywhere
385410
- *
385411
- * @param marketConfigurators
385412
- * @param pools
385413
- * @returns
385414
- */
385415
- async getUpdatePriceFeedsTx(marketConfigurators, pools) {
385416
- const feeds = await this.getPartialUpdatablePriceFeeds(
385417
- marketConfigurators,
385418
- pools
385419
- );
385420
- const updates = await this.#generatePriceFeedsUpdateTxs(feeds);
385421
- return createRawTx(
385422
- getChainContractAddress({
385423
- chain: this.sdk.provider.chain,
385424
- contract: "multicall3"
385425
- }),
385426
- {
385427
- abi: multicall3Abi,
385428
- functionName: "aggregate3",
385429
- args: [
385430
- updates.txs.map((tx) => ({
385431
- target: tx.to,
385432
- allowFailure: false,
385433
- callData: tx.callData
385434
- }))
385435
- ]
385436
- }
385437
- );
385438
- }
385439
385445
  async #generatePriceFeedsUpdateTxs(updateables, logContext = {}) {
385440
385446
  const txs = [];
385441
385447
  const redstonePFs = [];
385448
+ const latestUpdate = {
385449
+ redstone: [],
385450
+ timestamp: Math.floor(Date.now() / 1e3)
385451
+ };
385442
385452
  for (const pf of updateables) {
385443
385453
  if (isRedstone(pf)) {
385444
385454
  redstonePFs.push(pf);
@@ -385450,11 +385460,12 @@ var PriceFeedRegister = class extends SDKConstruct {
385450
385460
  redstonePFs,
385451
385461
  logContext
385452
385462
  );
385453
- for (const { tx, timestamp } of redstoneUpdates) {
385463
+ for (const { tx, timestamp, ...rest } of redstoneUpdates) {
385454
385464
  if (timestamp > maxTimestamp) {
385455
385465
  maxTimestamp = timestamp;
385456
385466
  }
385457
385467
  txs.push(tx);
385468
+ latestUpdate.redstone.push({ ...rest, timestamp });
385458
385469
  }
385459
385470
  }
385460
385471
  const result = { txs, timestamp: maxTimestamp };
@@ -385465,6 +385476,7 @@ var PriceFeedRegister = class extends SDKConstruct {
385465
385476
  if (txs.length) {
385466
385477
  await this.#hooks.triggerHooks("updatesGenerated", result);
385467
385478
  }
385479
+ this.#latestUpdate = latestUpdate;
385468
385480
  return result;
385469
385481
  }
385470
385482
  create(data) {
@@ -385526,6 +385538,12 @@ var PriceFeedRegister = class extends SDKConstruct {
385526
385538
  }
385527
385539
  });
385528
385540
  }
385541
+ /**
385542
+ * Information update latest update of updatable price feeds, for diagnostic purposes
385543
+ */
385544
+ get latestUpdate() {
385545
+ return this.#latestUpdate;
385546
+ }
385529
385547
  };
385530
385548
 
385531
385549
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pricefeeds/utils.js
@@ -385544,6 +385562,7 @@ function rawTxToMulticallPriceUpdate(tx) {
385544
385562
  }
385545
385563
 
385546
385564
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js
385565
+ var ZERO_PRICE_FEED = stringToHex("PRICE_FEED::ZERO", { size: 32 });
385547
385566
  var PriceOracleBaseContract = class extends BaseContract {
385548
385567
  /**
385549
385568
  * Underlying token of market to which this price oracle belongs
@@ -385747,12 +385766,13 @@ var PriceOracleBaseContract = class extends BaseContract {
385747
385766
  (n) => n.baseParams.addr === priceFeed
385748
385767
  );
385749
385768
  const price = node?.answer?.price;
385769
+ const priceFeedType = node?.baseParams.contractType;
385750
385770
  if (reserve) {
385751
385771
  this.reservePriceFeeds.upsert(token, ref);
385752
385772
  if (price !== void 0) {
385753
385773
  this.reservePrices.upsert(token, price);
385754
385774
  }
385755
- if (!price) {
385775
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
385756
385776
  this.logger?.warn(
385757
385777
  node ?? {},
385758
385778
  `answer not found for reserve price feed ${this.labelAddress(priceFeed)}`
@@ -385763,7 +385783,7 @@ var PriceOracleBaseContract = class extends BaseContract {
385763
385783
  if (price !== void 0) {
385764
385784
  this.mainPrices.upsert(token, price);
385765
385785
  }
385766
- if (!price) {
385786
+ if (!price && priceFeedType !== ZERO_PRICE_FEED) {
385767
385787
  this.logger?.warn(
385768
385788
  node ?? {},
385769
385789
  `answer not found for main price feed ${this.labelAddress(priceFeed)}`
@@ -386629,11 +386649,24 @@ var MarketRegister = class extends SDKConstruct {
386629
386649
  get marketFilter() {
386630
386650
  return this.#marketFilter;
386631
386651
  }
386632
- async syncState() {
386633
- const pools = this.markets.filter((m) => m.dirty).map((m) => m.pool.pool.address);
386634
- if (pools.length) {
386635
- this.#logger?.debug(`need to reload ${pools.length} markets`);
386636
- await this.#loadMarkets([], pools);
386652
+ async syncState(skipPriceUpdate) {
386653
+ const dirtyPools = [];
386654
+ const nonDirtyOracles = [];
386655
+ for (const m of this.markets) {
386656
+ if (m.dirty) {
386657
+ dirtyPools.push(m.pool.pool.address);
386658
+ } else {
386659
+ nonDirtyOracles.push(m.priceOracle.address);
386660
+ }
386661
+ }
386662
+ if (dirtyPools.length) {
386663
+ this.#logger?.debug(`need to reload ${dirtyPools.length} markets`);
386664
+ await this.#loadMarkets([], dirtyPools);
386665
+ } else if (!skipPriceUpdate && nonDirtyOracles.length) {
386666
+ this.#logger?.debug(
386667
+ `syncing prices on ${nonDirtyOracles.length} oracles`
386668
+ );
386669
+ await this.updatePrices(nonDirtyOracles);
386637
386670
  }
386638
386671
  }
386639
386672
  async #loadMarkets(configurators, pools, ignoreUpdateablePrices) {
@@ -389577,6 +389610,9 @@ var GearStakingContract = class extends BaseContract {
389577
389610
  }
389578
389611
  };
389579
389612
 
389613
+ // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/plugins/defaultPlugins.js
389614
+ var defaultPlugins = {};
389615
+
389580
389616
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js
389581
389617
  var V300StalenessPeriodPlugin = class extends SDKConstruct {
389582
389618
  #syncedTo;
@@ -389635,11 +389671,6 @@ var V300StalenessPeriodPlugin = class extends SDKConstruct {
389635
389671
  }
389636
389672
  };
389637
389673
 
389638
- // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/plugins/defaultPlugins.js
389639
- var defaultPlugins = {
389640
- stalenessV300: V300StalenessPeriodPlugin
389641
- };
389642
-
389643
389674
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/GearboxSDK.js
389644
389675
  var ERR_NOT_ATTACHED = new Error("Gearbox SDK not attached");
389645
389676
  var GearboxSDK = class _GearboxSDK {
@@ -389694,7 +389725,7 @@ var GearboxSDK = class _GearboxSDK {
389694
389725
  blockNumber,
389695
389726
  redstoneHistoricTimestamp,
389696
389727
  ignoreUpdateablePrices,
389697
- marketConfigurators
389728
+ marketConfigurators: mcs
389698
389729
  } = options;
389699
389730
  let { networkType, addressProvider, chainId } = options;
389700
389731
  const attachClient = createPublicClient({
@@ -389709,12 +389740,13 @@ var GearboxSDK = class _GearboxSDK {
389709
389740
  if (!addressProvider) {
389710
389741
  addressProvider = ADDRESS_PROVIDER_V310;
389711
389742
  }
389743
+ const marketConfigurators = mcs ?? TypedObjectUtils.keys(chains[networkType].defaultMarketConfigurators);
389712
389744
  const provider = new Provider({
389713
389745
  ...options,
389714
389746
  chainId,
389715
389747
  networkType
389716
389748
  });
389717
- logger2?.debug(
389749
+ logger2?.info(
389718
389750
  { networkType, chainId, addressProvider, marketConfigurators },
389719
389751
  "attaching gearbox sdk"
389720
389752
  );
@@ -389768,13 +389800,12 @@ var GearboxSDK = class _GearboxSDK {
389768
389800
  if (redstoneGateways?.length) {
389769
389801
  this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
389770
389802
  }
389771
- this.logger?.info(
389803
+ this.logger?.debug(
389772
389804
  {
389773
- addressProvider,
389774
- blockNumber: block.number,
389805
+ number: block.number,
389775
389806
  timestamp: block.timestamp
389776
389807
  },
389777
- "attaching"
389808
+ "attach block"
389778
389809
  );
389779
389810
  this.#addressProvider = await createAddressProvider(this, addressProvider);
389780
389811
  this.logger?.debug(
@@ -389913,7 +389944,7 @@ var GearboxSDK = class _GearboxSDK {
389913
389944
  * @returns
389914
389945
  */
389915
389946
  async syncState(opts) {
389916
- let { blockNumber, timestamp } = opts ?? {};
389947
+ let { blockNumber, timestamp, skipPriceUpdate } = opts ?? {};
389917
389948
  if (!blockNumber || !timestamp) {
389918
389949
  const block = await this.provider.publicClient.getBlock({
389919
389950
  blockTag: "latest"
@@ -389944,7 +389975,7 @@ var GearboxSDK = class _GearboxSDK {
389944
389975
  contract.processLog(event);
389945
389976
  }
389946
389977
  }
389947
- await this.marketRegister.syncState();
389978
+ await this.marketRegister.syncState(skipPriceUpdate);
389948
389979
  this.#currentBlock = blockNumber;
389949
389980
  this.#timestamp = timestamp;
389950
389981
  await this.#hooks.triggerHooks("syncState", { blockNumber, timestamp });
@@ -419100,7 +419131,7 @@ function getRenderer(opts) {
419100
419131
  var package_default = {
419101
419132
  name: "@gearbox-protocol/deploy-tools",
419102
419133
  description: "Gearbox deploy tools",
419103
- version: "5.24.7",
419134
+ version: "5.24.9",
419104
419135
  homepage: "https://gearbox.fi",
419105
419136
  keywords: [
419106
419137
  "gearbox"
@@ -419143,7 +419174,7 @@ var package_default = {
419143
419174
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
419144
419175
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
419145
419176
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
419146
- "@gearbox-protocol/sdk": "3.0.0-vfour.318",
419177
+ "@gearbox-protocol/sdk": "3.0.0-vfour.326",
419147
419178
  "@gearbox-protocol/sdk-gov": "^2.36.6",
419148
419179
  "@types/lodash-es": "^4.17.12",
419149
419180
  "@types/node": "^22.13.10",
@@ -419804,7 +419835,8 @@ function sdkExample() {
419804
419835
  plugins: {
419805
419836
  adapters: AdaptersPlugin,
419806
419837
  zappers: ZappersPlugin,
419807
- bots: BotsPlugin
419838
+ bots: BotsPlugin,
419839
+ stalenessV300: V300StalenessPeriodPlugin
419808
419840
  }
419809
419841
  });
419810
419842
  await writeFile7(
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.24.7",
4
+ "version": "5.24.9",
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.318",
47
+ "@gearbox-protocol/sdk": "3.0.0-vfour.326",
48
48
  "@gearbox-protocol/sdk-gov": "^2.36.6",
49
49
  "@types/lodash-es": "^4.17.12",
50
50
  "@types/node": "^22.13.10",