@gearbox-protocol/sdk 15.1.0-next.23 → 15.1.0-next.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/model/opportunities.schema.js +3 -5
- package/dist/cjs/sdk/index.js +4 -1
- package/dist/cjs/sdk/market/credit/CreditSuite.js +10 -8
- package/dist/cjs/sdk/market/index.js +4 -1
- package/dist/cjs/sdk/market/math.js +71 -17
- package/dist/esm/model/opportunities.schema.js +3 -5
- package/dist/esm/sdk/index.js +2 -2
- package/dist/esm/sdk/market/credit/CreditSuite.js +11 -9
- package/dist/esm/sdk/market/index.js +2 -2
- package/dist/esm/sdk/market/math.js +68 -17
- package/dist/types/model/opportunities.d.ts +9 -25
- package/dist/types/model/opportunities.schema.d.ts +12 -204
- package/dist/types/sdk/index.d.ts +2 -2
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +1 -5
- package/dist/types/sdk/market/index.d.ts +2 -2
- package/dist/types/sdk/market/math.d.ts +64 -13
- package/package.json +1 -1
|
@@ -92,12 +92,10 @@ const strategyOpportunitySchema = zod_v4.z.object({
|
|
|
92
92
|
expirationDate: require_model_primitives_schema.timestampSchema.nullable(),
|
|
93
93
|
collateralApy: require_model_compare_schema.offchainOnly(apyBreakdownSchema).optional(),
|
|
94
94
|
collateralApyAvg7D: require_model_compare_schema.offchainOnly(apyBreakdownSchema).optional(),
|
|
95
|
-
|
|
96
|
-
maxLeverageApyAvg7D: require_model_compare_schema.offchainOnly(apyBreakdownSchema).optional(),
|
|
97
|
-
borrowApy: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps").optional(),
|
|
95
|
+
borrowApy: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps"),
|
|
98
96
|
borrowApyAvg7D: require_model_compare_schema.offchainOnly(require_model_primitives_schema.bpsSchema).optional(),
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
quotaRate: require_model_compare_schema.tolerance(require_model_primitives_schema.bpsSchema, "bps"),
|
|
98
|
+
quotaRateAvg7D: require_model_compare_schema.offchainOnly(require_model_primitives_schema.bpsSchema).optional(),
|
|
101
99
|
totalValue: require_model_compare_schema.offchainOnly(require_model_primitives_schema.amountSchema).optional(),
|
|
102
100
|
utilization: require_model_compare_schema.offchainOnly(require_model_primitives_schema.bpsSchema).optional(),
|
|
103
101
|
availableLiquidity: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
|
package/dist/cjs/sdk/index.js
CHANGED
|
@@ -322,6 +322,7 @@ exports.CurveStablePriceFeedContract = require_sdk_market_pricefeeds_CurveStable
|
|
|
322
322
|
exports.CurveUSDPriceFeedContract = require_sdk_market_pricefeeds_CurveUSDPriceFeed.CurveUSDPriceFeedContract;
|
|
323
323
|
exports.CurveV1AdapterStETHContract = require_sdk_market_adapters_contracts_CurveV1AdapterStETHContract.CurveV1AdapterStETHContract;
|
|
324
324
|
exports.CurveV1StableNGAdapterContract = require_sdk_market_adapters_contracts_CurveV1StableNGAdapterContract.CurveV1StableNGAdapterContract;
|
|
325
|
+
exports.DEFAULT_QUOTA_BUFFER_BPS = require_sdk_market_math.DEFAULT_QUOTA_BUFFER_BPS;
|
|
325
326
|
exports.DELAYED_INTENT_TYPES = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_TYPES;
|
|
326
327
|
exports.DELAYED_INTENT_VERSION = require_sdk_accounts_withdrawal_compressor_intent_codec.DELAYED_INTENT_VERSION;
|
|
327
328
|
exports.DUST_THRESHOLD = require_sdk_constants_math.DUST_THRESHOLD;
|
|
@@ -469,14 +470,16 @@ exports.assetsMap = require_sdk_router_helpers.assetsMap;
|
|
|
469
470
|
exports.attachOptionsSchema = require_sdk_options.attachOptionsSchema;
|
|
470
471
|
exports.botPermissionsToString = require_sdk_constants_bot_permissions.botPermissionsToString;
|
|
471
472
|
exports.bytes32ToString = require_sdk_utils_bytes32ToString.bytes32ToString;
|
|
472
|
-
exports.calcAdditionalBorrowApy = require_sdk_market_math.calcAdditionalBorrowApy;
|
|
473
473
|
exports.calcBorrowApy = require_sdk_market_math.calcBorrowApy;
|
|
474
474
|
exports.calcBorrowRate = require_sdk_positions_calcBorrowRate.calcBorrowRate;
|
|
475
|
+
exports.calcEffectiveBorrowApy = require_sdk_market_math.calcEffectiveBorrowApy;
|
|
475
476
|
exports.calcHealthFactor = require_sdk_positions_calcHealthFactor.calcHealthFactor;
|
|
476
477
|
exports.calcLiquidationPrice = require_sdk_positions_calcLiquidationPrice.calcLiquidationPrice;
|
|
477
478
|
exports.calcLiquidationPriceForTarget = require_sdk_positions_calcLiquidationPriceForTarget.calcLiquidationPriceForTarget;
|
|
478
479
|
exports.calcMaxLeverage = require_sdk_market_math.calcMaxLeverage;
|
|
480
|
+
exports.calcNetStrategyApy = require_sdk_market_math.calcNetStrategyApy;
|
|
479
481
|
exports.calcPositionLeverage = require_sdk_market_math.calcPositionLeverage;
|
|
482
|
+
exports.calcQuotaRate = require_sdk_market_math.calcQuotaRate;
|
|
480
483
|
exports.calcTimeToLiquidationMs = require_sdk_positions_calcTimeToLiquidationMs.calcTimeToLiquidationMs;
|
|
481
484
|
exports.calcUtilization = require_sdk_market_math.calcUtilization;
|
|
482
485
|
exports.chains = require_sdk_chain_chains.chains;
|
|
@@ -15,6 +15,12 @@ const require_sdk_market_credit_createCreditFacade = require("./createCreditFaca
|
|
|
15
15
|
const require_sdk_market_credit_createCreditManager = require("./createCreditManager.js");
|
|
16
16
|
//#region src/sdk/market/credit/CreditSuite.ts
|
|
17
17
|
/**
|
|
18
|
+
* Amount of underlying seeded into each pool at market creation to protect
|
|
19
|
+
* from inflation attacks, in raw token units. A suite whose remaining borrow
|
|
20
|
+
* capacity is at or below this is treated as having nothing left to lend.
|
|
21
|
+
**/
|
|
22
|
+
const MIN_STRATEGY_BORROW_AMOUNT = 100000n;
|
|
23
|
+
/**
|
|
18
24
|
* SDK aggregate for one credit-manager branch inside a market.
|
|
19
25
|
*
|
|
20
26
|
* @remarks
|
|
@@ -174,13 +180,9 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
174
180
|
/**
|
|
175
181
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
176
182
|
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
177
|
-
*
|
|
178
|
-
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
179
|
-
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
180
|
-
* whatever its collaterals are.
|
|
181
183
|
*/
|
|
182
184
|
get strategyCollaterals() {
|
|
183
|
-
if (this.maxBorrowAmount
|
|
185
|
+
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return [];
|
|
184
186
|
return this.creditManager.collateralTokens.filter((token) => require_sdk_market_credit_collateralUtils.isStrategyCollateral(this.#strategyCollateralProps(token), true));
|
|
185
187
|
}
|
|
186
188
|
/**
|
|
@@ -224,10 +226,10 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
224
226
|
/**
|
|
225
227
|
* Describes this suite's leveraged strategy as the shared read model does,
|
|
226
228
|
* or `undefined` when {@link strategyTargetCollateral} cannot be resolved or
|
|
227
|
-
* {@link maxBorrowAmount} is
|
|
229
|
+
* {@link maxBorrowAmount} is at or below {@link MIN_STRATEGY_BORROW_AMOUNT}.
|
|
228
230
|
*/
|
|
229
231
|
strategyOpportunity() {
|
|
230
|
-
if (this.maxBorrowAmount
|
|
232
|
+
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
231
233
|
const collateral = this.strategyTargetCollateral;
|
|
232
234
|
if (!collateral) return;
|
|
233
235
|
const { market, creditManager: cm } = this;
|
|
@@ -255,7 +257,7 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
255
257
|
liquidationFee: cm.feeLiquidation,
|
|
256
258
|
expirationDate: this.expirationDate,
|
|
257
259
|
borrowApy: require_sdk_market_math.calcBorrowApy(pool.baseInterestRate, cm.feeInterest),
|
|
258
|
-
|
|
260
|
+
quotaRate: require_sdk_market_math.calcQuotaRate(market.pool.pqk.quotaRate(collateral), cm.feeInterest),
|
|
259
261
|
availableLiquidity: oracle.toAmount(pool.underlying, pool.availableLiquidity),
|
|
260
262
|
minDebt: oracle.toAmount(pool.underlying, this.creditFacade.minDebt),
|
|
261
263
|
totalDebtLimit: oracle.toAmount(pool.underlying, debtParams?.limit ?? 0n),
|
|
@@ -173,6 +173,7 @@ exports.CurveStablePriceFeedContract = require_sdk_market_pricefeeds_CurveStable
|
|
|
173
173
|
exports.CurveUSDPriceFeedContract = require_sdk_market_pricefeeds_CurveUSDPriceFeed.CurveUSDPriceFeedContract;
|
|
174
174
|
exports.CurveV1AdapterStETHContract = require_sdk_market_adapters_contracts_CurveV1AdapterStETHContract.CurveV1AdapterStETHContract;
|
|
175
175
|
exports.CurveV1StableNGAdapterContract = require_sdk_market_adapters_contracts_CurveV1StableNGAdapterContract.CurveV1StableNGAdapterContract;
|
|
176
|
+
exports.DEFAULT_QUOTA_BUFFER_BPS = require_sdk_market_math.DEFAULT_QUOTA_BUFFER_BPS;
|
|
176
177
|
exports.DaiUsdsAdapterContract = require_sdk_market_adapters_contracts_DaiUsdsAdapterContract.DaiUsdsAdapterContract;
|
|
177
178
|
exports.ERC4626AdapterContract = require_sdk_market_adapters_contracts_ERC4626AdapterContract.ERC4626AdapterContract;
|
|
178
179
|
exports.ERC4626ReferralAdapterContract = require_sdk_market_adapters_contracts_ERC4626ReferralAdapterContract.ERC4626ReferralAdapterContract;
|
|
@@ -245,10 +246,12 @@ exports.adapterActionSelectors = require_sdk_market_adapters_abi_actionAbi.adapt
|
|
|
245
246
|
exports.adapterActionSignatures = require_sdk_market_adapters_abi_actionAbi.adapterActionSignatures;
|
|
246
247
|
exports.adapterConstructorAbi = require_sdk_market_adapters_abi_conctructorAbi.adapterConstructorAbi;
|
|
247
248
|
exports.allTransfersAsTokenAmounts = require_sdk_market_adapters_transferHelpers.allTransfersAsTokenAmounts;
|
|
248
|
-
exports.calcAdditionalBorrowApy = require_sdk_market_math.calcAdditionalBorrowApy;
|
|
249
249
|
exports.calcBorrowApy = require_sdk_market_math.calcBorrowApy;
|
|
250
|
+
exports.calcEffectiveBorrowApy = require_sdk_market_math.calcEffectiveBorrowApy;
|
|
250
251
|
exports.calcMaxLeverage = require_sdk_market_math.calcMaxLeverage;
|
|
252
|
+
exports.calcNetStrategyApy = require_sdk_market_math.calcNetStrategyApy;
|
|
251
253
|
exports.calcPositionLeverage = require_sdk_market_math.calcPositionLeverage;
|
|
254
|
+
exports.calcQuotaRate = require_sdk_market_math.calcQuotaRate;
|
|
252
255
|
exports.calcUtilization = require_sdk_market_math.calcUtilization;
|
|
253
256
|
exports.classifyCurveOperation = require_sdk_market_adapters_transferHelpers.classifyCurveOperation;
|
|
254
257
|
exports.createAdapter = require_sdk_market_adapters_createAdapter.createAdapter;
|
|
@@ -75,6 +75,70 @@ function calcBorrowApy(baseInterestRate, feeInterest) {
|
|
|
75
75
|
return rayToBps(baseInterestRate * (require_sdk_constants_math.PERCENTAGE_FACTOR + BigInt(feeInterest)) / require_sdk_constants_math.PERCENTAGE_FACTOR);
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
+
* Annual quota cost of a collateral, in basis points:
|
|
79
|
+
* `quotaRate × (1 + feeInterest)` — the quoted rate plus the protocol's cut of
|
|
80
|
+
* the accrued quota interest, matching {@link calcBorrowApy}.
|
|
81
|
+
*
|
|
82
|
+
* @param quotaRate - Pool quota keeper rate in basis points, without the fee.
|
|
83
|
+
* @param feeInterest - Credit manager interest fee in basis points.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* ```ts
|
|
87
|
+
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%
|
|
88
|
+
* calcQuotaRate(200, 2500) // 2% × 1.25 = 250 bps = 2.5%
|
|
89
|
+
* ```
|
|
90
|
+
**/
|
|
91
|
+
function calcQuotaRate(quotaRate, feeInterest) {
|
|
92
|
+
return Math.round(quotaRate * (FULL + feeInterest) / FULL);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Extra quota, as a fraction of equity, that an aggressive position quotes
|
|
96
|
+
* above the debt it actually owes. Matches {@link MAX_LEVERAGE_BUFFER_BPS}.
|
|
97
|
+
**/
|
|
98
|
+
const DEFAULT_QUOTA_BUFFER_BPS = 500;
|
|
99
|
+
/**
|
|
100
|
+
* Quoted amount per unit of equity at the given leverage and quota mode.
|
|
101
|
+
* Dimensionless: `1` means the quota equals the user's equity.
|
|
102
|
+
**/
|
|
103
|
+
function calcQuotaMultiplier(leverage, lt, quotaMode = "safe") {
|
|
104
|
+
switch (quotaMode) {
|
|
105
|
+
case "min": return leverage - 1;
|
|
106
|
+
case "safe": return leverage * lt / FULL;
|
|
107
|
+
case "aggressive": return (1 + 500 / FULL) * (leverage - 1);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Annual cost of credit on the user's equity, in basis points, at a given
|
|
112
|
+
* leverage and quota mode: base interest on the borrowed part plus quota
|
|
113
|
+
* interest on the quoted amount. Both rates already include the protocol's
|
|
114
|
+
* interest fee.
|
|
115
|
+
*
|
|
116
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
117
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
118
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
119
|
+
**/
|
|
120
|
+
function calcEffectiveBorrowApy(opportunity, leverage, mode = "safe") {
|
|
121
|
+
const { borrowApy, quotaRate, liquidationThreshold } = opportunity;
|
|
122
|
+
return Math.round(borrowApy * (leverage - 1) + quotaRate * calcQuotaMultiplier(leverage, liquidationThreshold, mode));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Net yield of a strategy on the user's equity, in basis points, at a given
|
|
126
|
+
* leverage and quota mode:
|
|
127
|
+
* `leverage × totalCollateralApy − effectiveBorrowApy`. Collateral yield is
|
|
128
|
+
* on the whole position; borrow and quota interest are those of
|
|
129
|
+
* {@link calcEffectiveBorrowApy}.
|
|
130
|
+
*
|
|
131
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
132
|
+
* @param totalCollateralApy - Collateral yield the caller chose, typically
|
|
133
|
+
* `totalApy` of {@link StrategyOpportunity.collateralApy} or
|
|
134
|
+
* {@link StrategyOpportunity.collateralApyAvg7D}.
|
|
135
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
136
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
137
|
+
**/
|
|
138
|
+
function calcNetStrategyApy(opportunity, totalCollateralApy, leverage, mode = "safe") {
|
|
139
|
+
return Math.round(leverage * totalCollateralApy - calcEffectiveBorrowApy(opportunity, leverage, mode));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
78
142
|
* 5% safety margin subtracted from 100% in {@link calcMaxLeverage}, so a
|
|
79
143
|
* maxed position opens with HF slightly above 1.
|
|
80
144
|
**/
|
|
@@ -91,9 +155,11 @@ const MAX_LEVERAGE_BUFFER_BPS = 500;
|
|
|
91
155
|
* // liquidationThreshold: 9000 bps = 90%
|
|
92
156
|
* calcMaxLeverage(9000) // (1 − 0.05) / (1 − 0.9) = 9.5x total exposure
|
|
93
157
|
* ```
|
|
158
|
+
* @throws If `liquidationThreshold` is 100% or more, which would make
|
|
159
|
+
* leverage unbounded.
|
|
94
160
|
**/
|
|
95
161
|
function calcMaxLeverage(liquidationThreshold) {
|
|
96
|
-
if (liquidationThreshold >= FULL)
|
|
162
|
+
if (liquidationThreshold >= FULL) throw new Error("cannot compute max leverage: liquidation threshold is 100% or more");
|
|
97
163
|
const leverage = (FULL - 500) / (FULL - liquidationThreshold);
|
|
98
164
|
return Math.max(leverage, 1);
|
|
99
165
|
}
|
|
@@ -135,21 +201,6 @@ function calcPositionLeverage(totalValue, totalDebt) {
|
|
|
135
201
|
return Number(totalValue) / Number(equity);
|
|
136
202
|
}
|
|
137
203
|
/**
|
|
138
|
-
* Annual quota cost on equity, in basis points:
|
|
139
|
-
* `quotaRate × (1 + feeInterest) × leverage`. Quota accrues on the whole
|
|
140
|
-
* quoted position, and the DAO takes `feeInterest` of it as with base interest.
|
|
141
|
-
*
|
|
142
|
-
* @example
|
|
143
|
-
* ```ts
|
|
144
|
-
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%, leverage: 9.5x
|
|
145
|
-
* calcAdditionalBorrowApy(200, 2500, 9.5) // 2% × 1.25 × 9.5 = 2375 bps = 23.75%
|
|
146
|
-
* ```
|
|
147
|
-
**/
|
|
148
|
-
function calcAdditionalBorrowApy(quotaRate, feeInterest, leverage) {
|
|
149
|
-
if (!Number.isFinite(leverage) || leverage <= 0) return 0;
|
|
150
|
-
return Math.round(quotaRate * (1 + feeInterest / FULL) * leverage);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
204
|
* {@link PERCENTAGE_FACTOR} less a 0.1% safety buffer.
|
|
154
205
|
*
|
|
155
206
|
* Partial liquidation amounts are computed off prices that can drift between
|
|
@@ -205,12 +256,15 @@ function optimalHFForPartialLiquidation(borrowRate) {
|
|
|
205
256
|
return require_sdk_constants_math.PERCENTAGE_FACTOR + (borrowRate < 100n ? borrowRate : 100n);
|
|
206
257
|
}
|
|
207
258
|
//#endregion
|
|
259
|
+
exports.DEFAULT_QUOTA_BUFFER_BPS = DEFAULT_QUOTA_BUFFER_BPS;
|
|
208
260
|
exports.MAX_LEVERAGE_BUFFER_BPS = MAX_LEVERAGE_BUFFER_BPS;
|
|
209
261
|
exports.PARTIAL_LIQUIDATION_BUFFER_BPS = PARTIAL_LIQUIDATION_BUFFER_BPS;
|
|
210
|
-
exports.calcAdditionalBorrowApy = calcAdditionalBorrowApy;
|
|
211
262
|
exports.calcBorrowApy = calcBorrowApy;
|
|
263
|
+
exports.calcEffectiveBorrowApy = calcEffectiveBorrowApy;
|
|
212
264
|
exports.calcMaxLeverage = calcMaxLeverage;
|
|
265
|
+
exports.calcNetStrategyApy = calcNetStrategyApy;
|
|
213
266
|
exports.calcPositionLeverage = calcPositionLeverage;
|
|
267
|
+
exports.calcQuotaRate = calcQuotaRate;
|
|
214
268
|
exports.calcUtilization = calcUtilization;
|
|
215
269
|
exports.healthFactorBps = healthFactorBps;
|
|
216
270
|
exports.minSeizedAmount = minSeizedAmount;
|
|
@@ -91,12 +91,10 @@ const strategyOpportunitySchema = z.object({
|
|
|
91
91
|
expirationDate: timestampSchema.nullable(),
|
|
92
92
|
collateralApy: offchainOnly(apyBreakdownSchema).optional(),
|
|
93
93
|
collateralApyAvg7D: offchainOnly(apyBreakdownSchema).optional(),
|
|
94
|
-
|
|
95
|
-
maxLeverageApyAvg7D: offchainOnly(apyBreakdownSchema).optional(),
|
|
96
|
-
borrowApy: tolerance(bpsSchema, "bps").optional(),
|
|
94
|
+
borrowApy: tolerance(bpsSchema, "bps"),
|
|
97
95
|
borrowApyAvg7D: offchainOnly(bpsSchema).optional(),
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
quotaRate: tolerance(bpsSchema, "bps"),
|
|
97
|
+
quotaRateAvg7D: offchainOnly(bpsSchema).optional(),
|
|
100
98
|
totalValue: offchainOnly(amountSchema).optional(),
|
|
101
99
|
utilization: offchainOnly(bpsSchema).optional(),
|
|
102
100
|
availableLiquidity: tolerance(amountSchema, "amount"),
|
package/dist/esm/sdk/index.js
CHANGED
|
@@ -131,7 +131,7 @@ import { createAdapter } from "./market/adapters/createAdapter.js";
|
|
|
131
131
|
import { CreditConfiguratorV310Contract } from "./market/credit/CreditConfiguratorV310Contract.js";
|
|
132
132
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./market/credit/CreditFacadeV310BaseContract.js";
|
|
133
133
|
import { CreditFacadeV310Contract } from "./market/credit/CreditFacadeV310Contract.js";
|
|
134
|
-
import { MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
134
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./market/math.js";
|
|
135
135
|
import { CreditManagerV310Contract } from "./market/credit/CreditManagerV310Contract.js";
|
|
136
136
|
import { strategyName } from "./market/strategyName.js";
|
|
137
137
|
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES, dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./market/credit/collateralUtils.js";
|
|
@@ -238,4 +238,4 @@ import { OnchainSDK, STATE_VERSION } from "./OnchainSDK.js";
|
|
|
238
238
|
import { MultichainSDK } from "./MultichainSDK.js";
|
|
239
239
|
import { attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
240
240
|
import "./types/index.js";
|
|
241
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, IntentPreviewError, InvalidDelayedIntentError, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString,
|
|
241
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, IntentPreviewError, InvalidDelayedIntentError, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcBorrowApy, calcBorrowRate, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, classifyCurveOperation, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getTokenPrettyName, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, rayToBps, rayToNumber, retry, rewardsFromTransfers, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -6,7 +6,7 @@ import "../../constants/index.js";
|
|
|
6
6
|
import "../../utils/index.js";
|
|
7
7
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
8
8
|
import "../../base/index.js";
|
|
9
|
-
import {
|
|
9
|
+
import { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
|
|
10
10
|
import { strategyName } from "../strategyName.js";
|
|
11
11
|
import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
|
|
12
12
|
import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
@@ -14,6 +14,12 @@ import createCreditFacade from "./createCreditFacade.js";
|
|
|
14
14
|
import createCreditManager from "./createCreditManager.js";
|
|
15
15
|
//#region src/sdk/market/credit/CreditSuite.ts
|
|
16
16
|
/**
|
|
17
|
+
* Amount of underlying seeded into each pool at market creation to protect
|
|
18
|
+
* from inflation attacks, in raw token units. A suite whose remaining borrow
|
|
19
|
+
* capacity is at or below this is treated as having nothing left to lend.
|
|
20
|
+
**/
|
|
21
|
+
const MIN_STRATEGY_BORROW_AMOUNT = 100000n;
|
|
22
|
+
/**
|
|
17
23
|
* SDK aggregate for one credit-manager branch inside a market.
|
|
18
24
|
*
|
|
19
25
|
* @remarks
|
|
@@ -173,13 +179,9 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
173
179
|
/**
|
|
174
180
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
175
181
|
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
176
|
-
*
|
|
177
|
-
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
178
|
-
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
179
|
-
* whatever its collaterals are.
|
|
180
182
|
*/
|
|
181
183
|
get strategyCollaterals() {
|
|
182
|
-
if (this.maxBorrowAmount
|
|
184
|
+
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return [];
|
|
183
185
|
return this.creditManager.collateralTokens.filter((token) => isStrategyCollateral(this.#strategyCollateralProps(token), true));
|
|
184
186
|
}
|
|
185
187
|
/**
|
|
@@ -223,10 +225,10 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
223
225
|
/**
|
|
224
226
|
* Describes this suite's leveraged strategy as the shared read model does,
|
|
225
227
|
* or `undefined` when {@link strategyTargetCollateral} cannot be resolved or
|
|
226
|
-
* {@link maxBorrowAmount} is
|
|
228
|
+
* {@link maxBorrowAmount} is at or below {@link MIN_STRATEGY_BORROW_AMOUNT}.
|
|
227
229
|
*/
|
|
228
230
|
strategyOpportunity() {
|
|
229
|
-
if (this.maxBorrowAmount
|
|
231
|
+
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
|
|
230
232
|
const collateral = this.strategyTargetCollateral;
|
|
231
233
|
if (!collateral) return;
|
|
232
234
|
const { market, creditManager: cm } = this;
|
|
@@ -254,7 +256,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
254
256
|
liquidationFee: cm.feeLiquidation,
|
|
255
257
|
expirationDate: this.expirationDate,
|
|
256
258
|
borrowApy: calcBorrowApy(pool.baseInterestRate, cm.feeInterest),
|
|
257
|
-
|
|
259
|
+
quotaRate: calcQuotaRate(market.pool.pqk.quotaRate(collateral), cm.feeInterest),
|
|
258
260
|
availableLiquidity: oracle.toAmount(pool.underlying, pool.availableLiquidity),
|
|
259
261
|
minDebt: oracle.toAmount(pool.underlying, this.creditFacade.minDebt),
|
|
260
262
|
totalDebtLimit: oracle.toAmount(pool.underlying, debtParams?.limit ?? 0n),
|
|
@@ -87,7 +87,7 @@ import "./adapters/index.js";
|
|
|
87
87
|
import { CreditConfiguratorV310Contract } from "./credit/CreditConfiguratorV310Contract.js";
|
|
88
88
|
import { CreditFacadeV310BaseContract, creditFacadeV310Abi as abi } from "./credit/CreditFacadeV310BaseContract.js";
|
|
89
89
|
import { CreditFacadeV310Contract } from "./credit/CreditFacadeV310Contract.js";
|
|
90
|
-
import { MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
90
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
|
|
91
91
|
import { CreditManagerV310Contract } from "./credit/CreditManagerV310Contract.js";
|
|
92
92
|
import { strategyName } from "./strategyName.js";
|
|
93
93
|
import { NON_STRATEGY_PHANTOM_TOKEN_TYPES, dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./credit/collateralUtils.js";
|
|
@@ -144,4 +144,4 @@ import { RWARegistry } from "./rwa/RWARegistry.js";
|
|
|
144
144
|
import { RWA_FACTORY_TYPES, isRWAFactory } from "./rwa/types.js";
|
|
145
145
|
import "./rwa/index.js";
|
|
146
146
|
import "./types.js";
|
|
147
|
-
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts,
|
|
147
|
+
export { AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterType, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CamelotV3AdapterContract, CompositePriceFeedContract, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LidoV1AdapterContract, LinearInterestRateModelContract, MAX_LEVERAGE_BUFFER_BPS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolSuite, PoolV310Contract, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RWARegistry, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, StakingRewardsAdapterContract, TraderJoePoolVersion, TraderJoeRouterAdapterContract, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpshiftVaultAdapterContract, VelodromeV2RouterAdapterContract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, classifyCurveOperation, createAdapter, createPriceOracle, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
|
|
@@ -74,6 +74,70 @@ function calcBorrowApy(baseInterestRate, feeInterest) {
|
|
|
74
74
|
return rayToBps(baseInterestRate * (PERCENTAGE_FACTOR + BigInt(feeInterest)) / PERCENTAGE_FACTOR);
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
+
* Annual quota cost of a collateral, in basis points:
|
|
78
|
+
* `quotaRate × (1 + feeInterest)` — the quoted rate plus the protocol's cut of
|
|
79
|
+
* the accrued quota interest, matching {@link calcBorrowApy}.
|
|
80
|
+
*
|
|
81
|
+
* @param quotaRate - Pool quota keeper rate in basis points, without the fee.
|
|
82
|
+
* @param feeInterest - Credit manager interest fee in basis points.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%
|
|
87
|
+
* calcQuotaRate(200, 2500) // 2% × 1.25 = 250 bps = 2.5%
|
|
88
|
+
* ```
|
|
89
|
+
**/
|
|
90
|
+
function calcQuotaRate(quotaRate, feeInterest) {
|
|
91
|
+
return Math.round(quotaRate * (FULL + feeInterest) / FULL);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Extra quota, as a fraction of equity, that an aggressive position quotes
|
|
95
|
+
* above the debt it actually owes. Matches {@link MAX_LEVERAGE_BUFFER_BPS}.
|
|
96
|
+
**/
|
|
97
|
+
const DEFAULT_QUOTA_BUFFER_BPS = 500;
|
|
98
|
+
/**
|
|
99
|
+
* Quoted amount per unit of equity at the given leverage and quota mode.
|
|
100
|
+
* Dimensionless: `1` means the quota equals the user's equity.
|
|
101
|
+
**/
|
|
102
|
+
function calcQuotaMultiplier(leverage, lt, quotaMode = "safe") {
|
|
103
|
+
switch (quotaMode) {
|
|
104
|
+
case "min": return leverage - 1;
|
|
105
|
+
case "safe": return leverage * lt / FULL;
|
|
106
|
+
case "aggressive": return (1 + 500 / FULL) * (leverage - 1);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Annual cost of credit on the user's equity, in basis points, at a given
|
|
111
|
+
* leverage and quota mode: base interest on the borrowed part plus quota
|
|
112
|
+
* interest on the quoted amount. Both rates already include the protocol's
|
|
113
|
+
* interest fee.
|
|
114
|
+
*
|
|
115
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
116
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
117
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
118
|
+
**/
|
|
119
|
+
function calcEffectiveBorrowApy(opportunity, leverage, mode = "safe") {
|
|
120
|
+
const { borrowApy, quotaRate, liquidationThreshold } = opportunity;
|
|
121
|
+
return Math.round(borrowApy * (leverage - 1) + quotaRate * calcQuotaMultiplier(leverage, liquidationThreshold, mode));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Net yield of a strategy on the user's equity, in basis points, at a given
|
|
125
|
+
* leverage and quota mode:
|
|
126
|
+
* `leverage × totalCollateralApy − effectiveBorrowApy`. Collateral yield is
|
|
127
|
+
* on the whole position; borrow and quota interest are those of
|
|
128
|
+
* {@link calcEffectiveBorrowApy}.
|
|
129
|
+
*
|
|
130
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
131
|
+
* @param totalCollateralApy - Collateral yield the caller chose, typically
|
|
132
|
+
* `totalApy` of {@link StrategyOpportunity.collateralApy} or
|
|
133
|
+
* {@link StrategyOpportunity.collateralApyAvg7D}.
|
|
134
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
135
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
136
|
+
**/
|
|
137
|
+
function calcNetStrategyApy(opportunity, totalCollateralApy, leverage, mode = "safe") {
|
|
138
|
+
return Math.round(leverage * totalCollateralApy - calcEffectiveBorrowApy(opportunity, leverage, mode));
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
77
141
|
* 5% safety margin subtracted from 100% in {@link calcMaxLeverage}, so a
|
|
78
142
|
* maxed position opens with HF slightly above 1.
|
|
79
143
|
**/
|
|
@@ -90,9 +154,11 @@ const MAX_LEVERAGE_BUFFER_BPS = 500;
|
|
|
90
154
|
* // liquidationThreshold: 9000 bps = 90%
|
|
91
155
|
* calcMaxLeverage(9000) // (1 − 0.05) / (1 − 0.9) = 9.5x total exposure
|
|
92
156
|
* ```
|
|
157
|
+
* @throws If `liquidationThreshold` is 100% or more, which would make
|
|
158
|
+
* leverage unbounded.
|
|
93
159
|
**/
|
|
94
160
|
function calcMaxLeverage(liquidationThreshold) {
|
|
95
|
-
if (liquidationThreshold >= FULL)
|
|
161
|
+
if (liquidationThreshold >= FULL) throw new Error("cannot compute max leverage: liquidation threshold is 100% or more");
|
|
96
162
|
const leverage = (FULL - 500) / (FULL - liquidationThreshold);
|
|
97
163
|
return Math.max(leverage, 1);
|
|
98
164
|
}
|
|
@@ -134,21 +200,6 @@ function calcPositionLeverage(totalValue, totalDebt) {
|
|
|
134
200
|
return Number(totalValue) / Number(equity);
|
|
135
201
|
}
|
|
136
202
|
/**
|
|
137
|
-
* Annual quota cost on equity, in basis points:
|
|
138
|
-
* `quotaRate × (1 + feeInterest) × leverage`. Quota accrues on the whole
|
|
139
|
-
* quoted position, and the DAO takes `feeInterest` of it as with base interest.
|
|
140
|
-
*
|
|
141
|
-
* @example
|
|
142
|
-
* ```ts
|
|
143
|
-
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%, leverage: 9.5x
|
|
144
|
-
* calcAdditionalBorrowApy(200, 2500, 9.5) // 2% × 1.25 × 9.5 = 2375 bps = 23.75%
|
|
145
|
-
* ```
|
|
146
|
-
**/
|
|
147
|
-
function calcAdditionalBorrowApy(quotaRate, feeInterest, leverage) {
|
|
148
|
-
if (!Number.isFinite(leverage) || leverage <= 0) return 0;
|
|
149
|
-
return Math.round(quotaRate * (1 + feeInterest / FULL) * leverage);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
203
|
* {@link PERCENTAGE_FACTOR} less a 0.1% safety buffer.
|
|
153
204
|
*
|
|
154
205
|
* Partial liquidation amounts are computed off prices that can drift between
|
|
@@ -204,4 +255,4 @@ function optimalHFForPartialLiquidation(borrowRate) {
|
|
|
204
255
|
return PERCENTAGE_FACTOR + (borrowRate < 100n ? borrowRate : 100n);
|
|
205
256
|
}
|
|
206
257
|
//#endregion
|
|
207
|
-
export { MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
258
|
+
export { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, PARTIAL_LIQUIDATION_BUFFER_BPS, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
|
|
@@ -263,29 +263,13 @@ interface StrategyOpportunity extends OpportunityBase {
|
|
|
263
263
|
* @mode offchain
|
|
264
264
|
**/
|
|
265
265
|
collateralApyAvg7D?: ApyBreakdown;
|
|
266
|
-
/**
|
|
267
|
-
* Net yield at {@link maxLeverage}:
|
|
268
|
-
* `collateralApy × maxLeverage − borrowApy × (maxLeverage − 1) − additionalBorrowApy`.
|
|
269
|
-
* Yield is on the whole position; borrow interest is on the borrowed part only.
|
|
270
|
-
*
|
|
271
|
-
* Absent in `onchain` mode: its {@link collateralApy} term is.
|
|
272
|
-
*
|
|
273
|
-
* @mode offchain
|
|
274
|
-
**/
|
|
275
|
-
maxLeverageApy?: ApyBreakdown;
|
|
276
|
-
/**
|
|
277
|
-
* Average {@link maxLeverageApy} over the trailing seven days.
|
|
278
|
-
*
|
|
279
|
-
* @mode offchain
|
|
280
|
-
**/
|
|
281
|
-
maxLeverageApyAvg7D?: ApyBreakdown;
|
|
282
266
|
/**
|
|
283
267
|
* Annual cost of the borrowed underlying, in basis points, including the
|
|
284
268
|
* protocol's interest fee.
|
|
285
269
|
*
|
|
286
270
|
* @example `520` for 5.2% APY
|
|
287
271
|
**/
|
|
288
|
-
borrowApy
|
|
272
|
+
borrowApy: Bps;
|
|
289
273
|
/**
|
|
290
274
|
* Average {@link borrowApy} over the trailing seven days, in basis points.
|
|
291
275
|
*
|
|
@@ -295,22 +279,22 @@ interface StrategyOpportunity extends OpportunityBase {
|
|
|
295
279
|
**/
|
|
296
280
|
borrowApyAvg7D?: Bps;
|
|
297
281
|
/**
|
|
298
|
-
* Annual cost of
|
|
299
|
-
* `quotaRate × (1 + feeInterest)
|
|
300
|
-
* quoted
|
|
282
|
+
* Annual quota cost of {@link targetCollateral}, in basis points, including
|
|
283
|
+
* the protocol's interest fee: `pqk.quotaRate × (1 + feeInterest)`. Quota
|
|
284
|
+
* accrues on the quoted amount and carries the same DAO fee as
|
|
285
|
+
* {@link borrowApy}.
|
|
301
286
|
*
|
|
302
|
-
* @example `90` for
|
|
287
|
+
* @example `90` for 0.9% APY
|
|
303
288
|
**/
|
|
304
|
-
|
|
289
|
+
quotaRate: Bps;
|
|
305
290
|
/**
|
|
306
|
-
* Average {@link
|
|
307
|
-
* points.
|
|
291
|
+
* Average {@link quotaRate} over the trailing seven days, in basis points.
|
|
308
292
|
*
|
|
309
293
|
* Absent in `onchain` mode: calculating it requires historical data.
|
|
310
294
|
*
|
|
311
295
|
* @mode offchain
|
|
312
296
|
**/
|
|
313
|
-
|
|
297
|
+
quotaRateAvg7D?: Bps;
|
|
314
298
|
/**
|
|
315
299
|
* Size of the strategy: the summed total value of the credit accounts
|
|
316
300
|
* opened in this credit manager.
|
|
@@ -363,58 +363,10 @@ declare const strategyOpportunitySchema: z.ZodObject<{
|
|
|
363
363
|
}, z.core.$strip>>;
|
|
364
364
|
}, z.core.$strip>], "kind">>>;
|
|
365
365
|
}, z.core.$strip>>;
|
|
366
|
-
|
|
367
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
368
|
-
organicApy: z.ZodNumber;
|
|
369
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
370
|
-
kind: z.ZodLiteral<"token">;
|
|
371
|
-
token: z.ZodObject<{
|
|
372
|
-
chainId: z.ZodNumber;
|
|
373
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
374
|
-
symbol: z.ZodString;
|
|
375
|
-
name: z.ZodString;
|
|
376
|
-
decimals: z.ZodNumber;
|
|
377
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
378
|
-
}, z.core.$strip>;
|
|
379
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
380
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
381
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
382
|
-
kind: z.ZodLiteral<"point">;
|
|
383
|
-
points: z.ZodArray<z.ZodObject<{
|
|
384
|
-
id: z.ZodString;
|
|
385
|
-
name: z.ZodString;
|
|
386
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
387
|
-
}, z.core.$strip>>;
|
|
388
|
-
}, z.core.$strip>], "kind">>>;
|
|
389
|
-
}, z.core.$strip>>;
|
|
390
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
391
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
392
|
-
organicApy: z.ZodNumber;
|
|
393
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
394
|
-
kind: z.ZodLiteral<"token">;
|
|
395
|
-
token: z.ZodObject<{
|
|
396
|
-
chainId: z.ZodNumber;
|
|
397
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
398
|
-
symbol: z.ZodString;
|
|
399
|
-
name: z.ZodString;
|
|
400
|
-
decimals: z.ZodNumber;
|
|
401
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
402
|
-
}, z.core.$strip>;
|
|
403
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
404
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
405
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
406
|
-
kind: z.ZodLiteral<"point">;
|
|
407
|
-
points: z.ZodArray<z.ZodObject<{
|
|
408
|
-
id: z.ZodString;
|
|
409
|
-
name: z.ZodString;
|
|
410
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
411
|
-
}, z.core.$strip>>;
|
|
412
|
-
}, z.core.$strip>], "kind">>>;
|
|
413
|
-
}, z.core.$strip>>;
|
|
414
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
366
|
+
borrowApy: z.ZodNumber;
|
|
415
367
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
416
|
-
|
|
417
|
-
|
|
368
|
+
quotaRate: z.ZodNumber;
|
|
369
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
418
370
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
419
371
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
420
372
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -654,58 +606,10 @@ declare const opportunitySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
654
606
|
}, z.core.$strip>>;
|
|
655
607
|
}, z.core.$strip>], "kind">>>;
|
|
656
608
|
}, z.core.$strip>>;
|
|
657
|
-
|
|
658
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
659
|
-
organicApy: z.ZodNumber;
|
|
660
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
661
|
-
kind: z.ZodLiteral<"token">;
|
|
662
|
-
token: z.ZodObject<{
|
|
663
|
-
chainId: z.ZodNumber;
|
|
664
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
665
|
-
symbol: z.ZodString;
|
|
666
|
-
name: z.ZodString;
|
|
667
|
-
decimals: z.ZodNumber;
|
|
668
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
669
|
-
}, z.core.$strip>;
|
|
670
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
671
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
672
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
673
|
-
kind: z.ZodLiteral<"point">;
|
|
674
|
-
points: z.ZodArray<z.ZodObject<{
|
|
675
|
-
id: z.ZodString;
|
|
676
|
-
name: z.ZodString;
|
|
677
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
678
|
-
}, z.core.$strip>>;
|
|
679
|
-
}, z.core.$strip>], "kind">>>;
|
|
680
|
-
}, z.core.$strip>>;
|
|
681
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
682
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
683
|
-
organicApy: z.ZodNumber;
|
|
684
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
685
|
-
kind: z.ZodLiteral<"token">;
|
|
686
|
-
token: z.ZodObject<{
|
|
687
|
-
chainId: z.ZodNumber;
|
|
688
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
689
|
-
symbol: z.ZodString;
|
|
690
|
-
name: z.ZodString;
|
|
691
|
-
decimals: z.ZodNumber;
|
|
692
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
693
|
-
}, z.core.$strip>;
|
|
694
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
695
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
696
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
697
|
-
kind: z.ZodLiteral<"point">;
|
|
698
|
-
points: z.ZodArray<z.ZodObject<{
|
|
699
|
-
id: z.ZodString;
|
|
700
|
-
name: z.ZodString;
|
|
701
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
702
|
-
}, z.core.$strip>>;
|
|
703
|
-
}, z.core.$strip>], "kind">>>;
|
|
704
|
-
}, z.core.$strip>>;
|
|
705
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
609
|
+
borrowApy: z.ZodNumber;
|
|
706
610
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
707
|
-
|
|
708
|
-
|
|
611
|
+
quotaRate: z.ZodNumber;
|
|
612
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
709
613
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
710
614
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
711
615
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1105,58 +1009,10 @@ declare const strategyOpportunityDetailSchema: z.ZodObject<{
|
|
|
1105
1009
|
}, z.core.$strip>>;
|
|
1106
1010
|
}, z.core.$strip>], "kind">>>;
|
|
1107
1011
|
}, z.core.$strip>>;
|
|
1108
|
-
|
|
1109
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1110
|
-
organicApy: z.ZodNumber;
|
|
1111
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1112
|
-
kind: z.ZodLiteral<"token">;
|
|
1113
|
-
token: z.ZodObject<{
|
|
1114
|
-
chainId: z.ZodNumber;
|
|
1115
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1116
|
-
symbol: z.ZodString;
|
|
1117
|
-
name: z.ZodString;
|
|
1118
|
-
decimals: z.ZodNumber;
|
|
1119
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1120
|
-
}, z.core.$strip>;
|
|
1121
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1122
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1123
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1124
|
-
kind: z.ZodLiteral<"point">;
|
|
1125
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1126
|
-
id: z.ZodString;
|
|
1127
|
-
name: z.ZodString;
|
|
1128
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1129
|
-
}, z.core.$strip>>;
|
|
1130
|
-
}, z.core.$strip>], "kind">>>;
|
|
1131
|
-
}, z.core.$strip>>;
|
|
1132
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
1133
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1134
|
-
organicApy: z.ZodNumber;
|
|
1135
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1136
|
-
kind: z.ZodLiteral<"token">;
|
|
1137
|
-
token: z.ZodObject<{
|
|
1138
|
-
chainId: z.ZodNumber;
|
|
1139
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1140
|
-
symbol: z.ZodString;
|
|
1141
|
-
name: z.ZodString;
|
|
1142
|
-
decimals: z.ZodNumber;
|
|
1143
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1144
|
-
}, z.core.$strip>;
|
|
1145
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1146
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1147
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1148
|
-
kind: z.ZodLiteral<"point">;
|
|
1149
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1150
|
-
id: z.ZodString;
|
|
1151
|
-
name: z.ZodString;
|
|
1152
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1153
|
-
}, z.core.$strip>>;
|
|
1154
|
-
}, z.core.$strip>], "kind">>>;
|
|
1155
|
-
}, z.core.$strip>>;
|
|
1156
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
1012
|
+
borrowApy: z.ZodNumber;
|
|
1157
1013
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1158
|
-
|
|
1159
|
-
|
|
1014
|
+
quotaRate: z.ZodNumber;
|
|
1015
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1160
1016
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
1161
1017
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1162
1018
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -1448,58 +1304,10 @@ declare const opportunityDetailSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
1448
1304
|
}, z.core.$strip>>;
|
|
1449
1305
|
}, z.core.$strip>], "kind">>>;
|
|
1450
1306
|
}, z.core.$strip>>;
|
|
1451
|
-
|
|
1452
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1453
|
-
organicApy: z.ZodNumber;
|
|
1454
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1455
|
-
kind: z.ZodLiteral<"token">;
|
|
1456
|
-
token: z.ZodObject<{
|
|
1457
|
-
chainId: z.ZodNumber;
|
|
1458
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1459
|
-
symbol: z.ZodString;
|
|
1460
|
-
name: z.ZodString;
|
|
1461
|
-
decimals: z.ZodNumber;
|
|
1462
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1463
|
-
}, z.core.$strip>;
|
|
1464
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1465
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1466
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1467
|
-
kind: z.ZodLiteral<"point">;
|
|
1468
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1469
|
-
id: z.ZodString;
|
|
1470
|
-
name: z.ZodString;
|
|
1471
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1472
|
-
}, z.core.$strip>>;
|
|
1473
|
-
}, z.core.$strip>], "kind">>>;
|
|
1474
|
-
}, z.core.$strip>>;
|
|
1475
|
-
maxLeverageApyAvg7D: z.ZodOptional<z.ZodObject<{
|
|
1476
|
-
totalApy: z.ZodOptional<z.ZodNumber>;
|
|
1477
|
-
organicApy: z.ZodNumber;
|
|
1478
|
-
rewards: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
1479
|
-
kind: z.ZodLiteral<"token">;
|
|
1480
|
-
token: z.ZodObject<{
|
|
1481
|
-
chainId: z.ZodNumber;
|
|
1482
|
-
address: z.ZodCodec<z.ZodString, z.ZodCustom<`0x${string}`, `0x${string}`>>;
|
|
1483
|
-
symbol: z.ZodString;
|
|
1484
|
-
name: z.ZodString;
|
|
1485
|
-
decimals: z.ZodNumber;
|
|
1486
|
-
assetType: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"Stable">, z.ZodLiteral<"ETH">, z.ZodLiteral<"BTC">]>>;
|
|
1487
|
-
}, z.core.$strip>;
|
|
1488
|
-
supplyApr: z.ZodOptional<z.ZodNumber>;
|
|
1489
|
-
borrowApr: z.ZodOptional<z.ZodNumber>;
|
|
1490
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
1491
|
-
kind: z.ZodLiteral<"point">;
|
|
1492
|
-
points: z.ZodArray<z.ZodObject<{
|
|
1493
|
-
id: z.ZodString;
|
|
1494
|
-
name: z.ZodString;
|
|
1495
|
-
multiplier: z.ZodNullable<z.ZodNumber>;
|
|
1496
|
-
}, z.core.$strip>>;
|
|
1497
|
-
}, z.core.$strip>], "kind">>>;
|
|
1498
|
-
}, z.core.$strip>>;
|
|
1499
|
-
borrowApy: z.ZodOptional<z.ZodNumber>;
|
|
1307
|
+
borrowApy: z.ZodNumber;
|
|
1500
1308
|
borrowApyAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1501
|
-
|
|
1502
|
-
|
|
1309
|
+
quotaRate: z.ZodNumber;
|
|
1310
|
+
quotaRateAvg7D: z.ZodOptional<z.ZodNumber>;
|
|
1503
1311
|
totalValue: z.ZodOptional<z.ZodObject<{
|
|
1504
1312
|
value: z.ZodCodec<z.ZodUnion<[z.ZodString, z.ZodBigInt]>, z.ZodBigInt>;
|
|
1505
1313
|
valueUsd: z.ZodNullable<z.ZodNumber>;
|
|
@@ -181,7 +181,7 @@ import { ZapperContract } from "./market/zapper/ZapperContract.js";
|
|
|
181
181
|
import { IERC20ZapperContract } from "./market/zapper/IERC20ZapperContract.js";
|
|
182
182
|
import { IETHZapperContract } from "./market/zapper/IETHZapperContract.js";
|
|
183
183
|
import { MarketRegister, MarketRegistryState, MarketRegistryStateHuman } from "./market/MarketRegister.js";
|
|
184
|
-
import { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
184
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, QuotaMode, StrategyRateInputs, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./market/math.js";
|
|
185
185
|
import { strategyName } from "./market/strategyName.js";
|
|
186
186
|
import "./market/index.js";
|
|
187
187
|
import { BasePlugin } from "./plugins/BasePlugin.js";
|
|
@@ -262,4 +262,4 @@ import { LiquidationsService } from "./accounts/liquidations/LiquidationsService
|
|
|
262
262
|
import { MultichainLiquidationsService } from "./accounts/liquidations/MultichainLiquidationsService.js";
|
|
263
263
|
import "./accounts/index.js";
|
|
264
264
|
import { SDKOptions, attachOptionsSchema, onchainSDKOptionsSchema } from "./options.js";
|
|
265
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, ClaimFarmRewardsProps, ClaimableWithdrawal, ClientOptions, CloseCreditAccountResult, ClosePathBalances, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, FluidDexAdapterContract, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetReward, GetWithdrawalRequestResultProps, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, type InstantRoute, IntentPreviewError, type IntentPreviewResult, type IntentRoutesResult, type InterestRateModelStateHuman, InterestRateModelType, InvalidDelayedIntentError, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidationFees, LiquidationsService, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, type MarketStateHuman, MarketSuite, MarketType, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OperationState, OpportunitiesService, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolV310Contract, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, type PreviewErrorReason, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, QuotaKeeperState, type QuotaParamsHuman, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWALiquidatorInfo, RWAMissingOpenAccountRequirements, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteRefusals, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOnRampAdapterContract, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, StakingRewardsAdapterContract, type StartIntent, StrategyCollateralProps, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokensMeta, TokensMetaState, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, type WithBlock, type WithMultichain, type WithdrawAssetIntent, WithdrawCollateral, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcAdditionalBorrowApy, calcBorrowApy, calcBorrowRate, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcPositionLeverage, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, classifyCurveOperation, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getTokenPrettyName, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, rayToBps, rayToNumber, retry, rewardsFromTransfers, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
265
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountMigratorAdapterContract, AccountSnapshot, AccountToCheck, AdapterContractStateHuman, AdapterContractType, AdapterData, AdapterFactoryArgs, AdapterProtocolOperation, AdapterType, type AddCollateralIntent, AddLiquidityProps, AddressMap, AddressProviderAddresses, AddressProviderState, AddressProviderV310Contract, type AddressProviderV3StateHuman, AddressSet, type AdjustLeverageIntent, type AliasLossPolicyStateHuman, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, AssertAssignable, Asset, type AssetPriceFeedStateHuman, AssetsMap, AttachOptions, BLOCKS_PER_WEEK_BY_NETWORK, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, type BalancerWeightedPriceFeedStateHuman, BaseContract, BaseContractArgs, type BaseContractStateHuman, BaseParams, BasePlugin, type BasePriceFeedStateHuman, BaseState, BasicSwapCall, BigIntMath, type BlockNumberProps, type BotListStateHuman, BotPermissions, BotStatusCall, BotsDirectResponse, type BoundedOracleStateHuman, BoundedPriceFeedContract, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcBorrowRateProps, CalcHealthFactorProps, CalcLiquidationPriceForTargetProps, CalcLiquidationPriceProps, CamelotPool, CamelotV3AdapterContract, ChainBlock, ChainBlockPin, ChainBlockSource, ChainConfig, ChainContractsRegister, ChainNotConfiguredError, ChainQueryOneProps, ChainQueryProps, ClaimFarmRewardsProps, ClaimableWithdrawal, ClientOptions, CloseCreditAccountResult, ClosePathBalances, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConnectedBotData, ConnectedBotsCall, ConnectedBotsPerAccount, type ConstantOracleStateHuman, Construct, ConstructOptions, type ContractMethod, ContractOrInterface, ContractParseError, ContractParseErrorOptions, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, type CoreStateHuman, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountData, CreditAccountDataCall, CreditAccountDataPayload, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountTokenQuota, CreditAccountTokensSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditConfiguratorState, type CreditConfiguratorStateHuman, CreditConfiguratorV310Contract, CreditFacadeState, type CreditFacadeStateHuman, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerDebtParams, type CreditManagerDebtParamsHuman, CreditManagerFilter, CreditManagerOperationResult, CreditManagerState, type CreditManagerStateHuman, CreditManagerV310Contract, CreditSuite, CreditSuiteState, type CreditSuiteStateHuman, CurrentWithdrawals, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DStokenData, DUST_THRESHOLD, DaiUsdsAdapterContract, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, DelayedWithdrawalClaim, DelayedWithdrawalRequest, DelegatedMulticall, DepositMetadata, type DepositStrategyIntent, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EncodableCreditAccountOperation, Erc4626PriceFeedContract, EstimateRawTxGasParameters, EtherscanURLParam, ExecuteMulticallBatchesOptions, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, FilterDustUSDOptions, FindBestClosePathProps, FindClaimAllRewardsProps, FindManyToOnePathProps, FindOneTokenPathProps, FindOpenStrategyPathProps, type FinishIntentProps, FluidDexAdapterContract, FormatBNOptions, FullyLiquidateProps, FullyLiquidateResult, GaugeContract, GaugeData, GaugeParams, type GaugeParamsHuman, type GaugeStateHuman, type GearStakingV3StateHuman, GearboxChain, type GearboxState, type GearboxStateHuman, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetOpenAccountRequirementsProps, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetReward, GetWithdrawalRequestResultProps, HydrateOptions, IAdapterContract, IAddressProviderContract, IBaseContract, ICreditAccountsService, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, type ILogger, IOnchainSDKPlugin, IOnchainSDKPluginConstructor, IPluginState, IPoolContract, IPoolsService, IPriceFeedContract, IPriceOracleContract, type IPriceUpdateTx, IRWAFactory, IRateKeeperContract, IRedemptionLoggerContract, IRouterContract, IUpdatablePriceFeedContract, IWithdrawalCompressorContract, IZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, type InstantRoute, IntentPreviewError, type IntentPreviewResult, type IntentRoutesResult, type InterestRateModelStateHuman, InterestRateModelType, InvalidDelayedIntentError, IsDustOptions, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LPMonopolizedPoolMeta, type LPPriceFeedStateHuman, LatestUpdate, LegacyAdapterOperation, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, type LinearInterestRateModelStateHuman, LiquidationFees, LiquidationsService, ListPoolPositionsProps, ListPositionsProps, ListPositionsPropsBase, ListStrategyPositionsProps, LoadRWALiquidatorsProps, type LogFn, type LossPolicyStateHuman, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, MakerDeposit, MakerRedeem, MarketData, MarketFilter, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, type MarketStateHuman, MarketSuite, MarketType, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, Methods, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, type MultiCall, MulticallBatch, MulticallWithFailure, MultichainAttachOptions, type MultichainChainIdsProps, MultichainConstruct, MultichainHydrateOptions, MultichainLiquidationsService, type MultichainNetworkProps, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, MultichainSDKOptions, type MultichainState, type MultichainStateHuman, MultichainSyncStateOptions, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OnchainSDK, OnchainSDKOptions, OpenCAProps, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, OpenStrategyResult, type OperationState, OpportunitiesService, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, ParsedCall, ParsedCallArgs, ParsedCallV2, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PartialRecord, PartiallyLiquidateProps, PendingWithdrawal, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PeripheryContract, PermitResult, PhantomTokenContractType, PhantomTokenMeta, PickSomeRequired, PluginFactoriesMap, PluginFactory, PluginState, PluginStateVersionError, PluginStatesMap, PluginsMap, PoolQuotaKeeperContract, type PoolQuotaKeeperStateHuman, PoolService, PoolServiceCall, PoolServiceCallResult, PoolSimulation, PoolState, type PoolStateHuman, PoolSuite, type PoolSuiteStateHuman, PoolV310Contract, PositionsService, PrepareUpdateQuotasProps, PreviewDelayedWithdrawalProps, type PreviewErrorReason, PriceFeedAnswer, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedMapEntry, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, type PriceFeedStateHuman, PriceFeedTreeNode, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleData, type PriceOracleStateHuman, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, QuotaKeeperState, QuotaMode, type QuotaParamsHuman, QuotaState, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWADefaultTokenMeta, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWALiquidatorInfo, RWAMissingOpenAccountRequirements, RWAOnDemandLPMeta, RWAOnDemandLPMonopolizedMeta, RWAOnDemandLpContractType, RWAOnDemandTokenMeta, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWATokenMeta, RWAUnderlyingContractType, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RampEvent, RateKeeperState, type RateKeeperStateHuman, RateKeeperType, type RawTx, RedemptionLog, RedemptionLoggerV310Contract, RedstonePriceFeedContract, type RedstonePriceFeedStateHuman, RelaxedBaseParams, RemoveLiquidityProps, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, RetryOptions, RewardInfo, Rewards, type RouteRefusals, RouterCASlice, RouterCMSlice, RouterCloseResult, RouterResult, RouterRewardsResult, RouterV310Contract, SDKConstruct, SDKOptions, SECONDS_PER_YEAR, SECURITIZE_REGISTER_VAULT_TYPES, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOnRampAdapterContract, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, SendRawTxParameters, SetBotProps, SetBotResult, SimpleTokenMeta, SimulateCallOptions, SimulateCallParameters, SimulateCallReturnType, SimulateMulticallParameters, SimulateMulticallReturnType, SimulatePoolOperationProps, SimulateWithPriceUpdatesError, SimulateWithPriceUpdatesErrorParams, SimulateWithPriceUpdatesErrorType, SimulateWithPriceUpdatesParameters, SimulateWithPriceUpdatesReturnType, SimulationError, SimulationErrorType, StakingRewardsAdapterContract, type StartIntent, StrategyCollateralProps, StrategyRateInputs, SupportedValue, Swap, SwapOperation, SyncStateOptions, type TimestampedCalldata, TokenAmount, TokenInfo, TokenMetaData, TokensMeta, TokensMetaState, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, type TumblerStateHuman, TypedObjectUtils, Unarray, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, UpshiftVaultAdapterContract, VERSION_RANGE_310, VaultDeposit, VelodromeV2RouterAdapterContract, VersionRange, VersionedAbi, VotingContractStatus, WAD, WAD_DECIMALS_POW, WatchBlocksAsyncParameters, WatchBlocksAsyncReturnType, type WithBlock, type WithMultichain, type WithdrawAssetIntent, WithdrawCollateral, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalMetadata, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, type ZapperStateHuman, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, assetsMap, attachOptionsSchema, botPermissionsToString, bytes32ToString, calcBorrowApy, calcBorrowRate, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcTimeToLiquidationMs, calcUtilization, chains, childLogger, classifyCurveOperation, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCuratorMarketConfigurator, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getTokenPrettyName, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isDust, isLPPriceFeed, isPublicNetwork, isRWAFactory, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, percentFmt, pickStrategyTargetCollateral, rayToBps, rayToNumber, retry, rewardsFromTransfers, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toShares, toSharesUp, toSignificant, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
@@ -137,10 +137,6 @@ declare class CreditSuite extends SDKConstruct {
|
|
|
137
137
|
/**
|
|
138
138
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
139
139
|
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
140
|
-
*
|
|
141
|
-
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
142
|
-
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
143
|
-
* whatever its collaterals are.
|
|
144
140
|
*/
|
|
145
141
|
get strategyCollaterals(): Address[];
|
|
146
142
|
/**
|
|
@@ -172,7 +168,7 @@ declare class CreditSuite extends SDKConstruct {
|
|
|
172
168
|
/**
|
|
173
169
|
* Describes this suite's leveraged strategy as the shared read model does,
|
|
174
170
|
* or `undefined` when {@link strategyTargetCollateral} cannot be resolved or
|
|
175
|
-
* {@link maxBorrowAmount} is
|
|
171
|
+
* {@link maxBorrowAmount} is at or below {@link MIN_STRATEGY_BORROW_AMOUNT}.
|
|
176
172
|
*/
|
|
177
173
|
strategyOpportunity(): StrategyOpportunity | undefined;
|
|
178
174
|
/**
|
|
@@ -149,6 +149,6 @@ import { IERC20ZapperContract } from "./zapper/IERC20ZapperContract.js";
|
|
|
149
149
|
import { IETHZapperContract } from "./zapper/IETHZapperContract.js";
|
|
150
150
|
import "./zapper/index.js";
|
|
151
151
|
import { MarketRegister, MarketRegistryState, MarketRegistryStateHuman } from "./MarketRegister.js";
|
|
152
|
-
import { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
152
|
+
import { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, QuotaMode, StrategyRateInputs, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber } from "./math.js";
|
|
153
153
|
import { strategyName } from "./strategyName.js";
|
|
154
|
-
export { AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterContractStateHuman, AdapterContractType, AdapterFactoryArgs, AdapterProtocolOperation, AdapterType, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BasicSwapCall, BoundedPriceFeedContract, CamelotPool, CamelotV3AdapterContract, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, CreditAccountTokenQuota, CreditConfiguratorV310Contract, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DStokenData, DaiUsdsAdapterContract, DelayedWithdrawalClaim, DelayedWithdrawalRequest, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, FluidDexAdapterContract, GaugeContract, GaugeParams, GetOpenAccountRequirementsProps, GetReward, IAdapterContract, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, IPoolContract, IPriceFeedContract, IPriceOracleContract, IRWAFactory, IRateKeeperContract, IUpdatablePriceFeedContract, IZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InterestRateModelType, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LatestUpdate, LegacyAdapterOperation, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationFees, MAX_LEVERAGE_BUFFER_BPS, MakerDeposit, MakerRedeem, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolQuotaKeeperContract, PoolSuite, PoolV310Contract, PrepareUpdateQuotasProps, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RampEvent, RateKeeperType, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOnRampAdapterContract, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StakingRewardsAdapterContract, StrategyCollateralProps, Swap, type TimestampedCalldata, TokenAmount, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, UpshiftVaultAdapterContract, VaultDeposit, VelodromeV2RouterAdapterContract, VersionedAbi, WithdrawCollateral, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts,
|
|
154
|
+
export { AbstractAdapterContract, AbstractAdapterContractOptions, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AccountMigratorAdapterContract, AdapterContractStateHuman, AdapterContractType, AdapterFactoryArgs, AdapterProtocolOperation, AdapterType, BalanceDelta, BalancerStablePriceFeedContract, BalancerSwap, BalancerV3Pool, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BasicSwapCall, BoundedPriceFeedContract, CamelotPool, CamelotV3AdapterContract, CompositePriceFeedContract, CompressorZapperData, ConcreteAdapterContractOptions, ConvexDeposit, ConvexDepositAndStake, ConvexStake, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, ConvexWithdraw, ConvexWithdrawAndClaim, CreditAccountTokenQuota, CreditConfiguratorV310Contract, type abi as CreditFacadeV310Abi, abi as creditFacadeV310Abi, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveAddLiquidity, CurveClaims, CurveCryptoPriceFeedContract, CurveExchange, CurveRemoveLiquidity, CurveRemoveLiquidityOneCoin, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, CurveWithdrawal, DEFAULT_QUOTA_BUFFER_BPS, DStokenData, DaiUsdsAdapterContract, DelayedWithdrawalClaim, DelayedWithdrawalRequest, ERC4626AdapterContract, ERC4626ReferralAdapterContract, Erc4626PriceFeedContract, ExpectedBalanceDeltasProps, ExpectedOutput, ExternalPriceFeedContract, type FetchRedstonePayloadsOptions, FluidDexAdapterContract, GaugeContract, GaugeParams, GetOpenAccountRequirementsProps, GetReward, IAdapterContract, ICreditConfiguratorContract, ICreditFacadeContract, ICreditManagerContract, IERC20ZapperContract, IETHZapperContract, IInterestRateModelContract, IPoolContract, IPriceFeedContract, IPriceOracleContract, IRWAFactory, IRateKeeperContract, IUpdatablePriceFeedContract, IZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, InterestRateModelType, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LatestUpdate, LegacyAdapterOperation, LidoSubmit, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationFees, MAX_LEVERAGE_BUFFER_BPS, MakerDeposit, MakerRedeem, MarketRegister, MarketRegistryState, MarketRegistryStateHuman, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, NON_STRATEGY_PHANTOM_TOKEN_TYPES, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, ParsedZapperDeposit, ParsedZapperOperation, ParsedZapperRedeem, PartialLiquidationParams, PartialPriceFeedInitError, PartialPriceFeedTreeNode, PendlePair, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PoolQuotaKeeperContract, PoolSuite, PoolV310Contract, PrepareUpdateQuotasProps, PriceFeedConstructorArgs, PriceFeedContractType, PriceFeedRef, PriceFeedRegister, PriceFeedRegisterHooks, PriceFeedRegisterOptions, PriceFeedUsageType, PriceFeedsForAccountOptions, PriceFeedsForTokensOptions, PriceOracleV310Contract, PriceUpdate, PythPriceFeed, QuotaMode, RWACompressorCall, RWACompressorInvestorData, RWACompressorResponse, RWAFactoryData, RWAFactoryStateHuman, RWAFactoryType, RWAInvestorData, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWARegistry, RWAState, RWAStateHuman, RWAUnderlyingData, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RampEvent, RateKeeperType, RedstonePriceFeedContract, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeCreditAccountData, SecuritizeInvestorData, SecuritizeLiquidatorContract, SecuritizeMissingOpenAccountRequirements, SecuritizeOnRampAdapterContract, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRWAFactory, SecuritizeRWAFactoryStateHuman, SecuritizeRedemptionGatewayAdapterContract, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature, StakingRewardsAdapterContract, StrategyCollateralProps, StrategyRateInputs, Swap, type TimestampedCalldata, TokenAmount, TraderJoePool, TraderJoePoolVersion, TraderJoeRouterAdapterContract, Transfers, UniswapSwap, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UnsupportedZapperFunctionError, UpdatePriceFeedsResult, UpshiftVaultAdapterContract, VaultDeposit, VelodromeV2RouterAdapterContract, VersionedAbi, WithdrawCollateral, WstETHPriceFeedContract, WstETHUnwrap, WstETHV1AdapterContract, WstETHWrap, YearnPriceFeedContract, ZapperContract, ZapperData, ZeroPriceFeedContract, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, classifyCurveOperation, createAdapter, createPriceOracle, createZapper, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, dominantCollateral, erc4626ReferralAdapterAbi, expectedBalanceDeltas, fetchRedstonePayloads, fnSigToName, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getRawPriceUpdates, hasAdapterDeployParamsAbi, healthFactorBps, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isLPPriceFeed, isRWAFactory, isStrategyCollateral, isUpdatablePriceFeed, iwstETHAbi, iwstEthv1AdapterAbi, lidoV1_WETHGatewayAbi, mellowDvvAdapterAbi, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parsePosNegAmount, pickStrategyTargetCollateral, rayToBps, rewardsFromTransfers, strategyName, swapFromTransfers, toNetTransfers, usdToNumber };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Bps, Leverage } from "../../model/primitives.js";
|
|
2
|
+
import { StrategyOpportunity } from "../../model/opportunities.js";
|
|
2
3
|
import "../../model/index.js";
|
|
3
4
|
//#region src/sdk/market/math.d.ts
|
|
4
5
|
/**
|
|
@@ -50,6 +51,66 @@ declare function calcUtilization(borrowed: bigint, total: bigint): Bps;
|
|
|
50
51
|
* ```
|
|
51
52
|
**/
|
|
52
53
|
declare function calcBorrowApy(baseInterestRate: bigint, feeInterest: number): Bps;
|
|
54
|
+
/**
|
|
55
|
+
* Annual quota cost of a collateral, in basis points:
|
|
56
|
+
* `quotaRate × (1 + feeInterest)` — the quoted rate plus the protocol's cut of
|
|
57
|
+
* the accrued quota interest, matching {@link calcBorrowApy}.
|
|
58
|
+
*
|
|
59
|
+
* @param quotaRate - Pool quota keeper rate in basis points, without the fee.
|
|
60
|
+
* @param feeInterest - Credit manager interest fee in basis points.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%
|
|
65
|
+
* calcQuotaRate(200, 2500) // 2% × 1.25 = 250 bps = 2.5%
|
|
66
|
+
* ```
|
|
67
|
+
**/
|
|
68
|
+
declare function calcQuotaRate(quotaRate: Bps, feeInterest: Bps): Bps;
|
|
69
|
+
/**
|
|
70
|
+
* Extra quota, as a fraction of equity, that an aggressive position quotes
|
|
71
|
+
* above the debt it actually owes. Matches {@link MAX_LEVERAGE_BUFFER_BPS}.
|
|
72
|
+
**/
|
|
73
|
+
declare const DEFAULT_QUOTA_BUFFER_BPS = 500;
|
|
74
|
+
/**
|
|
75
|
+
* How much quota a leveraged position quotes, relative to the debt it needs.
|
|
76
|
+
*
|
|
77
|
+
* - `"min"` — quota covers exactly the borrowed amount (`leverage − 1`).
|
|
78
|
+
* - `"safe"` — quota covers the full LT-weighted position (`leverage × LT`),
|
|
79
|
+
* so a price drop to the liquidation threshold still leaves enough quota.
|
|
80
|
+
* - `"aggressive"` — quota covers the debt plus {@link DEFAULT_QUOTA_BUFFER_BPS}.
|
|
81
|
+
**/
|
|
82
|
+
type QuotaMode = "min" | "safe" | "aggressive";
|
|
83
|
+
/**
|
|
84
|
+
* Rates {@link calcEffectiveBorrowApy} and {@link calcNetStrategyApy} need
|
|
85
|
+
* from a {@link StrategyOpportunity}.
|
|
86
|
+
**/
|
|
87
|
+
type StrategyRateInputs = Pick<StrategyOpportunity, "borrowApy" | "quotaRate" | "liquidationThreshold">;
|
|
88
|
+
/**
|
|
89
|
+
* Annual cost of credit on the user's equity, in basis points, at a given
|
|
90
|
+
* leverage and quota mode: base interest on the borrowed part plus quota
|
|
91
|
+
* interest on the quoted amount. Both rates already include the protocol's
|
|
92
|
+
* interest fee.
|
|
93
|
+
*
|
|
94
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
95
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
96
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
97
|
+
**/
|
|
98
|
+
declare function calcEffectiveBorrowApy(opportunity: StrategyRateInputs, leverage: Leverage, mode?: QuotaMode): Bps;
|
|
99
|
+
/**
|
|
100
|
+
* Net yield of a strategy on the user's equity, in basis points, at a given
|
|
101
|
+
* leverage and quota mode:
|
|
102
|
+
* `leverage × totalCollateralApy − effectiveBorrowApy`. Collateral yield is
|
|
103
|
+
* on the whole position; borrow and quota interest are those of
|
|
104
|
+
* {@link calcEffectiveBorrowApy}.
|
|
105
|
+
*
|
|
106
|
+
* @param opportunity - Borrow APY, quota rate, and liquidation threshold.
|
|
107
|
+
* @param totalCollateralApy - Collateral yield the caller chose, typically
|
|
108
|
+
* `totalApy` of {@link StrategyOpportunity.collateralApy} or
|
|
109
|
+
* {@link StrategyOpportunity.collateralApyAvg7D}.
|
|
110
|
+
* @param leverage - Total-value leverage, same scale as {@link Leverage}.
|
|
111
|
+
* @param mode - How much quota the position quotes, see {@link QuotaMode}.
|
|
112
|
+
**/
|
|
113
|
+
declare function calcNetStrategyApy(opportunity: StrategyRateInputs, totalCollateralApy: Bps, leverage: Leverage, mode?: QuotaMode): Bps;
|
|
53
114
|
/**
|
|
54
115
|
* 5% safety margin subtracted from 100% in {@link calcMaxLeverage}, so a
|
|
55
116
|
* maxed position opens with HF slightly above 1.
|
|
@@ -67,6 +128,8 @@ declare const MAX_LEVERAGE_BUFFER_BPS = 500;
|
|
|
67
128
|
* // liquidationThreshold: 9000 bps = 90%
|
|
68
129
|
* calcMaxLeverage(9000) // (1 − 0.05) / (1 − 0.9) = 9.5x total exposure
|
|
69
130
|
* ```
|
|
131
|
+
* @throws If `liquidationThreshold` is 100% or more, which would make
|
|
132
|
+
* leverage unbounded.
|
|
70
133
|
**/
|
|
71
134
|
declare function calcMaxLeverage(liquidationThreshold: Bps): Leverage;
|
|
72
135
|
/**
|
|
@@ -98,18 +161,6 @@ declare function healthFactorBps(healthFactor: bigint): Bps;
|
|
|
98
161
|
* ```
|
|
99
162
|
**/
|
|
100
163
|
declare function calcPositionLeverage(totalValue: bigint, totalDebt: bigint): Leverage;
|
|
101
|
-
/**
|
|
102
|
-
* Annual quota cost on equity, in basis points:
|
|
103
|
-
* `quotaRate × (1 + feeInterest) × leverage`. Quota accrues on the whole
|
|
104
|
-
* quoted position, and the DAO takes `feeInterest` of it as with base interest.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```ts
|
|
108
|
-
* // quotaRate: 200 bps = 2%, feeInterest: 2500 bps = 25%, leverage: 9.5x
|
|
109
|
-
* calcAdditionalBorrowApy(200, 2500, 9.5) // 2% × 1.25 × 9.5 = 2375 bps = 23.75%
|
|
110
|
-
* ```
|
|
111
|
-
**/
|
|
112
|
-
declare function calcAdditionalBorrowApy(quotaRate: Bps, feeInterest: Bps, leverage: Leverage): Bps;
|
|
113
164
|
/**
|
|
114
165
|
* {@link PERCENTAGE_FACTOR} less a 0.1% safety buffer.
|
|
115
166
|
*
|
|
@@ -170,4 +221,4 @@ declare function optimalRepaidAmount({ totalDebt, twvUnderlying, minDebt, optima
|
|
|
170
221
|
**/
|
|
171
222
|
declare function optimalHFForPartialLiquidation(borrowRate: bigint): bigint;
|
|
172
223
|
//#endregion
|
|
173
|
-
export { MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS,
|
|
224
|
+
export { DEFAULT_QUOTA_BUFFER_BPS, MAX_LEVERAGE_BUFFER_BPS, OptimalRepaidAmountProps, PARTIAL_LIQUIDATION_BUFFER_BPS, QuotaMode, StrategyRateInputs, calcBorrowApy, calcEffectiveBorrowApy, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcUtilization, healthFactorBps, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount, rayToBps, usdToNumber };
|