@gearbox-protocol/sdk 14.12.0-next.66 → 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/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/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/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/index.js +2 -2
- package/dist/esm/sdk/accounts/liquidations/LiquidationsService.js +152 -108
- 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/base/MultichainConstruct.js +79 -0
- package/dist/esm/sdk/base/TokensMeta.js +51 -0
- package/dist/esm/sdk/base/index.js +2 -1
- package/dist/esm/sdk/chain/chains.js +74 -2
- package/dist/esm/sdk/chain/index.js +2 -2
- 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/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 +27 -0
- package/dist/esm/sdk/market/pool/math.js +41 -0
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +17 -0
- 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/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/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/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,21 @@
|
|
|
1
|
+
//#region src/new-sdk/types.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when a read had sources to ask and none of them answered.
|
|
4
|
+
*
|
|
5
|
+
* A read that partially succeeded never throws: it returns what it has and
|
|
6
|
+
* reports the rest in {@link SourceMeta}.
|
|
7
|
+
**/
|
|
8
|
+
var AllSourcesFailedError = class extends Error {
|
|
9
|
+
/**
|
|
10
|
+
* Outcome of every source the failed read asked.
|
|
11
|
+
**/
|
|
12
|
+
meta;
|
|
13
|
+
constructor(action, meta) {
|
|
14
|
+
const reasons = [...meta.chains.filter((c) => c.status === "error").map((c) => `${c.network}: ${c.error}`), ...meta.offchain?.status === "error" ? [`offchain: ${meta.offchain.error}`] : []];
|
|
15
|
+
super(`cannot ${action}, every source failed (${reasons.join("; ")})`);
|
|
16
|
+
this.name = "AllSourcesFailedError";
|
|
17
|
+
this.meta = meta;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { AllSourcesFailedError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
2
|
+
import "./opportunities/index.js";
|
|
3
|
+
//#region src/offchain/GearboxAPI.ts
|
|
4
|
+
/**
|
|
5
|
+
* Client for the Gearbox backend, the off-chain source of the read model.
|
|
6
|
+
*
|
|
7
|
+
* It mirrors the namespace layout of the combined `GearboxSDK`, so the same
|
|
8
|
+
* call reads the same way against either source:
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const api = new GearboxAPI({ baseUrl: "https://api.gearbox.fi" });
|
|
12
|
+
* const { result } = await api.opportunities.list({ kind: "strategy" });
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* The backend imports the read model from this package and its endpoints
|
|
16
|
+
* return those types directly, so there is no wire DTO layer here — only
|
|
17
|
+
* transport and schema validation.
|
|
18
|
+
*
|
|
19
|
+
* The transport is not implemented yet; see {@link OffchainOpportunities} for
|
|
20
|
+
* what each stubbed endpoint currently answers.
|
|
21
|
+
**/
|
|
22
|
+
var GearboxAPI = class {
|
|
23
|
+
/**
|
|
24
|
+
* Namespace for pool and strategy opportunities.
|
|
25
|
+
**/
|
|
26
|
+
opportunities;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.opportunities = new OffchainOpportunities(options);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
//#endregion
|
|
32
|
+
export { GearboxAPI };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { OffchainNotImplementedError, OffchainOpportunities } from "./opportunities/OffchainOpportunities.js";
|
|
2
|
+
import "./opportunities/index.js";
|
|
3
|
+
import { GearboxAPI } from "./GearboxAPI.js";
|
|
4
|
+
import "./types.js";
|
|
5
|
+
export { GearboxAPI, OffchainNotImplementedError, OffchainOpportunities };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region src/offchain/opportunities/OffchainOpportunities.ts
|
|
2
|
+
/**
|
|
3
|
+
* Thrown by the endpoints that have no stub answer, so that a caller in
|
|
4
|
+
* `offchain` mode fails loudly instead of reading an empty detail page as a
|
|
5
|
+
* missing opportunity.
|
|
6
|
+
**/
|
|
7
|
+
var OffchainNotImplementedError = class extends Error {
|
|
8
|
+
constructor(endpoint) {
|
|
9
|
+
super(`GearboxAPI: ${endpoint} is not implemented yet`);
|
|
10
|
+
this.name = "OffchainNotImplementedError";
|
|
11
|
+
}
|
|
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
|
+
var OffchainOpportunities = class {
|
|
28
|
+
#baseUrl;
|
|
29
|
+
#logger;
|
|
30
|
+
constructor(options) {
|
|
31
|
+
this.#baseUrl = options?.baseUrl;
|
|
32
|
+
this.#logger = options?.logger?.child?.({ name: "OffchainOpportunities" });
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Base URL the client will call once the transport is implemented.
|
|
36
|
+
**/
|
|
37
|
+
get baseUrl() {
|
|
38
|
+
return this.#baseUrl;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* All opportunities the backend knows about, optionally narrowed by
|
|
42
|
+
* {@link OpportunityFilter}.
|
|
43
|
+
*
|
|
44
|
+
* @returns An empty list until the backend client is implemented.
|
|
45
|
+
**/
|
|
46
|
+
async list(filter) {
|
|
47
|
+
this.#logger?.debug({ filter }, "offchain opportunities list is not implemented, serving empty list");
|
|
48
|
+
return {
|
|
49
|
+
result: [],
|
|
50
|
+
meta: { status: "success" }
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Detailed view of one pool opportunity.
|
|
55
|
+
*
|
|
56
|
+
* @throws {@link OffchainNotImplementedError} until the backend client is
|
|
57
|
+
* implemented.
|
|
58
|
+
**/
|
|
59
|
+
async getPool(key) {
|
|
60
|
+
throw new OffchainNotImplementedError("opportunities.getPool");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Detailed view of one strategy opportunity.
|
|
64
|
+
*
|
|
65
|
+
* @throws {@link OffchainNotImplementedError} until the backend client is
|
|
66
|
+
* implemented.
|
|
67
|
+
**/
|
|
68
|
+
async getStrategy(key) {
|
|
69
|
+
throw new OffchainNotImplementedError("opportunities.getStrategy");
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One historical series of one opportunity. History exists only here:
|
|
73
|
+
* rebuilding it from the chain would mean an archive read per point.
|
|
74
|
+
*
|
|
75
|
+
* The requested metric types the response, so a caller asking for one metric
|
|
76
|
+
* does not have to narrow the union back down. When the transport lands,
|
|
77
|
+
* validation is what upholds it: a response carrying a different metric than
|
|
78
|
+
* the one asked for is a version-skew error like any other.
|
|
79
|
+
*
|
|
80
|
+
* @returns An empty series until the backend client is implemented.
|
|
81
|
+
**/
|
|
82
|
+
async getHistory(query) {
|
|
83
|
+
this.#logger?.debug({ query }, "offchain opportunities history is not implemented, serving empty series");
|
|
84
|
+
return {
|
|
85
|
+
result: {
|
|
86
|
+
metric: query.metric,
|
|
87
|
+
points: [],
|
|
88
|
+
metadata: {}
|
|
89
|
+
},
|
|
90
|
+
meta: { status: "success" }
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { OffchainNotImplementedError, OffchainOpportunities };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type": "module","sideEffects":false}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetsMap } from "../../sdk/utils/AssetsMap.js";
|
|
2
|
+
import { BigIntMath } from "../../sdk/utils/bigint-math.js";
|
|
2
3
|
import "../../sdk/index.js";
|
|
3
|
-
import { BigIntMath } from "../../common-utils/utils/bigint-math.js";
|
|
4
4
|
import "../../common-utils/index.js";
|
|
5
5
|
import { ERROR_UNPRICEABLE_TOKEN, PREVIEW_DUST } from "./types.js";
|
|
6
6
|
import { isAddressEqual } from "viem";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { BigIntMath } from "../../sdk/utils/bigint-math.js";
|
|
1
2
|
import { chains } from "../../sdk/chain/chains.js";
|
|
2
3
|
import { toBigInt } from "../../sdk/utils/formatter.js";
|
|
3
4
|
import "../../sdk/index.js";
|
|
4
|
-
import { BigIntMath } from "../../common-utils/utils/bigint-math.js";
|
|
5
5
|
import "../../common-utils/index.js";
|
|
6
6
|
import { MerkleXYZApi } from "./merkl-api.js";
|
|
7
7
|
import { getAddress } from "viem";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { BigIntMath } from "../../sdk/utils/bigint-math.js";
|
|
1
2
|
import { chains } from "../../sdk/chain/chains.js";
|
|
2
3
|
import { PERCENTAGE_FACTOR } from "../../sdk/constants/math.js";
|
|
3
4
|
import { toBN } from "../../sdk/utils/formatter.js";
|
|
4
5
|
import "../../sdk/index.js";
|
|
5
|
-
import { BigIntMath } from "../../common-utils/utils/bigint-math.js";
|
|
6
6
|
import "../../common-utils/index.js";
|
|
7
7
|
import axios from "axios";
|
|
8
8
|
//#region src/rewards/rewards/extra-apy.ts
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { getNetworkType } from "./chain/chains.js";
|
|
2
|
+
import { ChainNotConfiguredError, SdkMissingChainStateError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./core/errors.js";
|
|
2
3
|
import { PriceUpdatesCache } from "./market/pricefeeds/updates/PriceUpdatesCache.js";
|
|
3
4
|
import "./market/pricefeeds/updates/index.js";
|
|
4
5
|
import { MultichainLiquidationsService } from "./accounts/liquidations/MultichainLiquidationsService.js";
|
|
5
6
|
import "./accounts/index.js";
|
|
6
|
-
import { SdkMissingChainStateError, SdkStateVersionMismatchError, SdkSyncFailedError } from "./core/errors.js";
|
|
7
7
|
import "./core/index.js";
|
|
8
|
+
import { MultichainOpportunitiesService } from "./opportunities/MultichainOpportunitiesService.js";
|
|
9
|
+
import "./opportunities/index.js";
|
|
8
10
|
import { OnchainSDK } from "./OnchainSDK.js";
|
|
9
11
|
//#region src/sdk/MultichainSDK.ts
|
|
10
12
|
/**
|
|
@@ -22,6 +24,11 @@ var MultichainSDK = class {
|
|
|
22
24
|
* configured chains.
|
|
23
25
|
*/
|
|
24
26
|
liquidations;
|
|
27
|
+
/**
|
|
28
|
+
* Namespace for the pool and strategy opportunities of all configured
|
|
29
|
+
* chains.
|
|
30
|
+
*/
|
|
31
|
+
opportunities;
|
|
25
32
|
constructor(options) {
|
|
26
33
|
this.#chains = /* @__PURE__ */ new Map();
|
|
27
34
|
this.#logger = options.logger;
|
|
@@ -39,6 +46,7 @@ var MultichainSDK = class {
|
|
|
39
46
|
this.#chains.set(network, sdk);
|
|
40
47
|
}
|
|
41
48
|
this.liquidations = new MultichainLiquidationsService(this);
|
|
49
|
+
this.opportunities = new MultichainOpportunitiesService(this);
|
|
42
50
|
}
|
|
43
51
|
/**
|
|
44
52
|
* Attach all configured chains in parallel.
|
|
@@ -127,7 +135,7 @@ var MultichainSDK = class {
|
|
|
127
135
|
if (typeof networkOrChainId === "number") network = getNetworkType(networkOrChainId);
|
|
128
136
|
else network = networkOrChainId;
|
|
129
137
|
const sdk = this.#chains.get(network);
|
|
130
|
-
if (!sdk) throw new
|
|
138
|
+
if (!sdk) throw new ChainNotConfiguredError(networkOrChainId);
|
|
131
139
|
return sdk;
|
|
132
140
|
}
|
|
133
141
|
/**
|
|
@@ -137,6 +145,14 @@ var MultichainSDK = class {
|
|
|
137
145
|
return this.#chains;
|
|
138
146
|
}
|
|
139
147
|
/**
|
|
148
|
+
* Shared logger, used for messages that are not attributable to a single
|
|
149
|
+
* chain. Per-chain messages should use the logger of the corresponding
|
|
150
|
+
* {@link OnchainSDK}.
|
|
151
|
+
**/
|
|
152
|
+
get logger() {
|
|
153
|
+
return this.#logger;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
140
156
|
* Sync state for all chains in parallel.
|
|
141
157
|
*
|
|
142
158
|
* @param opts - Sync options.
|
|
@@ -8,6 +8,7 @@ import { formatTimestamp } from "./utils/formatter.js";
|
|
|
8
8
|
import { toAddress } from "./utils/toAddress.js";
|
|
9
9
|
import "./utils/index.js";
|
|
10
10
|
import { ChainContractsRegister } from "./base/ChainContractsRegister.js";
|
|
11
|
+
import { SdkAlreadyAttachedError, SdkChainMismatchError, SdkNotAttachedError, SdkStateVersionMismatchError } from "./core/errors.js";
|
|
11
12
|
import "./base/index.js";
|
|
12
13
|
import { executeDelegatedMulticalls } from "./utils/viem/executeDelegatedMulticalls.js";
|
|
13
14
|
import "./utils/viem/index.js";
|
|
@@ -22,8 +23,9 @@ import { createRedemptionLogger } from "./accounts/withdrawal-compressor/createR
|
|
|
22
23
|
import { createWithdrawalCompressor } from "./accounts/withdrawal-compressor/createWithdrawalCompressor.js";
|
|
23
24
|
import "./accounts/index.js";
|
|
24
25
|
import { createAddressProvider, hydrateAddressProvider } from "./core/createAddressProvider.js";
|
|
25
|
-
import { SdkAlreadyAttachedError, SdkChainMismatchError, SdkNotAttachedError, SdkStateVersionMismatchError } from "./core/errors.js";
|
|
26
26
|
import "./core/index.js";
|
|
27
|
+
import { OpportunitiesService } from "./opportunities/OpportunitiesService.js";
|
|
28
|
+
import "./opportunities/index.js";
|
|
27
29
|
import { PluginStateVersionError } from "./plugins/errors.js";
|
|
28
30
|
import "./plugins/index.js";
|
|
29
31
|
import { PoolService } from "./pools/PoolService.js";
|
|
@@ -106,6 +108,10 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
106
108
|
*/
|
|
107
109
|
liquidations;
|
|
108
110
|
/**
|
|
111
|
+
* Namespace for the pool and strategy opportunities of this chain.
|
|
112
|
+
*/
|
|
113
|
+
opportunities;
|
|
114
|
+
/**
|
|
109
115
|
* @param network - Gearbox network type (e.g. `"Mainnet"`, `"Monad"`).
|
|
110
116
|
* @param clientOptions - Connection options (RPC URLs, transport, or client).
|
|
111
117
|
* @param options - SDK configuration options.
|
|
@@ -126,6 +132,7 @@ var OnchainSDK = class extends ChainContractsRegister {
|
|
|
126
132
|
this.accounts = new CreditAccountsServiceV310(this);
|
|
127
133
|
this.pools = new PoolService(this);
|
|
128
134
|
this.liquidations = new LiquidationsService(this);
|
|
135
|
+
this.opportunities = new OpportunitiesService(this);
|
|
129
136
|
this.#withdrawalCompressor = createWithdrawalCompressor(this);
|
|
130
137
|
}
|
|
131
138
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
|
|
2
|
-
import { LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
2
|
+
import { DUST_THRESHOLD, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS } from "./liquidations/constants.js";
|
|
3
3
|
import { LiquidationsService } from "./liquidations/LiquidationsService.js";
|
|
4
4
|
import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
|
|
5
5
|
import "./liquidations/index.js";
|
|
@@ -16,4 +16,4 @@ import { toWithdrawalStatus } from "./withdrawal-compressor/types.js";
|
|
|
16
16
|
import { WithdrawalCompressorV313Contract } from "./withdrawal-compressor/WithdrawalCompressorV313Contract.js";
|
|
17
17
|
import { createWithdrawalCompressor } from "./withdrawal-compressor/createWithdrawalCompressor.js";
|
|
18
18
|
import "./withdrawal-compressor/index.js";
|
|
19
|
-
export { AbstractWithdrawalCompressorContract, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, InvalidDelayedIntentError, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|
|
19
|
+
export { AbstractWithdrawalCompressorContract, CreditAccountsServiceV310, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LiquidationsService, MultichainLiquidationsService, RedemptionLoggerV310Contract, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, getWithdrawalCompressorAddress, iCreditAccountAbi, toClaimableWithdrawal, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
|