@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.
- package/dist/cjs/model/filters.js +0 -4
- package/dist/cjs/model/filters.schema.js +10 -1
- package/dist/cjs/model/index.js +3 -0
- package/dist/cjs/model/liquidations.js +1 -1
- package/dist/cjs/model/liquidations.schema.js +1 -1
- package/dist/cjs/model/opportunities.js +1 -1
- package/dist/cjs/model/opportunities.schema.js +6 -13
- package/dist/cjs/model/positions.js +1 -1
- package/dist/cjs/model/positions.schema.js +33 -1
- package/dist/cjs/model/response.schema.js +9 -6
- package/dist/cjs/new-sdk/AbstractNamespace.js +46 -128
- package/dist/cjs/new-sdk/GearboxSDK.js +55 -42
- package/dist/cjs/new-sdk/errors/AllSourcesFailedError.js +20 -0
- package/dist/cjs/new-sdk/errors/MissingSourceError.js +25 -0
- package/dist/cjs/new-sdk/errors/NoSourceServedError.js +20 -0
- package/dist/cjs/new-sdk/errors/SourceChainMismatchError.js +34 -0
- package/dist/cjs/new-sdk/errors/SourceUnavailableError.js +25 -0
- package/dist/cjs/new-sdk/errors/assertSameChains.js +12 -0
- package/dist/cjs/new-sdk/errors/everyChainFailed.js +11 -0
- package/dist/cjs/new-sdk/errors/index.js +15 -0
- package/dist/cjs/new-sdk/index.js +23 -3
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +37 -89
- package/dist/cjs/new-sdk/positions/PositionsNamespace.js +27 -94
- package/dist/cjs/new-sdk/types.js +0 -21
- package/dist/cjs/new-sdk/utils/filterResponse.js +12 -0
- package/dist/cjs/new-sdk/utils/index.js +6 -0
- package/dist/cjs/new-sdk/utils/mergeChains.js +76 -0
- package/dist/cjs/new-sdk/utils/types.js +1 -0
- package/dist/cjs/offchain/AbstractOffchainNamespace.js +42 -65
- package/dist/cjs/offchain/GearboxAPI.js +12 -8
- package/dist/cjs/offchain/errors/OffchainInvalidJsonError.js +19 -0
- package/dist/cjs/offchain/errors/OffchainNotConfiguredError.js +20 -0
- package/dist/cjs/offchain/errors/OffchainNotImplementedError.js +19 -0
- package/dist/cjs/offchain/errors/OffchainRequestFailedError.js +24 -0
- package/dist/cjs/offchain/errors/OffchainStatusError.js +20 -0
- package/dist/cjs/offchain/errors/OffchainTransportError.js +31 -0
- package/dist/cjs/offchain/errors/OffchainValidationError.js +26 -0
- package/dist/cjs/offchain/errors/backendMessage.js +28 -0
- package/dist/cjs/offchain/errors/errorCause.js +12 -0
- package/dist/cjs/offchain/errors/index.js +21 -0
- package/dist/cjs/offchain/errors/readResponseBody.js +15 -0
- package/dist/cjs/offchain/index.js +22 -5
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +6 -3
- package/dist/cjs/offchain/positions/OffchainPositions.js +15 -21
- package/dist/cjs/offchain/types.js +0 -75
- package/dist/cjs/sdk/MultichainSDK.js +1 -1
- package/dist/cjs/sdk/OnchainSDK.js +1 -1
- package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
- package/dist/cjs/sdk/base/MultichainConstruct.js +73 -34
- package/dist/cjs/sdk/chain/chains.js +11 -0
- package/dist/cjs/sdk/chain/index.js +1 -0
- package/dist/cjs/sdk/core/index.js +1 -1
- package/dist/cjs/sdk/index.js +2 -1
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +1 -4
- package/dist/cjs/sdk/positions/MultichainPositionsService.js +6 -29
- package/dist/cjs/sdk/positions/PositionsService.js +1 -2
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/filters.js +0 -4
- package/dist/esm/model/filters.schema.js +10 -2
- package/dist/esm/model/index.js +3 -3
- package/dist/esm/model/liquidations.js +1 -1
- package/dist/esm/model/liquidations.schema.js +1 -1
- package/dist/esm/model/opportunities.js +1 -1
- package/dist/esm/model/opportunities.schema.js +4 -11
- package/dist/esm/model/positions.js +1 -1
- package/dist/esm/model/positions.schema.js +33 -3
- package/dist/esm/model/response.schema.js +9 -6
- package/dist/esm/new-sdk/AbstractNamespace.js +46 -128
- package/dist/esm/new-sdk/GearboxSDK.js +55 -42
- package/dist/esm/new-sdk/errors/AllSourcesFailedError.js +19 -0
- package/dist/esm/new-sdk/errors/MissingSourceError.js +24 -0
- package/dist/esm/new-sdk/errors/NoSourceServedError.js +19 -0
- package/dist/esm/new-sdk/errors/SourceChainMismatchError.js +33 -0
- package/dist/esm/new-sdk/errors/SourceUnavailableError.js +24 -0
- package/dist/esm/new-sdk/errors/assertSameChains.js +11 -0
- package/dist/esm/new-sdk/errors/everyChainFailed.js +10 -0
- package/dist/esm/new-sdk/errors/index.js +8 -0
- package/dist/esm/new-sdk/index.js +13 -3
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +38 -90
- package/dist/esm/new-sdk/positions/PositionsNamespace.js +28 -95
- package/dist/esm/new-sdk/types.js +1 -21
- package/dist/esm/new-sdk/utils/filterResponse.js +11 -0
- package/dist/esm/new-sdk/utils/index.js +3 -1
- package/dist/esm/new-sdk/utils/mergeChains.js +73 -0
- package/dist/esm/new-sdk/utils/types.js +1 -0
- package/dist/esm/offchain/AbstractOffchainNamespace.js +41 -64
- package/dist/esm/offchain/GearboxAPI.js +12 -8
- package/dist/esm/offchain/errors/OffchainInvalidJsonError.js +18 -0
- package/dist/esm/offchain/errors/OffchainNotConfiguredError.js +19 -0
- package/dist/esm/offchain/errors/OffchainNotImplementedError.js +18 -0
- package/dist/esm/offchain/errors/OffchainRequestFailedError.js +23 -0
- package/dist/esm/offchain/errors/OffchainStatusError.js +19 -0
- package/dist/esm/offchain/errors/OffchainTransportError.js +30 -0
- package/dist/esm/offchain/errors/OffchainValidationError.js +25 -0
- package/dist/esm/offchain/errors/backendMessage.js +27 -0
- package/dist/esm/offchain/errors/errorCause.js +11 -0
- package/dist/esm/offchain/errors/index.js +11 -0
- package/dist/esm/offchain/errors/readResponseBody.js +14 -0
- package/dist/esm/offchain/index.js +13 -2
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +6 -3
- package/dist/esm/offchain/positions/OffchainPositions.js +15 -21
- package/dist/esm/offchain/types.js +1 -72
- package/dist/esm/plugins/adapters/contracts/ERC4626AdapterContract.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/sdk/MultichainSDK.js +1 -1
- package/dist/esm/sdk/OnchainSDK.js +1 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
- package/dist/esm/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
- package/dist/esm/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
- package/dist/esm/sdk/base/MultichainConstruct.js +73 -34
- package/dist/esm/sdk/base/TokensMeta.js +2 -2
- package/dist/esm/sdk/chain/chains.js +11 -1
- package/dist/esm/sdk/chain/detectNetwork.js +1 -1
- package/dist/esm/sdk/chain/index.js +2 -2
- package/dist/esm/sdk/core/createAddressProvider.js +1 -1
- package/dist/esm/sdk/core/index.js +1 -1
- package/dist/esm/sdk/index.js +3 -3
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +1 -1
- package/dist/esm/sdk/market/zapper/IETHZapperContract.js +1 -1
- package/dist/esm/sdk/market/zapper/ZapperContract.js +1 -1
- package/dist/esm/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +1 -4
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/positions/MultichainPositionsService.js +6 -29
- package/dist/esm/sdk/positions/PositionsService.js +1 -2
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/types/model/filters.d.ts +9 -3
- package/dist/types/model/filters.schema.d.ts +7 -1
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/liquidations.d.ts +2 -6
- package/dist/types/model/liquidations.schema.d.ts +1 -1
- package/dist/types/model/opportunities.d.ts +3 -7
- package/dist/types/model/opportunities.schema.d.ts +2 -2
- package/dist/types/model/positions.d.ts +2 -6
- package/dist/types/model/positions.schema.d.ts +32 -2
- package/dist/types/model/response.d.ts +7 -6
- package/dist/types/model/response.schema.d.ts +41 -32
- package/dist/types/new-sdk/AbstractNamespace.d.ts +33 -98
- package/dist/types/new-sdk/GearboxSDK.d.ts +10 -25
- package/dist/types/new-sdk/errors/AllSourcesFailedError.d.ts +11 -0
- package/dist/types/new-sdk/errors/MissingSourceError.d.ts +23 -0
- package/dist/types/new-sdk/errors/NoSourceServedError.d.ts +17 -0
- package/dist/types/new-sdk/errors/SourceChainMismatchError.d.ts +35 -0
- package/dist/types/new-sdk/errors/SourceUnavailableError.d.ts +22 -0
- package/dist/types/new-sdk/errors/assertSameChains.d.ts +11 -0
- package/dist/types/new-sdk/errors/everyChainFailed.d.ts +10 -0
- package/dist/types/new-sdk/errors/index.d.ts +8 -0
- package/dist/types/new-sdk/index.d.ts +17 -6
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +20 -40
- package/dist/types/new-sdk/opportunities/index.d.ts +2 -2
- package/dist/types/new-sdk/opportunities/types.d.ts +72 -26
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +18 -38
- package/dist/types/new-sdk/positions/index.d.ts +2 -2
- package/dist/types/new-sdk/positions/types.d.ts +68 -24
- package/dist/types/new-sdk/types.d.ts +24 -77
- package/dist/types/new-sdk/utils/filterResponse.d.ts +19 -0
- package/dist/types/new-sdk/utils/history.d.ts +6 -36
- package/dist/types/new-sdk/utils/index.d.ts +5 -2
- package/dist/types/new-sdk/utils/mergeChains.d.ts +22 -0
- package/dist/types/new-sdk/utils/types.d.ts +43 -0
- package/dist/types/offchain/AbstractOffchainNamespace.d.ts +21 -28
- package/dist/types/offchain/GearboxAPI.d.ts +13 -9
- package/dist/types/offchain/errors/OffchainInvalidJsonError.d.ts +16 -0
- package/dist/types/offchain/errors/OffchainNotConfiguredError.d.ts +16 -0
- package/dist/types/offchain/errors/OffchainNotImplementedError.d.ts +15 -0
- package/dist/types/offchain/errors/OffchainRequestFailedError.d.ts +12 -0
- package/dist/types/offchain/errors/OffchainStatusError.d.ts +16 -0
- package/dist/types/offchain/errors/OffchainTransportError.d.ts +43 -0
- package/dist/types/offchain/errors/OffchainValidationError.d.ts +21 -0
- package/dist/types/offchain/errors/backendMessage.d.ts +9 -0
- package/dist/types/offchain/errors/errorCause.d.ts +22 -0
- package/dist/types/offchain/errors/index.d.ts +11 -0
- package/dist/types/offchain/errors/readResponseBody.d.ts +8 -0
- package/dist/types/offchain/index.d.ts +13 -2
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +9 -8
- package/dist/types/offchain/positions/OffchainPositions.d.ts +9 -15
- package/dist/types/offchain/types.d.ts +7 -88
- package/dist/types/sdk/accounts/index.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +15 -14
- package/dist/types/sdk/accounts/liquidations/index.d.ts +2 -2
- package/dist/types/sdk/accounts/liquidations/types.d.ts +9 -15
- package/dist/types/sdk/base/MultichainConstruct.d.ts +63 -14
- package/dist/types/sdk/base/index.d.ts +2 -2
- package/dist/types/sdk/chain/chains.d.ts +10 -2
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +5 -5
- package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +13 -16
- package/dist/types/sdk/positions/MultichainPositionsService.d.ts +2 -12
- package/dist/types/sdk/types/index.d.ts +2 -2
- package/dist/types/sdk/types/multichain.d.ts +8 -43
- 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 {
|
|
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.
|
|
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.
|
|
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.
|
|
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,
|
|
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
|
|
61
|
+
blockNumber: number;
|
|
61
62
|
/**
|
|
62
63
|
* Unix seconds of {@link blockNumber}.
|
|
63
64
|
**/
|
|
64
|
-
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
|
|
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.
|
|
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.
|
|
21
|
-
|
|
22
|
-
|
|
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`
|
|
28
|
-
* codec also validates a locally produced envelope
|
|
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.
|
|
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.
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
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.
|
|
59
|
-
|
|
60
|
-
|
|
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.
|
|
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.
|
|
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 {
|
|
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 {
|
|
7
|
-
import "
|
|
8
|
-
import
|
|
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
|
-
*
|
|
15
|
-
*
|
|
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
|
-
* @
|
|
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
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
*
|
|
25
|
-
*
|
|
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
|
-
* @
|
|
25
|
+
* @typeParam Onchain - On-chain source namespace, e.g.
|
|
26
|
+
* `MultichainOpportunitiesService`.
|
|
27
|
+
* @typeParam Offchain - Backend source namespace, e.g. `OffchainOpportunities`.
|
|
28
28
|
**/
|
|
29
|
-
|
|
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
|
-
*
|
|
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
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
*
|
|
102
|
-
*
|
|
38
|
+
* The on-chain source namespace on its own. Throws
|
|
39
|
+
* {@link SourceUnavailableError} in `offchain` mode.
|
|
103
40
|
**/
|
|
104
|
-
|
|
41
|
+
get onchain(): Onchain;
|
|
105
42
|
/**
|
|
106
|
-
*
|
|
107
|
-
*
|
|
43
|
+
* The backend source namespace on its own. Throws
|
|
44
|
+
* {@link SourceUnavailableError} in `onchain` mode.
|
|
108
45
|
**/
|
|
109
|
-
|
|
46
|
+
get offchain(): Offchain;
|
|
110
47
|
/**
|
|
111
|
-
*
|
|
112
|
-
*
|
|
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
|
|
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,
|
|
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
|
-
*
|
|
11
|
-
*
|
|
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 {
|
|
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
|
|
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
|
|
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 };
|