@gearbox-protocol/sdk 16.1.2 → 16.3.0-next.1

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 (517) hide show
  1. package/dist/cjs/history/assembleOperations.js +3 -3
  2. package/dist/cjs/history/classifyMulticallOperations.js +7 -7
  3. package/dist/cjs/history/index.js +13 -0
  4. package/dist/cjs/history/parseCreditAccountTransaction.js +5 -5
  5. package/dist/cjs/{preview → history}/trace/errors.js +1 -1
  6. package/dist/cjs/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
  7. package/dist/cjs/{preview → history}/trace/extractTransfers.js +3 -3
  8. package/dist/cjs/{preview → history}/trace/findFacadeCalls.js +3 -3
  9. package/dist/cjs/history/trace/index.js +14 -0
  10. package/dist/cjs/model/errors/index.js +37 -0
  11. package/dist/cjs/model/errors/liquidation-errors.js +32 -0
  12. package/dist/cjs/model/errors/operation-errors.js +135 -0
  13. package/dist/cjs/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
  14. package/dist/cjs/model/errors/prepare-errors.js +108 -0
  15. package/dist/cjs/model/errors/preview-errors.js +12 -0
  16. package/dist/cjs/model/index.js +40 -2
  17. package/dist/cjs/model/positions.js +1 -1
  18. package/dist/cjs/model/result.js +0 -8
  19. package/dist/cjs/model/rwa.js +40 -0
  20. package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  21. package/dist/cjs/onchain/accounts/index.js +0 -2
  22. package/dist/cjs/onchain/accounts/intents/guards.js +42 -66
  23. package/dist/cjs/onchain/accounts/intents/index.js +38 -35
  24. package/dist/cjs/onchain/accounts/intents/leverage-band.js +1 -1
  25. package/dist/cjs/onchain/accounts/intents/math.js +19 -15
  26. package/dist/cjs/onchain/accounts/intents/open-strategy.js +44 -8
  27. package/dist/cjs/onchain/accounts/intents/plan.js +52 -48
  28. package/dist/cjs/onchain/accounts/intents/realize.js +26 -24
  29. package/dist/cjs/onchain/accounts/intents/tail.js +15 -12
  30. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +7 -0
  31. package/dist/cjs/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
  32. package/dist/cjs/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
  33. package/dist/cjs/onchain/accounts/intents/view.js +1 -1
  34. package/dist/cjs/onchain/accounts/withdrawal-compressor/index.js +0 -1
  35. package/dist/cjs/onchain/index.js +122 -36
  36. package/dist/cjs/onchain/market/MarketSuite.js +7 -1
  37. package/dist/cjs/onchain/market/adapters/index.js +1 -0
  38. package/dist/cjs/onchain/market/credit/CreditSuite.js +47 -15
  39. package/dist/cjs/onchain/market/index.js +0 -6
  40. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +6 -6
  41. package/dist/cjs/onchain/market/oracle/index.js +0 -2
  42. package/dist/cjs/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
  43. package/dist/cjs/onchain/market/rwa/RWARegistry.js +3 -2
  44. package/dist/cjs/onchain/market/rwa/index.js +0 -4
  45. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +7 -7
  46. package/dist/cjs/onchain/market/rwa/securitize/constants.js +0 -2
  47. package/dist/cjs/onchain/market/rwa/securitize/index.js +1 -3
  48. package/dist/cjs/onchain/market/rwa/securitize/types.js +0 -29
  49. package/dist/cjs/onchain/market/rwa/types.js +0 -7
  50. package/dist/cjs/onchain/market/zapper/index.js +0 -1
  51. package/dist/cjs/onchain/pools/PoolService.js +10 -16
  52. package/dist/cjs/onchain/preview/index.js +41 -0
  53. package/dist/cjs/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
  54. package/dist/cjs/onchain/preview/parse/index.js +14 -0
  55. package/dist/cjs/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +3 -3
  56. package/dist/cjs/{preview → onchain/preview}/parse/parseOperationCalldata.js +16 -17
  57. package/dist/cjs/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
  58. package/dist/cjs/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +11 -12
  59. package/dist/cjs/{preview → onchain/preview}/parse/types.js +1 -1
  60. package/dist/cjs/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
  61. package/dist/cjs/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
  62. package/dist/cjs/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
  63. package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
  64. package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
  65. package/dist/cjs/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
  66. package/dist/cjs/onchain/preview/preview/index.js +26 -0
  67. package/dist/cjs/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +18 -22
  68. package/dist/cjs/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +22 -28
  69. package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +60 -0
  70. package/dist/cjs/onchain/preview/preview/previewOperation.js +119 -0
  71. package/dist/cjs/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -32
  72. package/dist/cjs/onchain/preview/preview/replayInnerOperations.js +109 -0
  73. package/dist/cjs/onchain/preview/preview/replayMulticall.js +22 -0
  74. package/dist/cjs/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
  75. package/dist/cjs/onchain/validation/bundles/checkAccountQuotas.js +20 -0
  76. package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +59 -0
  77. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +65 -0
  78. package/dist/cjs/onchain/validation/bundles/checkDraw.js +28 -0
  79. package/dist/cjs/onchain/validation/bundles/checkHealthFactors.js +27 -0
  80. package/dist/cjs/onchain/validation/bundles/checkLiquidationEligibility.js +33 -0
  81. package/dist/cjs/onchain/validation/bundles/checkLiquidationFunding.js +29 -0
  82. package/dist/cjs/onchain/validation/bundles/checkMarket.js +24 -0
  83. package/dist/cjs/onchain/validation/bundles/checkObtained.js +13 -0
  84. package/dist/cjs/onchain/validation/bundles/checkPoolFunding.js +22 -0
  85. package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +35 -0
  86. package/dist/cjs/onchain/validation/bundles/checkQuotasAsked.js +20 -0
  87. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +33 -0
  88. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +24 -0
  89. package/dist/cjs/onchain/validation/bundles/checkWallet.js +22 -0
  90. package/dist/cjs/onchain/validation/bundles/checkWalletAllowance.js +32 -0
  91. package/dist/cjs/onchain/validation/bundles/checkWalletBalance.js +41 -0
  92. package/dist/cjs/onchain/validation/bundles/index.js +35 -0
  93. package/dist/cjs/onchain/validation/checkLiquidation.js +22 -0
  94. package/dist/cjs/onchain/validation/checkOperation.js +62 -0
  95. package/dist/cjs/onchain/validation/checkSimulation.js +60 -0
  96. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +25 -0
  97. package/dist/cjs/onchain/validation/checks/checkCollateralised.js +26 -0
  98. package/dist/cjs/onchain/validation/checks/checkCreditAccountFrozen.js +10 -0
  99. package/dist/cjs/onchain/validation/checks/checkCreditManagerPaused.js +10 -0
  100. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +18 -0
  101. package/dist/cjs/onchain/validation/checks/checkEmergencyLiquidator.js +13 -0
  102. package/dist/cjs/onchain/validation/checks/checkForbiddenToken.js +10 -0
  103. package/dist/cjs/onchain/validation/checks/checkLeverage.js +13 -0
  104. package/dist/cjs/onchain/validation/checks/checkLiquidatorEligible.js +10 -0
  105. package/dist/cjs/onchain/validation/checks/checkMarketExpired.js +10 -0
  106. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +25 -0
  107. package/dist/cjs/onchain/validation/checks/checkPoolPaused.js +10 -0
  108. package/dist/cjs/onchain/validation/checks/checkPoolSunset.js +10 -0
  109. package/dist/cjs/onchain/validation/checks/checkQuotaCount.js +10 -0
  110. package/dist/cjs/onchain/validation/checks/checkQuotaLimit.js +18 -0
  111. package/dist/cjs/onchain/validation/checks/index.js +31 -0
  112. package/dist/cjs/onchain/validation/helpers/amount.js +12 -0
  113. package/dist/cjs/onchain/validation/helpers/health-factor-limits.js +25 -0
  114. package/dist/cjs/onchain/validation/helpers/index.js +11 -0
  115. package/dist/cjs/onchain/validation/{token.js → helpers/token.js} +4 -4
  116. package/dist/cjs/onchain/validation/index.js +85 -27
  117. package/dist/cjs/onchain/validation/raise.js +33 -0
  118. package/dist/cjs/sdk/execute/ExecuteApi.js +1 -0
  119. package/dist/cjs/sdk/index.js +6 -9
  120. package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +9 -0
  121. package/dist/cjs/sdk/prepare/PrepareApi.js +55 -48
  122. package/dist/cjs/sdk/prepare/index.js +7 -9
  123. package/dist/cjs/sdk/prepare/types.js +0 -4
  124. package/dist/cjs/sdk/preview/PreviewNamespace.js +24 -13
  125. package/dist/esm/history/assembleOperations.js +2 -2
  126. package/dist/esm/history/classifyMulticallOperations.js +2 -2
  127. package/dist/esm/history/index.js +6 -1
  128. package/dist/esm/history/parseCreditAccountTransaction.js +3 -3
  129. package/dist/esm/{preview → history}/trace/errors.js +1 -1
  130. package/dist/esm/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
  131. package/dist/esm/{preview → history}/trace/extractTransfers.js +1 -1
  132. package/dist/esm/{preview → history}/trace/findFacadeCalls.js +1 -1
  133. package/dist/esm/model/errors/index.js +7 -0
  134. package/dist/esm/model/errors/liquidation-errors.js +29 -0
  135. package/dist/esm/model/errors/operation-errors.js +121 -0
  136. package/dist/esm/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
  137. package/dist/esm/model/errors/prepare-errors.js +97 -0
  138. package/dist/esm/model/errors/preview-errors.js +11 -0
  139. package/dist/esm/model/index.js +9 -3
  140. package/dist/esm/model/positions.js +1 -1
  141. package/dist/esm/model/result.js +1 -8
  142. package/dist/esm/model/rwa.js +37 -0
  143. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  144. package/dist/esm/onchain/accounts/index.js +1 -2
  145. package/dist/esm/onchain/accounts/intents/guards.js +29 -52
  146. package/dist/esm/onchain/accounts/intents/index.js +39 -35
  147. package/dist/esm/onchain/accounts/intents/leverage-band.js +1 -1
  148. package/dist/esm/onchain/accounts/intents/math.js +18 -14
  149. package/dist/esm/onchain/accounts/intents/open-strategy.js +46 -10
  150. package/dist/esm/onchain/accounts/intents/plan.js +51 -47
  151. package/dist/esm/onchain/accounts/intents/realize.js +26 -24
  152. package/dist/esm/onchain/accounts/intents/tail.js +14 -11
  153. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +7 -0
  154. package/dist/esm/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
  155. package/dist/esm/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
  156. package/dist/esm/onchain/accounts/intents/view.js +1 -1
  157. package/dist/esm/onchain/accounts/withdrawal-compressor/index.js +0 -1
  158. package/dist/esm/onchain/index.js +61 -10
  159. package/dist/esm/onchain/market/MarketSuite.js +7 -1
  160. package/dist/esm/onchain/market/adapters/index.js +1 -0
  161. package/dist/esm/onchain/market/credit/CreditSuite.js +47 -15
  162. package/dist/esm/onchain/market/index.js +3 -5
  163. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
  164. package/dist/esm/onchain/market/oracle/index.js +1 -2
  165. package/dist/esm/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
  166. package/dist/esm/onchain/market/rwa/RWARegistry.js +2 -1
  167. package/dist/esm/onchain/market/rwa/index.js +3 -4
  168. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +2 -2
  169. package/dist/esm/onchain/market/rwa/securitize/constants.js +1 -2
  170. package/dist/esm/onchain/market/rwa/securitize/index.js +3 -3
  171. package/dist/esm/onchain/market/rwa/securitize/types.js +1 -29
  172. package/dist/esm/onchain/market/rwa/types.js +1 -7
  173. package/dist/esm/onchain/market/zapper/index.js +0 -1
  174. package/dist/esm/onchain/pools/PoolService.js +10 -16
  175. package/dist/esm/onchain/preview/index.js +20 -0
  176. package/dist/esm/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
  177. package/dist/esm/{preview → onchain/preview}/parse/index.js +0 -1
  178. package/dist/esm/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +1 -1
  179. package/dist/esm/{preview → onchain/preview}/parse/parseOperationCalldata.js +10 -11
  180. package/dist/esm/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
  181. package/dist/esm/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +8 -9
  182. package/dist/esm/{preview → onchain/preview}/parse/types.js +1 -1
  183. package/dist/esm/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
  184. package/dist/esm/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
  185. package/dist/esm/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
  186. package/dist/esm/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
  187. package/dist/esm/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
  188. package/dist/esm/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
  189. package/dist/esm/{preview → onchain/preview}/preview/index.js +3 -4
  190. package/dist/esm/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +17 -21
  191. package/dist/esm/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +20 -26
  192. package/dist/esm/{preview → onchain/preview}/preview/previewOpenStrategyPosition.js +25 -15
  193. package/dist/esm/{preview → onchain/preview}/preview/previewOperation.js +54 -35
  194. package/dist/esm/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -30
  195. package/dist/esm/onchain/preview/preview/replayInnerOperations.js +107 -0
  196. package/dist/esm/onchain/preview/preview/replayMulticall.js +21 -0
  197. package/dist/esm/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
  198. package/dist/esm/onchain/validation/bundles/checkAccountQuotas.js +19 -0
  199. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +58 -0
  200. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +64 -0
  201. package/dist/esm/onchain/validation/bundles/checkDraw.js +27 -0
  202. package/dist/esm/onchain/validation/bundles/checkHealthFactors.js +26 -0
  203. package/dist/esm/onchain/validation/bundles/checkLiquidationEligibility.js +32 -0
  204. package/dist/esm/onchain/validation/bundles/checkLiquidationFunding.js +28 -0
  205. package/dist/esm/onchain/validation/bundles/checkMarket.js +23 -0
  206. package/dist/esm/onchain/validation/bundles/checkObtained.js +12 -0
  207. package/dist/esm/onchain/validation/bundles/checkPoolFunding.js +21 -0
  208. package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +34 -0
  209. package/dist/esm/onchain/validation/bundles/checkQuotasAsked.js +19 -0
  210. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +32 -0
  211. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +23 -0
  212. package/dist/esm/onchain/validation/bundles/checkWallet.js +21 -0
  213. package/dist/esm/onchain/validation/bundles/checkWalletAllowance.js +31 -0
  214. package/dist/esm/onchain/validation/bundles/checkWalletBalance.js +40 -0
  215. package/dist/esm/onchain/validation/bundles/index.js +18 -0
  216. package/dist/esm/onchain/validation/checkLiquidation.js +21 -0
  217. package/dist/esm/onchain/validation/checkOperation.js +61 -0
  218. package/dist/esm/onchain/validation/checkSimulation.js +59 -0
  219. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +24 -0
  220. package/dist/esm/onchain/validation/checks/checkCollateralised.js +25 -0
  221. package/dist/esm/onchain/validation/checks/checkCreditAccountFrozen.js +9 -0
  222. package/dist/esm/onchain/validation/checks/checkCreditManagerPaused.js +9 -0
  223. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +17 -0
  224. package/dist/esm/onchain/validation/checks/checkEmergencyLiquidator.js +12 -0
  225. package/dist/esm/onchain/validation/checks/checkForbiddenToken.js +9 -0
  226. package/dist/esm/onchain/validation/checks/checkLeverage.js +12 -0
  227. package/dist/esm/onchain/validation/checks/checkLiquidatorEligible.js +9 -0
  228. package/dist/esm/onchain/validation/checks/checkMarketExpired.js +9 -0
  229. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +24 -0
  230. package/dist/esm/onchain/validation/checks/checkPoolPaused.js +9 -0
  231. package/dist/esm/onchain/validation/checks/checkPoolSunset.js +9 -0
  232. package/dist/esm/onchain/validation/checks/checkQuotaCount.js +9 -0
  233. package/dist/esm/onchain/validation/checks/checkQuotaLimit.js +17 -0
  234. package/dist/esm/onchain/validation/checks/index.js +16 -0
  235. package/dist/esm/onchain/validation/helpers/amount.js +11 -0
  236. package/dist/esm/onchain/validation/helpers/health-factor-limits.js +21 -0
  237. package/dist/esm/onchain/validation/helpers/index.js +4 -0
  238. package/dist/esm/onchain/validation/{token.js → helpers/token.js} +3 -3
  239. package/dist/esm/onchain/validation/index.js +43 -4
  240. package/dist/esm/onchain/validation/raise.js +31 -0
  241. package/dist/esm/sdk/execute/ExecuteApi.js +1 -0
  242. package/dist/esm/sdk/index.js +2 -3
  243. package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +9 -0
  244. package/dist/esm/sdk/prepare/PrepareApi.js +43 -36
  245. package/dist/esm/sdk/prepare/index.js +3 -3
  246. package/dist/esm/sdk/prepare/types.js +1 -2
  247. package/dist/esm/sdk/preview/PreviewNamespace.js +24 -13
  248. package/dist/types/history/assembleOperations.d.ts +4 -5
  249. package/dist/types/history/classifyMulticallOperations.d.ts +3 -4
  250. package/dist/types/history/index.d.ts +8 -2
  251. package/dist/types/history/mapOperations.d.ts +1 -1
  252. package/dist/types/{preview → history}/trace/errors.d.ts +1 -1
  253. package/dist/types/{preview → history}/trace/extractAdapterCallTraces.d.ts +1 -1
  254. package/dist/types/{preview → history}/trace/extractTransfers.d.ts +2 -3
  255. package/dist/types/{preview → history}/trace/findFacadeCalls.d.ts +1 -1
  256. package/dist/types/{preview → history}/trace/types.d.ts +1 -1
  257. package/dist/types/history/types.d.ts +2 -3
  258. package/dist/types/model/errors/base.d.ts +28 -0
  259. package/dist/types/model/errors/index.d.ts +7 -0
  260. package/dist/types/model/errors/liquidation-errors.d.ts +45 -0
  261. package/dist/types/model/errors/operation-errors.d.ts +216 -0
  262. package/dist/types/{onchain/market/oracle/errors.d.ts → model/errors/oracle-errors.d.ts} +3 -5
  263. package/dist/types/model/errors/prepare-errors.d.ts +131 -0
  264. package/dist/types/model/errors/preview-errors.d.ts +72 -0
  265. package/dist/types/model/index.d.ts +11 -4
  266. package/dist/types/model/opportunities.d.ts +3 -2
  267. package/dist/types/model/positions.d.ts +2 -2
  268. package/dist/types/model/previews.d.ts +52 -113
  269. package/dist/types/model/result.d.ts +4 -8
  270. package/dist/types/model/rwa.d.ts +143 -0
  271. package/dist/types/onchain/accounts/CreditAccountsServiceV310.d.ts +3 -1
  272. package/dist/types/onchain/accounts/index.d.ts +2 -4
  273. package/dist/types/onchain/accounts/intents/guards.d.ts +8 -18
  274. package/dist/types/onchain/accounts/intents/index.d.ts +20 -19
  275. package/dist/types/onchain/accounts/intents/leverage-band.d.ts +1 -1
  276. package/dist/types/onchain/accounts/intents/math.d.ts +6 -6
  277. package/dist/types/onchain/accounts/intents/open-strategy.d.ts +34 -3
  278. package/dist/types/onchain/accounts/intents/operations.d.ts +2 -2
  279. package/dist/types/onchain/accounts/intents/plan.d.ts +9 -9
  280. package/dist/types/onchain/accounts/intents/tail.d.ts +2 -2
  281. package/dist/types/onchain/accounts/intents/testing/expect.d.ts +3 -3
  282. package/dist/types/onchain/accounts/intents/tests/finish-withdraw.fixtures.d.ts +6 -6
  283. package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
  284. package/dist/types/onchain/accounts/intents/tests/withdraw.fixtures.d.ts +12 -12
  285. package/dist/types/onchain/accounts/intents/types.d.ts +32 -30
  286. package/dist/types/onchain/accounts/types.d.ts +4 -2
  287. package/dist/types/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +1 -1
  288. package/dist/types/onchain/accounts/withdrawal-compressor/index.d.ts +1 -2
  289. package/dist/types/onchain/accounts/withdrawal-compressor/types.d.ts +1 -1
  290. package/dist/types/onchain/index.d.ts +68 -13
  291. package/dist/types/onchain/market/MarketSuite.d.ts +5 -1
  292. package/dist/types/onchain/market/adapters/index.d.ts +2 -1
  293. package/dist/types/onchain/market/adapters/transfers.d.ts +0 -7
  294. package/dist/types/onchain/market/credit/CreditSuite.d.ts +20 -8
  295. package/dist/types/onchain/market/credit/index.d.ts +2 -2
  296. package/dist/types/onchain/market/credit/types.d.ts +11 -1
  297. package/dist/types/onchain/market/index.d.ts +6 -7
  298. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +1 -1
  299. package/dist/types/onchain/market/oracle/index.d.ts +1 -2
  300. package/dist/types/onchain/market/oracle/types.d.ts +1 -1
  301. package/dist/types/onchain/market/pool/PoolQuotaKeeperV310Contract.d.ts +5 -0
  302. package/dist/types/onchain/market/rwa/index.d.ts +4 -4
  303. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +3 -2
  304. package/dist/types/onchain/market/rwa/securitize/constants.d.ts +1 -2
  305. package/dist/types/onchain/market/rwa/securitize/index.d.ts +3 -3
  306. package/dist/types/onchain/market/rwa/securitize/types.d.ts +4 -110
  307. package/dist/types/onchain/market/rwa/types.d.ts +6 -32
  308. package/dist/types/onchain/market/zapper/ZapperContract.d.ts +1 -1
  309. package/dist/types/onchain/market/zapper/index.d.ts +1 -2
  310. package/dist/types/onchain/market/zapper/types.d.ts +1 -1
  311. package/dist/types/onchain/pools/types.d.ts +2 -2
  312. package/dist/types/onchain/preview/index.d.ts +24 -0
  313. package/dist/types/{preview → onchain/preview}/parse/classifyInnerOperations.d.ts +4 -4
  314. package/dist/types/{preview → onchain/preview}/parse/index.d.ts +2 -4
  315. package/dist/types/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.d.ts +4 -4
  316. package/dist/types/onchain/preview/parse/parseOperationCalldata.d.ts +18 -0
  317. package/dist/types/{preview → onchain/preview}/parse/parsePoolOperationCalldata.d.ts +7 -7
  318. package/dist/types/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.d.ts +4 -4
  319. package/dist/types/{preview → onchain/preview}/parse/types-adapters.d.ts +5 -16
  320. package/dist/types/{preview → onchain/preview}/parse/types-facades.d.ts +3 -3
  321. package/dist/types/{preview → onchain/preview}/parse/types-pools.d.ts +1 -1
  322. package/dist/types/{preview → onchain/preview}/parse/types-rwa.d.ts +3 -3
  323. package/dist/types/{preview → onchain/preview}/parse/types.d.ts +3 -3
  324. package/dist/types/{preview → onchain/preview}/preview/CreditAccountState.d.ts +5 -5
  325. package/dist/types/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.d.ts +5 -5
  326. package/dist/types/{preview → onchain/preview}/preview/detectCloseOrRepay.d.ts +1 -1
  327. package/dist/types/{preview → onchain/preview}/preview/detectDelayedClaim.d.ts +8 -8
  328. package/dist/types/{preview → onchain/preview}/preview/detectDelayedOperation.d.ts +9 -9
  329. package/dist/types/{preview → onchain/preview}/preview/estimateClaimableAt.d.ts +6 -6
  330. package/dist/types/{preview → onchain/preview}/preview/index.d.ts +3 -4
  331. package/dist/types/onchain/preview/preview/previewAdjustStrategyPosition.d.ts +20 -0
  332. package/dist/types/onchain/preview/preview/previewExitOrRepayStrategyPosition.d.ts +21 -0
  333. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +14 -0
  334. package/dist/types/onchain/preview/preview/previewOperation.d.ts +32 -0
  335. package/dist/types/onchain/preview/preview/previewPoolPositionOperation.d.ts +13 -0
  336. package/dist/types/{preview → onchain/preview}/preview/replayInnerOperations.d.ts +11 -11
  337. package/dist/types/{preview → onchain/preview}/preview/replayMulticall.d.ts +10 -10
  338. package/dist/types/{preview → onchain/preview}/preview/unwrapNativeCollateral.d.ts +10 -20
  339. package/dist/types/onchain/validation/bundles/checkAccountQuotas.d.ts +16 -0
  340. package/dist/types/onchain/validation/bundles/checkCollateralFunding.d.ts +22 -0
  341. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +31 -0
  342. package/dist/types/onchain/validation/bundles/checkDraw.d.ts +20 -0
  343. package/dist/types/onchain/validation/bundles/checkHealthFactors.d.ts +39 -0
  344. package/dist/types/onchain/validation/bundles/checkLiquidationEligibility.d.ts +20 -0
  345. package/dist/types/onchain/validation/bundles/checkLiquidationFunding.d.ts +18 -0
  346. package/dist/types/onchain/validation/bundles/checkMarket.d.ts +15 -0
  347. package/dist/types/onchain/validation/bundles/checkObtained.d.ts +9 -0
  348. package/dist/types/onchain/validation/bundles/checkPoolFunding.d.ts +19 -0
  349. package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +31 -0
  350. package/dist/types/onchain/validation/bundles/checkQuotasAsked.d.ts +10 -0
  351. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +21 -0
  352. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +19 -0
  353. package/dist/types/onchain/validation/bundles/checkWallet.d.ts +23 -0
  354. package/dist/types/onchain/validation/bundles/checkWalletAllowance.d.ts +18 -0
  355. package/dist/types/onchain/validation/bundles/checkWalletBalance.d.ts +17 -0
  356. package/dist/types/onchain/validation/bundles/index.d.ts +18 -0
  357. package/dist/types/onchain/validation/checkLiquidation.d.ts +23 -0
  358. package/dist/types/onchain/validation/checkOperation.d.ts +32 -0
  359. package/dist/types/onchain/validation/checkSimulation.d.ts +56 -0
  360. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +21 -0
  361. package/dist/types/onchain/validation/checks/checkCollateralised.d.ts +25 -0
  362. package/dist/types/onchain/validation/checks/checkCreditAccountFrozen.d.ts +12 -0
  363. package/dist/types/onchain/validation/checks/checkCreditManagerPaused.d.ts +12 -0
  364. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +21 -0
  365. package/dist/types/onchain/validation/checks/checkEmergencyLiquidator.d.ts +17 -0
  366. package/dist/types/onchain/validation/checks/checkForbiddenToken.d.ts +12 -0
  367. package/dist/types/onchain/validation/checks/checkLeverage.d.ts +12 -0
  368. package/dist/types/onchain/validation/checks/checkLiquidatorEligible.d.ts +13 -0
  369. package/dist/types/onchain/validation/checks/checkMarketExpired.d.ts +14 -0
  370. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +20 -0
  371. package/dist/types/onchain/validation/checks/checkPoolPaused.d.ts +12 -0
  372. package/dist/types/onchain/validation/checks/checkPoolSunset.d.ts +13 -0
  373. package/dist/types/onchain/validation/checks/checkQuotaCount.d.ts +11 -0
  374. package/dist/types/onchain/validation/checks/checkQuotaLimit.d.ts +18 -0
  375. package/dist/types/onchain/validation/checks/index.d.ts +16 -0
  376. package/dist/types/onchain/validation/helpers/amount.d.ts +7 -0
  377. package/dist/types/onchain/validation/helpers/health-factor-limits.d.ts +21 -0
  378. package/dist/types/onchain/validation/helpers/index.d.ts +4 -0
  379. package/dist/types/onchain/validation/{token.d.ts → helpers/token.d.ts} +4 -4
  380. package/dist/types/onchain/validation/index.d.ts +43 -4
  381. package/dist/types/onchain/validation/raise.d.ts +33 -0
  382. package/dist/types/sdk/execute/types.d.ts +2 -2
  383. package/dist/types/sdk/index.d.ts +5 -6
  384. package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -0
  385. package/dist/types/sdk/liquidations/types.d.ts +8 -0
  386. package/dist/types/sdk/prepare/PrepareApi.d.ts +6 -5
  387. package/dist/types/sdk/prepare/index.d.ts +5 -5
  388. package/dist/types/sdk/prepare/types.d.ts +65 -23
  389. package/dist/types/sdk/preview/PreviewNamespace.d.ts +13 -3
  390. package/dist/types/sdk/preview/index.d.ts +2 -2
  391. package/dist/types/sdk/preview/types.d.ts +30 -7
  392. package/package.json +1 -6
  393. package/dist/cjs/onchain/accounts/withdrawal-compressor/errors.js +0 -1
  394. package/dist/cjs/onchain/market/zapper/errors.js +0 -1
  395. package/dist/cjs/onchain/validation/checks.js +0 -258
  396. package/dist/cjs/onchain/validation/refusal.js +0 -39
  397. package/dist/cjs/preview/index.js +0 -86
  398. package/dist/cjs/preview/package.json +0 -1
  399. package/dist/cjs/preview/parse/errors.js +0 -1
  400. package/dist/cjs/preview/parse/index.js +0 -15
  401. package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +0 -38
  402. package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +0 -52
  403. package/dist/cjs/preview/prerequisites/Prerequisite.js +0 -52
  404. package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -53
  405. package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +0 -63
  406. package/dist/cjs/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -19
  407. package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +0 -76
  408. package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +0 -39
  409. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +0 -74
  410. package/dist/cjs/preview/prerequisites/helpers.js +0 -23
  411. package/dist/cjs/preview/prerequisites/index.js +0 -12
  412. package/dist/cjs/preview/preview/errors.js +0 -85
  413. package/dist/cjs/preview/preview/index.js +0 -33
  414. package/dist/cjs/preview/preview/previewOpenStrategyPosition.js +0 -50
  415. package/dist/cjs/preview/preview/previewOperation.js +0 -100
  416. package/dist/cjs/preview/preview/previewPoolPositionOperation.js +0 -49
  417. package/dist/cjs/preview/preview/replayInnerOperations.js +0 -109
  418. package/dist/cjs/preview/preview/replayMulticall.js +0 -19
  419. package/dist/cjs/preview/simulate/errors.js +0 -73
  420. package/dist/cjs/preview/simulate/index.js +0 -11
  421. package/dist/cjs/preview/simulate/simulateFacadeOperation.js +0 -15
  422. package/dist/cjs/preview/simulate/simulateOperation.js +0 -29
  423. package/dist/cjs/preview/simulate/simulateRWAOperation.js +0 -15
  424. package/dist/cjs/preview/simulate/types.js +0 -1
  425. package/dist/cjs/preview/trace/index.js +0 -14
  426. package/dist/cjs/preview/trace/types.js +0 -1
  427. package/dist/cjs/preview/types.js +0 -1
  428. package/dist/cjs/preview/validate/checkOperation.js +0 -187
  429. package/dist/cjs/preview/validate/checkSimulation.js +0 -39
  430. package/dist/cjs/preview/validate/index.js +0 -8
  431. package/dist/cjs/sdk/prepare/errors.js +0 -93
  432. package/dist/esm/onchain/accounts/withdrawal-compressor/errors.js +0 -1
  433. package/dist/esm/onchain/market/zapper/errors.js +0 -1
  434. package/dist/esm/onchain/validation/checks.js +0 -238
  435. package/dist/esm/onchain/validation/refusal.js +0 -36
  436. package/dist/esm/preview/index.js +0 -38
  437. package/dist/esm/preview/package.json +0 -1
  438. package/dist/esm/preview/parse/errors.js +0 -1
  439. package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +0 -37
  440. package/dist/esm/preview/prerequisites/BalancePrerequisite.js +0 -51
  441. package/dist/esm/preview/prerequisites/Prerequisite.js +0 -51
  442. package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -52
  443. package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +0 -62
  444. package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -18
  445. package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +0 -75
  446. package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +0 -38
  447. package/dist/esm/preview/prerequisites/checkPrerequisites.js +0 -73
  448. package/dist/esm/preview/prerequisites/helpers.js +0 -22
  449. package/dist/esm/preview/prerequisites/index.js +0 -7
  450. package/dist/esm/preview/preview/errors.js +0 -79
  451. package/dist/esm/preview/preview/previewPoolPositionOperation.js +0 -48
  452. package/dist/esm/preview/preview/replayInnerOperations.js +0 -107
  453. package/dist/esm/preview/preview/replayMulticall.js +0 -18
  454. package/dist/esm/preview/simulate/errors.js +0 -71
  455. package/dist/esm/preview/simulate/index.js +0 -6
  456. package/dist/esm/preview/simulate/simulateFacadeOperation.js +0 -14
  457. package/dist/esm/preview/simulate/simulateOperation.js +0 -28
  458. package/dist/esm/preview/simulate/simulateRWAOperation.js +0 -14
  459. package/dist/esm/preview/simulate/types.js +0 -1
  460. package/dist/esm/preview/trace/types.js +0 -1
  461. package/dist/esm/preview/types.js +0 -1
  462. package/dist/esm/preview/validate/checkOperation.js +0 -183
  463. package/dist/esm/preview/validate/checkSimulation.js +0 -38
  464. package/dist/esm/preview/validate/index.js +0 -3
  465. package/dist/esm/sdk/prepare/errors.js +0 -89
  466. package/dist/types/model/errors.d.ts +0 -46
  467. package/dist/types/onchain/accounts/withdrawal-compressor/errors.d.ts +0 -20
  468. package/dist/types/onchain/market/zapper/errors.d.ts +0 -18
  469. package/dist/types/onchain/validation/checks.d.ts +0 -164
  470. package/dist/types/onchain/validation/refusal.d.ts +0 -242
  471. package/dist/types/preview/index.d.ts +0 -47
  472. package/dist/types/preview/parse/errors.d.ts +0 -29
  473. package/dist/types/preview/parse/parseOperationCalldata.d.ts +0 -18
  474. package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +0 -26
  475. package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +0 -29
  476. package/dist/types/preview/prerequisites/Prerequisite.d.ts +0 -26
  477. package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +0 -55
  478. package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +0 -20
  479. package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +0 -12
  480. package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +0 -12
  481. package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +0 -26
  482. package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +0 -28
  483. package/dist/types/preview/prerequisites/helpers.d.ts +0 -10
  484. package/dist/types/preview/prerequisites/index.d.ts +0 -7
  485. package/dist/types/preview/prerequisites/types.d.ts +0 -53
  486. package/dist/types/preview/preview/errors.d.ts +0 -44
  487. package/dist/types/preview/preview/previewAdjustStrategyPosition.d.ts +0 -19
  488. package/dist/types/preview/preview/previewExitOrRepayStrategyPosition.d.ts +0 -18
  489. package/dist/types/preview/preview/previewOpenStrategyPosition.d.ts +0 -12
  490. package/dist/types/preview/preview/previewOperation.d.ts +0 -32
  491. package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +0 -13
  492. package/dist/types/preview/simulate/errors.d.ts +0 -52
  493. package/dist/types/preview/simulate/index.d.ts +0 -7
  494. package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -16
  495. package/dist/types/preview/simulate/simulateOperation.d.ts +0 -12
  496. package/dist/types/preview/simulate/simulatePoolOperation.d.ts +0 -42
  497. package/dist/types/preview/simulate/simulateRWAOperation.d.ts +0 -16
  498. package/dist/types/preview/simulate/types.d.ts +0 -48
  499. package/dist/types/preview/types.d.ts +0 -65
  500. package/dist/types/preview/validate/checkOperation.d.ts +0 -71
  501. package/dist/types/preview/validate/checkSimulation.d.ts +0 -32
  502. package/dist/types/preview/validate/index.d.ts +0 -3
  503. package/dist/types/sdk/prepare/errors.d.ts +0 -319
  504. /package/dist/cjs/{preview/prerequisites → history/trace}/types.js +0 -0
  505. /package/dist/cjs/model/{errors.js → errors/base.js} +0 -0
  506. /package/dist/cjs/{preview → onchain/preview}/parse/types-adapters.js +0 -0
  507. /package/dist/cjs/{preview → onchain/preview}/parse/types-facades.js +0 -0
  508. /package/dist/cjs/{preview → onchain/preview}/parse/types-pools.js +0 -0
  509. /package/dist/cjs/{preview → onchain/preview}/parse/types-rwa.js +0 -0
  510. /package/dist/esm/{preview → history}/trace/index.js +0 -0
  511. /package/dist/esm/{preview/prerequisites → history/trace}/types.js +0 -0
  512. /package/dist/esm/model/{errors.js → errors/base.js} +0 -0
  513. /package/dist/esm/{preview → onchain/preview}/parse/types-adapters.js +0 -0
  514. /package/dist/esm/{preview → onchain/preview}/parse/types-facades.js +0 -0
  515. /package/dist/esm/{preview → onchain/preview}/parse/types-pools.js +0 -0
  516. /package/dist/esm/{preview → onchain/preview}/parse/types-rwa.js +0 -0
  517. /package/dist/types/{preview → history}/trace/index.d.ts +0 -0
@@ -0,0 +1,18 @@
1
+ import { checkAccountQuotas } from "./checkAccountQuotas.js";
2
+ import { CheckWalletInput, WalletFundingError, checkWallet } from "./checkWallet.js";
3
+ import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralFunding } from "./checkCollateralFunding.js";
4
+ import { HealthFactorThresholds, WeighedFactors, checkHealthFactors } from "./checkHealthFactors.js";
5
+ import { MarketStateError, checkMarket } from "./checkMarket.js";
6
+ import { CreditOperationArgs, CreditOperationError, CreditOperationPreview, checkCreditOperation } from "./checkCreditOperation.js";
7
+ import { checkDraw } from "./checkDraw.js";
8
+ import { CheckLiquidationEligibilityInput, LiquidationEligibilityError, checkLiquidationEligibility } from "./checkLiquidationEligibility.js";
9
+ import { CheckLiquidationFundingInput, checkLiquidationFunding } from "./checkLiquidationFunding.js";
10
+ import { checkObtained } from "./checkObtained.js";
11
+ import { CheckPoolFundingInput, checkPoolFunding } from "./checkPoolFunding.js";
12
+ import { PoolOperationArgs, PoolOperationError, checkPoolOperation } from "./checkPoolOperation.js";
13
+ import { checkQuotasAsked } from "./checkQuotasAsked.js";
14
+ import { CheckRWAOpeningInput, checkRWAOpening } from "./checkRWAOpening.js";
15
+ import { CheckRWAOpenRequirementsInput, checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
16
+ import { CheckWalletAllowanceInput, checkWalletAllowance } from "./checkWalletAllowance.js";
17
+ import { CheckWalletBalanceInput, checkWalletBalance } from "./checkWalletBalance.js";
18
+ export { CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CreditOperationArgs, CreditOperationError, CreditOperationPreview, HealthFactorThresholds, LiquidationEligibilityError, MarketStateError, PoolOperationArgs, PoolOperationError, WalletFundingError, WeighedFactors, checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkDraw, checkHealthFactors, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkObtained, checkPoolFunding, checkPoolOperation, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
@@ -0,0 +1,23 @@
1
+ import { LiquidationDetails } from "../../model/liquidations.js";
2
+ import "../../model/index.js";
3
+ import { OnchainSDK } from "../OnchainSDK.js";
4
+ import { WalletFundingError } from "./bundles/checkWallet.js";
5
+ import { LiquidationEligibilityError } from "./bundles/checkLiquidationEligibility.js";
6
+ import { Address } from "viem";
7
+ //#region src/onchain/validation/checkLiquidation.d.ts
8
+ interface CheckLiquidationInput {
9
+ details: LiquidationDetails;
10
+ liquidator: Address;
11
+ }
12
+ interface CheckLiquidationOptions {
13
+ /** Block to read at; defaults to latest. Only set for testnet forks. */
14
+ blockNumber?: bigint;
15
+ }
16
+ /** {@inheritDoc checkLiquidation} */
17
+ type LiquidationValidationError = LiquidationEligibilityError | WalletFundingError;
18
+ /**
19
+ * Whether `liquidator` may send a full liquidation of this account
20
+ */
21
+ declare function checkLiquidation(sdk: OnchainSDK, input: CheckLiquidationInput, options?: CheckLiquidationOptions): Promise<LiquidationValidationError[]>;
22
+ //#endregion
23
+ export { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError, checkLiquidation };
@@ -0,0 +1,32 @@
1
+ import { OperationPreview } from "../../model/previews.js";
2
+ import "../../model/index.js";
3
+ import { OnchainSDK } from "../OnchainSDK.js";
4
+ import { WalletFundingError } from "./bundles/checkWallet.js";
5
+ import { HealthFactorThresholds } from "./bundles/checkHealthFactors.js";
6
+ import { CreditOperationError } from "./bundles/checkCreditOperation.js";
7
+ import { PoolOperationError } from "./bundles/checkPoolOperation.js";
8
+ import { Address } from "viem";
9
+ //#region src/onchain/validation/checkOperation.d.ts
10
+ interface CheckOperationOptions extends HealthFactorThresholds {
11
+ /** Block to read at; defaults to latest. Only set for testnet forks. */
12
+ blockNumber?: bigint;
13
+ }
14
+ interface CheckOperationInput {
15
+ sdk: OnchainSDK;
16
+ preview: OperationPreview;
17
+ /** The wallet that signs. Its allowances, balances and RWA standing are read on-chain. */
18
+ sender: Address;
19
+ }
20
+ /** {@inheritDoc checkOperation} */
21
+ type OperationValidationError = CreditOperationError | PoolOperationError | WalletFundingError;
22
+ /**
23
+ * Whether a parsed operation may be signed by `sender`: protocol state first,
24
+ * then what the wallet has to approve, hold or sign.
25
+ *
26
+ * The array is in check order, most fundamental first, so a caller with room
27
+ * for one verdict reports the first entry. Approve and sign errors are picked
28
+ * out by `code`, not by position.
29
+ */
30
+ declare function checkOperation(input: CheckOperationInput, options?: CheckOperationOptions): Promise<OperationValidationError[]>;
31
+ //#endregion
32
+ export { CheckOperationInput, CheckOperationOptions, OperationValidationError, checkOperation };
@@ -0,0 +1,56 @@
1
+ import { ChainId } from "../../model/primitives.js";
2
+ import { DebtOutOfRangeError, InsufficientCollateralError, QuotaCountExceededError } from "../../model/errors/operation-errors.js";
3
+ import "../../model/index.js";
4
+ import { PoolSimulation } from "../pools/types.js";
5
+ import { OnchainSDK } from "../OnchainSDK.js";
6
+ import { OperationState } from "../accounts/intents/types.js";
7
+ import { HealthFactorThresholds } from "./bundles/checkHealthFactors.js";
8
+ import { MarketStateError } from "./bundles/checkMarket.js";
9
+ import { PoolOperationError } from "./bundles/checkPoolOperation.js";
10
+ import { Address } from "viem";
11
+ //#region src/onchain/validation/checkSimulation.d.ts
12
+ /** A simulated credit operation, as the intents engine reports one. */
13
+ interface CreditSimulationInput {
14
+ chainId: ChainId;
15
+ state: OperationState;
16
+ }
17
+ /**
18
+ * A simulated pool operation. The pool comes alongside the state, which names
19
+ * the tokens moving through it but not the market they belong to.
20
+ */
21
+ interface PoolSimulationInput {
22
+ chainId: ChainId;
23
+ pool: Address;
24
+ state: PoolSimulation;
25
+ /** Whether the operation puts liquidity in rather than taking it out. */
26
+ isDeposit: boolean;
27
+ }
28
+ type CheckSimulationInput = CreditSimulationInput | PoolSimulationInput;
29
+ /** {@inheritDoc checkSimulation} */
30
+ type SimulationValidationError = MarketStateError | DebtOutOfRangeError | QuotaCountExceededError | InsufficientCollateralError | PoolOperationError;
31
+ /**
32
+ * Whether a simulated operation clears the caller's own thresholds.
33
+ *
34
+ * The engine holds an account to the facade's `1.0`, because its guards answer
35
+ * "would this revert". A form is wiser to ask for more, and the engine's own
36
+ * note says so — a caller wanting the stricter threshold applies it itself.
37
+ * This is that second opinion, over the numbers the engine already reported.
38
+ *
39
+ * Three of the checks on a credit account the engine does not make at all:
40
+ * both health-factor thresholds are its own `1.0`, and the quota count it never
41
+ * weighs. The other two run against the same numbers the engine used, and are
42
+ * here so that a change in the engine cannot pass silently.
43
+ *
44
+ * What is deliberately absent: the forbidden-token, quota-limit and funding
45
+ * checks all need the *delta* an operation applies, and `OperationState` reports
46
+ * only the state after it. Weighing them against absolutes would stop a
47
+ * forbidden token the account merely holds, or a quota the operation never
48
+ * touched. The engine performed all three during the walk, so a simulation that
49
+ * came back `ok` has already passed them.
50
+ *
51
+ * A pool operation has no account to weigh, so what is left is the pool's own
52
+ * state — which the engine does not read either.
53
+ */
54
+ declare function checkSimulation(sdk: OnchainSDK, input: CheckSimulationInput, options?: HealthFactorThresholds): SimulationValidationError[];
55
+ //#endregion
56
+ export { CheckSimulationInput, CreditSimulationInput, PoolSimulationInput, SimulationValidationError, checkSimulation };
@@ -0,0 +1,21 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { BorrowLimitCause, InsufficientPoolLiquidityError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkBorrowLimit.d.ts
5
+ interface BorrowLimitArgs {
6
+ requested: bigint;
7
+ available: bigint;
8
+ limit: BorrowLimitCause;
9
+ underlying: Token;
10
+ maxBorrowAmount?: bigint;
11
+ }
12
+ /**
13
+ * What the pool will hand over, against what is asked for.
14
+ *
15
+ * `available` and `limit` are the caller's reading of which limit is in the
16
+ * way; this check only compares. `maxBorrowAmount` is the largest debt still
17
+ * takeable, left out when none is.
18
+ */
19
+ declare function checkBorrowLimit(args: BorrowLimitArgs): InsufficientPoolLiquidityError[];
20
+ //#endregion
21
+ export { BorrowLimitArgs, checkBorrowLimit };
@@ -0,0 +1,25 @@
1
+ import { Bps } from "../../../model/primitives.js";
2
+ import { InsufficientCollateralError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkCollateralised.d.ts
5
+ interface CollateralisedArgs {
6
+ healthFactor: Bps | undefined;
7
+ /** The lowest acceptable factor — a factor equal to it passes. */
8
+ healthFactorThreshold: Bps;
9
+ safePrices: boolean;
10
+ /**
11
+ * The factor the account stands at now. Given, an operation that raises it
12
+ * passes even from under the required factor: an account already below is
13
+ * rescued by exactly the top-ups a flat threshold would refuse.
14
+ */
15
+ improvesFrom?: Bps;
16
+ }
17
+ /**
18
+ * The account against its debt, at whichever threshold the caller holds it to.
19
+ *
20
+ * An unread factor counts as failing: a check that cannot see the number is
21
+ * not evidence that the number is fine.
22
+ */
23
+ declare function checkCollateralised(args: CollateralisedArgs): InsufficientCollateralError[];
24
+ //#endregion
25
+ export { CollateralisedArgs, checkCollateralised };
@@ -0,0 +1,12 @@
1
+ import { CreditAccountFrozenError } from "../../../model/errors/liquidation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkCreditAccountFrozen.d.ts
5
+ interface CreditAccountFrozenArgs {
6
+ frozen: boolean;
7
+ creditAccount: Address;
8
+ }
9
+ /** An RWA factory freeze stops the account's collateral from moving. */
10
+ declare function checkCreditAccountFrozen(args: CreditAccountFrozenArgs): CreditAccountFrozenError[];
11
+ //#endregion
12
+ export { CreditAccountFrozenArgs, checkCreditAccountFrozen };
@@ -0,0 +1,12 @@
1
+ import { CreditManagerPausedError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkCreditManagerPaused.d.ts
5
+ interface CreditManagerPausedArgs {
6
+ isPaused: boolean;
7
+ creditManager: Address;
8
+ }
9
+ /** The credit manager takes no multicall while it is paused. */
10
+ declare function checkCreditManagerPaused(args: CreditManagerPausedArgs): CreditManagerPausedError[];
11
+ //#endregion
12
+ export { CreditManagerPausedArgs, checkCreditManagerPaused };
@@ -0,0 +1,21 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { DebtOutOfRangeError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkDebtLimits.d.ts
5
+ interface DebtLimitsArgs {
6
+ debt: bigint;
7
+ minDebt: bigint;
8
+ maxDebt: bigint;
9
+ underlying: Token;
10
+ /**
11
+ * Whether ending with no loan at all is acceptable. The one place the two
12
+ * callers genuinely disagree: an account being adjusted may end owing
13
+ * nothing, while one being opened may not — so the exemption is stated
14
+ * rather than assumed.
15
+ */
16
+ allowZero: boolean;
17
+ }
18
+ /** A debt the facade would revert on. */
19
+ declare function checkDebtLimits(args: DebtLimitsArgs): DebtOutOfRangeError[];
20
+ //#endregion
21
+ export { DebtLimitsArgs, checkDebtLimits };
@@ -0,0 +1,17 @@
1
+ import { NotEmergencyLiquidatorError } from "../../../model/errors/liquidation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkEmergencyLiquidator.d.ts
5
+ interface EmergencyLiquidatorArgs {
6
+ paused: boolean;
7
+ isEmergencyLiquidator: boolean;
8
+ creditManager: Address;
9
+ liquidator: Address;
10
+ }
11
+ /**
12
+ * A paused market only accepts liquidations from its emergency liquidators.
13
+ * An unpaused market does not consult the list.
14
+ */
15
+ declare function checkEmergencyLiquidator(args: EmergencyLiquidatorArgs): NotEmergencyLiquidatorError[];
16
+ //#endregion
17
+ export { EmergencyLiquidatorArgs, checkEmergencyLiquidator };
@@ -0,0 +1,12 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { ForbiddenTokenError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkForbiddenToken.d.ts
5
+ interface ForbiddenTokenArgs {
6
+ token: Token;
7
+ isForbidden: boolean;
8
+ }
9
+ /** A token the market will not let the account hold more of. */
10
+ declare function checkForbiddenToken(args: ForbiddenTokenArgs): ForbiddenTokenError[];
11
+ //#endregion
12
+ export { ForbiddenTokenArgs, checkForbiddenToken };
@@ -0,0 +1,12 @@
1
+ import { LeverageOutOfRangeError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ //#region src/onchain/validation/checks/checkLeverage.d.ts
4
+ interface LeverageArgs {
5
+ /** Scaled by `LEVERAGE_DECIMALS` (`100n` = 1x), as the intent states it. */
6
+ leverage: bigint;
7
+ min: bigint;
8
+ }
9
+ /** Leverage below 1x is not a position, it is a withdrawal. */
10
+ declare function checkLeverage(args: LeverageArgs): LeverageOutOfRangeError[];
11
+ //#endregion
12
+ export { LeverageArgs, checkLeverage };
@@ -0,0 +1,13 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { LiquidatorNotEligibleError } from "../../../model/errors/liquidation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkLiquidatorEligible.d.ts
5
+ interface LiquidatorEligibleArgs {
6
+ eligible: boolean;
7
+ kycProtocol?: string;
8
+ kycToken?: Token;
9
+ }
10
+ /** The compressor's KYC check of this wallet against the liquidated assets. */
11
+ declare function checkLiquidatorEligible(args: LiquidatorEligibleArgs): LiquidatorNotEligibleError[];
12
+ //#endregion
13
+ export { LiquidatorEligibleArgs, checkLiquidatorEligible };
@@ -0,0 +1,14 @@
1
+ import { MarketExpiredError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkMarketExpired.d.ts
5
+ interface MarketExpiredArgs {
6
+ isExpired: boolean;
7
+ creditManager: Address;
8
+ /** Unix seconds, as the facade reports it. */
9
+ expirationDate: number;
10
+ }
11
+ /** Past its expiration date the facade takes no more multicalls. */
12
+ declare function checkMarketExpired(args: MarketExpiredArgs): MarketExpiredError[];
13
+ //#endregion
14
+ export { MarketExpiredArgs, checkMarketExpired };
@@ -0,0 +1,20 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { InsufficientPoolLiquidityError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkPoolLiquidity.d.ts
5
+ interface PoolLiquidityArgs {
6
+ requested: bigint;
7
+ available: bigint;
8
+ underlying: Token;
9
+ }
10
+ /**
11
+ * What the pool holds, against what is being taken out of it.
12
+ *
13
+ * The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
14
+ * asked for still cannot serve it, so equality is already a refusal. That is
15
+ * the rule the legacy withdrawal validator enforced and it is preserved to the
16
+ * unit.
17
+ */
18
+ declare function checkPoolLiquidity(args: PoolLiquidityArgs): InsufficientPoolLiquidityError[];
19
+ //#endregion
20
+ export { PoolLiquidityArgs, checkPoolLiquidity };
@@ -0,0 +1,12 @@
1
+ import { PoolPausedError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkPoolPaused.d.ts
5
+ interface PoolPausedArgs {
6
+ isPaused: boolean;
7
+ pool: Address;
8
+ }
9
+ /** A paused pool neither takes deposits nor serves withdrawals. */
10
+ declare function checkPoolPaused(args: PoolPausedArgs): PoolPausedError[];
11
+ //#endregion
12
+ export { PoolPausedArgs, checkPoolPaused };
@@ -0,0 +1,13 @@
1
+ import { PoolSunsetError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ import { Address } from "viem";
4
+ //#region src/onchain/validation/checks/checkPoolSunset.d.ts
5
+ interface PoolSunsetArgs {
6
+ isSunset: boolean;
7
+ isDeposit: boolean;
8
+ pool: Address;
9
+ }
10
+ /** A pool winding down still serves withdrawals, so only what puts money in is refused. */
11
+ declare function checkPoolSunset(args: PoolSunsetArgs): PoolSunsetError[];
12
+ //#endregion
13
+ export { PoolSunsetArgs, checkPoolSunset };
@@ -0,0 +1,11 @@
1
+ import { QuotaCountExceededError } from "../../../model/errors/operation-errors.js";
2
+ import "../../../model/index.js";
3
+ //#region src/onchain/validation/checks/checkQuotaCount.d.ts
4
+ interface QuotaCountArgs {
5
+ count: number;
6
+ max: number;
7
+ }
8
+ /** How many quoted tokens the facade enables at once. */
9
+ declare function checkQuotaCount(args: QuotaCountArgs): QuotaCountExceededError[];
10
+ //#endregion
11
+ export { QuotaCountArgs, checkQuotaCount };
@@ -0,0 +1,18 @@
1
+ import { Token } from "../../../model/primitives.js";
2
+ import { QuotaLimitReachedError } from "../../../model/errors/operation-errors.js";
3
+ import "../../../model/index.js";
4
+ //#region src/onchain/validation/checks/checkQuotaLimit.d.ts
5
+ interface QuotaLimitArgs {
6
+ token: Token;
7
+ /**
8
+ * Absent for a token the market opened no quota for at all — nothing is
9
+ * weighed against a limit, the token simply counts as no collateral.
10
+ */
11
+ requested: bigint | undefined;
12
+ available: bigint;
13
+ underlying: Token;
14
+ }
15
+ /** The room the keeper still has for a token's quota, in the underlying. */
16
+ declare function checkQuotaLimit(args: QuotaLimitArgs): QuotaLimitReachedError[];
17
+ //#endregion
18
+ export { QuotaLimitArgs, checkQuotaLimit };
@@ -0,0 +1,16 @@
1
+ import { BorrowLimitArgs, checkBorrowLimit } from "./checkBorrowLimit.js";
2
+ import { CollateralisedArgs, checkCollateralised } from "./checkCollateralised.js";
3
+ import { CreditAccountFrozenArgs, checkCreditAccountFrozen } from "./checkCreditAccountFrozen.js";
4
+ import { CreditManagerPausedArgs, checkCreditManagerPaused } from "./checkCreditManagerPaused.js";
5
+ import { DebtLimitsArgs, checkDebtLimits } from "./checkDebtLimits.js";
6
+ import { EmergencyLiquidatorArgs, checkEmergencyLiquidator } from "./checkEmergencyLiquidator.js";
7
+ import { ForbiddenTokenArgs, checkForbiddenToken } from "./checkForbiddenToken.js";
8
+ import { LeverageArgs, checkLeverage } from "./checkLeverage.js";
9
+ import { LiquidatorEligibleArgs, checkLiquidatorEligible } from "./checkLiquidatorEligible.js";
10
+ import { MarketExpiredArgs, checkMarketExpired } from "./checkMarketExpired.js";
11
+ import { PoolLiquidityArgs, checkPoolLiquidity } from "./checkPoolLiquidity.js";
12
+ import { PoolPausedArgs, checkPoolPaused } from "./checkPoolPaused.js";
13
+ import { PoolSunsetArgs, checkPoolSunset } from "./checkPoolSunset.js";
14
+ import { QuotaCountArgs, checkQuotaCount } from "./checkQuotaCount.js";
15
+ import { QuotaLimitArgs, checkQuotaLimit } from "./checkQuotaLimit.js";
16
+ export { BorrowLimitArgs, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, LeverageArgs, LiquidatorEligibleArgs, MarketExpiredArgs, PoolLiquidityArgs, PoolPausedArgs, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, checkBorrowLimit, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkLeverage, checkLiquidatorEligible, checkMarketExpired, checkPoolLiquidity, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit };
@@ -0,0 +1,7 @@
1
+ import { Token, TokenAmount } from "../../../model/primitives.js";
2
+ import "../../../model/index.js";
3
+ //#region src/onchain/validation/helpers/amount.d.ts
4
+ /** A check names what a limit was measured in, never what it is worth. */
5
+ declare function amountOf(token: Token, value: bigint): TokenAmount;
6
+ //#endregion
7
+ export { amountOf };
@@ -0,0 +1,21 @@
1
+ //#region src/onchain/validation/helpers/health-factor-limits.d.ts
2
+ /**
3
+ * The health-factor thresholds this codebase holds an account to.
4
+ *
5
+ * They are deliberately different numbers for different jobs: the facade's is
6
+ * what a transaction must clear to land, a form's is what makes a position
7
+ * worth signing, and a sizing helper leaves a margin above both.
8
+ **/
9
+ /** A factor at or below this is refused; kept for the callers that size on it. */
10
+ declare const MIN_HF_LIMITED = 10100n;
11
+ /** The same threshold as a `required` argument — the lowest factor that passes. */
12
+ declare const MIN_HEALTH_FACTOR_FORM = 10101;
13
+ /** The threshold the facade itself enforces: an account may end exactly at 1.0. */
14
+ declare const MIN_HEALTH_FACTOR_FACADE = 10000;
15
+ /**
16
+ * The safe-price threshold a form holds an account to. A step above the
17
+ * facade's, because a factor of exactly 1.0 at safe prices is already refused.
18
+ **/
19
+ declare const MIN_SAFE_HEALTH_FACTOR_FORM = 10001;
20
+ //#endregion
21
+ export { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM };
@@ -0,0 +1,4 @@
1
+ import { amountOf } from "./amount.js";
2
+ import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./health-factor-limits.js";
3
+ import { toToken, toTokenAmount } from "./token.js";
4
+ export { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, amountOf, toToken, toTokenAmount };
@@ -1,8 +1,8 @@
1
- import { Token, TokenAmount } from "../../model/primitives.js";
2
- import "../../model/index.js";
3
- import { OnchainSDK } from "../OnchainSDK.js";
1
+ import { Token, TokenAmount } from "../../../model/primitives.js";
2
+ import "../../../model/index.js";
3
+ import { OnchainSDK } from "../../OnchainSDK.js";
4
4
  import { Address } from "viem";
5
- //#region src/onchain/validation/token.d.ts
5
+ //#region src/onchain/validation/helpers/token.d.ts
6
6
  /**
7
7
  * The token behind an address, for the refusal details that inline one.
8
8
  *
@@ -1,4 +1,43 @@
1
- import { BorrowLimitBinding, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "./refusal.js";
2
- import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, amountOf, checkBorrowLimit, checkCollateralised, checkCreditManagerPaused, checkDebtInBand, checkForbiddenToken, checkFunding, checkLeverageAtLeastOne, checkMarketExpired, checkPoolPaused, checkPoolPayout, checkPoolSunset, checkPreviewError, checkQuotaCount, checkQuotaLimit, isMalformedPreviewError } from "./checks.js";
3
- import { toToken, toTokenAmount } from "./token.js";
4
- export { type BorrowLimitBinding, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, type PreviewErrorDetails, type PreviewErrorReason, type PreviewIssue, type PreviewRefusal, amountOf, checkBorrowLimit, checkCollateralised, checkCreditManagerPaused, checkDebtInBand, checkForbiddenToken, checkFunding, checkLeverageAtLeastOne, checkMarketExpired, checkPoolPaused, checkPoolPayout, checkPoolSunset, checkPreviewError, checkQuotaCount, checkQuotaLimit, isMalformedPreviewError, raise, refuse, toToken, toTokenAmount };
1
+ import { IntentValidationError, raise } from "./raise.js";
2
+ import { checkAccountQuotas } from "./bundles/checkAccountQuotas.js";
3
+ import { CheckWalletInput, WalletFundingError, checkWallet } from "./bundles/checkWallet.js";
4
+ import { CheckCollateralFundingInput, CollateralFundingPreview, checkCollateralFunding } from "./bundles/checkCollateralFunding.js";
5
+ import { HealthFactorThresholds, WeighedFactors, checkHealthFactors } from "./bundles/checkHealthFactors.js";
6
+ import { MarketStateError, checkMarket } from "./bundles/checkMarket.js";
7
+ import { CreditOperationArgs, CreditOperationError, CreditOperationPreview, checkCreditOperation } from "./bundles/checkCreditOperation.js";
8
+ import { checkDraw } from "./bundles/checkDraw.js";
9
+ import { CheckLiquidationEligibilityInput, LiquidationEligibilityError, checkLiquidationEligibility } from "./bundles/checkLiquidationEligibility.js";
10
+ import { CheckLiquidationFundingInput, checkLiquidationFunding } from "./bundles/checkLiquidationFunding.js";
11
+ import { checkObtained } from "./bundles/checkObtained.js";
12
+ import { CheckPoolFundingInput, checkPoolFunding } from "./bundles/checkPoolFunding.js";
13
+ import { PoolOperationArgs, PoolOperationError, checkPoolOperation } from "./bundles/checkPoolOperation.js";
14
+ import { checkQuotasAsked } from "./bundles/checkQuotasAsked.js";
15
+ import { CheckRWAOpeningInput, checkRWAOpening } from "./bundles/checkRWAOpening.js";
16
+ import { CheckRWAOpenRequirementsInput, checkRWAOpenRequirements } from "./bundles/checkRWAOpenRequirements.js";
17
+ import { CheckWalletAllowanceInput, checkWalletAllowance } from "./bundles/checkWalletAllowance.js";
18
+ import { CheckWalletBalanceInput, checkWalletBalance } from "./bundles/checkWalletBalance.js";
19
+ import "./bundles/index.js";
20
+ import { CheckLiquidationInput, CheckLiquidationOptions, LiquidationValidationError, checkLiquidation } from "./checkLiquidation.js";
21
+ import { CheckOperationInput, CheckOperationOptions, OperationValidationError, checkOperation } from "./checkOperation.js";
22
+ import { CheckSimulationInput, CreditSimulationInput, PoolSimulationInput, SimulationValidationError, checkSimulation } from "./checkSimulation.js";
23
+ import { BorrowLimitArgs, checkBorrowLimit } from "./checks/checkBorrowLimit.js";
24
+ import { CollateralisedArgs, checkCollateralised } from "./checks/checkCollateralised.js";
25
+ import { CreditAccountFrozenArgs, checkCreditAccountFrozen } from "./checks/checkCreditAccountFrozen.js";
26
+ import { CreditManagerPausedArgs, checkCreditManagerPaused } from "./checks/checkCreditManagerPaused.js";
27
+ import { DebtLimitsArgs, checkDebtLimits } from "./checks/checkDebtLimits.js";
28
+ import { EmergencyLiquidatorArgs, checkEmergencyLiquidator } from "./checks/checkEmergencyLiquidator.js";
29
+ import { ForbiddenTokenArgs, checkForbiddenToken } from "./checks/checkForbiddenToken.js";
30
+ import { LeverageArgs, checkLeverage } from "./checks/checkLeverage.js";
31
+ import { LiquidatorEligibleArgs, checkLiquidatorEligible } from "./checks/checkLiquidatorEligible.js";
32
+ import { MarketExpiredArgs, checkMarketExpired } from "./checks/checkMarketExpired.js";
33
+ import { PoolLiquidityArgs, checkPoolLiquidity } from "./checks/checkPoolLiquidity.js";
34
+ import { PoolPausedArgs, checkPoolPaused } from "./checks/checkPoolPaused.js";
35
+ import { PoolSunsetArgs, checkPoolSunset } from "./checks/checkPoolSunset.js";
36
+ import { QuotaCountArgs, checkQuotaCount } from "./checks/checkQuotaCount.js";
37
+ import { QuotaLimitArgs, checkQuotaLimit } from "./checks/checkQuotaLimit.js";
38
+ import "./checks/index.js";
39
+ import { amountOf } from "./helpers/amount.js";
40
+ import { MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM } from "./helpers/health-factor-limits.js";
41
+ import { toToken, toTokenAmount } from "./helpers/token.js";
42
+ import "./helpers/index.js";
43
+ export { BorrowLimitArgs, CheckCollateralFundingInput, CheckLiquidationEligibilityInput, CheckLiquidationFundingInput, CheckLiquidationInput, CheckLiquidationOptions, CheckOperationInput, CheckOperationOptions, CheckPoolFundingInput, CheckRWAOpenRequirementsInput, CheckRWAOpeningInput, CheckSimulationInput, CheckWalletAllowanceInput, CheckWalletBalanceInput, CheckWalletInput, CollateralFundingPreview, CollateralisedArgs, CreditAccountFrozenArgs, CreditManagerPausedArgs, CreditOperationArgs, CreditOperationError, CreditOperationPreview, CreditSimulationInput, DebtLimitsArgs, EmergencyLiquidatorArgs, ForbiddenTokenArgs, HealthFactorThresholds, type IntentValidationError, LeverageArgs, LiquidationEligibilityError, LiquidationValidationError, LiquidatorEligibleArgs, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_SAFE_HEALTH_FACTOR_FORM, MarketExpiredArgs, MarketStateError, OperationValidationError, PoolLiquidityArgs, PoolOperationArgs, PoolOperationError, PoolPausedArgs, PoolSimulationInput, PoolSunsetArgs, QuotaCountArgs, QuotaLimitArgs, SimulationValidationError, WalletFundingError, WeighedFactors, amountOf, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, raise, toToken, toTokenAmount };
@@ -0,0 +1,33 @@
1
+ import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
2
+ import { MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
3
+ import "../../model/index.js";
4
+ //#region src/onchain/validation/raise.d.ts
5
+ /**
6
+ * What the intents engine can raise: unit-check errors it runs, plus the
7
+ * planning outcomes discovered mid-walk. Feeds prepare's per-method unions.
8
+ *
9
+ * Not a catch-all of every SDK error — pool paused/sunset is `checkOperation`'s,
10
+ * a malformed transaction is `previewOperation`'s, not the engine's.
11
+ **/
12
+ type IntentValidationError = CreditManagerPausedError | MarketExpiredError | InsufficientPoolLiquidityError | DebtOutOfRangeError | LeverageOutOfRangeError | InsufficientCollateralError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientBalanceError | UnsupportedCollateralTokenError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError | NoRecordedIntentError;
13
+ /**
14
+ * Engine-internal throw: planners and guards raise one error object, and the
15
+ * service boundary turns it into {@link SDKError}.
16
+ **/
17
+ declare class IntentPreviewError extends Error {
18
+ readonly error: IntentValidationError;
19
+ constructor(error: IntentValidationError, message?: string);
20
+ /** The same wrap the checks hand out, with an optional engine-side sentence. */
21
+ static of(error: IntentValidationError, message?: string): IntentPreviewError;
22
+ }
23
+ /**
24
+ * Throws the first error a check found, with the sentence the engine logs for
25
+ * it. An empty array is a pass.
26
+ *
27
+ * Returns normally when there is nothing to raise, so it cannot narrow a type
28
+ * the way a bare `throw` does — a site that guards a value for the code below
29
+ * it keeps throwing directly.
30
+ **/
31
+ declare function raise(errors: readonly IntentValidationError[], message: string): void;
32
+ //#endregion
33
+ export { IntentPreviewError, IntentValidationError, raise };
@@ -1,8 +1,8 @@
1
1
  import { ChainId } from "../../model/primitives.js";
2
+ import { SecuritizeRegisterMessage } from "../../model/rwa.js";
2
3
  import { SDKResult } from "../../model/result.js";
3
4
  import "../../model/index.js";
4
5
  import { Asset } from "../../onchain/base/types.js";
5
- import { SecuritizeRegisterMessage } from "../../onchain/market/rwa/securitize/types.js";
6
6
  import { RawTx } from "../../onchain/types/transactions.js";
7
7
  import "../../onchain/index.js";
8
8
  import { LpResult, OpenStrategyResult, StrategyResult } from "../prepare/types.js";
@@ -72,7 +72,7 @@ type PrepareRequest = PoolPrepareRequest | OpenPrepareRequest | AccountPrepareRe
72
72
  * The write side of the opportunities namespace: turns what `prepare`
73
73
  * answered into the transaction to sign. Sending, and whatever the wallet has
74
74
  * to do first (allowances, permits, RWA signatures), stays with the caller —
75
- * `checkPrerequisites` reports the former on the built transaction.
75
+ * `checkOperation` reports the former on the built transaction's preview.
76
76
  **/
77
77
  interface IOpportunitiesExecute {
78
78
  /**
@@ -1,10 +1,9 @@
1
- import { BorrowLimitBinding, IntentPreviewError, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewRefusal, raise, refuse } from "../onchain/validation/refusal.js";
1
+ import { CreditAccountNotEmptyError, CreditAccountNotFoundError, EmptyOpenTakesNothingError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, emptyOpenTakesNothing, noStrategyTargetCollateral, unexpectedFailure } from "../model/errors/prepare-errors.js";
2
2
  import { LeverageBand } from "../onchain/accounts/intents/leverage-band.js";
3
- import { OperationState, PathLossRate, WithdrawCeilings } from "../onchain/accounts/intents/types.js";
3
+ import { OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../onchain/accounts/intents/types.js";
4
4
  import { IAnalytics, IAnalyticsByMode } from "./analytics/types.js";
5
5
  import { ILiquidations, ILiquidationsByMode } from "./liquidations/types.js";
6
- import { AccountFlowError, CreditAccountNotFoundError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientCollateralError, InsufficientPoolLiquidityError, InsufficientSourceBalanceError, LeverageOutOfRangeError, MalformedTransactionError, MarketExpiredError, MarketPausedError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, OpenFlowError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RefusalErrors, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, WithdrawalInProgressError, creditAccountNotFound, noStrategyTargetCollateral, toRefusalError, unexpectedFailure } from "./prepare/errors.js";
7
- import { AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
6
+ import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./prepare/types.js";
8
7
  import { ChainOf, PrepareApi } from "./prepare/PrepareApi.js";
9
8
  import "./prepare/index.js";
10
9
  import { AccountPrepareRequest, IOpportunitiesExecute, OpenPrepareRequest, PoolPrepareRequest, PrepareRequest } from "./execute/types.js";
@@ -16,7 +15,7 @@ import { DEFAULT_MAX_OFFCHAIN_LAG, mergeChainList, mergeChainOne } from "./utils
16
15
  import "./utils/index.js";
17
16
  import { IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunityMergers } from "./opportunities/types.js";
18
17
  import { IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly } from "./positions/types.js";
19
- import { IPreview, IPreviewByMode } from "./preview/types.js";
18
+ import { CheckOperationProps, IPreview, IPreviewByMode } from "./preview/types.js";
20
19
  import { EnsureFreshChains, GearboxSDKOptions, IGearboxSDK, INotices, INoticesByMode, Mode, NamespaceOptions, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, PlainMultichainSDKOptions } from "./types.js";
21
20
  import { AbstractNamespace, MergedQuery } from "./AbstractNamespace.js";
22
21
  import { AnalyticsNamespace } from "./analytics/AnalyticsNamespace.js";
@@ -38,4 +37,4 @@ import { SourceUnavailableError } from "./errors/SourceUnavailableError.js";
38
37
  import { assertSameChains } from "./errors/assertSameChains.js";
39
38
  import { everyChainFailed } from "./errors/everyChainFailed.js";
40
39
  import "./errors/index.js";
41
- export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, BorrowLimitBinding, ChainOf, ChainRef, CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DebtOutOfRangeError, DelayedStrategyResult, DepositStrategyParams, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, FinalizeResult, ForbiddenTokenError, GearboxSDK, GearboxSDKOptions, IAnalytics, IAnalyticsByMode, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, InsufficientCollateralError, InsufficientPoolLiquidityError, InsufficientSourceBalanceError, IntentPreviewError, type LeverageBand, LeverageOutOfRangeError, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, MalformedTransactionError, MarketExpiredError, MarketPausedError, type MergeListResult, MergedQuery, MissingSourceError, Mode, MultipleDelayedWithdrawalsError, NamespaceOptions, NoDelayedRouteError, NoRecordedIntentError, NoSourceServedError, NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PoolSunsetError, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewErrorDetails, PreviewErrorReason, PreviewIssue, PreviewNamespace, PreviewRefusal, QuotaCountExceededError, QuotaLimitReachedError, RefusalErrors, RepayStrategyParams, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithRouteRefusals, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, WithdrawalInProgressError, assertSameChains, creditAccountNotFound, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, raise, refuse, toRefusalError, unexpectedFailure };
40
+ export { AbstractNamespace, AccountFlowError, AccountPrepareRequest, AddCollateralParams, AdjustLeverageParams, AllSourcesFailedError, AnalyticsNamespace, ChainOf, ChainRef, CheckOperationProps, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DEFAULT_MAX_OFFCHAIN_LAG, DEFAULT_MAX_STATE_AGE, DelayedStrategyResult, DepositStrategyParams, type EmptyOpenTakesNothingError, EnsureFreshChains, type EntityMerger, ExecuteApi, type FilterResult, FinalizeParams, FinalizeResult, GearboxSDK, GearboxSDKOptions, IAnalytics, IAnalyticsByMode, IGearboxSDK, ILiquidations, ILiquidationsByMode, INotices, INoticesByMode, IOpportunities, IOpportunitiesBase, IOpportunitiesByMode, IOpportunitiesExecute, IOpportunitiesOffchainBranch, IOpportunitiesOffchainOnly, IOpportunitiesOnchainBranch, IOpportunitiesOnchainOnly, IOpportunitiesPrepare, IOpportunityMergers, IPositionMergers, IPositions, IPositionsBase, IPositionsByMode, IPositionsOffchainBranch, IPositionsOffchainOnly, IPositionsOnchainBranch, IPositionsOnchainOnly, IPreview, IPreviewByMode, type LeverageBand, LiquidationsNamespace, type ListMerger, LpParams, LpRedeemParams, LpResult, LpState, type MergeListResult, MergedQuery, MissingSourceError, Mode, type MultipleDelayedWithdrawalsError, NamespaceOptions, type NoDelayedRouteError, type NoRecordedIntentError, NoSourceServedError, type NoStrategyTargetCollateralError, OffchainByMode, OffchainSource, OnchainByMode, OnchainSource, OpenFlowError, OpenPrepareRequest, OpenStrategyParams, OpenStrategyResult, type OperationState, OpportunitiesNamespace, type PathLossRate, PlainMultichainSDKOptions, PoolInput, PoolPrepareRequest, PositionInput, PositionsNamespace, PrepareApi, PrepareOptions, PrepareRequest, PreviewNamespace, RepayStrategyParams, type RouteErrors, SourceChainMismatchError, SourceUnavailableError, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, assertSameChains, creditAccountNotEmpty, creditAccountNotFound, emptyOpenTakesNothing, everyChainFailed, filterResponse, mergeChainList, mergeChainOne, noStrategyTargetCollateral, unexpectedFailure };