@gearbox-protocol/sdk 3.0.0-vfour.190 → 3.0.0-vfour.191

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.
@@ -63799,13 +63799,23 @@ var RedstoneUpdater = class extends SDKConstruct {
63799
63799
  #logger;
63800
63800
  #cache = /* @__PURE__ */ new Map();
63801
63801
  #historicalTimestampMs;
63802
+ #gateways;
63802
63803
  constructor(sdk) {
63803
63804
  super(sdk);
63804
63805
  this.#logger = childLogger("RedstoneUpdater", sdk.logger);
63805
63806
  }
63806
- setHistoricalTimestamp(timestampMs) {
63807
+ /**
63808
+ * Set redstone historical timestamp in milliseconds
63809
+ */
63810
+ set historicalTimestamp(timestampMs) {
63807
63811
  this.#historicalTimestampMs = 6e4 * Math.floor(timestampMs / 6e4);
63808
63812
  }
63813
+ /**
63814
+ * Set redstone gateways
63815
+ */
63816
+ set gateways(gateways) {
63817
+ this.#gateways = gateways;
63818
+ }
63809
63819
  async getUpdateTxs(feeds, logContext = {}) {
63810
63820
  this.#logger?.debug(
63811
63821
  logContext,
@@ -63922,7 +63932,8 @@ var RedstoneUpdater = class extends SDKConstruct {
63922
63932
  dataServiceId,
63923
63933
  dataPackagesIds,
63924
63934
  uniqueSignersCount,
63925
- historicalTimestamp: this.#historicalTimestampMs
63935
+ historicalTimestamp: this.#historicalTimestampMs,
63936
+ urls: this.#gateways
63926
63937
  });
63927
63938
  const dataPayload = await wrapper.prepareRedstonePayload(true);
63928
63939
  const parsed = protocol.RedstonePayload.parse(viem.toBytes(`0x${dataPayload}`));
@@ -64045,11 +64056,11 @@ var PriceFeedRegister = class extends SDKConstruct {
64045
64056
  logger;
64046
64057
  #hooks = new Hooks();
64047
64058
  #feeds = new AddressMap();
64048
- #redstoneUpdater;
64059
+ redstoneUpdater;
64049
64060
  constructor(sdk) {
64050
64061
  super(sdk);
64051
64062
  this.logger = childLogger("PriceFeedRegister", sdk.logger);
64052
- this.#redstoneUpdater = new RedstoneUpdater(sdk);
64063
+ this.redstoneUpdater = new RedstoneUpdater(sdk);
64053
64064
  }
64054
64065
  addHook = this.#hooks.addHook.bind(this.#hooks);
64055
64066
  removeHook = this.#hooks.removeHook.bind(this.#hooks);
@@ -64078,14 +64089,6 @@ var PriceFeedRegister = class extends SDKConstruct {
64078
64089
  this.#feeds.upsert(data.baseParams.addr, feed);
64079
64090
  return feed;
64080
64091
  }
64081
- /**
64082
- * Set redstone historical timestamp
64083
- * @param timestampMs in milliseconds, or true to use timestamp from attach block
64084
- */
64085
- setRedstoneHistoricalTimestamp(timestampMs) {
64086
- const ts = timestampMs === true ? Number(this.sdk.timestamp) * 1e3 : timestampMs;
64087
- this.#redstoneUpdater.setHistoricalTimestamp(ts);
64088
- }
64089
64092
  /**
64090
64093
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
64091
64094
  * This can later be used to load price feed updates
@@ -64141,7 +64144,7 @@ var PriceFeedRegister = class extends SDKConstruct {
64141
64144
  }
64142
64145
  let maxTimestamp = 0;
64143
64146
  if (redstonePFs.length > 0) {
64144
- const redstoneUpdates = await this.#redstoneUpdater.getUpdateTxs(
64147
+ const redstoneUpdates = await this.redstoneUpdater.getUpdateTxs(
64145
64148
  redstonePFs,
64146
64149
  logContext
64147
64150
  );
@@ -72330,6 +72333,7 @@ var GearboxSDK = class _GearboxSDK {
72330
72333
  addressProvider,
72331
72334
  blockNumber,
72332
72335
  redstoneHistoricTimestamp,
72336
+ redstoneGateways,
72333
72337
  ignoreUpdateablePrices,
72334
72338
  marketConfigurators
72335
72339
  } = opts;
@@ -72342,7 +72346,10 @@ var GearboxSDK = class _GearboxSDK {
72342
72346
  this.#currentBlock = block.number;
72343
72347
  this.#timestamp = block.timestamp;
72344
72348
  if (redstoneHistoricTimestamp) {
72345
- this.priceFeeds.setRedstoneHistoricalTimestamp(redstoneHistoricTimestamp);
72349
+ this.priceFeeds.redstoneUpdater.historicalTimestamp = redstoneHistoricTimestamp === true ? Number(block.timestamp) * 1e3 : redstoneHistoricTimestamp;
72350
+ }
72351
+ if (redstoneGateways) {
72352
+ this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
72346
72353
  }
72347
72354
  this.logger?.info(
72348
72355
  {
@@ -85126,6 +85126,38 @@ interface IHooks<HookMap extends Record<string, any[]>> {
85126
85126
  removeHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
85127
85127
  }
85128
85128
 
85129
+ type abi$j = typeof redstonePriceFeedAbi;
85130
+ declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi$j> {
85131
+ readonly dataServiceId: string;
85132
+ readonly dataId: string;
85133
+ readonly signers: Hex[];
85134
+ readonly signersThreshold: number;
85135
+ constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
85136
+ stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
85137
+ }
85138
+
85139
+ interface UpdatePFTask {
85140
+ priceFeed: Address;
85141
+ tx: RawTx;
85142
+ timestamp: number;
85143
+ }
85144
+ /**
85145
+ * Class to update multiple redstone price feeds at once
85146
+ */
85147
+ declare class RedstoneUpdater extends SDKConstruct {
85148
+ #private;
85149
+ constructor(sdk: GearboxSDK);
85150
+ /**
85151
+ * Set redstone historical timestamp in milliseconds
85152
+ */
85153
+ set historicalTimestamp(timestampMs: number);
85154
+ /**
85155
+ * Set redstone gateways
85156
+ */
85157
+ set gateways(gateways: string[]);
85158
+ getUpdateTxs(feeds: RedstonePriceFeedContract[], logContext?: Record<string, any>): Promise<UpdatePFTask[]>;
85159
+ }
85160
+
85129
85161
  type PriceFeedRegisterHooks = {
85130
85162
  /**
85131
85163
  * Emitted when transactions to update price feeds have been generated, but before they're used anywhere
@@ -85140,6 +85172,7 @@ type PriceFeedRegisterHooks = {
85140
85172
  declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeedRegisterHooks> {
85141
85173
  #private;
85142
85174
  readonly logger?: ILogger;
85175
+ readonly redstoneUpdater: RedstoneUpdater;
85143
85176
  constructor(sdk: GearboxSDK);
85144
85177
  addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
85145
85178
  removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
@@ -85153,11 +85186,6 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
85153
85186
  has(address: Address): boolean;
85154
85187
  mustGet(address: Address): IPriceFeedContract;
85155
85188
  getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
85156
- /**
85157
- * Set redstone historical timestamp
85158
- * @param timestampMs in milliseconds, or true to use timestamp from attach block
85159
- */
85160
- setRedstoneHistoricalTimestamp(timestampMs: number | true): void;
85161
85189
  /**
85162
85190
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
85163
85191
  * This can later be used to load price feed updates
@@ -85173,16 +85201,6 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
85173
85201
  create(data: PartialPriceFeedTreeNode): IPriceFeedContract;
85174
85202
  }
85175
85203
 
85176
- type abi$j = typeof redstonePriceFeedAbi;
85177
- declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi$j> {
85178
- readonly dataServiceId: string;
85179
- readonly dataId: string;
85180
- readonly signers: Hex[];
85181
- readonly signersThreshold: number;
85182
- constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
85183
- stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
85184
- }
85185
-
85186
85204
  /**
85187
85205
  * Helper method to convert our RawTx into viem's multicall format
85188
85206
  * Involves decoding what was previously encoded, but it's better than adding another method to PriceOracle
@@ -92343,6 +92361,10 @@ interface SDKOptions {
92343
92361
  * Set to true to enable redstone historical mode using timestamp from attach block
92344
92362
  */
92345
92363
  redstoneHistoricTimestamp?: number | true;
92364
+ /**
92365
+ * Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
92366
+ */
92367
+ redstoneGateways?: string[];
92346
92368
  /**
92347
92369
  * Will skip updateable prices on attach and sync
92348
92370
  * Makes things faster when your service is not intereseted in prices
@@ -85126,6 +85126,38 @@ interface IHooks<HookMap extends Record<string, any[]>> {
85126
85126
  removeHook: <K extends keyof HookMap>(hookName: K, fn: (...args: HookMap[K]) => void | Promise<void>) => void;
85127
85127
  }
85128
85128
 
85129
+ type abi$j = typeof redstonePriceFeedAbi;
85130
+ declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi$j> {
85131
+ readonly dataServiceId: string;
85132
+ readonly dataId: string;
85133
+ readonly signers: Hex[];
85134
+ readonly signersThreshold: number;
85135
+ constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
85136
+ stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
85137
+ }
85138
+
85139
+ interface UpdatePFTask {
85140
+ priceFeed: Address;
85141
+ tx: RawTx;
85142
+ timestamp: number;
85143
+ }
85144
+ /**
85145
+ * Class to update multiple redstone price feeds at once
85146
+ */
85147
+ declare class RedstoneUpdater extends SDKConstruct {
85148
+ #private;
85149
+ constructor(sdk: GearboxSDK);
85150
+ /**
85151
+ * Set redstone historical timestamp in milliseconds
85152
+ */
85153
+ set historicalTimestamp(timestampMs: number);
85154
+ /**
85155
+ * Set redstone gateways
85156
+ */
85157
+ set gateways(gateways: string[]);
85158
+ getUpdateTxs(feeds: RedstonePriceFeedContract[], logContext?: Record<string, any>): Promise<UpdatePFTask[]>;
85159
+ }
85160
+
85129
85161
  type PriceFeedRegisterHooks = {
85130
85162
  /**
85131
85163
  * Emitted when transactions to update price feeds have been generated, but before they're used anywhere
@@ -85140,6 +85172,7 @@ type PriceFeedRegisterHooks = {
85140
85172
  declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeedRegisterHooks> {
85141
85173
  #private;
85142
85174
  readonly logger?: ILogger;
85175
+ readonly redstoneUpdater: RedstoneUpdater;
85143
85176
  constructor(sdk: GearboxSDK);
85144
85177
  addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
85145
85178
  removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
@@ -85153,11 +85186,6 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
85153
85186
  has(address: Address): boolean;
85154
85187
  mustGet(address: Address): IPriceFeedContract;
85155
85188
  getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
85156
- /**
85157
- * Set redstone historical timestamp
85158
- * @param timestampMs in milliseconds, or true to use timestamp from attach block
85159
- */
85160
- setRedstoneHistoricalTimestamp(timestampMs: number | true): void;
85161
85189
  /**
85162
85190
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
85163
85191
  * This can later be used to load price feed updates
@@ -85173,16 +85201,6 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
85173
85201
  create(data: PartialPriceFeedTreeNode): IPriceFeedContract;
85174
85202
  }
85175
85203
 
85176
- type abi$j = typeof redstonePriceFeedAbi;
85177
- declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi$j> {
85178
- readonly dataServiceId: string;
85179
- readonly dataId: string;
85180
- readonly signers: Hex[];
85181
- readonly signersThreshold: number;
85182
- constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
85183
- stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
85184
- }
85185
-
85186
85204
  /**
85187
85205
  * Helper method to convert our RawTx into viem's multicall format
85188
85206
  * Involves decoding what was previously encoded, but it's better than adding another method to PriceOracle
@@ -92343,6 +92361,10 @@ interface SDKOptions {
92343
92361
  * Set to true to enable redstone historical mode using timestamp from attach block
92344
92362
  */
92345
92363
  redstoneHistoricTimestamp?: number | true;
92364
+ /**
92365
+ * Override redstone gateways. Can be used to set caching proxies, to avoid rate limiting
92366
+ */
92367
+ redstoneGateways?: string[];
92346
92368
  /**
92347
92369
  * Will skip updateable prices on attach and sync
92348
92370
  * Makes things faster when your service is not intereseted in prices
@@ -63792,13 +63792,23 @@ var RedstoneUpdater = class extends SDKConstruct {
63792
63792
  #logger;
63793
63793
  #cache = /* @__PURE__ */ new Map();
63794
63794
  #historicalTimestampMs;
63795
+ #gateways;
63795
63796
  constructor(sdk) {
63796
63797
  super(sdk);
63797
63798
  this.#logger = childLogger("RedstoneUpdater", sdk.logger);
63798
63799
  }
63799
- setHistoricalTimestamp(timestampMs) {
63800
+ /**
63801
+ * Set redstone historical timestamp in milliseconds
63802
+ */
63803
+ set historicalTimestamp(timestampMs) {
63800
63804
  this.#historicalTimestampMs = 6e4 * Math.floor(timestampMs / 6e4);
63801
63805
  }
63806
+ /**
63807
+ * Set redstone gateways
63808
+ */
63809
+ set gateways(gateways) {
63810
+ this.#gateways = gateways;
63811
+ }
63802
63812
  async getUpdateTxs(feeds, logContext = {}) {
63803
63813
  this.#logger?.debug(
63804
63814
  logContext,
@@ -63915,7 +63925,8 @@ var RedstoneUpdater = class extends SDKConstruct {
63915
63925
  dataServiceId,
63916
63926
  dataPackagesIds,
63917
63927
  uniqueSignersCount,
63918
- historicalTimestamp: this.#historicalTimestampMs
63928
+ historicalTimestamp: this.#historicalTimestampMs,
63929
+ urls: this.#gateways
63919
63930
  });
63920
63931
  const dataPayload = await wrapper.prepareRedstonePayload(true);
63921
63932
  const parsed = RedstonePayload.parse(toBytes(`0x${dataPayload}`));
@@ -64038,11 +64049,11 @@ var PriceFeedRegister = class extends SDKConstruct {
64038
64049
  logger;
64039
64050
  #hooks = new Hooks();
64040
64051
  #feeds = new AddressMap();
64041
- #redstoneUpdater;
64052
+ redstoneUpdater;
64042
64053
  constructor(sdk) {
64043
64054
  super(sdk);
64044
64055
  this.logger = childLogger("PriceFeedRegister", sdk.logger);
64045
- this.#redstoneUpdater = new RedstoneUpdater(sdk);
64056
+ this.redstoneUpdater = new RedstoneUpdater(sdk);
64046
64057
  }
64047
64058
  addHook = this.#hooks.addHook.bind(this.#hooks);
64048
64059
  removeHook = this.#hooks.removeHook.bind(this.#hooks);
@@ -64071,14 +64082,6 @@ var PriceFeedRegister = class extends SDKConstruct {
64071
64082
  this.#feeds.upsert(data.baseParams.addr, feed);
64072
64083
  return feed;
64073
64084
  }
64074
- /**
64075
- * Set redstone historical timestamp
64076
- * @param timestampMs in milliseconds, or true to use timestamp from attach block
64077
- */
64078
- setRedstoneHistoricalTimestamp(timestampMs) {
64079
- const ts = timestampMs === true ? Number(this.sdk.timestamp) * 1e3 : timestampMs;
64080
- this.#redstoneUpdater.setHistoricalTimestamp(ts);
64081
- }
64082
64085
  /**
64083
64086
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
64084
64087
  * This can later be used to load price feed updates
@@ -64134,7 +64137,7 @@ var PriceFeedRegister = class extends SDKConstruct {
64134
64137
  }
64135
64138
  let maxTimestamp = 0;
64136
64139
  if (redstonePFs.length > 0) {
64137
- const redstoneUpdates = await this.#redstoneUpdater.getUpdateTxs(
64140
+ const redstoneUpdates = await this.redstoneUpdater.getUpdateTxs(
64138
64141
  redstonePFs,
64139
64142
  logContext
64140
64143
  );
@@ -72323,6 +72326,7 @@ var GearboxSDK = class _GearboxSDK {
72323
72326
  addressProvider,
72324
72327
  blockNumber,
72325
72328
  redstoneHistoricTimestamp,
72329
+ redstoneGateways,
72326
72330
  ignoreUpdateablePrices,
72327
72331
  marketConfigurators
72328
72332
  } = opts;
@@ -72335,7 +72339,10 @@ var GearboxSDK = class _GearboxSDK {
72335
72339
  this.#currentBlock = block.number;
72336
72340
  this.#timestamp = block.timestamp;
72337
72341
  if (redstoneHistoricTimestamp) {
72338
- this.priceFeeds.setRedstoneHistoricalTimestamp(redstoneHistoricTimestamp);
72342
+ this.priceFeeds.redstoneUpdater.historicalTimestamp = redstoneHistoricTimestamp === true ? Number(block.timestamp) * 1e3 : redstoneHistoricTimestamp;
72343
+ }
72344
+ if (redstoneGateways) {
72345
+ this.priceFeeds.redstoneUpdater.gateways = redstoneGateways;
72339
72346
  }
72340
72347
  this.logger?.info(
72341
72348
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfour.190",
3
+ "version": "3.0.0-vfour.191",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.cjs",