@gearbox-protocol/sdk 13.0.0-beta.5 → 13.0.0-beta.7

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.
Files changed (28) hide show
  1. package/dist/cjs/common-utils/utils/creditAccount/index.js +2 -0
  2. package/dist/cjs/permissionless/utils/price-update/get-prices.js +2 -6
  3. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +2 -1
  4. package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
  5. package/dist/cjs/sdk/market/MarketConfiguratorContract.js +3 -2
  6. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +5 -3
  7. package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +6 -6
  8. package/dist/cjs/sdk/market/pricefeeds/updates/RedstoneUpdater.js +5 -5
  9. package/dist/cjs/sdk/market/pricefeeds/updates/fetchPythPayloads.js +5 -5
  10. package/dist/cjs/sdk/market/pricefeeds/updates/fetchRedstonePayloads.js +10 -10
  11. package/dist/esm/common-utils/utils/creditAccount/index.js +1 -0
  12. package/dist/esm/permissionless/utils/price-update/get-prices.js +2 -6
  13. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +2 -1
  14. package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
  15. package/dist/esm/sdk/market/MarketConfiguratorContract.js +3 -2
  16. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +5 -3
  17. package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +6 -6
  18. package/dist/esm/sdk/market/pricefeeds/updates/RedstoneUpdater.js +5 -5
  19. package/dist/esm/sdk/market/pricefeeds/updates/fetchPythPayloads.js +5 -5
  20. package/dist/esm/sdk/market/pricefeeds/updates/fetchRedstonePayloads.js +10 -10
  21. package/dist/types/common-utils/utils/creditAccount/index.d.ts +1 -0
  22. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +1 -1
  23. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +1 -1
  24. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
  25. package/dist/types/sdk/market/pricefeeds/updates/fetchPythPayloads.d.ts +2 -2
  26. package/dist/types/sdk/market/pricefeeds/updates/fetchRedstonePayloads.d.ts +2 -2
  27. package/dist/types/sdk/options.d.ts +2 -2
  28. package/package.json +1 -1
@@ -16,6 +16,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  var creditAccount_exports = {};
17
17
  module.exports = __toCommonJS(creditAccount_exports);
18
18
  __reExport(creditAccount_exports, require("./calcHealthFactor.js"), module.exports);
19
+ __reExport(creditAccount_exports, require("./calcOverallAPY.js"), module.exports);
19
20
  __reExport(creditAccount_exports, require("./calcQuotaBorrowRate.js"), module.exports);
20
21
  __reExport(creditAccount_exports, require("./calcQuotaBorrowRate.js"), module.exports);
21
22
  __reExport(creditAccount_exports, require("./calcRelativeBaseBorrowRate.js"), module.exports);
@@ -27,6 +28,7 @@ __reExport(creditAccount_exports, require("./sort.js"), module.exports);
27
28
  // Annotate the CommonJS export names for ESM import in node:
28
29
  0 && (module.exports = {
29
30
  ...require("./calcHealthFactor.js"),
31
+ ...require("./calcOverallAPY.js"),
30
32
  ...require("./calcQuotaBorrowRate.js"),
31
33
  ...require("./calcQuotaBorrowRate.js"),
32
34
  ...require("./calcRelativeBaseBorrowRate.js"),
@@ -105,12 +105,8 @@ async function getPrices({
105
105
  client,
106
106
  gasLimit,
107
107
  marketConfigurators: [],
108
- redstone: {
109
- ignoreMissingFeeds: true
110
- },
111
- pyth: {
112
- ignoreMissingFeeds: true
113
- }
108
+ redstone: {},
109
+ pyth: {}
114
110
  });
115
111
  const chunks = [];
116
112
  for (let i = 0; i < priceFeeds.length; i += chunkSize) {
@@ -43,7 +43,8 @@ class DegenDistributorsPlugin extends import_sdk.BasePlugin {
43
43
  const distributors = await import_MarketConfiguratorContract.MarketConfiguratorContract.getPeripheryContractBatch(
44
44
  Object.values(configurators),
45
45
  this.sdk.client,
46
- "DEGEN_DISTRIBUTOR"
46
+ "DEGEN_DISTRIBUTOR",
47
+ this.sdk.currentBlock
47
48
  );
48
49
  const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
49
50
  const cfgLC = cfg.address.toLowerCase();
@@ -52,7 +52,8 @@ class ZappersPlugin extends import_sdk.BasePlugin {
52
52
  })
53
53
  ),
54
54
  allowFailure: true,
55
- batchSize: 0
55
+ batchSize: 0,
56
+ blockNumber: this.sdk.currentBlock
56
57
  });
57
58
  this.#zappers = new import_sdk.AddressMap(void 0, "zappers");
58
59
  for (let i = 0; i < resp.length; i++) {
@@ -47,7 +47,7 @@ class MarketConfiguratorContract extends import_base.BaseContract {
47
47
  `Market configurator ${this.#curatorName}`
48
48
  );
49
49
  }
50
- static async getPeripheryContractBatch(configurators, client, contract) {
50
+ static async getPeripheryContractBatch(configurators, client, contract, blockNumber) {
51
51
  const resp = await client.multicall({
52
52
  allowFailure: true,
53
53
  contracts: configurators.map(
@@ -58,7 +58,8 @@ class MarketConfiguratorContract extends import_base.BaseContract {
58
58
  args: [(0, import_viem.stringToHex)(contract, { size: 32 })]
59
59
  })
60
60
  ),
61
- batchSize: 0
61
+ batchSize: 0,
62
+ blockNumber
62
63
  });
63
64
  return resp;
64
65
  }
@@ -55,8 +55,8 @@ class PriceFeedRegister extends import_base.SDKConstruct {
55
55
  constructor(sdk, opts = {}) {
56
56
  super(sdk);
57
57
  this.updaters = [
58
- new import_updates.RedstoneUpdater(sdk, opts?.redstone),
59
- new import_updates.PythUpdater(sdk, opts?.pyth)
58
+ new import_updates.PythUpdater(sdk, opts?.pyth),
59
+ new import_updates.RedstoneUpdater(sdk, opts?.redstone)
60
60
  ];
61
61
  }
62
62
  addHook = this.#hooks.addHook.bind(this.#hooks);
@@ -93,7 +93,9 @@ class PriceFeedRegister extends import_base.SDKConstruct {
93
93
  updates: [],
94
94
  timestamp: Math.floor(Date.now() / 1e3)
95
95
  };
96
- const updates = (await Promise.all(this.updaters.map((u) => u.getUpdateTxs(updateables)))).flat();
96
+ const updates = (await Promise.all(
97
+ this.updaters.map((u) => u.getUpdateTxs(updateables).catch(() => []))
98
+ )).flat();
97
99
  let maxTimestamp = 0;
98
100
  for (const tx of updates) {
99
101
  const { data } = tx;
@@ -48,19 +48,19 @@ const PythOptions = import_v4.z.object({
48
48
  */
49
49
  cacheTTL: import_v4.z.number().nonnegative().optional(),
50
50
  /**
51
- * When true, no error will be thrown when pyth is unable to fetch data for some feeds
51
+ * When true, an error will be thrown when pyth is unable to fetch data for some feeds
52
52
  */
53
- ignoreMissingFeeds: import_v4.z.boolean().optional()
53
+ failOnMissingFeeds: import_v4.z.boolean().optional()
54
54
  });
55
55
  class PythUpdater extends import_base.SDKConstruct {
56
56
  #cache;
57
57
  #historicalTimestamp;
58
58
  #apiProxy;
59
- #ignoreMissingFeeds;
59
+ #failOnMissingFeeds;
60
60
  constructor(sdk, opts = {}) {
61
61
  super(sdk);
62
- const { apiProxy, cacheTTL, ignoreMissingFeeds, historicTimestamp } = opts;
63
- this.#ignoreMissingFeeds = ignoreMissingFeeds;
62
+ const { apiProxy, cacheTTL, failOnMissingFeeds, historicTimestamp } = opts;
63
+ this.#failOnMissingFeeds = failOnMissingFeeds;
64
64
  this.#apiProxy = apiProxy;
65
65
  if (historicTimestamp) {
66
66
  this.#historicalTimestamp = historicTimestamp === true ? Number(this.sdk.timestamp) : historicTimestamp;
@@ -168,7 +168,7 @@ class PythUpdater extends import_base.SDKConstruct {
168
168
  dataFeedsIds,
169
169
  historicalTimestampSeconds: this.#historicalTimestamp,
170
170
  apiProxy: this.#apiProxy,
171
- ignoreMissingFeeds: this.#ignoreMissingFeeds,
171
+ failOnMissingFeeds: this.#failOnMissingFeeds,
172
172
  logger: this.logger
173
173
  });
174
174
  }
@@ -49,9 +49,9 @@ const RedstoneOptions = import_v4.z.object({
49
49
  */
50
50
  cacheTTL: import_v4.z.number().nonnegative().optional(),
51
51
  /**
52
- * When true, no error will be thrown when redstone is unable to fetch data for some feeds
52
+ * When true, an error will be thrown when redstone is unable to fetch data for some feeds
53
53
  */
54
- ignoreMissingFeeds: import_v4.z.boolean().optional(),
54
+ failOnMissingFeeds: import_v4.z.boolean().optional(),
55
55
  /**
56
56
  * Enable redstone internal logging
57
57
  */
@@ -61,11 +61,11 @@ class RedstoneUpdater extends import_base.SDKConstruct {
61
61
  #cache;
62
62
  #historicalTimestampMs;
63
63
  #gateways;
64
- #ignoreMissingFeeds;
64
+ #failOnMissingFeeds;
65
65
  #enableLogging;
66
66
  constructor(sdk, opts = {}) {
67
67
  super(sdk);
68
- this.#ignoreMissingFeeds = opts.ignoreMissingFeeds;
68
+ this.#failOnMissingFeeds = opts.failOnMissingFeeds;
69
69
  this.#enableLogging = opts.enableLogging;
70
70
  this.#gateways = opts.gateways?.length ? opts.gateways : void 0;
71
71
  let ts = opts.historicTimestamp;
@@ -247,7 +247,7 @@ class RedstoneUpdater extends import_base.SDKConstruct {
247
247
  uniqueSignersCount,
248
248
  historicalTimestampMs: this.#historicalTimestampMs,
249
249
  gateways: this.#gateways,
250
- ignoreMissingFeeds: this.#ignoreMissingFeeds,
250
+ failOnMissingFeeds: this.#failOnMissingFeeds,
251
251
  enableLogging: this.#enableLogging,
252
252
  logger: this.logger,
253
253
  metadataTimestampMs: Number(this.sdk.timestamp) * 1e3
@@ -28,7 +28,7 @@ var import_PythAccumulatorUpdateData = require("./PythAccumulatorUpdateData.js")
28
28
  async function fetchPythPayloads(options) {
29
29
  const {
30
30
  dataFeedsIds,
31
- ignoreMissingFeeds,
31
+ failOnMissingFeeds,
32
32
  historicalTimestampSeconds,
33
33
  logger,
34
34
  apiProxy,
@@ -43,7 +43,7 @@ async function fetchPythPayloads(options) {
43
43
  api = api.endsWith("/") ? api : `${api}/`;
44
44
  const url = new URL(api + (historicalTimestampSeconds ?? "latest"));
45
45
  url.searchParams.append("parsed", returnPrices ? "true" : "false");
46
- if (ignoreMissingFeeds) {
46
+ if (!failOnMissingFeeds) {
47
47
  url.searchParams.append("ignore_invalid_price_ids", "true");
48
48
  }
49
49
  for (const id of ids) {
@@ -65,12 +65,12 @@ async function fetchPythPayloads(options) {
65
65
  );
66
66
  const result = respToCalldata(resp, returnPrices);
67
67
  if (result.length !== ids.length) {
68
- if (ignoreMissingFeeds) {
69
- logger?.warn(`expected ${ids.length} price feeds, got ${result.length}`);
70
- } else {
68
+ if (failOnMissingFeeds) {
71
69
  throw new Error(
72
70
  `expected ${ids.length} price feeds, got ${result.length}`
73
71
  );
72
+ } else {
73
+ logger?.warn(`expected ${ids.length} price feeds, got ${result.length}`);
74
74
  }
75
75
  }
76
76
  return result;
@@ -34,7 +34,7 @@ async function fetchRedstonePayloads(options) {
34
34
  uniqueSignersCount,
35
35
  historicalTimestampMs,
36
36
  gateways,
37
- ignoreMissingFeeds,
37
+ failOnMissingFeeds,
38
38
  enableLogging,
39
39
  logger,
40
40
  returnPrices
@@ -53,7 +53,7 @@ async function fetchRedstonePayloads(options) {
53
53
  ),
54
54
  historicalTimestamp: historicalTimestampMs,
55
55
  urls: gateways,
56
- ignoreMissingFeed: ignoreMissingFeeds,
56
+ ignoreMissingFeed: !failOnMissingFeeds,
57
57
  enableEnhancedLogs: enableLogging
58
58
  });
59
59
  if (metadataTimestampMs) {
@@ -69,22 +69,22 @@ async function fetchRedstonePayloads(options) {
69
69
  for (const dataFeedId of dataFeedsIds) {
70
70
  const signedDataPackages = packagesByDataFeedId[dataFeedId];
71
71
  if (!signedDataPackages) {
72
- if (ignoreMissingFeeds) {
73
- logger?.warn(`cannot find data packages for ${dataFeedId}`);
74
- continue;
72
+ if (failOnMissingFeeds) {
73
+ throw new Error(`cannot find data packages for ${dataFeedId}`);
75
74
  }
76
- throw new Error(`cannot find data packages for ${dataFeedId}`);
75
+ logger?.warn(`cannot find data packages for ${dataFeedId}`);
76
+ continue;
77
77
  }
78
78
  if (signedDataPackages.length !== uniqueSignersCount) {
79
- if (ignoreMissingFeeds) {
80
- logger?.warn(
79
+ if (failOnMissingFeeds) {
80
+ throw new Error(
81
81
  `got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
82
82
  );
83
- continue;
84
83
  }
85
- throw new Error(
84
+ logger?.warn(
86
85
  `got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
87
86
  );
87
+ continue;
88
88
  }
89
89
  result.push(
90
90
  getCalldataWithTimestamp(
@@ -1,4 +1,5 @@
1
1
  export * from "./calcHealthFactor.js";
2
+ export * from "./calcOverallAPY.js";
2
3
  export * from "./calcQuotaBorrowRate.js";
3
4
  export * from "./calcQuotaBorrowRate.js";
4
5
  export * from "./calcRelativeBaseBorrowRate.js";
@@ -84,12 +84,8 @@ async function getPrices({
84
84
  client,
85
85
  gasLimit,
86
86
  marketConfigurators: [],
87
- redstone: {
88
- ignoreMissingFeeds: true
89
- },
90
- pyth: {
91
- ignoreMissingFeeds: true
92
- }
87
+ redstone: {},
88
+ pyth: {}
93
89
  });
94
90
  const chunks = [];
95
91
  for (let i = 0; i < priceFeeds.length; i += chunkSize) {
@@ -20,7 +20,8 @@ class DegenDistributorsPlugin extends BasePlugin {
20
20
  const distributors = await MarketConfiguratorContract.getPeripheryContractBatch(
21
21
  Object.values(configurators),
22
22
  this.sdk.client,
23
- "DEGEN_DISTRIBUTOR"
23
+ "DEGEN_DISTRIBUTOR",
24
+ this.sdk.currentBlock
24
25
  );
25
26
  const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
26
27
  const cfgLC = cfg.address.toLowerCase();
@@ -35,7 +35,8 @@ class ZappersPlugin extends BasePlugin {
35
35
  })
36
36
  ),
37
37
  allowFailure: true,
38
- batchSize: 0
38
+ batchSize: 0,
39
+ blockNumber: this.sdk.currentBlock
39
40
  });
40
41
  this.#zappers = new AddressMap(void 0, "zappers");
41
42
  for (let i = 0; i < resp.length; i++) {
@@ -26,7 +26,7 @@ class MarketConfiguratorContract extends BaseContract {
26
26
  `Market configurator ${this.#curatorName}`
27
27
  );
28
28
  }
29
- static async getPeripheryContractBatch(configurators, client, contract) {
29
+ static async getPeripheryContractBatch(configurators, client, contract, blockNumber) {
30
30
  const resp = await client.multicall({
31
31
  allowFailure: true,
32
32
  contracts: configurators.map(
@@ -37,7 +37,8 @@ class MarketConfiguratorContract extends BaseContract {
37
37
  args: [stringToHex(contract, { size: 32 })]
38
38
  })
39
39
  ),
40
- batchSize: 0
40
+ batchSize: 0,
41
+ blockNumber
41
42
  });
42
43
  return resp;
43
44
  }
@@ -39,8 +39,8 @@ class PriceFeedRegister extends SDKConstruct {
39
39
  constructor(sdk, opts = {}) {
40
40
  super(sdk);
41
41
  this.updaters = [
42
- new RedstoneUpdater(sdk, opts?.redstone),
43
- new PythUpdater(sdk, opts?.pyth)
42
+ new PythUpdater(sdk, opts?.pyth),
43
+ new RedstoneUpdater(sdk, opts?.redstone)
44
44
  ];
45
45
  }
46
46
  addHook = this.#hooks.addHook.bind(this.#hooks);
@@ -77,7 +77,9 @@ class PriceFeedRegister extends SDKConstruct {
77
77
  updates: [],
78
78
  timestamp: Math.floor(Date.now() / 1e3)
79
79
  };
80
- const updates = (await Promise.all(this.updaters.map((u) => u.getUpdateTxs(updateables)))).flat();
80
+ const updates = (await Promise.all(
81
+ this.updaters.map((u) => u.getUpdateTxs(updateables).catch(() => []))
82
+ )).flat();
81
83
  let maxTimestamp = 0;
82
84
  for (const tx of updates) {
83
85
  const { data } = tx;
@@ -24,19 +24,19 @@ const PythOptions = z.object({
24
24
  */
25
25
  cacheTTL: z.number().nonnegative().optional(),
26
26
  /**
27
- * When true, no error will be thrown when pyth is unable to fetch data for some feeds
27
+ * When true, an error will be thrown when pyth is unable to fetch data for some feeds
28
28
  */
29
- ignoreMissingFeeds: z.boolean().optional()
29
+ failOnMissingFeeds: z.boolean().optional()
30
30
  });
31
31
  class PythUpdater extends SDKConstruct {
32
32
  #cache;
33
33
  #historicalTimestamp;
34
34
  #apiProxy;
35
- #ignoreMissingFeeds;
35
+ #failOnMissingFeeds;
36
36
  constructor(sdk, opts = {}) {
37
37
  super(sdk);
38
- const { apiProxy, cacheTTL, ignoreMissingFeeds, historicTimestamp } = opts;
39
- this.#ignoreMissingFeeds = ignoreMissingFeeds;
38
+ const { apiProxy, cacheTTL, failOnMissingFeeds, historicTimestamp } = opts;
39
+ this.#failOnMissingFeeds = failOnMissingFeeds;
40
40
  this.#apiProxy = apiProxy;
41
41
  if (historicTimestamp) {
42
42
  this.#historicalTimestamp = historicTimestamp === true ? Number(this.sdk.timestamp) : historicTimestamp;
@@ -144,7 +144,7 @@ class PythUpdater extends SDKConstruct {
144
144
  dataFeedsIds,
145
145
  historicalTimestampSeconds: this.#historicalTimestamp,
146
146
  apiProxy: this.#apiProxy,
147
- ignoreMissingFeeds: this.#ignoreMissingFeeds,
147
+ failOnMissingFeeds: this.#failOnMissingFeeds,
148
148
  logger: this.logger
149
149
  });
150
150
  }
@@ -25,9 +25,9 @@ const RedstoneOptions = z.object({
25
25
  */
26
26
  cacheTTL: z.number().nonnegative().optional(),
27
27
  /**
28
- * When true, no error will be thrown when redstone is unable to fetch data for some feeds
28
+ * When true, an error will be thrown when redstone is unable to fetch data for some feeds
29
29
  */
30
- ignoreMissingFeeds: z.boolean().optional(),
30
+ failOnMissingFeeds: z.boolean().optional(),
31
31
  /**
32
32
  * Enable redstone internal logging
33
33
  */
@@ -37,11 +37,11 @@ class RedstoneUpdater extends SDKConstruct {
37
37
  #cache;
38
38
  #historicalTimestampMs;
39
39
  #gateways;
40
- #ignoreMissingFeeds;
40
+ #failOnMissingFeeds;
41
41
  #enableLogging;
42
42
  constructor(sdk, opts = {}) {
43
43
  super(sdk);
44
- this.#ignoreMissingFeeds = opts.ignoreMissingFeeds;
44
+ this.#failOnMissingFeeds = opts.failOnMissingFeeds;
45
45
  this.#enableLogging = opts.enableLogging;
46
46
  this.#gateways = opts.gateways?.length ? opts.gateways : void 0;
47
47
  let ts = opts.historicTimestamp;
@@ -223,7 +223,7 @@ class RedstoneUpdater extends SDKConstruct {
223
223
  uniqueSignersCount,
224
224
  historicalTimestampMs: this.#historicalTimestampMs,
225
225
  gateways: this.#gateways,
226
- ignoreMissingFeeds: this.#ignoreMissingFeeds,
226
+ failOnMissingFeeds: this.#failOnMissingFeeds,
227
227
  enableLogging: this.#enableLogging,
228
228
  logger: this.logger,
229
229
  metadataTimestampMs: Number(this.sdk.timestamp) * 1e3
@@ -9,7 +9,7 @@ import {
9
9
  async function fetchPythPayloads(options) {
10
10
  const {
11
11
  dataFeedsIds,
12
- ignoreMissingFeeds,
12
+ failOnMissingFeeds,
13
13
  historicalTimestampSeconds,
14
14
  logger,
15
15
  apiProxy,
@@ -24,7 +24,7 @@ async function fetchPythPayloads(options) {
24
24
  api = api.endsWith("/") ? api : `${api}/`;
25
25
  const url = new URL(api + (historicalTimestampSeconds ?? "latest"));
26
26
  url.searchParams.append("parsed", returnPrices ? "true" : "false");
27
- if (ignoreMissingFeeds) {
27
+ if (!failOnMissingFeeds) {
28
28
  url.searchParams.append("ignore_invalid_price_ids", "true");
29
29
  }
30
30
  for (const id of ids) {
@@ -46,12 +46,12 @@ async function fetchPythPayloads(options) {
46
46
  );
47
47
  const result = respToCalldata(resp, returnPrices);
48
48
  if (result.length !== ids.length) {
49
- if (ignoreMissingFeeds) {
50
- logger?.warn(`expected ${ids.length} price feeds, got ${result.length}`);
51
- } else {
49
+ if (failOnMissingFeeds) {
52
50
  throw new Error(
53
51
  `expected ${ids.length} price feeds, got ${result.length}`
54
52
  );
53
+ } else {
54
+ logger?.warn(`expected ${ids.length} price feeds, got ${result.length}`);
55
55
  }
56
56
  }
57
57
  return result;
@@ -15,7 +15,7 @@ async function fetchRedstonePayloads(options) {
15
15
  uniqueSignersCount,
16
16
  historicalTimestampMs,
17
17
  gateways,
18
- ignoreMissingFeeds,
18
+ failOnMissingFeeds,
19
19
  enableLogging,
20
20
  logger,
21
21
  returnPrices
@@ -34,7 +34,7 @@ async function fetchRedstonePayloads(options) {
34
34
  ),
35
35
  historicalTimestamp: historicalTimestampMs,
36
36
  urls: gateways,
37
- ignoreMissingFeed: ignoreMissingFeeds,
37
+ ignoreMissingFeed: !failOnMissingFeeds,
38
38
  enableEnhancedLogs: enableLogging
39
39
  });
40
40
  if (metadataTimestampMs) {
@@ -50,22 +50,22 @@ async function fetchRedstonePayloads(options) {
50
50
  for (const dataFeedId of dataFeedsIds) {
51
51
  const signedDataPackages = packagesByDataFeedId[dataFeedId];
52
52
  if (!signedDataPackages) {
53
- if (ignoreMissingFeeds) {
54
- logger?.warn(`cannot find data packages for ${dataFeedId}`);
55
- continue;
53
+ if (failOnMissingFeeds) {
54
+ throw new Error(`cannot find data packages for ${dataFeedId}`);
56
55
  }
57
- throw new Error(`cannot find data packages for ${dataFeedId}`);
56
+ logger?.warn(`cannot find data packages for ${dataFeedId}`);
57
+ continue;
58
58
  }
59
59
  if (signedDataPackages.length !== uniqueSignersCount) {
60
- if (ignoreMissingFeeds) {
61
- logger?.warn(
60
+ if (failOnMissingFeeds) {
61
+ throw new Error(
62
62
  `got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
63
63
  );
64
- continue;
65
64
  }
66
- throw new Error(
65
+ logger?.warn(
67
66
  `got ${signedDataPackages.length} data packages for ${dataFeedId}, but expected ${uniqueSignersCount}`
68
67
  );
68
+ continue;
69
69
  }
70
70
  result.push(
71
71
  getCalldataWithTimestamp(
@@ -1,4 +1,5 @@
1
1
  export * from "./calcHealthFactor.js";
2
+ export * from "./calcOverallAPY.js";
2
3
  export * from "./calcQuotaBorrowRate.js";
3
4
  export * from "./calcQuotaBorrowRate.js";
4
5
  export * from "./calcRelativeBaseBorrowRate.js";
@@ -1531,7 +1531,7 @@ export declare class MarketConfiguratorContract extends BaseContract<abi> {
1531
1531
  #private;
1532
1532
  constructor(options: ConstructOptions, address: Address);
1533
1533
  loadCuratorName(): Promise<void>;
1534
- static getPeripheryContractBatch(configurators: MarketConfiguratorContract[], client: MarketConfiguratorContract["client"], contract: PeripheryContract): Promise<({
1534
+ static getPeripheryContractBatch(configurators: MarketConfiguratorContract[], client: MarketConfiguratorContract["client"], contract: PeripheryContract, blockNumber?: bigint): Promise<({
1535
1535
  error: Error;
1536
1536
  result?: undefined;
1537
1537
  status: "failure";
@@ -12,7 +12,7 @@ export declare const PythOptions: z.ZodObject<{
12
12
  historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
13
13
  apiProxy: z.ZodOptional<z.ZodURL>;
14
14
  cacheTTL: z.ZodOptional<z.ZodNumber>;
15
- ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
15
+ failOnMissingFeeds: z.ZodOptional<z.ZodBoolean>;
16
16
  }, z.core.$strip>;
17
17
  export type PythOptions = z.infer<typeof PythOptions>;
18
18
  /**
@@ -14,7 +14,7 @@ export declare const RedstoneOptions: z.ZodObject<{
14
14
  historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
15
15
  gateways: z.ZodOptional<z.ZodArray<z.ZodURL>>;
16
16
  cacheTTL: z.ZodOptional<z.ZodNumber>;
17
- ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
17
+ failOnMissingFeeds: z.ZodOptional<z.ZodBoolean>;
18
18
  enableLogging: z.ZodOptional<z.ZodBoolean>;
19
19
  }, z.core.$strip>;
20
20
  export type RedstoneOptions = z.infer<typeof RedstoneOptions>;
@@ -6,9 +6,9 @@ export interface FetchPythPayloadsOptions {
6
6
  */
7
7
  dataFeedsIds: Iterable<string>;
8
8
  /**
9
- * When true, will not throw an error if pyth is unable to fetch data for some feeds
9
+ * When true, will throw an error if pyth is unable to fetch data for some feeds
10
10
  */
11
- ignoreMissingFeeds?: boolean;
11
+ failOnMissingFeeds?: boolean;
12
12
  /**
13
13
  * Historical timestamp in seconds
14
14
  */
@@ -33,9 +33,9 @@ export interface FetchRedstonePayloadsOptions {
33
33
  */
34
34
  enableLogging?: boolean;
35
35
  /**
36
- * When true, will not throw an error if redstone is unable to fetch data for some feeds
36
+ * When true, will throw an error if redstone is unable to fetch data for some feeds
37
37
  */
38
- ignoreMissingFeeds?: boolean;
38
+ failOnMissingFeeds?: boolean;
39
39
  /**
40
40
  * Logger to use
41
41
  */
@@ -14,14 +14,14 @@ export declare const SDKOptions: z.ZodObject<{
14
14
  historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
15
15
  gateways: z.ZodOptional<z.ZodArray<z.ZodURL>>;
16
16
  cacheTTL: z.ZodOptional<z.ZodNumber>;
17
- ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
17
+ failOnMissingFeeds: z.ZodOptional<z.ZodBoolean>;
18
18
  enableLogging: z.ZodOptional<z.ZodBoolean>;
19
19
  }, z.core.$strip>>;
20
20
  pyth: z.ZodOptional<z.ZodObject<{
21
21
  historicTimestamp: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodLiteral<true>]>>;
22
22
  apiProxy: z.ZodOptional<z.ZodURL>;
23
23
  cacheTTL: z.ZodOptional<z.ZodNumber>;
24
- ignoreMissingFeeds: z.ZodOptional<z.ZodBoolean>;
24
+ failOnMissingFeeds: z.ZodOptional<z.ZodBoolean>;
25
25
  }, z.core.$strip>>;
26
26
  gasLimit: z.ZodOptional<z.ZodNullable<z.ZodBigInt>>;
27
27
  }, z.core.$strip>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "13.0.0-beta.5",
3
+ "version": "13.0.0-beta.7",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",