@gearbox-protocol/sdk 16.0.0-next.17 → 16.0.0-next.19

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 (197) hide show
  1. package/dist/cjs/common-utils/index.js +3 -21
  2. package/dist/cjs/common-utils/test-utils/index.js +4 -3
  3. package/dist/cjs/common-utils/utils/index.js +3 -22
  4. package/dist/cjs/common-utils/utils/strategies/index.js +3 -0
  5. package/dist/cjs/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -5
  6. package/dist/cjs/common-utils/utils/strategies/strategy-info/credit-manager-issues.js +135 -0
  7. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +12 -23
  8. package/dist/cjs/common-utils/utils/strategies/strategy-info/index.js +3 -0
  9. package/dist/cjs/onchain/accounts/index.js +2 -3
  10. package/dist/cjs/onchain/accounts/intents/guards.js +55 -50
  11. package/dist/cjs/onchain/accounts/intents/index.js +24 -16
  12. package/dist/cjs/onchain/accounts/intents/leverage-band.js +2 -2
  13. package/dist/cjs/onchain/accounts/intents/math.js +15 -22
  14. package/dist/cjs/onchain/accounts/intents/open-strategy.js +5 -5
  15. package/dist/cjs/onchain/accounts/intents/plan.js +27 -41
  16. package/dist/cjs/onchain/accounts/intents/realize.js +14 -21
  17. package/dist/cjs/onchain/accounts/intents/tail.js +2 -2
  18. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  19. package/dist/cjs/onchain/accounts/intents/view.js +1 -0
  20. package/dist/cjs/onchain/constants/index.js +1 -0
  21. package/dist/cjs/onchain/constants/math.js +11 -0
  22. package/dist/cjs/onchain/index.js +32 -3
  23. package/dist/cjs/onchain/market/credit/CreditManagerV310Contract.js +2 -2
  24. package/dist/cjs/onchain/market/math.js +23 -11
  25. package/dist/cjs/onchain/validation/checks.js +250 -0
  26. package/dist/cjs/onchain/validation/index.js +29 -0
  27. package/dist/cjs/onchain/{accounts/intents → validation}/refusal.js +12 -1
  28. package/dist/cjs/onchain/validation/token.js +29 -0
  29. package/dist/cjs/preview/index.js +10 -0
  30. package/dist/cjs/preview/preview/buildDelayedPreview.js +1 -0
  31. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +1 -0
  32. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +1 -0
  33. package/dist/cjs/preview/validate/checkOperation.js +173 -0
  34. package/dist/cjs/preview/validate/checkSimulation.js +52 -0
  35. package/dist/cjs/preview/validate/index.js +6 -0
  36. package/dist/cjs/sdk/index.js +4 -0
  37. package/dist/cjs/sdk/prepare/PrepareApi.js +23 -17
  38. package/dist/cjs/sdk/prepare/index.js +4 -0
  39. package/dist/cjs/sdk/prepare/types.js +4 -0
  40. package/dist/esm/common-utils/index.js +2 -11
  41. package/dist/esm/common-utils/test-utils/index.js +4 -3
  42. package/dist/esm/common-utils/utils/index.js +2 -12
  43. package/dist/esm/common-utils/utils/strategies/index.js +2 -1
  44. package/dist/esm/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -5
  45. package/dist/esm/common-utils/utils/strategies/strategy-info/credit-manager-issues.js +133 -0
  46. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +12 -23
  47. package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +2 -1
  48. package/dist/esm/dev/AccountOpener.js +1 -1
  49. package/dist/esm/dev/withdrawalUtils.js +1 -1
  50. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  51. package/dist/esm/onchain/accounts/index.js +2 -2
  52. package/dist/esm/onchain/accounts/intents/guards.js +55 -50
  53. package/dist/esm/onchain/accounts/intents/index.js +23 -14
  54. package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -2
  55. package/dist/esm/onchain/accounts/intents/math.js +14 -21
  56. package/dist/esm/onchain/accounts/intents/open-strategy.js +4 -4
  57. package/dist/esm/onchain/accounts/intents/plan.js +15 -29
  58. package/dist/esm/onchain/accounts/intents/realize.js +12 -19
  59. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  60. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +2 -1
  61. package/dist/esm/onchain/accounts/intents/view.js +1 -0
  62. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  63. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  64. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  65. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  66. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  67. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  68. package/dist/esm/onchain/chain/detectNetwork.js +1 -1
  69. package/dist/esm/onchain/constants/index.js +2 -2
  70. package/dist/esm/onchain/constants/math.js +11 -1
  71. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  72. package/dist/esm/onchain/index.js +7 -3
  73. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  74. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  75. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  76. package/dist/esm/onchain/market/credit/CreditManagerV310Contract.js +2 -2
  77. package/dist/esm/onchain/market/math.js +23 -11
  78. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  79. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  80. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  81. package/dist/esm/onchain/pools/PoolService.js +1 -1
  82. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  83. package/dist/esm/onchain/validation/checks.js +230 -0
  84. package/dist/esm/onchain/validation/index.js +4 -0
  85. package/dist/esm/onchain/{accounts/intents → validation}/refusal.js +12 -2
  86. package/dist/esm/onchain/validation/token.js +27 -0
  87. package/dist/esm/preview/index.js +5 -1
  88. package/dist/esm/preview/preview/buildDelayedPreview.js +1 -0
  89. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +1 -0
  90. package/dist/esm/preview/preview/previewOpenCreditAccount.js +1 -0
  91. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  92. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  93. package/dist/esm/preview/validate/checkOperation.js +171 -0
  94. package/dist/esm/preview/validate/checkSimulation.js +51 -0
  95. package/dist/esm/preview/validate/index.js +3 -0
  96. package/dist/esm/sdk/index.js +2 -1
  97. package/dist/esm/sdk/prepare/PrepareApi.js +21 -15
  98. package/dist/esm/sdk/prepare/index.js +2 -1
  99. package/dist/esm/sdk/prepare/types.js +2 -1
  100. package/dist/types/common-utils/index.d.ts +2 -12
  101. package/dist/types/common-utils/utils/index.d.ts +2 -13
  102. package/dist/types/common-utils/utils/strategies/index.d.ts +2 -1
  103. package/dist/types/common-utils/utils/strategies/strategy-info/credit-manager-issues.d.ts +34 -0
  104. package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +2 -1
  105. package/dist/types/model/previews.d.ts +22 -0
  106. package/dist/types/onchain/accounts/index.d.ts +2 -2
  107. package/dist/types/onchain/accounts/intents/guards.d.ts +8 -4
  108. package/dist/types/onchain/accounts/intents/index.d.ts +20 -10
  109. package/dist/types/onchain/accounts/intents/leverage-band.d.ts +7 -2
  110. package/dist/types/onchain/accounts/intents/math.d.ts +2 -1
  111. package/dist/types/onchain/accounts/intents/plan.d.ts +3 -0
  112. package/dist/types/onchain/accounts/intents/types.d.ts +7 -1
  113. package/dist/types/onchain/constants/index.d.ts +2 -2
  114. package/dist/types/onchain/constants/math.d.ts +9 -1
  115. package/dist/types/onchain/index.d.ts +7 -3
  116. package/dist/types/onchain/market/credit/CreditManagerV310Contract.d.ts +1 -1
  117. package/dist/types/onchain/market/credit/types.d.ts +4 -3
  118. package/dist/types/onchain/market/math.d.ts +20 -9
  119. package/dist/types/onchain/validation/checks.d.ts +167 -0
  120. package/dist/types/onchain/validation/index.d.ts +4 -0
  121. package/dist/types/onchain/{accounts/intents → validation}/refusal.d.ts +100 -31
  122. package/dist/types/onchain/validation/token.d.ts +17 -0
  123. package/dist/types/preview/index.d.ts +5 -1
  124. package/dist/types/preview/validate/checkOperation.d.ts +46 -0
  125. package/dist/types/preview/validate/checkSimulation.d.ts +34 -0
  126. package/dist/types/preview/validate/index.d.ts +3 -0
  127. package/dist/types/sdk/index.d.ts +2 -2
  128. package/dist/types/sdk/prepare/PrepareApi.d.ts +3 -3
  129. package/dist/types/sdk/prepare/index.d.ts +2 -2
  130. package/dist/types/sdk/prepare/types.d.ts +8 -4
  131. package/package.json +1 -1
  132. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -267
  133. package/dist/cjs/common-utils/utils/validation/index.js +0 -23
  134. package/dist/cjs/common-utils/utils/validation/is-zero-balance.js +0 -7
  135. package/dist/cjs/common-utils/utils/validation/validate-balance.js +0 -22
  136. package/dist/cjs/common-utils/utils/validation/validate-balance.spec.js +0 -54
  137. package/dist/cjs/common-utils/utils/validation/validate-balances.js +0 -17
  138. package/dist/cjs/common-utils/utils/validation/validate-balances.spec.js +0 -45
  139. package/dist/cjs/common-utils/utils/validation/validate-credit-manager.js +0 -8
  140. package/dist/cjs/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
  141. package/dist/cjs/common-utils/utils/validation/validate-hf.js +0 -10
  142. package/dist/cjs/common-utils/utils/validation/validate-hf.spec.js +0 -26
  143. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -14
  144. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
  145. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +0 -37
  146. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
  147. package/dist/cjs/common-utils/utils/validation/validate-open-account.js +0 -18
  148. package/dist/cjs/common-utils/utils/validation/validate-open-account.spec.js +0 -56
  149. package/dist/cjs/common-utils/utils/validation/validate-quota.js +0 -23
  150. package/dist/cjs/common-utils/utils/validation/validate-quota.spec.js +0 -88
  151. package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.js +0 -18
  152. package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
  153. package/dist/cjs/common-utils/utils/validation/validation-types.js +0 -1
  154. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -264
  155. package/dist/esm/common-utils/utils/validation/index.js +0 -12
  156. package/dist/esm/common-utils/utils/validation/is-zero-balance.js +0 -6
  157. package/dist/esm/common-utils/utils/validation/validate-balance.js +0 -21
  158. package/dist/esm/common-utils/utils/validation/validate-balance.spec.js +0 -54
  159. package/dist/esm/common-utils/utils/validation/validate-balances.js +0 -16
  160. package/dist/esm/common-utils/utils/validation/validate-balances.spec.js +0 -45
  161. package/dist/esm/common-utils/utils/validation/validate-credit-manager.js +0 -7
  162. package/dist/esm/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
  163. package/dist/esm/common-utils/utils/validation/validate-hf.js +0 -8
  164. package/dist/esm/common-utils/utils/validation/validate-hf.spec.js +0 -26
  165. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -13
  166. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
  167. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +0 -36
  168. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
  169. package/dist/esm/common-utils/utils/validation/validate-open-account.js +0 -17
  170. package/dist/esm/common-utils/utils/validation/validate-open-account.spec.js +0 -56
  171. package/dist/esm/common-utils/utils/validation/validate-quota.js +0 -22
  172. package/dist/esm/common-utils/utils/validation/validate-quota.spec.js +0 -88
  173. package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.js +0 -17
  174. package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
  175. package/dist/esm/common-utils/utils/validation/validation-types.js +0 -1
  176. package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.d.ts +0 -1
  177. package/dist/types/common-utils/utils/validation/index.d.ts +0 -12
  178. package/dist/types/common-utils/utils/validation/is-zero-balance.d.ts +0 -4
  179. package/dist/types/common-utils/utils/validation/validate-balance.d.ts +0 -25
  180. package/dist/types/common-utils/utils/validation/validate-balance.spec.d.ts +0 -1
  181. package/dist/types/common-utils/utils/validation/validate-balances.d.ts +0 -13
  182. package/dist/types/common-utils/utils/validation/validate-balances.spec.d.ts +0 -1
  183. package/dist/types/common-utils/utils/validation/validate-credit-manager.d.ts +0 -13
  184. package/dist/types/common-utils/utils/validation/validate-credit-manager.spec.d.ts +0 -1
  185. package/dist/types/common-utils/utils/validation/validate-hf.d.ts +0 -12
  186. package/dist/types/common-utils/utils/validation/validate-hf.spec.d.ts +0 -1
  187. package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts +0 -10
  188. package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.d.ts +0 -1
  189. package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.d.ts +0 -26
  190. package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.spec.d.ts +0 -1
  191. package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +0 -25
  192. package/dist/types/common-utils/utils/validation/validate-open-account.spec.d.ts +0 -1
  193. package/dist/types/common-utils/utils/validation/validate-quota.d.ts +0 -24
  194. package/dist/types/common-utils/utils/validation/validate-quota.spec.d.ts +0 -1
  195. package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +0 -17
  196. package/dist/types/common-utils/utils/validation/validate-token-to-obtain.spec.d.ts +0 -1
  197. package/dist/types/common-utils/utils/validation/validation-types.d.ts +0 -10
@@ -1,6 +1,7 @@
1
1
  import { hexEq } from "../../onchain/utils/hex.js";
2
2
  import { MultichainConstruct } from "../../onchain/base/MultichainConstruct.js";
3
- import { refuse } from "../../onchain/accounts/intents/refusal.js";
3
+ import { refuse } from "../../onchain/validation/refusal.js";
4
+ import { toToken } from "../../onchain/validation/token.js";
4
5
  import { fetchCreditAccountSlice } from "../../onchain/accounts/intents/utils/credit-account-slice.js";
5
6
  import { CreditAccountOperationsService } from "../../onchain/accounts/intents/index.js";
6
7
  import "../../onchain/index.js";
@@ -52,10 +53,11 @@ var PrepareApi = class extends MultichainConstruct {
52
53
  * {@inheritDoc OpportunitiesPrepare.deposit}
53
54
  **/
54
55
  deposit(pool, params) {
55
- const { marketRegister, pools } = this.sdk.chain(pool.chainId);
56
+ const chain = this.sdk.chain(pool.chainId);
57
+ const { marketRegister, pools } = chain;
56
58
  const tokenIn = params.tokenIn ?? marketRegister.findByPool(pool.pool).pool.underlying;
57
59
  const tokenOut = lpRoute(params.tokenOut, () => pools.getDepositTokensOut(pool.pool, tokenIn));
58
- if (!tokenOut) return unroutable(tokenIn, void 0);
60
+ if (!tokenOut) return unroutable(chain, tokenIn, void 0);
59
61
  const preview = pools.simulateDeposit({
60
62
  pool: pool.pool,
61
63
  amount: params.amount,
@@ -68,7 +70,7 @@ var PrepareApi = class extends MultichainConstruct {
68
70
  wallet: params.wallet,
69
71
  meta: pools.getDepositMetadata(pool.pool, tokenIn, tokenOut)
70
72
  });
71
- if (!call) return unroutable(tokenIn, tokenOut);
73
+ if (!call) return unroutable(chain, tokenIn, tokenOut);
72
74
  return {
73
75
  ok: true,
74
76
  operations: [],
@@ -80,10 +82,11 @@ var PrepareApi = class extends MultichainConstruct {
80
82
  * {@inheritDoc OpportunitiesPrepare.withdraw}
81
83
  **/
82
84
  withdraw(pool, params) {
83
- const { pools } = this.sdk.chain(pool.chainId);
85
+ const chain = this.sdk.chain(pool.chainId);
86
+ const { pools } = chain;
84
87
  const tokenIn = params.tokenIn ?? pool.pool;
85
88
  const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
86
- if (!tokenOut) return unroutable(tokenIn, void 0);
89
+ if (!tokenOut) return unroutable(chain, tokenIn, void 0);
87
90
  const preview = pools.simulateWithdraw({
88
91
  pool: pool.pool,
89
92
  amount: params.amount,
@@ -109,10 +112,11 @@ var PrepareApi = class extends MultichainConstruct {
109
112
  * {@inheritDoc OpportunitiesPrepare.redeem}
110
113
  **/
111
114
  redeem(pool, params) {
112
- const { pools } = this.sdk.chain(pool.chainId);
115
+ const chain = this.sdk.chain(pool.chainId);
116
+ const { pools } = chain;
113
117
  const tokenIn = params.tokenIn ?? pool.pool;
114
118
  const tokenOut = lpRoute(params.tokenOut, () => pools.getWithdrawalTokensOut(pool.pool, tokenIn));
115
- if (!tokenOut) return unroutable(tokenIn, void 0);
119
+ if (!tokenOut) return unroutable(chain, tokenIn, void 0);
116
120
  const preview = pools.simulateRedeem({
117
121
  pool: pool.pool,
118
122
  amount: params.amount,
@@ -251,24 +255,26 @@ var PrepareApi = class extends MultichainConstruct {
251
255
  /**
252
256
  * {@inheritDoc OpportunitiesPrepare.leverageBand}
253
257
  **/
254
- leverageBand(strategy, collateral) {
258
+ leverageBand(strategy, collateral, targetHF) {
255
259
  const sdk = this.sdk.chain(strategy.chainId);
256
260
  return service(sdk).leverageBand({
257
261
  sdk,
258
262
  creditManager: strategy.creditManager,
259
- collateral
263
+ collateral,
264
+ targetHF
260
265
  });
261
266
  }
262
267
  /**
263
268
  * {@inheritDoc OpportunitiesPrepare.maxWithdrawCollateral}
264
269
  **/
265
- async maxWithdrawCollateral(position, token) {
270
+ async maxWithdrawCollateral(position, token, targetHF) {
266
271
  return this.queryChain({
267
272
  network: position.chainId,
268
273
  run: async (sdk) => service(sdk).maxWithdrawCollateral({
269
274
  creditAccount: await slice(sdk, position.creditAccount),
270
275
  sdk,
271
- token
276
+ token,
277
+ targetHF
272
278
  })
273
279
  });
274
280
  }
@@ -330,10 +336,10 @@ function resumable(intent) {
330
336
  * is the usual way of it; both are present where a pair exists but nothing of
331
337
  * ours implements it.
332
338
  **/
333
- function unroutable(from, to) {
339
+ function unroutable(sdk, from, to) {
334
340
  return refuse("unsupportedTokenPair", {
335
- from,
336
- to
341
+ from: toToken(sdk, from),
342
+ to: to === void 0 ? void 0 : toToken(sdk, to)
337
343
  });
338
344
  }
339
345
  /**
@@ -1,3 +1,4 @@
1
+ import { IntentPreviewError, raise, refuse } from "../../onchain/validation/refusal.js";
1
2
  import { PrepareApi } from "./PrepareApi.js";
2
3
  import "./types.js";
3
- export { PrepareApi };
4
+ export { IntentPreviewError, PrepareApi, raise, refuse };
@@ -1 +1,2 @@
1
- export {};
1
+ import { IntentPreviewError, raise, refuse } from "../../onchain/validation/refusal.js";
2
+ export { IntentPreviewError, raise, refuse };
@@ -84,6 +84,7 @@ import { getPointsInfo } from "./utils/strategies/points/get-points-info.js";
84
84
  import { getPointsRates } from "./utils/strategies/points/get-points-rates.js";
85
85
  import { SortStrategyCMsByAvailabilityProps, SortedCMs, sortStrategyCMsByAvailability } from "./utils/strategies/sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.js";
86
86
  import { cmAvailabilityCondition } from "./utils/strategies/strategy-info/cm-availability-condition.js";
87
+ import { checkCreditManagerUsable, checkOpenAccountCeilings } from "./utils/strategies/strategy-info/credit-manager-issues.js";
87
88
  import { getCMYouCanEarn } from "./utils/strategies/strategy-info/get-cm-you-can-earn.js";
88
89
  import { getStrategyInfo } from "./utils/strategies/strategy-info/get-strategy-info.js";
89
90
  import { GetStrategyInfoCoreArgs, getStrategyInfoCore } from "./utils/strategies/strategy-info/get-strategy-info-core.js";
@@ -102,16 +103,5 @@ import { IsObtainableTokenProps, isObtainableToken } from "./utils/strategies/to
102
103
  import { isUsableToken } from "./utils/strategies/tokens/is-usable-token.js";
103
104
  import { IsValidExtraCollateralTokenProps, isValidExtraCollateralToken } from "./utils/strategies/tokens/is-valid-extra-collateral-token.js";
104
105
  import { wrapTokenAddress } from "./utils/strategies/tokens/wrap-token-address.js";
105
- import { isZeroBalance } from "./utils/validation/is-zero-balance.js";
106
- import { ValidateBalanceProps, ValidateBalanceResult, validateBalance } from "./utils/validation/validate-balance.js";
107
- import { ValidateBalancesProps, validateBalances } from "./utils/validation/validate-balances.js";
108
- import { ValidateCreditManagerProps, ValidateCreditManagerResult, validateCreditManager } from "./utils/validation/validate-credit-manager.js";
109
- import { MIN_HF_LIMITED, ValidateHFProps, ValidateHFResult, validateHF } from "./utils/validation/validate-hf.js";
110
- import { ValidateQuotaProps, ValidateQuotaResult, validateQuota } from "./utils/validation/validate-quota.js";
111
- import { ValidateOpenAccountProps, ValidateOpenAccountResult, validateOpenAccount } from "./utils/validation/validate-open-account.js";
112
- import { ValidateOpenAccountPoolQuotaStatusResult, validateOpenAccountPoolQuotaStatus } from "./utils/validation/validate-open-account-pool-quota-status.js";
113
- import { ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, validateOpenAccountPoolStatus } from "./utils/validation/validate-open-account-pool-status.js";
114
- import { ValidateTokenToObtainProps, ValidateTokenToObtainResult, validateTokenToObtain } from "./utils/validation/validate-token-to-obtain.js";
115
- import { FlattenUnion } from "./utils/validation/validation-types.js";
116
106
  import "./utils/index.js";
117
- export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, AssetUtils, AssetWithAmountInTarget, AssetWithView, AxiosCache, BONUS_APY_FROM_POINTS, BasePointsList, BestEarningsState, BigIntMath, BigNumberish, CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcMaxLendingDebtProps, CalcOverallAPYProps, CalcQuotaBorrowRateProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CalcRelativeBaseBorrowRateProps, CalculateBorrowRateSafelyProps, CalculateEarningsProps, CalculateMaxDebtProps, CalculateTotalAPYProps, CallTrace, ChartsAggregatedPoolPayload, ChartsAggregatedStats, ChartsCreditManagerData, ChartsCreditManagerPayload, ChartsPoolData, ChartsPoolDataPayload, CreditManagerDataSlice, CreditManagerSlice, CreditSession, CreditSessionAsset, CreditSessionBalancePayload, CreditSessionFiltered, CreditSessionFilteredPayload, CreditSessionPayload, CreditSessionReward, CreditSessionSortFields, CreditSessionSortType, CreditSessionStatus, CreditSessionsAggregatedStats, CreditSessionsAggregatedStatsPayload, CuratorFilter, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, FlattenUnion, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetSingleQuotaBorrowRateRate, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, GraphPayload, IconComposite, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, MIN_HF_LIMITED, NotValidatedStrategy, PointsData, PointsList, PoolConfigPayload, PoolSlice, PriceUtils, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SecondaryStatus, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyConfigPayload, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyMarketType, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TimeToLiquidationProps, TokenData, TokenDataPayload, TokenIconCompositePreset, TokenIconLayerSource, TokenMigration, TokenMigrationConfigPayload, TokenSlice, TokenTypePool, TokenTypeStrategy, TotalAPY, TradingPairConfigPayload, TradingType, UserCreditSessions, UserCreditSessionsAggregatedStatsPayload, UserCreditSessionsBuilder, UserPoolAggregatedStatsPayload, UserPoolData, UserPoolPayload, ValidateBalanceProps, ValidateBalanceResult, ValidateBalancesProps, ValidateCreditManagerProps, ValidateCreditManagerResult, ValidateHFProps, ValidateHFResult, ValidateOpenAccountPoolQuotaStatusResult, ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, ValidateOpenAccountProps, ValidateOpenAccountResult, ValidateQuotaProps, ValidateQuotaResult, ValidateTokenToObtainProps, ValidateTokenToObtainResult, WrapResult, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkDegenNFT, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, isZeroBalance, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, validateBalance, validateBalances, validateCreditManager, validateHF, validateOpenAccount, validateOpenAccountPoolQuotaStatus, validateOpenAccountPoolStatus, validateQuota, validateTokenToObtain, wrapTokenAddress };
107
+ export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, AssetUtils, AssetWithAmountInTarget, AssetWithView, AxiosCache, BONUS_APY_FROM_POINTS, BasePointsList, BestEarningsState, BigIntMath, BigNumberish, CREDIT_SESSION_ID_BY_STATUS, CREDIT_SESSION_STATUS_BY_ID, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcMaxLendingDebtProps, CalcOverallAPYProps, CalcQuotaBorrowRateProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CalcRelativeBaseBorrowRateProps, CalculateBorrowRateSafelyProps, CalculateEarningsProps, CalculateMaxDebtProps, CalculateTotalAPYProps, CallTrace, ChartsAggregatedPoolPayload, ChartsAggregatedStats, ChartsCreditManagerData, ChartsCreditManagerPayload, ChartsPoolData, ChartsPoolDataPayload, CreditManagerDataSlice, CreditManagerSlice, CreditSession, CreditSessionAsset, CreditSessionBalancePayload, CreditSessionFiltered, CreditSessionFilteredPayload, CreditSessionPayload, CreditSessionReward, CreditSessionSortFields, CreditSessionSortType, CreditSessionStatus, CreditSessionsAggregatedStats, CreditSessionsAggregatedStatsPayload, CuratorFilter, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetSingleQuotaBorrowRateRate, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, GraphPayload, IconComposite, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, NotValidatedStrategy, PointsData, PointsList, PoolConfigPayload, PoolSlice, PriceUtils, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SecondaryStatus, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyConfigPayload, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyMarketType, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TimeToLiquidationProps, TokenData, TokenDataPayload, TokenIconCompositePreset, TokenIconLayerSource, TokenMigration, TokenMigrationConfigPayload, TokenSlice, TokenTypePool, TokenTypeStrategy, TotalAPY, TradingPairConfigPayload, TradingType, UserCreditSessions, UserCreditSessionsAggregatedStatsPayload, UserCreditSessionsBuilder, UserPoolAggregatedStatsPayload, UserPoolData, UserPoolPayload, WrapResult, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkCreditManagerUsable, checkDegenNFT, checkOpenAccountCeilings, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, wrapTokenAddress };
@@ -70,6 +70,7 @@ import { getPointsInfo } from "./strategies/points/get-points-info.js";
70
70
  import { getPointsRates } from "./strategies/points/get-points-rates.js";
71
71
  import { SortStrategyCMsByAvailabilityProps, SortedCMs, sortStrategyCMsByAvailability } from "./strategies/sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.js";
72
72
  import { cmAvailabilityCondition } from "./strategies/strategy-info/cm-availability-condition.js";
73
+ import { checkCreditManagerUsable, checkOpenAccountCeilings } from "./strategies/strategy-info/credit-manager-issues.js";
73
74
  import { getCMYouCanEarn } from "./strategies/strategy-info/get-cm-you-can-earn.js";
74
75
  import { getStrategyInfo } from "./strategies/strategy-info/get-strategy-info.js";
75
76
  import { GetStrategyInfoCoreArgs, getStrategyInfoCore } from "./strategies/strategy-info/get-strategy-info-core.js";
@@ -89,16 +90,4 @@ import { isUsableToken } from "./strategies/tokens/is-usable-token.js";
89
90
  import { IsValidExtraCollateralTokenProps, isValidExtraCollateralToken } from "./strategies/tokens/is-valid-extra-collateral-token.js";
90
91
  import { wrapTokenAddress } from "./strategies/tokens/wrap-token-address.js";
91
92
  import "./strategies/index.js";
92
- import { isZeroBalance } from "./validation/is-zero-balance.js";
93
- import { ValidateBalanceProps, ValidateBalanceResult, validateBalance } from "./validation/validate-balance.js";
94
- import { ValidateBalancesProps, validateBalances } from "./validation/validate-balances.js";
95
- import { ValidateCreditManagerProps, ValidateCreditManagerResult, validateCreditManager } from "./validation/validate-credit-manager.js";
96
- import { MIN_HF_LIMITED, ValidateHFProps, ValidateHFResult, validateHF } from "./validation/validate-hf.js";
97
- import { ValidateQuotaProps, ValidateQuotaResult, validateQuota } from "./validation/validate-quota.js";
98
- import { ValidateOpenAccountProps, ValidateOpenAccountResult, validateOpenAccount } from "./validation/validate-open-account.js";
99
- import { ValidateOpenAccountPoolQuotaStatusResult, validateOpenAccountPoolQuotaStatus } from "./validation/validate-open-account-pool-quota-status.js";
100
- import { ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, validateOpenAccountPoolStatus } from "./validation/validate-open-account-pool-status.js";
101
- import { ValidateTokenToObtainProps, ValidateTokenToObtainResult, validateTokenToObtain } from "./validation/validate-token-to-obtain.js";
102
- import { FlattenUnion } from "./validation/validation-types.js";
103
- import "./validation/index.js";
104
- export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, AssetUtils, AssetWithAmountInTarget, AssetWithView, BONUS_APY_FROM_POINTS, BasePointsList, BestEarningsState, BigIntMath, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcMaxLendingDebtProps, CalcOverallAPYProps, CalcQuotaBorrowRateProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CalcRelativeBaseBorrowRateProps, CalculateBorrowRateSafelyProps, CalculateEarningsProps, CalculateMaxDebtProps, CalculateTotalAPYProps, CallTrace, CreditManagerDataSlice, CreditManagerSlice, CuratorFilter, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, FlattenUnion, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetSingleQuotaBorrowRateRate, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, MIN_HF_LIMITED, NotValidatedStrategy, PointsData, PointsList, PoolSlice, PriceUtils, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TimeToLiquidationProps, TokenSlice, TotalAPY, ValidateBalanceProps, ValidateBalanceResult, ValidateBalancesProps, ValidateCreditManagerProps, ValidateCreditManagerResult, ValidateHFProps, ValidateHFResult, ValidateOpenAccountPoolQuotaStatusResult, ValidateOpenAccountPoolStatusProps, ValidateOpenAccountPoolStatusResult, ValidateOpenAccountProps, ValidateOpenAccountResult, ValidateQuotaProps, ValidateQuotaResult, ValidateTokenToObtainProps, ValidateTokenToObtainResult, WrapResult, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkDegenNFT, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, isZeroBalance, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, validateBalance, validateBalances, validateCreditManager, validateHF, validateOpenAccount, validateOpenAccountPoolQuotaStatus, validateOpenAccountPoolStatus, validateQuota, validateTokenToObtain, wrapTokenAddress };
93
+ export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, AssetUtils, AssetWithAmountInTarget, AssetWithView, BONUS_APY_FROM_POINTS, BasePointsList, BestEarningsState, BigIntMath, CalcDefaultQuotaProps, CalcHealthFactorProps, CalcMaxLendingDebtProps, CalcOverallAPYProps, CalcQuotaBorrowRateProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, CalcRelativeBaseBorrowRateProps, CalculateBorrowRateSafelyProps, CalculateEarningsProps, CalculateMaxDebtProps, CalculateTotalAPYProps, CallTrace, CreditManagerDataSlice, CreditManagerSlice, CuratorFilter, EMPTY_ADDRESS, EMPTY_ARRAY, EMPTY_OBJECT, EXECUTE_BYTES_SELECTOR, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetSingleQuotaBorrowRateRate, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, NotValidatedStrategy, PointsData, PointsList, PoolSlice, PriceUtils, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TimeToLiquidationProps, TokenSlice, TotalAPY, WrapResult, addAmountInTarget, amountAbcComparator, assetComparator, calcDefaultQuota, calcHealthFactor, calcMaxDebtIncrease, calcMaxLendingDebt, calcOverallAPY, calcQuotaBorrowRate, calcQuotaUpdate, calcRecommendedQuota, calcRelativeBaseBorrowRate, calculateBorrowRateFromUtilization, calculateEarnings, calculateEffectiveBorrowRate, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateSafeBorrowRate, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkCreditManagerUsable, checkDegenNFT, checkOpenAccountCeilings, cmAvailabilityCondition, collectTraces, createLegacyStrategyDataSource, findCallTo, findCallWithInput, findExecuteBytes, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexAPYList, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRateWithFee, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getSafeBaseBorrowRate, getSingleQuotaBorrowRate, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getTimeToLiquidation, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, liquidationPrice, maxAPYFormula, maxLeverage, maxLeverageThreshold, resolveProtocolCall, roundUpQuota, sortAssets, sortBalances, sortStrategyCMsByAvailability, tokensAbcComparator, wrapTokenAddress };
@@ -53,6 +53,7 @@ import "./points/index.js";
53
53
  import { SortStrategyCMsByAvailabilityProps, SortedCMs, sortStrategyCMsByAvailability } from "./sort-strategy-cms-by-availability/sort-strategy-cms-by-availability.js";
54
54
  import "./sort-strategy-cms-by-availability/index.js";
55
55
  import { cmAvailabilityCondition } from "./strategy-info/cm-availability-condition.js";
56
+ import { checkCreditManagerUsable, checkOpenAccountCeilings } from "./strategy-info/credit-manager-issues.js";
56
57
  import { getCMYouCanEarn } from "./strategy-info/get-cm-you-can-earn.js";
57
58
  import { getStrategyInfo } from "./strategy-info/get-strategy-info.js";
58
59
  import { GetStrategyInfoCoreArgs, getStrategyInfoCore } from "./strategy-info/get-strategy-info-core.js";
@@ -74,4 +75,4 @@ import { isUsableToken } from "./tokens/is-usable-token.js";
74
75
  import { IsValidExtraCollateralTokenProps, isValidExtraCollateralToken } from "./tokens/is-valid-extra-collateral-token.js";
75
76
  import { wrapTokenAddress } from "./tokens/wrap-token-address.js";
76
77
  import "./tokens/index.js";
77
- export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, BasePointsList, BestEarningsState, CalculateMaxDebtProps, CalculateTotalAPYProps, CreditManagerDataSlice, CreditManagerSlice, CuratorFilter, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, NotValidatedStrategy, PointsData, PointsList, PoolSlice, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TokenSlice, TotalAPY, addAmountInTarget, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkDegenNFT, cmAvailabilityCondition, createLegacyStrategyDataSource, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, maxLeverage, maxLeverageThreshold, sortStrategyCMsByAvailability, wrapTokenAddress };
78
+ export { APYList, APYListByNetwork, APYListSlice, AddAmountInTargetProps, AppChains, BasePointsList, BestEarningsState, CalculateMaxDebtProps, CalculateTotalAPYProps, CreditManagerDataSlice, CreditManagerSlice, CuratorFilter, EarningsList, ExtraCollateralConfig, ExtraCollateralPointsList, ExtraCollaterals, GearboxSDKFullState, GearboxSDKFullStateByChain, GetCMAllowedCollateralsProps, GetRecommendedDebtProps, GetReleasedStrategiesListCoreArgs, GetStrategyCreditManagersListCoreArgs, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, GetStrategyPointsProps, GetWalletBalancesAllowedOnCMProps, IsCollateralTokenProps, IsObtainableTokenProps, IsTargetableProps, IsValidExtraCollateralTokenProps, LeverageFactor, LinearModel, LocalDebtReward, LocalPointsInfo, LocalPointsReward, NotValidatedStrategy, PointsData, PointsList, PoolSlice, PricesByChainSlice, PricesRecord, QuotaSlice, RST_ETH_ADDRESS, SortStrategyCMsByAvailabilityProps, SortedCMs, StrategiesCMListByChain, Strategy, StrategyCMEarningsInfo, StrategyCreditManagerLike, StrategyCreditManagerView, StrategyDataSource, StrategyEarningsListByChain, StrategyInfoLike, StrategyInfoResult, StrategyLike, StrategyPointsResult, StrategyPoolView, StrategyRecord, StrategySlice, StrategyTokenView, TokenSlice, TotalAPY, addAmountInTarget, calculateLossCoefficient, calculateMaxLeverageFactor, calculateMaxStrategyDebt, calculateTotalAPY, calculateTotalPoints, checkBoolean, checkCreditManagerUsable, checkDegenNFT, checkOpenAccountCeilings, cmAvailabilityCondition, createLegacyStrategyDataSource, getAvailableAndDisabledStrategies, getCMAllowedCollaterals, getCMYouCanEarn, getChainPhantomTokens, getCollateralByDebt, getComplexPointsList, getDefaultAsset, getFactorFromLeverage, getLeverageFromFactor, getListWithAmountInTarget, getNativeTokenAddress, getPointsInfo, getPointsRates, getRecommendedDebt, getRecommendedLeverageFactor, getReleasedStrategiesList, getReleasedStrategiesListCore, getStrategyCreditManagers, getStrategyCreditManagersList, getStrategyCreditManagersListCore, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyPoints, getStrategyYouCanEarn, getWalletBalancesAllowedOnCM, isActivatedToken, isApyWithPointsException, isCollateralToken, isCreditManagerUsable, isForbiddenToken, isObtainableToken, isStrategyCMDisabled, isStrategyDisabled, isStrategyEligible, isStrategyReleased, isUsableToken, isValidExtraCollateralToken, maxLeverage, maxLeverageThreshold, sortStrategyCMsByAvailability, wrapTokenAddress };
@@ -0,0 +1,34 @@
1
+ import { Asset } from "../../../../onchain/base/types.js";
2
+ import { PreviewIssue } from "../../../../onchain/validation/refusal.js";
3
+ import { CreditManagerSlice, PoolSlice } from "./types.js";
4
+ import "../../../../onchain/index.js";
5
+ import { Address } from "viem";
6
+ //#region src/common-utils/utils/strategies/strategy-info/credit-manager-issues.d.ts
7
+ /**
8
+ * The debt ceilings an account opening runs into, in the order a form reports
9
+ * them. The minimum debt is what is weighed — asking for less does not make it
10
+ * fit.
11
+ */
12
+ declare function checkOpenAccountCeilings(args: {
13
+ creditManager: Pick<CreditManagerSlice, "minDebt" | "totalDebtLimit" | "totalDebt" | "availableToBorrow" | "quotas" | "underlyingToken" | "chainId">;
14
+ pool: Pick<PoolSlice, "totalDebtLimit" | "totalBorrowed"> | undefined | null;
15
+ debt: bigint;
16
+ targetToken: Address | null;
17
+ }): PreviewIssue | null;
18
+ /** Everything the lists weigh before calling a manager usable, in their order. */
19
+ declare function checkCreditManagerUsable(args: {
20
+ creditManager: CreditManagerSlice;
21
+ pool: PoolSlice | undefined;
22
+ debt: bigint;
23
+ healthFactor: number | undefined;
24
+ targetToken: Address | null;
25
+ /** What the account would obtain, refused outright if the market forbids it. */
26
+ tokenToObtain: Address | null;
27
+ /** What the wallet puts in, against the balances it holds. */
28
+ collateral: readonly Asset[];
29
+ balances: Record<Address, bigint>;
30
+ desiredQuota: Record<Address, Asset>;
31
+ quotaUpdate: readonly Asset[];
32
+ }): PreviewIssue | null;
33
+ //#endregion
34
+ export { checkCreditManagerUsable, checkOpenAccountCeilings };
@@ -2,10 +2,11 @@ import { CalculateTotalAPYProps, TotalAPY, calculateTotalAPY } from "./calculate
2
2
  import { PointsData, calculateTotalPoints } from "./calculate-total-points.js";
3
3
  import { APYListSlice, CreditManagerSlice, GetStrategyInfoArgs, LinearModel, PoolSlice, PricesByChainSlice, QuotaSlice, StrategyInfoResult, StrategySlice, TokenSlice } from "./types.js";
4
4
  import { cmAvailabilityCondition } from "./cm-availability-condition.js";
5
+ import { checkCreditManagerUsable, checkOpenAccountCeilings } from "./credit-manager-issues.js";
5
6
  import { getCMYouCanEarn } from "./get-cm-you-can-earn.js";
6
7
  import { getStrategyInfo } from "./get-strategy-info.js";
7
8
  import { GetStrategyInfoCoreArgs, getStrategyInfoCore } from "./get-strategy-info-core.js";
8
9
  import { getStrategyMaxAPY } from "./get-strategy-max-apy.js";
9
10
  import { getStrategyYouCanEarn } from "./get-strategy-you-can-earn.js";
10
11
  import { isStrategyCMDisabled } from "./is-strategy-cm-disabled.js";
11
- export { APYListSlice, CalculateTotalAPYProps, CreditManagerSlice, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, LinearModel, PointsData, PoolSlice, PricesByChainSlice, QuotaSlice, StrategyInfoResult, StrategySlice, TokenSlice, TotalAPY, calculateTotalAPY, calculateTotalPoints, cmAvailabilityCondition, getCMYouCanEarn, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyYouCanEarn, isStrategyCMDisabled };
12
+ export { APYListSlice, CalculateTotalAPYProps, CreditManagerSlice, GetStrategyInfoArgs, GetStrategyInfoCoreArgs, LinearModel, PointsData, PoolSlice, PricesByChainSlice, QuotaSlice, StrategyInfoResult, StrategySlice, TokenSlice, TotalAPY, calculateTotalAPY, calculateTotalPoints, checkCreditManagerUsable, checkOpenAccountCeilings, cmAvailabilityCondition, getCMYouCanEarn, getStrategyInfo, getStrategyInfoCore, getStrategyMaxAPY, getStrategyYouCanEarn, isStrategyCMDisabled };
@@ -145,6 +145,17 @@ interface OpenCreditAccountPreview {
145
145
  * @example `12500` for a health factor of 1.25
146
146
  **/
147
147
  healthFactor: Bps;
148
+ /**
149
+ * The same factor with collateral valued at safe prices — the lower of each
150
+ * token's main and reserve oracle feeds, which is what the credit manager
151
+ * switches to for a call that hands funds over.
152
+ *
153
+ * Always reported, so a caller that needs the stricter reading does not have
154
+ * to recompute it; whether to hold the account to it is the caller's call.
155
+ *
156
+ * @example `11800` where `healthFactor` is `12500`
157
+ **/
158
+ safeHealthFactor: Bps;
148
159
  /**
149
160
  * Cost of the debt, broken down by source.
150
161
  **/
@@ -229,6 +240,17 @@ interface AdjustCreditAccountPreview {
229
240
  * @example `12500` for a health factor of 1.25
230
241
  **/
231
242
  healthFactor: Bps;
243
+ /**
244
+ * The same factor with collateral valued at safe prices — the lower of each
245
+ * token's main and reserve oracle feeds, which is what the credit manager
246
+ * switches to for a call that hands funds over.
247
+ *
248
+ * Always reported, so a caller that needs the stricter reading does not have
249
+ * to recompute it; whether to hold the account to it is the caller's call.
250
+ *
251
+ * @example `11800` where `healthFactor` is `12500`
252
+ **/
253
+ safeHealthFactor: Bps;
232
254
  /**
233
255
  * Cost of the debt, broken down by source.
234
256
  **/
@@ -20,9 +20,9 @@ import { AccountBotsService } from "./bots/AccountBotsService.js";
20
20
  import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
21
21
  import "./bots/index.js";
22
22
  import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
23
+ import { borrowable } from "./intents/guards.js";
23
24
  import { LeverageBand } from "./intents/leverage-band.js";
24
25
  import { AccountCalculatorOperation } from "./intents/operations.js";
25
- import { IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewRefusal, refuse } from "./intents/refusal.js";
26
26
  import { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./intents/types.js";
27
27
  import { OpenStrategyPreview, OpenStrategyProps } from "./intents/open-strategy.js";
28
28
  import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
@@ -32,4 +32,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
32
32
  import { LiquidationsService } from "./liquidations/LiquidationsService.js";
33
33
  import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
34
34
  import "./liquidations/index.js";
35
- export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, IntentPreviewError, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, type PreviewErrorDetails, type PreviewErrorReason, type PreviewRefusal, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteRefusals, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, refuse, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
35
+ export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, ClaimFarmRewardsProps, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetPendingWithdrawalsProps, GetPendingWithdrawalsResult, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteRefusals, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, borrowable, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
@@ -2,6 +2,7 @@ import { Asset } from "../../base/types.js";
2
2
  import { MarketSuite } from "../../market/MarketSuite.js";
3
3
  import { CreditSuite } from "../../market/credit/CreditSuite.js";
4
4
  import { OnchainSDK } from "../../OnchainSDK.js";
5
+ import { BorrowLimitBinding } from "../../validation/refusal.js";
5
6
  import "../../index.js";
6
7
  //#region src/onchain/accounts/intents/guards.d.ts
7
8
  /**
@@ -29,9 +30,12 @@ declare function assertMarketOperable(suite: CreditSuite): void;
29
30
  * facade puts on a single borrow. A zero multiplier switches borrowing off
30
31
  * outright, which reads here as nothing being available.
31
32
  */
32
- declare function borrowable(suite: CreditSuite): bigint;
33
+ declare function borrowable(suite: CreditSuite): {
34
+ limit: bigint;
35
+ binding: BorrowLimitBinding;
36
+ };
33
37
  /** The pool has to be able to lend what the plan means to draw. */
34
- declare function assertCanBorrow(suite: CreditSuite, amount: bigint): void;
38
+ declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bigint): void;
35
39
  /**
36
40
  * What the account is allowed to end up holding more of than it started with.
37
41
  *
@@ -63,7 +67,7 @@ declare function assertGrowthAllowed(args: {
63
67
  * - here, `1.0` — what the facade enforces, so what a plan must clear to land;
64
68
  * - `maxWithdrawCollateral` sizes at `MIN_HF_LIMITED + 2` — a *sizing* helper
65
69
  * leaving headroom, which is not the same as a validity check;
66
- * - `validateHF` refuses at or below `MIN_HF_LIMITED` — a form's own caution.
70
+ * - a form refuses at or below `MIN_HF_LIMITED` (`MIN_HEALTH_FACTOR_FORM`).
67
71
  *
68
72
  * Raising this one to `MIN_HF_LIMITED` was tried and reverted: it made
69
73
  * `maxWithdraw` hand back a ceiling this guard then refused, and it blocked
@@ -85,6 +89,6 @@ declare function assertCollateralised(healthFactorBps: number, safePrices: boole
85
89
  * A quota can only be raised as far as the market still has room for: past the
86
90
  * token's limit the keeper takes nothing more, whoever is asking.
87
91
  */
88
- declare function assertQuotaHeadroom(market: MarketSuite, increases: readonly Asset[]): void;
92
+ declare function assertQuotaHeadroom(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
89
93
  //#endregion
90
94
  export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaHeadroom, borrowable };
@@ -1,7 +1,8 @@
1
1
  import { SDKConstruct } from "../../base/SDKConstruct.js";
2
+ import { PreviewRefusal } from "../../validation/refusal.js";
3
+ import { borrowable } from "./guards.js";
2
4
  import { LeverageBand, LeverageBandProps } from "./leverage-band.js";
3
5
  import { AccountCalculatorOperation } from "./operations.js";
4
- import { IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewRefusal, refuse } from "./refusal.js";
5
6
  import { AddCollateralIntent, AdjustLeverageIntent, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawStrategyIntent } from "./types.js";
6
7
  import { OpenStrategyPreview, OpenStrategyProps } from "./open-strategy.js";
7
8
  import { fetchCreditAccountSlice, toCreditAccountSlice } from "./utils/credit-account-slice.js";
@@ -46,6 +47,10 @@ declare class CreditAccountOperationsService extends SDKConstruct {
46
47
  * withdraw form should offer. Taking everything out is the same intent with
47
48
  * `MAX_UINT256` for an amount, and needs none of this arithmetic.
48
49
  *
50
+ * Takes no target health factor, unlike {@link maxWithdrawCollateral}: a
51
+ * proportional withdrawal leaves the factor where it found it, and the
52
+ * facade's `minDebt` is what bounds it.
53
+ *
49
54
  * @param props - Account slice and the SDK holding its market
50
55
  * @returns Amount in underlying units; `0n` when nothing can leave
51
56
  */
@@ -76,24 +81,29 @@ declare class CreditAccountOperationsService extends SDKConstruct {
76
81
  * yet, and adjusting measures against the net value the caller already
77
82
  * holds. Nothing is fetched, so a form can ask on every keystroke.
78
83
  *
79
- * @param props - The manager, the SDK holding its market, and what stands
80
- * behind the position
84
+ * @param props - The manager, the SDK holding its market, what stands
85
+ * behind the position, and optionally the health factor the ceiling should
86
+ * leave
81
87
  * @returns The band, or nothing when the market has none to offer
82
88
  */
83
89
  leverageBand(props: LeverageBandProps): LeverageBand | undefined;
84
90
  /**
85
91
  * Largest `WITHDRAW_ASSET` amount of one token the account can take out
86
- * while its health factor stays at {@link MIN_HF_LIMITED} plus a basis
87
- * point — the ceiling a withdraw-collateral form should offer. Thresholds,
88
- * prices and quota activity come from the account's market, valued the way
89
- * the facade values a call that pays out; zero debt frees the whole balance.
92
+ * while its health factor stays at `targetHF` the ceiling a
93
+ * withdraw-collateral form should offer. Thresholds, prices and quota
94
+ * activity come from the account's market, valued the way the facade values
95
+ * a call that pays out; zero debt frees the whole balance.
96
+ *
97
+ * The default is {@link MIN_HF_LIMITED}, the bar a form holds an
98
+ * account to.
90
99
  *
91
- * @param props - Account slice, the SDK holding its market, and the
92
- * collateral to withdraw
100
+ * @param props - Account slice, the SDK holding its market, the collateral
101
+ * to withdraw, and optionally the health factor to leave behind
93
102
  * @returns Amount in the token's units; `0n` when nothing can leave
94
103
  */
95
104
  maxWithdrawCollateral(props: Pick<StartIntentProps, "creditAccount" | "sdk"> & {
96
105
  token: Address;
106
+ targetHF?: bigint;
97
107
  }): bigint;
98
108
  /**
99
109
  * Previews the same operation when its source only redeems through its
@@ -172,4 +182,4 @@ declare class CreditAccountOperationsService extends SDKConstruct {
172
182
  openStrategyIntent(props: OpenStrategyProps): Promise<OpenStrategyPreviewResult>;
173
183
  }
174
184
  //#endregion
175
- export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type InstantRoute, IntentPreviewError, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, type OperationState, type PathLossRate, type PreviewErrorDetails, type PreviewErrorReason, type PreviewRefusal, type RepayStrategyIntent, type ResumableIntent, type RouteRefusals, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, fetchCreditAccountSlice, refuse, toCreditAccountSlice };
185
+ export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, type OpenStrategyPreview, OpenStrategyPreviewResult, type OpenStrategyProps, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type RouteRefusals, type StartIntent, type WithdrawAssetIntent, type WithdrawStrategyIntent, borrowable, fetchCreditAccountSlice, toCreditAccountSlice };
@@ -1,4 +1,4 @@
1
- import { Leverage } from "../../../model/primitives.js";
1
+ import { Bps, Leverage } from "../../../model/primitives.js";
2
2
  import "../../../model/index.js";
3
3
  import { Asset } from "../../base/types.js";
4
4
  import { OnchainSDK } from "../../OnchainSDK.js";
@@ -20,6 +20,11 @@ interface LeverageBandProps {
20
20
  * underlying here, so a caller hands over amounts and no exchange rates.
21
21
  **/
22
22
  readonly collateral: readonly Asset[];
23
+ /**
24
+ * Health factor the maxed leverage should leave the position at, in basis
25
+ * points. Omitted keeps `calcMaxLeverage` on its flat buffer.
26
+ **/
27
+ readonly targetHF?: Bps;
23
28
  }
24
29
  /**
25
30
  * The leverages this market will actually fund for a position of this size.
@@ -48,6 +53,6 @@ interface LeverageBandProps {
48
53
  * calcLeverageBand({ sdk, creditManager, collateral }) // { min: 1.1, max: 9 }
49
54
  * ```
50
55
  **/
51
- declare function calcLeverageBand({ sdk, creditManager, collateral }: LeverageBandProps): LeverageBand | undefined;
56
+ declare function calcLeverageBand({ sdk, creditManager, collateral, targetHF }: LeverageBandProps): LeverageBand | undefined;
52
57
  //#endregion
53
58
  export { LeverageBand, LeverageBandProps, calcLeverageBand };
@@ -1,3 +1,4 @@
1
+ import { OnchainSDK } from "../../OnchainSDK.js";
1
2
  import { Address } from "viem";
2
3
  //#region src/onchain/accounts/intents/math.d.ts
3
4
  /**
@@ -42,6 +43,6 @@ declare function assertLeverageAtLeastOne(leverage: bigint): void;
42
43
  * Rejects a debt the facade would revert on: zero is always fine (no loan at
43
44
  * all), anything else has to sit inside `[minDebt, maxDebt]`.
44
45
  */
45
- declare function assertDebtInBand(debt: bigint, band: DebtBand, underlying: Address): void;
46
+ declare function assertDebtInBand(sdk: OnchainSDK, debt: bigint, band: DebtBand, underlying: Address): void;
46
47
  //#endregion
47
48
  export { DebtBand, Position, assertDebtInBand, assertLeverageAtLeastOne, debtForLeverage, maxProportionalWithdrawal, proportionalDebt };
@@ -1,6 +1,7 @@
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 { OnchainSDK } from "../../OnchainSDK.js";
4
5
  import { AddCollateralIntent, AdjustLeverageIntent, DepositStrategyIntent, RepayStrategyIntent, WithdrawAssetIntent, WithdrawStrategyIntent } from "./types.js";
5
6
  import { DebtBand } from "./math.js";
6
7
  import { Address } from "viem";
@@ -100,6 +101,8 @@ type Step = {
100
101
  /** What a planner is allowed to know about the account. */
101
102
  interface AccountView {
102
103
  underlying: Address;
104
+ /** The attached SDK, for the guards that inline a token into a refusal. */
105
+ sdk: OnchainSDK;
103
106
  /** Raw asset of an RWA market (e.g. USDC behind dcUSDC); undefined otherwise. */
104
107
  rwaAsset: Address | undefined;
105
108
  debt: bigint;
@@ -7,8 +7,8 @@ import { Asset } from "../../base/types.js";
7
7
  import { RouterCASlice } from "../../router/types.js";
8
8
  import { MultiCall } from "../../types/transactions.js";
9
9
  import { OnchainSDK } from "../../OnchainSDK.js";
10
+ import { PreviewErrorReason, PreviewRefusal } from "../../validation/refusal.js";
10
11
  import { AccountCalculatorOperation } from "./operations.js";
11
- import { PreviewErrorReason, PreviewRefusal } from "./refusal.js";
12
12
  import "../../index.js";
13
13
  import { Address } from "viem";
14
14
  //#region src/onchain/accounts/intents/types.d.ts
@@ -40,6 +40,12 @@ interface OperationState {
40
40
  * @example `12500` for a health factor of 1.25
41
41
  **/
42
42
  healthFactor: Bps;
43
+ /**
44
+ * The same factor with collateral valued at safe prices, present only where
45
+ * the walk had reason to compute it — a call that hands funds over, which is
46
+ * the one the credit manager weighs at safe prices on-chain.
47
+ **/
48
+ safeHealthFactor?: Bps;
43
49
  /**
44
50
  * Cost of the debt, broken down by source.
45
51
  **/
@@ -1,8 +1,8 @@
1
1
  import { 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_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./address-provider.js";
2
2
  import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./addresses.js";
3
3
  import { BotPermissions, botPermissionsToString } from "./bot-permissions.js";
4
- import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY } from "./math.js";
4
+ import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance } from "./math.js";
5
5
  import { BLOCKS_PER_WEEK_BY_NETWORK, RAMP_DURATION_BY_NETWORK } from "./networks.js";
6
6
  import { PERIPHERY_CONTRACTS, PeripheryContract } from "./periphery.js";
7
7
  import { VERSION_RANGE_310, VersionRange, isV310, isVersionRange } from "./versions.js";
8
- 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_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, PeripheryContract, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, VersionRange, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange };
8
+ 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_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, PeripheryContract, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, VersionRange, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange, isZeroBalance };
@@ -20,5 +20,13 @@ declare const SLIPPAGE_DECIMALS = 100n;
20
20
  * Token balances at or below this threshold are treated as dust and ignored.
21
21
  **/
22
22
  declare const DUST_THRESHOLD = 10n;
23
+ /**
24
+ * Whether a balance is nothing worth acting on.
25
+ *
26
+ * The threshold is a dust floor, not a zero test: rounding leaves amounts that
27
+ * are technically non-zero and worthless, and a form that offered to spend one
28
+ * would build a transaction nobody wants.
29
+ */
30
+ declare function isZeroBalance(balance: bigint | undefined): boolean;
23
31
  //#endregion
24
- export { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY };
32
+ export { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance };