@gearbox-protocol/sdk 14.12.0-next.81 → 14.12.0-next.83

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 (200) 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 +3 -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.schema.js +9 -6
  11. package/dist/cjs/new-sdk/AbstractNamespace.js +46 -128
  12. package/dist/cjs/new-sdk/GearboxSDK.js +55 -42
  13. package/dist/cjs/new-sdk/errors/AllSourcesFailedError.js +20 -0
  14. package/dist/cjs/new-sdk/errors/MissingSourceError.js +25 -0
  15. package/dist/cjs/new-sdk/errors/NoSourceServedError.js +20 -0
  16. package/dist/cjs/new-sdk/errors/SourceChainMismatchError.js +34 -0
  17. package/dist/cjs/new-sdk/errors/SourceUnavailableError.js +25 -0
  18. package/dist/cjs/new-sdk/errors/assertSameChains.js +12 -0
  19. package/dist/cjs/new-sdk/errors/everyChainFailed.js +11 -0
  20. package/dist/cjs/new-sdk/errors/index.js +15 -0
  21. package/dist/cjs/new-sdk/index.js +23 -3
  22. package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +37 -89
  23. package/dist/cjs/new-sdk/positions/PositionsNamespace.js +27 -94
  24. package/dist/cjs/new-sdk/types.js +0 -21
  25. package/dist/cjs/new-sdk/utils/filterResponse.js +12 -0
  26. package/dist/cjs/new-sdk/utils/index.js +6 -0
  27. package/dist/cjs/new-sdk/utils/mergeChains.js +76 -0
  28. package/dist/cjs/new-sdk/utils/types.js +1 -0
  29. package/dist/cjs/offchain/AbstractOffchainNamespace.js +42 -65
  30. package/dist/cjs/offchain/GearboxAPI.js +12 -8
  31. package/dist/cjs/offchain/errors/OffchainInvalidJsonError.js +19 -0
  32. package/dist/cjs/offchain/errors/OffchainNotConfiguredError.js +20 -0
  33. package/dist/cjs/offchain/errors/OffchainNotImplementedError.js +19 -0
  34. package/dist/cjs/offchain/errors/OffchainRequestFailedError.js +24 -0
  35. package/dist/cjs/offchain/errors/OffchainStatusError.js +20 -0
  36. package/dist/cjs/offchain/errors/OffchainTransportError.js +31 -0
  37. package/dist/cjs/offchain/errors/OffchainValidationError.js +26 -0
  38. package/dist/cjs/offchain/errors/backendMessage.js +28 -0
  39. package/dist/cjs/offchain/errors/errorCause.js +12 -0
  40. package/dist/cjs/offchain/errors/index.js +21 -0
  41. package/dist/cjs/offchain/errors/readResponseBody.js +15 -0
  42. package/dist/cjs/offchain/index.js +22 -5
  43. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +6 -3
  44. package/dist/cjs/offchain/positions/OffchainPositions.js +15 -21
  45. package/dist/cjs/offchain/types.js +0 -75
  46. package/dist/cjs/sdk/MultichainSDK.js +1 -1
  47. package/dist/cjs/sdk/OnchainSDK.js +1 -1
  48. package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
  49. package/dist/cjs/sdk/base/MultichainConstruct.js +73 -34
  50. package/dist/cjs/sdk/chain/chains.js +11 -0
  51. package/dist/cjs/sdk/chain/index.js +1 -0
  52. package/dist/cjs/sdk/core/index.js +1 -1
  53. package/dist/cjs/sdk/index.js +2 -1
  54. package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
  55. package/dist/cjs/sdk/opportunities/OpportunitiesService.js +1 -4
  56. package/dist/cjs/sdk/positions/MultichainPositionsService.js +6 -29
  57. package/dist/cjs/sdk/positions/PositionsService.js +1 -2
  58. package/dist/esm/dev/AccountOpener.js +1 -1
  59. package/dist/esm/dev/withdrawalUtils.js +1 -1
  60. package/dist/esm/model/filters.js +0 -4
  61. package/dist/esm/model/filters.schema.js +10 -2
  62. package/dist/esm/model/index.js +3 -3
  63. package/dist/esm/model/liquidations.js +1 -1
  64. package/dist/esm/model/liquidations.schema.js +1 -1
  65. package/dist/esm/model/opportunities.js +1 -1
  66. package/dist/esm/model/opportunities.schema.js +4 -11
  67. package/dist/esm/model/positions.js +1 -1
  68. package/dist/esm/model/positions.schema.js +33 -3
  69. package/dist/esm/model/response.schema.js +9 -6
  70. package/dist/esm/new-sdk/AbstractNamespace.js +46 -128
  71. package/dist/esm/new-sdk/GearboxSDK.js +55 -42
  72. package/dist/esm/new-sdk/errors/AllSourcesFailedError.js +19 -0
  73. package/dist/esm/new-sdk/errors/MissingSourceError.js +24 -0
  74. package/dist/esm/new-sdk/errors/NoSourceServedError.js +19 -0
  75. package/dist/esm/new-sdk/errors/SourceChainMismatchError.js +33 -0
  76. package/dist/esm/new-sdk/errors/SourceUnavailableError.js +24 -0
  77. package/dist/esm/new-sdk/errors/assertSameChains.js +11 -0
  78. package/dist/esm/new-sdk/errors/everyChainFailed.js +10 -0
  79. package/dist/esm/new-sdk/errors/index.js +8 -0
  80. package/dist/esm/new-sdk/index.js +13 -3
  81. package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +38 -90
  82. package/dist/esm/new-sdk/positions/PositionsNamespace.js +28 -95
  83. package/dist/esm/new-sdk/types.js +1 -21
  84. package/dist/esm/new-sdk/utils/filterResponse.js +11 -0
  85. package/dist/esm/new-sdk/utils/index.js +3 -1
  86. package/dist/esm/new-sdk/utils/mergeChains.js +73 -0
  87. package/dist/esm/new-sdk/utils/types.js +1 -0
  88. package/dist/esm/offchain/AbstractOffchainNamespace.js +41 -64
  89. package/dist/esm/offchain/GearboxAPI.js +12 -8
  90. package/dist/esm/offchain/errors/OffchainInvalidJsonError.js +18 -0
  91. package/dist/esm/offchain/errors/OffchainNotConfiguredError.js +19 -0
  92. package/dist/esm/offchain/errors/OffchainNotImplementedError.js +18 -0
  93. package/dist/esm/offchain/errors/OffchainRequestFailedError.js +23 -0
  94. package/dist/esm/offchain/errors/OffchainStatusError.js +19 -0
  95. package/dist/esm/offchain/errors/OffchainTransportError.js +30 -0
  96. package/dist/esm/offchain/errors/OffchainValidationError.js +25 -0
  97. package/dist/esm/offchain/errors/backendMessage.js +27 -0
  98. package/dist/esm/offchain/errors/errorCause.js +11 -0
  99. package/dist/esm/offchain/errors/index.js +11 -0
  100. package/dist/esm/offchain/errors/readResponseBody.js +14 -0
  101. package/dist/esm/offchain/index.js +13 -2
  102. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +6 -3
  103. package/dist/esm/offchain/positions/OffchainPositions.js +15 -21
  104. package/dist/esm/offchain/types.js +1 -72
  105. package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
  106. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  107. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  108. package/dist/esm/sdk/MultichainSDK.js +1 -1
  109. package/dist/esm/sdk/OnchainSDK.js +1 -1
  110. package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
  111. package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
  112. package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
  113. package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  114. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  115. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  116. package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  117. package/dist/esm/sdk/base/MultichainConstruct.js +73 -34
  118. package/dist/esm/sdk/base/TokensMeta.js +2 -2
  119. package/dist/esm/sdk/chain/chains.js +11 -1
  120. package/dist/esm/sdk/chain/detectNetwork.js +1 -1
  121. package/dist/esm/sdk/chain/index.js +2 -2
  122. package/dist/esm/sdk/core/createAddressProvider.js +1 -1
  123. package/dist/esm/sdk/core/index.js +1 -1
  124. package/dist/esm/sdk/index.js +3 -3
  125. package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
  126. package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
  127. package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
  128. package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
  129. package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
  130. package/dist/esm/sdk/opportunities/OpportunitiesService.js +1 -4
  131. package/dist/esm/sdk/pools/PoolService.js +1 -1
  132. package/dist/esm/sdk/positions/MultichainPositionsService.js +6 -29
  133. package/dist/esm/sdk/positions/PositionsService.js +1 -2
  134. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
  135. package/dist/types/model/filters.d.ts +9 -3
  136. package/dist/types/model/filters.schema.d.ts +7 -1
  137. package/dist/types/model/index.d.ts +5 -5
  138. package/dist/types/model/liquidations.d.ts +2 -6
  139. package/dist/types/model/liquidations.schema.d.ts +1 -1
  140. package/dist/types/model/opportunities.d.ts +3 -7
  141. package/dist/types/model/opportunities.schema.d.ts +2 -2
  142. package/dist/types/model/positions.d.ts +2 -6
  143. package/dist/types/model/positions.schema.d.ts +32 -2
  144. package/dist/types/model/response.d.ts +7 -6
  145. package/dist/types/model/response.schema.d.ts +41 -32
  146. package/dist/types/new-sdk/AbstractNamespace.d.ts +33 -98
  147. package/dist/types/new-sdk/GearboxSDK.d.ts +10 -25
  148. package/dist/types/new-sdk/errors/AllSourcesFailedError.d.ts +11 -0
  149. package/dist/types/new-sdk/errors/MissingSourceError.d.ts +23 -0
  150. package/dist/types/new-sdk/errors/NoSourceServedError.d.ts +17 -0
  151. package/dist/types/new-sdk/errors/SourceChainMismatchError.d.ts +35 -0
  152. package/dist/types/new-sdk/errors/SourceUnavailableError.d.ts +22 -0
  153. package/dist/types/new-sdk/errors/assertSameChains.d.ts +11 -0
  154. package/dist/types/new-sdk/errors/everyChainFailed.d.ts +10 -0
  155. package/dist/types/new-sdk/errors/index.d.ts +8 -0
  156. package/dist/types/new-sdk/index.d.ts +17 -6
  157. package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +20 -40
  158. package/dist/types/new-sdk/opportunities/index.d.ts +2 -2
  159. package/dist/types/new-sdk/opportunities/types.d.ts +72 -26
  160. package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +18 -38
  161. package/dist/types/new-sdk/positions/index.d.ts +2 -2
  162. package/dist/types/new-sdk/positions/types.d.ts +68 -24
  163. package/dist/types/new-sdk/types.d.ts +24 -77
  164. package/dist/types/new-sdk/utils/filterResponse.d.ts +19 -0
  165. package/dist/types/new-sdk/utils/history.d.ts +6 -36
  166. package/dist/types/new-sdk/utils/index.d.ts +5 -2
  167. package/dist/types/new-sdk/utils/mergeChains.d.ts +22 -0
  168. package/dist/types/new-sdk/utils/types.d.ts +43 -0
  169. package/dist/types/offchain/AbstractOffchainNamespace.d.ts +21 -28
  170. package/dist/types/offchain/GearboxAPI.d.ts +13 -9
  171. package/dist/types/offchain/errors/OffchainInvalidJsonError.d.ts +16 -0
  172. package/dist/types/offchain/errors/OffchainNotConfiguredError.d.ts +16 -0
  173. package/dist/types/offchain/errors/OffchainNotImplementedError.d.ts +15 -0
  174. package/dist/types/offchain/errors/OffchainRequestFailedError.d.ts +12 -0
  175. package/dist/types/offchain/errors/OffchainStatusError.d.ts +16 -0
  176. package/dist/types/offchain/errors/OffchainTransportError.d.ts +43 -0
  177. package/dist/types/offchain/errors/OffchainValidationError.d.ts +21 -0
  178. package/dist/types/offchain/errors/backendMessage.d.ts +9 -0
  179. package/dist/types/offchain/errors/errorCause.d.ts +22 -0
  180. package/dist/types/offchain/errors/index.d.ts +11 -0
  181. package/dist/types/offchain/errors/readResponseBody.d.ts +8 -0
  182. package/dist/types/offchain/index.d.ts +13 -2
  183. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +9 -8
  184. package/dist/types/offchain/positions/OffchainPositions.d.ts +9 -15
  185. package/dist/types/offchain/types.d.ts +7 -88
  186. package/dist/types/sdk/accounts/index.d.ts +2 -2
  187. package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +15 -14
  188. package/dist/types/sdk/accounts/liquidations/index.d.ts +2 -2
  189. package/dist/types/sdk/accounts/liquidations/types.d.ts +9 -15
  190. package/dist/types/sdk/base/MultichainConstruct.d.ts +63 -14
  191. package/dist/types/sdk/base/index.d.ts +2 -2
  192. package/dist/types/sdk/chain/chains.d.ts +10 -2
  193. package/dist/types/sdk/chain/index.d.ts +2 -2
  194. package/dist/types/sdk/index.d.ts +5 -5
  195. package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
  196. package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +13 -16
  197. package/dist/types/sdk/positions/MultichainPositionsService.d.ts +2 -12
  198. package/dist/types/sdk/types/index.d.ts +2 -2
  199. package/dist/types/sdk/types/multichain.d.ts +8 -43
  200. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
- import { Curator } from "./curators.js";
2
1
  import { Amount, AssetType, Bps, ChainId, Leverage, Timestamp, Token } from "./primitives.js";
3
- import { Filterable } from "./filters.js";
2
+ import { Curator } from "./curators.js";
3
+ import { ChainScopedFilter, Filterable } from "./filters.js";
4
4
  import { Address } from "viem";
5
5
  //#region src/model/opportunities.d.ts
6
6
  /**
@@ -356,15 +356,11 @@ declare function opportunityId(opportunity: Opportunity): OpportunityId;
356
356
  * `"all"` to say the same thing explicitly, which is what a UI whose state has
357
357
  * an "any" option holds, see {@link Filterable}. Conditions combine with AND.
358
358
  **/
359
- interface OpportunityFilter {
359
+ interface OpportunityFilter extends ChainScopedFilter {
360
360
  /**
361
361
  * Keep only pools or only strategies.
362
362
  **/
363
363
  kind?: Filterable<OpportunityKind>;
364
- /**
365
- * Keep only opportunities on these chains.
366
- **/
367
- chainIds?: Filterable<ChainId[]>;
368
364
  /**
369
365
  * Keep only opportunities whose {@link OpportunityBase.underlyingToken} is of
370
366
  * this class, which for an RWA market means the class of the token its
@@ -562,7 +562,7 @@ declare const opportunitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
562
562
  **/
563
563
  declare const opportunityFilterSchema: z.ZodObject<{
564
564
  kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">]>, z.ZodLiteral<"all">]>>;
565
- chainIds: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodNumber>, z.ZodLiteral<"all">]>>;
565
+ chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
566
566
  underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
567
567
  paused: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
568
568
  sunset: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
@@ -610,7 +610,7 @@ declare const opportunityFilterQuerySchema: z.ZodCodec<z.ZodObject<{
610
610
  }>>;
611
611
  }, z.core.$strip>, z.ZodObject<{
612
612
  kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">]>, z.ZodLiteral<"all">]>>;
613
- chainIds: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodNumber>, z.ZodLiteral<"all">]>>;
613
+ chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
614
614
  underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
615
615
  paused: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
616
616
  sunset: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
@@ -1,5 +1,5 @@
1
1
  import { AssetType, Bps, ChainId, Leverage, Token, TokenAmount } from "./primitives.js";
2
- import { Filterable } from "./filters.js";
2
+ import { ChainScopedFilter, Filterable } from "./filters.js";
3
3
  import { ApyBreakdown, PointsProgram } from "./opportunities.js";
4
4
  import { DelayedReceivedAsset, LiquidationPosition } from "./liquidations.js";
5
5
  import { Address } from "viem";
@@ -264,7 +264,7 @@ declare function positionId(position: Position): PositionId;
264
264
  * `"all"` to say the same thing explicitly, which is what a UI whose state has
265
265
  * an "any" option holds, see {@link Filterable}. Conditions combine with AND.
266
266
  **/
267
- interface PositionFilter {
267
+ interface PositionFilter extends ChainScopedFilter {
268
268
  /**
269
269
  * Keep only positions of this kind.
270
270
  **/
@@ -274,10 +274,6 @@ interface PositionFilter {
274
274
  * Applicable only to {@link StrategyPosition}
275
275
  **/
276
276
  isZeroDebt?: Filterable<boolean>;
277
- /**
278
- * Keep only positions on these chains.
279
- **/
280
- chainIds?: Filterable<ChainId[]>;
281
277
  /**
282
278
  * Keep only positions whose underlying is of this class, which for an RWA
283
279
  * market means the class of the token its wrapper holds.
@@ -694,9 +694,39 @@ declare const positionSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
694
694
  declare const positionFilterSchema: z.ZodObject<{
695
695
  kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
696
696
  isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
697
- chainIds: z.ZodOptional<z.ZodUnion<[z.ZodArray<z.ZodNumber>, z.ZodLiteral<"all">]>>;
697
+ chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
698
698
  underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
699
699
  }, z.core.$strip>;
700
+ /**
701
+ * {@link PositionFilter} as a URL can carry it: every condition is a string,
702
+ * and a condition that does not narrow is absent rather than empty.
703
+ **/
704
+ declare const positionFilterQueryParamsSchema: z.ZodObject<{
705
+ kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
706
+ isZeroDebt: z.ZodOptional<z.ZodEnum<{
707
+ false: "false";
708
+ true: "true";
709
+ }>>;
710
+ chainIds: z.ZodOptional<z.ZodString>;
711
+ underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
712
+ }, z.core.$strip>;
713
+ /**
714
+ * Code for {@link PositionFilter} to encode/decode to/from url query parameters.
715
+ **/
716
+ declare const positionFilterQuerySchema: z.ZodCodec<z.ZodObject<{
717
+ kind: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>>;
718
+ isZeroDebt: z.ZodOptional<z.ZodEnum<{
719
+ false: "false";
720
+ true: "true";
721
+ }>>;
722
+ chainIds: z.ZodOptional<z.ZodString>;
723
+ underlyingType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
724
+ }, z.core.$strip>, z.ZodObject<{
725
+ kind: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"pool">, z.ZodLiteral<"strategy">, z.ZodLiteral<"liquidation">]>, z.ZodLiteral<"all">]>>;
726
+ isZeroDebt: z.ZodOptional<z.ZodUnion<[z.ZodBoolean, z.ZodLiteral<"all">]>>;
727
+ chainIds: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
728
+ underlyingType: z.ZodOptional<z.ZodUnion<[z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>, z.ZodLiteral<"all">]>>;
729
+ }, z.core.$strip>>;
700
730
  /**
701
731
  * {@link PoolPositionKey}
702
732
  **/
@@ -726,4 +756,4 @@ declare const positionKeySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
726
756
  kind: z.ZodLiteral<"strategy">;
727
757
  }, z.core.$strip>], "kind">;
728
758
  //#endregion
729
- export { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema };
759
+ export { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema };
@@ -37,10 +37,10 @@ interface ResponseMetadata {
37
37
  **/
38
38
  type DataSource = "onchain" | "offchain";
39
39
  /**
40
- * Chain that answered, and which source served it.
40
+ * Chain that answered, which source served it, and the block it answered from.
41
41
  *
42
42
  * Discriminated from {@link ChainFailed} on {@link status}, so a success
43
- * without a source is unrepresentable.
43
+ * without a source, or without the block it reflects, is unrepresentable.
44
44
  **/
45
45
  interface ChainSucceeded {
46
46
  /**
@@ -55,13 +55,14 @@ interface ChainSucceeded {
55
55
  source: DataSource;
56
56
  /**
57
57
  * Block the data reflects. A `number` here (model convention), converted
58
- * from `bigint` at the onchain boundary.
58
+ * from `bigint` at the onchain boundary. A chain that cannot say which block
59
+ * it answered from is a {@link ChainFailed}.
59
60
  **/
60
- blockNumber?: number;
61
+ blockNumber: number;
61
62
  /**
62
63
  * Unix seconds of {@link blockNumber}.
63
64
  **/
64
- timestamp?: Timestamp;
65
+ timestamp: Timestamp;
65
66
  }
66
67
  /**
67
68
  * Chain that did not answer.
@@ -78,7 +79,7 @@ interface ChainFailed {
78
79
  **/
79
80
  source?: DataSource;
80
81
  /**
81
- * Rejection reason. A `string` in JSON responses, an `Error` (or an
82
+ * Rejection reason. A `string` in a JSON response, an `Error` (or an
82
83
  * `AggregateError` when both sources failed) when produced locally.
83
84
  *
84
85
  * Serialises to `{}` if an envelope carrying a real `Error` is put into
@@ -1,3 +1,4 @@
1
+ import { DataResponse } from "./response.js";
1
2
  import { z } from "zod/v4";
2
3
  //#region src/model/response.schema.d.ts
3
4
  /**
@@ -10,27 +11,39 @@ import { z } from "zod/v4";
10
11
  /**
11
12
  * {@link DataSource}
12
13
  **/
13
- declare const dataSourceSchema: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
14
+ declare const dataSourceSchema: z.ZodEnum<{
15
+ offchain: "offchain";
16
+ onchain: "onchain";
17
+ }>;
14
18
  /**
15
19
  * {@link ChainSucceeded}
20
+ *
21
+ * `source` may be omitted by the backend and decodes to `"offchain"`. The block
22
+ * has no such default: a success that omits it fails validation.
16
23
  **/
17
24
  declare const chainSucceededSchema: z.ZodObject<{
18
25
  chainId: z.ZodNumber;
19
26
  status: z.ZodLiteral<"success">;
20
- source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
21
- blockNumber: z.ZodOptional<z.ZodNumber>;
22
- timestamp: z.ZodOptional<z.ZodNumber>;
27
+ source: z.ZodDefault<z.ZodEnum<{
28
+ offchain: "offchain";
29
+ onchain: "onchain";
30
+ }>>;
31
+ blockNumber: z.ZodNumber;
32
+ timestamp: z.ZodNumber;
23
33
  }, z.core.$strip>;
24
34
  /**
25
35
  * {@link ChainFailed}
26
36
  *
27
- * `error` is a `string` on the wire. The schema accepts `unknown` so the same
28
- * codec also validates a locally produced envelope that carries an `Error`.
37
+ * `error` is a `string` in a JSON body. The schema accepts `unknown` so the
38
+ * same codec also validates a locally produced envelope carrying an `Error`.
29
39
  **/
30
40
  declare const chainFailedSchema: z.ZodObject<{
31
41
  chainId: z.ZodNumber;
32
42
  status: z.ZodLiteral<"error">;
33
- source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
43
+ source: z.ZodOptional<z.ZodEnum<{
44
+ offchain: "offchain";
45
+ onchain: "onchain";
46
+ }>>;
34
47
  error: z.ZodOptional<z.ZodUnknown>;
35
48
  }, z.core.$strip>;
36
49
  /**
@@ -39,13 +52,19 @@ declare const chainFailedSchema: z.ZodObject<{
39
52
  declare const chainMetadataSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
40
53
  chainId: z.ZodNumber;
41
54
  status: z.ZodLiteral<"success">;
42
- source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
43
- blockNumber: z.ZodOptional<z.ZodNumber>;
44
- timestamp: z.ZodOptional<z.ZodNumber>;
55
+ source: z.ZodDefault<z.ZodEnum<{
56
+ offchain: "offchain";
57
+ onchain: "onchain";
58
+ }>>;
59
+ blockNumber: z.ZodNumber;
60
+ timestamp: z.ZodNumber;
45
61
  }, z.core.$strip>, z.ZodObject<{
46
62
  chainId: z.ZodNumber;
47
63
  status: z.ZodLiteral<"error">;
48
- source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
64
+ source: z.ZodOptional<z.ZodEnum<{
65
+ offchain: "offchain";
66
+ onchain: "onchain";
67
+ }>>;
49
68
  error: z.ZodOptional<z.ZodUnknown>;
50
69
  }, z.core.$strip>], "status">;
51
70
  /**
@@ -55,35 +74,25 @@ declare const responseMetadataSchema: z.ZodObject<{
55
74
  chains: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
56
75
  chainId: z.ZodNumber;
57
76
  status: z.ZodLiteral<"success">;
58
- source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
59
- blockNumber: z.ZodOptional<z.ZodNumber>;
60
- timestamp: z.ZodOptional<z.ZodNumber>;
77
+ source: z.ZodDefault<z.ZodEnum<{
78
+ offchain: "offchain";
79
+ onchain: "onchain";
80
+ }>>;
81
+ blockNumber: z.ZodNumber;
82
+ timestamp: z.ZodNumber;
61
83
  }, z.core.$strip>, z.ZodObject<{
62
84
  chainId: z.ZodNumber;
63
85
  status: z.ZodLiteral<"error">;
64
- source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
86
+ source: z.ZodOptional<z.ZodEnum<{
87
+ offchain: "offchain";
88
+ onchain: "onchain";
89
+ }>>;
65
90
  error: z.ZodOptional<z.ZodUnknown>;
66
91
  }, z.core.$strip>], "status">>;
67
92
  }, z.core.$strip>;
68
93
  /**
69
94
  * {@link DataResponse} parameterized by the payload schema.
70
95
  **/
71
- declare function responseSchema<S extends z.ZodType>(payloadSchema: S): z.ZodObject<{
72
- data: S;
73
- meta: z.ZodObject<{
74
- chains: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
75
- chainId: z.ZodNumber;
76
- status: z.ZodLiteral<"success">;
77
- source: z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>;
78
- blockNumber: z.ZodOptional<z.ZodNumber>;
79
- timestamp: z.ZodOptional<z.ZodNumber>;
80
- }, z.core.$strip>, z.ZodObject<{
81
- chainId: z.ZodNumber;
82
- status: z.ZodLiteral<"error">;
83
- source: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"onchain">, z.ZodLiteral<"offchain">]>>;
84
- error: z.ZodOptional<z.ZodUnknown>;
85
- }, z.core.$strip>], "status">>;
86
- }, z.core.$strip>;
87
- }, z.core.$strip>;
96
+ declare function responseSchema<S extends z.ZodType>(payloadSchema: S): z.ZodType<DataResponse<z.output<S>>>;
88
97
  //#endregion
89
98
  export { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema };
@@ -1,119 +1,54 @@
1
1
  import { ILogger } from "../sdk/types/logger.js";
2
- import { ChainId } from "../model/primitives.js";
3
- import { NetworkType } from "../sdk/chain/chains.js";
4
- import { MultichainNetworkMeta } from "../sdk/types/multichain.js";
2
+ import { DataResponse } from "../model/response.js";
5
3
  import "../model/index.js";
6
- import { MultichainSDK } from "../sdk/MultichainSDK.js";
7
- import "../sdk/index.js";
8
- import { OffchainResult } from "../offchain/types.js";
9
- import { GearboxAPI } from "../offchain/GearboxAPI.js";
10
- import "../offchain/index.js";
11
- import { OffchainSourceStatus, ReadResult, SourceMeta } from "./types.js";
4
+ import { NamespaceOptions } from "./types.js";
5
+ import { EntityMerger, ListMerger } from "./utils/types.js";
6
+ import "./utils/index.js";
12
7
  //#region src/new-sdk/AbstractNamespace.d.ts
13
8
  /**
14
- * What the on-chain source contributed, after per-chain failures have been
15
- * turned into metadata.
9
+ * One read of a combined namespace: the same query against each source, plus
10
+ * the policy that turns the two answers into one.
16
11
  *
17
- * @internal
12
+ * @typeParam Onchain - On-chain source namespace.
13
+ * @typeParam Offchain - Backend source namespace.
14
+ * @typeParam T - Payload type of the read.
18
15
  **/
19
- interface OnchainContribution<T> {
20
- value?: T;
21
- chains: MultichainNetworkMeta[];
16
+ interface MergedQuery<Onchain, Offchain, T> {
17
+ fromChain: (source: Onchain) => Promise<DataResponse<T>>;
18
+ fromBackend: (source: Offchain) => Promise<DataResponse<T>>;
19
+ merge: ListMerger<T> | EntityMerger<T>;
22
20
  }
23
21
  /**
24
- * What the off-chain source contributed, after a rejection has been turned into
25
- * metadata.
22
+ * Base class of every {@link GearboxSDK} namespace: holds the two source
23
+ * namespaces, exposes each on its own, and runs merged reads over both.
26
24
  *
27
- * @internal
25
+ * @typeParam Onchain - On-chain source namespace, e.g.
26
+ * `MultichainOpportunitiesService`.
27
+ * @typeParam Offchain - Backend source namespace, e.g. `OffchainOpportunities`.
28
28
  **/
29
- interface OffchainContribution<T> {
30
- value?: T;
31
- status?: OffchainSourceStatus;
32
- }
33
- /**
34
- * How a read turns the two contributions into one payload. Either side is
35
- * absent when its source was not asked, or was asked and failed.
36
- *
37
- * @internal
38
- **/
39
- type CombineSources<T> = (onchain: T | undefined, offchain: T | undefined) => T;
40
- /**
41
- * Shared machinery of every {@link GearboxSDK} namespace.
42
- *
43
- * A namespace is a stateless router: it asks the sources its mode allows, in
44
- * parallel, merges what came back and reports what did not. This class owns
45
- * that routing — per-chain failure capture, backend degradation, the response
46
- * envelope and the all-sources-failed rule — so a namespace holds nothing but
47
- * its reads and its merge policy.
48
- *
49
- * The sources are whatever it was handed, and their readiness is their owner's
50
- * business: a source that is not ready to answer fails the read it was given,
51
- * and that failure is reported like any other.
52
- *
53
- * All protocol knowledge lives in the sources: `MultichainSDK` for the chain,
54
- * `GearboxAPI` for the backend. None of it is repeated here or in a subclass.
55
- *
56
- * @typeParam ListRow - Row type of the namespace's list read.
57
- **/
58
- declare abstract class AbstractNamespace<ListRow extends object> {
29
+ declare abstract class AbstractNamespace<Onchain, Offchain> {
59
30
  #private;
60
- protected readonly logger?: ILogger;
61
- protected constructor(name: string, onchain: MultichainSDK | undefined, offchain: GearboxAPI | undefined, logger?: ILogger);
62
- /**
63
- * Per-field source policy for one row of this namespace.
64
- **/
65
- protected abstract mergeOne<T extends object>(onchain: T, offchain: T): T;
66
- /**
67
- * Union policy for this namespace's list read.
68
- **/
69
- protected abstract mergeList(onchain: ListRow[], offchain: ListRow[]): ListRow[];
70
- /**
71
- * Asks both sources in parallel and combines whatever answered.
72
- *
73
- * The action name is only used in diagnostics and in the error raised when
74
- * every source the read had failed.
75
- **/
76
- protected read<T>(action: string, fromChain: (sdk: MultichainSDK) => Promise<OnchainContribution<T>>, fromBackend: (api: GearboxAPI) => Promise<OffchainResult<T>>, combine: CombineSources<T>): Promise<ReadResult<T>>;
77
- /**
78
- * Reads the namespace's list from both sources, unioned by
79
- * {@link AbstractNamespace.mergeList}.
80
- **/
81
- protected readList(action: string, fromChain: (sdk: MultichainSDK) => Promise<OnchainContribution<ListRow[]>>, fromBackend: (api: GearboxAPI) => Promise<OffchainResult<ListRow[]>>): Promise<ReadResult<ListRow[]>>;
82
- /**
83
- * Reads one row from both sources and merges them under
84
- * {@link AbstractNamespace.mergeOne}. The key names the chain, so the
85
- * on-chain leg queries exactly one.
86
- **/
87
- protected readOne<T extends object>(action: string, chainId: ChainId, fromChain: (sdk: MultichainSDK) => Promise<T>, fromBackend: (api: GearboxAPI) => Promise<OffchainResult<T>>): Promise<ReadResult<T>>;
88
31
  /**
89
- * Reads something only the backend can answer.
90
- *
91
- * The fallback stands in for a backend that answered with nothing, which is
92
- * a different thing from a backend that failed and was dropped.
32
+ * How far the backend may lag the chain and still serve a chain.
93
33
  **/
94
- protected readOffchain<T>(action: string, fromBackend: (api: GearboxAPI) => Promise<OffchainResult<T>>, fallback: T): Promise<ReadResult<T>>;
95
- /**
96
- * Runs a read against the chain, or reports the chain as absent when the
97
- * namespace has no on-chain source at all.
98
- **/
99
- protected fromChain<T>(run: (sdk: MultichainSDK) => Promise<OnchainContribution<T>>): Promise<OnchainContribution<T>>;
34
+ protected readonly maxOffchainLagSeconds: number;
35
+ protected readonly logger?: ILogger;
36
+ protected constructor(name: string, onchain: Onchain | undefined, offchain: Offchain | undefined, options: NamespaceOptions);
100
37
  /**
101
- * Runs a read against the backend, turning any rejection into metadata so
102
- * that a dead backend degrades a `both`-mode read instead of failing it.
38
+ * The on-chain source namespace on its own. Throws
39
+ * {@link SourceUnavailableError} in `offchain` mode.
103
40
  **/
104
- protected fromBackend<T>(run: (api: GearboxAPI) => Promise<OffchainResult<T>>): Promise<OffchainContribution<T>>;
41
+ get onchain(): Onchain;
105
42
  /**
106
- * Runs a read against one chain, turning a rejection into that chain's
107
- * metadata entry.
43
+ * The backend source namespace on its own. Throws
44
+ * {@link SourceUnavailableError} in `onchain` mode.
108
45
  **/
109
- protected onOneChain<T>(action: string, network: NetworkType, run: () => Promise<T>): Promise<OnchainContribution<T>>;
46
+ get offchain(): Offchain;
110
47
  /**
111
- * A read that reached at least one source returns what it has; a read where
112
- * every source it had failed throws, because an empty result would otherwise
113
- * be indistinguishable from "there is nothing here".
48
+ * Asks both sources at once and merges what came back, failing only when no
49
+ * chain was served at all.
114
50
  **/
115
- protected assertAnySourceSucceeded(action: string, meta: SourceMeta): void;
116
- protected networkOf(chainId: ChainId): NetworkType | undefined;
51
+ protected merged<T>(action: string, query: MergedQuery<Onchain, Offchain, T>): Promise<DataResponse<T>>;
117
52
  }
118
53
  //#endregion
119
- export { AbstractNamespace, CombineSources, OffchainContribution, OnchainContribution };
54
+ export { AbstractNamespace, MergedQuery };
@@ -7,12 +7,9 @@ import { Positions } from "./positions/types.js";
7
7
  import "./positions/index.js";
8
8
  //#region src/new-sdk/GearboxSDK.d.ts
9
9
  /**
10
- * Combined entry point over both sources of Gearbox data: the chain and the
11
- * Gearbox backend.
12
- *
13
- * The {@link Mode} is fixed at construction and decides which methods exist,
14
- * not what they return, so a screen written against `both` cannot silently
15
- * degrade to a subset when someone reconfigures the SDK:
10
+ * Entry point over both sources of Gearbox data: the chain and the Gearbox
11
+ * backend. The {@link Mode} is fixed at construction and decides which methods
12
+ * exist.
16
13
  *
17
14
  * ```ts
18
15
  * const sdk = new GearboxSDK({
@@ -23,13 +20,9 @@ import "./positions/index.js";
23
20
  * });
24
21
  * await sdk.attach();
25
22
  *
26
- * const { result, meta } = await sdk.opportunities.list({ kind: "strategy" });
23
+ * const { data, meta } = await sdk.opportunities.list({ kind: "strategy" });
27
24
  * ```
28
25
  *
29
- * Every read answers with `{ result, meta }`: `meta` says which chains and
30
- * which backend answered, because a partial answer is the normal case for a
31
- * multi-chain read.
32
- *
33
26
  * @typeParam M - Mode the instance was built in.
34
27
  **/
35
28
  declare class GearboxSDK<const M extends Mode = Mode> {
@@ -39,8 +32,7 @@ declare class GearboxSDK<const M extends Mode = Mode> {
39
32
  **/
40
33
  readonly mode: M;
41
34
  /**
42
- * Chains this instance covers. Authoritative even when an injected on-chain
43
- * SDK covers a different set.
35
+ * Chains this instance covers, which every read is scoped to.
44
36
  **/
45
37
  readonly networks: readonly NetworkType[];
46
38
  /**
@@ -53,26 +45,19 @@ declare class GearboxSDK<const M extends Mode = Mode> {
53
45
  readonly positions: Positions<M>;
54
46
  constructor(options: GearboxSDKOptions<M>);
55
47
  /**
56
- * Attaches the on-chain SDK when this instance owns one.
57
- *
58
- * Reads issued before this resolves still reach the chain and fail there, so
59
- * in `both` mode they are served from the backend alone and report the chain
60
- * as failed in their meta, rather than blocking.
61
- *
62
- * A no-op in `offchain` mode and when an already-attached SDK was injected.
48
+ * Attaches the on-chain SDK when this instance owns one; a no-op in `offchain`
49
+ * mode and when an already-attached SDK was injected.
63
50
  **/
64
51
  attach(): Promise<void>;
65
52
  /**
66
53
  * Whether the on-chain source is ready to be read from. Always `true` in
67
- * `offchain` mode, where there is nothing to wait for.
54
+ * `offchain` mode.
68
55
  **/
69
56
  get attached(): boolean;
70
57
  /**
71
58
  * The underlying on-chain SDK, for everything this facade does not expose
72
- * yet: markets, credit accounts, transaction building.
73
- *
74
- * `undefined` in `offchain` mode. Otherwise it exists from construction on,
75
- * but only answers reads once {@link attach} has resolved.
59
+ * yet: markets, credit accounts, transaction building. `undefined` in
60
+ * `offchain` mode, and only answers reads once {@link attach} has resolved.
76
61
  **/
77
62
  get onchain(): OnchainByMode[M];
78
63
  /**
@@ -0,0 +1,11 @@
1
+ import { ResponseMetadata } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ //#region src/new-sdk/errors/AllSourcesFailedError.d.ts
4
+ /**
5
+ * Thrown when a read had sources to ask and none of them served a single chain.
6
+ **/
7
+ declare class AllSourcesFailedError extends AggregateError {
8
+ constructor(action: string, sourceErrors: unknown[], meta?: ResponseMetadata);
9
+ }
10
+ //#endregion
11
+ export { AllSourcesFailedError };
@@ -0,0 +1,23 @@
1
+ import { DataSource } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ import { Mode } from "../types.js";
4
+ import { BaseError } from "viem";
5
+ //#region src/new-sdk/errors/MissingSourceError.d.ts
6
+ /**
7
+ * Thrown at construction when a {@link GearboxSDK} was not given a source its
8
+ * {@link Mode} reads from.
9
+ **/
10
+ declare class MissingSourceError extends BaseError {
11
+ name: string;
12
+ /**
13
+ * Mode the SDK was built in.
14
+ **/
15
+ readonly mode: Mode;
16
+ /**
17
+ * Source that mode needs and did not get.
18
+ **/
19
+ readonly source: DataSource;
20
+ constructor(mode: Mode, source: DataSource);
21
+ }
22
+ //#endregion
23
+ export { MissingSourceError };
@@ -0,0 +1,17 @@
1
+ import { ChainId } from "../../model/primitives.js";
2
+ import "../../model/index.js";
3
+ //#region src/new-sdk/errors/NoSourceServedError.d.ts
4
+ /**
5
+ * The failure of a chain no source served. It is reported in that chain's
6
+ * metadata entry rather than thrown: the other chains of the same read may
7
+ * still have been served.
8
+ **/
9
+ declare class NoSourceServedError extends AggregateError {
10
+ /**
11
+ * Chain no source served.
12
+ **/
13
+ readonly chainId: ChainId;
14
+ constructor(chainId: ChainId, reasons: unknown[]);
15
+ }
16
+ //#endregion
17
+ export { NoSourceServedError };
@@ -0,0 +1,35 @@
1
+ import { ChainId } from "../../model/primitives.js";
2
+ import { NetworkType } from "../../sdk/chain/chains.js";
3
+ import { DataSource } from "../../model/response.js";
4
+ import "../../model/index.js";
5
+ import "../../sdk/index.js";
6
+ import { BaseError } from "viem";
7
+ //#region src/new-sdk/errors/SourceChainMismatchError.d.ts
8
+ /**
9
+ * How a source names the chains it covers: by label or by id, depending on which
10
+ * of the two it was configured with.
11
+ **/
12
+ type ChainRef = NetworkType | ChainId;
13
+ /**
14
+ * Thrown at construction when a source covers anything other than exactly the
15
+ * chains a {@link GearboxSDK} was built for, see
16
+ * {@link GearboxSDKOptions.networks}.
17
+ **/
18
+ declare class SourceChainMismatchError extends BaseError {
19
+ name: string;
20
+ /**
21
+ * Source whose coverage does not match.
22
+ **/
23
+ readonly source: DataSource;
24
+ /**
25
+ * Chains the SDK covers.
26
+ **/
27
+ readonly expected: readonly ChainRef[];
28
+ /**
29
+ * Chains the source covers.
30
+ **/
31
+ readonly covered: readonly ChainRef[];
32
+ constructor(source: DataSource, expected: readonly ChainRef[], covered: readonly ChainRef[]);
33
+ }
34
+ //#endregion
35
+ export { ChainRef, SourceChainMismatchError };
@@ -0,0 +1,22 @@
1
+ import { DataSource } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ import { BaseError } from "viem";
4
+ //#region src/new-sdk/errors/SourceUnavailableError.d.ts
5
+ /**
6
+ * Thrown when a source branch of a namespace is read in a mode that has no such
7
+ * source, e.g. `sdk.opportunities.onchain` in `offchain` mode.
8
+ **/
9
+ declare class SourceUnavailableError extends BaseError {
10
+ name: string;
11
+ /**
12
+ * Namespace whose branch was read.
13
+ **/
14
+ readonly namespace: string;
15
+ /**
16
+ * Source this mode does not read.
17
+ **/
18
+ readonly source: DataSource;
19
+ constructor(namespace: string, source: DataSource);
20
+ }
21
+ //#endregion
22
+ export { SourceUnavailableError };
@@ -0,0 +1,11 @@
1
+ import { DataSource } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ import { ChainRef } from "./SourceChainMismatchError.js";
4
+ //#region src/new-sdk/errors/assertSameChains.d.ts
5
+ /**
6
+ * Rejects a source covering anything other than exactly the chains the SDK was
7
+ * built for. A source is not narrowed to them: it has to name them.
8
+ **/
9
+ declare function assertSameChains<T extends ChainRef>(source: DataSource, expected: readonly T[], covered: readonly T[]): void;
10
+ //#endregion
11
+ export { assertSameChains };
@@ -0,0 +1,10 @@
1
+ import { ResponseMetadata } from "../../model/response.js";
2
+ import "../../model/index.js";
3
+ //#region src/new-sdk/errors/everyChainFailed.d.ts
4
+ /**
5
+ * Whether a merged envelope covered chains and lost every one of them, which is
6
+ * what makes a read a failure rather than a partial result.
7
+ **/
8
+ declare function everyChainFailed(meta: ResponseMetadata): boolean;
9
+ //#endregion
10
+ export { everyChainFailed };