@gearbox-protocol/sdk 9.9.1 → 9.9.3
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.
- package/dist/cjs/sdk/GearboxSDK.js +6 -2
- package/dist/cjs/sdk/market/MarketRegister.js +4 -3
- package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +20 -6
- package/dist/esm/sdk/GearboxSDK.js +6 -2
- package/dist/esm/sdk/market/MarketRegister.js +4 -3
- package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +20 -6
- package/dist/types/sdk/GearboxSDK.d.ts +1 -1
- package/dist/types/sdk/market/MarketRegister.d.ts +1 -1
- package/package.json +1 -1
|
@@ -397,7 +397,11 @@ class GearboxSDK {
|
|
|
397
397
|
* @returns
|
|
398
398
|
*/
|
|
399
399
|
async syncState(opts) {
|
|
400
|
-
let {
|
|
400
|
+
let {
|
|
401
|
+
blockNumber,
|
|
402
|
+
timestamp,
|
|
403
|
+
ignoreUpdateablePrices = this.#attachConfig?.ignoreUpdateablePrices
|
|
404
|
+
} = opts ?? {};
|
|
401
405
|
if (this.#attachConfig?.redstone?.historicTimestamp || this.#attachConfig?.pyth?.historicTimestamp) {
|
|
402
406
|
throw new Error(
|
|
403
407
|
"syncState is not supported with redstone or pyth historicTimestamp"
|
|
@@ -452,7 +456,7 @@ class GearboxSDK {
|
|
|
452
456
|
}
|
|
453
457
|
this.#currentBlock = blockNumber;
|
|
454
458
|
this.#timestamp = timestamp;
|
|
455
|
-
await this.marketRegister.syncState(
|
|
459
|
+
await this.marketRegister.syncState(ignoreUpdateablePrices);
|
|
456
460
|
await this.#hooks.triggerHooks("syncState", { blockNumber, timestamp });
|
|
457
461
|
const pluginsList = import_utils.TypedObjectUtils.entries(this.plugins);
|
|
458
462
|
const pluginResponse = await Promise.allSettled(
|
|
@@ -95,7 +95,7 @@ class MarketRegister extends import_base.SDKConstruct {
|
|
|
95
95
|
}
|
|
96
96
|
return this.#marketFilter;
|
|
97
97
|
}
|
|
98
|
-
async syncState(
|
|
98
|
+
async syncState(ignoreUpdateablePrices) {
|
|
99
99
|
const dirty = this.markets.some((m) => m.dirty) || this.marketConfigurators.some((c) => c.dirty);
|
|
100
100
|
if (dirty) {
|
|
101
101
|
this.#logger?.debug(
|
|
@@ -103,9 +103,10 @@ class MarketRegister extends import_base.SDKConstruct {
|
|
|
103
103
|
);
|
|
104
104
|
await this.#loadMarkets(
|
|
105
105
|
[...this.marketFilter.configurators],
|
|
106
|
-
[...this.marketFilter.pools]
|
|
106
|
+
[...this.marketFilter.pools],
|
|
107
|
+
ignoreUpdateablePrices
|
|
107
108
|
);
|
|
108
|
-
} else if (!
|
|
109
|
+
} else if (!ignoreUpdateablePrices) {
|
|
109
110
|
await this.updatePrices();
|
|
110
111
|
}
|
|
111
112
|
}
|
|
@@ -228,22 +228,36 @@ class RedstoneUpdater extends import_base.SDKConstruct {
|
|
|
228
228
|
);
|
|
229
229
|
const parsed = import_protocol.RedstonePayload.parse((0, import_viem.toBytes)(`0x${dataPayload}`));
|
|
230
230
|
const packagesByDataFeedId = groupDataPackages(parsed.signedDataPackages);
|
|
231
|
-
|
|
231
|
+
const result = [];
|
|
232
|
+
for (const dataFeedId of dataFeedsIds) {
|
|
232
233
|
const signedDataPackages = packagesByDataFeedId[dataFeedId];
|
|
233
234
|
if (!signedDataPackages) {
|
|
235
|
+
if (this.#ignoreMissingFeeds) {
|
|
236
|
+
this.#logger?.warn(`cannot find data packages for ${dataFeedId}`);
|
|
237
|
+
continue;
|
|
238
|
+
}
|
|
234
239
|
throw new Error(`cannot find data packages for ${dataFeedId}`);
|
|
235
240
|
}
|
|
236
241
|
if (signedDataPackages.length !== uniqueSignersCount) {
|
|
242
|
+
if (this.#ignoreMissingFeeds) {
|
|
243
|
+
this.#logger?.warn(
|
|
244
|
+
`got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
|
|
245
|
+
);
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
237
248
|
throw new Error(
|
|
238
249
|
`got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
|
|
239
250
|
);
|
|
240
251
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
252
|
+
result.push(
|
|
253
|
+
getCalldataWithTimestamp(
|
|
254
|
+
dataFeedId,
|
|
255
|
+
signedDataPackages,
|
|
256
|
+
wrapper.getUnsignedMetadata()
|
|
257
|
+
)
|
|
245
258
|
);
|
|
246
|
-
}
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
247
261
|
}
|
|
248
262
|
}
|
|
249
263
|
function groupDataPackages(signedDataPackages) {
|
|
@@ -395,7 +395,11 @@ class GearboxSDK {
|
|
|
395
395
|
* @returns
|
|
396
396
|
*/
|
|
397
397
|
async syncState(opts) {
|
|
398
|
-
let {
|
|
398
|
+
let {
|
|
399
|
+
blockNumber,
|
|
400
|
+
timestamp,
|
|
401
|
+
ignoreUpdateablePrices = this.#attachConfig?.ignoreUpdateablePrices
|
|
402
|
+
} = opts ?? {};
|
|
399
403
|
if (this.#attachConfig?.redstone?.historicTimestamp || this.#attachConfig?.pyth?.historicTimestamp) {
|
|
400
404
|
throw new Error(
|
|
401
405
|
"syncState is not supported with redstone or pyth historicTimestamp"
|
|
@@ -450,7 +454,7 @@ class GearboxSDK {
|
|
|
450
454
|
}
|
|
451
455
|
this.#currentBlock = blockNumber;
|
|
452
456
|
this.#timestamp = timestamp;
|
|
453
|
-
await this.marketRegister.syncState(
|
|
457
|
+
await this.marketRegister.syncState(ignoreUpdateablePrices);
|
|
454
458
|
await this.#hooks.triggerHooks("syncState", { blockNumber, timestamp });
|
|
455
459
|
const pluginsList = TypedObjectUtils.entries(this.plugins);
|
|
456
460
|
const pluginResponse = await Promise.allSettled(
|
|
@@ -76,7 +76,7 @@ class MarketRegister extends SDKConstruct {
|
|
|
76
76
|
}
|
|
77
77
|
return this.#marketFilter;
|
|
78
78
|
}
|
|
79
|
-
async syncState(
|
|
79
|
+
async syncState(ignoreUpdateablePrices) {
|
|
80
80
|
const dirty = this.markets.some((m) => m.dirty) || this.marketConfigurators.some((c) => c.dirty);
|
|
81
81
|
if (dirty) {
|
|
82
82
|
this.#logger?.debug(
|
|
@@ -84,9 +84,10 @@ class MarketRegister extends SDKConstruct {
|
|
|
84
84
|
);
|
|
85
85
|
await this.#loadMarkets(
|
|
86
86
|
[...this.marketFilter.configurators],
|
|
87
|
-
[...this.marketFilter.pools]
|
|
87
|
+
[...this.marketFilter.pools],
|
|
88
|
+
ignoreUpdateablePrices
|
|
88
89
|
);
|
|
89
|
-
} else if (!
|
|
90
|
+
} else if (!ignoreUpdateablePrices) {
|
|
90
91
|
await this.updatePrices();
|
|
91
92
|
}
|
|
92
93
|
}
|
|
@@ -206,22 +206,36 @@ class RedstoneUpdater extends SDKConstruct {
|
|
|
206
206
|
);
|
|
207
207
|
const parsed = RedstonePayload.parse(toBytes(`0x${dataPayload}`));
|
|
208
208
|
const packagesByDataFeedId = groupDataPackages(parsed.signedDataPackages);
|
|
209
|
-
|
|
209
|
+
const result = [];
|
|
210
|
+
for (const dataFeedId of dataFeedsIds) {
|
|
210
211
|
const signedDataPackages = packagesByDataFeedId[dataFeedId];
|
|
211
212
|
if (!signedDataPackages) {
|
|
213
|
+
if (this.#ignoreMissingFeeds) {
|
|
214
|
+
this.#logger?.warn(`cannot find data packages for ${dataFeedId}`);
|
|
215
|
+
continue;
|
|
216
|
+
}
|
|
212
217
|
throw new Error(`cannot find data packages for ${dataFeedId}`);
|
|
213
218
|
}
|
|
214
219
|
if (signedDataPackages.length !== uniqueSignersCount) {
|
|
220
|
+
if (this.#ignoreMissingFeeds) {
|
|
221
|
+
this.#logger?.warn(
|
|
222
|
+
`got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
|
|
223
|
+
);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
215
226
|
throw new Error(
|
|
216
227
|
`got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
|
|
217
228
|
);
|
|
218
229
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
230
|
+
result.push(
|
|
231
|
+
getCalldataWithTimestamp(
|
|
232
|
+
dataFeedId,
|
|
233
|
+
signedDataPackages,
|
|
234
|
+
wrapper.getUnsignedMetadata()
|
|
235
|
+
)
|
|
223
236
|
);
|
|
224
|
-
}
|
|
237
|
+
}
|
|
238
|
+
return result;
|
|
225
239
|
}
|
|
226
240
|
}
|
|
227
241
|
function groupDataPackages(signedDataPackages) {
|
|
@@ -21,7 +21,7 @@ export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins
|
|
|
21
21
|
export interface SyncStateOptions {
|
|
22
22
|
blockNumber: bigint;
|
|
23
23
|
timestamp: bigint;
|
|
24
|
-
|
|
24
|
+
ignoreUpdateablePrices?: boolean;
|
|
25
25
|
}
|
|
26
26
|
export type SDKHooks = {
|
|
27
27
|
syncState: [SyncStateOptions];
|
|
@@ -15,7 +15,7 @@ export declare class MarketRegister extends SDKConstruct {
|
|
|
15
15
|
hydrate(state: MarketData[]): void;
|
|
16
16
|
loadMarkets(marketConfigurators: Address[], ignoreUpdateablePrices?: boolean): Promise<void>;
|
|
17
17
|
get marketFilter(): MarketFilter;
|
|
18
|
-
syncState(
|
|
18
|
+
syncState(ignoreUpdateablePrices?: boolean): Promise<void>;
|
|
19
19
|
/**
|
|
20
20
|
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
21
21
|
* Supports v300 and v310 oracles
|