@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,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_chain_chains = require("./chain/chains.js");
|
|
3
|
-
const require_sdk_core_errors = require("./core/errors.js");
|
|
4
3
|
const require_sdk_market_pricefeeds_updates_PriceUpdatesCache = require("./market/pricefeeds/updates/PriceUpdatesCache.js");
|
|
5
4
|
require("./market/pricefeeds/updates/index.js");
|
|
6
5
|
const require_sdk_accounts_liquidations_MultichainLiquidationsService = require("./accounts/liquidations/MultichainLiquidationsService.js");
|
|
7
6
|
require("./accounts/index.js");
|
|
7
|
+
const require_sdk_core_errors = require("./core/errors.js");
|
|
8
8
|
require("./core/index.js");
|
|
9
9
|
const require_sdk_opportunities_MultichainOpportunitiesService = require("./opportunities/MultichainOpportunitiesService.js");
|
|
10
10
|
require("./opportunities/index.js");
|
|
@@ -9,7 +9,6 @@ const require_sdk_utils_formatter = require("./utils/formatter.js");
|
|
|
9
9
|
const require_sdk_utils_toAddress = require("./utils/toAddress.js");
|
|
10
10
|
require("./utils/index.js");
|
|
11
11
|
const require_sdk_base_ChainContractsRegister = require("./base/ChainContractsRegister.js");
|
|
12
|
-
const require_sdk_core_errors = require("./core/errors.js");
|
|
13
12
|
require("./base/index.js");
|
|
14
13
|
const require_sdk_utils_viem_executeDelegatedMulticalls = require("./utils/viem/executeDelegatedMulticalls.js");
|
|
15
14
|
require("./utils/viem/index.js");
|
|
@@ -24,6 +23,7 @@ const require_sdk_accounts_withdrawal_compressor_createRedemptionLogger = requir
|
|
|
24
23
|
const require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor = require("./accounts/withdrawal-compressor/createWithdrawalCompressor.js");
|
|
25
24
|
require("./accounts/index.js");
|
|
26
25
|
const require_sdk_core_createAddressProvider = require("./core/createAddressProvider.js");
|
|
26
|
+
const require_sdk_core_errors = require("./core/errors.js");
|
|
27
27
|
require("./core/index.js");
|
|
28
28
|
const require_sdk_opportunities_OpportunitiesService = require("./opportunities/OpportunitiesService.js");
|
|
29
29
|
require("./opportunities/index.js");
|
|
@@ -3,13 +3,8 @@ const require_sdk_base_MultichainConstruct = require("../../base/MultichainConst
|
|
|
3
3
|
require("../../base/index.js");
|
|
4
4
|
//#region src/sdk/accounts/liquidations/MultichainLiquidationsService.ts
|
|
5
5
|
/**
|
|
6
|
-
* Cross-chain counterpart of {@link LiquidationsService}.
|
|
7
|
-
*
|
|
8
|
-
* Fans out over all chains configured in {@link MultichainSDK} (optionally
|
|
9
|
-
* restricted via {@link MultichainNetworksProps.networks}). A failed chain is
|
|
10
|
-
* logged as a warning and skipped, so one dead RPC does not empty the whole
|
|
11
|
-
* list; its failure is reported in {@link MultichainResult.meta}. Networks that
|
|
12
|
-
* are not configured in the SDK are reported there the same way.
|
|
6
|
+
* Cross-chain counterpart of {@link LiquidationsService}. These reads are live,
|
|
7
|
+
* so each chain is pinned to its own freshly fetched head.
|
|
13
8
|
**/
|
|
14
9
|
var MultichainLiquidationsService = class extends require_sdk_base_MultichainConstruct.MultichainConstruct {
|
|
15
10
|
/**
|
|
@@ -18,22 +13,44 @@ var MultichainLiquidationsService = class extends require_sdk_base_MultichainCon
|
|
|
18
13
|
**/
|
|
19
14
|
async getLiquidatableAccounts(props) {
|
|
20
15
|
return this.queryChains({
|
|
21
|
-
|
|
16
|
+
chainIds: props?.chainIds,
|
|
22
17
|
label: "get liquidatable accounts",
|
|
23
|
-
|
|
18
|
+
block: "latest",
|
|
19
|
+
run: (sdk, block) => sdk.liquidations.getLiquidatableAccounts({
|
|
20
|
+
...props,
|
|
21
|
+
blockNumber: block.blockNumber
|
|
22
|
+
})
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
27
26
|
* {@inheritDoc LiquidationsService.getLiquidationDetails}
|
|
27
|
+
*
|
|
28
|
+
* Throws when the chain cannot answer.
|
|
28
29
|
**/
|
|
29
30
|
async getLiquidationDetails(props) {
|
|
30
|
-
return this.
|
|
31
|
+
return this.queryChain({
|
|
32
|
+
network: props.network,
|
|
33
|
+
block: props.blockNumber ?? "latest",
|
|
34
|
+
run: (sdk, block) => sdk.liquidations.getLiquidationDetails({
|
|
35
|
+
...props,
|
|
36
|
+
blockNumber: block.blockNumber
|
|
37
|
+
})
|
|
38
|
+
});
|
|
31
39
|
}
|
|
32
40
|
/**
|
|
33
41
|
* {@inheritDoc LiquidationsService.buildLiquidationTx}
|
|
42
|
+
*
|
|
43
|
+
* The reported block is the one the transaction was built against.
|
|
34
44
|
**/
|
|
35
45
|
async buildLiquidationTx(props) {
|
|
36
|
-
return this.
|
|
46
|
+
return this.queryChain({
|
|
47
|
+
network: props.network,
|
|
48
|
+
block: props.blockNumber ?? "latest",
|
|
49
|
+
run: (sdk, block) => sdk.liquidations.buildLiquidationTx({
|
|
50
|
+
...props,
|
|
51
|
+
blockNumber: block.blockNumber
|
|
52
|
+
})
|
|
53
|
+
});
|
|
37
54
|
}
|
|
38
55
|
/**
|
|
39
56
|
* Liquidation positions of all queried chains, see
|
|
@@ -41,18 +58,25 @@ var MultichainLiquidationsService = class extends require_sdk_base_MultichainCon
|
|
|
41
58
|
**/
|
|
42
59
|
async getLiquidationPositions(props) {
|
|
43
60
|
return this.queryChains({
|
|
44
|
-
|
|
61
|
+
chainIds: props.chainIds,
|
|
45
62
|
label: "get liquidation positions",
|
|
46
|
-
|
|
63
|
+
block: "latest",
|
|
64
|
+
run: (sdk, block) => sdk.liquidations.getLiquidationPositions({
|
|
65
|
+
...props,
|
|
66
|
+
blockNumber: block.blockNumber
|
|
67
|
+
})
|
|
47
68
|
});
|
|
48
69
|
}
|
|
49
70
|
/**
|
|
50
71
|
* Loads the liquidators of all queried chains, see
|
|
51
72
|
* {@link LiquidationsService.loadRWALiquidators}.
|
|
73
|
+
*
|
|
74
|
+
* Nothing consumes the block of a cache warm-up, so this one is left on the
|
|
75
|
+
* loaded snapshot.
|
|
52
76
|
**/
|
|
53
77
|
async loadRWALiquidators(props) {
|
|
54
78
|
return this.runChains({
|
|
55
|
-
|
|
79
|
+
chainIds: props?.chainIds,
|
|
56
80
|
label: "load RWA liquidators",
|
|
57
81
|
run: (sdk) => sdk.liquidations.loadRWALiquidators()
|
|
58
82
|
});
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_core_errors = require("../core/errors.js");
|
|
3
2
|
//#region src/sdk/base/MultichainConstruct.ts
|
|
4
3
|
/**
|
|
5
4
|
* @internal
|
|
6
5
|
* Base class for services that fan out over the chains of a
|
|
7
6
|
* {@link MultichainSDK}, the cross-chain counterpart of {@link SDKConstruct}.
|
|
8
7
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* reported in {@link MultichainResult.meta}.
|
|
8
|
+
* A fan-out soft-fails: a chain that rejects is logged as a warning and
|
|
9
|
+
* contributes no payload, while the remaining chains still return their rows.
|
|
10
|
+
* A single-chain request throws instead.
|
|
13
11
|
*
|
|
14
12
|
* @typeParam Plugins - Map of attached plugin types.
|
|
15
13
|
**/
|
|
@@ -23,58 +21,99 @@ var MultichainConstruct = class {
|
|
|
23
21
|
* chains that responded successfully.
|
|
24
22
|
**/
|
|
25
23
|
async queryChains(props) {
|
|
26
|
-
const { values,
|
|
24
|
+
const { values, chains } = await this.#settle(props);
|
|
27
25
|
return {
|
|
28
|
-
|
|
29
|
-
meta
|
|
26
|
+
data: values.flat(),
|
|
27
|
+
meta: { chains }
|
|
30
28
|
};
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
31
|
* Fans out a request with no payload, reporting the outcome of every queried
|
|
34
|
-
* chain in
|
|
32
|
+
* chain in `meta.chains`.
|
|
35
33
|
**/
|
|
36
34
|
async runChains(props) {
|
|
37
|
-
const {
|
|
35
|
+
const { chains } = await this.#settle(props);
|
|
38
36
|
return {
|
|
39
|
-
|
|
40
|
-
meta
|
|
37
|
+
data: void 0,
|
|
38
|
+
meta: { chains }
|
|
41
39
|
};
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
|
-
* Runs
|
|
45
|
-
*
|
|
42
|
+
* Runs a request against one chain and reports the block it was read at.
|
|
43
|
+
* Throws when the chain is not configured, not attached, or rejects the read.
|
|
46
44
|
**/
|
|
47
|
-
async
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
45
|
+
async queryChain({ network, block = "state", run }) {
|
|
46
|
+
const sdk = this.sdk.chain(network);
|
|
47
|
+
const at = await this.#resolveBlock(sdk, block);
|
|
48
|
+
return {
|
|
49
|
+
data: await run(sdk, at),
|
|
50
|
+
meta: { chains: [succeeded(sdk.chainId, at)] }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Runs the request on every queried chain in parallel.
|
|
55
|
+
**/
|
|
56
|
+
async #settle({ chainIds, label, block = "state", run }) {
|
|
57
|
+
const wanted = chainIds && new Set(chainIds);
|
|
58
|
+
const requested = [];
|
|
59
|
+
for (const [network, sdk] of this.sdk.chains) if (!wanted || wanted.has(sdk.chainId)) requested.push([network, sdk]);
|
|
60
|
+
const settled = await Promise.allSettled(requested.map(async ([, sdk]) => {
|
|
61
|
+
const at = await this.#resolveBlock(sdk, block);
|
|
62
|
+
return {
|
|
63
|
+
data: await run(sdk, at),
|
|
64
|
+
at
|
|
65
|
+
};
|
|
53
66
|
}));
|
|
54
67
|
const values = [];
|
|
55
|
-
const
|
|
56
|
-
settled.
|
|
57
|
-
const network = requested[i];
|
|
68
|
+
const chains = [];
|
|
69
|
+
for (let i = 0; i < settled.length; i++) {
|
|
70
|
+
const [network, sdk] = requested[i];
|
|
71
|
+
const result = settled[i];
|
|
58
72
|
if (result.status === "fulfilled") {
|
|
59
|
-
values.push(result.value);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
status: "success"
|
|
63
|
-
});
|
|
64
|
-
return;
|
|
73
|
+
values.push(result.value.data);
|
|
74
|
+
chains.push(succeeded(sdk.chainId, result.value.at));
|
|
75
|
+
continue;
|
|
65
76
|
}
|
|
66
|
-
(
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
(sdk.logger ?? this.sdk.logger)?.warn(result.reason, `failed to ${label} on ${network}`);
|
|
78
|
+
chains.push({
|
|
79
|
+
chainId: sdk.chainId,
|
|
69
80
|
status: "error",
|
|
81
|
+
source: "onchain",
|
|
70
82
|
error: result.reason
|
|
71
83
|
});
|
|
72
|
-
}
|
|
84
|
+
}
|
|
73
85
|
return {
|
|
74
86
|
values,
|
|
75
|
-
|
|
87
|
+
chains
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Block a chain's read is pinned to and reported at.
|
|
92
|
+
**/
|
|
93
|
+
async #resolveBlock(sdk, source) {
|
|
94
|
+
if (source === "state") return {
|
|
95
|
+
blockNumber: sdk.currentBlock,
|
|
96
|
+
timestamp: sdk.timestamp
|
|
97
|
+
};
|
|
98
|
+
if (typeof source === "bigint") return {
|
|
99
|
+
blockNumber: source,
|
|
100
|
+
timestamp: (await sdk.client.getBlock({ blockNumber: source })).timestamp
|
|
101
|
+
};
|
|
102
|
+
const block = await sdk.client.getBlock({ blockTag: "latest" });
|
|
103
|
+
return {
|
|
104
|
+
blockNumber: block.number,
|
|
105
|
+
timestamp: block.timestamp
|
|
76
106
|
};
|
|
77
107
|
}
|
|
78
108
|
};
|
|
109
|
+
function succeeded(chainId, at) {
|
|
110
|
+
return {
|
|
111
|
+
chainId,
|
|
112
|
+
status: "success",
|
|
113
|
+
source: "onchain",
|
|
114
|
+
blockNumber: Number(at.blockNumber),
|
|
115
|
+
timestamp: Number(at.timestamp)
|
|
116
|
+
};
|
|
117
|
+
}
|
|
79
118
|
//#endregion
|
|
80
119
|
exports.MultichainConstruct = MultichainConstruct;
|
|
@@ -355,6 +355,16 @@ function getNetworkType(chainId) {
|
|
|
355
355
|
return network;
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
358
|
+
* Chain IDs of chains named as {@link NetworkType} labels or as IDs already,
|
|
359
|
+
* e.g. `sdk.opportunities.list({ chainIds: toChainIds(["Mainnet"]) })`.
|
|
360
|
+
*
|
|
361
|
+
* @param scope - Chains as labels, or already as IDs.
|
|
362
|
+
* @throws If any entry is not a supported network.
|
|
363
|
+
**/
|
|
364
|
+
function toChainIds(scope) {
|
|
365
|
+
return scope.map((entry) => getChain(entry).id);
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
358
368
|
* Type guard that checks whether a chain ID belongs to a supported Gearbox network.
|
|
359
369
|
*
|
|
360
370
|
* @param chainId - Numeric chain ID, or `undefined`.
|
|
@@ -465,3 +475,4 @@ exports.isRWAToken = isRWAToken;
|
|
|
465
475
|
exports.isSunsetPool = isSunsetPool;
|
|
466
476
|
exports.isSunsetStrategy = isSunsetStrategy;
|
|
467
477
|
exports.isSupportedNetwork = isSupportedNetwork;
|
|
478
|
+
exports.toChainIds = toChainIds;
|
|
@@ -15,3 +15,4 @@ exports.isRWAToken = require_sdk_chain_chains.isRWAToken;
|
|
|
15
15
|
exports.isSunsetPool = require_sdk_chain_chains.isSunsetPool;
|
|
16
16
|
exports.isSunsetStrategy = require_sdk_chain_chains.isSunsetStrategy;
|
|
17
17
|
exports.isSupportedNetwork = require_sdk_chain_chains.isSupportedNetwork;
|
|
18
|
+
exports.toChainIds = require_sdk_chain_chains.toChainIds;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_core_errors = require("./errors.js");
|
|
3
2
|
const require_sdk_core_AddressProviderV310Contract = require("./AddressProviderV310Contract.js");
|
|
4
3
|
const require_sdk_core_createAddressProvider = require("./createAddressProvider.js");
|
|
4
|
+
const require_sdk_core_errors = require("./errors.js");
|
|
5
5
|
require("./types.js");
|
|
6
6
|
exports.AddressProviderV310Contract = require_sdk_core_AddressProviderV310Contract.AddressProviderV310Contract;
|
|
7
7
|
exports.ChainNotConfiguredError = require_sdk_core_errors.ChainNotConfiguredError;
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -36,7 +36,6 @@ const require_sdk_base_ChainContractsRegister = require("./base/ChainContractsRe
|
|
|
36
36
|
const require_sdk_base_Construct = require("./base/Construct.js");
|
|
37
37
|
const require_sdk_base_BaseContract = require("./base/BaseContract.js");
|
|
38
38
|
const require_sdk_base_errors = require("./base/errors.js");
|
|
39
|
-
const require_sdk_core_errors = require("./core/errors.js");
|
|
40
39
|
const require_sdk_base_MultichainConstruct = require("./base/MultichainConstruct.js");
|
|
41
40
|
const require_sdk_base_PlaceholderContract = require("./base/PlaceholderContract.js");
|
|
42
41
|
const require_sdk_base_SDKConstruct = require("./base/SDKConstruct.js");
|
|
@@ -129,6 +128,7 @@ const require_sdk_accounts_withdrawal_compressor_createWithdrawalCompressor = re
|
|
|
129
128
|
require("./accounts/index.js");
|
|
130
129
|
const require_sdk_core_AddressProviderV310Contract = require("./core/AddressProviderV310Contract.js");
|
|
131
130
|
const require_sdk_core_createAddressProvider = require("./core/createAddressProvider.js");
|
|
131
|
+
const require_sdk_core_errors = require("./core/errors.js");
|
|
132
132
|
require("./core/index.js");
|
|
133
133
|
const require_sdk_opportunities_MultichainOpportunitiesService = require("./opportunities/MultichainOpportunitiesService.js");
|
|
134
134
|
const require_sdk_opportunities_OpportunitiesService = require("./opportunities/OpportunitiesService.js");
|
|
@@ -415,6 +415,7 @@ exports.simulateWithPriceUpdates = require_sdk_utils_viem_simulateWithPriceUpdat
|
|
|
415
415
|
exports.toAddress = require_sdk_utils_toAddress.toAddress;
|
|
416
416
|
exports.toBN = require_sdk_utils_formatter.toBN;
|
|
417
417
|
exports.toBigInt = require_sdk_utils_formatter.toBigInt;
|
|
418
|
+
exports.toChainIds = require_sdk_chain_chains.toChainIds;
|
|
418
419
|
exports.toClaimableWithdrawal = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.toClaimableWithdrawal;
|
|
419
420
|
exports.toPendingWithdrawal = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.toPendingWithdrawal;
|
|
420
421
|
exports.toRequestableWithdrawal = require_sdk_accounts_withdrawal_compressor_AbstractWithdrawalCompressorContract.toRequestableWithdrawal;
|
|
@@ -1,62 +1,48 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_chain_chains = require("../chain/chains.js");
|
|
3
2
|
const require_sdk_base_MultichainConstruct = require("../base/MultichainConstruct.js");
|
|
4
3
|
require("../base/index.js");
|
|
5
|
-
const require_model_filters = require("../../model/filters.js");
|
|
6
|
-
require("../../model/index.js");
|
|
7
4
|
//#region src/sdk/opportunities/MultichainOpportunitiesService.ts
|
|
8
5
|
/**
|
|
9
|
-
* Cross-chain counterpart of {@link OpportunitiesService}.
|
|
10
|
-
*
|
|
11
|
-
* Fans out over every chain configured in {@link MultichainSDK}. A chain that
|
|
12
|
-
* fails is logged and skipped so one dead RPC does not empty the list; its
|
|
13
|
-
* failure is reported in {@link MultichainResult.meta}.
|
|
14
|
-
*
|
|
15
|
-
* Detail reads need no fan-out: an opportunity key names its chain.
|
|
6
|
+
* Cross-chain counterpart of {@link OpportunitiesService}. Every read walks
|
|
7
|
+
* loaded market state, so the block it reports is the SDK's snapshot.
|
|
16
8
|
*
|
|
17
9
|
* @typeParam Plugins - Map of attached plugin types.
|
|
18
10
|
**/
|
|
19
11
|
var MultichainOpportunitiesService = class extends require_sdk_base_MultichainConstruct.MultichainConstruct {
|
|
20
12
|
/**
|
|
21
13
|
* Opportunities of all queried chains, see {@link OpportunitiesService.list}.
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* would be discarded are never queried and never appear in the meta.
|
|
14
|
+
* A filter that names chains narrows the fan-out itself, so a chain whose
|
|
15
|
+
* rows would be discarded is never queried and never appears in the meta.
|
|
25
16
|
**/
|
|
26
17
|
async list(filter) {
|
|
27
18
|
return this.queryChains({
|
|
28
|
-
|
|
19
|
+
chainIds: filter?.chainIds,
|
|
29
20
|
label: "list opportunities",
|
|
30
21
|
run: (sdk) => sdk.opportunities.list(filter)
|
|
31
22
|
});
|
|
32
23
|
}
|
|
33
24
|
/**
|
|
34
25
|
* {@inheritDoc OpportunitiesService.getPool}
|
|
26
|
+
*
|
|
27
|
+
* The key names its chain, so there is no fan-out. Throws when that chain
|
|
28
|
+
* cannot answer.
|
|
35
29
|
**/
|
|
36
30
|
async getPool(key) {
|
|
37
|
-
return this.
|
|
31
|
+
return this.queryChain({
|
|
32
|
+
network: key.chainId,
|
|
33
|
+
run: (sdk) => sdk.opportunities.getPool(key)
|
|
34
|
+
});
|
|
38
35
|
}
|
|
39
36
|
/**
|
|
40
37
|
* {@inheritDoc OpportunitiesService.getStrategy}
|
|
38
|
+
*
|
|
39
|
+
* See {@link MultichainOpportunitiesService.getPool}.
|
|
41
40
|
**/
|
|
42
41
|
async getStrategy(key) {
|
|
43
|
-
return this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
* the SDK does not support are dropped here rather than reported as failures:
|
|
48
|
-
* a filter naming them is a narrowing, not a request.
|
|
49
|
-
**/
|
|
50
|
-
#networksOf(filter) {
|
|
51
|
-
const chainIds = filter?.chainIds;
|
|
52
|
-
if (!require_model_filters.isFilterSet(chainIds)) return;
|
|
53
|
-
const networks = [];
|
|
54
|
-
for (const chainId of chainIds) try {
|
|
55
|
-
networks.push(require_sdk_chain_chains.getNetworkType(chainId));
|
|
56
|
-
} catch {
|
|
57
|
-
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
|
|
58
|
-
}
|
|
59
|
-
return networks;
|
|
42
|
+
return this.queryChain({
|
|
43
|
+
network: key.chainId,
|
|
44
|
+
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
45
|
+
});
|
|
60
46
|
}
|
|
61
47
|
};
|
|
62
48
|
//#endregion
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_sdk_base_SDKConstruct = require("../base/SDKConstruct.js");
|
|
3
3
|
require("../base/index.js");
|
|
4
|
-
const require_model_filters = require("../../model/filters.js");
|
|
5
|
-
require("../../model/index.js");
|
|
6
4
|
//#region src/sdk/opportunities/OpportunitiesService.ts
|
|
7
5
|
/**
|
|
8
6
|
* Builds the `opportunities` read model from the chain.
|
|
@@ -24,8 +22,7 @@ var OpportunitiesService = class extends require_sdk_base_SDKConstruct.SDKConstr
|
|
|
24
22
|
* @param filter - Optional narrowing, applied to the built rows.
|
|
25
23
|
**/
|
|
26
24
|
async list(filter) {
|
|
27
|
-
|
|
28
|
-
if (require_model_filters.isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
25
|
+
if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
|
|
29
26
|
return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
|
|
30
27
|
}
|
|
31
28
|
/**
|
|
@@ -1,51 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_sdk_chain_chains = require("../chain/chains.js");
|
|
3
2
|
const require_sdk_base_MultichainConstruct = require("../base/MultichainConstruct.js");
|
|
4
3
|
require("../base/index.js");
|
|
5
|
-
const require_model_filters = require("../../model/filters.js");
|
|
6
|
-
require("../../model/index.js");
|
|
7
4
|
//#region src/sdk/positions/MultichainPositionsService.ts
|
|
8
5
|
/**
|
|
9
6
|
* Cross-chain counterpart of {@link PositionsService}.
|
|
10
7
|
*
|
|
11
|
-
* Fans out over every chain configured in {@link MultichainSDK}. A chain that
|
|
12
|
-
* fails is logged and skipped so one dead RPC does not hide the positions a
|
|
13
|
-
* wallet holds elsewhere; its failure is reported in
|
|
14
|
-
* {@link MultichainResult.meta}.
|
|
15
|
-
*
|
|
16
8
|
* @typeParam Plugins - Map of attached plugin types.
|
|
17
9
|
**/
|
|
18
10
|
var MultichainPositionsService = class extends require_sdk_base_MultichainConstruct.MultichainConstruct {
|
|
19
11
|
/**
|
|
20
12
|
* Positions of a wallet on all queried chains, see
|
|
21
13
|
* {@link PositionsService.list}.
|
|
22
|
-
*
|
|
23
|
-
* A filter that names chains narrows the fan-out itself, so chains whose rows
|
|
24
|
-
* would be discarded are never queried and never appear in the meta.
|
|
25
14
|
**/
|
|
26
15
|
async list(props) {
|
|
27
16
|
return this.queryChains({
|
|
28
|
-
|
|
17
|
+
chainIds: props.filter?.chainIds,
|
|
29
18
|
label: "list positions",
|
|
30
|
-
|
|
19
|
+
block: "latest",
|
|
20
|
+
run: (sdk, block) => sdk.positions.list({
|
|
21
|
+
...props,
|
|
22
|
+
blockNumber: block.blockNumber
|
|
23
|
+
})
|
|
31
24
|
});
|
|
32
25
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Chains named by the filter, or `undefined` to query all of them. Chain ids
|
|
35
|
-
* the SDK does not support are dropped here rather than reported as failures:
|
|
36
|
-
* a filter naming them is a narrowing, not a request.
|
|
37
|
-
**/
|
|
38
|
-
#networksOf(filter) {
|
|
39
|
-
const chainIds = filter?.chainIds;
|
|
40
|
-
if (!require_model_filters.isFilterSet(chainIds)) return;
|
|
41
|
-
const networks = [];
|
|
42
|
-
for (const chainId of chainIds) try {
|
|
43
|
-
networks.push(require_sdk_chain_chains.getNetworkType(chainId));
|
|
44
|
-
} catch {
|
|
45
|
-
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in positions filter`);
|
|
46
|
-
}
|
|
47
|
-
return networks;
|
|
48
|
-
}
|
|
49
26
|
};
|
|
50
27
|
//#endregion
|
|
51
28
|
exports.MultichainPositionsService = MultichainPositionsService;
|
|
@@ -19,8 +19,7 @@ var PositionsService = class extends require_sdk_base_SDKConstruct.SDKConstruct
|
|
|
19
19
|
**/
|
|
20
20
|
async list(props) {
|
|
21
21
|
const { wallet, filter, blockNumber } = props;
|
|
22
|
-
|
|
23
|
-
if (require_model_filters.isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
22
|
+
if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
|
|
24
23
|
const wantedKind = filter?.kind;
|
|
25
24
|
const wanted = (kind) => !require_model_filters.isFilterSet(wantedKind) || wantedKind === kind;
|
|
26
25
|
const isZeroDebt = filter?.isZeroDebt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { ierc20Abi } from "../abi/iERC20.js";
|
|
2
1
|
import { iCreditFacadeV310Abi } from "../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../sdk/utils/AddressMap.js";
|
|
4
3
|
import { AddressSet } from "../sdk/utils/AddressSet.js";
|
|
5
4
|
import { AssetsMap } from "../sdk/utils/AssetsMap.js";
|
|
6
5
|
import { childLogger } from "../sdk/utils/childLogger.js";
|
|
6
|
+
import { ierc20Abi } from "../abi/iERC20.js";
|
|
7
7
|
import "../sdk/constants/addresses.js";
|
|
8
8
|
import { MAX_UINT256, PERCENTAGE_FACTOR } from "../sdk/constants/math.js";
|
|
9
9
|
import { SDKConstruct } from "../sdk/base/SDKConstruct.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { getNetworkType } from "../sdk/chain/chains.js";
|
|
3
2
|
import { getWithdrawalCompressorAddress } from "../sdk/accounts/withdrawal-compressor/addresses.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import "../sdk/index.js";
|
|
5
5
|
import { iMidasDataFeedAbi, iMidasRedemptionVaultAbi, midasGatewayAbi, midasRedeemerAbi, midasRedemptionVaultPhantomTokenAbi, securitizeRedeemerAbi, securitizeRedemptionGatewayAbi, securitizeRedemptionPhantomTokenAbi } from "./withdrawalAbi.js";
|
|
6
6
|
import { erc20Abi, hexToString, parseAbi, parseEther } from "viem";
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
//#region src/model/filters.ts
|
|
2
2
|
/**
|
|
3
|
-
* The vocabulary every read-model filter is written in: how a single condition
|
|
4
|
-
* says "do not narrow", and how a predicate asks whether it narrows at all.
|
|
5
|
-
**/
|
|
6
|
-
/**
|
|
7
3
|
* Sentinel a filter condition can be set to instead of being omitted.
|
|
8
4
|
**/
|
|
9
5
|
const FILTER_ALL = "all";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./filters.js";
|
|
1
|
+
import { isFilterSet } from "./filters.js";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
//#region src/model/filters.schema.ts
|
|
4
4
|
/**
|
|
@@ -16,5 +16,13 @@ function filterable(schema) {
|
|
|
16
16
|
return z.union([schema, filterAllSchema]);
|
|
17
17
|
}
|
|
18
18
|
const booleanParamSchema = z.enum(["true", "false"]);
|
|
19
|
+
/**
|
|
20
|
+
* A boolean condition as a URL can carry it: a condition that does not narrow
|
|
21
|
+
* is absent rather than spelled out, see {@link booleanParamSchema}.
|
|
22
|
+
**/
|
|
23
|
+
function encodeFlag(condition) {
|
|
24
|
+
if (!isFilterSet(condition)) return;
|
|
25
|
+
return condition ? "true" : "false";
|
|
26
|
+
}
|
|
19
27
|
//#endregion
|
|
20
|
-
export { booleanParamSchema, filterAllSchema, filterable };
|
|
28
|
+
export { booleanParamSchema, encodeFlag, filterAllSchema, filterable };
|
package/dist/esm/model/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "./curators.js";
|
|
2
2
|
import { curatorNameSchema, curatorSchema } from "./curators.schema.js";
|
|
3
3
|
import { FILTER_ALL, isFilterSet } from "./filters.js";
|
|
4
|
-
import { booleanParamSchema, filterAllSchema, filterable } from "./filters.schema.js";
|
|
4
|
+
import { booleanParamSchema, encodeFlag, filterAllSchema, filterable } from "./filters.schema.js";
|
|
5
5
|
import { POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS } from "./history.js";
|
|
6
6
|
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
7
7
|
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
8
8
|
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
9
|
-
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
9
|
+
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionKeySchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionKeySchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
10
10
|
import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, poolPositionHistoryMetricSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, strategyHistoryMetricSchema, strategyPositionHistoryMetricSchema } from "./history.schema.js";
|
|
11
11
|
import { matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
12
12
|
import { matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
@@ -14,4 +14,4 @@ import { liquidationPositionId, matchesPositionFilter, poolPositionId, positionI
|
|
|
14
14
|
import "./primitives.js";
|
|
15
15
|
import "./response.js";
|
|
16
16
|
import { chainFailedSchema, chainMetadataSchema, chainSucceededSchema, dataSourceSchema, responseMetadataSchema, responseSchema } from "./response.schema.js";
|
|
17
|
-
export { FILTER_ALL, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
17
|
+
export { FILTER_ALL, POOL_HISTORY_METRICS, POOL_POSITION_HISTORY_METRICS, STRATEGY_HISTORY_METRICS, STRATEGY_POSITION_HISTORY_METRICS, amountSchema, apyBreakdownSchema, assetTypeSchema, booleanParamSchema, bpsSchema, chainFailedSchema, chainIdSchema, chainMetadataSchema, chainSucceededSchema, curatorNameSchema, curatorSchema, dataSourceSchema, delayedReceivedAssetSchema, encodeFlag, filterAllSchema, filterable, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, isFilterSet, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionId, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, matchesPositionFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterQueryParamsSchema, opportunityFilterQuerySchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionHistoryMetricSchema, poolPositionId, poolPositionKeySchema, poolPositionSchema, positionCollateralSchema, positionFilterQueryParamsSchema, positionFilterQuerySchema, positionFilterSchema, positionHistoryMetricSchema, positionHistoryQuerySchema, positionId, positionKeySchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, responseMetadataSchema, responseSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionHistoryMetricSchema, strategyPositionId, strategyPositionKeySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|
|
@@ -13,7 +13,7 @@ import { isFilterSet } from "./filters.js";
|
|
|
13
13
|
**/
|
|
14
14
|
function matchesLiquidatableAccountFilter(account, filter) {
|
|
15
15
|
if (!filter) return true;
|
|
16
|
-
if (
|
|
16
|
+
if (filter.chainIds && !filter.chainIds.includes(account.chainId)) return false;
|
|
17
17
|
if (isFilterSet(filter.underlyingType) && account.totalValue.token.assetType !== filter.underlyingType) return false;
|
|
18
18
|
if (isFilterSet(filter.paused) && account.paused !== filter.paused) return false;
|
|
19
19
|
if (isFilterSet(filter.rwa) && account.rwa !== filter.rwa) return false;
|
|
@@ -11,7 +11,7 @@ import { z } from "zod/v4";
|
|
|
11
11
|
* {@link LiquidatableAccountFilter}
|
|
12
12
|
**/
|
|
13
13
|
const liquidatableAccountFilterSchema = z.object({
|
|
14
|
-
chainIds:
|
|
14
|
+
chainIds: z.array(chainIdSchema).optional(),
|
|
15
15
|
underlyingType: filterable(assetTypeSchema).optional(),
|
|
16
16
|
paused: filterable(z.boolean()).optional(),
|
|
17
17
|
rwa: filterable(z.boolean()).optional(),
|
|
@@ -42,7 +42,7 @@ function opportunityId(opportunity) {
|
|
|
42
42
|
function matchesOpportunityFilter(opportunity, filter) {
|
|
43
43
|
if (!filter) return true;
|
|
44
44
|
if (isFilterSet(filter.kind) && opportunity.kind !== filter.kind) return false;
|
|
45
|
-
if (
|
|
45
|
+
if (filter.chainIds && !filter.chainIds.includes(opportunity.chainId)) return false;
|
|
46
46
|
if (isFilterSet(filter.underlyingType) && opportunity.underlyingToken.assetType !== filter.underlyingType) return false;
|
|
47
47
|
if (isFilterSet(filter.paused) && opportunity.paused !== filter.paused) return false;
|
|
48
48
|
if (isFilterSet(filter.sunset) && opportunity.sunset !== filter.sunset) return false;
|