@gearbox-protocol/sdk 16.2.0 → 16.3.0-next.2

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 (572) hide show
  1. package/dist/cjs/abi/rwa/iMidasAccessControl.js +23 -0
  2. package/dist/cjs/abi/rwa/iMidasDegenNFT.js +92 -0
  3. package/dist/cjs/history/assembleOperations.js +3 -3
  4. package/dist/cjs/history/classifyMulticallOperations.js +7 -7
  5. package/dist/cjs/history/index.js +13 -0
  6. package/dist/cjs/history/parseCreditAccountTransaction.js +5 -5
  7. package/dist/cjs/{preview → history}/trace/errors.js +1 -1
  8. package/dist/cjs/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
  9. package/dist/cjs/{preview → history}/trace/extractTransfers.js +3 -3
  10. package/dist/cjs/{preview → history}/trace/findFacadeCalls.js +3 -3
  11. package/dist/cjs/history/trace/index.js +14 -0
  12. package/dist/cjs/model/errors/index.js +37 -0
  13. package/dist/cjs/model/errors/liquidation-errors.js +32 -0
  14. package/dist/cjs/model/errors/operation-errors.js +135 -0
  15. package/dist/cjs/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
  16. package/dist/cjs/model/errors/prepare-errors.js +108 -0
  17. package/dist/cjs/model/errors/preview-errors.js +12 -0
  18. package/dist/cjs/model/index.js +45 -2
  19. package/dist/cjs/model/opportunities.schema.js +3 -1
  20. package/dist/cjs/model/positions.js +1 -1
  21. package/dist/cjs/model/result.js +0 -8
  22. package/dist/cjs/model/rwa.js +53 -0
  23. package/dist/cjs/model/rwa.schema.js +20 -0
  24. package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
  25. package/dist/cjs/onchain/accounts/index.js +0 -2
  26. package/dist/cjs/onchain/accounts/intents/guards.js +42 -66
  27. package/dist/cjs/onchain/accounts/intents/index.js +38 -35
  28. package/dist/cjs/onchain/accounts/intents/leverage-band.js +1 -1
  29. package/dist/cjs/onchain/accounts/intents/math.js +19 -15
  30. package/dist/cjs/onchain/accounts/intents/open-strategy.js +6 -4
  31. package/dist/cjs/onchain/accounts/intents/plan.js +52 -48
  32. package/dist/cjs/onchain/accounts/intents/realize.js +26 -24
  33. package/dist/cjs/onchain/accounts/intents/tail.js +15 -12
  34. package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +7 -0
  35. package/dist/cjs/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
  36. package/dist/cjs/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
  37. package/dist/cjs/onchain/accounts/intents/view.js +1 -1
  38. package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +2 -2
  39. package/dist/cjs/onchain/accounts/withdrawal-compressor/index.js +0 -1
  40. package/dist/cjs/onchain/index.js +130 -38
  41. package/dist/cjs/onchain/market/MarketSuite.js +10 -4
  42. package/dist/cjs/onchain/market/adapters/index.js +1 -0
  43. package/dist/cjs/onchain/market/credit/CreditSuite.js +77 -15
  44. package/dist/cjs/onchain/market/index.js +8 -8
  45. package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +6 -6
  46. package/dist/cjs/onchain/market/oracle/index.js +0 -2
  47. package/dist/cjs/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
  48. package/dist/cjs/onchain/market/rwa/RWARegistry.js +3 -2
  49. package/dist/cjs/onchain/market/rwa/createDegenNFT.js +53 -0
  50. package/dist/cjs/onchain/market/rwa/index.js +7 -5
  51. package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +56 -0
  52. package/dist/cjs/onchain/market/rwa/midas/constants.js +2 -0
  53. package/dist/cjs/onchain/market/rwa/midas/index.js +3 -0
  54. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +22 -3
  55. package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +9 -9
  56. package/dist/cjs/onchain/market/rwa/securitize/constants.js +2 -2
  57. package/dist/cjs/onchain/market/rwa/securitize/index.js +4 -3
  58. package/dist/cjs/onchain/market/rwa/securitize/types.js +0 -29
  59. package/dist/cjs/onchain/market/rwa/types.js +0 -7
  60. package/dist/cjs/onchain/market/zapper/index.js +0 -1
  61. package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
  62. package/dist/cjs/onchain/opportunities/OpportunitiesService.js +11 -3
  63. package/dist/cjs/onchain/pools/PoolService.js +10 -16
  64. package/dist/cjs/onchain/preview/index.js +41 -0
  65. package/dist/cjs/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
  66. package/dist/cjs/onchain/preview/parse/index.js +14 -0
  67. package/dist/cjs/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +3 -3
  68. package/dist/cjs/{preview → onchain/preview}/parse/parseOperationCalldata.js +16 -17
  69. package/dist/cjs/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
  70. package/dist/cjs/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +11 -12
  71. package/dist/cjs/{preview → onchain/preview}/parse/types.js +1 -1
  72. package/dist/cjs/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
  73. package/dist/cjs/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
  74. package/dist/cjs/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
  75. package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
  76. package/dist/cjs/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
  77. package/dist/cjs/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
  78. package/dist/cjs/onchain/preview/preview/index.js +26 -0
  79. package/dist/cjs/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +18 -22
  80. package/dist/cjs/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +22 -28
  81. package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +60 -0
  82. package/dist/cjs/onchain/preview/preview/previewOperation.js +119 -0
  83. package/dist/cjs/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -32
  84. package/dist/cjs/onchain/preview/preview/replayInnerOperations.js +109 -0
  85. package/dist/cjs/onchain/preview/preview/replayMulticall.js +22 -0
  86. package/dist/cjs/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
  87. package/dist/cjs/onchain/validation/bundles/checkAccountQuotas.js +20 -0
  88. package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +59 -0
  89. package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +65 -0
  90. package/dist/cjs/onchain/validation/bundles/checkDraw.js +28 -0
  91. package/dist/cjs/onchain/validation/bundles/checkHealthFactors.js +27 -0
  92. package/dist/cjs/onchain/validation/bundles/checkLiquidationEligibility.js +33 -0
  93. package/dist/cjs/onchain/validation/bundles/checkLiquidationFunding.js +29 -0
  94. package/dist/cjs/onchain/validation/bundles/checkMarket.js +24 -0
  95. package/dist/cjs/onchain/validation/bundles/checkObtained.js +13 -0
  96. package/dist/cjs/onchain/validation/bundles/checkPoolFunding.js +22 -0
  97. package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +35 -0
  98. package/dist/cjs/onchain/validation/bundles/checkQuotasAsked.js +20 -0
  99. package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +33 -0
  100. package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +24 -0
  101. package/dist/cjs/onchain/validation/bundles/checkWallet.js +22 -0
  102. package/dist/cjs/onchain/validation/bundles/checkWalletAllowance.js +32 -0
  103. package/dist/cjs/onchain/validation/bundles/checkWalletBalance.js +41 -0
  104. package/dist/cjs/onchain/validation/bundles/index.js +35 -0
  105. package/dist/cjs/onchain/validation/checkLiquidation.js +22 -0
  106. package/dist/cjs/onchain/validation/checkOperation.js +62 -0
  107. package/dist/cjs/onchain/validation/checkSimulation.js +60 -0
  108. package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +25 -0
  109. package/dist/cjs/onchain/validation/checks/checkCollateralised.js +26 -0
  110. package/dist/cjs/onchain/validation/checks/checkCreditAccountFrozen.js +10 -0
  111. package/dist/cjs/onchain/validation/checks/checkCreditManagerPaused.js +10 -0
  112. package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +18 -0
  113. package/dist/cjs/onchain/validation/checks/checkEmergencyLiquidator.js +13 -0
  114. package/dist/cjs/onchain/validation/checks/checkForbiddenToken.js +10 -0
  115. package/dist/cjs/onchain/validation/checks/checkLeverage.js +13 -0
  116. package/dist/cjs/onchain/validation/checks/checkLiquidatorEligible.js +10 -0
  117. package/dist/cjs/onchain/validation/checks/checkMarketExpired.js +10 -0
  118. package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +25 -0
  119. package/dist/cjs/onchain/validation/checks/checkPoolPaused.js +10 -0
  120. package/dist/cjs/onchain/validation/checks/checkPoolSunset.js +10 -0
  121. package/dist/cjs/onchain/validation/checks/checkQuotaCount.js +10 -0
  122. package/dist/cjs/onchain/validation/checks/checkQuotaLimit.js +18 -0
  123. package/dist/cjs/onchain/validation/checks/index.js +31 -0
  124. package/dist/cjs/onchain/validation/helpers/amount.js +12 -0
  125. package/dist/cjs/onchain/validation/helpers/health-factor-limits.js +25 -0
  126. package/dist/cjs/onchain/validation/helpers/index.js +11 -0
  127. package/dist/cjs/onchain/validation/{token.js → helpers/token.js} +4 -4
  128. package/dist/cjs/onchain/validation/index.js +85 -27
  129. package/dist/cjs/onchain/validation/raise.js +33 -0
  130. package/dist/cjs/sdk/index.js +6 -11
  131. package/dist/cjs/sdk/liquidations/LiquidationsNamespace.js +9 -0
  132. package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +19 -4
  133. package/dist/cjs/sdk/prepare/PrepareApi.js +40 -50
  134. package/dist/cjs/sdk/prepare/index.js +7 -11
  135. package/dist/cjs/sdk/prepare/types.js +0 -4
  136. package/dist/cjs/sdk/preview/PreviewNamespace.js +24 -13
  137. package/dist/esm/abi/rwa/iMidasAccessControl.js +22 -0
  138. package/dist/esm/abi/rwa/iMidasDegenNFT.js +91 -0
  139. package/dist/esm/dev/AccountOpener.js +1 -1
  140. package/dist/esm/dev/withdrawalUtils.js +1 -1
  141. package/dist/esm/history/assembleOperations.js +2 -2
  142. package/dist/esm/history/classifyMulticallOperations.js +2 -2
  143. package/dist/esm/history/index.js +6 -1
  144. package/dist/esm/history/parseCreditAccountTransaction.js +3 -3
  145. package/dist/esm/{preview → history}/trace/errors.js +1 -1
  146. package/dist/esm/{preview → history}/trace/extractAdapterCallTraces.js +1 -1
  147. package/dist/esm/{preview → history}/trace/extractTransfers.js +2 -2
  148. package/dist/esm/{preview → history}/trace/findFacadeCalls.js +1 -1
  149. package/dist/esm/model/errors/index.js +7 -0
  150. package/dist/esm/model/errors/liquidation-errors.js +29 -0
  151. package/dist/esm/model/errors/operation-errors.js +121 -0
  152. package/dist/esm/{onchain/market/oracle/errors.js → model/errors/oracle-errors.js} +1 -1
  153. package/dist/esm/model/errors/prepare-errors.js +97 -0
  154. package/dist/esm/model/errors/preview-errors.js +11 -0
  155. package/dist/esm/model/index.js +10 -3
  156. package/dist/esm/model/opportunities.schema.js +3 -1
  157. package/dist/esm/model/positions.js +1 -1
  158. package/dist/esm/model/result.js +1 -8
  159. package/dist/esm/model/rwa.js +48 -0
  160. package/dist/esm/model/rwa.schema.js +18 -0
  161. package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
  162. package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -2
  163. package/dist/esm/onchain/accounts/index.js +1 -2
  164. package/dist/esm/onchain/accounts/intents/guards.js +29 -52
  165. package/dist/esm/onchain/accounts/intents/index.js +39 -35
  166. package/dist/esm/onchain/accounts/intents/leverage-band.js +1 -1
  167. package/dist/esm/onchain/accounts/intents/math.js +18 -14
  168. package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -6
  169. package/dist/esm/onchain/accounts/intents/plan.js +51 -47
  170. package/dist/esm/onchain/accounts/intents/realize.js +26 -24
  171. package/dist/esm/onchain/accounts/intents/tail.js +14 -11
  172. package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +7 -0
  173. package/dist/esm/onchain/accounts/intents/tests/finish-withdraw.fixtures.js +6 -6
  174. package/dist/esm/onchain/accounts/intents/tests/withdraw.fixtures.js +12 -12
  175. package/dist/esm/onchain/accounts/intents/view.js +1 -1
  176. package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +3 -3
  177. package/dist/esm/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.js +1 -1
  178. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV310Contract.js +1 -1
  179. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV311Contract.js +1 -1
  180. package/dist/esm/onchain/accounts/withdrawal-compressor/WithdrawalCompressorV313Contract.js +1 -1
  181. package/dist/esm/onchain/accounts/withdrawal-compressor/index.js +0 -1
  182. package/dist/esm/onchain/base/TokensMeta.js +3 -3
  183. package/dist/esm/onchain/core/createAddressProvider.js +1 -1
  184. package/dist/esm/onchain/index.js +64 -11
  185. package/dist/esm/onchain/market/MarketSuite.js +10 -4
  186. package/dist/esm/onchain/market/adapters/contracts/AccountMigratorAdapterContract.js +1 -1
  187. package/dist/esm/onchain/market/adapters/contracts/ERC4626AdapterContract.js +1 -1
  188. package/dist/esm/onchain/market/adapters/index.js +1 -0
  189. package/dist/esm/onchain/market/credit/CreditFacadeV310BaseContract.js +1 -1
  190. package/dist/esm/onchain/market/credit/CreditSuite.js +77 -15
  191. package/dist/esm/onchain/market/index.js +6 -6
  192. package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
  193. package/dist/esm/onchain/market/oracle/index.js +1 -2
  194. package/dist/esm/onchain/market/pool/PoolQuotaKeeperV310Contract.js +8 -0
  195. package/dist/esm/onchain/market/pool/PoolV310Contract.js +1 -1
  196. package/dist/esm/onchain/market/rwa/RWARegistry.js +2 -1
  197. package/dist/esm/onchain/market/rwa/createDegenNFT.js +52 -0
  198. package/dist/esm/onchain/market/rwa/index.js +6 -5
  199. package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +55 -0
  200. package/dist/esm/onchain/market/rwa/midas/constants.js +2 -1
  201. package/dist/esm/onchain/market/rwa/midas/index.js +3 -2
  202. package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +20 -2
  203. package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +4 -4
  204. package/dist/esm/onchain/market/rwa/securitize/constants.js +2 -2
  205. package/dist/esm/onchain/market/rwa/securitize/index.js +4 -3
  206. package/dist/esm/onchain/market/rwa/securitize/types.js +1 -29
  207. package/dist/esm/onchain/market/rwa/types.js +1 -7
  208. package/dist/esm/onchain/market/zapper/IETHZapperContract.js +1 -1
  209. package/dist/esm/onchain/market/zapper/ZapperContract.js +1 -1
  210. package/dist/esm/onchain/market/zapper/index.js +0 -1
  211. package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +2 -2
  212. package/dist/esm/onchain/opportunities/OpportunitiesService.js +11 -3
  213. package/dist/esm/onchain/pools/PoolService.js +10 -16
  214. package/dist/esm/onchain/preview/index.js +20 -0
  215. package/dist/esm/{preview → onchain/preview}/parse/classifyInnerOperations.js +2 -3
  216. package/dist/esm/{preview → onchain/preview}/parse/index.js +0 -1
  217. package/dist/esm/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.js +1 -1
  218. package/dist/esm/{preview → onchain/preview}/parse/parseOperationCalldata.js +10 -11
  219. package/dist/esm/{preview → onchain/preview}/parse/parsePoolOperationCalldata.js +3 -3
  220. package/dist/esm/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.js +8 -9
  221. package/dist/esm/{preview → onchain/preview}/parse/types.js +1 -1
  222. package/dist/esm/{preview → onchain/preview}/preview/CreditAccountState.js +3 -4
  223. package/dist/esm/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.js +10 -11
  224. package/dist/esm/{preview → onchain/preview}/preview/detectCloseOrRepay.js +2 -3
  225. package/dist/esm/{preview → onchain/preview}/preview/detectDelayedClaim.js +4 -5
  226. package/dist/esm/{preview → onchain/preview}/preview/detectDelayedOperation.js +5 -6
  227. package/dist/esm/{preview → onchain/preview}/preview/estimateClaimableAt.js +1 -1
  228. package/dist/esm/{preview → onchain/preview}/preview/index.js +3 -4
  229. package/dist/esm/{preview → onchain/preview}/preview/previewAdjustStrategyPosition.js +17 -21
  230. package/dist/esm/{preview → onchain/preview}/preview/previewExitOrRepayStrategyPosition.js +20 -26
  231. package/dist/esm/{preview → onchain/preview}/preview/previewOpenStrategyPosition.js +25 -15
  232. package/dist/esm/{preview → onchain/preview}/preview/previewOperation.js +54 -35
  233. package/dist/esm/{preview/simulate/simulatePoolOperation.js → onchain/preview/preview/previewPoolPositionOperation.js} +46 -30
  234. package/dist/esm/onchain/preview/preview/replayInnerOperations.js +107 -0
  235. package/dist/esm/onchain/preview/preview/replayMulticall.js +21 -0
  236. package/dist/esm/{preview → onchain/preview}/preview/unwrapNativeCollateral.js +11 -14
  237. package/dist/esm/onchain/utils/viem/simulateWithPriceUpdates.js +1 -1
  238. package/dist/esm/onchain/validation/bundles/checkAccountQuotas.js +19 -0
  239. package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +58 -0
  240. package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +64 -0
  241. package/dist/esm/onchain/validation/bundles/checkDraw.js +27 -0
  242. package/dist/esm/onchain/validation/bundles/checkHealthFactors.js +26 -0
  243. package/dist/esm/onchain/validation/bundles/checkLiquidationEligibility.js +32 -0
  244. package/dist/esm/onchain/validation/bundles/checkLiquidationFunding.js +28 -0
  245. package/dist/esm/onchain/validation/bundles/checkMarket.js +23 -0
  246. package/dist/esm/onchain/validation/bundles/checkObtained.js +12 -0
  247. package/dist/esm/onchain/validation/bundles/checkPoolFunding.js +21 -0
  248. package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +34 -0
  249. package/dist/esm/onchain/validation/bundles/checkQuotasAsked.js +19 -0
  250. package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +32 -0
  251. package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +23 -0
  252. package/dist/esm/onchain/validation/bundles/checkWallet.js +21 -0
  253. package/dist/esm/onchain/validation/bundles/checkWalletAllowance.js +31 -0
  254. package/dist/esm/onchain/validation/bundles/checkWalletBalance.js +40 -0
  255. package/dist/esm/onchain/validation/bundles/index.js +18 -0
  256. package/dist/esm/onchain/validation/checkLiquidation.js +21 -0
  257. package/dist/esm/onchain/validation/checkOperation.js +61 -0
  258. package/dist/esm/onchain/validation/checkSimulation.js +59 -0
  259. package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +24 -0
  260. package/dist/esm/onchain/validation/checks/checkCollateralised.js +25 -0
  261. package/dist/esm/onchain/validation/checks/checkCreditAccountFrozen.js +9 -0
  262. package/dist/esm/onchain/validation/checks/checkCreditManagerPaused.js +9 -0
  263. package/dist/esm/onchain/validation/checks/checkDebtLimits.js +17 -0
  264. package/dist/esm/onchain/validation/checks/checkEmergencyLiquidator.js +12 -0
  265. package/dist/esm/onchain/validation/checks/checkForbiddenToken.js +9 -0
  266. package/dist/esm/onchain/validation/checks/checkLeverage.js +12 -0
  267. package/dist/esm/onchain/validation/checks/checkLiquidatorEligible.js +9 -0
  268. package/dist/esm/onchain/validation/checks/checkMarketExpired.js +9 -0
  269. package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +24 -0
  270. package/dist/esm/onchain/validation/checks/checkPoolPaused.js +9 -0
  271. package/dist/esm/onchain/validation/checks/checkPoolSunset.js +9 -0
  272. package/dist/esm/onchain/validation/checks/checkQuotaCount.js +9 -0
  273. package/dist/esm/onchain/validation/checks/checkQuotaLimit.js +17 -0
  274. package/dist/esm/onchain/validation/checks/index.js +16 -0
  275. package/dist/esm/onchain/validation/helpers/amount.js +11 -0
  276. package/dist/esm/onchain/validation/helpers/health-factor-limits.js +21 -0
  277. package/dist/esm/onchain/validation/helpers/index.js +4 -0
  278. package/dist/esm/onchain/validation/{token.js → helpers/token.js} +3 -3
  279. package/dist/esm/onchain/validation/index.js +43 -4
  280. package/dist/esm/onchain/validation/raise.js +31 -0
  281. package/dist/esm/sdk/index.js +2 -3
  282. package/dist/esm/sdk/liquidations/LiquidationsNamespace.js +9 -0
  283. package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +19 -4
  284. package/dist/esm/sdk/prepare/PrepareApi.js +25 -35
  285. package/dist/esm/sdk/prepare/index.js +3 -3
  286. package/dist/esm/sdk/prepare/types.js +1 -2
  287. package/dist/esm/sdk/preview/PreviewNamespace.js +24 -13
  288. package/dist/types/abi/rwa/iMidasAccessControl.d.ts +22 -0
  289. package/dist/types/abi/rwa/iMidasDegenNFT.d.ts +82 -0
  290. package/dist/types/history/assembleOperations.d.ts +4 -5
  291. package/dist/types/history/classifyMulticallOperations.d.ts +3 -4
  292. package/dist/types/history/index.d.ts +8 -2
  293. package/dist/types/history/mapOperations.d.ts +1 -1
  294. package/dist/types/{preview → history}/trace/errors.d.ts +1 -1
  295. package/dist/types/{preview → history}/trace/extractAdapterCallTraces.d.ts +1 -1
  296. package/dist/types/{preview → history}/trace/extractTransfers.d.ts +2 -3
  297. package/dist/types/{preview → history}/trace/findFacadeCalls.d.ts +1 -1
  298. package/dist/types/{preview → history}/trace/types.d.ts +1 -1
  299. package/dist/types/history/types.d.ts +2 -3
  300. package/dist/types/model/errors/base.d.ts +28 -0
  301. package/dist/types/model/errors/index.d.ts +7 -0
  302. package/dist/types/model/errors/liquidation-errors.d.ts +45 -0
  303. package/dist/types/model/errors/operation-errors.d.ts +216 -0
  304. package/dist/types/{onchain/market/oracle/errors.d.ts → model/errors/oracle-errors.d.ts} +3 -5
  305. package/dist/types/model/errors/prepare-errors.d.ts +131 -0
  306. package/dist/types/model/errors/preview-errors.d.ts +72 -0
  307. package/dist/types/model/index.d.ts +12 -4
  308. package/dist/types/model/opportunities.d.ts +12 -2
  309. package/dist/types/model/opportunities.schema.d.ts +30 -0
  310. package/dist/types/model/positions.d.ts +2 -2
  311. package/dist/types/model/previews.d.ts +52 -113
  312. package/dist/types/model/result.d.ts +4 -8
  313. package/dist/types/model/rwa.d.ts +167 -0
  314. package/dist/types/model/rwa.schema.d.ts +29 -0
  315. package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +2 -1
  316. package/dist/types/offchain/opportunities/types.d.ts +4 -1
  317. package/dist/types/onchain/accounts/CreditAccountsServiceV310.d.ts +3 -1
  318. package/dist/types/onchain/accounts/index.d.ts +2 -4
  319. package/dist/types/onchain/accounts/intents/guards.d.ts +8 -18
  320. package/dist/types/onchain/accounts/intents/index.d.ts +20 -19
  321. package/dist/types/onchain/accounts/intents/leverage-band.d.ts +1 -1
  322. package/dist/types/onchain/accounts/intents/math.d.ts +6 -6
  323. package/dist/types/onchain/accounts/intents/operations.d.ts +2 -2
  324. package/dist/types/onchain/accounts/intents/plan.d.ts +9 -9
  325. package/dist/types/onchain/accounts/intents/tail.d.ts +2 -2
  326. package/dist/types/onchain/accounts/intents/testing/expect.d.ts +3 -3
  327. package/dist/types/onchain/accounts/intents/tests/finish-withdraw.fixtures.d.ts +6 -6
  328. package/dist/types/onchain/accounts/intents/tests/withdraw.fixtures.d.ts +12 -12
  329. package/dist/types/onchain/accounts/intents/types.d.ts +32 -30
  330. package/dist/types/onchain/accounts/types.d.ts +2 -1
  331. package/dist/types/onchain/accounts/withdrawal-compressor/RedemptionLoggerV310Contract.d.ts +1 -1
  332. package/dist/types/onchain/accounts/withdrawal-compressor/index.d.ts +1 -2
  333. package/dist/types/onchain/accounts/withdrawal-compressor/types.d.ts +1 -1
  334. package/dist/types/onchain/index.d.ts +73 -16
  335. package/dist/types/onchain/market/MarketSuite.d.ts +5 -1
  336. package/dist/types/onchain/market/adapters/index.d.ts +2 -1
  337. package/dist/types/onchain/market/adapters/transfers.d.ts +0 -7
  338. package/dist/types/onchain/market/credit/CreditSuite.d.ts +30 -8
  339. package/dist/types/onchain/market/credit/index.d.ts +2 -2
  340. package/dist/types/onchain/market/credit/types.d.ts +11 -1
  341. package/dist/types/onchain/market/index.d.ts +11 -10
  342. package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +1 -1
  343. package/dist/types/onchain/market/oracle/index.d.ts +1 -2
  344. package/dist/types/onchain/market/oracle/types.d.ts +1 -1
  345. package/dist/types/onchain/market/pool/PoolQuotaKeeperV310Contract.d.ts +5 -0
  346. package/dist/types/onchain/market/rwa/RWARegistry.d.ts +1 -1
  347. package/dist/types/onchain/market/rwa/createDegenNFT.d.ts +12 -0
  348. package/dist/types/onchain/market/rwa/index.d.ts +10 -8
  349. package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +98 -0
  350. package/dist/types/onchain/market/rwa/midas/constants.d.ts +2 -1
  351. package/dist/types/onchain/market/rwa/midas/index.d.ts +3 -2
  352. package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +8 -2
  353. package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +4 -3
  354. package/dist/types/onchain/market/rwa/securitize/constants.d.ts +2 -2
  355. package/dist/types/onchain/market/rwa/securitize/index.d.ts +5 -4
  356. package/dist/types/onchain/market/rwa/securitize/types.d.ts +4 -110
  357. package/dist/types/onchain/market/rwa/types.d.ts +24 -32
  358. package/dist/types/onchain/market/zapper/ZapperContract.d.ts +1 -1
  359. package/dist/types/onchain/market/zapper/index.d.ts +1 -2
  360. package/dist/types/onchain/market/zapper/types.d.ts +1 -1
  361. package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +2 -1
  362. package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +5 -1
  363. package/dist/types/onchain/opportunities/types.d.ts +3 -2
  364. package/dist/types/onchain/pools/types.d.ts +2 -2
  365. package/dist/types/onchain/preview/index.d.ts +24 -0
  366. package/dist/types/{preview → onchain/preview}/parse/classifyInnerOperations.d.ts +4 -4
  367. package/dist/types/{preview → onchain/preview}/parse/index.d.ts +2 -4
  368. package/dist/types/{preview → onchain/preview}/parse/parseFacadeOperationCalldata.d.ts +4 -4
  369. package/dist/types/onchain/preview/parse/parseOperationCalldata.d.ts +18 -0
  370. package/dist/types/{preview → onchain/preview}/parse/parsePoolOperationCalldata.d.ts +7 -7
  371. package/dist/types/{preview → onchain/preview}/parse/parseRWAFactoryOperationCalldata.d.ts +4 -4
  372. package/dist/types/{preview → onchain/preview}/parse/types-adapters.d.ts +5 -16
  373. package/dist/types/{preview → onchain/preview}/parse/types-facades.d.ts +3 -3
  374. package/dist/types/{preview → onchain/preview}/parse/types-pools.d.ts +1 -1
  375. package/dist/types/{preview → onchain/preview}/parse/types-rwa.d.ts +3 -3
  376. package/dist/types/{preview → onchain/preview}/parse/types.d.ts +3 -3
  377. package/dist/types/{preview → onchain/preview}/preview/CreditAccountState.d.ts +5 -5
  378. package/dist/types/{preview → onchain/preview}/preview/buildDelayedStrategyPositionOperationPreview.d.ts +5 -5
  379. package/dist/types/{preview → onchain/preview}/preview/detectCloseOrRepay.d.ts +1 -1
  380. package/dist/types/{preview → onchain/preview}/preview/detectDelayedClaim.d.ts +8 -8
  381. package/dist/types/{preview → onchain/preview}/preview/detectDelayedOperation.d.ts +9 -9
  382. package/dist/types/{preview → onchain/preview}/preview/estimateClaimableAt.d.ts +6 -6
  383. package/dist/types/{preview → onchain/preview}/preview/index.d.ts +3 -4
  384. package/dist/types/onchain/preview/preview/previewAdjustStrategyPosition.d.ts +20 -0
  385. package/dist/types/onchain/preview/preview/previewExitOrRepayStrategyPosition.d.ts +21 -0
  386. package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +14 -0
  387. package/dist/types/onchain/preview/preview/previewOperation.d.ts +32 -0
  388. package/dist/types/onchain/preview/preview/previewPoolPositionOperation.d.ts +13 -0
  389. package/dist/types/{preview → onchain/preview}/preview/replayInnerOperations.d.ts +11 -11
  390. package/dist/types/{preview → onchain/preview}/preview/replayMulticall.d.ts +10 -10
  391. package/dist/types/{preview → onchain/preview}/preview/unwrapNativeCollateral.d.ts +10 -20
  392. package/dist/types/onchain/validation/bundles/checkAccountQuotas.d.ts +16 -0
  393. package/dist/types/onchain/validation/bundles/checkCollateralFunding.d.ts +22 -0
  394. package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +31 -0
  395. package/dist/types/onchain/validation/bundles/checkDraw.d.ts +20 -0
  396. package/dist/types/onchain/validation/bundles/checkHealthFactors.d.ts +39 -0
  397. package/dist/types/onchain/validation/bundles/checkLiquidationEligibility.d.ts +20 -0
  398. package/dist/types/onchain/validation/bundles/checkLiquidationFunding.d.ts +18 -0
  399. package/dist/types/onchain/validation/bundles/checkMarket.d.ts +15 -0
  400. package/dist/types/onchain/validation/bundles/checkObtained.d.ts +9 -0
  401. package/dist/types/onchain/validation/bundles/checkPoolFunding.d.ts +19 -0
  402. package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +31 -0
  403. package/dist/types/onchain/validation/bundles/checkQuotasAsked.d.ts +10 -0
  404. package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +21 -0
  405. package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +19 -0
  406. package/dist/types/onchain/validation/bundles/checkWallet.d.ts +23 -0
  407. package/dist/types/onchain/validation/bundles/checkWalletAllowance.d.ts +18 -0
  408. package/dist/types/onchain/validation/bundles/checkWalletBalance.d.ts +17 -0
  409. package/dist/types/onchain/validation/bundles/index.d.ts +18 -0
  410. package/dist/types/onchain/validation/checkLiquidation.d.ts +23 -0
  411. package/dist/types/onchain/validation/checkOperation.d.ts +32 -0
  412. package/dist/types/onchain/validation/checkSimulation.d.ts +56 -0
  413. package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +21 -0
  414. package/dist/types/onchain/validation/checks/checkCollateralised.d.ts +25 -0
  415. package/dist/types/onchain/validation/checks/checkCreditAccountFrozen.d.ts +12 -0
  416. package/dist/types/onchain/validation/checks/checkCreditManagerPaused.d.ts +12 -0
  417. package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +21 -0
  418. package/dist/types/onchain/validation/checks/checkEmergencyLiquidator.d.ts +17 -0
  419. package/dist/types/onchain/validation/checks/checkForbiddenToken.d.ts +12 -0
  420. package/dist/types/onchain/validation/checks/checkLeverage.d.ts +12 -0
  421. package/dist/types/onchain/validation/checks/checkLiquidatorEligible.d.ts +13 -0
  422. package/dist/types/onchain/validation/checks/checkMarketExpired.d.ts +14 -0
  423. package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +20 -0
  424. package/dist/types/onchain/validation/checks/checkPoolPaused.d.ts +12 -0
  425. package/dist/types/onchain/validation/checks/checkPoolSunset.d.ts +13 -0
  426. package/dist/types/onchain/validation/checks/checkQuotaCount.d.ts +11 -0
  427. package/dist/types/onchain/validation/checks/checkQuotaLimit.d.ts +18 -0
  428. package/dist/types/onchain/validation/checks/index.d.ts +16 -0
  429. package/dist/types/onchain/validation/helpers/amount.d.ts +7 -0
  430. package/dist/types/onchain/validation/helpers/health-factor-limits.d.ts +21 -0
  431. package/dist/types/onchain/validation/helpers/index.d.ts +4 -0
  432. package/dist/types/onchain/validation/{token.d.ts → helpers/token.d.ts} +4 -4
  433. package/dist/types/onchain/validation/index.d.ts +43 -4
  434. package/dist/types/onchain/validation/raise.d.ts +33 -0
  435. package/dist/types/sdk/execute/types.d.ts +2 -2
  436. package/dist/types/sdk/index.d.ts +5 -6
  437. package/dist/types/sdk/liquidations/LiquidationsNamespace.d.ts +5 -0
  438. package/dist/types/sdk/liquidations/types.d.ts +8 -0
  439. package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +2 -1
  440. package/dist/types/sdk/opportunities/types.d.ts +8 -2
  441. package/dist/types/sdk/prepare/PrepareApi.d.ts +5 -4
  442. package/dist/types/sdk/prepare/index.d.ts +5 -5
  443. package/dist/types/sdk/prepare/types.d.ts +41 -22
  444. package/dist/types/sdk/preview/PreviewNamespace.d.ts +13 -3
  445. package/dist/types/sdk/preview/index.d.ts +2 -2
  446. package/dist/types/sdk/preview/types.d.ts +30 -7
  447. package/package.json +1 -6
  448. package/dist/cjs/onchain/accounts/withdrawal-compressor/errors.js +0 -1
  449. package/dist/cjs/onchain/market/zapper/errors.js +0 -1
  450. package/dist/cjs/onchain/validation/checks.js +0 -258
  451. package/dist/cjs/onchain/validation/refusal.js +0 -39
  452. package/dist/cjs/preview/index.js +0 -86
  453. package/dist/cjs/preview/package.json +0 -1
  454. package/dist/cjs/preview/parse/errors.js +0 -1
  455. package/dist/cjs/preview/parse/index.js +0 -15
  456. package/dist/cjs/preview/prerequisites/AllowancePrerequisite.js +0 -38
  457. package/dist/cjs/preview/prerequisites/BalancePrerequisite.js +0 -52
  458. package/dist/cjs/preview/prerequisites/Prerequisite.js +0 -52
  459. package/dist/cjs/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -53
  460. package/dist/cjs/preview/prerequisites/buildCollateralPrerequisites.js +0 -63
  461. package/dist/cjs/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -19
  462. package/dist/cjs/preview/prerequisites/buildPoolPrerequisites.js +0 -76
  463. package/dist/cjs/preview/prerequisites/buildRWAPrerequisites.js +0 -39
  464. package/dist/cjs/preview/prerequisites/checkPrerequisites.js +0 -74
  465. package/dist/cjs/preview/prerequisites/helpers.js +0 -23
  466. package/dist/cjs/preview/prerequisites/index.js +0 -12
  467. package/dist/cjs/preview/preview/errors.js +0 -85
  468. package/dist/cjs/preview/preview/index.js +0 -33
  469. package/dist/cjs/preview/preview/previewOpenStrategyPosition.js +0 -50
  470. package/dist/cjs/preview/preview/previewOperation.js +0 -100
  471. package/dist/cjs/preview/preview/previewPoolPositionOperation.js +0 -49
  472. package/dist/cjs/preview/preview/replayInnerOperations.js +0 -109
  473. package/dist/cjs/preview/preview/replayMulticall.js +0 -19
  474. package/dist/cjs/preview/simulate/errors.js +0 -73
  475. package/dist/cjs/preview/simulate/index.js +0 -11
  476. package/dist/cjs/preview/simulate/simulateFacadeOperation.js +0 -15
  477. package/dist/cjs/preview/simulate/simulateOperation.js +0 -29
  478. package/dist/cjs/preview/simulate/simulateRWAOperation.js +0 -15
  479. package/dist/cjs/preview/simulate/types.js +0 -1
  480. package/dist/cjs/preview/trace/index.js +0 -14
  481. package/dist/cjs/preview/trace/types.js +0 -1
  482. package/dist/cjs/preview/types.js +0 -1
  483. package/dist/cjs/preview/validate/checkOperation.js +0 -187
  484. package/dist/cjs/preview/validate/checkSimulation.js +0 -39
  485. package/dist/cjs/preview/validate/index.js +0 -8
  486. package/dist/cjs/sdk/prepare/errors.js +0 -114
  487. package/dist/esm/onchain/accounts/withdrawal-compressor/errors.js +0 -1
  488. package/dist/esm/onchain/market/zapper/errors.js +0 -1
  489. package/dist/esm/onchain/validation/checks.js +0 -238
  490. package/dist/esm/onchain/validation/refusal.js +0 -36
  491. package/dist/esm/preview/index.js +0 -38
  492. package/dist/esm/preview/package.json +0 -1
  493. package/dist/esm/preview/parse/errors.js +0 -1
  494. package/dist/esm/preview/prerequisites/AllowancePrerequisite.js +0 -37
  495. package/dist/esm/preview/prerequisites/BalancePrerequisite.js +0 -51
  496. package/dist/esm/preview/prerequisites/Prerequisite.js +0 -51
  497. package/dist/esm/preview/prerequisites/RWAOpenRequirementsPrerequisite.js +0 -52
  498. package/dist/esm/preview/prerequisites/buildCollateralPrerequisites.js +0 -62
  499. package/dist/esm/preview/prerequisites/buildPartialLiquidationPrerequisites.js +0 -18
  500. package/dist/esm/preview/prerequisites/buildPoolPrerequisites.js +0 -75
  501. package/dist/esm/preview/prerequisites/buildRWAPrerequisites.js +0 -38
  502. package/dist/esm/preview/prerequisites/checkPrerequisites.js +0 -73
  503. package/dist/esm/preview/prerequisites/helpers.js +0 -22
  504. package/dist/esm/preview/prerequisites/index.js +0 -7
  505. package/dist/esm/preview/preview/errors.js +0 -79
  506. package/dist/esm/preview/preview/previewPoolPositionOperation.js +0 -48
  507. package/dist/esm/preview/preview/replayInnerOperations.js +0 -107
  508. package/dist/esm/preview/preview/replayMulticall.js +0 -18
  509. package/dist/esm/preview/simulate/errors.js +0 -71
  510. package/dist/esm/preview/simulate/index.js +0 -6
  511. package/dist/esm/preview/simulate/simulateFacadeOperation.js +0 -14
  512. package/dist/esm/preview/simulate/simulateOperation.js +0 -28
  513. package/dist/esm/preview/simulate/simulateRWAOperation.js +0 -14
  514. package/dist/esm/preview/simulate/types.js +0 -1
  515. package/dist/esm/preview/trace/types.js +0 -1
  516. package/dist/esm/preview/types.js +0 -1
  517. package/dist/esm/preview/validate/checkOperation.js +0 -183
  518. package/dist/esm/preview/validate/checkSimulation.js +0 -38
  519. package/dist/esm/preview/validate/index.js +0 -3
  520. package/dist/esm/sdk/prepare/errors.js +0 -108
  521. package/dist/types/model/errors.d.ts +0 -46
  522. package/dist/types/onchain/accounts/withdrawal-compressor/errors.d.ts +0 -20
  523. package/dist/types/onchain/market/zapper/errors.d.ts +0 -18
  524. package/dist/types/onchain/validation/checks.d.ts +0 -164
  525. package/dist/types/onchain/validation/refusal.d.ts +0 -242
  526. package/dist/types/preview/index.d.ts +0 -47
  527. package/dist/types/preview/parse/errors.d.ts +0 -29
  528. package/dist/types/preview/parse/parseOperationCalldata.d.ts +0 -18
  529. package/dist/types/preview/prerequisites/AllowancePrerequisite.d.ts +0 -26
  530. package/dist/types/preview/prerequisites/BalancePrerequisite.d.ts +0 -29
  531. package/dist/types/preview/prerequisites/Prerequisite.d.ts +0 -26
  532. package/dist/types/preview/prerequisites/RWAOpenRequirementsPrerequisite.d.ts +0 -55
  533. package/dist/types/preview/prerequisites/buildCollateralPrerequisites.d.ts +0 -20
  534. package/dist/types/preview/prerequisites/buildPartialLiquidationPrerequisites.d.ts +0 -12
  535. package/dist/types/preview/prerequisites/buildPoolPrerequisites.d.ts +0 -12
  536. package/dist/types/preview/prerequisites/buildRWAPrerequisites.d.ts +0 -26
  537. package/dist/types/preview/prerequisites/checkPrerequisites.d.ts +0 -28
  538. package/dist/types/preview/prerequisites/helpers.d.ts +0 -10
  539. package/dist/types/preview/prerequisites/index.d.ts +0 -7
  540. package/dist/types/preview/prerequisites/types.d.ts +0 -53
  541. package/dist/types/preview/preview/errors.d.ts +0 -44
  542. package/dist/types/preview/preview/previewAdjustStrategyPosition.d.ts +0 -19
  543. package/dist/types/preview/preview/previewExitOrRepayStrategyPosition.d.ts +0 -18
  544. package/dist/types/preview/preview/previewOpenStrategyPosition.d.ts +0 -12
  545. package/dist/types/preview/preview/previewOperation.d.ts +0 -32
  546. package/dist/types/preview/preview/previewPoolPositionOperation.d.ts +0 -13
  547. package/dist/types/preview/simulate/errors.d.ts +0 -52
  548. package/dist/types/preview/simulate/index.d.ts +0 -7
  549. package/dist/types/preview/simulate/simulateFacadeOperation.d.ts +0 -16
  550. package/dist/types/preview/simulate/simulateOperation.d.ts +0 -12
  551. package/dist/types/preview/simulate/simulatePoolOperation.d.ts +0 -42
  552. package/dist/types/preview/simulate/simulateRWAOperation.d.ts +0 -16
  553. package/dist/types/preview/simulate/types.d.ts +0 -48
  554. package/dist/types/preview/types.d.ts +0 -65
  555. package/dist/types/preview/validate/checkOperation.d.ts +0 -71
  556. package/dist/types/preview/validate/checkSimulation.d.ts +0 -32
  557. package/dist/types/preview/validate/index.d.ts +0 -3
  558. package/dist/types/sdk/prepare/errors.d.ts +0 -343
  559. /package/dist/cjs/{preview/prerequisites → history/trace}/types.js +0 -0
  560. /package/dist/cjs/model/{errors.js → errors/base.js} +0 -0
  561. /package/dist/cjs/{preview → onchain/preview}/parse/types-adapters.js +0 -0
  562. /package/dist/cjs/{preview → onchain/preview}/parse/types-facades.js +0 -0
  563. /package/dist/cjs/{preview → onchain/preview}/parse/types-pools.js +0 -0
  564. /package/dist/cjs/{preview → onchain/preview}/parse/types-rwa.js +0 -0
  565. /package/dist/esm/{preview → history}/trace/index.js +0 -0
  566. /package/dist/esm/{preview/prerequisites → history/trace}/types.js +0 -0
  567. /package/dist/esm/model/{errors.js → errors/base.js} +0 -0
  568. /package/dist/esm/{preview → onchain/preview}/parse/types-adapters.js +0 -0
  569. /package/dist/esm/{preview → onchain/preview}/parse/types-facades.js +0 -0
  570. /package/dist/esm/{preview → onchain/preview}/parse/types-pools.js +0 -0
  571. /package/dist/esm/{preview → onchain/preview}/parse/types-rwa.js +0 -0
  572. /package/dist/types/{preview → history}/trace/index.d.ts +0 -0
@@ -1,187 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_onchain_validation_checks = require("../../onchain/validation/checks.js");
3
- const require_onchain_validation_token = require("../../onchain/validation/token.js");
4
- const require_onchain_accounts_intents_guards = require("../../onchain/accounts/intents/guards.js");
5
- require("../../onchain/index.js");
6
- let viem = require("viem");
7
- //#region src/preview/validate/checkOperation.ts
8
- /**
9
- * Whether a parsed operation may be signed at all — the protocol state that
10
- * `checkPrerequisites` leaves out, since that one covers only what the sender
11
- * can fix themselves.
12
- *
13
- * Synchronous: the preview carries the numbers and the market is attached.
14
- * Reports the most fundamental issue it finds and stops there, which is the one
15
- * a caller acts on.
16
- */
17
- function checkOperation(input, options = {}) {
18
- const { sdk, preview } = input;
19
- const malformed = require_onchain_validation_checks.checkPreviewError("warning" in preview ? preview.warning : void 0);
20
- if (malformed) return malformed;
21
- switch (preview.operation) {
22
- case "Deposit":
23
- case "Mint": return poolIssues(sdk, preview, options, true);
24
- case "Withdraw":
25
- case "Redeem": return poolIssues(sdk, preview, options, false);
26
- case "DelayedCreditAccountOperation": return checkOperation({
27
- sdk,
28
- preview: preview.instantPreview
29
- }, options);
30
- case "OpenCreditAccount":
31
- case "RWAOpenCreditAccount":
32
- case "AdjustCreditAccount": return creditIssues(sdk, preview, options);
33
- case "CloseCreditAccount":
34
- case "RepayCreditAccount": return marketIssues(sdk.marketRegister.findCreditManager(preview.creditManager));
35
- }
36
- }
37
- function poolIssues(sdk, preview, options, isDeposit) {
38
- const market = sdk.marketRegister.findByPool(preview.pool);
39
- return require_onchain_validation_checks.checkPoolPaused({
40
- isPaused: market.pool.pool.isPaused,
41
- pool: preview.pool
42
- }) || require_onchain_validation_checks.checkPoolSunset({
43
- isSunset: market.sunset,
44
- isDeposit,
45
- pool: preview.pool
46
- }) || (isDeposit ? null : require_onchain_validation_checks.checkPoolPayout({
47
- requested: preview.tokenOut.value,
48
- available: market.pool.pool.availableLiquidity,
49
- underlying: preview.tokenOut.token
50
- })) || fundingIssue(options, [preview.tokenIn]);
51
- }
52
- /** What the market itself refuses, whatever the operation does. */
53
- function marketIssues(suite) {
54
- const creditManager = suite.creditManager.address;
55
- return require_onchain_validation_checks.checkCreditManagerPaused({
56
- isPaused: suite.isPaused,
57
- creditManager
58
- }) || require_onchain_validation_checks.checkMarketExpired({
59
- isExpired: suite.isExpired,
60
- creditManager,
61
- expirationDate: suite.creditFacade.expirationDate
62
- });
63
- }
64
- function creditIssues(sdk, preview, options) {
65
- const suite = sdk.marketRegister.findCreditManager(preview.creditManager);
66
- const market = suite.market;
67
- const underlying = require_onchain_validation_token.toToken(sdk, market.pool.underlying);
68
- const isOpening = preview.operation === "OpenCreditAccount" || preview.operation === "RWAOpenCreditAccount";
69
- return marketIssues(suite) || require_onchain_validation_checks.checkDebtInBand({
70
- debt: preview.totalDebt.value,
71
- minDebt: suite.creditFacade.minDebt,
72
- maxDebt: suite.creditFacade.maxDebt,
73
- underlying,
74
- allowZero: !isOpening
75
- }) || borrowIssue(suite, preview, underlying) || forbiddenIssue(suite, preview) || quotaCountIssue(suite, preview) || quotaIssue(market, preview, underlying) || collateralIssue({
76
- totalDebt: preview.totalDebt,
77
- healthFactor: preview.estHealthFactor,
78
- safeHealthFactor: preview.estSafeHealthFactor
79
- }, options) || fundingIssue(options, preview.collateralAdded);
80
- }
81
- /**
82
- * A bar that reads nothing but the projected account, so a parsed transaction
83
- * and a simulated one are held to it by the same code.
84
- *
85
- * These stay separate functions rather than one block because the order the
86
- * checks run in is the answer: `checkOperation` interleaves the checks that
87
- * need an operation's *delta* between them, and the caller acts on the first
88
- * issue reported.
89
- */
90
- function quotaCountIssue(suite, account) {
91
- return require_onchain_validation_checks.checkQuotaCount({
92
- count: account.quotas.filter((q) => q.value > 0n).length,
93
- max: suite.creditManager.maxEnabledTokens
94
- });
95
- }
96
- /**
97
- * What the transaction draws, against what the market can lend right now.
98
- *
99
- * Only a draw is weighed: repaying, or leaving the debt alone, can never exceed
100
- * a ceiling. Opening borrows the whole debt; adjusting borrows
101
- * `totalDebtChange`.
102
- *
103
- * The engine holds every simulation to this already (`assertCanBorrow`), so
104
- * this is here for the transactions it never saw — a pasted calldata reaches
105
- * the confirm screen with nothing else standing between it and a revert.
106
- */
107
- function borrowIssue(suite, preview, underlying) {
108
- const drawn = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
109
- if (drawn <= 0n) return null;
110
- const { limit, binding } = require_onchain_accounts_intents_guards.borrowable(suite);
111
- return require_onchain_validation_checks.checkBorrowLimit({
112
- requested: drawn,
113
- available: limit,
114
- binding,
115
- underlying
116
- });
117
- }
118
- /**
119
- * The account against whichever bars the caller holds it to.
120
- *
121
- * A loan-free account is nothing to weigh: the health factor reports its
122
- * zero-debt sentinel and no bar applies.
123
- *
124
- * {@inheritDoc quotaCountIssue}
125
- */
126
- function collateralIssue(account, options) {
127
- const { minHealthFactor, minSafeHealthFactor, currentHealthFactor } = options;
128
- if (account.totalDebt.value === 0n) return null;
129
- return (minHealthFactor === void 0 ? null : require_onchain_validation_checks.checkCollateralised({
130
- healthFactor: account.healthFactor,
131
- required: minHealthFactor,
132
- safePrices: false,
133
- improvesFrom: currentHealthFactor
134
- })) || (minSafeHealthFactor === void 0 ? null : require_onchain_validation_checks.checkCollateralised({
135
- healthFactor: account.safeHealthFactor,
136
- required: minSafeHealthFactor,
137
- safePrices: true
138
- }));
139
- }
140
- /** The wallet's side of the operation, against the balances it was given. */
141
- function fundingIssue(options, puts) {
142
- const { balances } = options;
143
- if (!balances) return null;
144
- for (const { token, value } of puts) {
145
- const issue = require_onchain_validation_checks.checkFunding({
146
- token,
147
- required: value,
148
- held: balances.get(token.address) ?? 0n
149
- });
150
- if (issue) return issue;
151
- }
152
- return null;
153
- }
154
- function forbiddenIssue(suite, preview) {
155
- const obtained = preview.operation === "AdjustCreditAccount" ? preview.assetsChange : preview.estAssets;
156
- const forbidden = suite.forbiddenTokens;
157
- for (const asset of obtained) {
158
- if (asset.value <= 0n) continue;
159
- const issue = require_onchain_validation_checks.checkForbiddenToken({
160
- token: asset.token,
161
- isForbidden: forbidden.some((f) => (0, viem.isAddressEqual)(f, asset.token.address))
162
- });
163
- if (issue) return issue;
164
- }
165
- return null;
166
- }
167
- function quotaIssue(market, preview, underlying) {
168
- const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
169
- const { pqk } = market.pool;
170
- for (const q of increases) {
171
- if (q.value <= 0n) continue;
172
- const quota = pqk.hasActiveQuota(q.token.address) ? pqk.quotas.get(q.token.address) : void 0;
173
- const issue = require_onchain_validation_checks.checkQuotaLimit({
174
- token: q.token,
175
- requested: quota ? q.value : void 0,
176
- available: (quota?.limit ?? 0n) - (quota?.totalQuoted ?? 0n),
177
- underlying
178
- });
179
- if (issue) return issue;
180
- }
181
- return null;
182
- }
183
- //#endregion
184
- exports.checkOperation = checkOperation;
185
- exports.collateralIssue = collateralIssue;
186
- exports.marketIssues = marketIssues;
187
- exports.quotaCountIssue = quotaCountIssue;
@@ -1,39 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_onchain_validation_checks = require("../../onchain/validation/checks.js");
3
- const require_onchain_validation_token = require("../../onchain/validation/token.js");
4
- require("../../onchain/index.js");
5
- const require_preview_validate_checkOperation = require("./checkOperation.js");
6
- //#region src/preview/validate/checkSimulation.ts
7
- /**
8
- * Whether a simulated operation clears the caller's own bars.
9
- *
10
- * The engine holds an account to the facade's `1.0`, because its guards answer
11
- * "would this revert". A form is wiser to ask for more, and the engine's own
12
- * note says so — a caller wanting the stricter bar applies it itself. This is
13
- * that second opinion, over the numbers the engine already reported.
14
- *
15
- * Three of the checks below the engine does not make at all: both health-factor
16
- * bars are its own `1.0`, and the quota count it never weighs. The other two run
17
- * against the same numbers the engine used, and are here so that a change in the
18
- * engine cannot pass silently.
19
- *
20
- * What is deliberately absent: the forbidden-token, quota-limit and funding
21
- * checks all need the *delta* an operation applies, and `OperationState` reports
22
- * only the state after it. Weighing them against absolutes would refuse a
23
- * forbidden token the account merely holds, or a quota the operation never
24
- * touched. The engine performed all three during the walk, so a simulation that
25
- * came back `ok` has already passed them.
26
- */
27
- function checkSimulation(input, options = {}) {
28
- const { sdk, state } = input;
29
- const suite = sdk.marketRegister.findCreditManager(state.creditManager);
30
- return require_preview_validate_checkOperation.marketIssues(suite) || require_onchain_validation_checks.checkDebtInBand({
31
- debt: state.totalDebt.value,
32
- minDebt: suite.creditFacade.minDebt,
33
- maxDebt: suite.creditFacade.maxDebt,
34
- underlying: require_onchain_validation_token.toToken(sdk, suite.market.pool.underlying),
35
- allowZero: true
36
- }) || require_preview_validate_checkOperation.quotaCountIssue(suite, state) || require_preview_validate_checkOperation.collateralIssue(state, options);
37
- }
38
- //#endregion
39
- exports.checkSimulation = checkSimulation;
@@ -1,8 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_preview_validate_checkOperation = require("./checkOperation.js");
3
- const require_preview_validate_checkSimulation = require("./checkSimulation.js");
4
- exports.checkOperation = require_preview_validate_checkOperation.checkOperation;
5
- exports.checkSimulation = require_preview_validate_checkSimulation.checkSimulation;
6
- exports.collateralIssue = require_preview_validate_checkOperation.collateralIssue;
7
- exports.marketIssues = require_preview_validate_checkOperation.marketIssues;
8
- exports.quotaCountIssue = require_preview_validate_checkOperation.quotaCountIssue;
@@ -1,114 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- //#region src/sdk/prepare/errors.ts
3
- /**
4
- * One sentence per refusal, naming what was ruled out rather than restating the
5
- * numbers the error already carries.
6
- *
7
- * English and loggable, not a string to put on a screen: a form renders the
8
- * code and the amounts in its own words, see {@link IGearboxError.message}.
9
- **/
10
- const MESSAGES = {
11
- debtOutOfRange: "The debt this request implies is outside the market's band.",
12
- leverageOutOfRange: "The leverage asked for cannot be expressed as a plan.",
13
- insufficientSourceBalance: "Neither the account nor the wallet holds enough to fund this request.",
14
- unsupportedCollateralToken: "This flow does not accept that token.",
15
- unsupportedTokenPair: "No route exists between these two tokens.",
16
- noDelayedRoute: "This request cannot be served as a delayed redemption.",
17
- multipleDelayedWithdrawals: "The source asset has several redemption venues and none was named.",
18
- withdrawalInProgress: "A redemption of this asset is already in flight on the account.",
19
- noRecordedIntent: "The claim names no operation to resume.",
20
- marketPaused: "The market is paused.",
21
- marketExpired: "The market is past its expiration date.",
22
- insufficientPoolLiquidity: "The pool cannot lend what this plan draws.",
23
- quotaLimitReached: "The market takes no more quota for a token this plan holds.",
24
- forbiddenToken: "This plan would increase the balance of a forbidden token.",
25
- insufficientCollateral: "The account would end this transaction under-collateralised.",
26
- poolSunset: "The pool is winding down and takes no more deposits.",
27
- quotaCountExceeded: "The account would hold more quoted tokens than the facade enables at once.",
28
- malformedTransaction: "The transaction could not be replayed."
29
- };
30
- /**
31
- * The engine's refusal, as the error the namespace answers with.
32
- *
33
- * One place does the lifting, so the two shapes cannot drift: `reason` becomes
34
- * `code`, the detail is spread onto the error, and the sentence comes from
35
- * {@link MESSAGES}. A malformed transaction is spelled out rather than spread,
36
- * because its detail names a `code` and a `message` of its own and they are not
37
- * the envelope's.
38
- *
39
- * Generic over the issue it is handed, so a call site that already knows the
40
- * reason gets that reason's error back rather than a union to narrow again.
41
- **/
42
- function toRefusalError(issue) {
43
- if (issue.reason === "malformedTransaction") return {
44
- code: "malformedTransaction",
45
- message: MESSAGES.malformedTransaction,
46
- previewCode: issue.detail.code,
47
- detail: issue.detail.message
48
- };
49
- return {
50
- code: issue.reason,
51
- message: MESSAGES[issue.reason],
52
- ...issue.detail
53
- };
54
- }
55
- /**
56
- * {@inheritDoc NoStrategyTargetCollateralError}
57
- **/
58
- function noStrategyTargetCollateral(creditManager) {
59
- return {
60
- code: "noStrategyTargetCollateral",
61
- message: `Credit manager ${creditManager} has no strategy target collateral, and none was named.`,
62
- creditManager
63
- };
64
- }
65
- /**
66
- * {@inheritDoc CreditAccountNotEmptyError}
67
- **/
68
- function creditAccountNotEmpty(creditAccount) {
69
- return {
70
- code: "creditAccountNotEmpty",
71
- message: `Credit account ${creditAccount} carries debt or quotas.`,
72
- creditAccount
73
- };
74
- }
75
- /**
76
- * {@inheritDoc CreditAccountNotFoundError}
77
- **/
78
- function creditAccountNotFound(creditAccount) {
79
- return {
80
- code: "creditAccountNotFound",
81
- message: `Credit account not found: ${creditAccount}.`,
82
- creditAccount
83
- };
84
- }
85
- /**
86
- * {@inheritDoc EmptyOpenTakesNothingError}
87
- **/
88
- function emptyOpenTakesNothing() {
89
- return {
90
- code: "emptyOpenTakesNothing",
91
- message: "An empty opening takes no collateral, no account to reuse and no leverage."
92
- };
93
- }
94
- /**
95
- * {@inheritDoc UnexpectedFailureError}
96
- *
97
- * Takes what was thrown, whatever that is: a `throw` is not obliged to raise an
98
- * `Error`, and `cause` promises one.
99
- **/
100
- function unexpectedFailure(thrown) {
101
- const cause = thrown instanceof Error ? thrown : new Error(String(thrown));
102
- return {
103
- code: "unexpectedFailure",
104
- message: `The SDK could not prepare this operation: ${cause.message}`,
105
- cause
106
- };
107
- }
108
- //#endregion
109
- exports.creditAccountNotEmpty = creditAccountNotEmpty;
110
- exports.creditAccountNotFound = creditAccountNotFound;
111
- exports.emptyOpenTakesNothing = emptyOpenTakesNothing;
112
- exports.noStrategyTargetCollateral = noStrategyTargetCollateral;
113
- exports.toRefusalError = toRefusalError;
114
- exports.unexpectedFailure = unexpectedFailure;
@@ -1 +0,0 @@
1
- export {};
@@ -1,238 +0,0 @@
1
- //#region src/onchain/validation/checks.ts
2
- /**
3
- * Every refusal the protocol can pass on an operation, as values.
4
- *
5
- * Each check is handed the numbers it compares — never a suite, a market or an
6
- * SDK — so the engine, `checkOperation` and the strategy lists share one
7
- * implementation.
8
- *
9
- * Ladders stay with the caller because they differ deliberately: the engine
10
- * reports the tightest ceiling it found, the account-opening path the first one
11
- * exceeded in its own order.
12
- */
13
- /** A factor at or below this is refused; kept for the callers that size on it. */
14
- const MIN_HF_LIMITED = 10100n;
15
- /** The same bar as a `required` argument — the lowest factor that passes. */
16
- const MIN_HEALTH_FACTOR_FORM = 10101;
17
- /** The bar the facade itself enforces: an account may end exactly at 1.0. */
18
- const MIN_HEALTH_FACTOR_FACADE = 1e4;
19
- /**
20
- * The safe-price bar a form holds an account to. A step above the facade's,
21
- * because a factor of exactly 1.0 at safe prices is already a refusal.
22
- */
23
- const MIN_SAFE_HEALTH_FACTOR_FORM = 10001;
24
- /** A refusal names what a limit was measured in, never what it is worth. */
25
- function amountOf(token, value) {
26
- return {
27
- token,
28
- value,
29
- valueUsd: null
30
- };
31
- }
32
- /** The credit manager takes no multicall while it is paused. */
33
- function checkCreditManagerPaused(args) {
34
- if (!args.isPaused) return null;
35
- return {
36
- reason: "marketPaused",
37
- detail: { creditManager: args.creditManager }
38
- };
39
- }
40
- /** Past its expiration date the facade takes no more multicalls. */
41
- function checkMarketExpired(args) {
42
- if (!args.isExpired) return null;
43
- return {
44
- reason: "marketExpired",
45
- detail: {
46
- creditManager: args.creditManager,
47
- expirationDate: args.expirationDate
48
- }
49
- };
50
- }
51
- /** A paused pool neither takes deposits nor pays out. */
52
- function checkPoolPaused(args) {
53
- return args.isPaused ? {
54
- reason: "marketPaused",
55
- detail: { pool: args.pool }
56
- } : null;
57
- }
58
- /**
59
- * A pool winding down still pays out, so only what puts money in is refused.
60
- */
61
- function checkPoolSunset(args) {
62
- return args.isSunset && args.isDeposit ? {
63
- reason: "poolSunset",
64
- detail: { pool: args.pool }
65
- } : null;
66
- }
67
- /**
68
- * What the pool will hand over, against what is asked for.
69
- *
70
- * `binding` and `available` are the caller's answer to "which ceiling stands in
71
- * the way", not this check's: see the ladder note above. `solutionAmount` is
72
- * the largest position still openable, left out when none is.
73
- */
74
- function checkBorrowLimit(args) {
75
- if (args.requested <= args.available) return null;
76
- return {
77
- reason: "insufficientPoolLiquidity",
78
- detail: {
79
- requested: amountOf(args.underlying, args.requested),
80
- available: amountOf(args.underlying, args.available),
81
- binding: args.binding,
82
- ...args.solutionAmount === void 0 ? {} : { solutionAmount: amountOf(args.underlying, args.solutionAmount) }
83
- }
84
- };
85
- }
86
- /**
87
- * What the pool can pay out, against what is being taken out.
88
- *
89
- * The operator is not `checkBorrowLimit`'s: a pool holding exactly the amount
90
- * asked for still cannot serve it, so equality is already a refusal. That is
91
- * the rule the legacy withdrawal validator enforced and it is preserved to the
92
- * unit.
93
- */
94
- function checkPoolPayout(args) {
95
- if (args.requested < args.available) return null;
96
- return {
97
- reason: "insufficientPoolLiquidity",
98
- detail: {
99
- requested: amountOf(args.underlying, args.requested),
100
- available: amountOf(args.underlying, args.available),
101
- binding: "poolAvailableLiquidity"
102
- }
103
- };
104
- }
105
- /**
106
- * A debt the facade would revert on.
107
- *
108
- * `allowZero` is the one place the two callers genuinely disagree: an account
109
- * being adjusted may end owing nothing, while one being opened may not — so the
110
- * exemption is stated rather than assumed.
111
- */
112
- function checkDebtInBand(args) {
113
- const { debt, minDebt, maxDebt, underlying, allowZero } = args;
114
- if (!(debt > maxDebt || debt < minDebt && !(allowZero && debt === 0n))) return null;
115
- return {
116
- reason: "debtOutOfRange",
117
- detail: {
118
- requested: amountOf(underlying, debt),
119
- minDebt: amountOf(underlying, minDebt),
120
- maxDebt: amountOf(underlying, maxDebt)
121
- }
122
- };
123
- }
124
- /** Leverage below 1x is not a position, it is a withdrawal. */
125
- function checkLeverageAtLeastOne(args) {
126
- return args.leverage < args.min ? {
127
- reason: "leverageOutOfRange",
128
- detail: {
129
- requested: args.leverage,
130
- min: args.min
131
- }
132
- } : null;
133
- }
134
- /**
135
- * The account against its debt, at whichever bar the caller holds it to.
136
- *
137
- * An unread factor counts as failing: a check that cannot see the number is not
138
- * evidence that the number is fine.
139
- */
140
- function checkCollateralised(args) {
141
- const { healthFactor, required, safePrices, improvesFrom } = args;
142
- if (healthFactor === void 0) return {
143
- reason: "insufficientCollateral",
144
- detail: {
145
- healthFactor: 0,
146
- required,
147
- safePrices
148
- }
149
- };
150
- if (healthFactor >= required || improvesFrom !== void 0 && healthFactor > improvesFrom) return null;
151
- return {
152
- reason: "insufficientCollateral",
153
- detail: {
154
- healthFactor,
155
- required,
156
- safePrices
157
- }
158
- };
159
- }
160
- /** A token the market will not let the account hold. */
161
- function checkForbiddenToken(args) {
162
- return args.isForbidden ? {
163
- reason: "forbiddenToken",
164
- detail: { token: args.token }
165
- } : null;
166
- }
167
- /**
168
- * The room the keeper still has for a token's quota, in the underlying.
169
- *
170
- * `requested` is absent for a token the market opened no quota for at all —
171
- * nothing was weighed against a limit, the token simply counts as no collateral.
172
- */
173
- function checkQuotaLimit(args) {
174
- const { token, requested, available, underlying } = args;
175
- if (requested !== void 0 && requested <= available) return null;
176
- return {
177
- reason: "quotaLimitReached",
178
- detail: {
179
- token,
180
- requested: requested === void 0 ? void 0 : amountOf(underlying, requested),
181
- available: amountOf(underlying, available)
182
- }
183
- };
184
- }
185
- /** How many quoted tokens the facade enables at once. */
186
- function checkQuotaCount(args) {
187
- return args.count > args.max ? {
188
- reason: "quotaCountExceeded",
189
- detail: {
190
- count: args.count,
191
- max: args.max
192
- }
193
- } : null;
194
- }
195
- /** What the operation is funded from, against what is there. */
196
- function checkFunding(args) {
197
- const { token, required, held } = args;
198
- if (required <= held) return null;
199
- return {
200
- reason: "insufficientSourceBalance",
201
- detail: {
202
- required: amountOf(token, required),
203
- held: amountOf(token, held)
204
- }
205
- };
206
- }
207
- /**
208
- * The SDK could not replay the transaction.
209
- *
210
- * Only a {@link MalformedPreviewError} lands here. An `unpriceableToken`
211
- * warning says the transaction is fine and the SDK could not fully evaluate
212
- * it, which is a caveat on the numbers rather than a reason to refuse — it
213
- * stays on the preview for the caller to surface.
214
- */
215
- function checkPreviewError(warning) {
216
- if (!warning || !isMalformedPreviewError(warning)) return null;
217
- return {
218
- reason: "malformedTransaction",
219
- detail: warning
220
- };
221
- }
222
- /**
223
- * Whether the preview warning means the transaction itself is malformed,
224
- * rather than that only the evaluation was incomplete.
225
- */
226
- function isMalformedPreviewError(warning) {
227
- switch (warning.code) {
228
- case "malformedBracket":
229
- case "adapterCallOutsideBracket":
230
- case "nonAdapterCallInBracket":
231
- case "unpreviewableAdapterCall":
232
- case "unsupportedOutOfBracketCall":
233
- case "invalidTransactionValue": return true;
234
- default: return false;
235
- }
236
- }
237
- //#endregion
238
- export { 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 };
@@ -1,36 +0,0 @@
1
- //#region src/onchain/validation/refusal.ts
2
- /** Builds the refusal a caller sees. */
3
- function refuse(reason, detail) {
4
- return {
5
- ok: false,
6
- reason,
7
- detail
8
- };
9
- }
10
- /**
11
- * Validation failure that maps onto {@link PreviewErrorReason} rather than
12
- * crashing the caller: raised by the planners and the guards, turned into
13
- * `{ ok: false }` by `CreditAccountOperationsService`.
14
- */
15
- var IntentPreviewError = class extends Error {
16
- reason;
17
- detail;
18
- constructor(reason, detail, message) {
19
- super(message ?? reason);
20
- this.name = "IntentPreviewError";
21
- this.reason = reason;
22
- this.detail = detail;
23
- }
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
- }
35
- //#endregion
36
- export { IntentPreviewError, raise, refuse };
@@ -1,38 +0,0 @@
1
- import { raise, refuse } from "../onchain/validation/refusal.js";
2
- import { TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, WithdrawCollateralAlignmentError } from "./trace/errors.js";
3
- import { extractAdapterCallTraces } from "./trace/extractAdapterCallTraces.js";
4
- import { extractTransfers } from "./trace/extractTransfers.js";
5
- import { findFacadeCalls } from "./trace/findFacadeCalls.js";
6
- import "./trace/index.js";
7
- import { classifyInnerOperations } from "./parse/classifyInnerOperations.js";
8
- import { parseFacadeOperationCalldata } from "./parse/parseFacadeOperationCalldata.js";
9
- import { parsePoolOperationCalldata } from "./parse/parsePoolOperationCalldata.js";
10
- import { parseRWAFactoryOperationCalldata } from "./parse/parseRWAFactoryOperationCalldata.js";
11
- import { parseOperationCalldata } from "./parse/parseOperationCalldata.js";
12
- import { isPoolOperation, isRWAOperation } from "./parse/types.js";
13
- import "./parse/index.js";
14
- import { Prerequisite } from "./prerequisites/Prerequisite.js";
15
- import { AllowancePrerequisite } from "./prerequisites/AllowancePrerequisite.js";
16
- import { BalancePrerequisite } from "./prerequisites/BalancePrerequisite.js";
17
- import { RWAOpenRequirementsPrerequisite } from "./prerequisites/RWAOpenRequirementsPrerequisite.js";
18
- import { checkPrerequisites } from "./prerequisites/checkPrerequisites.js";
19
- import "./prerequisites/index.js";
20
- import { buildDelayedStrategyPositionOperationPreview } from "./preview/buildDelayedStrategyPositionOperationPreview.js";
21
- import { CreditAccountState } from "./preview/CreditAccountState.js";
22
- import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/detectCloseOrRepay.js";
23
- import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/detectDelayedClaim.js";
24
- import { detectDelayedOperation } from "./preview/detectDelayedOperation.js";
25
- import { adapterCallOutsideBracketError, invalidTransactionValueError, malformedBracketError, nonAdapterCallInBracketError, unpreviewableAdapterCallError, unsupportedOutOfBracketCallError } from "./preview/errors.js";
26
- import { estimateClaimableAt } from "./preview/estimateClaimableAt.js";
27
- import { makeReplayState, replayInnerOperations } from "./preview/replayInnerOperations.js";
28
- import { replayMulticall } from "./preview/replayMulticall.js";
29
- import { previewAdjustStrategyPosition } from "./preview/previewAdjustStrategyPosition.js";
30
- import { previewExitOrRepayStrategyPosition } from "./preview/previewExitOrRepayStrategyPosition.js";
31
- import { asPreviewSimulationError } from "./simulate/errors.js";
32
- import { previewOperation } from "./preview/previewOperation.js";
33
- import "./preview/index.js";
34
- import "./types.js";
35
- import { checkOperation, collateralIssue, marketIssues, quotaCountIssue } from "./validate/checkOperation.js";
36
- import { checkSimulation } from "./validate/checkSimulation.js";
37
- import "./validate/index.js";
38
- export { AllowancePrerequisite, BalancePrerequisite, CreditAccountState, Prerequisite, RWAOpenRequirementsPrerequisite, TransferAlignmentError, UnexpectedFacadeEventOrderError, UnknownAdapterError, UnknownFacadeCallError, WithdrawCollateralAlignmentError, adapterCallOutsideBracketError, asPreviewSimulationError, buildDelayedStrategyPositionOperationPreview, checkOperation, checkPrerequisites, checkSimulation, classifyCloseOrRepay, classifyInnerOperations, collateralIssue, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, extractAdapterCallTraces, extractTransfers, findFacadeCalls, invalidTransactionValueError, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, malformedBracketError, marketIssues, nonAdapterCallInBracketError, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, quotaCountIssue, raise, refuse, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, unpreviewableAdapterCallError, unsupportedOutOfBracketCallError };
@@ -1 +0,0 @@
1
- {"type": "module","sideEffects":false}
@@ -1 +0,0 @@
1
- export {};