@gearbox-protocol/sdk 14.12.0-next.80 → 14.12.0-next.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/filters.js +0 -4
- package/dist/cjs/model/filters.schema.js +10 -1
- package/dist/cjs/model/index.js +11 -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.js +1 -0
- package/dist/cjs/model/response.schema.js +64 -0
- 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/credit-account-compressor/CreditAccountCompressor.js +6 -6
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +26 -20
- package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
- package/dist/cjs/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
- package/dist/cjs/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +3 -2
- 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/market/rwa/RWARegistry.js +4 -2
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +18 -32
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +1 -4
- package/dist/cjs/sdk/pools/PoolService.js +2 -1
- package/dist/cjs/sdk/positions/MultichainPositionsService.js +6 -29
- package/dist/cjs/sdk/positions/PositionsService.js +12 -6
- 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 +5 -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.js +1 -0
- package/dist/esm/model/response.schema.js +58 -0
- 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/credit-account-compressor/CreditAccountCompressor.js +6 -6
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +27 -21
- package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +38 -14
- package/dist/esm/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.js +7 -5
- 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 +4 -3
- 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/rwa/RWARegistry.js +4 -2
- 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 +3 -2
- package/dist/esm/sdk/positions/MultichainPositionsService.js +6 -29
- package/dist/esm/sdk/positions/PositionsService.js +12 -6
- 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 +7 -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 +105 -0
- package/dist/types/model/response.schema.d.ts +98 -0
- 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/credit-account-compressor/types.d.ts +4 -0
- package/dist/types/sdk/accounts/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/LiquidationsService.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 +32 -16
- package/dist/types/sdk/accounts/withdrawal-compressor/AbstractWithdrawalCompressorContract.d.ts +4 -4
- package/dist/types/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.d.ts +2 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/index.d.ts +2 -2
- package/dist/types/sdk/accounts/withdrawal-compressor/types.d.ts +26 -4
- 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 +7 -7
- package/dist/types/sdk/market/MarketSuite.d.ts +1 -1
- package/dist/types/sdk/market/rwa/RWARegistry.d.ts +2 -1
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +13 -16
- package/dist/types/sdk/pools/types.d.ts +4 -0
- package/dist/types/sdk/positions/MultichainPositionsService.d.ts +2 -12
- package/dist/types/sdk/positions/index.d.ts +2 -2
- package/dist/types/sdk/positions/types.d.ts +14 -5
- package/dist/types/sdk/types/index.d.ts +2 -2
- package/dist/types/sdk/types/multichain.d.ts +16 -36
- package/package.json +1 -1
|
@@ -2,13 +2,8 @@ import { MultichainConstruct } from "../../base/MultichainConstruct.js";
|
|
|
2
2
|
import "../../base/index.js";
|
|
3
3
|
//#region src/sdk/accounts/liquidations/MultichainLiquidationsService.ts
|
|
4
4
|
/**
|
|
5
|
-
* Cross-chain counterpart of {@link LiquidationsService}.
|
|
6
|
-
*
|
|
7
|
-
* Fans out over all chains configured in {@link MultichainSDK} (optionally
|
|
8
|
-
* restricted via {@link MultichainNetworksProps.networks}). A failed chain is
|
|
9
|
-
* logged as a warning and skipped, so one dead RPC does not empty the whole
|
|
10
|
-
* list; its failure is reported in {@link MultichainResult.meta}. Networks that
|
|
11
|
-
* are not configured in the SDK are reported there the same way.
|
|
5
|
+
* Cross-chain counterpart of {@link LiquidationsService}. These reads are live,
|
|
6
|
+
* so each chain is pinned to its own freshly fetched head.
|
|
12
7
|
**/
|
|
13
8
|
var MultichainLiquidationsService = class extends MultichainConstruct {
|
|
14
9
|
/**
|
|
@@ -17,22 +12,44 @@ var MultichainLiquidationsService = class extends MultichainConstruct {
|
|
|
17
12
|
**/
|
|
18
13
|
async getLiquidatableAccounts(props) {
|
|
19
14
|
return this.queryChains({
|
|
20
|
-
|
|
15
|
+
chainIds: props?.chainIds,
|
|
21
16
|
label: "get liquidatable accounts",
|
|
22
|
-
|
|
17
|
+
block: "latest",
|
|
18
|
+
run: (sdk, block) => sdk.liquidations.getLiquidatableAccounts({
|
|
19
|
+
...props,
|
|
20
|
+
blockNumber: block.blockNumber
|
|
21
|
+
})
|
|
23
22
|
});
|
|
24
23
|
}
|
|
25
24
|
/**
|
|
26
25
|
* {@inheritDoc LiquidationsService.getLiquidationDetails}
|
|
26
|
+
*
|
|
27
|
+
* Throws when the chain cannot answer.
|
|
27
28
|
**/
|
|
28
29
|
async getLiquidationDetails(props) {
|
|
29
|
-
return this.
|
|
30
|
+
return this.queryChain({
|
|
31
|
+
network: props.network,
|
|
32
|
+
block: props.blockNumber ?? "latest",
|
|
33
|
+
run: (sdk, block) => sdk.liquidations.getLiquidationDetails({
|
|
34
|
+
...props,
|
|
35
|
+
blockNumber: block.blockNumber
|
|
36
|
+
})
|
|
37
|
+
});
|
|
30
38
|
}
|
|
31
39
|
/**
|
|
32
40
|
* {@inheritDoc LiquidationsService.buildLiquidationTx}
|
|
41
|
+
*
|
|
42
|
+
* The reported block is the one the transaction was built against.
|
|
33
43
|
**/
|
|
34
44
|
async buildLiquidationTx(props) {
|
|
35
|
-
return this.
|
|
45
|
+
return this.queryChain({
|
|
46
|
+
network: props.network,
|
|
47
|
+
block: props.blockNumber ?? "latest",
|
|
48
|
+
run: (sdk, block) => sdk.liquidations.buildLiquidationTx({
|
|
49
|
+
...props,
|
|
50
|
+
blockNumber: block.blockNumber
|
|
51
|
+
})
|
|
52
|
+
});
|
|
36
53
|
}
|
|
37
54
|
/**
|
|
38
55
|
* Liquidation positions of all queried chains, see
|
|
@@ -40,18 +57,25 @@ var MultichainLiquidationsService = class extends MultichainConstruct {
|
|
|
40
57
|
**/
|
|
41
58
|
async getLiquidationPositions(props) {
|
|
42
59
|
return this.queryChains({
|
|
43
|
-
|
|
60
|
+
chainIds: props.chainIds,
|
|
44
61
|
label: "get liquidation positions",
|
|
45
|
-
|
|
62
|
+
block: "latest",
|
|
63
|
+
run: (sdk, block) => sdk.liquidations.getLiquidationPositions({
|
|
64
|
+
...props,
|
|
65
|
+
blockNumber: block.blockNumber
|
|
66
|
+
})
|
|
46
67
|
});
|
|
47
68
|
}
|
|
48
69
|
/**
|
|
49
70
|
* Loads the liquidators of all queried chains, see
|
|
50
71
|
* {@link LiquidationsService.loadRWALiquidators}.
|
|
72
|
+
*
|
|
73
|
+
* Nothing consumes the block of a cache warm-up, so this one is left on the
|
|
74
|
+
* loaded snapshot.
|
|
51
75
|
**/
|
|
52
76
|
async loadRWALiquidators(props) {
|
|
53
77
|
return this.runChains({
|
|
54
|
-
|
|
78
|
+
chainIds: props?.chainIds,
|
|
55
79
|
label: "load RWA liquidators",
|
|
56
80
|
run: (sdk) => sdk.liquidations.loadRWALiquidators()
|
|
57
81
|
});
|
|
@@ -64,7 +64,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
64
64
|
/**
|
|
65
65
|
* {@inheritDoc IWithdrawalCompressorContract.loadWithdrawableAssets}
|
|
66
66
|
**/
|
|
67
|
-
async loadWithdrawableAssets(force) {
|
|
67
|
+
async loadWithdrawableAssets(force, blockNumber) {
|
|
68
68
|
if (this.#withdrawableAssets && !force) return this.getWithdrawableAssets();
|
|
69
69
|
const cms = this.#sdk.marketRegister.creditManagers.map((cm) => cm.creditManager.address);
|
|
70
70
|
const resp = await this.client.multicall({
|
|
@@ -75,7 +75,8 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
75
75
|
args: [cm]
|
|
76
76
|
})),
|
|
77
77
|
allowFailure: true,
|
|
78
|
-
batchSize: 0
|
|
78
|
+
batchSize: 0,
|
|
79
|
+
blockNumber
|
|
79
80
|
});
|
|
80
81
|
const cache = new AddressMap(void 0, MAP_LABEL);
|
|
81
82
|
for (let i = 0; i < resp.length; i++) {
|
|
@@ -120,7 +121,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
120
121
|
/**
|
|
121
122
|
* {@inheritDoc IWithdrawalCompressorContract.getCurrentWithdrawals}
|
|
122
123
|
**/
|
|
123
|
-
async getCurrentWithdrawals(creditAccount) {
|
|
124
|
+
async getCurrentWithdrawals(creditAccount, blockNumber) {
|
|
124
125
|
const [[claimable, pending], creditManager] = await this.client.multicall({
|
|
125
126
|
contracts: [{
|
|
126
127
|
address: this.address,
|
|
@@ -133,7 +134,8 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
133
134
|
functionName: "creditManager"
|
|
134
135
|
}],
|
|
135
136
|
allowFailure: false,
|
|
136
|
-
batchSize: 0
|
|
137
|
+
batchSize: 0,
|
|
138
|
+
blockNumber
|
|
137
139
|
});
|
|
138
140
|
return {
|
|
139
141
|
claimable: claimable.map((w) => toClaimableWithdrawal(w, creditManager)),
|
|
@@ -143,7 +145,7 @@ var AbstractWithdrawalCompressorContract = class extends BaseContract {
|
|
|
143
145
|
/**
|
|
144
146
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
145
147
|
**/
|
|
146
|
-
async getExternalAccountCurrentWithdrawals(
|
|
148
|
+
async getExternalAccountCurrentWithdrawals(_props) {
|
|
147
149
|
this.#reportUnsupported("external account withdrawals");
|
|
148
150
|
return {
|
|
149
151
|
claimable: [],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
4
3
|
import { decodeDelayedIntent } from "./intent-codec.js";
|
|
4
|
+
import { iRedemptionLoggerV310Abi } from "../../../abi/iRedemptionLoggerV310.js";
|
|
5
5
|
import { InvalidDelayedIntentError } from "./errors.js";
|
|
6
6
|
//#region src/sdk/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.ts
|
|
7
7
|
const abi = iRedemptionLoggerV310Abi;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV310Abi } from "../../../abi/IWithdrawalCompressorV310.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV310Abi;
|
|
5
5
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
2
1
|
import { AbstractWithdrawalCompressorContract } from "./AbstractWithdrawalCompressorContract.js";
|
|
2
|
+
import { iWithdrawalCompressorV311Abi } from "../../../abi/IWithdrawalCompressorV311.js";
|
|
3
3
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.ts
|
|
4
4
|
const abi = iWithdrawalCompressorV311Abi;
|
|
5
5
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
2
1
|
import { encodeDelayedIntent } from "./intent-codec.js";
|
|
3
2
|
import { AbstractWithdrawalCompressorContract, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal } from "./AbstractWithdrawalCompressorContract.js";
|
|
3
|
+
import { iWithdrawalCompressorV313Abi } from "../../../abi/IWithdrawalCompressorV313.js";
|
|
4
4
|
import { toWithdrawalStatus } from "./types.js";
|
|
5
5
|
//#region src/sdk/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.ts
|
|
6
6
|
const abi = iWithdrawalCompressorV313Abi;
|
|
@@ -183,7 +183,7 @@ var WithdrawalCompressorV313Contract = class extends AbstractWithdrawalCompresso
|
|
|
183
183
|
/**
|
|
184
184
|
* {@inheritDoc IWithdrawalCompressorContract.getExternalAccountCurrentWithdrawals}
|
|
185
185
|
**/
|
|
186
|
-
async getExternalAccountCurrentWithdrawals(account,
|
|
186
|
+
async getExternalAccountCurrentWithdrawals({ account, withdrawalTokens = [], blockNumber }) {
|
|
187
187
|
if (withdrawalTokens.length === 0) return {
|
|
188
188
|
claimable: [],
|
|
189
189
|
pending: []
|
|
@@ -192,7 +192,8 @@ var WithdrawalCompressorV313Contract = class extends AbstractWithdrawalCompresso
|
|
|
192
192
|
address: this.address,
|
|
193
193
|
abi: iExternalWithdrawalsBatchAbi,
|
|
194
194
|
functionName: "getExternalAccountCurrentWithdrawals",
|
|
195
|
-
args: [withdrawalTokens, account]
|
|
195
|
+
args: [withdrawalTokens, account],
|
|
196
|
+
blockNumber
|
|
196
197
|
});
|
|
197
198
|
return {
|
|
198
199
|
claimable: claimable.map((w) => toClaimableWithdrawal(w, void 0)),
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { ChainNotConfiguredError } from "../core/errors.js";
|
|
2
1
|
//#region src/sdk/base/MultichainConstruct.ts
|
|
3
2
|
/**
|
|
4
3
|
* @internal
|
|
5
4
|
* Base class for services that fan out over the chains of a
|
|
6
5
|
* {@link MultichainSDK}, the cross-chain counterpart of {@link SDKConstruct}.
|
|
7
6
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* reported in {@link MultichainResult.meta}.
|
|
7
|
+
* A fan-out soft-fails: a chain that rejects is logged as a warning and
|
|
8
|
+
* contributes no payload, while the remaining chains still return their rows.
|
|
9
|
+
* A single-chain request throws instead.
|
|
12
10
|
*
|
|
13
11
|
* @typeParam Plugins - Map of attached plugin types.
|
|
14
12
|
**/
|
|
@@ -22,58 +20,99 @@ var MultichainConstruct = class {
|
|
|
22
20
|
* chains that responded successfully.
|
|
23
21
|
**/
|
|
24
22
|
async queryChains(props) {
|
|
25
|
-
const { values,
|
|
23
|
+
const { values, chains } = await this.#settle(props);
|
|
26
24
|
return {
|
|
27
|
-
|
|
28
|
-
meta
|
|
25
|
+
data: values.flat(),
|
|
26
|
+
meta: { chains }
|
|
29
27
|
};
|
|
30
28
|
}
|
|
31
29
|
/**
|
|
32
30
|
* Fans out a request with no payload, reporting the outcome of every queried
|
|
33
|
-
* chain in
|
|
31
|
+
* chain in `meta.chains`.
|
|
34
32
|
**/
|
|
35
33
|
async runChains(props) {
|
|
36
|
-
const {
|
|
34
|
+
const { chains } = await this.#settle(props);
|
|
37
35
|
return {
|
|
38
|
-
|
|
39
|
-
meta
|
|
36
|
+
data: void 0,
|
|
37
|
+
meta: { chains }
|
|
40
38
|
};
|
|
41
39
|
}
|
|
42
40
|
/**
|
|
43
|
-
* Runs
|
|
44
|
-
*
|
|
41
|
+
* Runs a request against one chain and reports the block it was read at.
|
|
42
|
+
* Throws when the chain is not configured, not attached, or rejects the read.
|
|
45
43
|
**/
|
|
46
|
-
async
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
async queryChain({ network, block = "state", run }) {
|
|
45
|
+
const sdk = this.sdk.chain(network);
|
|
46
|
+
const at = await this.#resolveBlock(sdk, block);
|
|
47
|
+
return {
|
|
48
|
+
data: await run(sdk, at),
|
|
49
|
+
meta: { chains: [succeeded(sdk.chainId, at)] }
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Runs the request on every queried chain in parallel.
|
|
54
|
+
**/
|
|
55
|
+
async #settle({ chainIds, label, block = "state", run }) {
|
|
56
|
+
const wanted = chainIds && new Set(chainIds);
|
|
57
|
+
const requested = [];
|
|
58
|
+
for (const [network, sdk] of this.sdk.chains) if (!wanted || wanted.has(sdk.chainId)) requested.push([network, sdk]);
|
|
59
|
+
const settled = await Promise.allSettled(requested.map(async ([, sdk]) => {
|
|
60
|
+
const at = await this.#resolveBlock(sdk, block);
|
|
61
|
+
return {
|
|
62
|
+
data: await run(sdk, at),
|
|
63
|
+
at
|
|
64
|
+
};
|
|
52
65
|
}));
|
|
53
66
|
const values = [];
|
|
54
|
-
const
|
|
55
|
-
settled.
|
|
56
|
-
const network = requested[i];
|
|
67
|
+
const chains = [];
|
|
68
|
+
for (let i = 0; i < settled.length; i++) {
|
|
69
|
+
const [network, sdk] = requested[i];
|
|
70
|
+
const result = settled[i];
|
|
57
71
|
if (result.status === "fulfilled") {
|
|
58
|
-
values.push(result.value);
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
status: "success"
|
|
62
|
-
});
|
|
63
|
-
return;
|
|
72
|
+
values.push(result.value.data);
|
|
73
|
+
chains.push(succeeded(sdk.chainId, result.value.at));
|
|
74
|
+
continue;
|
|
64
75
|
}
|
|
65
|
-
(
|
|
66
|
-
|
|
67
|
-
|
|
76
|
+
(sdk.logger ?? this.sdk.logger)?.warn(result.reason, `failed to ${label} on ${network}`);
|
|
77
|
+
chains.push({
|
|
78
|
+
chainId: sdk.chainId,
|
|
68
79
|
status: "error",
|
|
80
|
+
source: "onchain",
|
|
69
81
|
error: result.reason
|
|
70
82
|
});
|
|
71
|
-
}
|
|
83
|
+
}
|
|
72
84
|
return {
|
|
73
85
|
values,
|
|
74
|
-
|
|
86
|
+
chains
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Block a chain's read is pinned to and reported at.
|
|
91
|
+
**/
|
|
92
|
+
async #resolveBlock(sdk, source) {
|
|
93
|
+
if (source === "state") return {
|
|
94
|
+
blockNumber: sdk.currentBlock,
|
|
95
|
+
timestamp: sdk.timestamp
|
|
96
|
+
};
|
|
97
|
+
if (typeof source === "bigint") return {
|
|
98
|
+
blockNumber: source,
|
|
99
|
+
timestamp: (await sdk.client.getBlock({ blockNumber: source })).timestamp
|
|
100
|
+
};
|
|
101
|
+
const block = await sdk.client.getBlock({ blockTag: "latest" });
|
|
102
|
+
return {
|
|
103
|
+
blockNumber: block.number,
|
|
104
|
+
timestamp: block.timestamp
|
|
75
105
|
};
|
|
76
106
|
}
|
|
77
107
|
};
|
|
108
|
+
function succeeded(chainId, at) {
|
|
109
|
+
return {
|
|
110
|
+
chainId,
|
|
111
|
+
status: "success",
|
|
112
|
+
source: "onchain",
|
|
113
|
+
blockNumber: Number(at.blockNumber),
|
|
114
|
+
timestamp: Number(at.timestamp)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
78
117
|
//#endregion
|
|
79
118
|
export { MultichainConstruct };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
2
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
3
1
|
import { AddressMap } from "../utils/AddressMap.js";
|
|
4
2
|
import { AddressSet } from "../utils/AddressSet.js";
|
|
5
3
|
import { bytes32ToString } from "../utils/bytes32ToString.js";
|
|
6
4
|
import { getAssetType } from "../chain/chains.js";
|
|
7
5
|
import { formatBN } from "../utils/formatter.js";
|
|
8
6
|
import "../utils/index.js";
|
|
7
|
+
import { iStateSerializerAbi } from "../../abi/iStateSerializer.js";
|
|
8
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
9
9
|
//#region src/sdk/base/TokensMeta.ts
|
|
10
10
|
/**
|
|
11
11
|
* Registry of token metadata (symbol, decimals, phantom type) keyed by address.
|
|
@@ -354,6 +354,16 @@ function getNetworkType(chainId) {
|
|
|
354
354
|
return network;
|
|
355
355
|
}
|
|
356
356
|
/**
|
|
357
|
+
* Chain IDs of chains named as {@link NetworkType} labels or as IDs already,
|
|
358
|
+
* e.g. `sdk.opportunities.list({ chainIds: toChainIds(["Mainnet"]) })`.
|
|
359
|
+
*
|
|
360
|
+
* @param scope - Chains as labels, or already as IDs.
|
|
361
|
+
* @throws If any entry is not a supported network.
|
|
362
|
+
**/
|
|
363
|
+
function toChainIds(scope) {
|
|
364
|
+
return scope.map((entry) => getChain(entry).id);
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
357
367
|
* Type guard that checks whether a chain ID belongs to a supported Gearbox network.
|
|
358
368
|
*
|
|
359
369
|
* @param chainId - Numeric chain ID, or `undefined`.
|
|
@@ -451,4 +461,4 @@ function isSunsetStrategy(creditManager, collateral, network) {
|
|
|
451
461
|
return !!chains[network].sunsetStrategies?.some((s) => isAddressEqual(s.creditManager, creditManager) && isAddressEqual(s.collateral, collateral));
|
|
452
462
|
}
|
|
453
463
|
//#endregion
|
|
454
|
-
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork };
|
|
464
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork } from "./chains.js";
|
|
1
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chains.js";
|
|
2
2
|
import { detectNetwork } from "./detectNetwork.js";
|
|
3
|
-
export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork };
|
|
3
|
+
export { NetworkType, SUPPORTED_NETWORKS, chains, detectNetwork, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
1
|
import { AP_MARKET_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR } from "../constants/address-provider.js";
|
|
3
2
|
import { isV310 } from "../constants/versions.js";
|
|
4
3
|
import "../constants/index.js";
|
|
5
4
|
import { hexEq } from "../utils/hex.js";
|
|
5
|
+
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/sdk/core/createAddressProvider.ts
|
|
8
8
|
const OVERRIDE_ADDRESSES = { Mainnet: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ChainNotConfiguredError, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./errors.js";
|
|
2
1
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
3
2
|
import { createAddressProvider, hydrateAddressProvider } from "./createAddressProvider.js";
|
|
3
|
+
import { ChainNotConfiguredError, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./errors.js";
|
|
4
4
|
import "./types.js";
|
|
5
5
|
export { AddressProviderV310Contract, ChainNotConfiguredError, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, createAddressProvider, hydrateAddressProvider };
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import { bytes32ToString } from "./utils/bytes32ToString.js";
|
|
|
8
8
|
import { childLogger } from "./utils/childLogger.js";
|
|
9
9
|
import { createRawTx } from "./utils/createRawTx.js";
|
|
10
10
|
import { TypedObjectUtils } from "./utils/mappers.js";
|
|
11
|
-
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork } from "./chain/chains.js";
|
|
11
|
+
import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator, getAssetType, getChain, getCuratorName, getNetworkType, isPublicNetwork, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, toChainIds } from "./chain/chains.js";
|
|
12
12
|
import { detectNetwork } from "./chain/detectNetwork.js";
|
|
13
13
|
import "./chain/index.js";
|
|
14
14
|
import { etherscanApiUrl, etherscanUrl } from "./utils/etherscan.js";
|
|
@@ -35,7 +35,6 @@ import { ChainContractsRegister } from "./base/ChainContractsRegister.js";
|
|
|
35
35
|
import { Construct } from "./base/Construct.js";
|
|
36
36
|
import { BaseContract, ContractParseError } from "./base/BaseContract.js";
|
|
37
37
|
import { MissingSerializedParamsError } from "./base/errors.js";
|
|
38
|
-
import { ChainNotConfiguredError, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./core/errors.js";
|
|
39
38
|
import { MultichainConstruct } from "./base/MultichainConstruct.js";
|
|
40
39
|
import { PlaceholderContract } from "./base/PlaceholderContract.js";
|
|
41
40
|
import { SDKConstruct } from "./base/SDKConstruct.js";
|
|
@@ -128,6 +127,7 @@ import { createWithdrawalCompressor } from "./accounts/withdrawal-compressor/cre
|
|
|
128
127
|
import "./accounts/index.js";
|
|
129
128
|
import { AddressProviderV310Contract } from "./core/AddressProviderV310Contract.js";
|
|
130
129
|
import { createAddressProvider, hydrateAddressProvider } from "./core/createAddressProvider.js";
|
|
130
|
+
import { ChainNotConfiguredError, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./core/errors.js";
|
|
131
131
|
import "./core/index.js";
|
|
132
132
|
import { MultichainOpportunitiesService } from "./opportunities/MultichainOpportunitiesService.js";
|
|
133
133
|
import { OpportunitiesService } from "./opportunities/OpportunitiesService.js";
|
|
@@ -148,4 +148,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
148
148
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
149
149
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
150
150
|
import "./types/index.js";
|
|
151
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, expectedBalanceDeltas, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
151
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, Erc4626PriceFeedContract, ExternalPriceFeedContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InvalidDelayedIntentError, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowLRTPriceFeedContract, MidasLiquidatorContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PeripheryCompressorV310Contract, PlaceholderAdapterContract, PlaceholderContract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeRWAFactory, SimulateWithPriceUpdatesError, SimulationError, TokensMeta, TypedObjectUtils, UnsupportedZapperFunctionError, VERSION_RANGE_310, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, additionalBorrowApyBps, assetsMap, attachOptionsSchema, borrowApyBps, botPermissionsToString, bytes32ToString, chains, childLogger, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, expectedBalanceDeltas, fetchPythPayloads, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, healthFactorBps, hexEq, hydrateAddressProvider, iCreditAccountAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, json_parse, json_stringify, maxLeverage, minSeizedAmount, mustGetDominantCollateral, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, percentFmt, positionLeverage, primaryInstantOutput, rayToBps, rayToNumber, retry, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toWithdrawalStatus, usdToNumber, utilizationBps, watchBlocksAsync };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iCreditFacadeMulticallV310Abi, iCreditFacadeV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
4
3
|
import "../../base/index.js";
|
|
4
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
5
5
|
//#region src/sdk/market/credit/CreditFacadeV310BaseContract.ts
|
|
6
6
|
const abi = [
|
|
7
7
|
...iCreditFacadeV310Abi,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
2
1
|
import { iPoolV310Abi } from "../../../abi/310/generated.js";
|
|
3
2
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
4
3
|
import { RAY } from "../../constants/math.js";
|
|
@@ -7,6 +6,7 @@ import { formatBN, formatBNvalue, percentFmt } from "../../utils/formatter.js";
|
|
|
7
6
|
import "../../utils/index.js";
|
|
8
7
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
9
8
|
import "../../base/index.js";
|
|
9
|
+
import { iPausableAbi } from "../../../abi/iPausable.js";
|
|
10
10
|
import { utilizationBps } from "../math.js";
|
|
11
11
|
//#region src/sdk/market/pool/PoolV310Contract.ts
|
|
12
12
|
const abi = [...iPoolV310Abi, ...iPausableAbi];
|
|
@@ -54,8 +54,9 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
54
54
|
* @param investor - Investor EOA address.
|
|
55
55
|
* @param factories_ - Optional subset of factory addresses to query.
|
|
56
56
|
* When omitted, all loaded factories are used.
|
|
57
|
+
* @param blockNumber - Block to read at, defaults to the latest block.
|
|
57
58
|
*/
|
|
58
|
-
async getInvestorData(investor, factories_) {
|
|
59
|
+
async getInvestorData(investor, factories_, blockNumber) {
|
|
59
60
|
let factories = this.#factories.values();
|
|
60
61
|
if (factories_?.length) factories = factories_.map((f) => this.#factories.mustGet(f));
|
|
61
62
|
if (!factories.length) return [];
|
|
@@ -64,7 +65,8 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
64
65
|
abi: iRWACompressorAbi,
|
|
65
66
|
address: rwaCompressorAddress,
|
|
66
67
|
functionName: "getRWAInvestorData",
|
|
67
|
-
args: [investor, factories.map((f) => f.address)]
|
|
68
|
+
args: [investor, factories.map((f) => f.address)],
|
|
69
|
+
blockNumber
|
|
68
70
|
});
|
|
69
71
|
const result = [];
|
|
70
72
|
for (let i = 0; i < factories.length; i++) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
2
1
|
import { ZapperContract } from "./ZapperContract.js";
|
|
2
|
+
import { iethZapperAbi } from "../../../abi/iETHZapper.js";
|
|
3
3
|
//#region src/sdk/market/zapper/IETHZapperContract.ts
|
|
4
4
|
const abi = iethZapperAbi;
|
|
5
5
|
var IETHZapperContract = class extends ZapperContract {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
2
1
|
import { BaseContract } from "../../base/BaseContract.js";
|
|
3
2
|
import "../../base/index.js";
|
|
3
|
+
import { iZapperAbi } from "../../../abi/iZapper.js";
|
|
4
4
|
import { UnsupportedZapperFunctionError } from "./errors.js";
|
|
5
5
|
//#region src/sdk/market/zapper/ZapperContract.ts
|
|
6
6
|
/**
|
|
@@ -1,61 +1,47 @@
|
|
|
1
|
-
import { getNetworkType } from "../chain/chains.js";
|
|
2
1
|
import { MultichainConstruct } from "../base/MultichainConstruct.js";
|
|
3
2
|
import "../base/index.js";
|
|
4
|
-
import { isFilterSet } from "../../model/filters.js";
|
|
5
|
-
import "../../model/index.js";
|
|
6
3
|
//#region src/sdk/opportunities/MultichainOpportunitiesService.ts
|
|
7
4
|
/**
|
|
8
|
-
* Cross-chain counterpart of {@link OpportunitiesService}.
|
|
9
|
-
*
|
|
10
|
-
* Fans out over every chain configured in {@link MultichainSDK}. A chain that
|
|
11
|
-
* fails is logged and skipped so one dead RPC does not empty the list; its
|
|
12
|
-
* failure is reported in {@link MultichainResult.meta}.
|
|
13
|
-
*
|
|
14
|
-
* Detail reads need no fan-out: an opportunity key names its chain.
|
|
5
|
+
* Cross-chain counterpart of {@link OpportunitiesService}. Every read walks
|
|
6
|
+
* loaded market state, so the block it reports is the SDK's snapshot.
|
|
15
7
|
*
|
|
16
8
|
* @typeParam Plugins - Map of attached plugin types.
|
|
17
9
|
**/
|
|
18
10
|
var MultichainOpportunitiesService = class extends MultichainConstruct {
|
|
19
11
|
/**
|
|
20
12
|
* Opportunities of all queried chains, see {@link OpportunitiesService.list}.
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* would be discarded are never queried and never appear in the meta.
|
|
13
|
+
* A filter that names chains narrows the fan-out itself, so a chain whose
|
|
14
|
+
* rows would be discarded is never queried and never appears in the meta.
|
|
24
15
|
**/
|
|
25
16
|
async list(filter) {
|
|
26
17
|
return this.queryChains({
|
|
27
|
-
|
|
18
|
+
chainIds: filter?.chainIds,
|
|
28
19
|
label: "list opportunities",
|
|
29
20
|
run: (sdk) => sdk.opportunities.list(filter)
|
|
30
21
|
});
|
|
31
22
|
}
|
|
32
23
|
/**
|
|
33
24
|
* {@inheritDoc OpportunitiesService.getPool}
|
|
25
|
+
*
|
|
26
|
+
* The key names its chain, so there is no fan-out. Throws when that chain
|
|
27
|
+
* cannot answer.
|
|
34
28
|
**/
|
|
35
29
|
async getPool(key) {
|
|
36
|
-
return this.
|
|
30
|
+
return this.queryChain({
|
|
31
|
+
network: key.chainId,
|
|
32
|
+
run: (sdk) => sdk.opportunities.getPool(key)
|
|
33
|
+
});
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
39
36
|
* {@inheritDoc OpportunitiesService.getStrategy}
|
|
37
|
+
*
|
|
38
|
+
* See {@link MultichainOpportunitiesService.getPool}.
|
|
40
39
|
**/
|
|
41
40
|
async getStrategy(key) {
|
|
42
|
-
return this.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* the SDK does not support are dropped here rather than reported as failures:
|
|
47
|
-
* a filter naming them is a narrowing, not a request.
|
|
48
|
-
**/
|
|
49
|
-
#networksOf(filter) {
|
|
50
|
-
const chainIds = filter?.chainIds;
|
|
51
|
-
if (!isFilterSet(chainIds)) return;
|
|
52
|
-
const networks = [];
|
|
53
|
-
for (const chainId of chainIds) try {
|
|
54
|
-
networks.push(getNetworkType(chainId));
|
|
55
|
-
} catch {
|
|
56
|
-
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
|
|
57
|
-
}
|
|
58
|
-
return networks;
|
|
41
|
+
return this.queryChain({
|
|
42
|
+
network: key.chainId,
|
|
43
|
+
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
44
|
+
});
|
|
59
45
|
}
|
|
60
46
|
};
|
|
61
47
|
//#endregion
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
2
2
|
import "../base/index.js";
|
|
3
|
-
import { isFilterSet } from "../../model/filters.js";
|
|
4
|
-
import "../../model/index.js";
|
|
5
3
|
//#region src/sdk/opportunities/OpportunitiesService.ts
|
|
6
4
|
/**
|
|
7
5
|
* Builds the `opportunities` read model from the chain.
|
|
@@ -23,8 +21,7 @@ var OpportunitiesService = class extends SDKConstruct {
|
|
|
23
21
|
* @param filter - Optional narrowing, applied to the built rows.
|
|
24
22
|
**/
|
|
25
23
|
async list(filter) {
|
|
26
|
-
|
|
27
|
-
if (isFilterSet(chainIds) && !chainIds.includes(this.chainId)) return [];
|
|
24
|
+
if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
|
|
28
25
|
return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
|
|
29
26
|
}
|
|
30
27
|
/**
|