@gearbox-protocol/sdk 17.5.0 → 17.6.1
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/charts.js +3 -0
- package/dist/cjs/onchain/accounts/intents/borrow.js +1 -1
- package/dist/cjs/onchain/accounts/intents/math.js +3 -2
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +1 -1
- package/dist/cjs/onchain/accounts/intents/plan.js +6 -5
- package/dist/cjs/onchain/accounts/intents/view.js +4 -3
- package/dist/esm/model/charts.js +3 -0
- package/dist/esm/onchain/accounts/intents/borrow.js +1 -1
- package/dist/esm/onchain/accounts/intents/math.js +3 -2
- package/dist/esm/onchain/accounts/intents/open-strategy.js +1 -1
- package/dist/esm/onchain/accounts/intents/plan.js +6 -5
- package/dist/esm/onchain/accounts/intents/view.js +4 -3
- package/dist/types/model/charts.d.ts +3 -1
- package/dist/types/model/charts.schema.d.ts +4 -0
- package/dist/types/onchain/accounts/intents/math.d.ts +3 -1
- package/dist/types/onchain/accounts/intents/plan.d.ts +3 -0
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/model/charts.js
CHANGED
|
@@ -41,6 +41,7 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
|
|
|
41
41
|
/**
|
|
42
42
|
* Every metric a strategy opportunity can chart.
|
|
43
43
|
*
|
|
44
|
+
* `quotaRateAvg7d` is the trailing seven-day average quota rate.
|
|
44
45
|
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
45
46
|
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
46
47
|
**/
|
|
@@ -49,6 +50,7 @@ const STRATEGY_OPPORTUNITY_CHART_METRICS = [
|
|
|
49
50
|
"borrowApyAvg7d",
|
|
50
51
|
"rewardsApyAvg7d",
|
|
51
52
|
"quotaRate",
|
|
53
|
+
"quotaRateAvg7d",
|
|
52
54
|
"liquidationThreshold",
|
|
53
55
|
"collateralApy",
|
|
54
56
|
"tvl",
|
|
@@ -114,6 +116,7 @@ const CHART_METRIC_UNITS = {
|
|
|
114
116
|
borrowApy: "bps",
|
|
115
117
|
borrowApyAvg7d: "bps",
|
|
116
118
|
quotaRate: "bps",
|
|
119
|
+
quotaRateAvg7d: "bps",
|
|
117
120
|
liquidationThreshold: "bps",
|
|
118
121
|
collateralApy: "bps",
|
|
119
122
|
supplied: "token",
|
|
@@ -55,7 +55,7 @@ async function buildBorrowState(props) {
|
|
|
55
55
|
totalDebt: market.toUnderlyingAmount(debt),
|
|
56
56
|
netValue: market.toUnderlyingAmount(margin - debt)
|
|
57
57
|
});
|
|
58
|
-
require_onchain_accounts_intents_math.assertDebtLimits(sdk, debt, suite.creditFacade, underlying);
|
|
58
|
+
require_onchain_accounts_intents_math.assertDebtLimits(sdk, debt, suite.creditFacade, underlying, suite.maxBorrowAmount());
|
|
59
59
|
require_onchain_accounts_intents_guards.assertCanBorrow(sdk, suite, debt);
|
|
60
60
|
const account = existing ?? require_onchain_accounts_intents_utils_credit_account_slice.unopenedAccountSlice({
|
|
61
61
|
creditManager,
|
|
@@ -56,13 +56,14 @@ function assertLeverageAtLeastOne(leverage) {
|
|
|
56
56
|
* Rejects a debt the facade would revert on: zero is always fine (no loan at
|
|
57
57
|
* all), anything else has to sit inside `[minDebt, maxDebt]`.
|
|
58
58
|
*/
|
|
59
|
-
function assertDebtLimits(sdk, debt, debtLimits, underlying) {
|
|
59
|
+
function assertDebtLimits(sdk, debt, debtLimits, underlying, maxBorrowAmount) {
|
|
60
60
|
require_onchain_validation_raise.raise(require_onchain_validation_checks_checkDebtLimits.checkDebtLimits({
|
|
61
61
|
debt,
|
|
62
62
|
minDebt: debtLimits.minDebt,
|
|
63
63
|
maxDebt: debtLimits.maxDebt,
|
|
64
64
|
underlying: require_onchain_validation_helpers_token.toToken(sdk, underlying),
|
|
65
|
-
allowZero: true
|
|
65
|
+
allowZero: true,
|
|
66
|
+
maxBorrowAmount
|
|
66
67
|
}), debt > debtLimits.maxDebt ? `debt ${debt} exceeds maxDebt ${debtLimits.maxDebt}` : `debt ${debt} is below minDebt ${debtLimits.minDebt}`);
|
|
67
68
|
}
|
|
68
69
|
//#endregion
|
|
@@ -45,7 +45,7 @@ async function buildOpenStrategyState(props) {
|
|
|
45
45
|
creditFacade: suite.creditFacade.address,
|
|
46
46
|
underlying
|
|
47
47
|
});
|
|
48
|
-
require_onchain_accounts_intents_math.assertDebtLimits(sdk, debt, suite.creditFacade, underlying);
|
|
48
|
+
require_onchain_accounts_intents_math.assertDebtLimits(sdk, debt, suite.creditFacade, underlying, suite.maxBorrowAmount());
|
|
49
49
|
require_onchain_accounts_intents_guards.assertCanBorrow(sdk, suite, debt);
|
|
50
50
|
const paths = require_onchain_accounts_intents_utils_router_path.createRouterPaths({
|
|
51
51
|
sdk,
|
|
@@ -43,7 +43,7 @@ function planDeposit(intent, view) {
|
|
|
43
43
|
const aU = view.price(intent.token, U, intent.amount);
|
|
44
44
|
const debtDelta = intent.targetLeverage === void 0 ? require_onchain_accounts_intents_math.proportionalDebt(view, aU) : require_onchain_accounts_intents_math.debtForLeverage(view.collateral + aU, intent.targetLeverage) - view.debt;
|
|
45
45
|
if (debtDelta < 0n) throw new require_onchain_validation_raise.IntentPreviewError(require_model_errors_operation_errors.leverageOutOfRange(), `deposit: target leverage ${intent.targetLeverage} would require repaying debt`);
|
|
46
|
-
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U);
|
|
46
|
+
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U, view.maxBorrowAmount);
|
|
47
47
|
const T = intent.positionToken ?? positionToken(view, "deposit");
|
|
48
48
|
const depositStays = require_onchain_accounts_intents_utils_common.eq(intent.token, T);
|
|
49
49
|
return [
|
|
@@ -74,11 +74,12 @@ function planRepay(intent, view) {
|
|
|
74
74
|
if (view.debt <= 0n) throw new require_onchain_validation_raise.IntentPreviewError(require_model_errors_operation_errors.debtOutOfRange({
|
|
75
75
|
requested: require_onchain_validation_helpers_token.toTokenAmount(view.sdk, U, view.debt),
|
|
76
76
|
minDebt: require_onchain_validation_helpers_token.toTokenAmount(view.sdk, U, view.debtLimits.minDebt),
|
|
77
|
-
maxDebt: require_onchain_validation_helpers_token.toTokenAmount(view.sdk, U, view.debtLimits.maxDebt)
|
|
77
|
+
maxDebt: require_onchain_validation_helpers_token.toTokenAmount(view.sdk, U, view.debtLimits.maxDebt),
|
|
78
|
+
maxBorrowAmount: view.maxBorrowAmount
|
|
78
79
|
}), "repay: the account owes nothing");
|
|
79
80
|
const funding = everything(intent.amount) ? view.price(U, intent.token, withMargin(view.debt)) : intent.amount;
|
|
80
81
|
const repaid = min(view.price(intent.token, U, funding), view.debt);
|
|
81
|
-
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying);
|
|
82
|
+
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
82
83
|
return [
|
|
83
84
|
add(intent.token, funding, intent.value),
|
|
84
85
|
...fundsInU ? [] : [convert(intent.token, U, funding)],
|
|
@@ -307,7 +308,7 @@ function withdrawShape(intent, view) {
|
|
|
307
308
|
};
|
|
308
309
|
}
|
|
309
310
|
const dD = require_onchain_accounts_intents_math.proportionalDebt(view, WU);
|
|
310
|
-
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying);
|
|
311
|
+
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
311
312
|
return {
|
|
312
313
|
U,
|
|
313
314
|
T,
|
|
@@ -326,7 +327,7 @@ function leverageShape(intent, view) {
|
|
|
326
327
|
require_onchain_accounts_intents_math.assertLeverageAtLeastOne(intent.targetLeverage);
|
|
327
328
|
if (view.collateral <= 0n) throw new require_onchain_validation_raise.IntentPreviewError(require_model_errors_operation_errors.insufficientBalance(), "adjustLeverage: account has no collateral to lever");
|
|
328
329
|
const target = require_onchain_accounts_intents_math.debtForLeverage(view.collateral, intent.targetLeverage);
|
|
329
|
-
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying);
|
|
330
|
+
require_onchain_accounts_intents_math.assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
330
331
|
return {
|
|
331
332
|
U: view.underlying,
|
|
332
333
|
delta: target - view.debt
|
|
@@ -13,7 +13,7 @@ function accountView(creditAccount, sdk) {
|
|
|
13
13
|
const { underlying, creditManager } = creditAccount;
|
|
14
14
|
const oracle = sdk.marketRegister.findByCreditManager(creditManager).priceOracle;
|
|
15
15
|
const price = (from, to, amount) => oracle.safeConvert(from, to, amount).value;
|
|
16
|
-
const
|
|
16
|
+
const creditSuite = sdk.marketRegister.findCreditManager(creditManager);
|
|
17
17
|
let totalValue = 0n;
|
|
18
18
|
for (const t of creditAccount.tokens) totalValue += price(t.token, underlying, t.balance);
|
|
19
19
|
return {
|
|
@@ -23,9 +23,10 @@ function accountView(creditAccount, sdk) {
|
|
|
23
23
|
debt: creditAccount.totalDebt,
|
|
24
24
|
collateral: totalValue - creditAccount.totalDebt,
|
|
25
25
|
debtLimits: {
|
|
26
|
-
minDebt: creditFacade.minDebt,
|
|
27
|
-
maxDebt: creditFacade.maxDebt
|
|
26
|
+
minDebt: creditSuite.creditFacade.minDebt,
|
|
27
|
+
maxDebt: creditSuite.creditFacade.maxDebt
|
|
28
28
|
},
|
|
29
|
+
maxBorrowAmount: creditSuite.maxBorrowAmount(),
|
|
29
30
|
balanceOf: (token) => creditAccount.tokens.find((t) => require_onchain_accounts_intents_utils_common.eq(t.token, token))?.balance ?? 0n,
|
|
30
31
|
price,
|
|
31
32
|
fattest: (exclude) => require_onchain_accounts_intents_utils_pick_token.pickFattestNonPhantomToken({
|
package/dist/esm/model/charts.js
CHANGED
|
@@ -40,6 +40,7 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
|
|
|
40
40
|
/**
|
|
41
41
|
* Every metric a strategy opportunity can chart.
|
|
42
42
|
*
|
|
43
|
+
* `quotaRateAvg7d` is the trailing seven-day average quota rate.
|
|
43
44
|
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
44
45
|
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
45
46
|
**/
|
|
@@ -48,6 +49,7 @@ const STRATEGY_OPPORTUNITY_CHART_METRICS = [
|
|
|
48
49
|
"borrowApyAvg7d",
|
|
49
50
|
"rewardsApyAvg7d",
|
|
50
51
|
"quotaRate",
|
|
52
|
+
"quotaRateAvg7d",
|
|
51
53
|
"liquidationThreshold",
|
|
52
54
|
"collateralApy",
|
|
53
55
|
"tvl",
|
|
@@ -113,6 +115,7 @@ const CHART_METRIC_UNITS = {
|
|
|
113
115
|
borrowApy: "bps",
|
|
114
116
|
borrowApyAvg7d: "bps",
|
|
115
117
|
quotaRate: "bps",
|
|
118
|
+
quotaRateAvg7d: "bps",
|
|
116
119
|
liquidationThreshold: "bps",
|
|
117
120
|
collateralApy: "bps",
|
|
118
121
|
supplied: "token",
|
|
@@ -54,7 +54,7 @@ async function buildBorrowState(props) {
|
|
|
54
54
|
totalDebt: market.toUnderlyingAmount(debt),
|
|
55
55
|
netValue: market.toUnderlyingAmount(margin - debt)
|
|
56
56
|
});
|
|
57
|
-
assertDebtLimits(sdk, debt, suite.creditFacade, underlying);
|
|
57
|
+
assertDebtLimits(sdk, debt, suite.creditFacade, underlying, suite.maxBorrowAmount());
|
|
58
58
|
assertCanBorrow(sdk, suite, debt);
|
|
59
59
|
const account = existing ?? unopenedAccountSlice({
|
|
60
60
|
creditManager,
|
|
@@ -55,13 +55,14 @@ function assertLeverageAtLeastOne(leverage) {
|
|
|
55
55
|
* Rejects a debt the facade would revert on: zero is always fine (no loan at
|
|
56
56
|
* all), anything else has to sit inside `[minDebt, maxDebt]`.
|
|
57
57
|
*/
|
|
58
|
-
function assertDebtLimits(sdk, debt, debtLimits, underlying) {
|
|
58
|
+
function assertDebtLimits(sdk, debt, debtLimits, underlying, maxBorrowAmount) {
|
|
59
59
|
raise(checkDebtLimits({
|
|
60
60
|
debt,
|
|
61
61
|
minDebt: debtLimits.minDebt,
|
|
62
62
|
maxDebt: debtLimits.maxDebt,
|
|
63
63
|
underlying: toToken(sdk, underlying),
|
|
64
|
-
allowZero: true
|
|
64
|
+
allowZero: true,
|
|
65
|
+
maxBorrowAmount
|
|
65
66
|
}), debt > debtLimits.maxDebt ? `debt ${debt} exceeds maxDebt ${debtLimits.maxDebt}` : `debt ${debt} is below minDebt ${debtLimits.minDebt}`);
|
|
66
67
|
}
|
|
67
68
|
//#endregion
|
|
@@ -44,7 +44,7 @@ async function buildOpenStrategyState(props) {
|
|
|
44
44
|
creditFacade: suite.creditFacade.address,
|
|
45
45
|
underlying
|
|
46
46
|
});
|
|
47
|
-
assertDebtLimits(sdk, debt, suite.creditFacade, underlying);
|
|
47
|
+
assertDebtLimits(sdk, debt, suite.creditFacade, underlying, suite.maxBorrowAmount());
|
|
48
48
|
assertCanBorrow(sdk, suite, debt);
|
|
49
49
|
const paths = createRouterPaths({
|
|
50
50
|
sdk,
|
|
@@ -42,7 +42,7 @@ function planDeposit(intent, view) {
|
|
|
42
42
|
const aU = view.price(intent.token, U, intent.amount);
|
|
43
43
|
const debtDelta = intent.targetLeverage === void 0 ? proportionalDebt(view, aU) : debtForLeverage(view.collateral + aU, intent.targetLeverage) - view.debt;
|
|
44
44
|
if (debtDelta < 0n) throw new IntentPreviewError(leverageOutOfRange(), `deposit: target leverage ${intent.targetLeverage} would require repaying debt`);
|
|
45
|
-
assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U);
|
|
45
|
+
assertDebtLimits(view.sdk, view.debt + debtDelta, view.debtLimits, U, view.maxBorrowAmount);
|
|
46
46
|
const T = intent.positionToken ?? positionToken(view, "deposit");
|
|
47
47
|
const depositStays = eq(intent.token, T);
|
|
48
48
|
return [
|
|
@@ -73,11 +73,12 @@ function planRepay(intent, view) {
|
|
|
73
73
|
if (view.debt <= 0n) throw new IntentPreviewError(debtOutOfRange({
|
|
74
74
|
requested: toTokenAmount(view.sdk, U, view.debt),
|
|
75
75
|
minDebt: toTokenAmount(view.sdk, U, view.debtLimits.minDebt),
|
|
76
|
-
maxDebt: toTokenAmount(view.sdk, U, view.debtLimits.maxDebt)
|
|
76
|
+
maxDebt: toTokenAmount(view.sdk, U, view.debtLimits.maxDebt),
|
|
77
|
+
maxBorrowAmount: view.maxBorrowAmount
|
|
77
78
|
}), "repay: the account owes nothing");
|
|
78
79
|
const funding = everything(intent.amount) ? view.price(U, intent.token, withMargin(view.debt)) : intent.amount;
|
|
79
80
|
const repaid = min(view.price(intent.token, U, funding), view.debt);
|
|
80
|
-
assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying);
|
|
81
|
+
assertDebtLimits(view.sdk, view.debt - repaid, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
81
82
|
return [
|
|
82
83
|
add(intent.token, funding, intent.value),
|
|
83
84
|
...fundsInU ? [] : [convert(intent.token, U, funding)],
|
|
@@ -306,7 +307,7 @@ function withdrawShape(intent, view) {
|
|
|
306
307
|
};
|
|
307
308
|
}
|
|
308
309
|
const dD = proportionalDebt(view, WU);
|
|
309
|
-
assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying);
|
|
310
|
+
assertDebtLimits(view.sdk, view.debt - dD, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
310
311
|
return {
|
|
311
312
|
U,
|
|
312
313
|
T,
|
|
@@ -325,7 +326,7 @@ function leverageShape(intent, view) {
|
|
|
325
326
|
assertLeverageAtLeastOne(intent.targetLeverage);
|
|
326
327
|
if (view.collateral <= 0n) throw new IntentPreviewError(insufficientBalance(), "adjustLeverage: account has no collateral to lever");
|
|
327
328
|
const target = debtForLeverage(view.collateral, intent.targetLeverage);
|
|
328
|
-
assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying);
|
|
329
|
+
assertDebtLimits(view.sdk, target, view.debtLimits, view.underlying, view.maxBorrowAmount);
|
|
329
330
|
return {
|
|
330
331
|
U: view.underlying,
|
|
331
332
|
delta: target - view.debt
|
|
@@ -12,7 +12,7 @@ function accountView(creditAccount, sdk) {
|
|
|
12
12
|
const { underlying, creditManager } = creditAccount;
|
|
13
13
|
const oracle = sdk.marketRegister.findByCreditManager(creditManager).priceOracle;
|
|
14
14
|
const price = (from, to, amount) => oracle.safeConvert(from, to, amount).value;
|
|
15
|
-
const
|
|
15
|
+
const creditSuite = sdk.marketRegister.findCreditManager(creditManager);
|
|
16
16
|
let totalValue = 0n;
|
|
17
17
|
for (const t of creditAccount.tokens) totalValue += price(t.token, underlying, t.balance);
|
|
18
18
|
return {
|
|
@@ -22,9 +22,10 @@ function accountView(creditAccount, sdk) {
|
|
|
22
22
|
debt: creditAccount.totalDebt,
|
|
23
23
|
collateral: totalValue - creditAccount.totalDebt,
|
|
24
24
|
debtLimits: {
|
|
25
|
-
minDebt: creditFacade.minDebt,
|
|
26
|
-
maxDebt: creditFacade.maxDebt
|
|
25
|
+
minDebt: creditSuite.creditFacade.minDebt,
|
|
26
|
+
maxDebt: creditSuite.creditFacade.maxDebt
|
|
27
27
|
},
|
|
28
|
+
maxBorrowAmount: creditSuite.maxBorrowAmount(),
|
|
28
29
|
balanceOf: (token) => creditAccount.tokens.find((t) => eq(t.token, token))?.balance ?? 0n,
|
|
29
30
|
price,
|
|
30
31
|
fattest: (exclude) => pickFattestNonPhantomToken({
|
|
@@ -33,10 +33,11 @@ type PoolOpportunityChartMetric = (typeof POOL_OPPORTUNITY_CHART_METRICS)[number
|
|
|
33
33
|
/**
|
|
34
34
|
* Every metric a strategy opportunity can chart.
|
|
35
35
|
*
|
|
36
|
+
* `quotaRateAvg7d` is the trailing seven-day average quota rate.
|
|
36
37
|
* `collateralPrice` is the collateral/underlying series a liquidation-price
|
|
37
38
|
* chart draws; the two USD series are the same prices quoted in dollars.
|
|
38
39
|
**/
|
|
39
|
-
declare const STRATEGY_OPPORTUNITY_CHART_METRICS: readonly ["borrowApy", "borrowApyAvg7d", "rewardsApyAvg7d", "quotaRate", "liquidationThreshold", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
40
|
+
declare const STRATEGY_OPPORTUNITY_CHART_METRICS: readonly ["borrowApy", "borrowApyAvg7d", "rewardsApyAvg7d", "quotaRate", "quotaRateAvg7d", "liquidationThreshold", "collateralApy", "tvl", "collateralPrice", "collateralUsdPrice", "underlyingUsdPrice"];
|
|
40
41
|
/**
|
|
41
42
|
* Metric a strategy opportunity can chart, derived from
|
|
42
43
|
* {@link STRATEGY_OPPORTUNITY_CHART_METRICS}.
|
|
@@ -183,6 +184,7 @@ declare const CHART_METRIC_UNITS: {
|
|
|
183
184
|
readonly borrowApy: "bps";
|
|
184
185
|
readonly borrowApyAvg7d: "bps";
|
|
185
186
|
readonly quotaRate: "bps";
|
|
187
|
+
readonly quotaRateAvg7d: "bps";
|
|
186
188
|
readonly liquidationThreshold: "bps";
|
|
187
189
|
readonly collateralApy: "bps";
|
|
188
190
|
readonly supplied: "token";
|
|
@@ -43,6 +43,7 @@ declare const strategyOpportunityChartMetricSchema: z.ZodEnum<{
|
|
|
43
43
|
collateralUsdPrice: "collateralUsdPrice";
|
|
44
44
|
liquidationThreshold: "liquidationThreshold";
|
|
45
45
|
quotaRate: "quotaRate";
|
|
46
|
+
quotaRateAvg7d: "quotaRateAvg7d";
|
|
46
47
|
rewardsApyAvg7d: "rewardsApyAvg7d";
|
|
47
48
|
tvl: "tvl";
|
|
48
49
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
@@ -94,6 +95,7 @@ declare const chartMetricSchema: z.ZodUnion<readonly [z.ZodEnum<{
|
|
|
94
95
|
collateralUsdPrice: "collateralUsdPrice";
|
|
95
96
|
liquidationThreshold: "liquidationThreshold";
|
|
96
97
|
quotaRate: "quotaRate";
|
|
98
|
+
quotaRateAvg7d: "quotaRateAvg7d";
|
|
97
99
|
rewardsApyAvg7d: "rewardsApyAvg7d";
|
|
98
100
|
tvl: "tvl";
|
|
99
101
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
@@ -134,6 +136,7 @@ declare const chartQuerySchema: z.ZodObject<{
|
|
|
134
136
|
collateralUsdPrice: "collateralUsdPrice";
|
|
135
137
|
liquidationThreshold: "liquidationThreshold";
|
|
136
138
|
quotaRate: "quotaRate";
|
|
139
|
+
quotaRateAvg7d: "quotaRateAvg7d";
|
|
137
140
|
rewardsApyAvg7d: "rewardsApyAvg7d";
|
|
138
141
|
tvl: "tvl";
|
|
139
142
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
@@ -211,6 +214,7 @@ declare const chartQueryCodec: z.ZodCodec<z.ZodObject<{
|
|
|
211
214
|
collateralUsdPrice: "collateralUsdPrice";
|
|
212
215
|
liquidationThreshold: "liquidationThreshold";
|
|
213
216
|
quotaRate: "quotaRate";
|
|
217
|
+
quotaRateAvg7d: "quotaRateAvg7d";
|
|
214
218
|
rewardsApyAvg7d: "rewardsApyAvg7d";
|
|
215
219
|
tvl: "tvl";
|
|
216
220
|
underlyingUsdPrice: "underlyingUsdPrice";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { MaxBorrowAmount } from "../../market/credit/types.js";
|
|
2
|
+
import "../../market/index.js";
|
|
1
3
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
2
4
|
import { Address } from "viem";
|
|
3
5
|
//#region src/onchain/accounts/intents/math.d.ts
|
|
@@ -44,6 +46,6 @@ declare function assertLeverageAtLeastOne(leverage: bigint): void;
|
|
|
44
46
|
* Rejects a debt the facade would revert on: zero is always fine (no loan at
|
|
45
47
|
* all), anything else has to sit inside `[minDebt, maxDebt]`.
|
|
46
48
|
*/
|
|
47
|
-
declare function assertDebtLimits(sdk: OnchainSDK, debt: bigint, debtLimits: DebtLimits, underlying: Address): void;
|
|
49
|
+
declare function assertDebtLimits(sdk: OnchainSDK, debt: bigint, debtLimits: DebtLimits, underlying: Address, maxBorrowAmount: MaxBorrowAmount): void;
|
|
48
50
|
//#endregion
|
|
49
51
|
export { DebtLimits, Position, assertDebtLimits, assertLeverageAtLeastOne, debtForLeverage, maxProportionalWithdrawal, proportionalDebt };
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { DelayedIntent } from "../../../model/delayed-intents.js";
|
|
2
2
|
import "../../../model/index.js";
|
|
3
3
|
import { ClaimableWithdrawal } from "../withdrawal-compressor/types.js";
|
|
4
|
+
import { MaxBorrowAmount } from "../../market/credit/types.js";
|
|
5
|
+
import "../../market/index.js";
|
|
4
6
|
import { OnchainSDK } from "../../OnchainSDK.js";
|
|
5
7
|
import { AddCollateralIntent, AdjustLeverageIntent, DepositStrategyIntent, RepayStrategyIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./types.js";
|
|
6
8
|
import { DebtLimits } from "./math.js";
|
|
@@ -109,6 +111,7 @@ interface AccountView {
|
|
|
109
111
|
/** TVL − debt, in underlying. */
|
|
110
112
|
collateral: bigint;
|
|
111
113
|
debtLimits: DebtLimits;
|
|
114
|
+
maxBorrowAmount: MaxBorrowAmount;
|
|
112
115
|
balanceOf(token: Address): bigint;
|
|
113
116
|
/** Oracle conversion; unpriceable tokens contribute 0n. */
|
|
114
117
|
price(from: Address, to: Address, amount: bigint): bigint;
|
|
@@ -17,7 +17,7 @@ interface DebtLimitsArgs {
|
|
|
17
17
|
*/
|
|
18
18
|
allowZero: boolean;
|
|
19
19
|
/** From the caller's suite; a caller that raises to throw advises nobody. */
|
|
20
|
-
maxBorrowAmount
|
|
20
|
+
maxBorrowAmount: MaxBorrowAmount;
|
|
21
21
|
}
|
|
22
22
|
/** A debt the facade would revert on. */
|
|
23
23
|
declare function checkDebtLimits(args: DebtLimitsArgs): DebtOutOfRangeError[];
|