@gearbox-protocol/deploy-tools 5.18.4 → 5.18.6

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 +210 -54
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -87443,7 +87443,7 @@ var require_mappers = __commonJS({
87443
87443
  "use strict";
87444
87444
  Object.defineProperty(exports2, "__esModule", { value: true });
87445
87445
  exports2.TypedObjectUtils = void 0;
87446
- var TypedObjectUtils = class _TypedObjectUtils {
87446
+ var TypedObjectUtils2 = class _TypedObjectUtils {
87447
87447
  static keys = (o) => Object.keys(o);
87448
87448
  static entries = (o) => Object.entries(o);
87449
87449
  static fromEntries = (o) => Object.fromEntries(o);
@@ -87453,7 +87453,7 @@ var require_mappers = __commonJS({
87453
87453
  return { ...acc, [keyTransformed]: value };
87454
87454
  }, {});
87455
87455
  };
87456
- exports2.TypedObjectUtils = TypedObjectUtils;
87456
+ exports2.TypedObjectUtils = TypedObjectUtils2;
87457
87457
  }
87458
87458
  });
87459
87459
 
@@ -358129,6 +358129,29 @@ function formatDuration2(seconds, raw = true) {
358129
358129
  return `${formatDuration(duration)}` + (raw ? `[${seconds.toString()}]` : "");
358130
358130
  }
358131
358131
 
358132
+ // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/hex.js
358133
+ function hexEq(a, b) {
358134
+ return !!a && !!b && a.toLowerCase() === b.toLowerCase();
358135
+ }
358136
+
358137
+ // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/mappers.js
358138
+ var TypedObjectUtils = class _TypedObjectUtils {
358139
+ static keys = (o) => Object.keys(o);
358140
+ static entries = (o) => Object.entries(o);
358141
+ static fromEntries = (o) => Object.fromEntries(o);
358142
+ static swapKeyValue = (o) => _TypedObjectUtils.entries(o).reduce(
358143
+ (acc, [key, value]) => ({ ...acc, [value]: key }),
358144
+ {}
358145
+ );
358146
+ static keyToLowercase = (o) => _TypedObjectUtils.entries(o).reduce(
358147
+ (acc, [key, value]) => {
358148
+ const keyTransformed = typeof key === "string" ? key.toLowerCase() : key;
358149
+ return { ...acc, [keyTransformed]: value };
358150
+ },
358151
+ {}
358152
+ );
358153
+ };
358154
+
358132
358155
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/utils/retry.js
358133
358156
  async function retry(fn, options = {}) {
358134
358157
  const { attempts = 3, interval = 200 } = options;
@@ -358405,6 +358428,12 @@ var SDKConstruct = class {
358405
358428
  get provider() {
358406
358429
  return this.sdk.provider;
358407
358430
  }
358431
+ get network() {
358432
+ return this.provider.networkType;
358433
+ }
358434
+ get client() {
358435
+ return this.provider.publicClient;
358436
+ }
358408
358437
  /**
358409
358438
  * Indicates that contract state needs to be updated
358410
358439
  */
@@ -375470,6 +375499,7 @@ var PythPriceFeed = class extends AbstractPriceFeedContract {
375470
375499
 
375471
375500
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js
375472
375501
  var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
375502
+ token;
375473
375503
  dataServiceId;
375474
375504
  dataId;
375475
375505
  signers;
@@ -375480,45 +375510,91 @@ var RedstonePriceFeedContract = class extends AbstractPriceFeedContract {
375480
375510
  name: `RedstonePriceFeed`,
375481
375511
  abi: redstonePriceFeedAbi
375482
375512
  });
375483
- const decoder = decodeAbiParameters(
375484
- [
375485
- { type: "address" },
375486
- // [0]: pf.token(),
375487
- { type: "bytes32" },
375488
- // [1]: pf.dataFeedId(),
375489
- { type: "address" },
375490
- // [2]: pf.signerAddress0(),
375491
- { type: "address" },
375492
- // [3]: pf.signerAddress1(),
375493
- { type: "address" },
375494
- // [4]: pf.signerAddress2(),
375495
- { type: "address" },
375496
- // [5]: pf.signerAddress3(),
375497
- { type: "address" },
375498
- // [6]: pf.signerAddress4(),
375499
- { type: "address" },
375500
- // [7]: pf.signerAddress5()
375501
- { type: "address" },
375502
- // [8]: pf.signerAddress6(),
375503
- { type: "address" },
375504
- // [9]: pf.signerAddress7(),
375505
- { type: "address" },
375506
- // [10]: pf.signerAddress8(),
375507
- { type: "address" },
375508
- // [11]: pf.signerAddress9(),
375509
- { type: "uint8" },
375510
- // [12]: pf.getUniqueSignersThreshold()
375511
- { type: "uint128" },
375512
- // [13]: pf.lastPrice(),
375513
- { type: "uint40" }
375514
- // [14]: pf.lastPayloadTimestamp()
375515
- ],
375516
- args.baseParams.serializedParams
375517
- );
375518
- this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
375519
- this.signers = decoder.slice(2, 11);
375520
- this.signersThreshold = Number(decoder[12]);
375521
- this.dataServiceId = ["GMX", "BAL"].includes(this.dataId) ? "redstone-arbitrum-prod" : "redstone-primary-prod";
375513
+ if (args.baseParams.version === 310n) {
375514
+ const decoder = decodeAbiParameters(
375515
+ [
375516
+ { type: "address" },
375517
+ // [0]: pf.token(),
375518
+ { type: "bytes32" },
375519
+ // [1]: pf.dataFeedId(),
375520
+ { type: "string" },
375521
+ // [2]: pf.dataServiceId(),
375522
+ { type: "address" },
375523
+ // [3]: pf.signerAddress0(),
375524
+ { type: "address" },
375525
+ // [4]: pf.signerAddress1(),
375526
+ { type: "address" },
375527
+ // [5]: pf.signerAddress2(),
375528
+ { type: "address" },
375529
+ // [6]: pf.signerAddress3(),
375530
+ { type: "address" },
375531
+ // [7]: pf.signerAddress4(),
375532
+ { type: "address" },
375533
+ // [8]: pf.signerAddress5()
375534
+ { type: "address" },
375535
+ // [9]: pf.signerAddress6(),
375536
+ { type: "address" },
375537
+ // [10]: pf.signerAddress7(),
375538
+ { type: "address" },
375539
+ // [11]: pf.signerAddress8(),
375540
+ { type: "address" },
375541
+ // [12]: pf.signerAddress9(),
375542
+ { type: "uint8" },
375543
+ // [13]: pf.getUniqueSignersThreshold()
375544
+ { type: "uint128" },
375545
+ // [14]: pf.lastPrice(),
375546
+ { type: "uint40" }
375547
+ // [15]: pf.lastPayloadTimestamp()
375548
+ ],
375549
+ args.baseParams.serializedParams
375550
+ );
375551
+ this.token = decoder[0];
375552
+ this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
375553
+ this.signers = decoder.slice(3, 13);
375554
+ this.signersThreshold = Number(decoder[13]);
375555
+ this.dataServiceId = decoder[2];
375556
+ } else {
375557
+ const decoder = decodeAbiParameters(
375558
+ [
375559
+ { type: "address" },
375560
+ // [0]: pf.token(),
375561
+ { type: "bytes32" },
375562
+ // [1]: pf.dataFeedId(),
375563
+ { type: "address" },
375564
+ // [2]: pf.signerAddress0(),
375565
+ { type: "address" },
375566
+ // [3]: pf.signerAddress1(),
375567
+ { type: "address" },
375568
+ // [4]: pf.signerAddress2(),
375569
+ { type: "address" },
375570
+ // [5]: pf.signerAddress3(),
375571
+ { type: "address" },
375572
+ // [6]: pf.signerAddress4(),
375573
+ { type: "address" },
375574
+ // [7]: pf.signerAddress5()
375575
+ { type: "address" },
375576
+ // [8]: pf.signerAddress6(),
375577
+ { type: "address" },
375578
+ // [9]: pf.signerAddress7(),
375579
+ { type: "address" },
375580
+ // [10]: pf.signerAddress8(),
375581
+ { type: "address" },
375582
+ // [11]: pf.signerAddress9(),
375583
+ { type: "uint8" },
375584
+ // [12]: pf.getUniqueSignersThreshold()
375585
+ { type: "uint128" },
375586
+ // [13]: pf.lastPrice(),
375587
+ { type: "uint40" }
375588
+ // [14]: pf.lastPayloadTimestamp()
375589
+ ],
375590
+ args.baseParams.serializedParams
375591
+ );
375592
+ this.token = decoder[0];
375593
+ this.dataId = bytesToString(toBytes(decoder[1])).replaceAll("\0", "");
375594
+ this.signers = decoder.slice(2, 12);
375595
+ this.signersThreshold = Number(decoder[12]);
375596
+ this.dataServiceId = ["GMX", "BAL"].includes(this.dataId) ? "redstone-arbitrum-prod" : "redstone-primary-prod";
375597
+ }
375522
375598
  }
375523
375599
  stateHuman(raw = true) {
375524
375600
  return {
@@ -380026,6 +380102,69 @@ var GearStakingContract = class extends BaseContract {
380026
380102
  }
380027
380103
  };
380028
380104
 
380105
+ // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/plugins/V300StalenessPeriodPlugin.js
380106
+ var V300StalenessPeriodPlugin = class extends SDKConstruct {
380107
+ #syncedTo;
380108
+ #logger;
380109
+ constructor(sdk) {
380110
+ super(sdk);
380111
+ this.#syncedTo = ADDRESS_PROVIDER_BLOCK[sdk.provider.networkType] - 1n;
380112
+ this.#logger = sdk.logger?.child?.({ name: "V300StalenessPeriodPlugin" }) ?? sdk.logger;
380113
+ }
380114
+ async attach() {
380115
+ await this.#syncReservePriceFeeds();
380116
+ }
380117
+ async syncState() {
380118
+ await this.#syncReservePriceFeeds();
380119
+ }
380120
+ async #syncReservePriceFeeds() {
380121
+ const markets = this.sdk.marketRegister.markets;
380122
+ const oracles = markets.filter((m) => m.priceOracle.version === 300).map((m) => m.priceOracle);
380123
+ const addresses = Array.from(new Set(oracles.map((o) => o.address)));
380124
+ const [fromBlock, toBlock] = [this.#syncedTo + 1n, this.sdk.currentBlock];
380125
+ if (addresses.length === 0 || fromBlock > toBlock) {
380126
+ return;
380127
+ }
380128
+ const events = await this.client.getLogs({
380129
+ address: addresses,
380130
+ event: getAbiItem({
380131
+ abi: iPriceOracleV300Abi,
380132
+ name: "SetReservePriceFeed"
380133
+ }),
380134
+ fromBlock,
380135
+ toBlock,
380136
+ strict: true
380137
+ });
380138
+ this.#logger?.info(
380139
+ `loaded ${events.length} SetReservePriceFeed events in range [${fromBlock}; ${toBlock}]`
380140
+ );
380141
+ for (const e of events) {
380142
+ const oracle = getAddress(e.address);
380143
+ const priceFeed = getAddress(e.args.priceFeed);
380144
+ const token = getAddress(e.args.token);
380145
+ const stalenessPeriod = e.args.stalenessPeriod;
380146
+ for (const o of oracles) {
380147
+ const pf = o.reservePriceFeeds.get(token);
380148
+ if (hexEq(pf?.address, priceFeed) && hexEq(o.address, oracle)) {
380149
+ o.reservePriceFeeds.upsert(
380150
+ token,
380151
+ new PriceFeedRef(this.sdk, priceFeed, stalenessPeriod)
380152
+ );
380153
+ this.#logger?.info(
380154
+ `updated staleness period for ${this.labelAddress(token)}/${this.labelAddress(priceFeed)} in oracle ${this.labelAddress(oracle)} to ${formatDuration2(stalenessPeriod)}`
380155
+ );
380156
+ }
380157
+ }
380158
+ }
380159
+ this.#syncedTo = toBlock;
380160
+ }
380161
+ };
380162
+
380163
+ // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/plugins/defaultPlugins.js
380164
+ var defaultPlugins = {
380165
+ stalenessV300: V300StalenessPeriodPlugin
380166
+ };
380167
+
380029
380168
  // ../../node_modules/@gearbox-protocol/sdk/dist/esm/sdk/GearboxSDK.js
380030
380169
  var ERR_NOT_ATTACHED = new Error("Gearbox SDK not attached");
380031
380170
  var GearboxSDK = class _GearboxSDK {
@@ -380122,10 +380261,12 @@ var GearboxSDK = class _GearboxSDK {
380122
380261
  this.priceFeeds = new PriceFeedRegister(this);
380123
380262
  this.strictContractTypes = options.strictContractTypes ?? false;
380124
380263
  const pluginsInstances = {};
380125
- for (const [name, PluginConstructor] of Object.entries(
380126
- options.plugins ?? {}
380127
- )) {
380128
- pluginsInstances[name] = new PluginConstructor(this);
380264
+ const pluginConstructros = {
380265
+ ...defaultPlugins,
380266
+ ...options.plugins
380267
+ };
380268
+ for (const [name, Plugin] of TypedObjectUtils.entries(pluginConstructros)) {
380269
+ pluginsInstances[name] = new Plugin(this);
380129
380270
  }
380130
380271
  this.plugins = pluginsInstances;
380131
380272
  }
@@ -380193,11 +380334,15 @@ var GearboxSDK = class _GearboxSDK {
380193
380334
  } catch (e) {
380194
380335
  this.logger?.warn("Router not found", e);
380195
380336
  }
380196
- for (const [name, plugin] of Object.entries(this.plugins)) {
380337
+ for (const [name, plugin] of TypedObjectUtils.entries(this.plugins)) {
380197
380338
  if (plugin.attach) {
380198
380339
  this.logger?.debug(`attaching plugin ${name}`);
380199
- await plugin.attach();
380200
- this.logger?.debug(`attached plugin ${name}`);
380340
+ try {
380341
+ await plugin.attach();
380342
+ this.logger?.debug(`attached plugin ${name}`);
380343
+ } catch (e) {
380344
+ this.logger?.error(e, `failed to attach plugin ${name}`);
380345
+ }
380201
380346
  }
380202
380347
  }
380203
380348
  this.logger?.info(`attach time: ${Date.now() - time} ms`);
@@ -380260,9 +380405,9 @@ var GearboxSDK = class _GearboxSDK {
380260
380405
  },
380261
380406
  tokens: this.tokensMeta.values(),
380262
380407
  plugins: Object.fromEntries(
380263
- Object.entries(this.plugins).map(([name, plugin]) => [
380408
+ TypedObjectUtils.entries(this.plugins).map(([name, plugin]) => [
380264
380409
  name,
380265
- plugin.stateHuman(raw)
380410
+ plugin.stateHuman?.(raw) ?? {}
380266
380411
  ])
380267
380412
  ),
380268
380413
  ...this.marketRegister.stateHuman(raw)
@@ -380321,6 +380466,17 @@ var GearboxSDK = class _GearboxSDK {
380321
380466
  this.#currentBlock = blockNumber;
380322
380467
  this.#timestamp = timestamp;
380323
380468
  await this.#hooks.triggerHooks("syncState", { blockNumber, timestamp });
380469
+ for (const [name, plugin] of TypedObjectUtils.entries(this.plugins)) {
380470
+ if (plugin.syncState) {
380471
+ this.logger?.debug(`syncing plugin ${name}`);
380472
+ try {
380473
+ await plugin.syncState();
380474
+ this.logger?.debug(`syncing plugin ${name}`);
380475
+ } catch (e) {
380476
+ this.logger?.error(e, `failed to sync plugin ${name}`);
380477
+ }
380478
+ }
380479
+ }
380324
380480
  this.#syncing = false;
380325
380481
  this.logger?.debug(`synced state to block ${blockNumber}`);
380326
380482
  }
@@ -403093,7 +403249,7 @@ function normalizeTimelockTx2(t) {
403093
403249
  }
403094
403250
 
403095
403251
  // ../../packages/shared/dist/hex.js
403096
- function hexEq(a, b) {
403252
+ function hexEq2(a, b) {
403097
403253
  const [aa, bb] = [a, b].map((s) => s.replace(/^0x/, "").toLowerCase());
403098
403254
  return aa === bb;
403099
403255
  }
@@ -406712,7 +406868,7 @@ var Verifier = class {
406712
406868
  }
406713
406869
  if (match2) {
406714
406870
  const abiEncodedConstructorArguments = extractAbiEncodedConstructorArguments(creatorTxData, recompiledCreationBytecode) ?? "";
406715
- if (!hexEq(abiEncodedConstructorArguments, meta.encodedConstructorArgs)) {
406871
+ if (!hexEq2(abiEncodedConstructorArguments, meta.encodedConstructorArgs)) {
406716
406872
  return {
406717
406873
  ...result,
406718
406874
  error: `Encoded constructor arguments mismatch: meta ${meta.encodedConstructorArgs} tx ${abiEncodedConstructorArguments}`
@@ -413417,7 +413573,7 @@ function getRenderer(opts) {
413417
413573
  var package_default = {
413418
413574
  name: "@gearbox-protocol/deploy-tools",
413419
413575
  description: "Gearbox deploy tools",
413420
- version: "5.18.4",
413576
+ version: "5.18.6",
413421
413577
  homepage: "https://gearbox.fi",
413422
413578
  keywords: [
413423
413579
  "gearbox"
@@ -413460,7 +413616,7 @@ var package_default = {
413460
413616
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
413461
413617
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
413462
413618
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
413463
- "@gearbox-protocol/sdk": "3.0.0-vfour.294",
413619
+ "@gearbox-protocol/sdk": "3.0.0-vfour.300",
413464
413620
  "@gearbox-protocol/sdk-gov": "^2.36.5",
413465
413621
  "@types/lodash-es": "^4.17.12",
413466
413622
  "@types/node": "^22.13.5",
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.18.4",
4
+ "version": "5.18.6",
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.294",
47
+ "@gearbox-protocol/sdk": "3.0.0-vfour.300",
48
48
  "@gearbox-protocol/sdk-gov": "^2.36.5",
49
49
  "@types/lodash-es": "^4.17.12",
50
50
  "@types/node": "^22.13.5",