@gearbox-protocol/sdk 8.14.4 → 8.15.1

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.
@@ -52,7 +52,7 @@ class GearboxSDK {
52
52
  #marketRegister;
53
53
  #priceFeeds;
54
54
  logger;
55
- gasLimit = 550000000n;
55
+ gasLimit;
56
56
  /**
57
57
  * Interest rate models can be reused across chain (and SDK operates on chain level)
58
58
  * TODO: use whatever interface is necessary for InterestRateModels
@@ -85,7 +85,8 @@ class GearboxSDK {
85
85
  ignoreUpdateablePrices,
86
86
  ignoreMarkets,
87
87
  marketConfigurators: mcs,
88
- strictContractTypes
88
+ strictContractTypes,
89
+ gasLimit
89
90
  } = options;
90
91
  let { networkType, addressProvider, chainId } = options;
91
92
  const attachClient = (0, import_viem.createPublicClient)({
@@ -110,7 +111,8 @@ class GearboxSDK {
110
111
  provider,
111
112
  logger,
112
113
  plugins,
113
- strictContractTypes
114
+ strictContractTypes,
115
+ gasLimit
114
116
  }).#attach({
115
117
  addressProvider,
116
118
  blockNumber,
@@ -122,7 +124,7 @@ class GearboxSDK {
122
124
  });
123
125
  }
124
126
  static hydrate(options, state) {
125
- const { logger, plugins, strictContractTypes, ...rest } = options;
127
+ const { logger, plugins, strictContractTypes, gasLimit, ...rest } = options;
126
128
  const provider = new import_chain.Provider({
127
129
  ...rest,
128
130
  chainId: state.chainId,
@@ -132,7 +134,8 @@ class GearboxSDK {
132
134
  provider,
133
135
  plugins,
134
136
  logger,
135
- strictContractTypes
137
+ strictContractTypes,
138
+ gasLimit
136
139
  }).#hydrate(rest, state);
137
140
  }
138
141
  constructor(options) {
@@ -143,6 +146,9 @@ class GearboxSDK {
143
146
  for (const plugin of Object.values(this.plugins)) {
144
147
  plugin.sdk = this;
145
148
  }
149
+ if (options.gasLimit !== null) {
150
+ this.gasLimit = options.gasLimit || 550000000n;
151
+ }
146
152
  }
147
153
  async #attach(opts) {
148
154
  const {
@@ -65,7 +65,12 @@ const SDKOptions = import_v4.z.object({
65
65
  /**
66
66
  * Options related to pyth price feeds
67
67
  */
68
- pyth: import_updates.PythOptions.optional()
68
+ pyth: import_updates.PythOptions.optional(),
69
+ /**
70
+ * Explicit gas limit for read eth_calls
71
+ * Null to disable explicitly setting gas limit, undefined to use default sdk value
72
+ */
73
+ gasLimit: import_v4.z.bigint().nonnegative().nullable().optional()
69
74
  });
70
75
  // Annotate the CommonJS export names for ESM import in node:
71
76
  0 && (module.exports = {
@@ -53,7 +53,6 @@ class GearboxRewardsApy {
53
53
  rewardPoolsInfo,
54
54
  rewardPoolsSupply,
55
55
  tokensList,
56
- currentTokenData,
57
56
  currentTimestamp
58
57
  }) {
59
58
  const { underlyingToken, dieselRateRay } = pool;
@@ -61,7 +60,7 @@ class GearboxRewardsApy {
61
60
  const { decimals: underlyingDecimals = 18 } = tokensList[underlyingToken] || {};
62
61
  const underlyingPrice = prices[underlyingToken] ?? 0n;
63
62
  const dieselPrice = underlyingPrice * dieselRateRay / import_constants.RAY;
64
- const rewardAddress = currentTokenData[rewardPoolsInfo.symbol];
63
+ const rewardAddress = rewardPoolsInfo?.token || "";
65
64
  const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
66
65
  const rewardPrice = prices[rewardAddress] ?? 0n;
67
66
  const r = GearboxRewardsApy.calculateAPY_V3({
@@ -140,14 +139,13 @@ class GearboxRewardsApy {
140
139
  rewardInfo,
141
140
  supply,
142
141
  tokensList,
143
- currentTokenData,
144
142
  currentTimestamp
145
143
  }) {
146
144
  const { token, balance } = asset;
147
145
  const safeSupply = supply[token] ?? 0n;
148
146
  const { decimals: tokenDecimals = 18 } = tokensList[token] || {};
149
147
  const tokenPrice = prices[token] ?? 0n;
150
- const rewardAddress = currentTokenData[rewardInfo.symbol];
148
+ const rewardAddress = rewardInfo?.token || "";
151
149
  const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
152
150
  const rewardPrice = prices[rewardAddress] ?? 0n;
153
151
  const r = GearboxRewardsApy.calculateAPY_V3({
@@ -50,7 +50,7 @@ class GearboxSDK {
50
50
  #marketRegister;
51
51
  #priceFeeds;
52
52
  logger;
53
- gasLimit = 550000000n;
53
+ gasLimit;
54
54
  /**
55
55
  * Interest rate models can be reused across chain (and SDK operates on chain level)
56
56
  * TODO: use whatever interface is necessary for InterestRateModels
@@ -83,7 +83,8 @@ class GearboxSDK {
83
83
  ignoreUpdateablePrices,
84
84
  ignoreMarkets,
85
85
  marketConfigurators: mcs,
86
- strictContractTypes
86
+ strictContractTypes,
87
+ gasLimit
87
88
  } = options;
88
89
  let { networkType, addressProvider, chainId } = options;
89
90
  const attachClient = createPublicClient({
@@ -108,7 +109,8 @@ class GearboxSDK {
108
109
  provider,
109
110
  logger,
110
111
  plugins,
111
- strictContractTypes
112
+ strictContractTypes,
113
+ gasLimit
112
114
  }).#attach({
113
115
  addressProvider,
114
116
  blockNumber,
@@ -120,7 +122,7 @@ class GearboxSDK {
120
122
  });
121
123
  }
122
124
  static hydrate(options, state) {
123
- const { logger, plugins, strictContractTypes, ...rest } = options;
125
+ const { logger, plugins, strictContractTypes, gasLimit, ...rest } = options;
124
126
  const provider = new Provider({
125
127
  ...rest,
126
128
  chainId: state.chainId,
@@ -130,7 +132,8 @@ class GearboxSDK {
130
132
  provider,
131
133
  plugins,
132
134
  logger,
133
- strictContractTypes
135
+ strictContractTypes,
136
+ gasLimit
134
137
  }).#hydrate(rest, state);
135
138
  }
136
139
  constructor(options) {
@@ -141,6 +144,9 @@ class GearboxSDK {
141
144
  for (const plugin of Object.values(this.plugins)) {
142
145
  plugin.sdk = this;
143
146
  }
147
+ if (options.gasLimit !== null) {
148
+ this.gasLimit = options.gasLimit || 550000000n;
149
+ }
144
150
  }
145
151
  async #attach(opts) {
146
152
  const {
@@ -45,7 +45,12 @@ const SDKOptions = z.object({
45
45
  /**
46
46
  * Options related to pyth price feeds
47
47
  */
48
- pyth: PythOptions.optional()
48
+ pyth: PythOptions.optional(),
49
+ /**
50
+ * Explicit gas limit for read eth_calls
51
+ * Null to disable explicitly setting gas limit, undefined to use default sdk value
52
+ */
53
+ gasLimit: z.bigint().nonnegative().nullable().optional()
49
54
  });
50
55
  export {
51
56
  SDKOptions
@@ -36,7 +36,6 @@ class GearboxRewardsApy {
36
36
  rewardPoolsInfo,
37
37
  rewardPoolsSupply,
38
38
  tokensList,
39
- currentTokenData,
40
39
  currentTimestamp
41
40
  }) {
42
41
  const { underlyingToken, dieselRateRay } = pool;
@@ -44,7 +43,7 @@ class GearboxRewardsApy {
44
43
  const { decimals: underlyingDecimals = 18 } = tokensList[underlyingToken] || {};
45
44
  const underlyingPrice = prices[underlyingToken] ?? 0n;
46
45
  const dieselPrice = underlyingPrice * dieselRateRay / RAY;
47
- const rewardAddress = currentTokenData[rewardPoolsInfo.symbol];
46
+ const rewardAddress = rewardPoolsInfo?.token || "";
48
47
  const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
49
48
  const rewardPrice = prices[rewardAddress] ?? 0n;
50
49
  const r = GearboxRewardsApy.calculateAPY_V3({
@@ -123,14 +122,13 @@ class GearboxRewardsApy {
123
122
  rewardInfo,
124
123
  supply,
125
124
  tokensList,
126
- currentTokenData,
127
125
  currentTimestamp
128
126
  }) {
129
127
  const { token, balance } = asset;
130
128
  const safeSupply = supply[token] ?? 0n;
131
129
  const { decimals: tokenDecimals = 18 } = tokensList[token] || {};
132
130
  const tokenPrice = prices[token] ?? 0n;
133
- const rewardAddress = currentTokenData[rewardInfo.symbol];
131
+ const rewardAddress = rewardInfo?.token || "";
134
132
  const { decimals: rewardDecimals = 18 } = tokensList[rewardAddress] || {};
135
133
  const rewardPrice = prices[rewardAddress] ?? 0n;
136
134
  const r = GearboxRewardsApy.calculateAPY_V3({
@@ -31,7 +31,7 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
31
31
  #private;
32
32
  readonly plugins: Plugins;
33
33
  readonly logger?: ILogger;
34
- gasLimit: bigint | undefined;
34
+ readonly gasLimit: bigint | undefined;
35
35
  /**
36
36
  * Interest rate models can be reused across chain (and SDK operates on chain level)
37
37
  * TODO: use whatever interface is necessary for InterestRateModels
@@ -23,6 +23,7 @@ export declare const SDKOptions: z.ZodObject<{
23
23
  cacheTTL: z.ZodOptional<z.ZodNumber>;
24
24
  ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
25
25
  }, z.core.$strip>>;
26
+ gasLimit: z.ZodOptional<z.ZodNullable<z.ZodBigInt>>;
26
27
  }, z.core.$strip>;
27
28
  export type SDKOptions<Plugins extends PluginsMap> = Omit<z.infer<typeof SDKOptions>, "logger" | "plugins"> & {
28
29
  /**
@@ -1,6 +1,5 @@
1
1
  import type { Address } from "viem";
2
2
  import type { Asset } from "../../router/index.js";
3
- import type { SupportedToken } from "../../sdk-gov-legacy/index.js";
4
3
  import type { PoolData_Legacy } from "../core/pool.js";
5
4
  import type { TokenData } from "../tokens/tokenData.js";
6
5
  export interface FarmInfo {
@@ -9,7 +8,8 @@ export interface FarmInfo {
9
8
  duration: bigint;
10
9
  reward: bigint;
11
10
  balance: bigint;
12
- symbol: SupportedToken;
11
+ symbol: string;
12
+ token: Address;
13
13
  }
14
14
  export interface ExtraRewardApy {
15
15
  token: Address;
@@ -26,7 +26,6 @@ interface GetPoolExtraAPY_V3Props {
26
26
  rewardPoolsInfo: Record<Address, Array<FarmInfo>> | Record<Address, FarmInfo>;
27
27
  rewardPoolsSupply: Record<Address, bigint>;
28
28
  tokensList: Record<Address, TokenData>;
29
- currentTokenData: Record<SupportedToken, Address>;
30
29
  currentTimestamp: number;
31
30
  }
32
31
  interface GetCAExtraAPYProps {
@@ -36,7 +35,6 @@ interface GetCAExtraAPYProps {
36
35
  currentTimestamp: number;
37
36
  prices: Record<Address, bigint>;
38
37
  tokensList: Record<Address, TokenData>;
39
- currentTokenData: Record<SupportedToken, Address>;
40
38
  }
41
39
  export declare class GearboxRewardsApy {
42
40
  static getPoolExtraAPY_V3({ rewardPoolsInfo, stakedDieselToken, ...restProps }: GetPoolExtraAPY_V3Props): Array<ExtraRewardApy>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.14.4",
3
+ "version": "8.15.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",