@gearbox-protocol/sdk 15.1.0-next.2 → 15.1.0-next.3

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,29 @@ 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 those the market
176
- * still accepts quota for.
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
+ * - the market still accepts quota for, see
188
+ * {@link PoolQuotaKeeperContract.hasActiveQuota}.
177
189
  */
178
190
  get strategyCollaterals() {
179
- const { pqk } = this.market.pool;
180
- return this.creditManager.leverageableCollaterals.filter((token) => pqk.hasActiveQuota(token));
191
+ const { pqk, unwrappedUnderlying } = this.market.pool;
192
+ const { tokensMeta } = this;
193
+ return this.creditManager.leverageableCollaterals.filter((token) => {
194
+ if ((0, viem.isAddressEqual)(token, unwrappedUnderlying)) return false;
195
+ const meta = tokensMeta.mustGet(token);
196
+ if (tokensMeta.isPhantomToken(meta) || meta.isExpired) return false;
197
+ return pqk.hasActiveQuota(token);
198
+ });
181
199
  }
182
200
  /**
183
201
  * Largest debt a single new position can take on right now: the tightest of
@@ -224,7 +242,7 @@ var CreditSuite = class extends require_sdk_base_SDKConstruct.SDKConstruct {
224
242
  collateralTokens: market.collateralTokens,
225
243
  paused: this.isPaused,
226
244
  rwa: market.rwa,
227
- sunset: require_sdk_chain_chains.isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
245
+ sunset: market.sunset || require_sdk_chain_chains.isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
228
246
  liquidationThreshold,
229
247
  liquidationPremium: cm.liquidationPremium,
230
248
  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,29 @@ 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 those the market
175
- * still accepts quota for.
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
+ * - the market still accepts quota for, see
187
+ * {@link PoolQuotaKeeperContract.hasActiveQuota}.
176
188
  */
177
189
  get strategyCollaterals() {
178
- const { pqk } = this.market.pool;
179
- return this.creditManager.leverageableCollaterals.filter((token) => pqk.hasActiveQuota(token));
190
+ const { pqk, unwrappedUnderlying } = this.market.pool;
191
+ const { tokensMeta } = this;
192
+ return this.creditManager.leverageableCollaterals.filter((token) => {
193
+ if (isAddressEqual(token, unwrappedUnderlying)) return false;
194
+ const meta = tokensMeta.mustGet(token);
195
+ if (tokensMeta.isPhantomToken(meta) || meta.isExpired) return false;
196
+ return pqk.hasActiveQuota(token);
197
+ });
180
198
  }
181
199
  /**
182
200
  * Largest debt a single new position can take on right now: the tightest of
@@ -223,7 +241,7 @@ var CreditSuite = class extends SDKConstruct {
223
241
  collateralTokens: market.collateralTokens,
224
242
  paused: this.isPaused,
225
243
  rwa: market.rwa,
226
- sunset: isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
244
+ sunset: market.sunset || isSunsetStrategy(cm.address, collateral, this.sdk.networkType),
227
245
  liquidationThreshold,
228
246
  liquidationPremium: cm.liquidationPremium,
229
247
  liquidationFee: cm.feeLiquidation,
@@ -136,8 +136,19 @@ 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 those the market
140
- * still accepts quota for.
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
+ * - the market still accepts quota for, see
151
+ * {@link PoolQuotaKeeperContract.hasActiveQuota}.
141
152
  */
142
153
  get strategyCollaterals(): Address[];
143
154
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "15.1.0-next.2",
3
+ "version": "15.1.0-next.3",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "repository": {