@gearbox-protocol/sdk 14.12.0-next.80 → 14.12.0-next.82

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 (221) hide show
  1. package/dist/cjs/model/filters.js +0 -4
  2. package/dist/cjs/model/filters.schema.js +10 -1
  3. package/dist/cjs/model/index.js +11 -0
  4. package/dist/cjs/model/liquidations.js +1 -1
  5. package/dist/cjs/model/liquidations.schema.js +1 -1
  6. package/dist/cjs/model/opportunities.js +1 -1
  7. package/dist/cjs/model/opportunities.schema.js +6 -13
  8. package/dist/cjs/model/positions.js +1 -1
  9. package/dist/cjs/model/positions.schema.js +33 -1
  10. package/dist/cjs/model/response.js +1 -0
  11. package/dist/cjs/model/response.schema.js +64 -0
  12. package/dist/cjs/new-sdk/AbstractNamespace.js +46 -128
  13. package/dist/cjs/new-sdk/GearboxSDK.js +55 -42
  14. package/dist/cjs/new-sdk/errors/AllSourcesFailedError.js +20 -0
  15. package/dist/cjs/new-sdk/errors/MissingSourceError.js +25 -0
  16. package/dist/cjs/new-sdk/errors/NoSourceServedError.js +20 -0
  17. package/dist/cjs/new-sdk/errors/SourceChainMismatchError.js +34 -0
  18. package/dist/cjs/new-sdk/errors/SourceUnavailableError.js +25 -0
  19. package/dist/cjs/new-sdk/errors/assertSameChains.js +12 -0
  20. package/dist/cjs/new-sdk/errors/everyChainFailed.js +11 -0
  21. package/dist/cjs/new-sdk/errors/index.js +15 -0
  22. package/dist/cjs/new-sdk/index.js +23 -3
  23. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +37 -89
  24. package/dist/cjs/new-sdk/positions/PositionsNamespace.js +27 -94
  25. package/dist/cjs/new-sdk/types.js +0 -21
  26. package/dist/cjs/new-sdk/utils/filterResponse.js +21 -0
  27. package/dist/cjs/new-sdk/utils/index.js +6 -0
  28. package/dist/cjs/new-sdk/utils/mergeChains.js +81 -0
  29. package/dist/cjs/new-sdk/utils/types.js +1 -0
  30. package/dist/cjs/offchain/AbstractOffchainNamespace.js +42 -65
  31. package/dist/cjs/offchain/GearboxAPI.js +12 -8
  32. package/dist/cjs/offchain/errors/OffchainInvalidJsonError.js +19 -0
  33. package/dist/cjs/offchain/errors/OffchainNotConfiguredError.js +20 -0
  34. package/dist/cjs/offchain/errors/OffchainNotImplementedError.js +19 -0
  35. package/dist/cjs/offchain/errors/OffchainRequestFailedError.js +24 -0
  36. package/dist/cjs/offchain/errors/OffchainStatusError.js +20 -0
  37. package/dist/cjs/offchain/errors/OffchainTransportError.js +31 -0
  38. package/dist/cjs/offchain/errors/OffchainValidationError.js +26 -0
  39. package/dist/cjs/offchain/errors/backendMessage.js +28 -0
  40. package/dist/cjs/offchain/errors/errorCause.js +12 -0
  41. package/dist/cjs/offchain/errors/index.js +21 -0
  42. package/dist/cjs/offchain/errors/readResponseBody.js +15 -0
  43. package/dist/cjs/offchain/index.js +22 -5
  44. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +6 -3
  45. package/dist/cjs/offchain/positions/OffchainPositions.js +15 -21
  46. package/dist/cjs/offchain/types.js +0 -75
  47. package/dist/cjs/sdk/MultichainSDK.js +1 -1
  48. package/dist/cjs/sdk/OnchainSDK.js +1 -1
  49. package/dist/cjs/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +6 -6
  50. package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +26 -20
  51. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
  52. package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
  53. package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +3 -2
  54. package/dist/cjs/sdk/base/MultichainConstruct.js +73 -34
  55. package/dist/cjs/sdk/chain/chains.js +11 -0
  56. package/dist/cjs/sdk/chain/index.js +1 -0
  57. package/dist/cjs/sdk/core/index.js +1 -1
  58. package/dist/cjs/sdk/index.js +2 -1
  59. package/dist/cjs/sdk/market/rwa/RWARegistry.js +4 -2
  60. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
  61. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +1 -4
  62. package/dist/cjs/sdk/pools/PoolService.js +2 -1
  63. package/dist/cjs/sdk/positions/MultichainPositionsService.js +6 -29
  64. package/dist/cjs/sdk/positions/PositionsService.js +12 -6
  65. package/dist/esm/dev/AccountOpener.js +1 -1
  66. package/dist/esm/dev/withdrawalUtils.js +1 -1
  67. package/dist/esm/model/filters.js +0 -4
  68. package/dist/esm/model/filters.schema.js +10 -2
  69. package/dist/esm/model/index.js +5 -3
  70. package/dist/esm/model/liquidations.js +1 -1
  71. package/dist/esm/model/liquidations.schema.js +1 -1
  72. package/dist/esm/model/opportunities.js +1 -1
  73. package/dist/esm/model/opportunities.schema.js +4 -11
  74. package/dist/esm/model/positions.js +1 -1
  75. package/dist/esm/model/positions.schema.js +33 -3
  76. package/dist/esm/model/response.js +1 -0
  77. package/dist/esm/model/response.schema.js +58 -0
  78. package/dist/esm/new-sdk/AbstractNamespace.js +46 -128
  79. package/dist/esm/new-sdk/GearboxSDK.js +55 -42
  80. package/dist/esm/new-sdk/errors/AllSourcesFailedError.js +19 -0
  81. package/dist/esm/new-sdk/errors/MissingSourceError.js +24 -0
  82. package/dist/esm/new-sdk/errors/NoSourceServedError.js +19 -0
  83. package/dist/esm/new-sdk/errors/SourceChainMismatchError.js +33 -0
  84. package/dist/esm/new-sdk/errors/SourceUnavailableError.js +24 -0
  85. package/dist/esm/new-sdk/errors/assertSameChains.js +11 -0
  86. package/dist/esm/new-sdk/errors/everyChainFailed.js +10 -0
  87. package/dist/esm/new-sdk/errors/index.js +8 -0
  88. package/dist/esm/new-sdk/index.js +13 -3
  89. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +38 -90
  90. package/dist/esm/new-sdk/positions/PositionsNamespace.js +28 -95
  91. package/dist/esm/new-sdk/types.js +1 -21
  92. package/dist/esm/new-sdk/utils/filterResponse.js +20 -0
  93. package/dist/esm/new-sdk/utils/index.js +3 -1
  94. package/dist/esm/new-sdk/utils/mergeChains.js +78 -0
  95. package/dist/esm/new-sdk/utils/types.js +1 -0
  96. package/dist/esm/offchain/AbstractOffchainNamespace.js +41 -64
  97. package/dist/esm/offchain/GearboxAPI.js +12 -8
  98. package/dist/esm/offchain/errors/OffchainInvalidJsonError.js +18 -0
  99. package/dist/esm/offchain/errors/OffchainNotConfiguredError.js +19 -0
  100. package/dist/esm/offchain/errors/OffchainNotImplementedError.js +18 -0
  101. package/dist/esm/offchain/errors/OffchainRequestFailedError.js +23 -0
  102. package/dist/esm/offchain/errors/OffchainStatusError.js +19 -0
  103. package/dist/esm/offchain/errors/OffchainTransportError.js +30 -0
  104. package/dist/esm/offchain/errors/OffchainValidationError.js +25 -0
  105. package/dist/esm/offchain/errors/backendMessage.js +27 -0
  106. package/dist/esm/offchain/errors/errorCause.js +11 -0
  107. package/dist/esm/offchain/errors/index.js +11 -0
  108. package/dist/esm/offchain/errors/readResponseBody.js +14 -0
  109. package/dist/esm/offchain/index.js +13 -2
  110. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +6 -3
  111. package/dist/esm/offchain/positions/OffchainPositions.js +15 -21
  112. package/dist/esm/offchain/types.js +1 -72
  113. package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
  114. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  115. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  116. package/dist/esm/sdk/MultichainSDK.js +1 -1
  117. package/dist/esm/sdk/OnchainSDK.js +1 -1
  118. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  119. package/dist/esm/sdk/accounts/credit-account-compressor/CreditAccountCompressor.js +6 -6
  120. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +27 -21
  121. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
  122. package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
  123. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  124. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  125. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  126. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +4 -3
  127. package/dist/esm/sdk/base/MultichainConstruct.js +73 -34
  128. package/dist/esm/sdk/base/TokensMeta.js +2 -2
  129. package/dist/esm/sdk/chain/chains.js +11 -1
  130. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  131. package/dist/esm/sdk/chain/index.js +2 -2
  132. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  133. package/dist/esm/sdk/core/index.js +1 -1
  134. package/dist/esm/sdk/index.js +3 -3
  135. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  136. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  137. package/dist/esm/sdk/market/rwa/RWARegistry.js +4 -2
  138. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  139. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  140. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
  141. package/dist/esm/sdk/opportunities/OpportunitiesService.js +1 -4
  142. package/dist/esm/sdk/pools/PoolService.js +3 -2
  143. package/dist/esm/sdk/positions/MultichainPositionsService.js +6 -29
  144. package/dist/esm/sdk/positions/PositionsService.js +12 -6
  145. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  146. package/dist/types/model/filters.d.ts +9 -3
  147. package/dist/types/model/filters.schema.d.ts +7 -1
  148. package/dist/types/model/index.d.ts +7 -5
  149. package/dist/types/model/liquidations.d.ts +2 -6
  150. package/dist/types/model/liquidations.schema.d.ts +1 -1
  151. package/dist/types/model/opportunities.d.ts +3 -7
  152. package/dist/types/model/opportunities.schema.d.ts +2 -2
  153. package/dist/types/model/positions.d.ts +2 -6
  154. package/dist/types/model/positions.schema.d.ts +32 -2
  155. package/dist/types/model/response.d.ts +105 -0
  156. package/dist/types/model/response.schema.d.ts +98 -0
  157. package/dist/types/new-sdk/AbstractNamespace.d.ts +33 -98
  158. package/dist/types/new-sdk/GearboxSDK.d.ts +10 -25
  159. package/dist/types/new-sdk/errors/AllSourcesFailedError.d.ts +11 -0
  160. package/dist/types/new-sdk/errors/MissingSourceError.d.ts +23 -0
  161. package/dist/types/new-sdk/errors/NoSourceServedError.d.ts +17 -0
  162. package/dist/types/new-sdk/errors/SourceChainMismatchError.d.ts +35 -0
  163. package/dist/types/new-sdk/errors/SourceUnavailableError.d.ts +22 -0
  164. package/dist/types/new-sdk/errors/assertSameChains.d.ts +11 -0
  165. package/dist/types/new-sdk/errors/everyChainFailed.d.ts +10 -0
  166. package/dist/types/new-sdk/errors/index.d.ts +8 -0
  167. package/dist/types/new-sdk/index.d.ts +17 -6
  168. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +19 -40
  169. package/dist/types/new-sdk/opportunities/index.d.ts +2 -2
  170. package/dist/types/new-sdk/opportunities/types.d.ts +80 -26
  171. package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +17 -38
  172. package/dist/types/new-sdk/positions/index.d.ts +2 -2
  173. package/dist/types/new-sdk/positions/types.d.ts +74 -24
  174. package/dist/types/new-sdk/types.d.ts +24 -77
  175. package/dist/types/new-sdk/utils/filterResponse.d.ts +16 -0
  176. package/dist/types/new-sdk/utils/history.d.ts +6 -36
  177. package/dist/types/new-sdk/utils/index.d.ts +5 -2
  178. package/dist/types/new-sdk/utils/mergeChains.d.ts +20 -0
  179. package/dist/types/new-sdk/utils/types.d.ts +11 -0
  180. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +21 -28
  181. package/dist/types/offchain/GearboxAPI.d.ts +13 -9
  182. package/dist/types/offchain/errors/OffchainInvalidJsonError.d.ts +16 -0
  183. package/dist/types/offchain/errors/OffchainNotConfiguredError.d.ts +16 -0
  184. package/dist/types/offchain/errors/OffchainNotImplementedError.d.ts +15 -0
  185. package/dist/types/offchain/errors/OffchainRequestFailedError.d.ts +12 -0
  186. package/dist/types/offchain/errors/OffchainStatusError.d.ts +16 -0
  187. package/dist/types/offchain/errors/OffchainTransportError.d.ts +43 -0
  188. package/dist/types/offchain/errors/OffchainValidationError.d.ts +21 -0
  189. package/dist/types/offchain/errors/backendMessage.d.ts +9 -0
  190. package/dist/types/offchain/errors/errorCause.d.ts +22 -0
  191. package/dist/types/offchain/errors/index.d.ts +11 -0
  192. package/dist/types/offchain/errors/readResponseBody.d.ts +8 -0
  193. package/dist/types/offchain/index.d.ts +13 -2
  194. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +9 -8
  195. package/dist/types/offchain/positions/OffchainPositions.d.ts +9 -15
  196. package/dist/types/offchain/types.d.ts +7 -88
  197. package/dist/types/sdk/accounts/credit-account-compressor/types.d.ts +4 -0
  198. package/dist/types/sdk/accounts/index.d.ts +3 -3
  199. package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +2 -2
  200. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +15 -14
  201. package/dist/types/sdk/accounts/liquidations/index.d.ts +2 -2
  202. package/dist/types/sdk/accounts/liquidations/types.d.ts +32 -16
  203. package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +4 -4
  204. package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +2 -2
  205. package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +2 -2
  206. package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +26 -4
  207. package/dist/types/sdk/base/MultichainConstruct.d.ts +63 -14
  208. package/dist/types/sdk/base/index.d.ts +2 -2
  209. package/dist/types/sdk/chain/chains.d.ts +10 -2
  210. package/dist/types/sdk/chain/index.d.ts +2 -2
  211. package/dist/types/sdk/index.d.ts +7 -7
  212. package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
  213. package/dist/types/sdk/market/rwa/RWARegistry.d.ts +2 -1
  214. package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +13 -16
  215. package/dist/types/sdk/pools/types.d.ts +4 -0
  216. package/dist/types/sdk/positions/MultichainPositionsService.d.ts +2 -12
  217. package/dist/types/sdk/positions/index.d.ts +2 -2
  218. package/dist/types/sdk/positions/types.d.ts +14 -5
  219. package/dist/types/sdk/types/index.d.ts +2 -2
  220. package/dist/types/sdk/types/multichain.d.ts +16 -36
  221. package/package.json +1 -1
@@ -0,0 +1,28 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/offchain/errors/backendMessage.ts
3
+ const MAX_LENGTH = 200;
4
+ /**
5
+ * Why a non-2xx response failed, in the backend's own words: the `message` of a
6
+ * Gearbox backend error body, the whole body when it is not one, and nothing
7
+ * when it said nothing at all.
8
+ **/
9
+ function backendMessage(body) {
10
+ if (!body) return;
11
+ const message = parsedMessage(body) ?? body.trim();
12
+ return message ? truncate(message) : void 0;
13
+ }
14
+ /**
15
+ * The `message` of a Gearbox backend error body, or nothing when the body is
16
+ * not one.
17
+ **/
18
+ function parsedMessage(body) {
19
+ try {
20
+ const parsed = JSON.parse(body);
21
+ if (typeof parsed === "object" && parsed !== null && "message" in parsed && typeof parsed.message === "string") return parsed.message;
22
+ } catch {}
23
+ }
24
+ function truncate(text) {
25
+ return text.length > MAX_LENGTH ? `${text.slice(0, MAX_LENGTH)}…` : text;
26
+ }
27
+ //#endregion
28
+ exports.backendMessage = backendMessage;
@@ -0,0 +1,12 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/offchain/errors/errorCause.ts
3
+ /**
4
+ * Turns a caught `unknown` into what viem's `BaseError` takes: it types `cause`
5
+ * as an `Error`, so anything else can only be reported as `details`.
6
+ **/
7
+ function errorCause(error) {
8
+ if (error === void 0) return {};
9
+ return error instanceof Error ? { cause: error } : { details: String(error) };
10
+ }
11
+ //#endregion
12
+ exports.errorCause = errorCause;
@@ -0,0 +1,21 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_offchain_errors_backendMessage = require("./backendMessage.js");
3
+ const require_offchain_errors_errorCause = require("./errorCause.js");
4
+ const require_offchain_errors_OffchainTransportError = require("./OffchainTransportError.js");
5
+ const require_offchain_errors_OffchainInvalidJsonError = require("./OffchainInvalidJsonError.js");
6
+ const require_offchain_errors_OffchainNotConfiguredError = require("./OffchainNotConfiguredError.js");
7
+ const require_offchain_errors_OffchainNotImplementedError = require("./OffchainNotImplementedError.js");
8
+ const require_offchain_errors_OffchainRequestFailedError = require("./OffchainRequestFailedError.js");
9
+ const require_offchain_errors_OffchainStatusError = require("./OffchainStatusError.js");
10
+ const require_offchain_errors_OffchainValidationError = require("./OffchainValidationError.js");
11
+ const require_offchain_errors_readResponseBody = require("./readResponseBody.js");
12
+ exports.OffchainInvalidJsonError = require_offchain_errors_OffchainInvalidJsonError.OffchainInvalidJsonError;
13
+ exports.OffchainNotConfiguredError = require_offchain_errors_OffchainNotConfiguredError.OffchainNotConfiguredError;
14
+ exports.OffchainNotImplementedError = require_offchain_errors_OffchainNotImplementedError.OffchainNotImplementedError;
15
+ exports.OffchainRequestFailedError = require_offchain_errors_OffchainRequestFailedError.OffchainRequestFailedError;
16
+ exports.OffchainStatusError = require_offchain_errors_OffchainStatusError.OffchainStatusError;
17
+ exports.OffchainTransportError = require_offchain_errors_OffchainTransportError.OffchainTransportError;
18
+ exports.OffchainValidationError = require_offchain_errors_OffchainValidationError.OffchainValidationError;
19
+ exports.backendMessage = require_offchain_errors_backendMessage.backendMessage;
20
+ exports.errorCause = require_offchain_errors_errorCause.errorCause;
21
+ exports.readResponseBody = require_offchain_errors_readResponseBody.readResponseBody;
@@ -0,0 +1,15 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ //#region src/offchain/errors/readResponseBody.ts
3
+ /**
4
+ * Body of a failed response as text, or nothing when it cannot be read: a
5
+ * failure explaining a failure is not itself worth throwing.
6
+ **/
7
+ async function readResponseBody(response) {
8
+ try {
9
+ return await response.text();
10
+ } catch {
11
+ return;
12
+ }
13
+ }
14
+ //#endregion
15
+ exports.readResponseBody = readResponseBody;
@@ -1,16 +1,33 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_offchain_types = require("./types.js");
2
+ const require_offchain_errors_backendMessage = require("./errors/backendMessage.js");
3
+ const require_offchain_errors_errorCause = require("./errors/errorCause.js");
4
+ const require_offchain_errors_OffchainTransportError = require("./errors/OffchainTransportError.js");
5
+ const require_offchain_errors_OffchainInvalidJsonError = require("./errors/OffchainInvalidJsonError.js");
6
+ const require_offchain_errors_OffchainNotConfiguredError = require("./errors/OffchainNotConfiguredError.js");
7
+ const require_offchain_errors_OffchainNotImplementedError = require("./errors/OffchainNotImplementedError.js");
8
+ const require_offchain_errors_OffchainRequestFailedError = require("./errors/OffchainRequestFailedError.js");
9
+ const require_offchain_errors_OffchainStatusError = require("./errors/OffchainStatusError.js");
10
+ const require_offchain_errors_OffchainValidationError = require("./errors/OffchainValidationError.js");
11
+ const require_offchain_errors_readResponseBody = require("./errors/readResponseBody.js");
12
+ require("./errors/index.js");
3
13
  const require_offchain_AbstractOffchainNamespace = require("./AbstractOffchainNamespace.js");
4
14
  const require_offchain_opportunities_OffchainOpportunities = require("./opportunities/OffchainOpportunities.js");
5
15
  require("./opportunities/index.js");
6
16
  const require_offchain_positions_OffchainPositions = require("./positions/OffchainPositions.js");
7
17
  require("./positions/index.js");
8
18
  const require_offchain_GearboxAPI = require("./GearboxAPI.js");
19
+ require("./types.js");
9
20
  exports.AbstractOffchainNamespace = require_offchain_AbstractOffchainNamespace.AbstractOffchainNamespace;
10
21
  exports.GearboxAPI = require_offchain_GearboxAPI.GearboxAPI;
11
- exports.OffchainNotConfiguredError = require_offchain_types.OffchainNotConfiguredError;
12
- exports.OffchainNotImplementedError = require_offchain_types.OffchainNotImplementedError;
22
+ exports.OffchainInvalidJsonError = require_offchain_errors_OffchainInvalidJsonError.OffchainInvalidJsonError;
23
+ exports.OffchainNotConfiguredError = require_offchain_errors_OffchainNotConfiguredError.OffchainNotConfiguredError;
24
+ exports.OffchainNotImplementedError = require_offchain_errors_OffchainNotImplementedError.OffchainNotImplementedError;
13
25
  exports.OffchainOpportunities = require_offchain_opportunities_OffchainOpportunities.OffchainOpportunities;
14
26
  exports.OffchainPositions = require_offchain_positions_OffchainPositions.OffchainPositions;
15
- exports.OffchainTransportError = require_offchain_types.OffchainTransportError;
16
- exports.OffchainValidationError = require_offchain_types.OffchainValidationError;
27
+ exports.OffchainRequestFailedError = require_offchain_errors_OffchainRequestFailedError.OffchainRequestFailedError;
28
+ exports.OffchainStatusError = require_offchain_errors_OffchainStatusError.OffchainStatusError;
29
+ exports.OffchainTransportError = require_offchain_errors_OffchainTransportError.OffchainTransportError;
30
+ exports.OffchainValidationError = require_offchain_errors_OffchainValidationError.OffchainValidationError;
31
+ exports.backendMessage = require_offchain_errors_backendMessage.backendMessage;
32
+ exports.errorCause = require_offchain_errors_errorCause.errorCause;
33
+ exports.readResponseBody = require_offchain_errors_readResponseBody.readResponseBody;
@@ -12,13 +12,16 @@ var OffchainOpportunities = class extends require_offchain_AbstractOffchainNames
12
12
  super("OffchainOpportunities", options);
13
13
  }
14
14
  /**
15
- * All opportunities the backend knows about, optionally narrowed by
16
- * {@link OpportunityFilter}.
15
+ * Opportunities of the chains this client covers, optionally narrowed further
16
+ * by {@link OpportunityFilter}.
17
17
  **/
18
18
  async list(filter) {
19
19
  return this.get({
20
20
  path: this.#root,
21
- query: filter ? zod_v4.z.encode(require_model_opportunities_schema.opportunityFilterQuerySchema, filter) : void 0,
21
+ query: zod_v4.z.encode(require_model_opportunities_schema.opportunityFilterQuerySchema, {
22
+ ...filter,
23
+ chainIds: this.scopedChainIds(filter)
24
+ }),
22
25
  schema: zod_v4.z.array(require_model_opportunities_schema.opportunitySchema)
23
26
  });
24
27
  }
@@ -1,48 +1,42 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_model_positions_schema = require("../../model/positions.schema.js");
2
3
  const require_offchain_AbstractOffchainNamespace = require("../AbstractOffchainNamespace.js");
4
+ let zod_v4 = require("zod/v4");
3
5
  //#region src/offchain/positions/OffchainPositions.ts
4
6
  /**
5
7
  * Backend counterpart of the `positions` namespace.
6
8
  **/
7
9
  var OffchainPositions = class extends require_offchain_AbstractOffchainNamespace.AbstractOffchainNamespace {
10
+ #root = "/v2/positions";
8
11
  constructor(options) {
9
12
  super("OffchainPositions", options);
10
13
  }
11
14
  /**
12
15
  * Everything a wallet holds, optionally narrowed by {@link PositionFilter}.
13
- *
14
- * @returns An empty list until the backend client is implemented.
15
16
  **/
16
- async list(wallet, filter) {
17
- this.logger?.debug({
18
- wallet,
19
- filter
20
- }, "offchain positions list is not implemented, serving empty list");
21
- return {
22
- result: [],
23
- meta: { status: "success" }
24
- };
17
+ async list(props) {
18
+ return this.get({
19
+ path: `${this.#root}/${props.wallet}`,
20
+ query: zod_v4.z.encode(require_model_positions_schema.positionFilterQuerySchema, {
21
+ ...props.filter,
22
+ chainIds: this.scopedChainIds(props.filter)
23
+ }),
24
+ schema: zod_v4.z.array(require_model_positions_schema.positionSchema)
25
+ });
25
26
  }
26
27
  /**
27
- * One historical series of one position. History exists only here: rebuilding
28
- * it from the chain would mean an archive read per point.
29
- *
30
- * The requested metric types the response, so a caller asking for one metric
31
- * does not have to narrow the union back down. When the transport lands,
32
- * validation is what upholds it: a response carrying a different metric than
33
- * the one asked for is a version-skew error like any other.
28
+ * One historical series of one position.
34
29
  *
35
30
  * @returns An empty series until the backend client is implemented.
36
31
  **/
37
32
  async getHistory(query) {
38
- this.logger?.debug({ query }, "offchain positions history is not implemented, serving empty series");
39
33
  return {
40
- result: {
34
+ data: {
41
35
  metric: query.metric,
42
36
  points: [],
43
37
  metadata: {}
44
38
  },
45
- meta: { status: "success" }
39
+ meta: { chains: [] }
46
40
  };
47
41
  }
48
42
  };
@@ -1,76 +1 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/offchain/types.ts
3
- /**
4
- * Thrown by the endpoints that have no stub answer, so that a caller in
5
- * `offchain` mode fails loudly instead of reading an empty detail page as a
6
- * missing entity.
7
- *
8
- * Lives here rather than in one namespace because every stubbed namespace
9
- * throws it.
10
- **/
11
- var OffchainNotImplementedError = class extends Error {
12
- constructor(endpoint) {
13
- super(`GearboxAPI: ${endpoint} is not implemented yet`);
14
- this.name = "OffchainNotImplementedError";
15
- }
16
- };
17
- /**
18
- * Thrown when a read is issued against a client that was never told where the
19
- * backend is.
20
- **/
21
- var OffchainNotConfiguredError = class extends Error {
22
- constructor(path) {
23
- super(`GearboxAPI: cannot read ${path}, no baseUrl was configured`);
24
- this.name = "OffchainNotConfiguredError";
25
- }
26
- };
27
- /**
28
- * Thrown when the backend could not be reached, or answered with a status
29
- * outside the 2xx range.
30
- **/
31
- var OffchainTransportError = class extends Error {
32
- /**
33
- * URL that was requested, query included.
34
- **/
35
- url;
36
- /**
37
- * Status the backend answered with, absent when the request never completed.
38
- **/
39
- status;
40
- constructor(url, reason, status) {
41
- super(`GearboxAPI: request to ${url} failed, ${reason}`);
42
- this.name = "OffchainTransportError";
43
- this.url = url;
44
- this.status = status;
45
- }
46
- };
47
- /**
48
- * Thrown when the backend answered, but with a payload the read model does not
49
- * describe.
50
- *
51
- * This is version skew rather than a bad request, and it is deliberately
52
- * handled like a transport error: the combined SDK drops the backend's
53
- * contribution in `both` mode and fails the read in `offchain` mode.
54
- **/
55
- var OffchainValidationError = class extends Error {
56
- /**
57
- * URL whose payload failed to validate.
58
- **/
59
- url;
60
- /**
61
- * What did not match, in the order zod reported it.
62
- **/
63
- issues;
64
- constructor(url, issues) {
65
- const summary = issues.map((issue) => `${issue.path.join(".") || "<root>"}: ${issue.message}`).join("; ");
66
- super(`GearboxAPI: response from ${url} does not match the model, ${summary}`);
67
- this.name = "OffchainValidationError";
68
- this.url = url;
69
- this.issues = issues;
70
- }
71
- };
72
- //#endregion
73
- exports.OffchainNotConfiguredError = OffchainNotConfiguredError;
74
- exports.OffchainNotImplementedError = OffchainNotImplementedError;
75
- exports.OffchainTransportError = OffchainTransportError;
76
- exports.OffchainValidationError = OffchainValidationError;
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_sdk_chain_chains = require("./chain/chains.js");
3
- const require_sdk_core_errors = require("./core/errors.js");
4
3
  const require_sdk_market_pricefeeds_updates_PriceUpdatesCache = require("./market/pricefeeds/updates/PriceUpdatesCache.js");
5
4
  require("./market/pricefeeds/updates/index.js");
6
5
  const require_sdk_accounts_liquidations_MultichainLiquidationsService = require("./accounts/liquidations/MultichainLiquidationsService.js");
7
6
  require("./accounts/index.js");
7
+ const require_sdk_core_errors = require("./core/errors.js");
8
8
  require("./core/index.js");
9
9
  const require_sdk_opportunities_MultichainOpportunitiesService = require("./opportunities/MultichainOpportunitiesService.js");
10
10
  require("./opportunities/index.js");
@@ -9,7 +9,6 @@ const require_sdk_utils_formatter = require("./utils/formatter.js");
9
9
  const require_sdk_utils_toAddress = require("./utils/toAddress.js");
10
10
  require("./utils/index.js");
11
11
  const require_sdk_base_ChainContractsRegister = require("./base/ChainContractsRegister.js");
12
- const require_sdk_core_errors = require("./core/errors.js");
13
12
  require("./base/index.js");
14
13
  const require_sdk_utils_viem_executeDelegatedMulticalls = require("./utils/viem/executeDelegatedMulticalls.js");
15
14
  require("./utils/viem/index.js");
@@ -24,6 +23,7 @@ const require_sdk_accounts_withdrawal_compressor_createRedemptionLogger = requir
24
23
  const require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor = require("./accounts/withdrawal-compressor/createWithdrawalCompressor.js");
25
24
  require("./accounts/index.js");
26
25
  const require_sdk_core_createAddressProvider = require("./core/createAddressProvider.js");
26
+ const require_sdk_core_errors = require("./core/errors.js");
27
27
  require("./core/index.js");
28
28
  const require_sdk_opportunities_OpportunitiesService = require("./opportunities/OpportunitiesService.js");
29
29
  require("./opportunities/index.js");
@@ -109,7 +109,7 @@ var CreditAccountCompressor = class extends require_sdk_base_SDKConstruct.SDKCon
109
109
  async getBorrowerCreditAccounts(borrower, options, blockNumber) {
110
110
  const { creditManager, includeZeroDebt = false, maxHealthFactor = require_sdk_constants_math.MAX_UINT256, minHealthFactor = 0n, ignoreReservePrices = false } = options ?? {};
111
111
  const { txs: priceUpdateTxs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs(ignoreReservePrices ? { main: true } : void 0);
112
- const rwaAccountAddresses = (await this.sdk.rwa.getInvestorData(borrower)).flatMap((d) => d.creditAccounts.map((ca) => ca.creditAccount));
112
+ const rwaAccountAddresses = (await this.sdk.rwa.getInvestorData(borrower, void 0, blockNumber)).flatMap((d) => d.creditAccounts.map((ca) => ca.creditAccount));
113
113
  const cmFilter = creditManager ? {
114
114
  configurators: [],
115
115
  creditManagers: [creditManager],
@@ -179,13 +179,13 @@ var CreditAccountCompressor = class extends require_sdk_base_SDKConstruct.SDKCon
179
179
  * @param props - {@link ListStrategyPositionsProps}
180
180
  **/
181
181
  async listPositions(props) {
182
- const { owner, includeZeroDebt } = props;
183
- const [accounts] = await Promise.all([this.getBorrowerCreditAccounts(owner, { includeZeroDebt }), this.sdk.withdrawalCompressor?.loadWithdrawableAssets()]);
182
+ const { owner, includeZeroDebt, blockNumber } = props;
183
+ const [accounts] = await Promise.all([this.getBorrowerCreditAccounts(owner, { includeZeroDebt }, blockNumber), this.sdk.withdrawalCompressor?.loadWithdrawableAssets(void 0, blockNumber)]);
184
184
  const describable = accounts.filter((ca) => {
185
185
  if (!ca.success) this.logger?.warn(`cannot describe position of ${this.labelAddress(ca.creditAccount)}: collateral computation failed`);
186
186
  return ca.success;
187
187
  });
188
- const withdrawals = await Promise.all(describable.map((ca) => this.#accountWithdrawals(ca)));
188
+ const withdrawals = await Promise.all(describable.map((ca) => this.#accountWithdrawals(ca, blockNumber)));
189
189
  return describable.map((ca, i) => this.#toStrategyPosition(ca, withdrawals[i] ?? new require_sdk_utils_AddressMap.AddressMap()));
190
190
  }
191
191
  /**
@@ -236,13 +236,13 @@ var CreditAccountCompressor = class extends require_sdk_base_SDKConstruct.SDKCon
236
236
  * Delayed withdrawals of one account, keyed by the phantom token that
237
237
  * represents them on it, so that each collateral row can pick up its own.
238
238
  **/
239
- async #accountWithdrawals(ca) {
239
+ async #accountWithdrawals(ca, blockNumber) {
240
240
  const compressor = this.sdk.withdrawalCompressor;
241
241
  const byPhantomToken = new require_sdk_utils_AddressMap.AddressMap(void 0, "accountWithdrawals");
242
242
  const holdsPhantomToken = ca.tokens.some((t) => t.balance > 10n && compressor?.getWithdrawalSourceToken(t.token) !== void 0);
243
243
  if (!compressor || !holdsPhantomToken) return byPhantomToken;
244
244
  const { priceOracle } = this.sdk.marketRegister.findByCreditManager(ca.creditManager);
245
- const { claimable, pending } = await compressor.getCurrentWithdrawals(ca.creditAccount);
245
+ const { claimable, pending } = await compressor.getCurrentWithdrawals(ca.creditAccount, blockNumber);
246
246
  const add = (w, outputs, claimableAt) => {
247
247
  const assets = outputs.map((o) => ({
248
248
  isDelayed: true,
@@ -33,13 +33,13 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
33
33
  * Accounts whose collateral computation failed are excluded.
34
34
  **/
35
35
  async getLiquidatableAccounts(props) {
36
- await this.sdk.withdrawalCompressor?.loadWithdrawableAssets();
36
+ await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(void 0, props?.blockNumber);
37
37
  const unhealthy = await this.sdk.accounts.getCreditAccounts({
38
38
  maxHealthFactor: require_sdk_constants_math.WAD - 1n,
39
39
  includeZeroDebt: false
40
- });
40
+ }, props?.blockNumber);
41
41
  const seen = new require_sdk_utils_AddressSet.AddressSet(unhealthy.map((ca) => ca.creditAccount));
42
- let expired = await this.#getExpiredCreditAccounts();
42
+ let expired = await this.#getExpiredCreditAccounts(props?.blockNumber);
43
43
  expired = expired.filter((ca) => !seen.has(ca.creditAccount));
44
44
  return [...unhealthy, ...expired].flatMap((ca) => {
45
45
  if (!ca.success) {
@@ -56,13 +56,13 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
56
56
  * @throws When the account is not found or its collateral computation fails.
57
57
  **/
58
58
  async getLiquidationDetails(props) {
59
- const { creditAccount, liquidator, ignoreReservePrices } = props;
60
- const ca = await this.#getCreditAccountData(creditAccount);
59
+ const { creditAccount, liquidator, ignoreReservePrices, blockNumber } = props;
60
+ const ca = await this.#getCreditAccountData(creditAccount, blockNumber);
61
61
  const suite = this.sdk.marketRegister.findCreditManager(ca.creditManager);
62
62
  const { priceOracle } = suite.market;
63
- await this.sdk.withdrawalCompressor?.loadWithdrawableAssets();
63
+ await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(void 0, blockNumber);
64
64
  const account = this.#buildAccount(ca, suite);
65
- const data = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices);
65
+ const data = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices, blockNumber);
66
66
  return {
67
67
  ...account,
68
68
  repaymentAmount: priceOracle.toTokenAmount(require_sdk_utils_hex.hexEq(data.requiredToken, "0x0000000000000000000000000000000000000000") ? account.totalValue.token.address : data.requiredToken, data.requiredAmount),
@@ -80,9 +80,9 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
80
80
  * the debt from own funds and receiving the collateral from the credit account.
81
81
  **/
82
82
  async buildLiquidationTx(props) {
83
- const { creditAccount, liquidator, ignoreReservePrices } = props;
84
- const ca = await this.#getCreditAccountData(creditAccount);
85
- const { liquidationCall } = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices);
83
+ const { creditAccount, liquidator, ignoreReservePrices, blockNumber } = props;
84
+ const ca = await this.#getCreditAccountData(creditAccount, blockNumber);
85
+ const { liquidationCall } = await this.#getLiquidationData(ca, liquidator, ignoreReservePrices, blockNumber);
86
86
  this.logger?.debug(`built tx to liquidate credit account ${this.labelAddress(creditAccount)} to ${this.labelAddress(liquidator)}`);
87
87
  return {
88
88
  to: liquidationCall.target,
@@ -97,9 +97,13 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
97
97
  async getLiquidationPositions(props) {
98
98
  const compressor = this.sdk.withdrawalCompressor;
99
99
  if (!compressor) return [];
100
- await compressor.loadWithdrawableAssets();
100
+ await compressor.loadWithdrawableAssets(void 0, props.blockNumber);
101
101
  const phantomTokens = new require_sdk_utils_AddressSet.AddressSet(compressor.getWithdrawableAssets().map((a) => a.withdrawalPhantomToken));
102
- const { claimable, pending } = await compressor.getExternalAccountCurrentWithdrawals(props.liquidator, ...phantomTokens.asArray());
102
+ const { claimable, pending } = await compressor.getExternalAccountCurrentWithdrawals({
103
+ account: props.liquidator,
104
+ withdrawalTokens: phantomTokens.asArray(),
105
+ blockNumber: props.blockNumber
106
+ });
103
107
  return [...claimable.map((w) => ({
104
108
  ...this.#liquidationPosition(w.token, w.outputs),
105
109
  claimTx: this.#claimTx(w.claimCalls, w.token),
@@ -115,7 +119,7 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
115
119
  * deployed for the markets of the chain and registers them in the SDK
116
120
  * contracts register.
117
121
  **/
118
- async loadRWALiquidators() {
122
+ async loadRWALiquidators(props) {
119
123
  const configurators = this.sdk.marketRegister.marketConfigurators;
120
124
  if (configurators.length === 0) return;
121
125
  const resp = await this.client.multicall({
@@ -126,7 +130,8 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
126
130
  args: [mc.address]
127
131
  })),
128
132
  allowFailure: false,
129
- batchSize: 0
133
+ batchSize: 0,
134
+ blockNumber: props?.blockNumber
130
135
  });
131
136
  for (const info of resp.flat()) this.#createRWALiquidator(info);
132
137
  }
@@ -212,13 +217,13 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
212
217
  ...priceOracle.toTokenAmount(requiredToken, requiredAmount * (require_sdk_constants_math.PERCENTAGE_FACTOR + require_sdk_accounts_liquidations_constants.LIQUIDATION_APPROVAL_BUFFER) / require_sdk_constants_math.PERCENTAGE_FACTOR)
213
218
  };
214
219
  }
215
- async #getCreditAccountData(creditAccount) {
216
- const ca = await this.sdk.accounts.getCreditAccountData(creditAccount);
220
+ async #getCreditAccountData(creditAccount, blockNumber) {
221
+ const ca = await this.sdk.accounts.getCreditAccountData(creditAccount, blockNumber);
217
222
  if (!ca) throw new Error(`credit account ${creditAccount} not found`);
218
223
  if (!ca.success) throw new Error(`cannot compute liquidation details for ${creditAccount}: collateral computation failed`);
219
224
  return ca;
220
225
  }
221
- async #getLiquidationData(ca, liquidator = require_sdk_constants_addresses.ADDRESS_0X0, ignoreReservePrices) {
226
+ async #getLiquidationData(ca, liquidator = require_sdk_constants_addresses.ADDRESS_0X0, ignoreReservePrices, blockNumber) {
222
227
  const priceUpdates = await this.sdk.accounts.getOnDemandPriceUpdates(ca, ignoreReservePrices);
223
228
  const { result } = await this.client.simulateContract({
224
229
  address: require_sdk_accounts_liquidations_constants.LIQUIDATION_COMPRESSOR_V313_ADDRESS,
@@ -228,11 +233,12 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
228
233
  liquidator,
229
234
  ca.creditAccount,
230
235
  priceUpdates
231
- ]
236
+ ],
237
+ blockNumber
232
238
  });
233
239
  return result;
234
240
  }
235
- async #getExpiredCreditAccounts() {
241
+ async #getExpiredCreditAccounts(blockNumber) {
236
242
  const expiredCMs = [];
237
243
  for (const market of this.sdk.marketRegister.markets) {
238
244
  if (market.pool.pool.totalBorrowed === 0n) continue;
@@ -246,7 +252,7 @@ var LiquidationsService = class extends require_sdk_base_SDKConstruct.SDKConstru
246
252
  return (await Promise.all(expiredCMs.map((creditManager) => this.sdk.accounts.getCreditAccounts({
247
253
  creditManager,
248
254
  includeZeroDebt: false
249
- })))).flat();
255
+ }, blockNumber)))).flat();
250
256
  }
251
257
  #buildAccount(ca, suite = this.sdk.marketRegister.findCreditManager(ca.creditManager)) {
252
258
  const market = suite.market;
@@ -3,13 +3,8 @@ const require_sdk_base_MultichainConstruct = require("../../base/MultichainConst
3
3
  require("../../base/index.js");
4
4
  //#region src/sdk/accounts/liquidations/MultichainLiquidationsService.ts
5
5
  /**
6
- * Cross-chain counterpart of {@link LiquidationsService}.
7
- *
8
- * Fans out over all chains configured in {@link MultichainSDK} (optionally
9
- * restricted via {@link MultichainNetworksProps.networks}). A failed chain is
10
- * logged as a warning and skipped, so one dead RPC does not empty the whole
11
- * list; its failure is reported in {@link MultichainResult.meta}. Networks that
12
- * are not configured in the SDK are reported there the same way.
6
+ * Cross-chain counterpart of {@link LiquidationsService}. These reads are live,
7
+ * so each chain is pinned to its own freshly fetched head.
13
8
  **/
14
9
  var MultichainLiquidationsService = class extends require_sdk_base_MultichainConstruct.MultichainConstruct {
15
10
  /**
@@ -18,22 +13,44 @@ var MultichainLiquidationsService = class extends require_sdk_base_MultichainCon
18
13
  **/
19
14
  async getLiquidatableAccounts(props) {
20
15
  return this.queryChains({
21
- networks: props?.networks,
16
+ chainIds: props?.chainIds,
22
17
  label: "get liquidatable accounts",
23
- run: (sdk) => sdk.liquidations.getLiquidatableAccounts(props)
18
+ block: "latest",
19
+ run: (sdk, block) => sdk.liquidations.getLiquidatableAccounts({
20
+ ...props,
21
+ blockNumber: block.blockNumber
22
+ })
24
23
  });
25
24
  }
26
25
  /**
27
26
  * {@inheritDoc LiquidationsService.getLiquidationDetails}
27
+ *
28
+ * Throws when the chain cannot answer.
28
29
  **/
29
30
  async getLiquidationDetails(props) {
30
- return this.sdk.chain(props.network).liquidations.getLiquidationDetails(props);
31
+ return this.queryChain({
32
+ network: props.network,
33
+ block: props.blockNumber ?? "latest",
34
+ run: (sdk, block) => sdk.liquidations.getLiquidationDetails({
35
+ ...props,
36
+ blockNumber: block.blockNumber
37
+ })
38
+ });
31
39
  }
32
40
  /**
33
41
  * {@inheritDoc LiquidationsService.buildLiquidationTx}
42
+ *
43
+ * The reported block is the one the transaction was built against.
34
44
  **/
35
45
  async buildLiquidationTx(props) {
36
- return this.sdk.chain(props.network).liquidations.buildLiquidationTx(props);
46
+ return this.queryChain({
47
+ network: props.network,
48
+ block: props.blockNumber ?? "latest",
49
+ run: (sdk, block) => sdk.liquidations.buildLiquidationTx({
50
+ ...props,
51
+ blockNumber: block.blockNumber
52
+ })
53
+ });
37
54
  }
38
55
  /**
39
56
  * Liquidation positions of all queried chains, see
@@ -41,18 +58,25 @@ var MultichainLiquidationsService = class extends require_sdk_base_MultichainCon
41
58
  **/
42
59
  async getLiquidationPositions(props) {
43
60
  return this.queryChains({
44
- networks: props.networks,
61
+ chainIds: props.chainIds,
45
62
  label: "get liquidation positions",
46
- run: (sdk) => sdk.liquidations.getLiquidationPositions(props)
63
+ block: "latest",
64
+ run: (sdk, block) => sdk.liquidations.getLiquidationPositions({
65
+ ...props,
66
+ blockNumber: block.blockNumber
67
+ })
47
68
  });
48
69
  }
49
70
  /**
50
71
  * Loads the liquidators of all queried chains, see
51
72
  * {@link LiquidationsService.loadRWALiquidators}.
73
+ *
74
+ * Nothing consumes the block of a cache warm-up, so this one is left on the
75
+ * loaded snapshot.
52
76
  **/
53
77
  async loadRWALiquidators(props) {
54
78
  return this.runChains({
55
- networks: props?.networks,
79
+ chainIds: props?.chainIds,
56
80
  label: "load RWA liquidators",
57
81
  run: (sdk) => sdk.liquidations.loadRWALiquidators()
58
82
  });
@@ -65,7 +65,7 @@ var AbstractWithdrawalCompressorContract = class extends require_sdk_base_BaseCo
65
65
  /**
66
66
  * {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
67
67
  **/
68
- async loadWithdrawableAssets(force) {
68
+ async loadWithdrawableAssets(force, blockNumber) {
69
69
  if (this.#withdrawableAssets && !force) return this.getWithdrawableAssets();
70
70
  const cms = this.#sdk.marketRegister.creditManagers.map((cm) => cm.creditManager.address);
71
71
  const resp = await this.client.multicall({
@@ -76,7 +76,8 @@ var AbstractWithdrawalCompressorContract = class extends require_sdk_base_BaseCo
76
76
  args: [cm]
77
77
  })),
78
78
  allowFailure: true,
79
- batchSize: 0
79
+ batchSize: 0,
80
+ blockNumber
80
81
  });
81
82
  const cache = new require_sdk_utils_AddressMap.AddressMap(void 0, MAP_LABEL);
82
83
  for (let i = 0; i < resp.length; i++) {
@@ -121,7 +122,7 @@ var AbstractWithdrawalCompressorContract = class extends require_sdk_base_BaseCo
121
122
  /**
122
123
  * {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
123
124
  **/
124
- async getCurrentWithdrawals(creditAccount) {
125
+ async getCurrentWithdrawals(creditAccount, blockNumber) {
125
126
  const [[claimable, pending], creditManager] = await this.client.multicall({
126
127
  contracts: [{
127
128
  address: this.address,
@@ -134,7 +135,8 @@ var AbstractWithdrawalCompressorContract = class extends require_sdk_base_BaseCo
134
135
  functionName: "creditManager"
135
136
  }],
136
137
  allowFailure: false,
137
- batchSize: 0
138
+ batchSize: 0,
139
+ blockNumber
138
140
  });
139
141
  return {
140
142
  claimable: claimable.map((w) => toClaimableWithdrawal(w, creditManager)),
@@ -144,7 +146,7 @@ var AbstractWithdrawalCompressorContract = class extends require_sdk_base_BaseCo
144
146
  /**
145
147
  * {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
146
148
  **/
147
- async getExternalAccountCurrentWithdrawals(_account, ..._withdrawalTokens) {
149
+ async getExternalAccountCurrentWithdrawals(_props) {
148
150
  this.#reportUnsupported("external account withdrawals");
149
151
  return {
150
152
  claimable: [],
@@ -184,7 +184,7 @@ var WithdrawalCompressorV313Contract = class extends require_sdk_accounts_withdr
184
184
  /**
185
185
  * {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
186
186
  **/
187
- async getExternalAccountCurrentWithdrawals(account, ...withdrawalTokens) {
187
+ async getExternalAccountCurrentWithdrawals({ account, withdrawalTokens = [], blockNumber }) {
188
188
  if (withdrawalTokens.length === 0) return {
189
189
  claimable: [],
190
190
  pending: []
@@ -193,7 +193,8 @@ var WithdrawalCompressorV313Contract = class extends require_sdk_accounts_withdr
193
193
  address: this.address,
194
194
  abi: iExternalWithdrawalsBatchAbi,
195
195
  functionName: "getExternalAccountCurrentWithdrawals",
196
- args: [withdrawalTokens, account]
196
+ args: [withdrawalTokens, account],
197
+ blockNumber
197
198
  });
198
199
  return {
199
200
  claimable: claimable.map((w) => require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.toClaimableWithdrawal(w, void 0)),