@gearbox-protocol/sdk 14.12.0-next.65 → 14.12.0-next.67
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/common-utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/apy/calculate-safe-borrow-rate.js +3 -3
- package/dist/cjs/common-utils/utils/assets-math.js +7 -7
- package/dist/cjs/common-utils/utils/creditAccount/calc-health-factor.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/debt.js +2 -2
- package/dist/cjs/common-utils/utils/creditAccount/quota-utils.js +5 -5
- package/dist/cjs/common-utils/utils/index.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +5 -5
- package/dist/cjs/common-utils/utils/strategies/strategy-info/calculate-total-points.js +2 -2
- package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +2 -2
- package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +4 -4
- package/dist/cjs/dev/index.js +2 -1
- package/dist/cjs/dev/kycUtils.js +1 -1
- package/dist/cjs/dev/midasUtils.js +104 -0
- package/dist/cjs/model/history.js +28 -0
- package/dist/cjs/model/history.schema.js +84 -0
- package/dist/cjs/model/index.js +64 -0
- package/dist/cjs/model/liquidations.js +23 -0
- package/dist/cjs/model/liquidations.schema.js +91 -0
- package/dist/cjs/model/opportunities.js +55 -0
- package/dist/cjs/model/opportunities.schema.js +220 -0
- package/dist/cjs/model/package.json +1 -0
- package/dist/cjs/model/positions.js +1 -0
- package/dist/cjs/model/primitives.js +1 -0
- package/dist/cjs/model/primitives.schema.js +85 -0
- package/dist/cjs/new-sdk/AbstractNamespace.js +158 -0
- package/dist/cjs/new-sdk/GearboxSDK.js +122 -0
- package/dist/cjs/new-sdk/index.js +11 -0
- package/dist/cjs/new-sdk/opportunities/OpportunitiesNamespace.js +122 -0
- package/dist/cjs/new-sdk/opportunities/index.js +4 -0
- package/dist/cjs/new-sdk/opportunities/types.js +1 -0
- package/dist/cjs/new-sdk/package.json +1 -0
- package/dist/cjs/new-sdk/types.js +22 -0
- package/dist/cjs/new-sdk/utils/history.js +1 -0
- package/dist/cjs/new-sdk/utils/index.js +2 -0
- package/dist/cjs/offchain/GearboxAPI.js +33 -0
- package/dist/cjs/offchain/index.js +8 -0
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +97 -0
- package/dist/cjs/offchain/opportunities/index.js +4 -0
- package/dist/cjs/offchain/package.json +1 -0
- package/dist/cjs/offchain/types.js +1 -0
- package/dist/cjs/preview/preview/buildDelayedPreview.js +5 -5
- package/dist/cjs/rewards/rewards/api.js +2 -2
- package/dist/cjs/rewards/rewards/extra-apy.js +2 -2
- package/dist/cjs/sdk/MultichainSDK.js +18 -2
- package/dist/cjs/sdk/OnchainSDK.js +8 -1
- package/dist/cjs/sdk/accounts/index.js +2 -0
- package/dist/cjs/sdk/accounts/liquidations/LiquidationsService.js +150 -106
- package/dist/cjs/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/cjs/sdk/accounts/liquidations/constants.js +13 -0
- package/dist/cjs/sdk/accounts/liquidations/index.js +2 -0
- package/dist/cjs/sdk/base/MultichainConstruct.js +80 -0
- package/dist/cjs/sdk/base/TokensMeta.js +51 -0
- package/dist/cjs/sdk/base/index.js +2 -0
- package/dist/cjs/sdk/chain/chains.js +76 -0
- package/dist/cjs/sdk/chain/index.js +4 -0
- package/dist/cjs/sdk/core/errors.js +13 -0
- package/dist/cjs/sdk/core/index.js +2 -1
- package/dist/cjs/sdk/index.js +25 -1
- package/dist/cjs/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/cjs/sdk/market/MarketSuite.js +163 -0
- package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +102 -0
- package/dist/cjs/sdk/market/math.js +104 -0
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/cjs/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/cjs/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/cjs/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/cjs/sdk/market/pool/PoolV310Contract.js +27 -0
- package/dist/cjs/sdk/market/pool/math.js +44 -0
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- package/dist/cjs/sdk/opportunities/MultichainOpportunitiesService.js +60 -0
- package/dist/cjs/sdk/opportunities/OpportunitiesService.js +103 -0
- package/dist/cjs/sdk/opportunities/index.js +12 -0
- package/dist/cjs/sdk/types/multichain.js +1 -0
- package/dist/cjs/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/cjs/sdk/utils/index.js +3 -0
- package/dist/cjs/sdk/utils/zod.js +12 -0
- package/dist/esm/common-utils/index.js +1 -1
- package/dist/esm/common-utils/utils/apy/calculate-safe-borrow-rate.js +1 -1
- package/dist/esm/common-utils/utils/assets-math.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/calc-health-factor.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/debt.js +1 -1
- package/dist/esm/common-utils/utils/creditAccount/quota-utils.js +1 -1
- package/dist/esm/common-utils/utils/index.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-leverage-factor.js +1 -1
- package/dist/esm/common-utils/utils/strategies/leverage/calculate-max-strategy-debt.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/calculate-total-points.js +1 -1
- package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +1 -1
- package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +1 -1
- package/dist/esm/dev/AccountOpener.js +1 -1
- package/dist/esm/dev/index.js +3 -3
- package/dist/esm/dev/kycUtils.js +1 -1
- package/dist/esm/dev/midasUtils.js +105 -2
- package/dist/esm/dev/withdrawalUtils.js +1 -1
- package/dist/esm/model/history.js +26 -0
- package/dist/esm/model/history.schema.js +76 -0
- package/dist/esm/model/index.js +9 -0
- package/dist/esm/model/liquidations.js +22 -0
- package/dist/esm/model/liquidations.schema.js +83 -0
- package/dist/esm/model/opportunities.js +51 -0
- package/dist/esm/model/opportunities.schema.js +198 -0
- package/dist/esm/model/package.json +1 -0
- package/dist/esm/model/positions.js +1 -0
- package/dist/esm/model/primitives.js +1 -0
- package/dist/esm/model/primitives.schema.js +75 -0
- package/dist/esm/new-sdk/AbstractNamespace.js +157 -0
- package/dist/esm/new-sdk/GearboxSDK.js +121 -0
- package/dist/esm/new-sdk/index.js +7 -0
- package/dist/esm/new-sdk/opportunities/OpportunitiesNamespace.js +121 -0
- package/dist/esm/new-sdk/opportunities/index.js +3 -0
- package/dist/esm/new-sdk/opportunities/types.js +1 -0
- package/dist/esm/new-sdk/package.json +1 -0
- package/dist/esm/new-sdk/types.js +21 -0
- package/dist/esm/new-sdk/utils/history.js +1 -0
- package/dist/esm/new-sdk/utils/index.js +2 -0
- package/dist/esm/offchain/GearboxAPI.js +32 -0
- package/dist/esm/offchain/index.js +5 -0
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +95 -0
- package/dist/esm/offchain/opportunities/index.js +2 -0
- package/dist/esm/offchain/package.json +1 -0
- package/dist/esm/offchain/types.js +1 -0
- package/dist/esm/preview/preview/buildDelayedPreview.js +1 -1
- package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
- package/dist/esm/preview/trace/extractTransfers.js +1 -1
- package/dist/esm/rewards/rewards/api.js +1 -1
- package/dist/esm/rewards/rewards/extra-apy.js +1 -1
- package/dist/esm/sdk/MultichainSDK.js +18 -2
- package/dist/esm/sdk/OnchainSDK.js +8 -1
- package/dist/esm/sdk/accounts/CreditAccountsServiceV310.js +2 -2
- package/dist/esm/sdk/accounts/index.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +153 -109
- package/dist/esm/sdk/accounts/liquidations/MultichainLiquidationsService.js +32 -38
- package/dist/esm/sdk/accounts/liquidations/constants.js +12 -1
- package/dist/esm/sdk/accounts/liquidations/index.js +2 -2
- 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 +79 -0
- package/dist/esm/sdk/base/TokensMeta.js +53 -2
- package/dist/esm/sdk/base/index.js +2 -1
- package/dist/esm/sdk/chain/chains.js +74 -2
- 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/errors.js +13 -1
- package/dist/esm/sdk/core/index.js +2 -2
- package/dist/esm/sdk/index.js +11 -5
- package/dist/esm/sdk/market/MarketConfiguratorContract.js +14 -0
- package/dist/esm/sdk/market/MarketSuite.js +163 -0
- package/dist/esm/sdk/market/credit/CreditFacadeV310BaseContract.js +1 -1
- package/dist/esm/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/esm/sdk/market/credit/CreditSuite.js +102 -0
- package/dist/esm/sdk/market/math.js +98 -0
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +52 -0
- package/dist/esm/sdk/market/pool/LinearInterestRateModelContract.js +30 -0
- package/dist/esm/sdk/market/pool/PoolQuotaKeeperV310Contract.js +26 -0
- package/dist/esm/sdk/market/pool/PoolSuite.js +28 -0
- package/dist/esm/sdk/market/pool/PoolV310Contract.js +28 -1
- package/dist/esm/sdk/market/pool/math.js +41 -0
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- 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 +59 -0
- package/dist/esm/sdk/opportunities/OpportunitiesService.js +102 -0
- package/dist/esm/sdk/opportunities/index.js +4 -0
- package/dist/esm/sdk/pools/PoolService.js +1 -1
- package/dist/esm/sdk/types/multichain.js +1 -0
- package/dist/esm/{common-utils → sdk}/utils/bigint-math.js +11 -11
- package/dist/esm/sdk/utils/index.js +3 -2
- package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +1 -1
- package/dist/esm/sdk/utils/zod.js +13 -2
- package/dist/types/common-utils/index.d.ts +1 -1
- package/dist/types/common-utils/utils/index.d.ts +1 -1
- package/dist/types/dev/index.d.ts +2 -2
- package/dist/types/dev/midasUtils.d.ts +31 -2
- package/dist/types/model/history.d.ts +105 -0
- package/dist/types/model/history.schema.d.ts +66 -0
- package/dist/types/model/index.d.ts +9 -0
- package/dist/types/model/liquidations.d.ts +230 -0
- package/dist/types/model/liquidations.schema.d.ts +292 -0
- package/dist/types/model/opportunities.d.ts +543 -0
- package/dist/types/model/opportunities.schema.d.ts +1066 -0
- package/dist/types/model/positions.d.ts +11 -0
- package/dist/types/model/primitives.d.ts +193 -0
- package/dist/types/model/primitives.schema.d.ts +81 -0
- package/dist/types/new-sdk/AbstractNamespace.d.ts +119 -0
- package/dist/types/new-sdk/GearboxSDK.d.ts +78 -0
- package/dist/types/new-sdk/index.d.ts +9 -0
- package/dist/types/new-sdk/opportunities/OpportunitiesNamespace.d.ts +69 -0
- package/dist/types/new-sdk/opportunities/index.d.ts +3 -0
- package/dist/types/new-sdk/opportunities/types.d.ts +66 -0
- package/dist/types/new-sdk/types.d.ts +149 -0
- package/dist/types/new-sdk/utils/history.d.ts +44 -0
- package/dist/types/new-sdk/utils/index.d.ts +2 -0
- package/dist/types/offchain/GearboxAPI.d.ts +31 -0
- package/dist/types/offchain/index.d.ts +5 -0
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +69 -0
- package/dist/types/offchain/opportunities/index.d.ts +2 -0
- package/dist/types/offchain/types.d.ts +50 -0
- package/dist/types/sdk/MultichainSDK.d.ts +15 -2
- package/dist/types/sdk/OnchainSDK.d.ts +9 -3
- package/dist/types/sdk/accounts/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/LiquidationsService.d.ts +24 -16
- package/dist/types/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts +26 -20
- package/dist/types/sdk/accounts/liquidations/constants.d.ts +12 -1
- package/dist/types/sdk/accounts/liquidations/index.d.ts +3 -3
- package/dist/types/sdk/accounts/liquidations/types.d.ts +34 -309
- package/dist/types/sdk/base/MultichainConstruct.d.ts +57 -0
- package/dist/types/sdk/base/TokensMeta.d.ts +26 -0
- package/dist/types/sdk/base/index.d.ts +2 -1
- package/dist/types/sdk/chain/chains.d.ts +68 -1
- package/dist/types/sdk/chain/index.d.ts +2 -2
- package/dist/types/sdk/core/errors.d.ts +10 -1
- package/dist/types/sdk/core/index.d.ts +2 -2
- package/dist/types/sdk/index.d.ts +15 -8
- package/dist/types/sdk/market/MarketConfiguratorContract.d.ts +9 -0
- package/dist/types/sdk/market/MarketSuite.d.ts +109 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +47 -0
- package/dist/types/sdk/market/credit/types.d.ts +22 -0
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/math.d.ts +74 -0
- package/dist/types/sdk/market/oracle/PriceOracleBaseContract.d.ts +23 -0
- package/dist/types/sdk/market/oracle/types.d.ts +46 -0
- package/dist/types/sdk/market/pool/LinearInterestRateModelContract.d.ts +12 -0
- package/dist/types/sdk/market/pool/PoolQuotaKeeperV310Contract.d.ts +22 -1
- package/dist/types/sdk/market/pool/PoolSuite.d.ts +23 -0
- package/dist/types/sdk/market/pool/PoolV310Contract.d.ts +18 -0
- package/dist/types/sdk/market/pool/math.d.ts +57 -0
- package/dist/types/sdk/market/pool/types.d.ts +23 -0
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +6 -0
- package/dist/types/sdk/market/pricefeeds/types.d.ts +10 -0
- package/dist/types/sdk/opportunities/MultichainOpportunitiesService.d.ts +40 -0
- package/dist/types/sdk/opportunities/OpportunitiesService.d.ts +47 -0
- package/dist/types/sdk/opportunities/index.d.ts +4 -0
- package/dist/types/sdk/types/index.d.ts +2 -1
- package/dist/types/sdk/types/multichain.d.ts +65 -0
- package/dist/types/sdk/types/state.d.ts +1 -1
- package/dist/types/sdk/types/transactions.d.ts +3 -0
- package/dist/types/{common-utils → sdk}/utils/bigint-math.d.ts +7 -11
- package/dist/types/sdk/utils/index.d.ts +3 -2
- package/dist/types/sdk/utils/zod.d.ts +6 -2
- package/package.json +16 -1
- package/dist/cjs/sdk/accounts/liquidations/helpers.js +0 -201
- package/dist/esm/sdk/accounts/liquidations/helpers.js +0 -192
- package/dist/types/sdk/accounts/liquidations/helpers.d.ts +0 -140
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { ILogger } from "../sdk/types/logger.js";
|
|
2
|
+
import { NetworkType } from "../sdk/chain/chains.js";
|
|
3
|
+
import { MultichainNetworkMeta } from "../sdk/types/multichain.js";
|
|
4
|
+
import { MultichainAttachOptions, MultichainSDK, MultichainSDKOptions } from "../sdk/MultichainSDK.js";
|
|
5
|
+
import "../sdk/index.js";
|
|
6
|
+
import { GearboxAPIOptions } from "../offchain/types.js";
|
|
7
|
+
import { GearboxAPI } from "../offchain/GearboxAPI.js";
|
|
8
|
+
import "../offchain/index.js";
|
|
9
|
+
//#region src/new-sdk/types.d.ts
|
|
10
|
+
/**
|
|
11
|
+
* Which sources a {@link GearboxSDK} reads from. Fixed at construction: a
|
|
12
|
+
* running instance never changes mode, and the mode decides which methods
|
|
13
|
+
* exist at all rather than what they return.
|
|
14
|
+
**/
|
|
15
|
+
type Mode = "onchain" | "offchain" | "both";
|
|
16
|
+
/**
|
|
17
|
+
* Outcome of the off-chain read behind a response.
|
|
18
|
+
**/
|
|
19
|
+
interface OffchainSourceStatus {
|
|
20
|
+
/**
|
|
21
|
+
* Whether the backend served the request.
|
|
22
|
+
**/
|
|
23
|
+
status: "success" | "error";
|
|
24
|
+
/**
|
|
25
|
+
* Rejection reason. Only set when {@link status} is `"error"`.
|
|
26
|
+
**/
|
|
27
|
+
error?: unknown;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Which sources produced a response and which of them failed.
|
|
31
|
+
*
|
|
32
|
+
* Meta is always present, in every mode. A partial answer is the normal case
|
|
33
|
+
* for a multi-chain read, so a caller that ignores this block is choosing to
|
|
34
|
+
* treat "one chain is down" as "these opportunities do not exist".
|
|
35
|
+
**/
|
|
36
|
+
interface SourceMeta {
|
|
37
|
+
/**
|
|
38
|
+
* Outcome per queried chain. Empty when the read touched no chain, either
|
|
39
|
+
* because the SDK is off-chain or because a filter selected no chain.
|
|
40
|
+
**/
|
|
41
|
+
chains: MultichainNetworkMeta[];
|
|
42
|
+
/**
|
|
43
|
+
* Outcome of the off-chain read, absent when the SDK has no backend source.
|
|
44
|
+
**/
|
|
45
|
+
offchain?: OffchainSourceStatus;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* What every {@link GearboxSDK} read returns.
|
|
49
|
+
*
|
|
50
|
+
* @typeParam T - Payload type.
|
|
51
|
+
**/
|
|
52
|
+
interface ReadResult<T> {
|
|
53
|
+
/**
|
|
54
|
+
* Requested payload, built from every source that answered.
|
|
55
|
+
**/
|
|
56
|
+
result: T;
|
|
57
|
+
/**
|
|
58
|
+
* Which sources produced it, see {@link SourceMeta}.
|
|
59
|
+
**/
|
|
60
|
+
meta: SourceMeta;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Thrown when a read had sources to ask and none of them answered.
|
|
64
|
+
*
|
|
65
|
+
* A read that partially succeeded never throws: it returns what it has and
|
|
66
|
+
* reports the rest in {@link SourceMeta}.
|
|
67
|
+
**/
|
|
68
|
+
declare class AllSourcesFailedError extends Error {
|
|
69
|
+
/**
|
|
70
|
+
* Outcome of every source the failed read asked.
|
|
71
|
+
**/
|
|
72
|
+
readonly meta: SourceMeta;
|
|
73
|
+
constructor(action: string, meta: SourceMeta);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* On-chain source of a {@link GearboxSDK}: either an already-attached SDK to
|
|
77
|
+
* reuse, or the options to build one with.
|
|
78
|
+
*
|
|
79
|
+
* An injected instance is never re-attached — its owner decides when it syncs.
|
|
80
|
+
**/
|
|
81
|
+
type OnchainSource = MultichainSDK | PlainMultichainSDKOptions;
|
|
82
|
+
/**
|
|
83
|
+
* {@link MultichainSDKOptions} without plugin typing.
|
|
84
|
+
*
|
|
85
|
+
* The facade exposes the on-chain SDK as a plain `MultichainSDK`; a consumer
|
|
86
|
+
* that injects a plugin-typed instance keeps its own typed reference to it.
|
|
87
|
+
**/
|
|
88
|
+
type PlainMultichainSDKOptions = MultichainSDKOptions<{}>;
|
|
89
|
+
/**
|
|
90
|
+
* Off-chain source of a {@link GearboxSDK}: either a client to reuse or the
|
|
91
|
+
* options to build one with.
|
|
92
|
+
**/
|
|
93
|
+
type OffchainSource = GearboxAPI | GearboxAPIOptions;
|
|
94
|
+
/**
|
|
95
|
+
* Options for creating a {@link GearboxSDK}.
|
|
96
|
+
*
|
|
97
|
+
* @typeParam M - Mode, which decides which sources are required.
|
|
98
|
+
**/
|
|
99
|
+
interface GearboxSDKOptions<M extends Mode = Mode> {
|
|
100
|
+
/**
|
|
101
|
+
* Sources to read from, see {@link Mode}.
|
|
102
|
+
**/
|
|
103
|
+
mode: M;
|
|
104
|
+
/**
|
|
105
|
+
* Chains the SDK covers. This list is authoritative: when {@link onchain} is
|
|
106
|
+
* an already-attached instance covering a different set of chains, the
|
|
107
|
+
* mismatch is logged and this list still decides what is read.
|
|
108
|
+
**/
|
|
109
|
+
networks: NetworkType[];
|
|
110
|
+
/**
|
|
111
|
+
* On-chain source. Required in `onchain` and `both` mode.
|
|
112
|
+
**/
|
|
113
|
+
onchain?: OnchainSource;
|
|
114
|
+
/**
|
|
115
|
+
* Off-chain source. Required in `offchain` and `both` mode.
|
|
116
|
+
**/
|
|
117
|
+
offchain?: OffchainSource;
|
|
118
|
+
/**
|
|
119
|
+
* Options passed to {@link MultichainSDK.attach}, used only when the SDK
|
|
120
|
+
* builds the on-chain source itself.
|
|
121
|
+
**/
|
|
122
|
+
attach?: MultichainAttachOptions;
|
|
123
|
+
/**
|
|
124
|
+
* Logger for source selection and degradation diagnostics.
|
|
125
|
+
**/
|
|
126
|
+
logger?: ILogger;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* On-chain escape hatch per mode: absent when the SDK reads no chain.
|
|
130
|
+
*
|
|
131
|
+
* @internal
|
|
132
|
+
**/
|
|
133
|
+
interface OnchainByMode {
|
|
134
|
+
onchain: MultichainSDK;
|
|
135
|
+
offchain: undefined;
|
|
136
|
+
both: MultichainSDK;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Off-chain escape hatch per mode: absent when the SDK reads no backend.
|
|
140
|
+
*
|
|
141
|
+
* @internal
|
|
142
|
+
**/
|
|
143
|
+
interface OffchainByMode {
|
|
144
|
+
onchain: undefined;
|
|
145
|
+
offchain: GearboxAPI;
|
|
146
|
+
both: GearboxAPI;
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { AllSourcesFailedError, GearboxSDKOptions, Mode, OffchainByMode, OffchainSource, OffchainSourceStatus, OnchainByMode, OnchainSource, PlainMultichainSDKOptions, ReadResult, SourceMeta };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange } from "../../model/history.js";
|
|
2
|
+
import "../../model/index.js";
|
|
3
|
+
import { SourceMeta } from "../types.js";
|
|
4
|
+
//#region src/new-sdk/utils/history.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Everything that annotates a chart: what the backend said about the series,
|
|
7
|
+
* plus which sources produced it.
|
|
8
|
+
**/
|
|
9
|
+
interface ChartMetadata extends HistoryChartMetadata {
|
|
10
|
+
/**
|
|
11
|
+
* Which sources answered, see {@link SourceMeta}. A chart is backend-only,
|
|
12
|
+
* so this reports the backend alone.
|
|
13
|
+
**/
|
|
14
|
+
source: SourceMeta;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* One chart: the points to draw and everything that annotates them.
|
|
18
|
+
**/
|
|
19
|
+
interface Chart {
|
|
20
|
+
/**
|
|
21
|
+
* Samples, oldest first.
|
|
22
|
+
**/
|
|
23
|
+
data: HistoryPoint[];
|
|
24
|
+
/**
|
|
25
|
+
* Annotations of the series, see {@link ChartMetadata}.
|
|
26
|
+
**/
|
|
27
|
+
metadata: ChartMetadata;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Reads the charts of one subject, one metric and one range at a time.
|
|
31
|
+
*
|
|
32
|
+
* @typeParam Metric - Metrics the subject has.
|
|
33
|
+
**/
|
|
34
|
+
interface HistoryReader<Metric extends HistoryMetric> {
|
|
35
|
+
/**
|
|
36
|
+
* Historical chart of one metric over one window.
|
|
37
|
+
*
|
|
38
|
+
* A metric the subject does not have is a compile error rather than an empty
|
|
39
|
+
* chart.
|
|
40
|
+
**/
|
|
41
|
+
chart(metric: Metric, range: HistoryRange): Promise<Chart>;
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Chart, ChartMetadata, HistoryReader };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { GearboxAPIOptions } from "./types.js";
|
|
2
|
+
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
3
|
+
import "./opportunities/index.js";
|
|
4
|
+
//#region src/offchain/GearboxAPI.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Client for the Gearbox backend, the off-chain source of the read model.
|
|
7
|
+
*
|
|
8
|
+
* It mirrors the namespace layout of the combined `GearboxSDK`, so the same
|
|
9
|
+
* call reads the same way against either source:
|
|
10
|
+
*
|
|
11
|
+
* ```ts
|
|
12
|
+
* const api = new GearboxAPI({ baseUrl: "https://api.gearbox.fi" });
|
|
13
|
+
* const { result } = await api.opportunities.list({ kind: "strategy" });
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* The backend imports the read model from this package and its endpoints
|
|
17
|
+
* return those types directly, so there is no wire DTO layer here — only
|
|
18
|
+
* transport and schema validation.
|
|
19
|
+
*
|
|
20
|
+
* The transport is not implemented yet; see {@link OffchainOpportunities} for
|
|
21
|
+
* what each stubbed endpoint currently answers.
|
|
22
|
+
**/
|
|
23
|
+
declare class GearboxAPI {
|
|
24
|
+
/**
|
|
25
|
+
* Namespace for pool and strategy opportunities.
|
|
26
|
+
**/
|
|
27
|
+
readonly opportunities: OffchainOpportunities;
|
|
28
|
+
constructor(options?: GearboxAPIOptions);
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { GearboxAPI };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { GearboxAPIOptions, OffchainResult, OffchainSourceMeta } from "./types.js";
|
|
2
|
+
import { OffchainNotImplementedError, OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
3
|
+
import "./opportunities/index.js";
|
|
4
|
+
import { GearboxAPI } from "./GearboxAPI.js";
|
|
5
|
+
export { GearboxAPI, GearboxAPIOptions, OffchainNotImplementedError, OffchainOpportunities, OffchainResult, OffchainSourceMeta };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Opportunity, OpportunityFilter, PoolOpportunityDetail, PoolOpportunityKey, StrategyOpportunityDetail, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
2
|
+
import { HistoryMetric, HistorySeries, OpportunityHistoryQuery } from "../../model/history.js";
|
|
3
|
+
import { GearboxAPIOptions, OffchainResult } from "../types.js";
|
|
4
|
+
//#region src/offchain/opportunities/OffchainOpportunities.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Thrown by the endpoints that have no stub answer, so that a caller in
|
|
7
|
+
* `offchain` mode fails loudly instead of reading an empty detail page as a
|
|
8
|
+
* missing opportunity.
|
|
9
|
+
**/
|
|
10
|
+
declare class OffchainNotImplementedError extends Error {
|
|
11
|
+
constructor(endpoint: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Backend counterpart of the `opportunities` namespace.
|
|
15
|
+
*
|
|
16
|
+
* This is a stub: the HTTP client is not written yet, so list reads answer with
|
|
17
|
+
* an empty list and detail reads throw. Every signature is already the final
|
|
18
|
+
* one, because the backend returns the read model types directly — there is no
|
|
19
|
+
* wire DTO and no mapper between the two.
|
|
20
|
+
*
|
|
21
|
+
* When the transport lands, each method will validate the response against the
|
|
22
|
+
* matching schema from `src/model` before returning it. A validation failure is
|
|
23
|
+
* a version-skew error and is handled exactly like a transport error: the
|
|
24
|
+
* combined SDK drops the backend's contribution in `both` mode and rethrows in
|
|
25
|
+
* `offchain` mode.
|
|
26
|
+
**/
|
|
27
|
+
declare class OffchainOpportunities {
|
|
28
|
+
#private;
|
|
29
|
+
constructor(options?: GearboxAPIOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Base URL the client will call once the transport is implemented.
|
|
32
|
+
**/
|
|
33
|
+
get baseUrl(): string | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* All opportunities the backend knows about, optionally narrowed by
|
|
36
|
+
* {@link OpportunityFilter}.
|
|
37
|
+
*
|
|
38
|
+
* @returns An empty list until the backend client is implemented.
|
|
39
|
+
**/
|
|
40
|
+
list(filter?: OpportunityFilter): Promise<OffchainResult<Opportunity[]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Detailed view of one pool opportunity.
|
|
43
|
+
*
|
|
44
|
+
* @throws {@link OffchainNotImplementedError} until the backend client is
|
|
45
|
+
* implemented.
|
|
46
|
+
**/
|
|
47
|
+
getPool(key: PoolOpportunityKey): Promise<OffchainResult<PoolOpportunityDetail>>;
|
|
48
|
+
/**
|
|
49
|
+
* Detailed view of one strategy opportunity.
|
|
50
|
+
*
|
|
51
|
+
* @throws {@link OffchainNotImplementedError} until the backend client is
|
|
52
|
+
* implemented.
|
|
53
|
+
**/
|
|
54
|
+
getStrategy(key: StrategyOpportunityKey): Promise<OffchainResult<StrategyOpportunityDetail>>;
|
|
55
|
+
/**
|
|
56
|
+
* One historical series of one opportunity. History exists only here:
|
|
57
|
+
* rebuilding it from the chain would mean an archive read per point.
|
|
58
|
+
*
|
|
59
|
+
* The requested metric types the response, so a caller asking for one metric
|
|
60
|
+
* does not have to narrow the union back down. When the transport lands,
|
|
61
|
+
* validation is what upholds it: a response carrying a different metric than
|
|
62
|
+
* the one asked for is a version-skew error like any other.
|
|
63
|
+
*
|
|
64
|
+
* @returns An empty series until the backend client is implemented.
|
|
65
|
+
**/
|
|
66
|
+
getHistory<M extends HistoryMetric>(query: OpportunityHistoryQuery<M>): Promise<OffchainResult<HistorySeries<M>>>;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { OffchainNotImplementedError, OffchainOpportunities };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ILogger } from "../sdk/types/logger.js";
|
|
2
|
+
//#region src/offchain/types.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Outcome of the single request that serves a backend read. Unlike the
|
|
5
|
+
* on-chain source there is no per-chain breakdown here: one HTTP call covers
|
|
6
|
+
* every chain, so splitting it per chain would be fabricated.
|
|
7
|
+
**/
|
|
8
|
+
interface OffchainSourceMeta {
|
|
9
|
+
/**
|
|
10
|
+
* Whether the backend served the request.
|
|
11
|
+
**/
|
|
12
|
+
status: "success" | "error";
|
|
13
|
+
/**
|
|
14
|
+
* Rejection reason. Only set when {@link status} is `"error"`.
|
|
15
|
+
**/
|
|
16
|
+
error?: unknown;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* What every {@link GearboxAPI} read returns: the payload plus the outcome of
|
|
20
|
+
* the request that produced it, in the same shape the combined SDK exposes.
|
|
21
|
+
*
|
|
22
|
+
* @typeParam T - Payload type.
|
|
23
|
+
**/
|
|
24
|
+
interface OffchainResult<T> {
|
|
25
|
+
/**
|
|
26
|
+
* Requested payload.
|
|
27
|
+
**/
|
|
28
|
+
result: T;
|
|
29
|
+
/**
|
|
30
|
+
* Outcome of the backend request.
|
|
31
|
+
**/
|
|
32
|
+
meta: OffchainSourceMeta;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Options for creating a {@link GearboxAPI} instance.
|
|
36
|
+
**/
|
|
37
|
+
interface GearboxAPIOptions {
|
|
38
|
+
/**
|
|
39
|
+
* Base URL of the Gearbox backend, without a trailing slash.
|
|
40
|
+
*
|
|
41
|
+
* @example `"https://api.gearbox.fi"`
|
|
42
|
+
**/
|
|
43
|
+
baseUrl?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Logger used for transport and validation diagnostics.
|
|
46
|
+
**/
|
|
47
|
+
logger?: ILogger;
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { GearboxAPIOptions, OffchainResult, OffchainSourceMeta };
|
|
@@ -6,10 +6,12 @@ import { MultichainStateHuman } from "./types/state-human.js";
|
|
|
6
6
|
import { PythOptions } from "./market/pricefeeds/updates/PythUpdater.js";
|
|
7
7
|
import { RedstoneOptions } from "./market/pricefeeds/updates/RedstoneUpdater.js";
|
|
8
8
|
import "./market/pricefeeds/updates/index.js";
|
|
9
|
+
import { MultichainOpportunitiesService } from "./opportunities/MultichainOpportunitiesService.js";
|
|
10
|
+
import "./opportunities/index.js";
|
|
9
11
|
import { AttachOptions, ClientOptions, HydrateOptions, OnchainSDK } from "./OnchainSDK.js";
|
|
10
12
|
import { MultichainState } from "./types/state.js";
|
|
11
13
|
import "./types/index.js";
|
|
12
|
-
import {
|
|
14
|
+
import { MultichainLiquidationsService } from "./accounts/liquidations/MultichainLiquidationsService.js";
|
|
13
15
|
import "./accounts/index.js";
|
|
14
16
|
//#region src/sdk/MultichainSDK.d.ts
|
|
15
17
|
/**
|
|
@@ -115,7 +117,12 @@ declare class MultichainSDK<const Plugins extends PluginsMap = {}> {
|
|
|
115
117
|
* Namespace for liquidatable credit accounts discovery across all
|
|
116
118
|
* configured chains.
|
|
117
119
|
*/
|
|
118
|
-
readonly liquidations:
|
|
120
|
+
readonly liquidations: MultichainLiquidationsService<Plugins>;
|
|
121
|
+
/**
|
|
122
|
+
* Namespace for the pool and strategy opportunities of all configured
|
|
123
|
+
* chains.
|
|
124
|
+
*/
|
|
125
|
+
readonly opportunities: MultichainOpportunitiesService<Plugins>;
|
|
119
126
|
constructor(options: MultichainSDKOptions<Plugins>);
|
|
120
127
|
/**
|
|
121
128
|
* Attach all configured chains in parallel.
|
|
@@ -144,6 +151,12 @@ declare class MultichainSDK<const Plugins extends PluginsMap = {}> {
|
|
|
144
151
|
* Read-only map of all configured chains.
|
|
145
152
|
**/
|
|
146
153
|
get chains(): ReadonlyMap<NetworkType, OnchainSDK<Plugins>>;
|
|
154
|
+
/**
|
|
155
|
+
* Shared logger, used for messages that are not attributable to a single
|
|
156
|
+
* chain. Per-chain messages should use the logger of the corresponding
|
|
157
|
+
* {@link OnchainSDK}.
|
|
158
|
+
**/
|
|
159
|
+
get logger(): ILogger | undefined;
|
|
147
160
|
/**
|
|
148
161
|
* Sync state for all chains in parallel.
|
|
149
162
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ILogger } from "./types/logger.js";
|
|
2
|
-
import { IRedemptionLoggerContract, IWithdrawalCompressorContract } from "./accounts/withdrawal-compressor/types.js";
|
|
3
2
|
import { GearboxChain, NetworkType } from "./chain/chains.js";
|
|
3
|
+
import { IRedemptionLoggerContract, IWithdrawalCompressorContract } from "./accounts/withdrawal-compressor/types.js";
|
|
4
4
|
import { BaseState, IBaseContract } from "./base/types.js";
|
|
5
5
|
import { VersionRange } from "./constants/versions.js";
|
|
6
6
|
import "./constants/index.js";
|
|
@@ -18,6 +18,8 @@ import { PriceFeedRegister } from "./market/pricefeeds/PriceFeedsRegister.js";
|
|
|
18
18
|
import "./market/pricefeeds/index.js";
|
|
19
19
|
import { MarketRegister } from "./market/MarketRegister.js";
|
|
20
20
|
import "./market/index.js";
|
|
21
|
+
import { OpportunitiesService } from "./opportunities/OpportunitiesService.js";
|
|
22
|
+
import "./opportunities/index.js";
|
|
21
23
|
import { IPoolsService } from "./pools/types.js";
|
|
22
24
|
import "./pools/index.js";
|
|
23
25
|
import { ChainContractsRegister } from "./base/ChainContractsRegister.js";
|
|
@@ -26,7 +28,7 @@ import "./core/index.js";
|
|
|
26
28
|
import { GearboxState } from "./types/state.js";
|
|
27
29
|
import "./types/index.js";
|
|
28
30
|
import "./base/index.js";
|
|
29
|
-
import {
|
|
31
|
+
import { LiquidationsService } from "./accounts/liquidations/LiquidationsService.js";
|
|
30
32
|
import "./accounts/index.js";
|
|
31
33
|
import { Address, PublicClient, Transport } from "viem";
|
|
32
34
|
import { HttpRpcClientOptions } from "viem/utils";
|
|
@@ -210,7 +212,11 @@ declare class OnchainSDK<const Plugins extends PluginsMap = {}> extends ChainCon
|
|
|
210
212
|
/**
|
|
211
213
|
* Namespace for liquidatable credit accounts discovery.
|
|
212
214
|
*/
|
|
213
|
-
readonly liquidations:
|
|
215
|
+
readonly liquidations: LiquidationsService;
|
|
216
|
+
/**
|
|
217
|
+
* Namespace for the pool and strategy opportunities of this chain.
|
|
218
|
+
*/
|
|
219
|
+
readonly opportunities: OpportunitiesService;
|
|
214
220
|
/**
|
|
215
221
|
* @param network - Gearbox network type (e.g. `"Mainnet"`, `"Monad"`).
|
|
216
222
|
* @param clientOptions - Connection options (RPC URLs, transport, or client).
|
|
@@ -12,9 +12,9 @@ import { WithdrawalCompressorV313Contract } from "./withdrawal-compressor/Withdr
|
|
|
12
12
|
import "./withdrawal-compressor/index.js";
|
|
13
13
|
import { AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountFilter, CreditAccountOperationResult, CreditAccountTokensSlice, CreditManagerFilter, CreditManagerOperationResult, DefaultPartialLiquidationParams, EncodableCreditAccountOperation, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, ICreditAccountsService, OpenCAProps, PartiallyLiquidateProps, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps } from "./types.js";
|
|
14
14
|
import { CreditAccountServiceOptions, CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
15
|
-
import { LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
16
|
-
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase,
|
|
15
|
+
import { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
16
|
+
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo } from "./liquidations/types.js";
|
|
17
17
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
18
18
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
19
19
|
import "./liquidations/index.js";
|
|
20
|
-
export { AbstractWithdrawalCompressorContract, AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountFilter, CreditAccountOperationResult, CreditAccountServiceOptions, CreditAccountTokensSlice, CreditAccountsServiceV310, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DefaultPartialLiquidationParams, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended,
|
|
20
|
+
export { AbstractWithdrawalCompressorContract, AccountToCheck, AddCollateralProps, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, ChangeDeptProps, ClaimDelayedProps, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountProps, CloseCreditAccountResult, CloseOptions, CreditAccountFilter, CreditAccountOperationResult, CreditAccountServiceOptions, CreditAccountTokensSlice, CreditAccountsServiceV310, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DefaultPartialLiquidationParams, DelayedAddCollateralIntent, DelayedCloseAccountIntent, DelayedDecreaseLeverageIntent, DelayedDepositAndIncreaseLeverageIntent, DelayedDepositIntent, DelayedIncreaseLeverageIntent, DelayedIntent, DelayedIntentExtended, DelayedWithdrawCollateralIntent, EncodableCreditAccountOperation, ExecuteSwapProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, LoadRWALiquidatorsProps, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, PartiallyLiquidateProps, PendingWithdrawal, PermitResult, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, RepayAndLiquidateCreditAccountProps, RepayCreditAccountProps, RequestableWithdrawal, Rewards, SetBotProps, StartDelayedWithdrawalProps, UpdateQuotasProps, WithdrawCollateralProps, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
@@ -1,36 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "
|
|
1
|
+
import { TxCall } from "../../../model/primitives.js";
|
|
2
|
+
import { LiquidatableAccount, LiquidationDetails, LiquidationPosition } from "../../../model/liquidations.js";
|
|
3
|
+
import "../../../model/index.js";
|
|
3
4
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
4
5
|
import "../../base/index.js";
|
|
5
|
-
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps,
|
|
6
|
+
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps } from "./types.js";
|
|
6
7
|
//#region src/sdk/accounts/liquidations/LiquidationsService.d.ts
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* Discovers liquidatable credit accounts (health factor below 1 plus accounts
|
|
11
|
-
* of expired credit managers with outstanding debt) and previews what a
|
|
12
|
-
* manual liquidation pays and receives.
|
|
9
|
+
* Service for discovering liquidatable credit accounts and previewing manual
|
|
10
|
+
* liquidations.
|
|
13
11
|
**/
|
|
14
|
-
declare class LiquidationsService extends SDKConstruct
|
|
12
|
+
declare class LiquidationsService extends SDKConstruct {
|
|
15
13
|
#private;
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* Returns all liquidatable credit accounts: accounts with health factor
|
|
16
|
+
* below 1 plus accounts of expired credit managers with outstanding debt.
|
|
17
|
+
* Accounts whose collateral computation failed are excluded.
|
|
18
18
|
**/
|
|
19
19
|
getLiquidatableAccounts(props?: GetLiquidatableAccountsProps): Promise<LiquidatableAccount[]>;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Returns detailed information about a liquidatable credit account,
|
|
22
|
+
* including the full list of assets the liquidator receives.
|
|
23
|
+
*
|
|
24
|
+
* @throws When the account is not found or its collateral computation fails.
|
|
22
25
|
**/
|
|
23
26
|
getLiquidationDetails(props: GetLiquidationDetailsProps): Promise<LiquidationDetails>;
|
|
24
27
|
/**
|
|
25
|
-
*
|
|
28
|
+
* Builds the transaction that fully liquidates a credit account, repaying
|
|
29
|
+
* the debt from own funds and receiving the collateral from the credit account.
|
|
26
30
|
**/
|
|
27
|
-
buildLiquidationTx(props: BuildLiquidationTxProps): Promise<
|
|
31
|
+
buildLiquidationTx(props: BuildLiquidationTxProps): Promise<TxCall>;
|
|
28
32
|
/**
|
|
29
|
-
*
|
|
33
|
+
* Returns the status of delayed-withdrawal positions (redemption receipts)
|
|
34
|
+
* owned by a liquidator wallet: what is receivable, how much, and when it
|
|
35
|
+
* becomes claimable.
|
|
30
36
|
**/
|
|
31
|
-
|
|
37
|
+
getLiquidationPositions(props: GetLiquidationPositionsProps): Promise<LiquidationPosition[]>;
|
|
32
38
|
/**
|
|
33
|
-
*
|
|
39
|
+
* Discovers the dedicated RWA liquidator contracts (Securitize, Midas)
|
|
40
|
+
* deployed for the markets of the chain and registers them in the SDK
|
|
41
|
+
* contracts register.
|
|
34
42
|
**/
|
|
35
43
|
loadRWALiquidators(): Promise<void>;
|
|
36
44
|
}
|
|
@@ -1,41 +1,47 @@
|
|
|
1
|
+
import { TxCall } from "../../../model/primitives.js";
|
|
2
|
+
import { MultichainResult } from "../../types/multichain.js";
|
|
1
3
|
import { PluginsMap } from "../../plugins/types.js";
|
|
2
4
|
import "../../plugins/index.js";
|
|
3
|
-
import {
|
|
5
|
+
import { LiquidatableAccount, LiquidationDetails, LiquidationPosition } from "../../../model/liquidations.js";
|
|
6
|
+
import "../../../model/index.js";
|
|
4
7
|
import "../../types/index.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
8
|
+
import { MultichainConstruct } from "../../base/MultichainConstruct.js";
|
|
9
|
+
import "../../base/index.js";
|
|
10
|
+
import { BuildLiquidationTxProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationPositionsProps, LoadRWALiquidatorsProps } from "./types.js";
|
|
7
11
|
//#region src/sdk/accounts/liquidations/MultichainLiquidationsService.d.ts
|
|
8
12
|
/**
|
|
9
|
-
* Cross-chain
|
|
13
|
+
* Cross-chain counterpart of {@link LiquidationsService}.
|
|
10
14
|
*
|
|
11
|
-
*
|
|
12
|
-
* {@link
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
+
* Fans out over all chains configured in {@link MultichainSDK} (optionally
|
|
16
|
+
* restricted via {@link MultichainNetworksProps.networks}). A failed chain is
|
|
17
|
+
* logged as a warning and skipped, so one dead RPC does not empty the whole
|
|
18
|
+
* list; its failure is reported in {@link MultichainResult.meta}. Networks that
|
|
19
|
+
* are not configured in the SDK are reported there the same way.
|
|
15
20
|
**/
|
|
16
|
-
declare class MultichainLiquidationsService<const Plugins extends PluginsMap = {}>
|
|
17
|
-
#private;
|
|
18
|
-
constructor(sdk: MultichainSDK<Plugins>);
|
|
21
|
+
declare class MultichainLiquidationsService<const Plugins extends PluginsMap = {}> extends MultichainConstruct<Plugins> {
|
|
19
22
|
/**
|
|
20
|
-
*
|
|
23
|
+
* Accounts of all queried chains, see
|
|
24
|
+
* {@link LiquidationsService.getLiquidatableAccounts}.
|
|
21
25
|
**/
|
|
22
|
-
getLiquidatableAccounts(props?: GetLiquidatableAccountsProps<true>): Promise<LiquidatableAccount[]
|
|
26
|
+
getLiquidatableAccounts(props?: GetLiquidatableAccountsProps<true>): Promise<MultichainResult<LiquidatableAccount[]>>;
|
|
23
27
|
/**
|
|
24
|
-
* {@inheritDoc
|
|
28
|
+
* {@inheritDoc LiquidationsService.getLiquidationDetails}
|
|
25
29
|
**/
|
|
26
30
|
getLiquidationDetails(props: GetLiquidationDetailsProps<true>): Promise<LiquidationDetails>;
|
|
27
31
|
/**
|
|
28
|
-
* {@inheritDoc
|
|
32
|
+
* {@inheritDoc LiquidationsService.buildLiquidationTx}
|
|
29
33
|
**/
|
|
30
|
-
buildLiquidationTx(props: BuildLiquidationTxProps<true>): Promise<
|
|
34
|
+
buildLiquidationTx(props: BuildLiquidationTxProps<true>): Promise<TxCall>;
|
|
31
35
|
/**
|
|
32
|
-
*
|
|
36
|
+
* Liquidation positions of all queried chains, see
|
|
37
|
+
* {@link LiquidationsService.getLiquidationPositions}.
|
|
33
38
|
**/
|
|
34
|
-
|
|
39
|
+
getLiquidationPositions(props: GetLiquidationPositionsProps<true>): Promise<MultichainResult<LiquidationPosition[]>>;
|
|
35
40
|
/**
|
|
36
|
-
*
|
|
41
|
+
* Loads the liquidators of all queried chains, see
|
|
42
|
+
* {@link LiquidationsService.loadRWALiquidators}.
|
|
37
43
|
**/
|
|
38
|
-
loadRWALiquidators(props?: LoadRWALiquidatorsProps<true>): Promise<void
|
|
44
|
+
loadRWALiquidators(props?: LoadRWALiquidatorsProps<true>): Promise<MultichainResult<void>>;
|
|
39
45
|
}
|
|
40
46
|
//#endregion
|
|
41
47
|
export { MultichainLiquidationsService };
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
//#region src/sdk/accounts/liquidations/constants.d.ts
|
|
3
3
|
declare const LIQUIDATION_COMPRESSOR_V313_ADDRESS: Address;
|
|
4
|
+
/**
|
|
5
|
+
* Token balances at or below this threshold are treated as dust and ignored,
|
|
6
|
+
* consistent with the rest of the SDK (see `filterDust`).
|
|
7
|
+
**/
|
|
8
|
+
declare const DUST_THRESHOLD = 10n;
|
|
9
|
+
/**
|
|
10
|
+
* Headroom (in bps) added on top of the amount the liquidation pulls when
|
|
11
|
+
* building the liquidator's approval, so that the transaction does not revert
|
|
12
|
+
* when prices move between the preview and the execution.
|
|
13
|
+
**/
|
|
14
|
+
declare const LIQUIDATION_APPROVAL_BUFFER = 50n;
|
|
4
15
|
//#endregion
|
|
5
|
-
export { LIQUIDATION_COMPRESSOR_V313_ADDRESS };
|
|
16
|
+
export { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
2
|
-
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase,
|
|
1
|
+
import { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./constants.js";
|
|
2
|
+
import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LoadRWALiquidatorsProps, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo } from "./types.js";
|
|
3
3
|
import { LiquidationsService } from "./LiquidationsService.js";
|
|
4
4
|
import { MultichainLiquidationsService } from "./MultichainLiquidationsService.js";
|
|
5
|
-
export { BuildLiquidationTxProps, BuildLiquidationTxPropsBase,
|
|
5
|
+
export { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, DUST_THRESHOLD, GetLiquidatableAccountsProps, GetLiquidatableAccountsPropsBase, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, LoadRWALiquidatorsProps, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, RWALiquidatorInfo };
|