@gearbox-protocol/sdk 16.0.0-next.18 → 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 (186) 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 +7 -8
  12. package/dist/cjs/onchain/accounts/intents/math.js +15 -22
  13. package/dist/cjs/onchain/accounts/intents/open-strategy.js +5 -5
  14. package/dist/cjs/onchain/accounts/intents/plan.js +27 -41
  15. package/dist/cjs/onchain/accounts/intents/realize.js +14 -21
  16. package/dist/cjs/onchain/accounts/intents/tail.js +2 -2
  17. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  18. package/dist/cjs/onchain/accounts/intents/view.js +1 -0
  19. package/dist/cjs/onchain/constants/index.js +1 -0
  20. package/dist/cjs/onchain/constants/math.js +11 -0
  21. package/dist/cjs/onchain/index.js +32 -3
  22. package/dist/cjs/onchain/validation/checks.js +250 -0
  23. package/dist/cjs/onchain/validation/index.js +29 -0
  24. package/dist/cjs/onchain/{accounts/intents → validation}/refusal.js +12 -1
  25. package/dist/cjs/onchain/validation/token.js +29 -0
  26. package/dist/cjs/preview/index.js +10 -0
  27. package/dist/cjs/preview/preview/buildDelayedPreview.js +1 -0
  28. package/dist/cjs/preview/preview/previewAdjustCreditAccount.js +1 -0
  29. package/dist/cjs/preview/preview/previewOpenCreditAccount.js +1 -0
  30. package/dist/cjs/preview/validate/checkOperation.js +173 -0
  31. package/dist/cjs/preview/validate/checkSimulation.js +52 -0
  32. package/dist/cjs/preview/validate/index.js +6 -0
  33. package/dist/cjs/sdk/index.js +4 -0
  34. package/dist/cjs/sdk/prepare/PrepareApi.js +17 -13
  35. package/dist/cjs/sdk/prepare/index.js +4 -0
  36. package/dist/cjs/sdk/prepare/types.js +4 -0
  37. package/dist/esm/common-utils/index.js +2 -11
  38. package/dist/esm/common-utils/test-utils/index.js +4 -3
  39. package/dist/esm/common-utils/utils/index.js +2 -12
  40. package/dist/esm/common-utils/utils/strategies/index.js +2 -1
  41. package/dist/esm/common-utils/utils/strategies/strategy-info/cm-availability-condition.js +5 -5
  42. package/dist/esm/common-utils/utils/strategies/strategy-info/credit-manager-issues.js +133 -0
  43. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.js +12 -23
  44. package/dist/esm/common-utils/utils/strategies/strategy-info/index.js +2 -1
  45. package/dist/esm/dev/AccountOpener.js +1 -1
  46. package/dist/esm/dev/withdrawalUtils.js +1 -1
  47. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  48. package/dist/esm/onchain/accounts/index.js +2 -2
  49. package/dist/esm/onchain/accounts/intents/guards.js +55 -50
  50. package/dist/esm/onchain/accounts/intents/index.js +5 -5
  51. package/dist/esm/onchain/accounts/intents/math.js +14 -21
  52. package/dist/esm/onchain/accounts/intents/open-strategy.js +4 -4
  53. package/dist/esm/onchain/accounts/intents/plan.js +15 -29
  54. package/dist/esm/onchain/accounts/intents/realize.js +12 -19
  55. package/dist/esm/onchain/accounts/intents/tail.js +1 -1
  56. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
  57. package/dist/esm/onchain/accounts/intents/view.js +1 -0
  58. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
  59. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  60. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  61. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  62. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  63. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  64. package/dist/esm/onchain/chain/detectNetwork.js +1 -1
  65. package/dist/esm/onchain/constants/index.js +2 -2
  66. package/dist/esm/onchain/constants/math.js +11 -1
  67. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  68. package/dist/esm/onchain/index.js +7 -3
  69. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  70. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  71. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  72. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  73. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  74. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  75. package/dist/esm/onchain/pools/PoolService.js +1 -1
  76. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  77. package/dist/esm/onchain/validation/checks.js +230 -0
  78. package/dist/esm/onchain/validation/index.js +4 -0
  79. package/dist/esm/onchain/{accounts/intents → validation}/refusal.js +12 -2
  80. package/dist/esm/onchain/validation/token.js +27 -0
  81. package/dist/esm/preview/index.js +5 -1
  82. package/dist/esm/preview/preview/buildDelayedPreview.js +1 -0
  83. package/dist/esm/preview/preview/previewAdjustCreditAccount.js +1 -0
  84. package/dist/esm/preview/preview/previewOpenCreditAccount.js +1 -0
  85. package/dist/esm/preview/simulate/simulatePoolOperation.js +1 -1
  86. package/dist/esm/preview/trace/extractTransfers.js +1 -1
  87. package/dist/esm/preview/validate/checkOperation.js +171 -0
  88. package/dist/esm/preview/validate/checkSimulation.js +51 -0
  89. package/dist/esm/preview/validate/index.js +3 -0
  90. package/dist/esm/sdk/index.js +2 -1
  91. package/dist/esm/sdk/prepare/PrepareApi.js +15 -11
  92. package/dist/esm/sdk/prepare/index.js +2 -1
  93. package/dist/esm/sdk/prepare/types.js +2 -1
  94. package/dist/types/common-utils/index.d.ts +2 -12
  95. package/dist/types/common-utils/utils/index.d.ts +2 -13
  96. package/dist/types/common-utils/utils/strategies/index.d.ts +2 -1
  97. package/dist/types/common-utils/utils/strategies/strategy-info/credit-manager-issues.d.ts +34 -0
  98. package/dist/types/common-utils/utils/strategies/strategy-info/index.d.ts +2 -1
  99. package/dist/types/model/previews.d.ts +22 -0
  100. package/dist/types/onchain/accounts/index.d.ts +2 -2
  101. package/dist/types/onchain/accounts/intents/guards.d.ts +8 -4
  102. package/dist/types/onchain/accounts/intents/index.d.ts +4 -3
  103. package/dist/types/onchain/accounts/intents/math.d.ts +2 -1
  104. package/dist/types/onchain/accounts/intents/plan.d.ts +3 -0
  105. package/dist/types/onchain/accounts/intents/types.d.ts +7 -1
  106. package/dist/types/onchain/constants/index.d.ts +2 -2
  107. package/dist/types/onchain/constants/math.d.ts +9 -1
  108. package/dist/types/onchain/index.d.ts +7 -3
  109. package/dist/types/onchain/validation/checks.d.ts +167 -0
  110. package/dist/types/onchain/validation/index.d.ts +4 -0
  111. package/dist/types/onchain/{accounts/intents → validation}/refusal.d.ts +100 -31
  112. package/dist/types/onchain/validation/token.d.ts +17 -0
  113. package/dist/types/preview/index.d.ts +5 -1
  114. package/dist/types/preview/validate/checkOperation.d.ts +46 -0
  115. package/dist/types/preview/validate/checkSimulation.d.ts +34 -0
  116. package/dist/types/preview/validate/index.d.ts +3 -0
  117. package/dist/types/sdk/index.d.ts +2 -2
  118. package/dist/types/sdk/prepare/index.d.ts +2 -2
  119. package/dist/types/sdk/prepare/types.d.ts +2 -2
  120. package/package.json +1 -1
  121. package/dist/cjs/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -267
  122. package/dist/cjs/common-utils/utils/validation/index.js +0 -23
  123. package/dist/cjs/common-utils/utils/validation/is-zero-balance.js +0 -7
  124. package/dist/cjs/common-utils/utils/validation/validate-balance.js +0 -22
  125. package/dist/cjs/common-utils/utils/validation/validate-balance.spec.js +0 -54
  126. package/dist/cjs/common-utils/utils/validation/validate-balances.js +0 -17
  127. package/dist/cjs/common-utils/utils/validation/validate-balances.spec.js +0 -45
  128. package/dist/cjs/common-utils/utils/validation/validate-credit-manager.js +0 -8
  129. package/dist/cjs/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
  130. package/dist/cjs/common-utils/utils/validation/validate-hf.js +0 -10
  131. package/dist/cjs/common-utils/utils/validation/validate-hf.spec.js +0 -26
  132. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -14
  133. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
  134. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.js +0 -37
  135. package/dist/cjs/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
  136. package/dist/cjs/common-utils/utils/validation/validate-open-account.js +0 -18
  137. package/dist/cjs/common-utils/utils/validation/validate-open-account.spec.js +0 -56
  138. package/dist/cjs/common-utils/utils/validation/validate-quota.js +0 -23
  139. package/dist/cjs/common-utils/utils/validation/validate-quota.spec.js +0 -88
  140. package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.js +0 -18
  141. package/dist/cjs/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
  142. package/dist/cjs/common-utils/utils/validation/validation-types.js +0 -1
  143. package/dist/esm/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.js +0 -264
  144. package/dist/esm/common-utils/utils/validation/index.js +0 -12
  145. package/dist/esm/common-utils/utils/validation/is-zero-balance.js +0 -6
  146. package/dist/esm/common-utils/utils/validation/validate-balance.js +0 -21
  147. package/dist/esm/common-utils/utils/validation/validate-balance.spec.js +0 -54
  148. package/dist/esm/common-utils/utils/validation/validate-balances.js +0 -16
  149. package/dist/esm/common-utils/utils/validation/validate-balances.spec.js +0 -45
  150. package/dist/esm/common-utils/utils/validation/validate-credit-manager.js +0 -7
  151. package/dist/esm/common-utils/utils/validation/validate-credit-manager.spec.js +0 -36
  152. package/dist/esm/common-utils/utils/validation/validate-hf.js +0 -8
  153. package/dist/esm/common-utils/utils/validation/validate-hf.spec.js +0 -26
  154. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.js +0 -13
  155. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.js +0 -29
  156. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.js +0 -36
  157. package/dist/esm/common-utils/utils/validation/validate-open-account-pool-status.spec.js +0 -98
  158. package/dist/esm/common-utils/utils/validation/validate-open-account.js +0 -17
  159. package/dist/esm/common-utils/utils/validation/validate-open-account.spec.js +0 -56
  160. package/dist/esm/common-utils/utils/validation/validate-quota.js +0 -22
  161. package/dist/esm/common-utils/utils/validation/validate-quota.spec.js +0 -88
  162. package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.js +0 -17
  163. package/dist/esm/common-utils/utils/validation/validate-token-to-obtain.spec.js +0 -36
  164. package/dist/esm/common-utils/utils/validation/validation-types.js +0 -1
  165. package/dist/types/common-utils/utils/strategies/strategy-info/get-cm-you-can-earn.spec.d.ts +0 -1
  166. package/dist/types/common-utils/utils/validation/index.d.ts +0 -12
  167. package/dist/types/common-utils/utils/validation/is-zero-balance.d.ts +0 -4
  168. package/dist/types/common-utils/utils/validation/validate-balance.d.ts +0 -25
  169. package/dist/types/common-utils/utils/validation/validate-balance.spec.d.ts +0 -1
  170. package/dist/types/common-utils/utils/validation/validate-balances.d.ts +0 -13
  171. package/dist/types/common-utils/utils/validation/validate-balances.spec.d.ts +0 -1
  172. package/dist/types/common-utils/utils/validation/validate-credit-manager.d.ts +0 -13
  173. package/dist/types/common-utils/utils/validation/validate-credit-manager.spec.d.ts +0 -1
  174. package/dist/types/common-utils/utils/validation/validate-hf.d.ts +0 -12
  175. package/dist/types/common-utils/utils/validation/validate-hf.spec.d.ts +0 -1
  176. package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.d.ts +0 -10
  177. package/dist/types/common-utils/utils/validation/validate-open-account-pool-quota-status.spec.d.ts +0 -1
  178. package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.d.ts +0 -26
  179. package/dist/types/common-utils/utils/validation/validate-open-account-pool-status.spec.d.ts +0 -1
  180. package/dist/types/common-utils/utils/validation/validate-open-account.d.ts +0 -25
  181. package/dist/types/common-utils/utils/validation/validate-open-account.spec.d.ts +0 -1
  182. package/dist/types/common-utils/utils/validation/validate-quota.d.ts +0 -24
  183. package/dist/types/common-utils/utils/validation/validate-quota.spec.d.ts +0 -1
  184. package/dist/types/common-utils/utils/validation/validate-token-to-obtain.d.ts +0 -17
  185. package/dist/types/common-utils/utils/validation/validate-token-to-obtain.spec.d.ts +0 -1
  186. package/dist/types/common-utils/utils/validation/validation-types.d.ts +0 -10
@@ -1,4 +1,4 @@
1
- //#region src/onchain/accounts/intents/refusal.ts
1
+ //#region src/onchain/validation/refusal.ts
2
2
  /** Builds the refusal a caller sees. */
3
3
  function refuse(reason, detail) {
4
4
  return {
@@ -22,5 +22,15 @@ var IntentPreviewError = class extends Error {
22
22
  this.detail = detail;
23
23
  }
24
24
  };
25
+ /**
26
+ * Throws the issue a check found, with the sentence the engine logs for it.
27
+ *
28
+ * Returns normally when there is nothing to raise, so it cannot narrow a type
29
+ * the way a bare `throw` does — a site that guards a value for the code below
30
+ * it keeps throwing directly.
31
+ */
32
+ function raise(issue, message) {
33
+ if (issue) throw new IntentPreviewError(issue.reason, issue.detail, message);
34
+ }
25
35
  //#endregion
26
- export { IntentPreviewError, refuse };
36
+ export { IntentPreviewError, raise, refuse };
@@ -0,0 +1,27 @@
1
+ import { shortAddress } from "../utils/formatter.js";
2
+ import { amountOf } from "./checks.js";
3
+ //#region src/onchain/validation/token.ts
4
+ /**
5
+ * The token behind an address, for the refusal details that inline one.
6
+ *
7
+ * A token the registry does not know falls back to its own shortened address
8
+ * as a symbol and `decimals: 0` — an unknown token has no scale, and guessing
9
+ * 18 would silently misformat every amount denominated in it.
10
+ */
11
+ function toToken(sdk, address) {
12
+ const known = sdk.tokensMeta.getToken(address);
13
+ if (known) return known;
14
+ return {
15
+ chainId: sdk.chainId,
16
+ address,
17
+ symbol: shortAddress(address),
18
+ name: "",
19
+ decimals: 0
20
+ };
21
+ }
22
+ /** {@link toToken} plus an amount denominated in it. */
23
+ function toTokenAmount(sdk, address, value) {
24
+ return amountOf(toToken(sdk, address), value);
25
+ }
26
+ //#endregion
27
+ export { toToken, toTokenAmount };
@@ -1,4 +1,5 @@
1
1
  import { UnsupportedZapperFunctionError } from "../onchain/market/zapper/errors.js";
2
+ import { IntentPreviewError, raise, refuse } from "../onchain/validation/refusal.js";
2
3
  import { TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, WithdrawCollateralAlignmentError } from "./trace/errors.js";
3
4
  import { extractAdapterCallTraces } from "./trace/extractAdapterCallTraces.js";
4
5
  import { extractTransfers } from "./trace/extractTransfers.js";
@@ -31,4 +32,7 @@ import { previewCloseOrRepayCreditAccount } from "./preview/previewCloseOrRepayC
31
32
  import { previewOperation } from "./preview/previewOperation.js";
32
33
  import "./preview/index.js";
33
34
  import "./types.js";
34
- export { AllowancePrerequisite, BalancePrerequisite, CreditAccountState, Prerequisite, RWAOpenRequirementsPrerequisite, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, WithdrawCollateralAlignmentError, buildDelayedPreview, checkPrerequisites, classifyCloseOrRepay, classifyInnerOperations, detectDelayedClaim, detectDelayedOperation, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustCreditAccount, previewCloseOrRepayCreditAccount, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
35
+ import { checkOperation, collateralIssuesOf } from "./validate/checkOperation.js";
36
+ import { checkSimulation } from "./validate/checkSimulation.js";
37
+ import "./validate/index.js";
38
+ export { AllowancePrerequisite, BalancePrerequisite, CreditAccountState, IntentPreviewError, Prerequisite, RWAOpenRequirementsPrerequisite, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, WithdrawCollateralAlignmentError, buildDelayedPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssuesOf, detectDelayedClaim, detectDelayedOperation, extractAdapterCallTraces, extractTransfers, findFacadeCalls, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustCreditAccount, previewCloseOrRepayCreditAccount, previewOperation, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
@@ -203,6 +203,7 @@ function buildAdjustPreview(post, before, collateralWithdrawn, converter, sdk) {
203
203
  assetsChange: post.balances.difference(before.balances).toAssets(DUST_THRESHOLD).map((a) => oracle.toTokenAmount(a.token, a.balance)),
204
204
  error: converter.error,
205
205
  healthFactor: sdk.positions.healthFactor(snap),
206
+ safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
206
207
  borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: before.totalDebt - post.totalDebt }),
207
208
  timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: before.totalDebt - post.totalDebt }),
208
209
  liquidationPrice: sdk.positions.liquidationPrice(snap),
@@ -60,6 +60,7 @@ async function previewAdjustCreditAccount(input, operation, options) {
60
60
  assetsChange: assetsChange.map((a) => oracle.toTokenAmount(a.token, a.balance)),
61
61
  error,
62
62
  healthFactor: sdk.positions.healthFactor(snap),
63
+ safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
63
64
  borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: before.totalDebt - account.totalDebt }),
64
65
  timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: before.totalDebt - account.totalDebt }),
65
66
  liquidationPrice: sdk.positions.liquidationPrice(snap),
@@ -50,6 +50,7 @@ async function previewOpenCreditAccount(input, operation) {
50
50
  assets: assets.map((a) => oracle.toTokenAmount(a.token, a.balance)),
51
51
  error,
52
52
  healthFactor: sdk.positions.healthFactor(snap),
53
+ safeHealthFactor: sdk.positions.healthFactor(snap, { safePrices: true }),
53
54
  borrowRate: sdk.positions.borrowRate(snap, { availableLiquidityChange: -account.totalDebt }),
54
55
  timeToLiquidation: sdk.positions.timeToLiquidation(snap, { availableLiquidityChange: -account.totalDebt }),
55
56
  liquidationPrice: sdk.positions.liquidationPrice(snap),
@@ -1,5 +1,5 @@
1
- import { iPoolV310Abi } from "../../abi/310/generated.js";
2
1
  import { iZapperAbi } from "../../abi/iZapper.js";
2
+ import { iPoolV310Abi } from "../../abi/310/generated.js";
3
3
  import { asPreviewSimulationError } from "./errors.js";
4
4
  //#region src/preview/simulate/simulatePoolOperation.ts
5
5
  function previewRead(operation) {
@@ -1,6 +1,6 @@
1
+ import { ierc20Abi } from "../../abi/iERC20.js";
1
2
  import { iCreditFacadeV310Abi } from "../../abi/310/generated.js";
2
3
  import { AddressMap } from "../../onchain/utils/AddressMap.js";
3
- import { ierc20Abi } from "../../abi/iERC20.js";
4
4
  import "../../onchain/index.js";
5
5
  import { UnexpectedFacadeEventOrderError } from "./errors.js";
6
6
  import { getAddress, isAddressEqual, parseEventLogs } from "viem";
@@ -0,0 +1,171 @@
1
+ import { checkBorrowLimit, checkCollateralised, checkCreditManagerPaused, checkDebtInBand, checkForbiddenToken, checkFunding, checkMarketExpired, checkPoolPaused, checkPoolPayout, checkPoolSunset, checkPreviewError, checkQuotaCount, checkQuotaLimit } from "../../onchain/validation/checks.js";
2
+ import { toToken } from "../../onchain/validation/token.js";
3
+ import { borrowable } from "../../onchain/accounts/intents/guards.js";
4
+ import "../../onchain/index.js";
5
+ import { isAddressEqual } from "viem";
6
+ //#region src/preview/validate/checkOperation.ts
7
+ /**
8
+ * Whether a parsed operation may be signed at all — the protocol state that
9
+ * `checkPrerequisites` leaves out, since that one covers only what the sender
10
+ * can fix themselves.
11
+ *
12
+ * Synchronous: the preview carries the numbers and the market is attached.
13
+ * Reports the most fundamental issue it finds and stops there, which is the one
14
+ * a caller acts on.
15
+ */
16
+ function checkOperation(input, options = {}) {
17
+ const { sdk, preview } = input;
18
+ const malformed = checkPreviewError("error" in preview ? preview.error : void 0);
19
+ if (malformed) return malformed;
20
+ switch (preview.operation) {
21
+ case "Deposit":
22
+ case "Mint": return poolIssues(sdk, preview, options, true);
23
+ case "Withdraw":
24
+ case "Redeem": return poolIssues(sdk, preview, options, false);
25
+ case "DelayedCreditAccountOperation": return checkOperation({
26
+ sdk,
27
+ preview: preview.instantPreview
28
+ }, options);
29
+ case "OpenCreditAccount":
30
+ case "RWAOpenCreditAccount":
31
+ case "AdjustCreditAccount": return creditIssues(sdk, preview, options);
32
+ case "CloseCreditAccount":
33
+ case "RepayCreditAccount": return marketIssues(sdk, preview.creditManager);
34
+ }
35
+ }
36
+ function poolIssues(sdk, preview, options, isDeposit) {
37
+ const market = sdk.marketRegister.findByPool(preview.pool);
38
+ return checkPoolPaused({
39
+ isPaused: market.pool.pool.isPaused,
40
+ pool: preview.pool
41
+ }) || checkPoolSunset({
42
+ isSunset: market.sunset,
43
+ isDeposit,
44
+ pool: preview.pool
45
+ }) || (isDeposit ? null : checkPoolPayout({
46
+ requested: preview.tokenOut.value,
47
+ available: market.pool.pool.availableLiquidity,
48
+ underlying: preview.tokenOut.token
49
+ })) || fundingIssue(options, [preview.tokenIn]);
50
+ }
51
+ /** What the market itself refuses, whatever the operation does. */
52
+ function marketIssues(sdk, creditManager) {
53
+ const suite = sdk.marketRegister.findCreditManager(creditManager);
54
+ return checkCreditManagerPaused({
55
+ isPaused: suite.isPaused,
56
+ creditManager
57
+ }) || checkMarketExpired({
58
+ isExpired: suite.isExpired,
59
+ creditManager,
60
+ expirationDate: suite.creditFacade.expirationDate
61
+ });
62
+ }
63
+ function creditIssues(sdk, preview, options) {
64
+ const suite = sdk.marketRegister.findCreditManager(preview.creditManager);
65
+ const market = suite.market;
66
+ const underlying = toToken(sdk, market.pool.underlying);
67
+ const isOpening = preview.operation === "OpenCreditAccount" || preview.operation === "RWAOpenCreditAccount";
68
+ return marketIssues(sdk, preview.creditManager) || checkDebtInBand({
69
+ debt: preview.debt,
70
+ minDebt: suite.creditFacade.minDebt,
71
+ maxDebt: suite.creditFacade.maxDebt,
72
+ underlying,
73
+ allowZero: !isOpening
74
+ }) || borrowIssue(suite, preview, underlying) || forbiddenIssue(suite, preview) || checkQuotaCount({
75
+ count: preview.quotas.filter((q) => q.value > 0n).length,
76
+ max: suite.creditManager.maxEnabledTokens
77
+ }) || quotaIssue(market, preview, underlying) || (preview.debt === 0n ? null : collateralIssue(preview, options)) || fundingIssue(options, collateralOf(preview));
78
+ }
79
+ /**
80
+ * What the transaction draws, against what the market can lend right now.
81
+ *
82
+ * Only a draw is weighed: repaying, or leaving the debt alone, can never exceed
83
+ * a ceiling. Opening borrows the whole debt; adjusting borrows `debtChange`.
84
+ *
85
+ * The engine holds every simulation to this already (`assertCanBorrow`), so
86
+ * this is here for the transactions it never saw — a pasted calldata reaches
87
+ * the confirm screen with nothing else standing between it and a revert.
88
+ */
89
+ function borrowIssue(suite, preview, underlying) {
90
+ const drawn = preview.operation === "AdjustCreditAccount" ? preview.debtChange : preview.debt;
91
+ if (drawn <= 0n) return null;
92
+ const { limit, binding } = borrowable(suite);
93
+ return checkBorrowLimit({
94
+ requested: drawn,
95
+ available: limit,
96
+ binding,
97
+ underlying
98
+ });
99
+ }
100
+ /** The account against whichever bars the caller holds it to. */
101
+ function collateralIssue(preview, options) {
102
+ return collateralIssuesOf({
103
+ healthFactor: preview.healthFactor,
104
+ safeHealthFactor: preview.safeHealthFactor
105
+ }, options);
106
+ }
107
+ /** The wallet's side of the operation, against the balances it was given. */
108
+ function fundingIssue(options, puts) {
109
+ const { balances } = options;
110
+ if (!balances) return null;
111
+ for (const { token, value } of puts) {
112
+ const issue = checkFunding({
113
+ token,
114
+ required: value,
115
+ held: balances.get(token.address) ?? 0n
116
+ });
117
+ if (issue) return issue;
118
+ }
119
+ return null;
120
+ }
121
+ /** What the wallet puts in, which is what its balances have to cover. */
122
+ function collateralOf(preview) {
123
+ if ("collateral" in preview) return preview.collateral;
124
+ if ("collateralAdded" in preview) return preview.collateralAdded;
125
+ return [];
126
+ }
127
+ function forbiddenIssue(suite, preview) {
128
+ const obtained = preview.operation === "AdjustCreditAccount" ? preview.assetsChange : preview.assets;
129
+ const forbidden = suite.forbiddenTokens;
130
+ for (const asset of obtained) {
131
+ if (asset.value <= 0n) continue;
132
+ const issue = checkForbiddenToken({
133
+ token: asset.token,
134
+ isForbidden: forbidden.some((f) => isAddressEqual(f, asset.token.address))
135
+ });
136
+ if (issue) return issue;
137
+ }
138
+ return null;
139
+ }
140
+ function quotaIssue(market, preview, underlying) {
141
+ const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
142
+ const { pqk } = market.pool;
143
+ for (const q of increases) {
144
+ if (q.value <= 0n) continue;
145
+ const quota = pqk.hasActiveQuota(q.token.address) ? pqk.quotas.get(q.token.address) : void 0;
146
+ const issue = checkQuotaLimit({
147
+ token: q.token,
148
+ requested: quota ? q.value : void 0,
149
+ available: (quota?.limit ?? 0n) - (quota?.totalQuoted ?? 0n),
150
+ underlying
151
+ });
152
+ if (issue) return issue;
153
+ }
154
+ return null;
155
+ }
156
+ /** The two collateral bars, shared by the preview and the simulation paths. */
157
+ function collateralIssuesOf(factors, options) {
158
+ const { minHealthFactor, minSafeHealthFactor, currentHealthFactor } = options;
159
+ return (minHealthFactor === void 0 ? null : checkCollateralised({
160
+ healthFactor: factors.healthFactor,
161
+ required: minHealthFactor,
162
+ safePrices: false,
163
+ improvesFrom: currentHealthFactor
164
+ })) || (minSafeHealthFactor === void 0 || factors.safeHealthFactor === void 0 ? null : checkCollateralised({
165
+ healthFactor: factors.safeHealthFactor,
166
+ required: minSafeHealthFactor,
167
+ safePrices: true
168
+ }));
169
+ }
170
+ //#endregion
171
+ export { checkOperation, collateralIssuesOf };
@@ -0,0 +1,51 @@
1
+ import { checkCreditManagerPaused, checkDebtInBand, checkMarketExpired, checkQuotaCount } from "../../onchain/validation/checks.js";
2
+ import { toToken } from "../../onchain/validation/token.js";
3
+ import "../../onchain/index.js";
4
+ import { collateralIssuesOf } from "./checkOperation.js";
5
+ //#region src/preview/validate/checkSimulation.ts
6
+ /**
7
+ * Whether a simulated operation clears the caller's own bars.
8
+ *
9
+ * The engine holds an account to the facade's `1.0`, because its guards answer
10
+ * "would this revert". A form is wiser to ask for more, and the engine's own
11
+ * note says so — a caller wanting the stricter bar applies it itself. This is
12
+ * that second opinion, over the numbers the engine already reported.
13
+ *
14
+ * Three of the checks below the engine does not make at all: both health-factor
15
+ * bars are its own `1.0`, and the quota count it never weighs. The other two run
16
+ * against the same numbers the engine used, and are here so that a change in the
17
+ * engine cannot pass silently.
18
+ *
19
+ * What is deliberately absent: the forbidden-token, quota-limit and funding
20
+ * checks all need the *delta* an operation applies, and `OperationState` reports
21
+ * only the state after it. Weighing them against absolutes would refuse a
22
+ * forbidden token the account merely holds, or a quota the operation never
23
+ * touched. The engine performed all three during the walk, so a simulation that
24
+ * came back `ok` has already passed them.
25
+ */
26
+ function checkSimulation(input, options = {}) {
27
+ const { sdk, state, creditManager } = input;
28
+ const suite = sdk.marketRegister.findCreditManager(creditManager);
29
+ return checkCreditManagerPaused({
30
+ isPaused: suite.isPaused,
31
+ creditManager
32
+ }) || checkMarketExpired({
33
+ isExpired: suite.isExpired,
34
+ creditManager,
35
+ expirationDate: suite.creditFacade.expirationDate
36
+ }) || checkDebtInBand({
37
+ debt: state.accountDebt,
38
+ minDebt: suite.creditFacade.minDebt,
39
+ maxDebt: suite.creditFacade.maxDebt,
40
+ underlying: toToken(sdk, suite.market.pool.underlying),
41
+ allowZero: true
42
+ }) || checkQuotaCount({
43
+ count: Object.values(state.quotas).filter((q) => q.balance > 0n).length,
44
+ max: suite.creditManager.maxEnabledTokens
45
+ }) || (state.accountDebt === 0n ? null : collateralIssuesOf({
46
+ healthFactor: state.healthFactor,
47
+ safeHealthFactor: state.safeHealthFactor
48
+ }, options));
49
+ }
50
+ //#endregion
51
+ export { checkSimulation };
@@ -0,0 +1,3 @@
1
+ import { checkOperation, collateralIssuesOf } from "./checkOperation.js";
2
+ import { checkSimulation } from "./checkSimulation.js";
3
+ export { checkOperation, checkSimulation, collateralIssuesOf };
@@ -1,3 +1,4 @@
1
+ import { IntentPreviewError, raise, refuse } from "../onchain/validation/refusal.js";
1
2
  import { AllSourcesFailedError } from "./errors/AllSourcesFailedError.js";
2
3
  import { SourceChainMismatchError } from "./errors/SourceChainMismatchError.js";
3
4
  import { assertSameChains } from "./errors/assertSameChains.js";
@@ -24,4 +25,4 @@ import { PreviewNamespace } from "./preview/PreviewNamespace.js";
24
25
  import "./preview/index.js";
25
26
  import { DEFAULT_MAX_STATE_AGE, GearboxSDK } from "./GearboxSDK.js";
26
27
  import "./types.js";
27
- export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne };
28
+ export { AbstractNamespace, AllSourcesFailedError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, ExecuteApi, GearboxSDK, IntentPreviewError, LiquidationsNamespace, MissingSourceError, NoSourceServedError, OpportunitiesNamespace, PositionsNamespace, PrepareApi, PreviewNamespace, SourceChainMismatchError, SourceUnavailableError, assertSameChains, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, raise, refuse };
@@ -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,
@@ -332,10 +336,10 @@ function resumable(intent) {
332
336
  * is the usual way of it; both are present where a pair exists but nothing of
333
337
  * ours implements it.
334
338
  **/
335
- function unroutable(from, to) {
339
+ function unroutable(sdk, from, to) {
336
340
  return refuse("unsupportedTokenPair", {
337
- from,
338
- to
341
+ from: toToken(sdk, from),
342
+ to: to === void 0 ? void 0 : toToken(sdk, to)
339
343
  });
340
344
  }
341
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 };