@gearbox-protocol/sdk 14.12.0-next.81 → 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.
- 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 +21 -0
- package/dist/cjs/new-sdk/utils/index.js +6 -0
- package/dist/cjs/new-sdk/utils/mergeChains.js +81 -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 +20 -0
- package/dist/esm/new-sdk/utils/index.js +3 -1
- package/dist/esm/new-sdk/utils/mergeChains.js +78 -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 +19 -40
- package/dist/types/new-sdk/opportunities/index.d.ts +2 -2
- package/dist/types/new-sdk/opportunities/types.d.ts +80 -26
- package/dist/types/new-sdk/positions/PositionsNamespace.d.ts +17 -38
- package/dist/types/new-sdk/positions/index.d.ts +2 -2
- package/dist/types/new-sdk/positions/types.d.ts +74 -24
- package/dist/types/new-sdk/types.d.ts +24 -77
- package/dist/types/new-sdk/utils/filterResponse.d.ts +16 -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 +20 -0
- package/dist/types/new-sdk/utils/types.d.ts +11 -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
|
@@ -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 };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AllSourcesFailedError } from "./AllSourcesFailedError.js";
|
|
2
|
+
import { MissingSourceError } from "./MissingSourceError.js";
|
|
3
|
+
import { NoSourceServedError } from "./NoSourceServedError.js";
|
|
4
|
+
import { ChainRef, SourceChainMismatchError } from "./SourceChainMismatchError.js";
|
|
5
|
+
import { SourceUnavailableError } from "./SourceUnavailableError.js";
|
|
6
|
+
import { assertSameChains } from "./assertSameChains.js";
|
|
7
|
+
import { everyChainFailed } from "./everyChainFailed.js";
|
|
8
|
+
export { AllSourcesFailedError, ChainRef, MissingSourceError, NoSourceServedError, SourceChainMismatchError, SourceUnavailableError, assertSameChains, everyChainFailed };
|
|
@@ -1,12 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { GearboxSDKOptions, Mode, NamespaceOptions, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, PlainMultichainSDKOptions } from "./types.js";
|
|
2
|
+
import { filterResponse } from "./utils/filterResponse.js";
|
|
3
|
+
import { HistoryReader } from "./utils/history.js";
|
|
4
|
+
import { DEFAULT_MAX_OFFCHAIN_LAG, mergeChainList, mergeChainOne } from "./utils/mergeChains.js";
|
|
5
|
+
import { SourceMerger } from "./utils/types.js";
|
|
4
6
|
import "./utils/index.js";
|
|
5
|
-
import {
|
|
7
|
+
import { AbstractNamespace, MergedQuery } from "./AbstractNamespace.js";
|
|
8
|
+
import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers } from "./opportunities/types.js";
|
|
6
9
|
import { OpportunitiesNamespace } from "./opportunities/OpportunitiesNamespace.js";
|
|
7
10
|
import "./opportunities/index.js";
|
|
8
|
-
import { Positions, PositionsBase, PositionsByMode, PositionsOffchainOnly, PositionsOnchainOnly } from "./positions/types.js";
|
|
11
|
+
import { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly } from "./positions/types.js";
|
|
9
12
|
import { PositionsNamespace } from "./positions/PositionsNamespace.js";
|
|
10
13
|
import "./positions/index.js";
|
|
11
14
|
import { GearboxSDK } from "./GearboxSDK.js";
|
|
12
|
-
|
|
15
|
+
import { AllSourcesFailedError } from "./errors/AllSourcesFailedError.js";
|
|
16
|
+
import { MissingSourceError } from "./errors/MissingSourceError.js";
|
|
17
|
+
import { NoSourceServedError } from "./errors/NoSourceServedError.js";
|
|
18
|
+
import { ChainRef, SourceChainMismatchError } from "./errors/SourceChainMismatchError.js";
|
|
19
|
+
import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
|
|
20
|
+
import { assertSameChains } from "./errors/assertSameChains.js";
|
|
21
|
+
import { everyChainFailed } from "./errors/everyChainFailed.js";
|
|
22
|
+
import "./errors/index.js";
|
|
23
|
+
export { AbstractNamespace, AllSourcesFailedError, ChainRef, DEFAULT_MAX_OFFCHAIN_LAG, GearboxSDK, GearboxSDKOptions, HistoryReader, MergedQuery, MissingSourceError, Mode, NamespaceOptions, NoSourceServedError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers, PlainMultichainSDKOptions, PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly, SourceChainMismatchError, type SourceMerger, SourceUnavailableError, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
|
|
@@ -1,69 +1,48 @@
|
|
|
1
|
-
import { ILogger } from "../../sdk/types/logger.js";
|
|
2
1
|
import { Opportunity, OpportunityFilter, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
|
|
3
2
|
import { PoolHistoryMetric, StrategyHistoryMetric } from "../../model/history.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import "../../model/index.js";
|
|
5
5
|
import { MultichainSDK } from "../../sdk/MultichainSDK.js";
|
|
6
6
|
import "../../sdk/index.js";
|
|
7
7
|
import { GearboxAPI } from "../../offchain/GearboxAPI.js";
|
|
8
8
|
import "../../offchain/index.js";
|
|
9
|
-
import {
|
|
10
|
-
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
9
|
+
import { NamespaceOptions } from "../types.js";
|
|
11
10
|
import { HistoryReader } from "../utils/history.js";
|
|
12
11
|
import "../utils/index.js";
|
|
13
|
-
import {
|
|
12
|
+
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
13
|
+
import { OpportunitiesBase, OpportunitiesOffchainOnly, OpportunityMergers } from "./types.js";
|
|
14
14
|
//#region src/new-sdk/opportunities/OpportunitiesNamespace.d.ts
|
|
15
15
|
/**
|
|
16
|
-
* The `opportunities` namespace of
|
|
17
|
-
*
|
|
18
|
-
* A stateless router over the two sources, see {@link AbstractNamespace} for
|
|
19
|
-
* the routing itself. What is specific to opportunities is the reads below and
|
|
20
|
-
* the merge policy at the bottom of the class.
|
|
21
|
-
*
|
|
22
|
-
* The class implements the methods of every mode; {@link GearboxSDK} exposes it
|
|
23
|
-
* as its mode's slice of {@link OpportunitiesByMode}, so calling a method the
|
|
24
|
-
* mode does not have is a compile error rather than a runtime one.
|
|
16
|
+
* The `opportunities` namespace of a {@link GearboxSDK}, see
|
|
17
|
+
* {@link OpportunitiesByMode} for what each mode offers.
|
|
25
18
|
**/
|
|
26
|
-
declare class OpportunitiesNamespace extends AbstractNamespace<
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
declare class OpportunitiesNamespace extends AbstractNamespace<MultichainSDK["opportunities"], GearboxAPI["opportunities"]> implements OpportunitiesBase, OpportunitiesOffchainOnly {
|
|
20
|
+
/**
|
|
21
|
+
* {@inheritDoc OpportunitiesBase.merge}
|
|
22
|
+
**/
|
|
23
|
+
readonly merge: OpportunityMergers;
|
|
24
|
+
constructor(onchain: MultichainSDK | undefined, offchain: GearboxAPI | undefined, options: NamespaceOptions);
|
|
29
25
|
/**
|
|
30
26
|
* {@inheritDoc OpportunitiesBase.list}
|
|
31
27
|
**/
|
|
32
|
-
list(filter?: OpportunityFilter): Promise<
|
|
28
|
+
list(filter?: OpportunityFilter): Promise<DataResponse<Opportunity[]>>;
|
|
33
29
|
/**
|
|
34
30
|
* {@inheritDoc OpportunitiesBase.getPool}
|
|
35
31
|
**/
|
|
36
|
-
getPool(key: PoolOpportunityKey): Promise<
|
|
32
|
+
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
37
33
|
/**
|
|
38
34
|
* {@inheritDoc OpportunitiesBase.getStrategy}
|
|
39
35
|
**/
|
|
40
|
-
getStrategy(key: StrategyOpportunityKey): Promise<
|
|
36
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
37
|
+
/**
|
|
38
|
+
* {@inheritDoc OpportunitiesBase.filter}
|
|
39
|
+
**/
|
|
40
|
+
filter(response: DataResponse<Opportunity[]> | undefined, filter?: OpportunityFilter): DataResponse<Opportunity[]> | undefined;
|
|
41
41
|
/**
|
|
42
42
|
* {@inheritDoc OpportunitiesOffchainOnly.history}
|
|
43
43
|
**/
|
|
44
44
|
history(key: PoolOpportunityRef): HistoryReader<PoolHistoryMetric>;
|
|
45
45
|
history(key: StrategyOpportunityRef): HistoryReader<StrategyHistoryMetric>;
|
|
46
|
-
/**
|
|
47
|
-
* Merges the two versions of one opportunity.
|
|
48
|
-
*
|
|
49
|
-
* The chain wins every field it fills; the backend fills the rest and owns
|
|
50
|
-
* {@link OFFCHAIN_OWNED_FIELDS}.
|
|
51
|
-
*
|
|
52
|
-
* The rule is onchain-first, field-wise, and never deeper than one level: a
|
|
53
|
-
* group like `totalSupply` or `supplyApy` is taken whole from one source, so
|
|
54
|
-
* a row never mixes an on-chain token amount with a backend dollar value
|
|
55
|
-
* derived from a different block.
|
|
56
|
-
**/
|
|
57
|
-
protected mergeOne<T extends object>(onchain: T, offchain: T): T;
|
|
58
|
-
/**
|
|
59
|
-
* Unions the two lists by canonical opportunity id.
|
|
60
|
-
*
|
|
61
|
-
* Rows present in both are merged by {@link OpportunitiesNamespace.mergeOne}.
|
|
62
|
-
* Rows only the backend knows are appended: a chain the SDK does not cover,
|
|
63
|
-
* or a market it has not loaded, is a reason to show more rather than fewer
|
|
64
|
-
* opportunities.
|
|
65
|
-
**/
|
|
66
|
-
protected mergeList(onchain: Opportunity[], offchain: Opportunity[]): Opportunity[];
|
|
67
46
|
}
|
|
68
47
|
//#endregion
|
|
69
48
|
export { OpportunitiesNamespace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesOffchainOnly, OpportunitiesOnchainOnly } from "./types.js";
|
|
1
|
+
import { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers } from "./types.js";
|
|
2
2
|
import { OpportunitiesNamespace } from "./OpportunitiesNamespace.js";
|
|
3
|
-
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesNamespace, OpportunitiesOffchainOnly, OpportunitiesOnchainOnly };
|
|
3
|
+
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesNamespace, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers };
|
|
@@ -1,28 +1,54 @@
|
|
|
1
1
|
import { Opportunity, OpportunityFilter, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef } from "../../model/opportunities.js";
|
|
2
2
|
import { PoolHistoryMetric, StrategyHistoryMetric } from "../../model/history.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { MultichainOpportunitiesService } from "../../sdk/opportunities/MultichainOpportunitiesService.js";
|
|
6
|
+
import "../../sdk/index.js";
|
|
7
|
+
import { OffchainOpportunities } from "../../offchain/opportunities/OffchainOpportunities.js";
|
|
8
|
+
import "../../offchain/index.js";
|
|
9
|
+
import { Mode } from "../types.js";
|
|
5
10
|
import { HistoryReader } from "../utils/history.js";
|
|
11
|
+
import { SourceMerger } from "../utils/types.js";
|
|
12
|
+
import "../utils/index.js";
|
|
6
13
|
//#region src/new-sdk/opportunities/types.d.ts
|
|
7
14
|
/**
|
|
8
|
-
*
|
|
15
|
+
* What the `opportunities` namespace offers in every mode.
|
|
9
16
|
**/
|
|
10
17
|
interface OpportunitiesBase {
|
|
11
18
|
/**
|
|
12
|
-
* All pool and strategy opportunities, optionally narrowed.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* merged field-wise, with the chain winning any field both sources fill.
|
|
19
|
+
* All pool and strategy opportunities, optionally narrowed. In `both` mode
|
|
20
|
+
* each chain is served by whichever source is fresh enough, see
|
|
21
|
+
* {@link OpportunityMergers}.
|
|
16
22
|
**/
|
|
17
|
-
list(filter?: OpportunityFilter): Promise<
|
|
23
|
+
list(filter?: OpportunityFilter): Promise<DataResponse<Opportunity[]>>;
|
|
18
24
|
/**
|
|
19
25
|
* Detailed view of one pool opportunity.
|
|
20
26
|
**/
|
|
21
|
-
getPool(key: PoolOpportunityKey): Promise<
|
|
27
|
+
getPool(key: PoolOpportunityKey): Promise<DataResponse<PoolOpportunityDetail>>;
|
|
22
28
|
/**
|
|
23
29
|
* Detailed view of one strategy opportunity.
|
|
24
30
|
**/
|
|
25
|
-
getStrategy(key: StrategyOpportunityKey): Promise<
|
|
31
|
+
getStrategy(key: StrategyOpportunityKey): Promise<DataResponse<StrategyOpportunityDetail>>;
|
|
32
|
+
/**
|
|
33
|
+
* Narrows an already-read list, rows and metadata alike. `undefined` passes
|
|
34
|
+
* through, so a read still in flight stays that way.
|
|
35
|
+
**/
|
|
36
|
+
filter(response: DataResponse<Opportunity[]> | undefined, filter?: OpportunityFilter): DataResponse<Opportunity[]> | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* The chain on its own, for a consumer that shows each source as it arrives.
|
|
39
|
+
* Throws in `offchain` mode.
|
|
40
|
+
**/
|
|
41
|
+
readonly onchain: MultichainOpportunitiesService;
|
|
42
|
+
/**
|
|
43
|
+
* The backend on its own, see {@link OpportunitiesBase.onchain}. Throws in
|
|
44
|
+
* `onchain` mode.
|
|
45
|
+
**/
|
|
46
|
+
readonly offchain: OffchainOpportunities;
|
|
47
|
+
/**
|
|
48
|
+
* Merge policy of each read, for a consumer combining the two branches
|
|
49
|
+
* itself, see {@link OpportunityMergers}.
|
|
50
|
+
**/
|
|
51
|
+
readonly merge: OpportunityMergers;
|
|
26
52
|
}
|
|
27
53
|
/**
|
|
28
54
|
* Reads only a backend can answer.
|
|
@@ -30,37 +56,65 @@ interface OpportunitiesBase {
|
|
|
30
56
|
interface OpportunitiesOffchainOnly {
|
|
31
57
|
/**
|
|
32
58
|
* Historical charts of one opportunity, one metric and one range at a time:
|
|
33
|
-
* `history(key).chart("depositApy", "1m")`.
|
|
34
|
-
*
|
|
35
|
-
* The key's kind decides which metrics exist, so asking a pool for a
|
|
36
|
-
* strategy series does not compile.
|
|
37
|
-
*
|
|
38
|
-
* Absent in `onchain` mode: the chain serves the present, and rebuilding a
|
|
39
|
-
* series from it would mean an archive read per point.
|
|
59
|
+
* `history(key).chart("depositApy", "1m")`. The key's kind decides which
|
|
60
|
+
* metrics exist, so asking a pool for a strategy series does not compile.
|
|
40
61
|
**/
|
|
41
62
|
history(key: PoolOpportunityRef): HistoryReader<PoolHistoryMetric>;
|
|
42
63
|
history(key: StrategyOpportunityRef): HistoryReader<StrategyHistoryMetric>;
|
|
43
64
|
}
|
|
44
65
|
/**
|
|
45
|
-
* Reads only the chain can answer. Empty for now
|
|
46
|
-
* namespace exposes has a backend counterpart.
|
|
66
|
+
* Reads only the chain can answer. Empty for now.
|
|
47
67
|
**/
|
|
48
68
|
interface OpportunitiesOnchainOnly {}
|
|
69
|
+
/**
|
|
70
|
+
* How each read combines what the two sources returned: a chain is served by
|
|
71
|
+
* the backend when it is fresh enough, and by the chain otherwise.
|
|
72
|
+
**/
|
|
73
|
+
interface OpportunityMergers {
|
|
74
|
+
list: SourceMerger<Opportunity[]>;
|
|
75
|
+
pool: SourceMerger<PoolOpportunityDetail>;
|
|
76
|
+
strategy: SourceMerger<StrategyOpportunityDetail>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Which reads the `opportunities` namespace has in each mode. A widened mode
|
|
80
|
+
* offers what every mode has, i.e. {@link OpportunitiesBase} alone.
|
|
81
|
+
**/
|
|
82
|
+
interface OpportunitiesOnchainBranch {
|
|
83
|
+
readonly onchain: MultichainOpportunitiesService;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The backend on its own, see {@link OpportunitiesOnchainBranch}.
|
|
87
|
+
**/
|
|
88
|
+
interface OpportunitiesOffchainBranch {
|
|
89
|
+
readonly offchain: OffchainOpportunities;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Merge policy of each read, exposed so that a consumer reading the two
|
|
93
|
+
* branches itself combines them exactly as `both` mode would: a chain is served
|
|
94
|
+
* by the backend when it is fresh enough, and by the chain otherwise.
|
|
95
|
+
**/
|
|
96
|
+
interface OpportunityMergers {
|
|
97
|
+
list: SourceMerger<Opportunity[]>;
|
|
98
|
+
pool: SourceMerger<PoolOpportunityDetail>;
|
|
99
|
+
strategy: SourceMerger<StrategyOpportunityDetail>;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Merging, which only exists where there are two sources to merge.
|
|
103
|
+
**/
|
|
104
|
+
interface OpportunitiesMerged {
|
|
105
|
+
readonly merge: OpportunityMergers;
|
|
106
|
+
}
|
|
49
107
|
/**
|
|
50
108
|
* Which methods the `opportunities` namespace has in each mode.
|
|
51
|
-
*
|
|
52
|
-
* A lookup map rather than a conditional type: `both` is spelled out instead of
|
|
53
|
-
* being inferred, and a widened mode degrades to the intersection of what all
|
|
54
|
-
* modes offer rather than silently distributing into a union of everything.
|
|
55
109
|
**/
|
|
56
110
|
interface OpportunitiesByMode {
|
|
57
|
-
onchain: OpportunitiesBase & OpportunitiesOnchainOnly;
|
|
58
|
-
offchain: OpportunitiesBase & OpportunitiesOffchainOnly;
|
|
59
|
-
both: OpportunitiesBase &
|
|
111
|
+
onchain: OpportunitiesBase & OpportunitiesOnchainOnly & OpportunitiesOnchainBranch;
|
|
112
|
+
offchain: OpportunitiesBase & OpportunitiesOffchainOnly & OpportunitiesOffchainBranch;
|
|
113
|
+
both: OpportunitiesBase & OpportunitiesOnchainOnly & OpportunitiesOffchainOnly;
|
|
60
114
|
}
|
|
61
115
|
/**
|
|
62
116
|
* The `opportunities` namespace of a {@link GearboxSDK} in mode `M`.
|
|
63
117
|
**/
|
|
64
118
|
type Opportunities<M extends Mode = Mode> = OpportunitiesByMode[M];
|
|
65
119
|
//#endregion
|
|
66
|
-
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesOffchainOnly, OpportunitiesOnchainOnly };
|
|
120
|
+
export { Opportunities, OpportunitiesBase, OpportunitiesByMode, OpportunitiesMerged, OpportunitiesOffchainBranch, OpportunitiesOffchainOnly, OpportunitiesOnchainBranch, OpportunitiesOnchainOnly, OpportunityMergers };
|
|
@@ -1,62 +1,41 @@
|
|
|
1
|
-
import { ILogger } from "../../sdk/types/logger.js";
|
|
2
1
|
import { PoolPositionRef, Position, PositionFilter, StrategyPositionRef } from "../../model/positions.js";
|
|
3
2
|
import { PoolPositionHistoryMetric, StrategyPositionHistoryMetric } from "../../model/history.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
4
4
|
import "../../model/index.js";
|
|
5
5
|
import { MultichainSDK } from "../../sdk/MultichainSDK.js";
|
|
6
6
|
import "../../sdk/index.js";
|
|
7
7
|
import { GearboxAPI } from "../../offchain/GearboxAPI.js";
|
|
8
8
|
import "../../offchain/index.js";
|
|
9
|
-
import {
|
|
10
|
-
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
9
|
+
import { NamespaceOptions } from "../types.js";
|
|
11
10
|
import { HistoryReader } from "../utils/history.js";
|
|
12
11
|
import "../utils/index.js";
|
|
13
|
-
import {
|
|
12
|
+
import { AbstractNamespace } from "../AbstractNamespace.js";
|
|
13
|
+
import { PositionMergers, PositionsBase, PositionsOffchainOnly } from "./types.js";
|
|
14
14
|
import { Address } from "viem";
|
|
15
15
|
//#region src/new-sdk/positions/PositionsNamespace.d.ts
|
|
16
16
|
/**
|
|
17
|
-
* The `positions` namespace of
|
|
18
|
-
*
|
|
19
|
-
* A stateless router over the two sources, see {@link AbstractNamespace} for the
|
|
20
|
-
* routing itself. What is specific to positions is the reads below and the merge
|
|
21
|
-
* policy at the bottom of the class.
|
|
22
|
-
*
|
|
23
|
-
* The class implements the methods of every mode; {@link GearboxSDK} exposes it
|
|
24
|
-
* as its mode's slice of {@link PositionsByMode}, so calling a method the mode
|
|
25
|
-
* does not have is a compile error rather than a runtime one.
|
|
17
|
+
* The `positions` namespace of a {@link GearboxSDK}, see
|
|
18
|
+
* {@link PositionsByMode} for what each mode offers.
|
|
26
19
|
**/
|
|
27
|
-
declare class PositionsNamespace extends AbstractNamespace<
|
|
28
|
-
#private;
|
|
29
|
-
constructor(onchain: MultichainSDK | undefined, offchain: GearboxAPI | undefined, logger?: ILogger);
|
|
20
|
+
declare class PositionsNamespace extends AbstractNamespace<MultichainSDK["positions"], GearboxAPI["positions"]> implements PositionsBase, PositionsOffchainOnly {
|
|
30
21
|
/**
|
|
31
|
-
* {@inheritDoc PositionsBase.
|
|
22
|
+
* {@inheritDoc PositionsBase.merge}
|
|
32
23
|
**/
|
|
33
|
-
|
|
24
|
+
readonly merge: PositionMergers;
|
|
25
|
+
constructor(onchain: MultichainSDK | undefined, offchain: GearboxAPI | undefined, options: NamespaceOptions);
|
|
34
26
|
/**
|
|
35
|
-
* {@inheritDoc
|
|
27
|
+
* {@inheritDoc PositionsBase.list}
|
|
36
28
|
**/
|
|
37
|
-
|
|
38
|
-
history(key: StrategyPositionRef): HistoryReader<StrategyPositionHistoryMetric>;
|
|
29
|
+
list(wallet: Address, filter?: PositionFilter): Promise<DataResponse<Position[]>>;
|
|
39
30
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* The chain wins every field it fills; the backend fills the rest and owns
|
|
43
|
-
* {@link OFFCHAIN_OWNED_FIELDS}.
|
|
44
|
-
*
|
|
45
|
-
* The rule is onchain-first, field-wise, and never deeper than one level: a
|
|
46
|
-
* group like `totalValue` or `apy` is taken whole from one source, so a row
|
|
47
|
-
* never mixes an on-chain token amount with a backend dollar value derived
|
|
48
|
-
* from a different block.
|
|
31
|
+
* {@inheritDoc PositionsBase.filter}
|
|
49
32
|
**/
|
|
50
|
-
|
|
33
|
+
filter(response: DataResponse<Position[]> | undefined, filter?: PositionFilter): DataResponse<Position[]> | undefined;
|
|
51
34
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* Rows present in both are merged by {@link PositionsNamespace.mergeOne}.
|
|
55
|
-
* Rows only the backend knows are appended: a chain the SDK does not cover,
|
|
56
|
-
* or a market it has not loaded, must not hide a position the wallet actually
|
|
57
|
-
* holds.
|
|
35
|
+
* {@inheritDoc PositionsOffchainOnly.history}
|
|
58
36
|
**/
|
|
59
|
-
|
|
37
|
+
history(key: PoolPositionRef): HistoryReader<PoolPositionHistoryMetric>;
|
|
38
|
+
history(key: StrategyPositionRef): HistoryReader<StrategyPositionHistoryMetric>;
|
|
60
39
|
}
|
|
61
40
|
//#endregion
|
|
62
41
|
export { PositionsNamespace };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { Positions, PositionsBase, PositionsByMode, PositionsOffchainOnly, PositionsOnchainOnly } from "./types.js";
|
|
1
|
+
import { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly } from "./types.js";
|
|
2
2
|
import { PositionsNamespace } from "./PositionsNamespace.js";
|
|
3
|
-
export { Positions, PositionsBase, PositionsByMode, PositionsNamespace, PositionsOffchainOnly, PositionsOnchainOnly };
|
|
3
|
+
export { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsNamespace, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly };
|
|
@@ -1,22 +1,48 @@
|
|
|
1
1
|
import { PoolPositionRef, Position, PositionFilter, StrategyPositionRef } from "../../model/positions.js";
|
|
2
2
|
import { PoolPositionHistoryMetric, StrategyPositionHistoryMetric } from "../../model/history.js";
|
|
3
|
+
import { DataResponse } from "../../model/response.js";
|
|
3
4
|
import "../../model/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { MultichainPositionsService } from "../../sdk/positions/MultichainPositionsService.js";
|
|
6
|
+
import "../../sdk/index.js";
|
|
7
|
+
import { OffchainPositions } from "../../offchain/positions/OffchainPositions.js";
|
|
8
|
+
import "../../offchain/index.js";
|
|
9
|
+
import { Mode } from "../types.js";
|
|
5
10
|
import { HistoryReader } from "../utils/history.js";
|
|
11
|
+
import { SourceMerger } from "../utils/types.js";
|
|
12
|
+
import "../utils/index.js";
|
|
6
13
|
import { Address } from "viem";
|
|
7
14
|
//#region src/new-sdk/positions/types.d.ts
|
|
8
15
|
/**
|
|
9
|
-
*
|
|
16
|
+
* What the `positions` namespace offers in every mode.
|
|
10
17
|
**/
|
|
11
18
|
interface PositionsBase {
|
|
12
19
|
/**
|
|
13
20
|
* Everything a wallet holds: its pool shares, its credit accounts and the
|
|
14
|
-
* delayed withdrawals it took over by liquidating, optionally narrowed.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* merged field-wise, with the chain winning any field both sources fill.
|
|
21
|
+
* delayed withdrawals it took over by liquidating, optionally narrowed. In
|
|
22
|
+
* `both` mode each chain is served by whichever source is fresh enough, see
|
|
23
|
+
* {@link PositionMergers}.
|
|
18
24
|
**/
|
|
19
|
-
list(wallet: Address, filter?: PositionFilter): Promise<
|
|
25
|
+
list(wallet: Address, filter?: PositionFilter): Promise<DataResponse<Position[]>>;
|
|
26
|
+
/**
|
|
27
|
+
* Narrows an already-read list, rows and metadata alike. `undefined` passes
|
|
28
|
+
* through, so a read still in flight stays that way.
|
|
29
|
+
**/
|
|
30
|
+
filter(response: DataResponse<Position[]> | undefined, filter?: PositionFilter): DataResponse<Position[]> | undefined;
|
|
31
|
+
/**
|
|
32
|
+
* The chain on its own, for a consumer that shows each source as it arrives.
|
|
33
|
+
* Throws in `offchain` mode.
|
|
34
|
+
**/
|
|
35
|
+
readonly onchain: MultichainPositionsService;
|
|
36
|
+
/**
|
|
37
|
+
* The backend on its own, see {@link PositionsBase.onchain}. Throws in
|
|
38
|
+
* `onchain` mode.
|
|
39
|
+
**/
|
|
40
|
+
readonly offchain: OffchainPositions;
|
|
41
|
+
/**
|
|
42
|
+
* Merge policy of each read, for a consumer combining the two branches
|
|
43
|
+
* itself, see {@link PositionMergers}.
|
|
44
|
+
**/
|
|
45
|
+
readonly merge: PositionMergers;
|
|
20
46
|
}
|
|
21
47
|
/**
|
|
22
48
|
* Reads only a backend can answer.
|
|
@@ -24,39 +50,63 @@ interface PositionsBase {
|
|
|
24
50
|
interface PositionsOffchainOnly {
|
|
25
51
|
/**
|
|
26
52
|
* Historical charts of one position, one metric and one range at a time:
|
|
27
|
-
* `history(key).chart("netApy", "1m")`.
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
* all: a delayed withdrawal is a single event rather than a series, which is
|
|
32
|
-
* why no key names one.
|
|
33
|
-
*
|
|
34
|
-
* Absent in `onchain` mode: the chain serves the present, and rebuilding a
|
|
35
|
-
* series from it would mean an archive read per point.
|
|
53
|
+
* `history(key).chart("netApy", "1m")`. The key's kind decides which metrics
|
|
54
|
+
* exist, so asking a pool position for a strategy series does not compile.
|
|
55
|
+
* Liquidation positions have no charts: a delayed withdrawal is a single
|
|
56
|
+
* event rather than a series.
|
|
36
57
|
**/
|
|
37
58
|
history(key: PoolPositionRef): HistoryReader<PoolPositionHistoryMetric>;
|
|
38
59
|
history(key: StrategyPositionRef): HistoryReader<StrategyPositionHistoryMetric>;
|
|
39
60
|
}
|
|
40
61
|
/**
|
|
41
|
-
* Reads only the chain can answer. Empty for now
|
|
42
|
-
* namespace exposes has a backend counterpart.
|
|
62
|
+
* Reads only the chain can answer. Empty for now.
|
|
43
63
|
**/
|
|
44
64
|
interface PositionsOnchainOnly {}
|
|
65
|
+
/**
|
|
66
|
+
* How each read combines what the two sources returned: a chain is served by
|
|
67
|
+
* the backend when it is fresh enough, and by the chain otherwise.
|
|
68
|
+
**/
|
|
69
|
+
interface PositionMergers {
|
|
70
|
+
list: SourceMerger<Position[]>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Which reads the `positions` namespace has in each mode. A widened mode offers
|
|
74
|
+
* what every mode has, i.e. {@link PositionsBase} alone.
|
|
75
|
+
**/
|
|
76
|
+
interface PositionsOnchainBranch {
|
|
77
|
+
readonly onchain: MultichainPositionsService;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The backend on its own, see {@link PositionsOnchainBranch}.
|
|
81
|
+
**/
|
|
82
|
+
interface PositionsOffchainBranch {
|
|
83
|
+
readonly offchain: OffchainPositions;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Merge policy of each read, exposed so that a consumer reading the two
|
|
87
|
+
* branches itself combines them exactly as `both` mode would: a chain is served
|
|
88
|
+
* by the backend when it is fresh enough, and by the chain otherwise.
|
|
89
|
+
**/
|
|
90
|
+
interface PositionMergers {
|
|
91
|
+
list: SourceMerger<Position[]>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Merging, which only exists where there are two sources to merge.
|
|
95
|
+
**/
|
|
96
|
+
interface PositionsMerged {
|
|
97
|
+
readonly merge: PositionMergers;
|
|
98
|
+
}
|
|
45
99
|
/**
|
|
46
100
|
* Which methods the `positions` namespace has in each mode.
|
|
47
|
-
*
|
|
48
|
-
* A lookup map rather than a conditional type: `both` is spelled out instead of
|
|
49
|
-
* being inferred, and a widened mode degrades to the intersection of what all
|
|
50
|
-
* modes offer rather than silently distributing into a union of everything.
|
|
51
101
|
**/
|
|
52
102
|
interface PositionsByMode {
|
|
53
103
|
onchain: PositionsBase & PositionsOnchainOnly;
|
|
54
104
|
offchain: PositionsBase & PositionsOffchainOnly;
|
|
55
|
-
both: PositionsBase &
|
|
105
|
+
both: PositionsBase & PositionsOnchainOnly & PositionsOffchainOnly;
|
|
56
106
|
}
|
|
57
107
|
/**
|
|
58
108
|
* The `positions` namespace of a {@link GearboxSDK} in mode `M`.
|
|
59
109
|
**/
|
|
60
110
|
type Positions<M extends Mode = Mode> = PositionsByMode[M];
|
|
61
111
|
//#endregion
|
|
62
|
-
export { Positions, PositionsBase, PositionsByMode, PositionsOffchainOnly, PositionsOnchainOnly };
|
|
112
|
+
export { PositionMergers, Positions, PositionsBase, PositionsByMode, PositionsMerged, PositionsOffchainBranch, PositionsOffchainOnly, PositionsOnchainBranch, PositionsOnchainOnly };
|