@gearbox-protocol/sdk 13.0.0-beta.6 → 13.0.0-beta.8

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 (33) hide show
  1. package/dist/cjs/permissionless/utils/price-update/get-prices.js +2 -6
  2. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +2 -1
  3. package/dist/cjs/plugins/zappers/ZappersPlugin.js +2 -1
  4. package/dist/cjs/sdk/constants/versions.js +0 -3
  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/permissionless/utils/price-update/get-prices.js +2 -6
  12. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +2 -1
  13. package/dist/esm/plugins/zappers/ZappersPlugin.js +2 -1
  14. package/dist/esm/sdk/constants/versions.js +0 -2
  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/sdk/accounts/AbstractCreditAccountsService.d.ts +2 -2
  22. package/dist/types/sdk/accounts/types.d.ts +5 -15
  23. package/dist/types/sdk/constants/versions.d.ts +0 -1
  24. package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +1 -1
  25. package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +2 -2
  26. package/dist/types/sdk/market/oracle/PriceOracleV310Contract.d.ts +2 -2
  27. package/dist/types/sdk/market/oracle/types.d.ts +5 -7
  28. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +1 -1
  29. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
  30. package/dist/types/sdk/market/pricefeeds/updates/fetchPythPayloads.d.ts +2 -2
  31. package/dist/types/sdk/market/pricefeeds/updates/fetchRedstonePayloads.d.ts +2 -2
  32. package/dist/types/sdk/options.d.ts +2 -2
  33. package/package.json +7 -7
@@ -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++) {
@@ -18,13 +18,11 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var versions_exports = {};
20
20
  __export(versions_exports, {
21
- VERSION_RANGE_300: () => VERSION_RANGE_300,
22
21
  VERSION_RANGE_310: () => VERSION_RANGE_310,
23
22
  isV310: () => isV310,
24
23
  isVersionRange: () => isVersionRange
25
24
  });
26
25
  module.exports = __toCommonJS(versions_exports);
27
- const VERSION_RANGE_300 = [300, 309];
28
26
  const VERSION_RANGE_310 = [310, 319];
29
27
  function isV310(version) {
30
28
  return isVersionRange(version, VERSION_RANGE_310);
@@ -34,7 +32,6 @@ function isVersionRange(version, range) {
34
32
  }
35
33
  // Annotate the CommonJS export names for ESM import in node:
36
34
  0 && (module.exports = {
37
- VERSION_RANGE_300,
38
35
  VERSION_RANGE_310,
39
36
  isV310,
40
37
  isVersionRange
@@ -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(
@@ -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++) {
@@ -1,4 +1,3 @@
1
- const VERSION_RANGE_300 = [300, 309];
2
1
  const VERSION_RANGE_310 = [310, 319];
3
2
  function isV310(version) {
4
3
  return isVersionRange(version, VERSION_RANGE_310);
@@ -7,7 +6,6 @@ function isVersionRange(version, range) {
7
6
  return Number(version) >= range[0] && Number(version) <= range[1];
8
7
  }
9
8
  export {
10
- VERSION_RANGE_300,
11
9
  VERSION_RANGE_310,
12
10
  isV310,
13
11
  isVersionRange
@@ -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(
@@ -2,7 +2,7 @@ import type { Address } from "viem";
2
2
  import type { CreditAccountData } from "../base/index.js";
3
3
  import { SDKConstruct } from "../base/index.js";
4
4
  import type { GearboxSDK } from "../GearboxSDK.js";
5
- import type { OnDemandPriceUpdates, PriceUpdateV310, UpdatePriceFeedsResult } from "../market/index.js";
5
+ import type { OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
6
6
  import { type Asset, type RouterCASlice } from "../router/index.js";
7
7
  import type { MultiCall } from "../types/index.js";
8
8
  import type { AccountToCheck, AddCollateralProps, ChangeDeptProps, ClaimDelayedProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsOptions, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, PreviewDelayedWithdrawalResult, PriceUpdatesOptions, Rewards, StartDelayedWithdrawalProps, UpdateQuotasProps } from "./types.js";
@@ -191,7 +191,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
191
191
  * @param options
192
192
  * @returns
193
193
  */
194
- getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates<PriceUpdateV310>>;
194
+ getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates>;
195
195
  /**
196
196
  * Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
197
197
  * - If there are desiredQuotas and creditAccount update quotaBalance > 0 || (balance > 10n && isEnabled). Is used when account has both: balances and quota buys.
@@ -3,7 +3,7 @@ import type { creditAccountCompressorAbi } from "../../abi/compressors/creditAcc
3
3
  import type { iWithdrawalCompressorV310Abi } from "../../abi/IWithdrawalCompressorV310.js";
4
4
  import type { ConnectedBotData, Construct, CreditAccountData } from "../base/index.js";
5
5
  import type { GearboxSDK } from "../GearboxSDK.js";
6
- import type { CreditSuite, OnDemandPriceUpdates, PriceUpdateV310, UpdatePriceFeedsResult } from "../market/index.js";
6
+ import type { CreditSuite, OnDemandPriceUpdates, UpdatePriceFeedsResult } from "../market/index.js";
7
7
  import type { Asset, CreditAccountTokensSlice, RouterCASlice, RouterCloseResult } from "../router/index.js";
8
8
  import type { MultiCall, RawTx } from "../types/index.js";
9
9
  export type GetCreditAccountsArgs = ContractFunctionArgs<typeof creditAccountCompressorAbi, "pure" | "view", "getCreditAccounts">;
@@ -315,10 +315,6 @@ export interface FullyLiquidateProps {
315
315
  * Slippage in PERCENTAGE_FORMAT (100% = 10_000) per operation
316
316
  */
317
317
  slippage?: bigint;
318
- /**
319
- * TODO: legacy v3 option to remove
320
- */
321
- force?: boolean;
322
318
  /**
323
319
  * List of assets to keep on account after liquidation
324
320
  */
@@ -459,7 +455,7 @@ export interface ICreditAccountsService extends Construct {
459
455
  additionalBots: Array<Omit<NonNullable<GetConnectedMigrationBotsResult>, "botAddress">>;
460
456
  }>;
461
457
  /**
462
- * V3.1 method, throws in V3. Connects/disables a bot and updates prices
458
+ * Connects/disables a bot and updates prices
463
459
  * @param props - {@link SetBotProps}
464
460
  * @return All necessary data to execute the transaction (call, credit facade)
465
461
  */
@@ -569,7 +565,7 @@ export interface ICreditAccountsService extends Construct {
569
565
  * @param options
570
566
  * @returns
571
567
  */
572
- getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates<PriceUpdateV310>>;
568
+ getOnDemandPriceUpdates(options: PriceUpdatesOptions): Promise<OnDemandPriceUpdates>;
573
569
  /**
574
570
  * Returns price updates in format that is accepted by various credit facade methods (multicall, close/liquidate, etc...).
575
571
  * @param options
@@ -588,8 +584,6 @@ export interface ICreditAccountsService extends Construct {
588
584
  * Fully repays credit account or repays credit account and keeps it open with zero debt
589
585
  * - Repays in the following order: price update -> add collateral to cover the debt ->
590
586
  * -> disable quotas for all tokens -> decrease debt -> disable tokens all tokens -> withdraw all tokens
591
- * - V3.0 claims rewards for tokens which are specified in legacy SDK
592
- * - V3.1 claims rewards for all tokens IF router is also V3.1
593
587
  * @param props - {@link RepayCreditAccountProps}
594
588
  * @return All necessary data to execute the transaction (call, credit facade)
595
589
  */
@@ -598,18 +592,14 @@ export interface ICreditAccountsService extends Construct {
598
592
  * Fully repays liquidatable account
599
593
  * - Repay and liquidate is executed in the following order: price update -> add collateral to cover the debt ->
600
594
  * withdraw all tokens from credit account
601
- * - V3.0 claims rewards for tokens which are specified in legacy SDK
602
- * - V3.1 claims rewards for all tokens IF router is also V3.1
603
595
  * @param props - {@link RepayAndLiquidateCreditAccountProps}
604
596
  * @return All necessary data to execute the transaction (call, credit facade)
605
597
  */
606
598
  repayAndLiquidateCreditAccount(props: RepayAndLiquidateCreditAccountProps): Promise<CreditAccountOperationResult>;
607
599
  /**
608
- * Executes swap specified by given calls, update quotas of affected tokens
600
+ * Claims farm rewards and optionally updates quotas
609
601
  * - Claim rewards is executed in the following order: price update -> execute claim calls ->
610
- * -> (optionally: disable reward tokens) -> (optionally: update quotas)
611
- * - V3.0 claims rewards for tokens which are specified in legacy SDK
612
- * - V3.1 claims rewards for all tokens IF router is also V3.1 and falls back to legacy calls if router is not v3.0
602
+ * -> (optionally: update quotas)
613
603
  * @param props - {@link ClaimFarmRewardsProps}
614
604
  * @return All necessary data to execute the transaction (call, credit facade)
615
605
  */
@@ -2,7 +2,6 @@
2
2
  * Version range, inclusive of both ends
3
3
  */
4
4
  export type VersionRange = [number, number];
5
- export declare const VERSION_RANGE_300: VersionRange;
6
5
  export declare const VERSION_RANGE_310: VersionRange;
7
6
  export declare function isV310(version: number | bigint | string): boolean;
8
7
  export declare function isVersionRange(version: number | bigint | string, range: VersionRange): boolean;
@@ -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";
@@ -5,7 +5,7 @@ import { BaseContract } from "../../base/index.js";
5
5
  import type { GearboxSDK } from "../../GearboxSDK.js";
6
6
  import type { PriceOracleStateHuman } from "../../types/index.js";
7
7
  import { AddressMap } from "../../utils/index.js";
8
- import type { IPriceFeedContract, PriceUpdateV310, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
8
+ import type { IPriceFeedContract, UpdatePriceFeedsResult } from "../pricefeeds/index.js";
9
9
  import { PriceFeedRef } from "../pricefeeds/index.js";
10
10
  import PriceFeedAnswerMap from "./PriceFeedAnswerMap.js";
11
11
  import type { DelegatedOracleMulticall, IPriceOracleContract, OnDemandPriceUpdates, PriceFeedsForTokensOptions } from "./types.js";
@@ -36,7 +36,7 @@ export declare abstract class PriceOracleBaseContract<abi extends Abi | readonly
36
36
  * @returns
37
37
  */
38
38
  priceFeedsForTokens(tokens: Address[], opts?: PriceFeedsForTokensOptions): IPriceFeedContract[];
39
- abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates<PriceUpdateV310>;
39
+ abstract onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
40
40
  /**
41
41
  * Gets main price for given token
42
42
  * Throws if token price feed is not found or answer is not successful
@@ -1,7 +1,7 @@
1
1
  import { type Address, type ContractEventName, type Log } from "viem";
2
2
  import type { PriceOracleData } from "../../base/index.js";
3
3
  import type { GearboxSDK } from "../../GearboxSDK.js";
4
- import { type PriceUpdateV310, type UpdatePriceFeedsResult } from "../pricefeeds/index.js";
4
+ import { type UpdatePriceFeedsResult } from "../pricefeeds/index.js";
5
5
  import { PriceOracleBaseContract } from "./PriceOracleBaseContract.js";
6
6
  import type { OnDemandPriceUpdates } from "./types.js";
7
7
  declare const abi: readonly [{
@@ -348,7 +348,7 @@ export declare class PriceOracleV310Contract extends PriceOracleBaseContract<abi
348
348
  * @param updates
349
349
  * @returns
350
350
  */
351
- onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates<PriceUpdateV310>;
351
+ onDemandPriceUpdates(creditFacade: Address, updates?: UpdatePriceFeedsResult): OnDemandPriceUpdates;
352
352
  processLog(log: Log<bigint, number, false, undefined, undefined, abi, ContractEventName<abi>>): void;
353
353
  }
354
354
  export {};
@@ -10,13 +10,11 @@ export interface PriceFeedsForTokensOptions {
10
10
  reserve?: boolean;
11
11
  }
12
12
  /**
13
- * Abstraction that represents on demand price updates acceptable by both credit facade multicall and
14
- * as raw PriceUpdate in liquidator calls
15
- * T is (priceFeed, data)
16
- * TODO: should be removed after v310 migration
13
+ * On demand price updates acceptable by both credit facade multicall and
14
+ * as raw PriceUpdate in liquidator calls.
17
15
  */
18
- export interface OnDemandPriceUpdates<T = unknown> {
19
- raw: T[];
16
+ export interface OnDemandPriceUpdates {
17
+ raw: PriceUpdateV310[];
20
18
  multicall: MultiCall[];
21
19
  }
22
20
  export interface IPriceOracleContract extends IBaseContract {
@@ -78,7 +76,7 @@ export interface IPriceOracleContract extends IBaseContract {
78
76
  * @param updates
79
77
  * @returns
80
78
  */
81
- onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates<PriceUpdateV310>;
79
+ onDemandPriceUpdates: (creditFacade: Address, updates?: UpdatePriceFeedsResult) => OnDemandPriceUpdates;
82
80
  /**
83
81
  * Tries to convert amount of from one token to another, using latest known prices
84
82
  * @param from
@@ -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.6",
3
+ "version": "13.0.0-beta.8",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -80,22 +80,22 @@
80
80
  "zod": "^4.3.6"
81
81
  },
82
82
  "devDependencies": {
83
- "@biomejs/biome": "^2.4.6",
84
- "@commitlint/cli": "^20.4.3",
85
- "@commitlint/config-conventional": "^20.4.3",
86
- "@gearbox-protocol/biome-config": "^1.0.22",
83
+ "@biomejs/biome": "^2.4.9",
84
+ "@commitlint/cli": "^20.5.0",
85
+ "@commitlint/config-conventional": "^20.5.0",
86
+ "@gearbox-protocol/biome-config": "^1.0.24",
87
87
  "@types/cross-spawn": "^6.0.6",
88
88
  "axios": "^1.13.6",
89
89
  "cross-spawn": "^7.0.6",
90
90
  "husky": "^9.1.7",
91
- "lint-staged": "^16.3.3",
91
+ "lint-staged": "^16.4.0",
92
92
  "pino": "^10.3.1",
93
93
  "pino-pretty": "^13.1.3",
94
94
  "tsup": "^8.5.1",
95
95
  "tsx": "^4.21.0",
96
96
  "typescript": "^5.9.3",
97
97
  "viem-deal": "^2.0.4",
98
- "vitest": "^4.0.18"
98
+ "vitest": "^4.1.1"
99
99
  },
100
100
  "peerDependencies": {
101
101
  "axios": "^1.0.0",