@gearbox-protocol/sdk 14.12.0-next.66 → 14.12.0-next.68
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 +77 -0
- package/dist/cjs/model/liquidations.js +23 -0
- package/dist/cjs/model/liquidations.schema.js +93 -0
- package/dist/cjs/model/opportunities.js +55 -0
- package/dist/cjs/model/opportunities.schema.js +223 -0
- package/dist/cjs/model/package.json +1 -0
- package/dist/cjs/model/positions.js +1 -0
- package/dist/cjs/model/positions.schema.js +120 -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 +161 -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 +159 -0
- package/dist/cjs/sdk/market/credit/CreditManagerV310Contract.js +26 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +92 -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 +48 -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/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 +11 -0
- package/dist/esm/model/liquidations.js +22 -0
- package/dist/esm/model/liquidations.schema.js +85 -0
- package/dist/esm/model/opportunities.js +51 -0
- package/dist/esm/model/opportunities.schema.js +201 -0
- package/dist/esm/model/package.json +1 -0
- package/dist/esm/model/positions.js +1 -0
- package/dist/esm/model/positions.schema.js +109 -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 +164 -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 +159 -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 +92 -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 +47 -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/model/history.d.ts +105 -0
- package/dist/types/model/history.schema.d.ts +66 -0
- package/dist/types/model/index.d.ts +11 -0
- package/dist/types/model/liquidations.d.ts +238 -0
- package/dist/types/model/liquidations.schema.d.ts +294 -0
- package/dist/types/model/opportunities.d.ts +584 -0
- package/dist/types/model/opportunities.schema.d.ts +1037 -0
- package/dist/types/model/positions.d.ts +247 -0
- package/dist/types/model/positions.schema.d.ts +701 -0
- package/dist/types/model/primitives.d.ts +194 -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 +98 -1
- package/dist/types/sdk/market/credit/CreditManagerV310Contract.d.ts +14 -0
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +43 -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 +42 -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,41 @@
|
|
|
1
|
+
import { PERCENTAGE_FACTOR } from "../../constants/math.js";
|
|
2
|
+
//#region src/sdk/market/pool/math.ts
|
|
3
|
+
const FULL = Number(PERCENTAGE_FACTOR);
|
|
4
|
+
/**
|
|
5
|
+
* Base rate borrowers pay at a given utilization, in basis points, following
|
|
6
|
+
* the linear interest rate model's three segments.
|
|
7
|
+
*
|
|
8
|
+
* The result excludes the per-credit-manager interest fee: the model belongs to
|
|
9
|
+
* the pool, and every credit manager of a market can charge a different one.
|
|
10
|
+
**/
|
|
11
|
+
function borrowRateAtUtilization(utilization, params) {
|
|
12
|
+
const { U1, U2, Rbase, Rslope1, Rslope2, Rslope3 } = params;
|
|
13
|
+
const u = Math.min(Math.max(utilization, 0), FULL);
|
|
14
|
+
if (u <= 0) return Rbase;
|
|
15
|
+
if (u <= U1) return Math.round(Rbase + Rslope1 * u / U1);
|
|
16
|
+
if (u <= U2) return Math.round(Rbase + Rslope1 + Rslope2 * (u - U1) / Math.max(U2 - U1, 1));
|
|
17
|
+
return Math.round(Rbase + Rslope1 + Rslope2 + Rslope3 * (u - U2) / Math.max(FULL - U2, 1));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Rate depositors earn at a given utilization, in basis points: the interest
|
|
21
|
+
* borrowers pay, spread over the pool's whole liquidity.
|
|
22
|
+
**/
|
|
23
|
+
function supplyRateAtUtilization(utilization, params) {
|
|
24
|
+
const u = Math.min(Math.max(utilization, 0), FULL);
|
|
25
|
+
return Math.round(borrowRateAtUtilization(u, params) * u / FULL);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Utilizations the rate curve is sampled at: a fixed grid plus both kinks of
|
|
29
|
+
* the model, so the borrow leg is exact and the supply leg — which is
|
|
30
|
+
* quadratic between kinks — is smooth.
|
|
31
|
+
**/
|
|
32
|
+
function rateCurveUtilizations(params) {
|
|
33
|
+
const step = FULL / 20;
|
|
34
|
+
const grid = /* @__PURE__ */ new Set();
|
|
35
|
+
for (let u = 0; u <= FULL; u += step) grid.add(u);
|
|
36
|
+
grid.add(params.U1);
|
|
37
|
+
grid.add(params.U2);
|
|
38
|
+
return [...grid].filter((u) => u >= 0 && u <= FULL).sort((a, b) => a - b);
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
export { borrowRateAtUtilization, rateCurveUtilizations, supplyRateAtUtilization };
|
|
@@ -88,6 +88,23 @@ var AbstractPriceFeedContract = class extends BaseContract {
|
|
|
88
88
|
const underlying = this.underlyingPriceFeeds.flatMap((f) => f.priceFeed.updatableDependencies());
|
|
89
89
|
return isUpdatablePriceFeed(this) ? [this, ...underlying] : underlying;
|
|
90
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* {@inheritDoc IPriceFeedContract.describe}
|
|
93
|
+
*/
|
|
94
|
+
describe() {
|
|
95
|
+
let dependencies = [];
|
|
96
|
+
try {
|
|
97
|
+
dependencies = this.underlyingPriceFeeds.map((ref) => ref.priceFeed.describe());
|
|
98
|
+
} catch {
|
|
99
|
+
dependencies = [];
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
name: this.name,
|
|
103
|
+
type: this.contractType,
|
|
104
|
+
feedAddress: this.address,
|
|
105
|
+
dependencies
|
|
106
|
+
};
|
|
107
|
+
}
|
|
91
108
|
};
|
|
92
109
|
//#endregion
|
|
93
110
|
export { AbstractPriceFeedContract, PartialPriceFeedInitError };
|
|
@@ -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
|
/**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { getNetworkType } from "../chain/chains.js";
|
|
2
|
+
import { MultichainConstruct } from "../base/MultichainConstruct.js";
|
|
3
|
+
import "../base/index.js";
|
|
4
|
+
//#region src/sdk/opportunities/MultichainOpportunitiesService.ts
|
|
5
|
+
/**
|
|
6
|
+
* Cross-chain counterpart of {@link OpportunitiesService}.
|
|
7
|
+
*
|
|
8
|
+
* Fans out over every chain configured in {@link MultichainSDK}. A chain that
|
|
9
|
+
* fails is logged and skipped so one dead RPC does not empty the list; its
|
|
10
|
+
* failure is reported in {@link MultichainResult.meta}.
|
|
11
|
+
*
|
|
12
|
+
* Detail reads need no fan-out: an opportunity key names its chain.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam Plugins - Map of attached plugin types.
|
|
15
|
+
**/
|
|
16
|
+
var MultichainOpportunitiesService = class extends MultichainConstruct {
|
|
17
|
+
/**
|
|
18
|
+
* Opportunities of all queried chains, see {@link OpportunitiesService.list}.
|
|
19
|
+
*
|
|
20
|
+
* A filter that names chains narrows the fan-out itself, so chains whose rows
|
|
21
|
+
* would be discarded are never queried and never appear in the meta.
|
|
22
|
+
**/
|
|
23
|
+
async list(filter) {
|
|
24
|
+
return this.queryChains({
|
|
25
|
+
networks: this.#networksOf(filter),
|
|
26
|
+
label: "list opportunities",
|
|
27
|
+
run: (sdk) => sdk.opportunities.list(filter)
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* {@inheritDoc OpportunitiesService.getPool}
|
|
32
|
+
**/
|
|
33
|
+
async getPool(key) {
|
|
34
|
+
return this.sdk.chain(key.chainId).opportunities.getPool(key);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* {@inheritDoc OpportunitiesService.getStrategy}
|
|
38
|
+
**/
|
|
39
|
+
async getStrategy(key) {
|
|
40
|
+
return this.sdk.chain(key.chainId).opportunities.getStrategy(key);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Chains named by the filter, or `undefined` to query all of them. Chain ids
|
|
44
|
+
* the SDK does not support are dropped here rather than reported as failures:
|
|
45
|
+
* a filter naming them is a narrowing, not a request.
|
|
46
|
+
**/
|
|
47
|
+
#networksOf(filter) {
|
|
48
|
+
if (!filter?.chainIds) return;
|
|
49
|
+
const networks = [];
|
|
50
|
+
for (const chainId of filter.chainIds) try {
|
|
51
|
+
networks.push(getNetworkType(chainId));
|
|
52
|
+
} catch {
|
|
53
|
+
this.sdk.logger?.debug(`ignoring unsupported chain ${chainId} in opportunities filter`);
|
|
54
|
+
}
|
|
55
|
+
return networks;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { MultichainOpportunitiesService };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { SDKConstruct } from "../base/SDKConstruct.js";
|
|
2
|
+
import "../base/index.js";
|
|
3
|
+
//#region src/sdk/opportunities/OpportunitiesService.ts
|
|
4
|
+
/**
|
|
5
|
+
* Builds the `opportunities` read model from the chain.
|
|
6
|
+
*
|
|
7
|
+
* Every value in a row is market state the SDK already holds, so a list costs
|
|
8
|
+
* no RPC round-trip at all. Yield figures that fold in incentives, points or
|
|
9
|
+
* history are deliberately absent: they are the backend's job, and this service
|
|
10
|
+
* never guesses them. So is the size of a strategy — summing it takes a sweep
|
|
11
|
+
* over every credit account of the chain, which is too expensive for a list.
|
|
12
|
+
*
|
|
13
|
+
* The rows themselves are assembled by the market wrappers — see
|
|
14
|
+
* {@link MarketSuite.opportunities} — because every value in them is market
|
|
15
|
+
* state. This service only picks the markets and applies the filter.
|
|
16
|
+
**/
|
|
17
|
+
var OpportunitiesService = class extends SDKConstruct {
|
|
18
|
+
/**
|
|
19
|
+
* Every pool and strategy of every loaded market on this chain.
|
|
20
|
+
*
|
|
21
|
+
* @param filter - Optional narrowing, applied to the built rows.
|
|
22
|
+
**/
|
|
23
|
+
async list(filter) {
|
|
24
|
+
if (filter?.chainIds && !filter.chainIds.includes(this.chainId)) return [];
|
|
25
|
+
return this.sdk.marketRegister.markets.flatMap((market) => market.opportunities(filter));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A single pool opportunity plus its interest rate curve and quotas.
|
|
29
|
+
*
|
|
30
|
+
* @throws If no loaded market has this pool.
|
|
31
|
+
**/
|
|
32
|
+
async getPool(key) {
|
|
33
|
+
return this.sdk.marketRegister.findByPool(key.pool).poolOpportunityDetail();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
37
|
+
* from and the price feeds its liquidation price depends on.
|
|
38
|
+
*
|
|
39
|
+
* @throws If the credit manager is unknown, or does not accept the requested
|
|
40
|
+
* collateral as a strategy.
|
|
41
|
+
**/
|
|
42
|
+
async getStrategy(key) {
|
|
43
|
+
return this.sdk.marketRegister.findByCreditManager(key.creditManager).strategyOpportunityDetail(key.creditManager, key.targetCollateral);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { OpportunitiesService };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { additionalBorrowApyBps, borrowApyBps, maxLeverage, rayToBps, usdToNumber, utilizationBps } from "../market/math.js";
|
|
2
|
+
import { MultichainOpportunitiesService } from "./MultichainOpportunitiesService.js";
|
|
3
|
+
import { OpportunitiesService } from "./OpportunitiesService.js";
|
|
4
|
+
export { MultichainOpportunitiesService, OpportunitiesService, additionalBorrowApyBps, borrowApyBps, maxLeverage, rayToBps, usdToNumber, utilizationBps };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/sdk/utils/bigint-math.ts
|
|
2
2
|
/**
|
|
3
3
|
* Utility namespace for common `bigint` operations.
|
|
4
4
|
*
|
|
@@ -16,20 +16,20 @@ var BigIntMath = class {
|
|
|
16
16
|
static abs = (x) => x < 0n ? -x : x;
|
|
17
17
|
/**
|
|
18
18
|
* Returns the greater of two bigint values.
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
* @param b Second candidate value.
|
|
22
|
-
* @returns The larger value between `a` and `b`.
|
|
19
|
+
* @param values - The values to find the maximum of.
|
|
20
|
+
* @returns The maximum value.
|
|
23
21
|
*/
|
|
24
|
-
static max = (
|
|
22
|
+
static max = (...values) => {
|
|
23
|
+
return values.reduce((max, v) => v > max ? v : max);
|
|
24
|
+
};
|
|
25
25
|
/**
|
|
26
26
|
* Returns the smaller of two bigint values.
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
* @param b Second candidate value.
|
|
30
|
-
* @returns The smaller value between `a` and `b`.
|
|
27
|
+
* @param values - The values to find the minimum of.
|
|
28
|
+
* @returns The minimum value.
|
|
31
29
|
*/
|
|
32
|
-
static min = (
|
|
30
|
+
static min = (...values) => {
|
|
31
|
+
return values.reduce((min, v) => v < min ? v : min);
|
|
32
|
+
};
|
|
33
33
|
/**
|
|
34
34
|
* Returns the negative form of a bigint if it is currently positive.
|
|
35
35
|
*
|
|
@@ -3,6 +3,7 @@ import { AddressSet } from "./AddressSet.js";
|
|
|
3
3
|
import { AssetsMap } from "./AssetsMap.js";
|
|
4
4
|
import { json_parse, json_stringify } from "./json.js";
|
|
5
5
|
import { functionArgsToMap, functionArgsToRecord, getFunctionSignature } from "./abi-decode.js";
|
|
6
|
+
import { BigIntMath } from "./bigint-math.js";
|
|
6
7
|
import { bytes32ToString } from "./bytes32ToString.js";
|
|
7
8
|
import { childLogger } from "./childLogger.js";
|
|
8
9
|
import { createRawTx } from "./createRawTx.js";
|
|
@@ -15,5 +16,5 @@ import { hexEq } from "./hex.js";
|
|
|
15
16
|
import { retry } from "./retry.js";
|
|
16
17
|
import { toAddress } from "./toAddress.js";
|
|
17
18
|
import "./type-utils.js";
|
|
18
|
-
import { ZodAddress } from "./zod.js";
|
|
19
|
-
export { AddressMap, AddressSet, AssetsMap, TypedObjectUtils, ZodAddress, bytes32ToString, childLogger, createRawTx, etherscanApiUrl, etherscanUrl, filterDust, filterDustUSD, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, getFunctionSignature, hexEq, isDust, json_parse, json_stringify, numberWithCommas, percentFmt, rayToNumber, retry, shortAddress, shortHash, toAddress, toBN, toBigInt, toSignificant };
|
|
19
|
+
import { ZodAddress, ZodHex } from "./zod.js";
|
|
20
|
+
export { AddressMap, AddressSet, AssetsMap, BigIntMath, TypedObjectUtils, ZodAddress, ZodHex, bytes32ToString, childLogger, createRawTx, etherscanApiUrl, etherscanUrl, filterDust, filterDustUSD, fmtBinaryMask, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, getFunctionSignature, hexEq, isDust, json_parse, json_stringify, numberWithCommas, percentFmt, rayToNumber, retry, shortAddress, shortHash, toAddress, toBN, toBigInt, toSignificant };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorAbis } from "../../../abi/errors.js";
|
|
2
|
-
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
3
2
|
import { generateCastTraceCall } from "./cast.js";
|
|
3
|
+
import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
|
|
4
4
|
import { simulateMulticall } from "./simulateMulticall.js";
|
|
5
5
|
import { BaseError, CallExecutionError, ContractFunctionRevertedError, decodeFunctionData, decodeFunctionResult, encodeFunctionData, parseAbi } from "viem";
|
|
6
6
|
import { getAction, parseAccount } from "viem/utils";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAddress, isAddress } from "viem";
|
|
1
|
+
import { getAddress, isAddress, isHex } from "viem";
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
//#region src/sdk/utils/zod.ts
|
|
4
4
|
/**
|
|
@@ -12,5 +12,16 @@ const ZodAddress = () => z.string().transform((val, ctx) => {
|
|
|
12
12
|
});
|
|
13
13
|
return getAddress(val);
|
|
14
14
|
});
|
|
15
|
+
/**
|
|
16
|
+
* A `0x`-prefixed hex string, as viem's Hex.
|
|
17
|
+
*/
|
|
18
|
+
const ZodHex = () => z.string().transform((val, ctx) => {
|
|
19
|
+
if (!isHex(val)) ctx.issues.push({
|
|
20
|
+
code: "custom",
|
|
21
|
+
message: `invalid hex string ${val}`,
|
|
22
|
+
input: ctx.value
|
|
23
|
+
});
|
|
24
|
+
return val;
|
|
25
|
+
});
|
|
15
26
|
//#endregion
|
|
16
|
-
export { ZodAddress };
|
|
27
|
+
export { ZodAddress, ZodHex };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigIntMath } from "../sdk/utils/bigint-math.js";
|
|
1
2
|
import { AxiosCache } from "./axios-cache/AxiosCache.js";
|
|
2
3
|
import "./axios-cache/index.js";
|
|
3
4
|
import { BigNumberish, ChartsCreditManagerPayload } from "./charts/credit-manager-payload.js";
|
|
@@ -43,7 +44,6 @@ import { getSafeBaseBorrowRate } from "./utils/apy/get-safe-base-borrow-rate.js"
|
|
|
43
44
|
import { CalcQuotaBorrowRateProps, calcQuotaBorrowRate } from "./utils/creditAccount/calc-quota-borrow-rate.js";
|
|
44
45
|
import { GetSingleQuotaBorrowRateRate, getSingleQuotaBorrowRate } from "./utils/apy/get-single-quota-borrow-rate.js";
|
|
45
46
|
import { maxAPYFormula } from "./utils/apy/max-apy-formula.js";
|
|
46
|
-
import { BigIntMath } from "./utils/bigint-math.js";
|
|
47
47
|
import { EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT } from "./utils/constants.js";
|
|
48
48
|
import { CalcHealthFactorProps, calcHealthFactor } from "./utils/creditAccount/calc-health-factor.js";
|
|
49
49
|
import { CalcOverallAPYProps, calcOverallAPY } from "./utils/creditAccount/calc-overall-apy.js";
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BigIntMath } from "../../sdk/utils/bigint-math.js";
|
|
1
2
|
import { AssetUtils, AssetWithAmountInTarget, AssetWithView, WrapResult } from "./assets-math.js";
|
|
2
3
|
import { BONUS_APY_FROM_POINTS } from "./apy/bonus-apy-from-points.js";
|
|
3
4
|
import { AppChains } from "./strategies/types/chains.js";
|
|
@@ -28,7 +29,6 @@ import { CalcQuotaBorrowRateProps, calcQuotaBorrowRate } from "./creditAccount/c
|
|
|
28
29
|
import { GetSingleQuotaBorrowRateRate, getSingleQuotaBorrowRate } from "./apy/get-single-quota-borrow-rate.js";
|
|
29
30
|
import { maxAPYFormula } from "./apy/max-apy-formula.js";
|
|
30
31
|
import "./apy/index.js";
|
|
31
|
-
import { BigIntMath } from "./bigint-math.js";
|
|
32
32
|
import { EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT } from "./constants.js";
|
|
33
33
|
import { CalcHealthFactorProps, calcHealthFactor } from "./creditAccount/calc-health-factor.js";
|
|
34
34
|
import { CalcOverallAPYProps, calcOverallAPY } from "./creditAccount/calc-overall-apy.js";
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { Timestamp } from "./primitives.js";
|
|
2
|
+
import { OpportunityKey } from "./opportunities.js";
|
|
3
|
+
//#region src/model/history.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Historical time series of an opportunity.
|
|
6
|
+
*
|
|
7
|
+
* History is backend-only by construction: the chain serves the present, and
|
|
8
|
+
* reconstructing a series from it would mean archive-node reads per point.
|
|
9
|
+
**/
|
|
10
|
+
/**
|
|
11
|
+
* Time window a series covers, ending at the present.
|
|
12
|
+
*
|
|
13
|
+
* `"max"` is the full history the backend retains for the opportunity.
|
|
14
|
+
**/
|
|
15
|
+
type HistoryRange = "1d" | "1w" | "1m" | "1y" | "max";
|
|
16
|
+
/**
|
|
17
|
+
* Series available for a pool opportunity.
|
|
18
|
+
**/
|
|
19
|
+
type PoolHistoryMetric = "depositApy" | "borrowApy" | "dieselRate" | "supplied" | "borrowed" | "availableLiquidity";
|
|
20
|
+
/**
|
|
21
|
+
* Every {@link PoolHistoryMetric}, for callers that enumerate them.
|
|
22
|
+
**/
|
|
23
|
+
declare const POOL_HISTORY_METRICS: readonly ["depositApy", "borrowApy", "dieselRate", "supplied", "borrowed", "availableLiquidity"];
|
|
24
|
+
/**
|
|
25
|
+
* Series available for a strategy opportunity.
|
|
26
|
+
*
|
|
27
|
+
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
28
|
+
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
29
|
+
**/
|
|
30
|
+
type StrategyHistoryMetric = "netApy" | "borrowApy" | "collateralApy" | "tvl" | "collateralPrice" | "collateralUsdPrice" | "underlyingUsdPrice";
|
|
31
|
+
/**
|
|
32
|
+
* Every {@link StrategyHistoryMetric}, for callers that enumerate them.
|
|
33
|
+
**/
|
|
34
|
+
declare const STRATEGY_HISTORY_METRICS: readonly ["netApy", "borrowApy", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
35
|
+
/**
|
|
36
|
+
* Any series the read model can return.
|
|
37
|
+
**/
|
|
38
|
+
type HistoryMetric = PoolHistoryMetric | StrategyHistoryMetric;
|
|
39
|
+
/**
|
|
40
|
+
* One sample of a series.
|
|
41
|
+
**/
|
|
42
|
+
interface HistoryPoint {
|
|
43
|
+
/**
|
|
44
|
+
* When the sample was taken.
|
|
45
|
+
**/
|
|
46
|
+
timestamp: Timestamp;
|
|
47
|
+
/**
|
|
48
|
+
* Sampled value. The unit follows from the metric: APY metrics are in basis
|
|
49
|
+
* points, amount metrics are in the underlying's base units expressed as a
|
|
50
|
+
* float, price metrics are plain prices.
|
|
51
|
+
*
|
|
52
|
+
* @example `842` for an 8.42% APY sample
|
|
53
|
+
**/
|
|
54
|
+
value: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Annotations the backend ships alongside a series, e.g. what a chart drawn
|
|
58
|
+
* from it should say beyond the points themselves.
|
|
59
|
+
*
|
|
60
|
+
* TODO: the backend has not specified this payload yet. It stays empty until
|
|
61
|
+
* it does, so that filling it in later is additive rather than a rename.
|
|
62
|
+
**/
|
|
63
|
+
interface HistoryChartMetadata {}
|
|
64
|
+
/**
|
|
65
|
+
* A named series of samples ordered by ascending timestamp.
|
|
66
|
+
*
|
|
67
|
+
* @typeParam M - Metric the series carries.
|
|
68
|
+
**/
|
|
69
|
+
interface HistorySeries<M extends string = HistoryMetric> {
|
|
70
|
+
/**
|
|
71
|
+
* Metric the samples belong to; it also defines their unit, so no separate
|
|
72
|
+
* unit field ships.
|
|
73
|
+
**/
|
|
74
|
+
metric: M;
|
|
75
|
+
/**
|
|
76
|
+
* Samples, oldest first.
|
|
77
|
+
**/
|
|
78
|
+
points: HistoryPoint[];
|
|
79
|
+
/**
|
|
80
|
+
* What the backend says about the series, see {@link HistoryChartMetadata}.
|
|
81
|
+
**/
|
|
82
|
+
metadata: HistoryChartMetadata;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* A request for one series of a single opportunity.
|
|
86
|
+
*
|
|
87
|
+
* @typeParam M - Metric requested.
|
|
88
|
+
**/
|
|
89
|
+
interface OpportunityHistoryQuery<M extends HistoryMetric = HistoryMetric> {
|
|
90
|
+
/**
|
|
91
|
+
* Opportunity the series belongs to.
|
|
92
|
+
**/
|
|
93
|
+
opportunity: OpportunityKey;
|
|
94
|
+
/**
|
|
95
|
+
* Window to cover.
|
|
96
|
+
**/
|
|
97
|
+
range: HistoryRange;
|
|
98
|
+
/**
|
|
99
|
+
* Metric to return. A metric that does not apply to the opportunity's kind
|
|
100
|
+
* has no series.
|
|
101
|
+
**/
|
|
102
|
+
metric: M;
|
|
103
|
+
}
|
|
104
|
+
//#endregion
|
|
105
|
+
export { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, PoolHistoryMetric, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { HistoryChartMetadata } from "./history.js";
|
|
2
|
+
import { z } from "zod/v4";
|
|
3
|
+
//#region src/model/history.schema.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runtime schemas for {@link ./history.js}, see the note in
|
|
6
|
+
* `primitives.schema.ts` on why they are written by hand.
|
|
7
|
+
**/
|
|
8
|
+
/**
|
|
9
|
+
* {@link HistoryRange}
|
|
10
|
+
**/
|
|
11
|
+
declare const historyRangeSchema: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
|
|
12
|
+
/**
|
|
13
|
+
* {@link PoolHistoryMetric}
|
|
14
|
+
**/
|
|
15
|
+
declare const poolHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>;
|
|
16
|
+
/**
|
|
17
|
+
* {@link StrategyHistoryMetric}
|
|
18
|
+
**/
|
|
19
|
+
declare const strategyHistoryMetricSchema: z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>;
|
|
20
|
+
/**
|
|
21
|
+
* {@link HistoryMetric}
|
|
22
|
+
**/
|
|
23
|
+
declare const historyMetricSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
|
|
24
|
+
/**
|
|
25
|
+
* {@link HistoryPoint}
|
|
26
|
+
**/
|
|
27
|
+
declare const historyPointSchema: z.ZodObject<{
|
|
28
|
+
timestamp: z.ZodNumber;
|
|
29
|
+
value: z.ZodNumber;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/**
|
|
32
|
+
* {@link HistoryChartMetadata}
|
|
33
|
+
*
|
|
34
|
+
* TODO: empty until the backend specifies the payload.
|
|
35
|
+
**/
|
|
36
|
+
declare const historyChartMetadataSchema: z.ZodType<HistoryChartMetadata>;
|
|
37
|
+
/**
|
|
38
|
+
* {@link HistorySeries}
|
|
39
|
+
**/
|
|
40
|
+
declare const historySeriesSchema: z.ZodObject<{
|
|
41
|
+
metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
|
|
42
|
+
points: z.ZodArray<z.ZodObject<{
|
|
43
|
+
timestamp: z.ZodNumber;
|
|
44
|
+
value: z.ZodNumber;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
metadata: z.ZodType<HistoryChartMetadata, unknown, z.core.$ZodTypeInternals<HistoryChartMetadata, unknown>>;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
/**
|
|
49
|
+
* {@link OpportunityHistoryQuery}
|
|
50
|
+
**/
|
|
51
|
+
declare const opportunityHistoryQuerySchema: z.ZodObject<{
|
|
52
|
+
opportunity: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
53
|
+
chainId: z.ZodNumber;
|
|
54
|
+
pool: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
55
|
+
kind: z.ZodLiteral<"pool">;
|
|
56
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
+
chainId: z.ZodNumber;
|
|
58
|
+
creditManager: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
59
|
+
targetCollateral: z.ZodPipe<z.ZodString, z.ZodTransform<`0x${string}`, string>>;
|
|
60
|
+
kind: z.ZodLiteral<"strategy">;
|
|
61
|
+
}, z.core.$strip>], "kind">;
|
|
62
|
+
range: z.ZodUnion<readonly [z.ZodLiteral<"1d">, z.ZodLiteral<"1w">, z.ZodLiteral<"1m">, z.ZodLiteral<"1y">, z.ZodLiteral<"max">]>;
|
|
63
|
+
metric: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodLiteral<"depositApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"dieselRate">, z.ZodLiteral<"supplied">, z.ZodLiteral<"borrowed">, z.ZodLiteral<"availableLiquidity">]>, z.ZodUnion<readonly [z.ZodLiteral<"netApy">, z.ZodLiteral<"borrowApy">, z.ZodLiteral<"collateralApy">, z.ZodLiteral<"tvl">, z.ZodLiteral<"collateralPrice">, z.ZodLiteral<"collateralUsdPrice">, z.ZodLiteral<"underlyingUsdPrice">]>]>;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Amount, AssetType, Bps, ChainId, Curator, Leverage, Timestamp, Token, TokenAmount, TxCall } from "./primitives.js";
|
|
2
|
+
import { ApyBreakdown, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityId, OpportunityKey, OpportunityKind, PointRewards, PointsProgram, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, Rewards, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, TokenRewards, matchesOpportunityFilter, opportunityId, poolOpportunityId, strategyOpportunityId } from "./opportunities.js";
|
|
3
|
+
import { HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, OpportunityHistoryQuery, POOL_HISTORY_METRICS, PoolHistoryMetric, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric } from "./history.js";
|
|
4
|
+
import { historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, opportunityHistoryQuerySchema, poolHistoryMetricSchema, strategyHistoryMetricSchema } from "./history.schema.js";
|
|
5
|
+
import { DelayedReceivedAsset, InstantReceivedAsset, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, ReceivedAsset, matchesLiquidatableAccountFilter } from "./liquidations.js";
|
|
6
|
+
import { delayedReceivedAssetSchema, instantReceivedAssetSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, receivedAssetSchema } from "./liquidations.schema.js";
|
|
7
|
+
import { apyBreakdownSchema, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pointRewardsSchema, pointsProgramSchema, poolOpportunityDetailSchema, poolOpportunityKeySchema, poolOpportunitySchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, rewardsSchema, strategyOpportunityDetailSchema, strategyOpportunityKeySchema, strategyOpportunitySchema, tokenRewardsSchema } from "./opportunities.schema.js";
|
|
8
|
+
import { PnlBreakdown, PointsProgramPnL, PointsRewardsPnL, PoolPosition, Position, PositionCollateral, PositionFilter, PositionKind, RewardsPnL, StrategyPosition, TokenRewardsPnL } from "./positions.js";
|
|
9
|
+
import { pnlBreakdownSchema, pointsProgramPnLSchema, pointsRewardsPnLSchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKindSchema, positionSchema, rewardsPnLSchema, strategyPositionSchema, tokenRewardsPnLSchema } from "./positions.schema.js";
|
|
10
|
+
import { amountSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, leverageSchema, timestampSchema, tokenAmountSchema, tokenSchema, txCallSchema } from "./primitives.schema.js";
|
|
11
|
+
export { Amount, ApyBreakdown, AssetType, Bps, ChainId, Curator, DelayedReceivedAsset, HistoryChartMetadata, HistoryMetric, HistoryPoint, HistoryRange, HistorySeries, InstantReceivedAsset, Leverage, LiquidatableAccount, LiquidatableAccountFilter, LiquidationApproval, LiquidationDetails, LiquidationPosition, Opportunity, OpportunityBase, OpportunityDetail, OpportunityFilter, OpportunityHistoryQuery, OpportunityId, OpportunityKey, OpportunityKind, POOL_HISTORY_METRICS, PnlBreakdown, PointRewards, PointsProgram, PointsProgramPnL, PointsRewardsPnL, PoolHistoryMetric, PoolOpportunity, PoolOpportunityDetail, PoolOpportunityKey, PoolOpportunityRef, PoolPosition, Position, PositionCollateral, PositionFilter, PositionKind, PriceFeedData, PriceFeedSummary, QuotaAsset, RateCurve, RateCurvePoint, ReceivedAsset, Rewards, RewardsPnL, STRATEGY_HISTORY_METRICS, StrategyHistoryMetric, StrategyOpportunity, StrategyOpportunityDetail, StrategyOpportunityKey, StrategyOpportunityRef, StrategyPosition, Timestamp, Token, TokenAmount, TokenRewards, TokenRewardsPnL, TxCall, amountSchema, apyBreakdownSchema, assetTypeSchema, bpsSchema, chainIdSchema, curatorSchema, delayedReceivedAssetSchema, historyChartMetadataSchema, historyMetricSchema, historyPointSchema, historyRangeSchema, historySeriesSchema, instantReceivedAssetSchema, leverageSchema, liquidatableAccountFilterSchema, liquidatableAccountSchema, liquidationApprovalSchema, liquidationDetailsSchema, liquidationPositionSchema, matchesLiquidatableAccountFilter, matchesOpportunityFilter, opportunityBaseSchema, opportunityDetailSchema, opportunityFilterSchema, opportunityHistoryQuerySchema, opportunityId, opportunityKeySchema, opportunityKindSchema, opportunitySchema, pnlBreakdownSchema, pointRewardsSchema, pointsProgramPnLSchema, pointsProgramSchema, pointsRewardsPnLSchema, poolHistoryMetricSchema, poolOpportunityDetailSchema, poolOpportunityId, poolOpportunityKeySchema, poolOpportunitySchema, poolPositionSchema, positionCollateralSchema, positionFilterSchema, positionKindSchema, positionSchema, priceFeedDataSchema, priceFeedSummarySchema, quotaAssetSchema, rateCurvePointSchema, rateCurveSchema, receivedAssetSchema, rewardsPnLSchema, rewardsSchema, strategyHistoryMetricSchema, strategyOpportunityDetailSchema, strategyOpportunityId, strategyOpportunityKeySchema, strategyOpportunitySchema, strategyPositionSchema, timestampSchema, tokenAmountSchema, tokenRewardsPnLSchema, tokenRewardsSchema, tokenSchema, txCallSchema };
|