@gearbox-protocol/sdk 15.1.0-next.25 → 15.1.0-next.26
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 +1 -1
- package/dist/cjs/sdk/accounts/intents/guards.js +1 -7
- package/dist/cjs/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/sdk/market/credit/CreditSuite.js +13 -2
- package/dist/esm/model/opportunities.schema.js +1 -1
- package/dist/esm/sdk/accounts/intents/guards.js +1 -7
- package/dist/esm/sdk/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/sdk/market/credit/CreditSuite.js +13 -2
- package/dist/types/sdk/market/credit/CreditSuite.d.ts +7 -1
- package/package.json +1 -1
|
@@ -113,7 +113,7 @@ const strategyOpportunitySchema = zod_v4.z.object({
|
|
|
113
113
|
availableLiquidity: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
|
|
114
114
|
minDebt: require_model_primitives_schema.amountSchema,
|
|
115
115
|
totalDebtLimit: require_model_primitives_schema.amountSchema,
|
|
116
|
-
maxBorrowAmount: require_model_primitives_schema.amountSchema,
|
|
116
|
+
maxBorrowAmount: require_model_compare_schema.tolerance(require_model_primitives_schema.amountSchema, "amount"),
|
|
117
117
|
maxLeverage: require_model_primitives_schema.leverageSchema
|
|
118
118
|
});
|
|
119
119
|
/**
|
|
@@ -58,7 +58,7 @@ function assertCanBorrow(suite, amount) {
|
|
|
58
58
|
*/
|
|
59
59
|
function assertGrowthAllowed(args) {
|
|
60
60
|
const { sdk, suite, market, before, after } = args;
|
|
61
|
-
const forbidden = forbiddenTokens
|
|
61
|
+
const forbidden = suite.forbiddenTokens;
|
|
62
62
|
const underlying = market.pool.underlying;
|
|
63
63
|
for (const { token, balance } of after) {
|
|
64
64
|
if (balance <= (before.find((a) => require_sdk_accounts_intents_utils_common.eq(a.token, token))?.balance ?? 0n)) continue;
|
|
@@ -67,12 +67,6 @@ function assertGrowthAllowed(args) {
|
|
|
67
67
|
if (!market.pool.pqk.hasActiveQuota(token)) throw new require_sdk_accounts_intents_types.IntentPreviewError("quotaLimitReached", `${token} takes no quota in this market, so it counts as no collateral`);
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
|
-
/** Tokens the facade's mask flags, which is indexed by collateral position. */
|
|
71
|
-
function forbiddenTokens(suite) {
|
|
72
|
-
const mask = suite.creditFacade.forbiddenTokensMask;
|
|
73
|
-
if (mask === 0n) return [];
|
|
74
|
-
return suite.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
75
|
-
}
|
|
76
70
|
/**
|
|
77
71
|
* The facade weighs the account against its debt at the end of every multicall
|
|
78
72
|
* and reverts if the collateral does not cover it, so a plan that lands the
|
|
@@ -177,6 +177,7 @@ function buildMockSdk(args) {
|
|
|
177
177
|
},
|
|
178
178
|
market,
|
|
179
179
|
isPaused: facadePaused || poolPaused,
|
|
180
|
+
forbiddenTokens: [...forbidden],
|
|
180
181
|
strategyTargetCollateral: args.strategyTargetCollateral ?? collateralTokens.find((t) => t !== args.underlying.toLowerCase()),
|
|
181
182
|
isExpired: expirationDate > 0 && expirationDate < (args.timestamp ?? 0)
|
|
182
183
|
};
|
|
@@ -179,11 +179,22 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
179
179
|
}
|
|
180
180
|
/**
|
|
181
181
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
182
|
-
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
182
|
+
* see {@link isStrategyCollateral} for the per-token criteria. Tokens the
|
|
183
|
+
* facade has forbidden are excluded — they cannot be taken on — even when
|
|
184
|
+
* they still pass the shared eligibility rule used for target selection.
|
|
183
185
|
*/
|
|
184
186
|
get strategyCollaterals() {
|
|
185
187
|
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return [];
|
|
186
|
-
|
|
188
|
+
const forbidden = new Set(this.forbiddenTokens);
|
|
189
|
+
return this.creditManager.collateralTokens.filter((token) => !forbidden.has(token) && require_sdk_market_credit_collateralUtils.isStrategyCollateral(this.#strategyCollateralProps(token), true));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Tokens forbidden by the facade.
|
|
193
|
+
*/
|
|
194
|
+
get forbiddenTokens() {
|
|
195
|
+
const mask = this.creditFacade.forbiddenTokensMask;
|
|
196
|
+
if (mask === 0n) return [];
|
|
197
|
+
return this.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
187
198
|
}
|
|
188
199
|
/**
|
|
189
200
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -112,7 +112,7 @@ const strategyOpportunitySchema = z.object({
|
|
|
112
112
|
availableLiquidity: tolerance(amountSchema, "amount"),
|
|
113
113
|
minDebt: amountSchema,
|
|
114
114
|
totalDebtLimit: amountSchema,
|
|
115
|
-
maxBorrowAmount: amountSchema,
|
|
115
|
+
maxBorrowAmount: tolerance(amountSchema, "amount"),
|
|
116
116
|
maxLeverage: leverageSchema
|
|
117
117
|
});
|
|
118
118
|
/**
|
|
@@ -57,7 +57,7 @@ function assertCanBorrow(suite, amount) {
|
|
|
57
57
|
*/
|
|
58
58
|
function assertGrowthAllowed(args) {
|
|
59
59
|
const { sdk, suite, market, before, after } = args;
|
|
60
|
-
const forbidden = forbiddenTokens
|
|
60
|
+
const forbidden = suite.forbiddenTokens;
|
|
61
61
|
const underlying = market.pool.underlying;
|
|
62
62
|
for (const { token, balance } of after) {
|
|
63
63
|
if (balance <= (before.find((a) => eq(a.token, token))?.balance ?? 0n)) continue;
|
|
@@ -66,12 +66,6 @@ function assertGrowthAllowed(args) {
|
|
|
66
66
|
if (!market.pool.pqk.hasActiveQuota(token)) throw new IntentPreviewError("quotaLimitReached", `${token} takes no quota in this market, so it counts as no collateral`);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
/** Tokens the facade's mask flags, which is indexed by collateral position. */
|
|
70
|
-
function forbiddenTokens(suite) {
|
|
71
|
-
const mask = suite.creditFacade.forbiddenTokensMask;
|
|
72
|
-
if (mask === 0n) return [];
|
|
73
|
-
return suite.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
74
|
-
}
|
|
75
69
|
/**
|
|
76
70
|
* The facade weighs the account against its debt at the end of every multicall
|
|
77
71
|
* and reverts if the collateral does not cover it, so a plan that lands the
|
|
@@ -177,6 +177,7 @@ function buildMockSdk(args) {
|
|
|
177
177
|
},
|
|
178
178
|
market,
|
|
179
179
|
isPaused: facadePaused || poolPaused,
|
|
180
|
+
forbiddenTokens: [...forbidden],
|
|
180
181
|
strategyTargetCollateral: args.strategyTargetCollateral ?? collateralTokens.find((t) => t !== args.underlying.toLowerCase()),
|
|
181
182
|
isExpired: expirationDate > 0 && expirationDate < (args.timestamp ?? 0)
|
|
182
183
|
};
|
|
@@ -178,11 +178,22 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
178
178
|
}
|
|
179
179
|
/**
|
|
180
180
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
181
|
-
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
181
|
+
* see {@link isStrategyCollateral} for the per-token criteria. Tokens the
|
|
182
|
+
* facade has forbidden are excluded — they cannot be taken on — even when
|
|
183
|
+
* they still pass the shared eligibility rule used for target selection.
|
|
182
184
|
*/
|
|
183
185
|
get strategyCollaterals() {
|
|
184
186
|
if (this.maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return [];
|
|
185
|
-
|
|
187
|
+
const forbidden = new Set(this.forbiddenTokens);
|
|
188
|
+
return this.creditManager.collateralTokens.filter((token) => !forbidden.has(token) && isStrategyCollateral(this.#strategyCollateralProps(token), true));
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Tokens forbidden by the facade.
|
|
192
|
+
*/
|
|
193
|
+
get forbiddenTokens() {
|
|
194
|
+
const mask = this.creditFacade.forbiddenTokensMask;
|
|
195
|
+
if (mask === 0n) return [];
|
|
196
|
+
return this.creditManager.collateralTokens.filter((_, i) => (mask & 1n << BigInt(i)) !== 0n);
|
|
186
197
|
}
|
|
187
198
|
/**
|
|
188
199
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
@@ -136,9 +136,15 @@ declare class CreditSuite extends SDKConstruct {
|
|
|
136
136
|
get isPaused(): boolean;
|
|
137
137
|
/**
|
|
138
138
|
* Collateral tokens a leveraged position can be built around in this suite,
|
|
139
|
-
* see {@link isStrategyCollateral} for the per-token criteria.
|
|
139
|
+
* see {@link isStrategyCollateral} for the per-token criteria. Tokens the
|
|
140
|
+
* facade has forbidden are excluded — they cannot be taken on — even when
|
|
141
|
+
* they still pass the shared eligibility rule used for target selection.
|
|
140
142
|
*/
|
|
141
143
|
get strategyCollaterals(): Address[];
|
|
144
|
+
/**
|
|
145
|
+
* Tokens forbidden by the facade.
|
|
146
|
+
*/
|
|
147
|
+
get forbiddenTokens(): Address[];
|
|
142
148
|
/**
|
|
143
149
|
* The single target collateral of this suite's strategy, or `undefined` when
|
|
144
150
|
* none can be resolved.
|