@gearbox-protocol/sdk 17.2.0-next.1 → 17.2.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.
Files changed (42) hide show
  1. package/dist/cjs/model/charts.js +5 -0
  2. package/dist/cjs/model/opportunities.schema.js +2 -1
  3. package/dist/cjs/onchain/accounts/intents/leverage-band.js +1 -1
  4. package/dist/cjs/onchain/accounts/intents/maxBorrow.js +8 -6
  5. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +5 -3
  6. package/dist/cjs/onchain/chain/chains.js +1 -2
  7. package/dist/cjs/onchain/index.js +2 -0
  8. package/dist/cjs/onchain/market/MarketSuite.js +11 -4
  9. package/dist/cjs/onchain/market/credit/CreditSuite.js +24 -177
  10. package/dist/cjs/onchain/market/credit/CreditSuiteStrategy.js +179 -0
  11. package/dist/cjs/onchain/market/credit/index.js +2 -0
  12. package/dist/cjs/onchain/market/index.js +2 -0
  13. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +7 -9
  14. package/dist/cjs/sdk/prepare/PrepareApi.js +1 -1
  15. package/dist/esm/model/charts.js +5 -0
  16. package/dist/esm/model/opportunities.schema.js +2 -1
  17. package/dist/esm/onchain/accounts/intents/leverage-band.js +1 -1
  18. package/dist/esm/onchain/accounts/intents/maxBorrow.js +8 -6
  19. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +5 -3
  20. package/dist/esm/onchain/chain/chains.js +1 -2
  21. package/dist/esm/onchain/index.js +2 -1
  22. package/dist/esm/onchain/market/MarketSuite.js +11 -4
  23. package/dist/esm/onchain/market/credit/CreditSuite.js +26 -179
  24. package/dist/esm/onchain/market/credit/CreditSuiteStrategy.js +178 -0
  25. package/dist/esm/onchain/market/credit/index.js +2 -1
  26. package/dist/esm/onchain/market/index.js +2 -1
  27. package/dist/esm/onchain/opportunities/OpportunitiesService.js +7 -9
  28. package/dist/esm/sdk/prepare/PrepareApi.js +1 -1
  29. package/dist/types/model/charts.d.ts +5 -2
  30. package/dist/types/model/charts.schema.d.ts +8 -0
  31. package/dist/types/model/opportunities.d.ts +4 -0
  32. package/dist/types/model/opportunities.schema.d.ts +19 -0
  33. package/dist/types/model/positions.schema.d.ts +9 -0
  34. package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +5 -5
  35. package/dist/types/onchain/index.d.ts +2 -1
  36. package/dist/types/onchain/market/MarketSuite.d.ts +6 -0
  37. package/dist/types/onchain/market/credit/CreditSuite.d.ts +17 -70
  38. package/dist/types/onchain/market/credit/CreditSuiteStrategy.d.ts +78 -0
  39. package/dist/types/onchain/market/credit/index.d.ts +2 -1
  40. package/dist/types/onchain/market/credit/types.d.ts +3 -1
  41. package/dist/types/onchain/market/index.d.ts +2 -1
  42. package/package.json +1 -1
@@ -94,6 +94,7 @@ const require_onchain_market_rwa_midas_constants = require("./rwa/midas/constant
94
94
  const require_onchain_market_rwa_midas_MidasDegenNFT = require("./rwa/midas/MidasDegenNFT.js");
95
95
  const require_onchain_market_rwa_securitize_constants = require("./rwa/securitize/constants.js");
96
96
  const require_onchain_market_strategyName = require("./strategyName.js");
97
+ const require_onchain_market_credit_CreditSuiteStrategy = require("./credit/CreditSuiteStrategy.js");
97
98
  const require_onchain_market_credit_collateralUtils = require("./credit/collateralUtils.js");
98
99
  const require_onchain_market_credit_CreditSuite = require("./credit/CreditSuite.js");
99
100
  const require_onchain_market_credit_expectedBalanceDeltas = require("./credit/expectedBalanceDeltas.js");
@@ -170,6 +171,7 @@ exports.CreditFacadeV310BaseContract = require_onchain_market_credit_CreditFacad
170
171
  exports.CreditFacadeV310Contract = require_onchain_market_credit_CreditFacadeV310Contract.CreditFacadeV310Contract;
171
172
  exports.CreditManagerV310Contract = require_onchain_market_credit_CreditManagerV310Contract.CreditManagerV310Contract;
172
173
  exports.CreditSuite = require_onchain_market_credit_CreditSuite.CreditSuite;
174
+ exports.CreditSuiteStrategy = require_onchain_market_credit_CreditSuiteStrategy.CreditSuiteStrategy;
173
175
  exports.Curve2AssetsAdapterContract = require_onchain_market_adapters_contracts_Curve2AssetsAdapterContract.Curve2AssetsAdapterContract;
174
176
  exports.Curve3AssetsAdapterContract = require_onchain_market_adapters_contracts_Curve3AssetsAdapterContract.Curve3AssetsAdapterContract;
175
177
  exports.Curve4AssetsAdapterContract = require_onchain_market_adapters_contracts_Curve4AssetsAdapterContract.Curve4AssetsAdapterContract;
@@ -43,12 +43,11 @@ var OpportunitiesService = class extends require_onchain_base_SDKConstruct.SDKCo
43
43
  * strategy.
44
44
  **/
45
45
  async getStrategy(key) {
46
- const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
47
- const detail = suite.strategyOpportunityDetail();
48
- if (!detail) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
49
- const kyc = await suite.kycRequirement(detail.targetCollateral.address);
46
+ const strategy = this.sdk.marketRegister.findCreditManager(key.creditManager).strategy;
47
+ if (!strategy?.isListed) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
48
+ const kyc = await strategy.kycRequirement();
50
49
  return {
51
- ...detail,
50
+ ...strategy.opportunityDetail(),
52
51
  kyc
53
52
  };
54
53
  }
@@ -60,10 +59,9 @@ var OpportunitiesService = class extends require_onchain_base_SDKConstruct.SDKCo
60
59
  * strategy.
61
60
  **/
62
61
  async isEligibleForStrategy(key, wallet) {
63
- const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
64
- const opportunity = suite.strategyOpportunity();
65
- if (!opportunity) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
66
- return suite.isEligibleForStrategy(wallet, opportunity.targetCollateral.address);
62
+ const strategy = this.sdk.marketRegister.findCreditManager(key.creditManager).strategy;
63
+ if (!strategy?.isListed) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
64
+ return strategy.isEligible(wallet);
67
65
  }
68
66
  };
69
67
  //#endregion
@@ -231,7 +231,7 @@ var PrepareApi = class extends require_onchain_base_MultichainConstruct.Multicha
231
231
  const sdk = await this.#chain(strategy.chainId);
232
232
  const at = stateBlock(sdk);
233
233
  Object.assign(state, marketOf(sdk, strategy.creditManager));
234
- const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
234
+ const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategy?.targetCollateral;
235
235
  if (!targetToken) return refused(require_model_errors_prepare_errors.noStrategyTargetCollateral(strategy.creditManager), state);
236
236
  const reused = await reusable(sdk, strategy, params.creditAccount);
237
237
  if (reused && "error" in reused) return refused(reused.error, state);
@@ -25,10 +25,13 @@ const CHART_RANGES = [
25
25
  ];
26
26
  /**
27
27
  * Every metric a pool opportunity can chart.
28
+ *
29
+ * `rewardsApyAvg7d` is the trailing seven-day average yield from rewards.
28
30
  **/
29
31
  const POOL_OPPORTUNITY_CHART_METRICS = [
30
32
  "depositApy",
31
33
  "depositApyAvg7d",
34
+ "rewardsApyAvg7d",
32
35
  "dieselRate",
33
36
  "supplied",
34
37
  "borrowed",
@@ -43,6 +46,7 @@ const POOL_OPPORTUNITY_CHART_METRICS = [
43
46
  const STRATEGY_OPPORTUNITY_CHART_METRICS = [
44
47
  "borrowApy",
45
48
  "borrowApyAvg7d",
49
+ "rewardsApyAvg7d",
46
50
  "quotaRate",
47
51
  "liquidationThreshold",
48
52
  "collateralApy",
@@ -105,6 +109,7 @@ const PROTOCOL_CHART_METRICS = ["tvlUsd"];
105
109
  const CHART_METRIC_UNITS = {
106
110
  depositApy: "bps",
107
111
  depositApyAvg7d: "bps",
112
+ rewardsApyAvg7d: "bps",
108
113
  borrowApy: "bps",
109
114
  borrowApyAvg7d: "bps",
110
115
  quotaRate: "bps",
@@ -30,7 +30,8 @@ const tokenRewardsSchema = z.object({
30
30
  kind: z.literal("token"),
31
31
  token: tokenSchema,
32
32
  supplyApr: bpsSchema.optional(),
33
- borrowApr: bpsSchema.optional()
33
+ borrowApr: bpsSchema.optional(),
34
+ links: z.array(z.string()).optional()
34
35
  });
35
36
  /**
36
37
  * {@link PointRewards}
@@ -33,7 +33,7 @@ function calcLeverageBand({ sdk, creditManager, collateral, targetHF }) {
33
33
  const found = resolveCreditManager(sdk, creditManager);
34
34
  if (!found) return;
35
35
  const { suite, market } = found;
36
- const target = suite.strategyTargetCollateral;
36
+ const target = suite.strategy?.targetCollateral;
37
37
  if (!target) return;
38
38
  const ceiling = suite.creditManager.maxLeverage(target, targetHF);
39
39
  const underlying = market.pool.underlying;
@@ -19,9 +19,9 @@ import { collateralValuation } from "./collateral-valuation.js";
19
19
  * Collateral is valued the way the transaction will be judged — at safe
20
20
  * prices, under its liquidation threshold, capped by the quota the borrow
21
21
  * buys for it, all of which is {@link collateralValuation}'s business. The ceiling
22
- * is then held to what the market will actually lend: the pool's free
23
- * liquidity, the manager's own allowance, the facade's `maxDebt` and the
24
- * remaining quota of the strategy target collateral, whichever binds first.
22
+ * is then held to what the market will actually lend,
23
+ * {@link CreditSuite.maxBorrowAmount}: the pool's free liquidity, the
24
+ * manager's own allowance and the facade's `maxDebt`, whichever binds first.
25
25
  *
26
26
  * The facade's `minDebt` is not applied to the collateral's own ceiling. It
27
27
  * is a floor, and a ceiling answered as `0n` because the collateral is too
@@ -30,8 +30,8 @@ import { collateralValuation } from "./collateral-valuation.js";
30
30
  * that carries something therefore answers with it, whether or not the market
31
31
  * would lend that little; a loan under the floor is refused by `borrow`
32
32
  * itself, with `debtOutOfRange` naming both ends. A market whose own capacity
33
- * is under `minDebt` is different: `maxStrategyBorrowAmount` answers `0n`,
34
- * because no loan of any size exists there.
33
+ * is under `minDebt` is different: the answer is `0n`, because no loan of any
34
+ * size exists there.
35
35
  *
36
36
  * Nothing is fetched or simulated — the account does not exist yet and every
37
37
  * input is loaded market state, so a form can call this on each keystroke.
@@ -81,7 +81,9 @@ function maxBorrow(props) {
81
81
  const weighted = valuation.checkedUsd(holding) * valuation.lt(collateralToken);
82
82
  const backed = quotas.some((q) => eq(q.token, collateralToken)) ? BigIntMath.min(valuation.quotaValue(holding), weighted) : weighted;
83
83
  if (backed <= 0n) return 0n;
84
- const ceiling = BigIntMath.min(priceOracle.safeConvertFromUSD(underlying, backed / targetHF).value, suite.maxStrategyBorrowAmount().amount.value);
84
+ const lends = suite.maxBorrowAmount().amount.value;
85
+ if (lends < suite.creditFacade.minDebt) return 0n;
86
+ const ceiling = BigIntMath.min(priceOracle.safeConvertFromUSD(underlying, backed / targetHF).value, lends);
85
87
  const unwrapsPayout = !!rwaAsset && eq(borrowToken, rwaAsset);
86
88
  return eq(borrowToken, underlying) ? ceiling : unwrapsPayout ? toTargetDecimals(ceiling, underlying, borrowToken, sdk) : priceOracle.safeConvert(underlying, borrowToken, ceiling).value;
87
89
  }
@@ -1,6 +1,7 @@
1
1
  import "../../../constants/math.js";
2
2
  import "../../../constants/index.js";
3
3
  import { calcMaxLeverage } from "../../../market/math.js";
4
+ import { CreditSuiteStrategy } from "../../../market/credit/CreditSuiteStrategy.js";
4
5
  import { CreditSuite } from "../../../market/credit/CreditSuite.js";
5
6
  import { PositionsService } from "../../../positions/PositionsService.js";
6
7
  import { TestPriceOracle } from "../../../market/oracle/TestPriceOracle.mock.js";
@@ -189,8 +190,10 @@ function buildMockSdk(args) {
189
190
  const strategyName = strategyTargetCollateral ? `${tokenOf(strategyTargetCollateral).symbol} / ${underlyingToken.symbol}` : void 0;
190
191
  const creditManagerSuite = {
191
192
  name: "TestCreditManager",
192
- strategyName,
193
193
  underlyingToken,
194
+ get strategy() {
195
+ return strategyTargetCollateral ? new CreditSuiteStrategy(creditManagerSuite, strategyTargetCollateral) : void 0;
196
+ },
194
197
  accountTargetCollateral: () => strategyTargetCollateral ? tokenOf(strategyTargetCollateral) : null,
195
198
  accountStrategyName: () => strategyName ?? underlyingToken.symbol,
196
199
  liquidationFees: () => MOCK_LIQUIDATION_FEES,
@@ -198,7 +201,6 @@ function buildMockSdk(args) {
198
201
  creditOperationMarket: CreditSuite.prototype.creditOperationMarket,
199
202
  isForbidden: CreditSuite.prototype.isForbidden,
200
203
  maxBorrowAmount: CreditSuite.prototype.maxBorrowAmount,
201
- maxStrategyBorrowAmount: CreditSuite.prototype.maxStrategyBorrowAmount,
202
204
  creditManager: {
203
205
  address: args.creditManager,
204
206
  liquidationThresholds,
@@ -220,7 +222,6 @@ function buildMockSdk(args) {
220
222
  market,
221
223
  isPaused: facadePaused || poolPaused,
222
224
  forbiddenTokens: [...forbidden],
223
- strategyTargetCollateral,
224
225
  isExpired: expirationDate > 0 && expirationDate < (args.timestamp ?? 0)
225
226
  };
226
227
  const routeCalls = (tokenIn, tokenOut) => {
@@ -357,6 +358,7 @@ function buildMockSdk(args) {
357
358
  }
358
359
  };
359
360
  Object.assign(sdk, { positions: new PositionsService(sdk) });
361
+ Object.assign(creditManagerSuite, { sdk });
360
362
  return sdk;
361
363
  }
362
364
  /** A full account payload carrying exactly what the slice builder reads back. */
@@ -95,8 +95,7 @@ const chains = {
95
95
  "0x89014edc549ffa5c5b6e859b1496731bd035c247": "0x31454faa1daa04cacf59a6bd37681da9160d092a",
96
96
  "0x3b7ab1f4fee570933b24b202de90ffda82f6cae0": "0x31454faa1daa04cacf59a6bd37681da9160d092a",
97
97
  "0x721798d8ccf31ae75c12db82fa72b3806759cbc9": "0x31454faa1daa04cacf59a6bd37681da9160d092a",
98
- "0xd7273d9594ac88f993eda9773041e621633acea0": "0x1a711a5bc48b5c1352c1882fa65dc14b5b9e829d",
99
- "0x34442ca47435e90b80d835aab9737166e76d9962": "0x403cc0d2694ec2639101f32b146b90d766461ce9"
98
+ "0xd7273d9594ac88f993eda9773041e621633acea0": "0x1a711a5bc48b5c1352c1882fa65dc14b5b9e829d"
100
99
  }),
101
100
  sunsetPools: new AddressSet([
102
101
  "0xF791Ecc5F2472637eac9DFe3f7894C0B32C32bDf",
@@ -139,6 +139,7 @@ import { DEGEN_NFT_MIDAS, PHANTOM_TOKEN_MIDAS_REDEMPTION, RWA_LIQUIDATOR_MIDAS }
139
139
  import { MidasDegenNFT } from "./market/rwa/midas/MidasDegenNFT.js";
140
140
  import { DEGEN_NFT_SECURITIZE, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWA_LIQUIDATOR_SECURITIZE } from "./market/rwa/securitize/constants.js";
141
141
  import { strategyName } from "./market/strategyName.js";
142
+ import { CreditSuiteStrategy } from "./market/credit/CreditSuiteStrategy.js";
142
143
  import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./market/credit/collateralUtils.js";
143
144
  import { CreditSuite } from "./market/credit/CreditSuite.js";
144
145
  import { expectedBalanceDeltas } from "./market/credit/expectedBalanceDeltas.js";
@@ -304,4 +305,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
304
305
  import { previewOperation } from "./preview/preview/previewOperation.js";
305
306
  import "./preview/index.js";
306
307
  import "./types/index.js";
307
- 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_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, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, 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_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, 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, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, 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, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, 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, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, 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, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
308
+ 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_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, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, CreditSuiteStrategy, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, 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_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, 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, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, 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, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, 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, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, 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, 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, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
@@ -236,13 +236,20 @@ var MarketSuite = class extends SDKConstruct {
236
236
  const rows = [];
237
237
  const kind = filter?.kind;
238
238
  if (!isFilterSet(kind) || kind === "pool") rows.push(this.poolOpportunity());
239
- if (!isFilterSet(kind) || kind === "strategy") for (const suite of this.creditManagers) {
240
- const opportunity = suite.strategyOpportunity();
241
- if (opportunity) rows.push(opportunity);
242
- }
239
+ if (!isFilterSet(kind) || kind === "strategy") rows.push(...this.strategies().map((s) => s.opportunity()));
243
240
  return rows.filter((row) => matchesOpportunityFilter(row, filter));
244
241
  }
245
242
  /**
243
+ * Strategies this market lists as opportunities; see
244
+ * {@link CreditSuiteStrategy.isListed}.
245
+ */
246
+ strategies() {
247
+ return this.creditManagers.flatMap((suite) => {
248
+ const strategy = suite.strategy;
249
+ return strategy?.isListed ? [strategy] : [];
250
+ });
251
+ }
252
+ /**
246
253
  * Passive lending into this market's pool, as the shared read model
247
254
  * describes it.
248
255
  */
@@ -1,14 +1,15 @@
1
1
  import { AddressMap } from "../../utils/AddressMap.js";
2
- import { getAccountTargetCollateral, getLegacyStrategyTarget, isSunsetStrategy } from "../../chain/chains.js";
2
+ import { getAccountTargetCollateral, getLegacyStrategyTarget } from "../../chain/chains.js";
3
3
  import "../../constants/addresses.js";
4
4
  import { PERCENTAGE_FACTOR, RAY } from "../../constants/math.js";
5
5
  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 { calcBorrowApy, calcQuotaRate, minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
9
+ import { minSeizedAmount, optimalHFForPartialLiquidation, optimalRepaidAmount } from "../math.js";
10
10
  import { createDegenNFT } from "../rwa/createDegenNFT.js";
11
11
  import { strategyName } from "../strategyName.js";
12
+ import { CreditSuiteStrategy } from "./CreditSuiteStrategy.js";
12
13
  import { dominantCollateral, isStrategyCollateral, pickStrategyTargetCollateral } from "./collateralUtils.js";
13
14
  import createCreditConfigurator from "./createCreditConfigurator.js";
14
15
  import createCreditFacade from "./createCreditFacade.js";
@@ -16,13 +17,6 @@ import createCreditManager from "./createCreditManager.js";
16
17
  import { isAddressEqual } from "viem";
17
18
  //#region src/onchain/market/credit/CreditSuite.ts
18
19
  /**
19
- * Amount of underlying seeded into each pool at market creation to protect
20
- * from inflation attacks, in raw token units. A suite whose
21
- * {@link CreditSuite.maxStrategyBorrowAmount} is at or below this is treated as
22
- * having nothing left to lend.
23
- **/
24
- const MIN_STRATEGY_BORROW_AMOUNT = 100000n;
25
- /**
26
20
  * SDK aggregate for one credit-manager branch inside a market.
27
21
  *
28
22
  * @remarks
@@ -129,31 +123,6 @@ var CreditSuite = class extends SDKConstruct {
129
123
  return this.#degenNFT;
130
124
  }
131
125
  /**
132
- * The KYC gate of this suite's strategy; `null` when there is none.
133
- * Wallet-independent.
134
- */
135
- async kycRequirement(targetCollateral) {
136
- const nft = await this.degenNFT();
137
- if (!nft) return null;
138
- const tokens = await nft.getTokens();
139
- const token = tokens.find((t) => isAddressEqual(t, targetCollateral)) ?? tokens[0];
140
- return {
141
- protocol: nft.protocol,
142
- token: token ? this.tokensMeta.getToken(token) : void 0,
143
- registrationLink: nft.registrationLink
144
- };
145
- }
146
- /**
147
- * Whether `wallet` may open this suite's strategy today; `true` when there
148
- * is no KYC gate.
149
- */
150
- async isEligibleForStrategy(wallet, targetCollateral) {
151
- const nft = await this.degenNFT();
152
- if (!nft) return true;
153
- const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: targetCollateral });
154
- return nft.isRegistered(requirements);
155
- }
156
- /**
157
126
  * Builds a transaction that executes a multicall on one of this suite's
158
127
  * credit accounts.
159
128
  *
@@ -246,13 +215,14 @@ var CreditSuite = class extends SDKConstruct {
246
215
  * row all spread it, so the five fields are filled in one place and cannot
247
216
  * drift apart between the halves of the SDK.
248
217
  *
249
- * The curator comes from the same getter {@link strategyOpportunity} reads, so
218
+ * The curator comes from the same getter
219
+ * {@link CreditSuiteStrategy.opportunity} reads, so
250
220
  * a result and the opportunity beside it name one entity.
251
221
  */
252
222
  creditOperationMarket() {
253
223
  return {
254
224
  creditManager: this.creditManager.address,
255
- name: this.strategyName ?? this.underlyingToken.symbol,
225
+ name: this.strategy?.name ?? this.underlyingToken.symbol,
256
226
  underlyingToken: this.underlyingToken,
257
227
  curator: this.market.curator,
258
228
  liquidationDiscount: this.totalLiquidationDiscount()
@@ -281,19 +251,14 @@ var CreditSuite = class extends SDKConstruct {
281
251
  return this.forbiddenTokens.some((f) => isAddressEqual(f, token));
282
252
  }
283
253
  /**
284
- * Largest debt this credit manager will hand out on one operation right now,
285
- * and which limit set that number.
254
+ * Largest debt this credit manager allows to borrow, and which limit set that number.
286
255
  *
287
256
  * Minimum of:
288
257
  * - the pool's available liquidity,
289
258
  * - this manager's remaining debt allowance, and
290
259
  * - the facade's per-account `maxDebt`.
291
- * While `maxDebtPerBlockMultiplier` is `0` the facade
292
- * takes no new debt at all, so the answer is `0`.
293
260
  *
294
- * These are the bounds every debt increase answers to, an existing account's
295
- * included, which is what the guards hold a simulation to. Opening a position
296
- * answers to two more — see {@link maxStrategyBorrowAmount}.
261
+ * If the credit manager allows no debt at all, the answer is `0`.
297
262
  */
298
263
  maxBorrowAmount() {
299
264
  const { pool } = this.market.pool;
@@ -323,68 +288,25 @@ var CreditSuite = class extends SDKConstruct {
323
288
  };
324
289
  }
325
290
  /**
326
- * Largest debt one new position can take from this credit manager right now,
327
- * and which limit set that number.
328
- *
329
- * {@link maxBorrowAmount} held to the two bounds only a position being opened
330
- * answers to: the remaining quota of the strategy target collateral, which
331
- * the position has to buy to be worth anything, and the facade's `minDebt`,
332
- * which a first debt cannot sit under. `amount` is `0` whenever no position
333
- * can be opened right now, and `limit` names why.
334
- *
335
- * An operation on an account that already exists is held to neither: its
336
- * quota is weighed against the token its own plan buys, and its debt is
337
- * already over the floor, so a top-up smaller than `minDebt` is legal.
338
- */
339
- maxStrategyBorrowAmount() {
340
- const lends = this.maxBorrowAmount();
341
- if (lends.limit === "debtPerBlockLimit") return lends;
342
- const collateral = this.strategyTargetCollateral;
343
- let value = lends.amount.value;
344
- let limit = lends.limit;
345
- if (collateral !== void 0) {
346
- const quota = this.market.pool.pqk.quotaAvailable(collateral);
347
- if (quota < value) {
348
- value = quota;
349
- limit = "quotaAvailable";
350
- }
351
- }
352
- if (value < this.creditFacade.minDebt) return {
353
- amount: this.market.toUnderlyingAmount(0n),
354
- limit: "minDebt"
355
- };
356
- return {
357
- amount: this.market.toUnderlyingAmount(value),
358
- limit
359
- };
360
- }
361
- /**
362
- * The single target collateral of this suite's strategy, or `undefined` when
363
- * none can be resolved.
291
+ * This suite's leveraged strategy, or `undefined` when no target collateral
292
+ * can be resolved.
364
293
  *
365
- * Resolution, in order:
366
- * 1. a hardcoded legacy mapping for this credit manager, when that token is
367
- * still a collateral of the manager (it may be absent on an older
368
- * snapshot, or after it was delisted);
369
- * 2. the collateral with the biggest index in
370
- * {@link ICreditManagerContract.collateralTokens} that
371
- * {@link isStrategyCollateral} accepts with quota required;
372
- * 3. the biggest-index collateral that {@link isStrategyCollateral} accepts
373
- * without quota.
374
- */
375
- get strategyTargetCollateral() {
294
+ * The strategy exists whether or not it is offered today, because its
295
+ * target also names existing positions; see
296
+ * {@link CreditSuiteStrategy.isListed} for whether it is listed as an
297
+ * opportunity.
298
+ */
299
+ get strategy() {
376
300
  const legacy = getLegacyStrategyTarget(this.creditManager.address, this.chainId);
377
- if (legacy && this.creditManager.liquidationThresholds.has(legacy)) return legacy;
378
- return pickStrategyTargetCollateral(this.creditManager.collateralTokens.map((token) => this.#strategyCollateralProps(token)));
301
+ const target = legacy && this.creditManager.liquidationThresholds.has(legacy) ? legacy : pickStrategyTargetCollateral(this.creditManager.collateralTokens.map((token) => this.#strategyCollateralProps(token)));
302
+ return target ? new CreditSuiteStrategy(this, target) : void 0;
379
303
  }
380
304
  /**
381
- * Display name of this suite's leveraged strategy, e.g. `"wstETH / WETH"`,
382
- * or `undefined` when {@link strategyTargetCollateral} cannot be resolved.
305
+ * Whether `token` can be this suite's strategy target; see
306
+ * {@link isStrategyCollateral}.
383
307
  */
384
- get strategyName() {
385
- const collateral = this.strategyTargetCollateral;
386
- if (!collateral) return;
387
- return strategyName(this.tokensMeta.mustGetToken(collateral), this.underlyingToken);
308
+ isStrategyCollateral(token, requireQuota = false) {
309
+ return isStrategyCollateral(this.#strategyCollateralProps(token), requireQuota);
388
310
  }
389
311
  /**
390
312
  * Collateral token an existing credit account in this suite is a strategy
@@ -392,12 +314,13 @@ var CreditSuite = class extends SDKConstruct {
392
314
  *
393
315
  * Resolution, in order:
394
316
  * 1. a hardcoded per-account override, when present;
395
- * 2. {@link strategyTargetCollateral};
317
+ * 2. the target of {@link strategy};
396
318
  * 3. `null` when neither can be resolved.
397
319
  */
398
320
  accountTargetCollateral(creditAccount) {
399
- const addr = getAccountTargetCollateral(creditAccount, this.chainId) ?? this.strategyTargetCollateral;
400
- return addr ? this.tokensMeta.mustGetToken(addr) : null;
321
+ const override = getAccountTargetCollateral(creditAccount, this.chainId);
322
+ if (override) return this.tokensMeta.mustGetToken(override);
323
+ return this.strategy?.token ?? null;
401
324
  }
402
325
  /**
403
326
  * Display name of an existing credit account in this suite, e.g.
@@ -411,61 +334,6 @@ var CreditSuite = class extends SDKConstruct {
411
334
  return target ? strategyName(target, this.underlyingToken) : this.underlyingToken.symbol;
412
335
  }
413
336
  /**
414
- * Describes this suite's leveraged strategy as the shared read model does,
415
- * or `undefined` when credit suite does not offer a strategy opportunity.
416
- */
417
- strategyOpportunity() {
418
- const maxBorrowAmount = this.maxStrategyBorrowAmount().amount.value;
419
- if (maxBorrowAmount <= MIN_STRATEGY_BORROW_AMOUNT) return;
420
- const collateral = this.strategyTargetCollateral;
421
- if (!collateral) return;
422
- if (!isStrategyCollateral(this.#strategyCollateralProps(collateral), true)) return;
423
- const { market, creditManager: cm } = this;
424
- const { pool } = market.pool;
425
- const oracle = market.priceOracle;
426
- const liquidationThreshold = cm.liquidationThresholds.mustGet(collateral);
427
- const maxLeverage = cm.maxLeverage(collateral);
428
- const debtParams = pool.creditManagerDebtParams.get(cm.address);
429
- const borrowed = debtParams?.borrowed ?? 0n;
430
- return {
431
- kind: "strategy",
432
- chainId: this.chainId,
433
- creditManager: cm.address,
434
- targetCollateral: this.tokensMeta.mustGetToken(collateral),
435
- name: this.strategyName ?? this.underlyingToken.symbol,
436
- curator: market.curator,
437
- underlyingToken: this.underlyingToken,
438
- totalBorrowed: oracle.toAmount(pool.underlying, borrowed),
439
- allowedDepositTokens: this.allowedDepositTokens(collateral),
440
- paused: this.isPaused,
441
- rwa: market.rwa,
442
- sunset: market.sunset || isSunsetStrategy(cm.address, this.sdk.networkType),
443
- liquidationThreshold,
444
- liquidationPremium: cm.liquidationPremium,
445
- liquidationFee: cm.feeLiquidation,
446
- expirationDate: this.expirationDate,
447
- borrowApy: calcBorrowApy(pool.baseInterestRate, cm.feeInterest),
448
- quotaRate: calcQuotaRate(market.pool.pqk.quotaRate(collateral), cm.feeInterest),
449
- availableLiquidity: oracle.toAmount(pool.underlying, pool.availableLiquidity),
450
- minDebt: oracle.toAmount(pool.underlying, this.creditFacade.minDebt),
451
- totalDebtLimit: oracle.toAmount(pool.underlying, debtParams?.limit ?? 0n),
452
- maxBorrowAmount: oracle.toAmount(pool.underlying, maxBorrowAmount),
453
- maxLeverage
454
- };
455
- }
456
- /**
457
- * {@link strategyOpportunity} plus the data only its detail screen needs.
458
- */
459
- strategyOpportunityDetail() {
460
- const opportunity = this.strategyOpportunity();
461
- if (!opportunity) return;
462
- return {
463
- ...opportunity,
464
- rateCurve: this.market.pool.rateCurve,
465
- priceFeeds: this.market.priceFeedSummary(opportunity.targetCollateral.address)
466
- };
467
- }
468
- /**
469
337
  * Everything a partial liquidation of credit account needs, with any parameter the
470
338
  * caller pinned down taken as given and the rest derived from current state.
471
339
  *
@@ -505,27 +373,6 @@ var CreditSuite = class extends SDKConstruct {
505
373
  return collateral;
506
374
  }
507
375
  /**
508
- * Tokens a user can transfer from their wallet when opening an account in
509
- * this suite:
510
- *
511
- * 1. unwrapped underlying (USDC, never dcUSDC)
512
- * 2. target collateral
513
- * 3. remaining CM collaterals in manager order, excluding phantom tokens
514
- * and tokens without price
515
- */
516
- allowedDepositTokens(targetCollateral) {
517
- const unwrappedUnderlying = this.market.unwrappedUnderlying;
518
- const { mainPrices, reservePrices } = this.market.priceOracle;
519
- return [
520
- unwrappedUnderlying,
521
- targetCollateral,
522
- ...this.creditManager.collateralTokens.filter((token) => {
523
- const contractType = this.tokensMeta.mustGet(token).contractType;
524
- return !this.market.isUnderlyingLike(token) && !isAddressEqual(token, targetCollateral) && !contractType?.startsWith("PHANTOM_TOKEN::") && (!!mainPrices.get(token)?.price || !!reservePrices.get(token)?.price);
525
- })
526
- ].map((token) => this.tokensMeta.mustGetToken(token));
527
- }
528
- /**
529
376
  * Shared inputs of {@link isStrategyCollateral} for one of this suite's
530
377
  * collateral tokens.
531
378
  */