@gearbox-protocol/sdk 15.1.0-next.2 → 15.1.0-next.4
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.
|
@@ -12,6 +12,7 @@ const require_sdk_market_credit_createCreditConfigurator = require("./createCred
|
|
|
12
12
|
const require_sdk_market_credit_createCreditFacade = require("./createCreditFacade.js");
|
|
13
13
|
const require_sdk_market_credit_createCreditManager = require("./createCreditManager.js");
|
|
14
14
|
const require_sdk_market_credit_dominantCollateral = require("./dominantCollateral.js");
|
|
15
|
+
let viem = require("viem");
|
|
15
16
|
//#region src/sdk/market/credit/CreditSuite.ts
|
|
16
17
|
/**
|
|
17
18
|
* SDK aggregate for one credit-manager branch inside a market.
|
|
@@ -172,12 +173,39 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
172
173
|
}
|
|
173
174
|
/**
|
|
174
175
|
* Collateral tokens a leveraged position can be built around in this suite:
|
|
175
|
-
* the ones the credit manager can lever up, narrowed to
|
|
176
|
-
* still
|
|
176
|
+
* the ones the credit manager can lever up, narrowed to the tokens that can
|
|
177
|
+
* still be entered. A token qualifies when it
|
|
178
|
+
*
|
|
179
|
+
* - has a liquidation threshold above `0` and below `100%`, and is not the
|
|
180
|
+
* suite's underlying, see
|
|
181
|
+
* {@link ICreditManagerContract.leverageableCollaterals};
|
|
182
|
+
* - is not the token the market's underlying wraps, which for an RWA market
|
|
183
|
+
* is the same exposure as the underlying itself;
|
|
184
|
+
* - is not a phantom token, which only ever appears as the intermediate step
|
|
185
|
+
* of a withdrawal and cannot be acquired;
|
|
186
|
+
* - is not an expired token, e.g. a matured Pendle PT;
|
|
187
|
+
* - has a non-zero main price in the market's oracle — a zero or failed
|
|
188
|
+
* answer (e.g. a zero price feed) means the position cannot be valued;
|
|
189
|
+
* - the market still accepts quota for, see
|
|
190
|
+
* {@link PoolQuotaKeeperContract.hasActiveQuota}.
|
|
191
|
+
*
|
|
192
|
+
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
193
|
+
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
194
|
+
* whatever its collaterals are.
|
|
177
195
|
*/
|
|
178
196
|
get strategyCollaterals() {
|
|
179
|
-
|
|
180
|
-
|
|
197
|
+
if (this.maxBorrowAmount === 0n) return [];
|
|
198
|
+
const { pqk, unwrappedUnderlying } = this.market.pool;
|
|
199
|
+
const { mainPrices } = this.market.priceOracle;
|
|
200
|
+
const { tokensMeta } = this;
|
|
201
|
+
return this.creditManager.leverageableCollaterals.filter((token) => {
|
|
202
|
+
if ((0, viem.isAddressEqual)(token, unwrappedUnderlying)) return false;
|
|
203
|
+
const meta = tokensMeta.mustGet(token);
|
|
204
|
+
if (tokensMeta.isPhantomToken(meta) || meta.isExpired) return false;
|
|
205
|
+
const mainPrice = mainPrices.get(token);
|
|
206
|
+
if (!mainPrice?.success || mainPrice.price === 0n) return false;
|
|
207
|
+
return pqk.hasActiveQuota(token);
|
|
208
|
+
});
|
|
181
209
|
}
|
|
182
210
|
/**
|
|
183
211
|
* Largest debt a single new position can take on right now: the tightest of
|
|
@@ -224,7 +252,7 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
|
|
|
224
252
|
collateralTokens: market.collateralTokens,
|
|
225
253
|
paused: this.isPaused,
|
|
226
254
|
rwa: market.rwa,
|
|
227
|
-
sunset: require_sdk_chain_chains.isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
|
|
255
|
+
sunset: market.sunset || require_sdk_chain_chains.isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
|
|
228
256
|
liquidationThreshold,
|
|
229
257
|
liquidationPremium: cm.liquidationPremium,
|
|
230
258
|
liquidationFee: cm.feeLiquidation,
|
|
@@ -11,6 +11,7 @@ import createCreditConfigurator from "./createCreditConfigurator.js";
|
|
|
11
11
|
import createCreditFacade from "./createCreditFacade.js";
|
|
12
12
|
import createCreditManager from "./createCreditManager.js";
|
|
13
13
|
import { mustGetDominantCollateral } from "./dominantCollateral.js";
|
|
14
|
+
import { isAddressEqual } from "viem";
|
|
14
15
|
//#region src/sdk/market/credit/CreditSuite.ts
|
|
15
16
|
/**
|
|
16
17
|
* SDK aggregate for one credit-manager branch inside a market.
|
|
@@ -171,12 +172,39 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
171
172
|
}
|
|
172
173
|
/**
|
|
173
174
|
* Collateral tokens a leveraged position can be built around in this suite:
|
|
174
|
-
* the ones the credit manager can lever up, narrowed to
|
|
175
|
-
* still
|
|
175
|
+
* the ones the credit manager can lever up, narrowed to the tokens that can
|
|
176
|
+
* still be entered. A token qualifies when it
|
|
177
|
+
*
|
|
178
|
+
* - has a liquidation threshold above `0` and below `100%`, and is not the
|
|
179
|
+
* suite's underlying, see
|
|
180
|
+
* {@link ICreditManagerContract.leverageableCollaterals};
|
|
181
|
+
* - is not the token the market's underlying wraps, which for an RWA market
|
|
182
|
+
* is the same exposure as the underlying itself;
|
|
183
|
+
* - is not a phantom token, which only ever appears as the intermediate step
|
|
184
|
+
* of a withdrawal and cannot be acquired;
|
|
185
|
+
* - is not an expired token, e.g. a matured Pendle PT;
|
|
186
|
+
* - has a non-zero main price in the market's oracle — a zero or failed
|
|
187
|
+
* answer (e.g. a zero price feed) means the position cannot be valued;
|
|
188
|
+
* - the market still accepts quota for, see
|
|
189
|
+
* {@link PoolQuotaKeeperContract.hasActiveQuota}.
|
|
190
|
+
*
|
|
191
|
+
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
192
|
+
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
193
|
+
* whatever its collaterals are.
|
|
176
194
|
*/
|
|
177
195
|
get strategyCollaterals() {
|
|
178
|
-
|
|
179
|
-
|
|
196
|
+
if (this.maxBorrowAmount === 0n) return [];
|
|
197
|
+
const { pqk, unwrappedUnderlying } = this.market.pool;
|
|
198
|
+
const { mainPrices } = this.market.priceOracle;
|
|
199
|
+
const { tokensMeta } = this;
|
|
200
|
+
return this.creditManager.leverageableCollaterals.filter((token) => {
|
|
201
|
+
if (isAddressEqual(token, unwrappedUnderlying)) return false;
|
|
202
|
+
const meta = tokensMeta.mustGet(token);
|
|
203
|
+
if (tokensMeta.isPhantomToken(meta) || meta.isExpired) return false;
|
|
204
|
+
const mainPrice = mainPrices.get(token);
|
|
205
|
+
if (!mainPrice?.success || mainPrice.price === 0n) return false;
|
|
206
|
+
return pqk.hasActiveQuota(token);
|
|
207
|
+
});
|
|
180
208
|
}
|
|
181
209
|
/**
|
|
182
210
|
* Largest debt a single new position can take on right now: the tightest of
|
|
@@ -223,7 +251,7 @@ var CreditSuite = class extends SDKConstruct {
|
|
|
223
251
|
collateralTokens: market.collateralTokens,
|
|
224
252
|
paused: this.isPaused,
|
|
225
253
|
rwa: market.rwa,
|
|
226
|
-
sunset: isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
|
|
254
|
+
sunset: market.sunset || isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
|
|
227
255
|
liquidationThreshold,
|
|
228
256
|
liquidationPremium: cm.liquidationPremium,
|
|
229
257
|
liquidationFee: cm.feeLiquidation,
|
|
@@ -136,8 +136,25 @@ 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
|
-
* the ones the credit manager can lever up, narrowed to
|
|
140
|
-
* still
|
|
139
|
+
* the ones the credit manager can lever up, narrowed to the tokens that can
|
|
140
|
+
* still be entered. A token qualifies when it
|
|
141
|
+
*
|
|
142
|
+
* - has a liquidation threshold above `0` and below `100%`, and is not the
|
|
143
|
+
* suite's underlying, see
|
|
144
|
+
* {@link ICreditManagerContract.leverageableCollaterals};
|
|
145
|
+
* - is not the token the market's underlying wraps, which for an RWA market
|
|
146
|
+
* is the same exposure as the underlying itself;
|
|
147
|
+
* - is not a phantom token, which only ever appears as the intermediate step
|
|
148
|
+
* of a withdrawal and cannot be acquired;
|
|
149
|
+
* - is not an expired token, e.g. a matured Pendle PT;
|
|
150
|
+
* - has a non-zero main price in the market's oracle — a zero or failed
|
|
151
|
+
* answer (e.g. a zero price feed) means the position cannot be valued;
|
|
152
|
+
* - the market still accepts quota for, see
|
|
153
|
+
* {@link PoolQuotaKeeperContract.hasActiveQuota}.
|
|
154
|
+
*
|
|
155
|
+
* A suite where no debt can be drawn at all ({@link maxBorrowAmount} is `0`,
|
|
156
|
+
* e.g. its debt limit is exhausted or zeroed out) offers no strategies,
|
|
157
|
+
* whatever its collaterals are.
|
|
141
158
|
*/
|
|
142
159
|
get strategyCollaterals(): Address[];
|
|
143
160
|
/**
|