@gearbox-protocol/sdk 8.27.12 → 8.27.13

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.
@@ -23,6 +23,7 @@ __export(networks_exports, {
23
23
  RAMP_DURATION_BY_NETWORK: () => RAMP_DURATION_BY_NETWORK
24
24
  });
25
25
  module.exports = __toCommonJS(networks_exports);
26
+ var import_chain = require("../chain/index.js");
26
27
  var import_mappers = require("../utils/mappers.js");
27
28
  const ADDRESS_PROVIDER_BLOCK = {
28
29
  Mainnet: 18433056n,
@@ -51,27 +52,19 @@ const ADDRESS_PROVIDER_BLOCK = {
51
52
  Lisk: 18934260n
52
53
  // arbitrary not deployed yet
53
54
  };
54
- const BLOCK_DURATION_BY_NETWORK = {
55
- Mainnet: 12.05,
56
- Arbitrum: 0.26,
57
- Optimism: 2,
58
- Base: 2.01,
59
- Sonic: 0.91,
60
- // New networks
61
- MegaETH: 0.01,
62
- // <10ms/block, on testnet
63
- Monad: 1,
64
- // on testnet
65
- Berachain: 1.9,
66
- Avalanche: 1.7,
67
- BNB: 3,
68
- WorldChain: 2,
69
- Etherlink: 1,
70
- Hemi: 12,
71
- Lisk: 2
72
- };
55
+ const BLOCK_DURATION_LOCAL = {};
56
+ const BLOCK_DURATION = Object.values(import_chain.chains).reduce(
57
+ (acc, chain) => {
58
+ const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || 0;
59
+ if (blockTime === 0)
60
+ console.error(`Block time for ${chain.name} is unknown`);
61
+ acc[chain.network] = blockTime / 1e3;
62
+ return acc;
63
+ },
64
+ {}
65
+ );
73
66
  const RAMP_TIME = 30 * 24 * 60 * 60 * 1.2;
74
- const RAMP_DURATION_BY_NETWORK = import_mappers.TypedObjectUtils.entries(BLOCK_DURATION_BY_NETWORK).reduce(
67
+ const RAMP_DURATION_BY_NETWORK = import_mappers.TypedObjectUtils.entries(BLOCK_DURATION).reduce(
75
68
  (acc, [n, duration]) => {
76
69
  acc[n] = BigInt(Math.floor(RAMP_TIME / duration));
77
70
  return acc;
@@ -79,7 +72,7 @@ const RAMP_DURATION_BY_NETWORK = import_mappers.TypedObjectUtils.entries(BLOCK_D
79
72
  {}
80
73
  );
81
74
  const WEEK = 7 * 24 * 60 * 60;
82
- const BLOCKS_PER_WEEK_BY_NETWORK = import_mappers.TypedObjectUtils.entries(BLOCK_DURATION_BY_NETWORK).reduce(
75
+ const BLOCKS_PER_WEEK_BY_NETWORK = import_mappers.TypedObjectUtils.entries(BLOCK_DURATION).reduce(
83
76
  (acc, [n, duration]) => {
84
77
  acc[n] = BigInt(Math.floor(WEEK / duration));
85
78
  return acc;
@@ -1,3 +1,4 @@
1
+ import { chains as CHAINS } from "../chain/index.js";
1
2
  import { TypedObjectUtils } from "../utils/mappers.js";
2
3
  const ADDRESS_PROVIDER_BLOCK = {
3
4
  Mainnet: 18433056n,
@@ -26,27 +27,19 @@ const ADDRESS_PROVIDER_BLOCK = {
26
27
  Lisk: 18934260n
27
28
  // arbitrary not deployed yet
28
29
  };
29
- const BLOCK_DURATION_BY_NETWORK = {
30
- Mainnet: 12.05,
31
- Arbitrum: 0.26,
32
- Optimism: 2,
33
- Base: 2.01,
34
- Sonic: 0.91,
35
- // New networks
36
- MegaETH: 0.01,
37
- // <10ms/block, on testnet
38
- Monad: 1,
39
- // on testnet
40
- Berachain: 1.9,
41
- Avalanche: 1.7,
42
- BNB: 3,
43
- WorldChain: 2,
44
- Etherlink: 1,
45
- Hemi: 12,
46
- Lisk: 2
47
- };
30
+ const BLOCK_DURATION_LOCAL = {};
31
+ const BLOCK_DURATION = Object.values(CHAINS).reduce(
32
+ (acc, chain) => {
33
+ const blockTime = chain.blockTime || BLOCK_DURATION_LOCAL[chain.network] || 0;
34
+ if (blockTime === 0)
35
+ console.error(`Block time for ${chain.name} is unknown`);
36
+ acc[chain.network] = blockTime / 1e3;
37
+ return acc;
38
+ },
39
+ {}
40
+ );
48
41
  const RAMP_TIME = 30 * 24 * 60 * 60 * 1.2;
49
- const RAMP_DURATION_BY_NETWORK = TypedObjectUtils.entries(BLOCK_DURATION_BY_NETWORK).reduce(
42
+ const RAMP_DURATION_BY_NETWORK = TypedObjectUtils.entries(BLOCK_DURATION).reduce(
50
43
  (acc, [n, duration]) => {
51
44
  acc[n] = BigInt(Math.floor(RAMP_TIME / duration));
52
45
  return acc;
@@ -54,7 +47,7 @@ const RAMP_DURATION_BY_NETWORK = TypedObjectUtils.entries(BLOCK_DURATION_BY_NETW
54
47
  {}
55
48
  );
56
49
  const WEEK = 7 * 24 * 60 * 60;
57
- const BLOCKS_PER_WEEK_BY_NETWORK = TypedObjectUtils.entries(BLOCK_DURATION_BY_NETWORK).reduce(
50
+ const BLOCKS_PER_WEEK_BY_NETWORK = TypedObjectUtils.entries(BLOCK_DURATION).reduce(
58
51
  (acc, [n, duration]) => {
59
52
  acc[n] = BigInt(Math.floor(WEEK / duration));
60
53
  return acc;
@@ -1,4 +1,4 @@
1
- import type { NetworkType } from "../chain/index.js";
1
+ import { type NetworkType } from "../chain/index.js";
2
2
  /**
3
3
  * Block number when address provider was deployed
4
4
  * @deprecated use chain.firstBlock instead
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.27.12",
3
+ "version": "8.27.13",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",