@gearbox-protocol/sdk 8.27.5 → 8.27.7

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.
@@ -417,7 +417,10 @@ class GearboxSDK {
417
417
  return;
418
418
  }
419
419
  this.#syncing = true;
420
- this.logger?.debug(`syncing state to block ${blockNumber}...`);
420
+ let delta = Math.floor(Date.now() / 1e3) - Number(timestamp);
421
+ this.logger?.debug(
422
+ `syncing state to block ${blockNumber} (delta ${delta}s )...`
423
+ );
421
424
  const watchAddresses = [
422
425
  ...Array.from(this.marketRegister.watchAddresses),
423
426
  this.addressProvider.address
@@ -464,7 +467,10 @@ class GearboxSDK {
464
467
  }
465
468
  });
466
469
  this.#syncing = false;
467
- this.logger?.debug(`synced state to block ${blockNumber}`);
470
+ delta = Math.floor(Date.now() / 1e3) - Number(timestamp);
471
+ this.logger?.debug(
472
+ `synced state to block ${blockNumber} (delta ${delta}s)`
473
+ );
468
474
  }
469
475
  get provider() {
470
476
  return this.#provider;
@@ -87,7 +87,9 @@ async function simulateWithPriceUpdates(client, parameters) {
87
87
  }
88
88
  }
89
89
  }
90
- if (parameters.blockNumber) {
90
+ if (parameters.blockNumber && // this does not work for default multicall3 contracts on some L2 chains, so check on Eth Mainnet only
91
+ // https://docs.arbitrum.io/build-decentralized-apps/arbitrum-vs-ethereum/block-numbers-and-time#case-study-the-multicall-contract
92
+ (client.chain?.id === 1 || parameters.forceBlockNumberCheck)) {
91
93
  const r = multicallResults[1];
92
94
  if (r.status === "success") {
93
95
  const fromMc = BigInt(r.result);
@@ -415,7 +415,10 @@ class GearboxSDK {
415
415
  return;
416
416
  }
417
417
  this.#syncing = true;
418
- this.logger?.debug(`syncing state to block ${blockNumber}...`);
418
+ let delta = Math.floor(Date.now() / 1e3) - Number(timestamp);
419
+ this.logger?.debug(
420
+ `syncing state to block ${blockNumber} (delta ${delta}s )...`
421
+ );
419
422
  const watchAddresses = [
420
423
  ...Array.from(this.marketRegister.watchAddresses),
421
424
  this.addressProvider.address
@@ -462,7 +465,10 @@ class GearboxSDK {
462
465
  }
463
466
  });
464
467
  this.#syncing = false;
465
- this.logger?.debug(`synced state to block ${blockNumber}`);
468
+ delta = Math.floor(Date.now() / 1e3) - Number(timestamp);
469
+ this.logger?.debug(
470
+ `synced state to block ${blockNumber} (delta ${delta}s)`
471
+ );
466
472
  }
467
473
  get provider() {
468
474
  return this.#provider;
@@ -68,7 +68,9 @@ async function simulateWithPriceUpdates(client, parameters) {
68
68
  }
69
69
  }
70
70
  }
71
- if (parameters.blockNumber) {
71
+ if (parameters.blockNumber && // this does not work for default multicall3 contracts on some L2 chains, so check on Eth Mainnet only
72
+ // https://docs.arbitrum.io/build-decentralized-apps/arbitrum-vs-ethereum/block-numbers-and-time#case-study-the-multicall-contract
73
+ (client.chain?.id === 1 || parameters.forceBlockNumberCheck)) {
72
74
  const r = multicallResults[1];
73
75
  if (r.status === "success") {
74
76
  const fromMc = BigInt(r.result);
@@ -13,6 +13,10 @@ export type SimulateWithPriceUpdatesParameters<contracts extends readonly unknow
13
13
  * Defaults to false
14
14
  */
15
15
  strictPrices?: boolean;
16
+ /**
17
+ * Always check block number from multicall
18
+ */
19
+ forceBlockNumberCheck?: boolean;
16
20
  };
17
21
  export type SimulateWithPriceUpdatesReturnType<contracts extends readonly unknown[] = readonly ContractFunctionParameters[], options extends {
18
22
  error?: Error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.27.5",
3
+ "version": "8.27.7",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",