@gearbox-protocol/sdk 6.0.2 → 7.0.0-next.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.
@@ -50,16 +50,13 @@ class GearboxSDK {
50
50
  #attachConfig;
51
51
  // Collection of markets
52
52
  #marketRegister;
53
+ #priceFeeds;
53
54
  logger;
54
55
  /**
55
56
  * Interest rate models can be reused across chain (and SDK operates on chain level)
56
57
  * TODO: use whatever interface is necessary for InterestRateModels
57
58
  */
58
59
  interestRateModels = new import_utils.AddressMap();
59
- /**
60
- * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
61
- */
62
- priceFeeds;
63
60
  /**
64
61
  * Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
65
62
  */
@@ -82,9 +79,10 @@ class GearboxSDK {
82
79
  logger,
83
80
  plugins,
84
81
  blockNumber,
85
- redstoneHistoricTimestamp,
82
+ redstone,
86
83
  ignoreUpdateablePrices,
87
- marketConfigurators: mcs
84
+ marketConfigurators: mcs,
85
+ strictContractTypes
88
86
  } = options;
89
87
  let { networkType, addressProvider, chainId } = options;
90
88
  const attachClient = (0, import_viem.createPublicClient)({
@@ -108,28 +106,33 @@ class GearboxSDK {
108
106
  return new GearboxSDK({
109
107
  provider,
110
108
  logger,
111
- plugins
109
+ plugins,
110
+ strictContractTypes
112
111
  }).#attach({
113
112
  addressProvider,
114
113
  blockNumber,
115
- redstoneHistoricTimestamp,
116
114
  ignoreUpdateablePrices,
117
- marketConfigurators
115
+ marketConfigurators,
116
+ redstone
118
117
  });
119
118
  }
120
119
  static hydrate(options, state) {
121
- const { logger, plugins, ...rest } = options;
120
+ const { logger, plugins, strictContractTypes, ...rest } = options;
122
121
  const provider = new import_chain.Provider({
123
122
  ...rest,
124
123
  chainId: state.chainId,
125
124
  networkType: state.network
126
125
  });
127
- return new GearboxSDK({ provider, plugins, logger }).#hydrate(rest, state);
126
+ return new GearboxSDK({
127
+ provider,
128
+ plugins,
129
+ logger,
130
+ strictContractTypes
131
+ }).#hydrate(rest, state);
128
132
  }
129
133
  constructor(options) {
130
134
  this.#provider = options.provider;
131
135
  this.logger = options.logger;
132
- this.priceFeeds = new import_pricefeeds.PriceFeedRegister(this);
133
136
  this.strictContractTypes = options.strictContractTypes ?? false;
134
137
  const pluginsInstances = {};
135
138
  for (const [name, Plugin] of import_utils.TypedObjectUtils.entries(
@@ -143,9 +146,9 @@ class GearboxSDK {
143
146
  const {
144
147
  addressProvider,
145
148
  blockNumber,
146
- redstoneHistoricTimestamp,
147
149
  ignoreUpdateablePrices,
148
- marketConfigurators
150
+ marketConfigurators,
151
+ redstone
149
152
  } = opts;
150
153
  const re = this.#attachConfig ? "re" : "";
151
154
  this.logger?.info(
@@ -157,7 +160,7 @@ class GearboxSDK {
157
160
  },
158
161
  `${re}attaching gearbox sdk`
159
162
  );
160
- if (!!blockNumber && !redstoneHistoricTimestamp) {
163
+ if (!!blockNumber && !opts.redstone?.historicTimestamp) {
161
164
  this.logger?.warn(
162
165
  `${re}attaching to fixed block number, but redstoneHistoricTimestamp is not set. price updates might fail`
163
166
  );
@@ -171,7 +174,7 @@ class GearboxSDK {
171
174
  );
172
175
  this.#currentBlock = block.number;
173
176
  this.#timestamp = block.timestamp;
174
- this.#confugureRedstone(opts);
177
+ this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone });
175
178
  this.logger?.debug(
176
179
  `${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
177
180
  );
@@ -207,7 +210,7 @@ class GearboxSDK {
207
210
  return this;
208
211
  }
209
212
  #hydrate(options, state) {
210
- const { logger: _logger, ...opts } = options;
213
+ const { logger: _logger, redstone, ...opts } = options;
211
214
  if (state.version !== STATE_VERSION) {
212
215
  throw new Error(
213
216
  `hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
@@ -215,7 +218,7 @@ class GearboxSDK {
215
218
  }
216
219
  this.#currentBlock = state.currentBlock;
217
220
  this.#timestamp = state.timestamp;
218
- this.#confugureRedstone(opts);
221
+ this.#priceFeeds = new import_pricefeeds.PriceFeedRegister(this, { redstone });
219
222
  this.#addressProvider = (0, import_core.hydrateAddressProvider)(this, state.addressProvider);
220
223
  this.logger?.debug(
221
224
  `address provider version: ${this.#addressProvider.version}`
@@ -241,15 +244,6 @@ class GearboxSDK {
241
244
  }
242
245
  return this;
243
246
  }
244
- #confugureRedstone(opts) {
245
- const { redstoneGateways, redstoneHistoricTimestamp } = opts;
246
- if (redstoneHistoricTimestamp) {
247
- this.priceFeeds.redstoneUpdater.historicalTimestamp = redstoneHistoricTimestamp === true ? Number(this.timestamp) * 1e3 : redstoneHistoricTimestamp;
248
- }
249
- if (redstoneGateways?.length) {
250
- this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
251
- }
252
- }
253
247
  /**
254
248
  * Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
255
249
  * Be mindful of block number, for example
@@ -351,7 +345,7 @@ class GearboxSDK {
351
345
  */
352
346
  async syncState(opts) {
353
347
  let { blockNumber, timestamp, skipPriceUpdate } = opts ?? {};
354
- if (this.#attachConfig?.redstoneHistoricTimestamp) {
348
+ if (this.#attachConfig?.redstone?.historicTimestamp) {
355
349
  throw new Error(
356
350
  "syncState is not supported with redstoneHistoricTimestamp"
357
351
  );
@@ -434,6 +428,15 @@ class GearboxSDK {
434
428
  }
435
429
  return this.#timestamp;
436
430
  }
431
+ /**
432
+ * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
433
+ */
434
+ get priceFeeds() {
435
+ if (this.#priceFeeds === void 0) {
436
+ throw ERR_NOT_ATTACHED;
437
+ }
438
+ return this.#priceFeeds;
439
+ }
437
440
  get gear() {
438
441
  try {
439
442
  const g = this.addressProvider.getAddress(import_constants.AP_GEAR_TOKEN, import_constants.NO_VERSION);
@@ -50,10 +50,10 @@ class PriceFeedRegister extends import_base.SDKConstruct {
50
50
  #feeds = new import_utils.AddressMap(void 0, "priceFeeds");
51
51
  #latestUpdate;
52
52
  redstoneUpdater;
53
- constructor(sdk) {
53
+ constructor(sdk, opts = {}) {
54
54
  super(sdk);
55
55
  this.logger = (0, import_utils.childLogger)("PriceFeedRegister", sdk.logger);
56
- this.redstoneUpdater = new import_RedstoneUpdater.RedstoneUpdater(sdk);
56
+ this.redstoneUpdater = new import_RedstoneUpdater.RedstoneUpdater(sdk, opts?.redstone);
57
57
  }
58
58
  addHook = this.#hooks.addHook.bind(this.#hooks);
59
59
  removeHook = this.#hooks.removeHook.bind(this.#hooks);
@@ -57,21 +57,17 @@ class RedstoneUpdater extends import_base.SDKConstruct {
57
57
  #cache = /* @__PURE__ */ new Map();
58
58
  #historicalTimestampMs;
59
59
  #gateways;
60
- constructor(sdk) {
60
+ #ignoreErrors;
61
+ constructor(sdk, opts = {}) {
61
62
  super(sdk);
62
63
  this.#logger = (0, import_utils.childLogger)("RedstoneUpdater", sdk.logger);
63
- }
64
- /**
65
- * Set redstone historical timestamp in milliseconds
66
- */
67
- set historicalTimestamp(timestampMs) {
68
- this.#historicalTimestampMs = 6e4 * Math.floor(timestampMs / 6e4);
69
- }
70
- /**
71
- * Set redstone gateways
72
- */
73
- set gateways(gateways) {
74
- this.#gateways = gateways;
64
+ this.#ignoreErrors = opts.ignoreErrors;
65
+ this.#gateways = opts.gateways?.length ? opts.gateways : void 0;
66
+ let ts = opts.historicTimestamp;
67
+ if (ts) {
68
+ ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
69
+ this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
70
+ }
75
71
  }
76
72
  async getUpdateTxs(feeds, logContext = {}) {
77
73
  this.#logger?.debug(
@@ -158,10 +154,20 @@ class RedstoneUpdater extends import_base.SDKConstruct {
158
154
  uncached.push(dataFeedId);
159
155
  }
160
156
  }
161
- const [fromRedstoneResp] = await Promise.allSettled([
162
- this.#fetchPayloads(dataServiceId, new Set(uncached), uniqueSignersCount)
163
- ]);
164
- const fromRedstone = fromRedstoneResp.status === "fulfilled" ? fromRedstoneResp.value : [];
157
+ let fromRedstone = [];
158
+ try {
159
+ fromRedstone = await this.#fetchPayloads(
160
+ dataServiceId,
161
+ new Set(uncached),
162
+ uniqueSignersCount
163
+ );
164
+ } catch (e) {
165
+ if (this.#ignoreErrors) {
166
+ this.#logger?.error(e);
167
+ } else {
168
+ throw e;
169
+ }
170
+ }
165
171
  if (this.#historicalTimestampMs) {
166
172
  for (const resp of fromRedstone) {
167
173
  const key = cacheKey(
@@ -176,9 +182,6 @@ class RedstoneUpdater extends import_base.SDKConstruct {
176
182
  this.#logger?.debug(
177
183
  `got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`
178
184
  );
179
- if (fromRedstoneResp.status === "rejected") {
180
- this.#logger?.error(fromRedstoneResp.reason);
181
- }
182
185
  return [...fromCache, ...fromRedstone];
183
186
  }
184
187
  /**
@@ -98,11 +98,11 @@ class GearboxBackendApi {
98
98
  static getStaticTokenUrl = () => STATIC_TOKEN;
99
99
  static getRewardsMerkleUrl = (network, root, account) => {
100
100
  const path = `${network}_${root.slice(2)}/${account.slice(2, 4)}`;
101
- const url = `https://am.gearbox.fi/${path.toLowerCase()}.json`;
101
+ const url = `https://am.gearbox.finance/${path.toLowerCase()}.json`;
102
102
  return url;
103
103
  };
104
104
  static getNFTMerkleUrl = (network, root) => {
105
- const url = `https://dm.gearbox.fi/${network.toLowerCase()}_${root}.json`;
105
+ const url = `https://dm.gearbox.finance/${network.toLowerCase()}_${root}.json`;
106
106
  return url;
107
107
  };
108
108
  static getLeaderboardUrl = (url, chainId) => {
@@ -27,6 +27,7 @@ __reExport(utils_exports, require("./json.js"), module.exports);
27
27
  __reExport(utils_exports, require("./mappers.js"), module.exports);
28
28
  __reExport(utils_exports, require("./retry.js"), module.exports);
29
29
  __reExport(utils_exports, require("./toAddress.js"), module.exports);
30
+ __reExport(utils_exports, require("./type-utils.js"), module.exports);
30
31
  // Annotate the CommonJS export names for ESM import in node:
31
32
  0 && (module.exports = {
32
33
  ...require("./AddressMap.js"),
@@ -40,5 +41,6 @@ __reExport(utils_exports, require("./toAddress.js"), module.exports);
40
41
  ...require("./json.js"),
41
42
  ...require("./mappers.js"),
42
43
  ...require("./retry.js"),
43
- ...require("./toAddress.js")
44
+ ...require("./toAddress.js"),
45
+ ...require("./type-utils.js")
44
46
  });
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var type_utils_exports = {};
16
+ module.exports = __toCommonJS(type_utils_exports);
@@ -48,16 +48,13 @@ class GearboxSDK {
48
48
  #attachConfig;
49
49
  // Collection of markets
50
50
  #marketRegister;
51
+ #priceFeeds;
51
52
  logger;
52
53
  /**
53
54
  * Interest rate models can be reused across chain (and SDK operates on chain level)
54
55
  * TODO: use whatever interface is necessary for InterestRateModels
55
56
  */
56
57
  interestRateModels = new AddressMap();
57
- /**
58
- * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
59
- */
60
- priceFeeds;
61
58
  /**
62
59
  * Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
63
60
  */
@@ -80,9 +77,10 @@ class GearboxSDK {
80
77
  logger,
81
78
  plugins,
82
79
  blockNumber,
83
- redstoneHistoricTimestamp,
80
+ redstone,
84
81
  ignoreUpdateablePrices,
85
- marketConfigurators: mcs
82
+ marketConfigurators: mcs,
83
+ strictContractTypes
86
84
  } = options;
87
85
  let { networkType, addressProvider, chainId } = options;
88
86
  const attachClient = createPublicClient({
@@ -106,28 +104,33 @@ class GearboxSDK {
106
104
  return new GearboxSDK({
107
105
  provider,
108
106
  logger,
109
- plugins
107
+ plugins,
108
+ strictContractTypes
110
109
  }).#attach({
111
110
  addressProvider,
112
111
  blockNumber,
113
- redstoneHistoricTimestamp,
114
112
  ignoreUpdateablePrices,
115
- marketConfigurators
113
+ marketConfigurators,
114
+ redstone
116
115
  });
117
116
  }
118
117
  static hydrate(options, state) {
119
- const { logger, plugins, ...rest } = options;
118
+ const { logger, plugins, strictContractTypes, ...rest } = options;
120
119
  const provider = new Provider({
121
120
  ...rest,
122
121
  chainId: state.chainId,
123
122
  networkType: state.network
124
123
  });
125
- return new GearboxSDK({ provider, plugins, logger }).#hydrate(rest, state);
124
+ return new GearboxSDK({
125
+ provider,
126
+ plugins,
127
+ logger,
128
+ strictContractTypes
129
+ }).#hydrate(rest, state);
126
130
  }
127
131
  constructor(options) {
128
132
  this.#provider = options.provider;
129
133
  this.logger = options.logger;
130
- this.priceFeeds = new PriceFeedRegister(this);
131
134
  this.strictContractTypes = options.strictContractTypes ?? false;
132
135
  const pluginsInstances = {};
133
136
  for (const [name, Plugin] of TypedObjectUtils.entries(
@@ -141,9 +144,9 @@ class GearboxSDK {
141
144
  const {
142
145
  addressProvider,
143
146
  blockNumber,
144
- redstoneHistoricTimestamp,
145
147
  ignoreUpdateablePrices,
146
- marketConfigurators
148
+ marketConfigurators,
149
+ redstone
147
150
  } = opts;
148
151
  const re = this.#attachConfig ? "re" : "";
149
152
  this.logger?.info(
@@ -155,7 +158,7 @@ class GearboxSDK {
155
158
  },
156
159
  `${re}attaching gearbox sdk`
157
160
  );
158
- if (!!blockNumber && !redstoneHistoricTimestamp) {
161
+ if (!!blockNumber && !opts.redstone?.historicTimestamp) {
159
162
  this.logger?.warn(
160
163
  `${re}attaching to fixed block number, but redstoneHistoricTimestamp is not set. price updates might fail`
161
164
  );
@@ -169,7 +172,7 @@ class GearboxSDK {
169
172
  );
170
173
  this.#currentBlock = block.number;
171
174
  this.#timestamp = block.timestamp;
172
- this.#confugureRedstone(opts);
175
+ this.#priceFeeds = new PriceFeedRegister(this, { redstone });
173
176
  this.logger?.debug(
174
177
  `${re}attach block number ${this.currentBlock} timestamp ${this.timestamp}`
175
178
  );
@@ -205,7 +208,7 @@ class GearboxSDK {
205
208
  return this;
206
209
  }
207
210
  #hydrate(options, state) {
208
- const { logger: _logger, ...opts } = options;
211
+ const { logger: _logger, redstone, ...opts } = options;
209
212
  if (state.version !== STATE_VERSION) {
210
213
  throw new Error(
211
214
  `hydrated state version is ${state.version}, but expected ${STATE_VERSION}`
@@ -213,7 +216,7 @@ class GearboxSDK {
213
216
  }
214
217
  this.#currentBlock = state.currentBlock;
215
218
  this.#timestamp = state.timestamp;
216
- this.#confugureRedstone(opts);
219
+ this.#priceFeeds = new PriceFeedRegister(this, { redstone });
217
220
  this.#addressProvider = hydrateAddressProvider(this, state.addressProvider);
218
221
  this.logger?.debug(
219
222
  `address provider version: ${this.#addressProvider.version}`
@@ -239,15 +242,6 @@ class GearboxSDK {
239
242
  }
240
243
  return this;
241
244
  }
242
- #confugureRedstone(opts) {
243
- const { redstoneGateways, redstoneHistoricTimestamp } = opts;
244
- if (redstoneHistoricTimestamp) {
245
- this.priceFeeds.redstoneUpdater.historicalTimestamp = redstoneHistoricTimestamp === true ? Number(this.timestamp) * 1e3 : redstoneHistoricTimestamp;
246
- }
247
- if (redstoneGateways?.length) {
248
- this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
249
- }
250
- }
251
245
  /**
252
246
  * Reattach SDK with the same config as before, without re-creating instance. Will load all state from scratch
253
247
  * Be mindful of block number, for example
@@ -349,7 +343,7 @@ class GearboxSDK {
349
343
  */
350
344
  async syncState(opts) {
351
345
  let { blockNumber, timestamp, skipPriceUpdate } = opts ?? {};
352
- if (this.#attachConfig?.redstoneHistoricTimestamp) {
346
+ if (this.#attachConfig?.redstone?.historicTimestamp) {
353
347
  throw new Error(
354
348
  "syncState is not supported with redstoneHistoricTimestamp"
355
349
  );
@@ -432,6 +426,15 @@ class GearboxSDK {
432
426
  }
433
427
  return this.#timestamp;
434
428
  }
429
+ /**
430
+ * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
431
+ */
432
+ get priceFeeds() {
433
+ if (this.#priceFeeds === void 0) {
434
+ throw ERR_NOT_ATTACHED;
435
+ }
436
+ return this.#priceFeeds;
437
+ }
435
438
  get gear() {
436
439
  try {
437
440
  const g = this.addressProvider.getAddress(AP_GEAR_TOKEN, NO_VERSION);
@@ -33,10 +33,10 @@ class PriceFeedRegister extends SDKConstruct {
33
33
  #feeds = new AddressMap(void 0, "priceFeeds");
34
34
  #latestUpdate;
35
35
  redstoneUpdater;
36
- constructor(sdk) {
36
+ constructor(sdk, opts = {}) {
37
37
  super(sdk);
38
38
  this.logger = childLogger("PriceFeedRegister", sdk.logger);
39
- this.redstoneUpdater = new RedstoneUpdater(sdk);
39
+ this.redstoneUpdater = new RedstoneUpdater(sdk, opts?.redstone);
40
40
  }
41
41
  addHook = this.#hooks.addHook.bind(this.#hooks);
42
42
  removeHook = this.#hooks.removeHook.bind(this.#hooks);
@@ -33,21 +33,17 @@ class RedstoneUpdater extends SDKConstruct {
33
33
  #cache = /* @__PURE__ */ new Map();
34
34
  #historicalTimestampMs;
35
35
  #gateways;
36
- constructor(sdk) {
36
+ #ignoreErrors;
37
+ constructor(sdk, opts = {}) {
37
38
  super(sdk);
38
39
  this.#logger = childLogger("RedstoneUpdater", sdk.logger);
39
- }
40
- /**
41
- * Set redstone historical timestamp in milliseconds
42
- */
43
- set historicalTimestamp(timestampMs) {
44
- this.#historicalTimestampMs = 6e4 * Math.floor(timestampMs / 6e4);
45
- }
46
- /**
47
- * Set redstone gateways
48
- */
49
- set gateways(gateways) {
50
- this.#gateways = gateways;
40
+ this.#ignoreErrors = opts.ignoreErrors;
41
+ this.#gateways = opts.gateways?.length ? opts.gateways : void 0;
42
+ let ts = opts.historicTimestamp;
43
+ if (ts) {
44
+ ts = ts === true ? Number(this.sdk.timestamp) * 1e3 : ts;
45
+ this.#historicalTimestampMs = 6e4 * Math.floor(ts / 6e4);
46
+ }
51
47
  }
52
48
  async getUpdateTxs(feeds, logContext = {}) {
53
49
  this.#logger?.debug(
@@ -134,10 +130,20 @@ class RedstoneUpdater extends SDKConstruct {
134
130
  uncached.push(dataFeedId);
135
131
  }
136
132
  }
137
- const [fromRedstoneResp] = await Promise.allSettled([
138
- this.#fetchPayloads(dataServiceId, new Set(uncached), uniqueSignersCount)
139
- ]);
140
- const fromRedstone = fromRedstoneResp.status === "fulfilled" ? fromRedstoneResp.value : [];
133
+ let fromRedstone = [];
134
+ try {
135
+ fromRedstone = await this.#fetchPayloads(
136
+ dataServiceId,
137
+ new Set(uncached),
138
+ uniqueSignersCount
139
+ );
140
+ } catch (e) {
141
+ if (this.#ignoreErrors) {
142
+ this.#logger?.error(e);
143
+ } else {
144
+ throw e;
145
+ }
146
+ }
141
147
  if (this.#historicalTimestampMs) {
142
148
  for (const resp of fromRedstone) {
143
149
  const key = cacheKey(
@@ -152,9 +158,6 @@ class RedstoneUpdater extends SDKConstruct {
152
158
  this.#logger?.debug(
153
159
  `got ${fromRedstone.length} new redstone updates and ${fromCache.length} from cache`
154
160
  );
155
- if (fromRedstoneResp.status === "rejected") {
156
- this.#logger?.error(fromRedstoneResp.reason);
157
- }
158
161
  return [...fromCache, ...fromRedstone];
159
162
  }
160
163
  /**
@@ -69,11 +69,11 @@ class GearboxBackendApi {
69
69
  static getStaticTokenUrl = () => STATIC_TOKEN;
70
70
  static getRewardsMerkleUrl = (network, root, account) => {
71
71
  const path = `${network}_${root.slice(2)}/${account.slice(2, 4)}`;
72
- const url = `https://am.gearbox.fi/${path.toLowerCase()}.json`;
72
+ const url = `https://am.gearbox.finance/${path.toLowerCase()}.json`;
73
73
  return url;
74
74
  };
75
75
  static getNFTMerkleUrl = (network, root) => {
76
- const url = `https://dm.gearbox.fi/${network.toLowerCase()}_${root}.json`;
76
+ const url = `https://dm.gearbox.finance/${network.toLowerCase()}_${root}.json`;
77
77
  return url;
78
78
  };
79
79
  static getLeaderboardUrl = (url, chainId) => {
@@ -10,3 +10,4 @@ export * from "./json.js";
10
10
  export * from "./mappers.js";
11
11
  export * from "./retry.js";
12
12
  export * from "./toAddress.js";
13
+ export * from "./type-utils.js";
File without changes
@@ -7,6 +7,7 @@ import type { IAddressProviderContract } from "./core/index.js";
7
7
  import { BotListContract, GearStakingContract } from "./core/index.js";
8
8
  import { MarketRegister } from "./market/MarketRegister.js";
9
9
  import { PriceFeedRegister } from "./market/pricefeeds/index.js";
10
+ import type { RedstoneOptions } from "./market/pricefeeds/RedstoneUpdater.js";
10
11
  import { type PluginConstructorMap, type PluginsMap } from "./plugins/index.js";
11
12
  import { type IRouterContract } from "./router/index.js";
12
13
  import type { GearboxState, GearboxStateHuman, ILogger, MultiCall } from "./types/index.js";
@@ -28,15 +29,6 @@ export interface SDKOptions<Plugins extends PluginsMap> {
28
29
  * Attach and load state at this specific block number
29
30
  */
30
31
  blockNumber?: bigint | number;
31
- /**
32
- * Fixed redstone historic timestamp in ms
33
- * Set to true to enable redstone historical mode using timestamp from attach block
34
- */
35
- redstoneHistoricTimestamp?: number | true;
36
- /**
37
- * Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
38
- */
39
- redstoneGateways?: string[];
40
32
  /**
41
33
  * Will skip updateable prices on attach and sync
42
34
  * Makes things faster when your service is not intereseted in prices
@@ -54,6 +46,10 @@ export interface SDKOptions<Plugins extends PluginsMap> {
54
46
  * Bring your own logger
55
47
  */
56
48
  logger?: ILogger;
49
+ /**
50
+ * Options related to redstone price feeds
51
+ */
52
+ redstone?: RedstoneOptions;
57
53
  }
58
54
  export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
59
55
  export interface SyncStateOptions {
@@ -73,10 +69,6 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
73
69
  * TODO: use whatever interface is necessary for InterestRateModels
74
70
  */
75
71
  readonly interestRateModels: AddressMap<BaseContract<readonly unknown[]>>;
76
- /**
77
- * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
78
- */
79
- readonly priceFeeds: PriceFeedRegister;
80
72
  /**
81
73
  * Will throw an error if contract type is not supported, otherwise will try to use generic contract first, if possible
82
74
  */
@@ -150,6 +142,10 @@ export declare class GearboxSDK<const Plugins extends PluginsMap = {}> {
150
142
  get provider(): Provider;
151
143
  get currentBlock(): bigint;
152
144
  get timestamp(): bigint;
145
+ /**
146
+ * All price feeds known to sdk, without oracle-related data (stalenessPeriod, main/reserve, etc.)
147
+ */
148
+ get priceFeeds(): PriceFeedRegister;
153
149
  get gear(): Address | undefined;
154
150
  get addressProvider(): IAddressProviderContract;
155
151
  get botListContract(): BotListContract | undefined;
@@ -5,7 +5,7 @@ import type { GearboxSDK } from "../../GearboxSDK.js";
5
5
  import type { ILogger } from "../../types/index.js";
6
6
  import type { IHooks } from "../../utils/internal/index.js";
7
7
  import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
8
- import type { RedstoneUpdateTask } from "./RedstoneUpdater.js";
8
+ import type { RedstoneOptions, RedstoneUpdateTask } from "./RedstoneUpdater.js";
9
9
  import { RedstoneUpdater } from "./RedstoneUpdater.js";
10
10
  import type { IPriceFeedContract, UpdatePriceFeedsResult } from "./types.js";
11
11
  export type PriceFeedRegisterHooks = {
@@ -14,6 +14,9 @@ export type PriceFeedRegisterHooks = {
14
14
  */
15
15
  updatesGenerated: [UpdatePriceFeedsResult];
16
16
  };
17
+ export interface PriceFeedRegisterOptions {
18
+ redstone?: RedstoneOptions;
19
+ }
17
20
  export interface LatestUpdate {
18
21
  timestamp: number;
19
22
  redstone: RedstoneUpdateTask[];
@@ -27,7 +30,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
27
30
  #private;
28
31
  readonly logger?: ILogger;
29
32
  readonly redstoneUpdater: RedstoneUpdater;
30
- constructor(sdk: GearboxSDK);
33
+ constructor(sdk: GearboxSDK, opts?: PriceFeedRegisterOptions);
31
34
  addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
32
35
  removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
33
36
  /**
@@ -17,19 +17,26 @@ export declare class RedstoneUpdateTx implements IPriceUpdateTx<RedstoneUpdateTa
17
17
  get pretty(): string;
18
18
  validateTimestamp(blockTimestamp: bigint): "valid" | "too old" | "in future";
19
19
  }
20
+ export interface RedstoneOptions {
21
+ /**
22
+ * Fixed redstone historic timestamp in ms
23
+ * Set to true to enable redstone historical mode using timestamp from attach block
24
+ */
25
+ historicTimestamp?: number | true;
26
+ /**
27
+ * Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
28
+ */
29
+ gateways?: string[];
30
+ /**
31
+ * Ignore redstone SDK errors
32
+ */
33
+ ignoreErrors?: boolean;
34
+ }
20
35
  /**
21
36
  * Class to update multiple redstone price feeds at once
22
37
  */
23
38
  export declare class RedstoneUpdater extends SDKConstruct {
24
39
  #private;
25
- constructor(sdk: GearboxSDK);
26
- /**
27
- * Set redstone historical timestamp in milliseconds
28
- */
29
- set historicalTimestamp(timestampMs: number);
30
- /**
31
- * Set redstone gateways
32
- */
33
- set gateways(gateways: string[]);
40
+ constructor(sdk: GearboxSDK, opts?: RedstoneOptions);
34
41
  getUpdateTxs(feeds: RedstonePriceFeedContract[], logContext?: Record<string, any>): Promise<RedstoneUpdateTx[]>;
35
42
  }
@@ -10,3 +10,4 @@ export * from "./json.js";
10
10
  export * from "./mappers.js";
11
11
  export * from "./retry.js";
12
12
  export * from "./toAddress.js";
13
+ export * from "./type-utils.js";
@@ -0,0 +1 @@
1
+ export type PickSomeRequired<T, RequiredKeys extends keyof T, OptionalKeys extends keyof T> = Required<Pick<T, RequiredKeys>> & Partial<Pick<T, OptionalKeys>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "6.0.2",
3
+ "version": "7.0.0-next.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",