@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
@@ -1,8 +1,9 @@
1
1
  import { Bps, ChainId, Leverage, Timestamp, Token, TokenAmount, UnderlyingToken } from "./primitives.js";
2
- import { IGearboxError } from "./errors.js";
3
- import { UnpriceableTokenError } from "../onchain/market/oracle/errors.js";
4
2
  import { Curator } from "./curators.js";
5
3
  import { DelayedIntent } from "./delayed-intents.js";
4
+ import { RWAOperationArgs } from "./rwa.js";
5
+ import { UnpriceableTokenError } from "./errors/oracle-errors.js";
6
+ import "./errors/index.js";
6
7
  import { BorrowRateBreakdown } from "./positions.js";
7
8
  import { Address, Hex } from "viem";
8
9
  //#region src/model/previews.d.ts
@@ -12,7 +13,6 @@ import { Address, Hex } from "viem";
12
13
  type PoolOperationType = "Deposit" | "Mint" | "Withdraw" | "Redeem";
13
14
  /**
14
15
  * Raw-calldata operation to preview: the chain and the transaction fields.
15
- * The on-chain SDK is resolved from {@link chainId} by the caller.
16
16
  **/
17
17
  interface PreviewOperationInput {
18
18
  /**
@@ -46,86 +46,6 @@ interface PreviewOperationOptions {
46
46
  **/
47
47
  blockNumber?: bigint;
48
48
  }
49
- /**
50
- * Which `storeExpectedBalances`/`compareBalances` invariant was broken.
51
- **/
52
- type MalformedBracketKind = "nested" | "unmatchedStore" | "unmatchedCompare";
53
- /**
54
- * Broken `storeExpectedBalances`/`compareBalances` bracket structure:
55
- * nested brackets, `compareBalances` without a preceding
56
- * `storeExpectedBalances`, or `storeExpectedBalances` without a matching
57
- * `compareBalances`. We expect transactions generated by the frontend
58
- * using the router/withdrawal compressor.
59
- **/
60
- interface MalformedBracketError extends IGearboxError {
61
- code: "malformedBracket";
62
- /** Which bracket invariant was broken. */
63
- kind: MalformedBracketKind;
64
- }
65
- /**
66
- * Adapter call outside a `storeExpectedBalances`/`compareBalances` bracket.
67
- * We expect transactions generated by the frontend using the
68
- * router/withdrawal compressor.
69
- **/
70
- interface AdapterCallOutsideBracketError extends IGearboxError {
71
- code: "adapterCallOutsideBracket";
72
- /** Adapter the out-of-bracket call targeted. */
73
- adapter: Address;
74
- }
75
- /**
76
- * Bracketed call whose target is not an adapter (or an adapter the SDK
77
- * does not know).
78
- **/
79
- interface NonAdapterCallInBracketError extends IGearboxError {
80
- code: "nonAdapterCallInBracket";
81
- /** Contract the bracketed call targeted. */
82
- target: Address;
83
- }
84
- /**
85
- * Bracketed adapter call cannot be replayed (undecodable/unsupported
86
- * calldata).
87
- **/
88
- interface UnpreviewableAdapterCallError extends IGearboxError {
89
- code: "unpreviewableAdapterCall";
90
- /** Adapter whose calldata could not be replayed. */
91
- adapter: Address;
92
- }
93
- /**
94
- * An out-of-bracket adapter call that is allowed there (e.g. RWA
95
- * wrap/unwrap) could not be decoded or replayed.
96
- **/
97
- interface UnsupportedOutOfBracketCallError extends IGearboxError {
98
- code: "unsupportedOutOfBracketCall";
99
- /** Adapter whose out-of-bracket call could not be replayed. */
100
- adapter: Address;
101
- }
102
- /**
103
- * `msg.value` does not fit into the declared WETH collateral.
104
- * Transactions can have arbitrary value, but the ones the frontend
105
- * creates should have a value that fits into the declared WETH collateral.
106
- **/
107
- interface InvalidTransactionValueError extends IGearboxError {
108
- code: "invalidTransactionValue";
109
- /** Transaction `msg.value`. */
110
- value: bigint;
111
- /** WETH collateral declared by the multicall. */
112
- wethCollateral: bigint;
113
- }
114
- /**
115
- * The transaction itself is malformed: fields derived from replayed
116
- * balances may be unreliable. `checkPreviewError` maps any of these to
117
- * `malformedTransaction`.
118
- **/
119
- type MalformedPreviewError = MalformedBracketError | AdapterCallOutsideBracketError | NonAdapterCallInBracketError | UnpreviewableAdapterCallError | UnsupportedOutOfBracketCallError | InvalidTransactionValueError;
120
- /**
121
- * Non-throwing preview caveat. When set on a preview, all fields are still
122
- * computed best-effort, but some of them may be unreliable.
123
- *
124
- * `MalformedPreviewError` means the transaction would not execute correctly
125
- * on-chain. {@link UnpriceableTokenError} means the transaction may be fine,
126
- * but the SDK could not fully evaluate the preview.
127
- **/
128
- type OperationPreviewError = MalformedPreviewError | UnpriceableTokenError;
129
49
  /**
130
50
  * What a pool transaction that already exists would do — the counterpart of
131
51
  * `prepare.deposit`, `prepare.withdraw` and `prepare.redeem`, read off calldata
@@ -137,6 +57,17 @@ interface PoolPositionOperationPreview {
137
57
  * Pool address
138
58
  */
139
59
  pool: Address;
60
+ /**
61
+ * Call target when the operation is zapper-routed. The wallet approves this
62
+ * instead of the pool. Absent on a direct pool call.
63
+ */
64
+ zapper?: Address;
65
+ /**
66
+ * Whose share balance {@link netValue} describes and whose shares burn on a
67
+ * withdrawal or redeem (the calldata's `owner` there, its `receiver` on a
68
+ * deposit or mint).
69
+ */
70
+ holder: Address;
140
71
  /**
141
72
  * Human-readable pool name
142
73
  */
@@ -153,7 +84,7 @@ interface PoolPositionOperationPreview {
153
84
  * In case of deposit, underlying for direct deposit, zapper input for zapper-routed deposit.
154
85
  * In case of withdraw, pool shares (diesel token) for direct withdraw or zapper token out.
155
86
  *
156
- * On withdraw, this is the amount of shares burend that covers both the requested payout
87
+ * On withdraw, this is the amount of shares burned that covers both the requested withdrawal
157
88
  * and the fee.
158
89
  *
159
90
  * On redeem this is the shares from calldata, fee-free.
@@ -189,11 +120,6 @@ interface PoolPositionOperationPreview {
189
120
  * {@link tokenOut} instead.
190
121
  */
191
122
  netValue: TokenAmount;
192
- /**
193
- * Set when preview encountered non-fatal caveats, all fields are
194
- * still computed best-effort
195
- */
196
- warning?: OperationPreviewError;
197
123
  }
198
124
  /**
199
125
  * The market a credit operation acts on, reported the same way by every half of
@@ -425,12 +351,9 @@ interface AccountStateChange {
425
351
  assetsChange: TokenAmount[];
426
352
  }
427
353
  /**
428
- * What an account-opening transaction that already exists would do — the
429
- * counterpart of `prepare.openNewStrategy`, read off calldata rather than
430
- * planned into it.
354
+ * Fields every account opening shares.
431
355
  **/
432
- interface OpenStrategyPositionPreview extends EstimatedProjection {
433
- operation: "OpenCreditAccount" | "RWAOpenCreditAccount";
356
+ interface OpenStrategyPositionProjection extends EstimatedProjection {
434
357
  /**
435
358
  * Collateral token this position is a strategy in: the first quoted token,
436
359
  * with its balance taken from `estAssets` — so, like them, the floor the
@@ -447,12 +370,36 @@ interface OpenStrategyPositionPreview extends EstimatedProjection {
447
370
  */
448
371
  collateralAdded: TokenAmount[];
449
372
  /**
450
- * Set when preview encountered non-fatal caveats, all fields are
451
- * still computed best-effort, but derived fields (`estAssets`,
452
- * `targetCollateral`, `estNetValue`) may be unreliable in that case.
373
+ * The oracle could not price a token; it contributes nothing to the values.
453
374
  */
454
- warning?: OperationPreviewError;
375
+ warning?: UnpriceableTokenError;
455
376
  }
377
+ /**
378
+ * What a facade account-opening transaction that already exists would do —
379
+ * the counterpart of `prepare.openNewStrategy` on a non-RWA market, read off
380
+ * calldata rather than planned into it.
381
+ **/
382
+ interface OpenNonRWAStrategyPositionPreview extends OpenStrategyPositionProjection {
383
+ operation: "OpenCreditAccount";
384
+ }
385
+ /**
386
+ * What an RWA-factory account-opening transaction that already exists would
387
+ * do — the counterpart of `prepare.openNewStrategy` on an RWA market.
388
+ **/
389
+ interface OpenRWAStrategyPositionPreview extends OpenStrategyPositionProjection {
390
+ operation: "RWAOpenCreditAccount";
391
+ /**
392
+ * Registration args the factory received (Securitize: `tokensToRegister`,
393
+ * `signaturesToCache`).
394
+ */
395
+ rwaArgs: RWAOperationArgs;
396
+ }
397
+ /**
398
+ * What an account-opening transaction that already exists would do — the
399
+ * counterpart of `prepare.openNewStrategy`, read off calldata rather than
400
+ * planned into it.
401
+ **/
402
+ type OpenStrategyPositionPreview = OpenNonRWAStrategyPositionPreview | OpenRWAStrategyPositionPreview;
456
403
  /**
457
404
  * What a transaction on an existing account would do — the counterpart of the
458
405
  * `prepare` flows that adjust one (`depositStrategy`, `withdrawStrategy`,
@@ -488,11 +435,9 @@ interface AdjustStrategyPositionPreview extends EstimatedProjection, AccountStat
488
435
  */
489
436
  intent?: DelayedIntent;
490
437
  /**
491
- * Set when preview encountered non-fatal caveats, all fields are
492
- * still computed best-effort, but derived fields (`estAssets`, `assetsChange`,
493
- * `estTotalValue`) may be unreliable in that case.
438
+ * The oracle could not price a token; it contributes nothing to the values.
494
439
  */
495
- warning?: OperationPreviewError;
440
+ warning?: UnpriceableTokenError;
496
441
  }
497
442
  /**
498
443
  * What an exit transaction that already exists would do — the counterpart of
@@ -530,12 +475,9 @@ interface ExitStrategyPositionPreview extends EstimatedProjection {
530
475
  */
531
476
  intent?: DelayedIntent;
532
477
  /**
533
- * Set when preview encountered non-fatal caveats, all fields are
534
- * still computed best-effort, but the
535
- * balance-derived `receivedAmount` and the projected holdings may be
536
- * unreliable in that case.
478
+ * The oracle could not price a token; it contributes nothing to the values.
537
479
  */
538
- warning?: OperationPreviewError;
480
+ warning?: UnpriceableTokenError;
539
481
  }
540
482
  /**
541
483
  * What a settling repayment that already exists would do — the counterpart of
@@ -586,12 +528,9 @@ interface RepayStrategyPositionPreview extends EstimatedProjection {
586
528
  */
587
529
  intent?: DelayedIntent;
588
530
  /**
589
- * Set when preview encountered non-fatal caveats, all fields are
590
- * still computed best-effort, but the
591
- * balance-derived `collateralWithdrawn` and the projected holdings may be
592
- * unreliable in that case.
531
+ * The oracle could not price a token; it contributes nothing to the values.
593
532
  */
594
- warning?: OperationPreviewError;
533
+ warning?: UnpriceableTokenError;
595
534
  }
596
535
  /**
597
536
  * Preview of the "instant" part of an operation on an existing credit
@@ -646,4 +585,4 @@ interface DelayedStrategyPositionOperationPreview extends CreditOperationMarket
646
585
  */
647
586
  type OperationPreview = PoolPositionOperationPreview | OpenStrategyPositionPreview | AdjustStrategyPositionPreview | ExitStrategyPositionPreview | RepayStrategyPositionPreview | DelayedStrategyPositionOperationPreview;
648
587
  //#endregion
649
- export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdapterCallOutsideBracketError, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, InvalidTransactionValueError, MalformedBracketError, MalformedBracketKind, MalformedPreviewError, NonAdapterCallInBracketError, OpenStrategyPositionPreview, OperationPreview, OperationPreviewError, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, UnpreviewableAdapterCallError, UnsupportedOutOfBracketCallError, asEstimated };
588
+ export { AccountHoldings, AccountMetrics, AccountProjection, AccountStateChange, AdjustStrategyPositionPreview, CreditOperationMarket, DelayedStrategyPositionOperationPreview, Estimated, EstimatedProjection, ExitStrategyPositionPreview, InstantStrategyPositionOperationPreview, OpenNonRWAStrategyPositionPreview, OpenRWAStrategyPositionPreview, OpenStrategyPositionPreview, OperationPreview, PoolOperationType, PoolPositionOperationPreview, PreviewOperationInput, PreviewOperationOptions, RepayStrategyPositionPreview, RoutedField, asEstimated };
@@ -1,4 +1,5 @@
1
- import { IGearboxError } from "./errors.js";
1
+ import { IGearboxError } from "./errors/base.js";
2
+ import "./errors/index.js";
2
3
  //#region src/model/result.d.ts
3
4
  /**
4
5
  * The success half of every refusable answer: the data the method was asked
@@ -23,7 +24,7 @@ interface SDKError<E extends IGearboxError = IGearboxError> {
23
24
  *
24
25
  * ```ts
25
26
  * const res = await sdk.opportunities.prepare.depositStrategy(position, params);
26
- * if (isSDKError(res)) {
27
+ * if (!res.ok) {
27
28
  * return showRefusal(res.error); // res.error: exactly this method's union
28
29
  * }
29
30
  * res.data; // res.data: StrategyResult
@@ -54,10 +55,5 @@ declare function safeValue<T, E extends IGearboxError = IGearboxError>(value: T,
54
55
  declare function sdkOk<T>(data: T): SDKResult<T>;
55
56
  /** The failure half, built. */
56
57
  declare function sdkErr<E extends IGearboxError>(error: E): SDKError<E>;
57
- /**
58
- * Narrows a {@link SDKReturn} to its failure half. Trivial over `ok`, but it
59
- * names the intent at call sites that would otherwise read `!r.ok`.
60
- **/
61
- declare function isSDKError<T, E extends IGearboxError>(answer: SDKReturn<T, E>): answer is SDKError<E>;
62
58
  //#endregion
63
- export { SDKError, SDKResult, SDKReturn, SafeValue, isSDKError, safeValue, sdkErr, sdkOk };
59
+ export { SDKError, SDKResult, SDKReturn, SafeValue, safeValue, sdkErr, sdkOk };
@@ -0,0 +1,143 @@
1
+ import { Address, Hex, TypedDataDefinition } from "viem";
2
+ //#region src/model/rwa.d.ts
3
+ /**
4
+ * Discriminant of the Securitize RWA factory contract type.
5
+ **/
6
+ declare const RWA_FACTORY_SECURITIZE = "RWA_FACTORY::SECURITIZE";
7
+ /**
8
+ * Discriminated union of all known RWA factory contract type strings.
9
+ **/
10
+ declare const RWA_FACTORY_TYPES: readonly ["RWA_FACTORY::SECURITIZE"];
11
+ /**
12
+ * String literal union of known RWA factory types.
13
+ **/
14
+ type RWAFactoryType = (typeof RWA_FACTORY_TYPES)[number];
15
+ /**
16
+ * Cached registration signature for a single DSToken, stored in the
17
+ * @see SecuritizeDegenNFT in https://github.com/Gearbox-protocol/periphery-v3
18
+ **/
19
+ interface SecuritizeRegisterMessage {
20
+ /** DSToken address the signature authorises. */
21
+ token: Address;
22
+ /** EIP-712 deadline + raw signature bytes. */
23
+ signature: SecuritizeSignature;
24
+ }
25
+ /**
26
+ * Deadline-bound EIP-712 signature produced by the investor.
27
+ **/
28
+ interface SecuritizeSignature {
29
+ /** Unix timestamp after which the signature is no longer valid. */
30
+ deadline: bigint;
31
+ /** Raw EIP-712 signature bytes. */
32
+ signature: Hex;
33
+ }
34
+ /**
35
+ * EIP-712 type schema for the `RegisterVault` message expected by Securitize's
36
+ * VaultRegistrar. Matches the contract's `RegisterVault` typehash field order.
37
+ **/
38
+ declare const SECURITIZE_REGISTER_VAULT_TYPES: {
39
+ readonly RegisterVault: readonly [{
40
+ readonly name: "investor";
41
+ readonly type: "address";
42
+ }, {
43
+ readonly name: "operator";
44
+ readonly type: "address";
45
+ }, {
46
+ readonly name: "token";
47
+ readonly type: "address";
48
+ }, {
49
+ readonly name: "nonce";
50
+ readonly type: "uint256";
51
+ }, {
52
+ readonly name: "deadline";
53
+ readonly type: "uint256";
54
+ }];
55
+ };
56
+ /**
57
+ * EIP-712 typed-data message that must be signed by the investor to allow the
58
+ * RWA factory to register a credit account as a vault in Securitize's VaultRegistrar.
59
+ *
60
+ * Shaped as a viem {@link TypedDataDefinition} so it can be spread directly into
61
+ * `walletClient.signTypedData({ account, ...message })`. The caller only has to
62
+ * supply the signing `account`.
63
+ *
64
+ * - `domain` — EIP-712 domain from the VaultRegistrar contract.
65
+ * - `message.investor` — investor EOA that will sign the message.
66
+ * - `message.operator` — operator address (the DegenNFT contract).
67
+ * - `message.token` — DSToken address to register for.
68
+ * - `message.nonce` — monotonic nonce from VaultRegistrar `(investor, operator)`.
69
+ * - `message.deadline` — unix timestamp after which the message is no longer valid.
70
+ *
71
+ * @see VaultRegistrar in https://github.com/Gearbox-protocol/periphery-v3
72
+ **/
73
+ type SecuritizeRegisterVaultMessage = TypedDataDefinition<typeof SECURITIZE_REGISTER_VAULT_TYPES, "RegisterVault">;
74
+ /**
75
+ * Factory-specific args for a Securitize RWA factory `multicall` /
76
+ * `openCreditAccount`.
77
+ **/
78
+ interface SecuritizeOperationArgs {
79
+ type: typeof RWA_FACTORY_SECURITIZE;
80
+ /** DSToken addresses to register for this operation. */
81
+ tokensToRegister: Address[];
82
+ /** Cached EIP-712 registration signatures to store on-chain. */
83
+ signaturesToCache: SecuritizeRegisterMessage[];
84
+ }
85
+ /**
86
+ * Subset of {@link SecuritizeOpenAccountRequirements} still unfulfilled given
87
+ * the params already carried by the transaction calldata. Returned by
88
+ * `SecuritizeRWAFactory.getMissingRequirements`; `undefined` there means the
89
+ * requirements are satisfied.
90
+ **/
91
+ interface SecuritizeMissingOpenAccountRequirements {
92
+ type: typeof RWA_FACTORY_SECURITIZE;
93
+ /**
94
+ * EIP-712 messages the investor still has to sign (not covered by
95
+ * calldata-provided signatures). Once signed, they become the
96
+ * `signaturesToCache` arg of the factory's `openCreditAccount`/`multicall`
97
+ * calls (see {@link SecuritizeOperationArgs}).
98
+ */
99
+ requiredSignatures: SecuritizeRegisterVaultMessage[];
100
+ }
101
+ interface SecuritizeOpenAccountRequirements {
102
+ type: typeof RWA_FACTORY_SECURITIZE;
103
+ /**
104
+ * User must visit securitize website to register these tokens
105
+ * May be empty if user already registered all required tokens
106
+ */
107
+ securitizeTokensToRegister: Address[];
108
+ /**
109
+ * Desired tokens to register for this operation, must be always present on open credit account
110
+ * Come from strategy configuration
111
+ * Passed to openCreditAccount contract call on securitize factory
112
+ */
113
+ tokensToRegister: Address[];
114
+ /**
115
+ * User must sign these messages to gearbox and provide EIP-712 signatures
116
+ * as {@link SecuritizeRegisterMessage} to gearbox
117
+ */
118
+ requiredSignatures: SecuritizeRegisterVaultMessage[];
119
+ }
120
+ /**
121
+ * Open-account requirements for a RWA factory, defaults to union of all factory types.
122
+ * Can be discriminated by type.
123
+ **/
124
+ type RWAOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeOpenAccountRequirements, {
125
+ type: T;
126
+ }>;
127
+ /**
128
+ * Subset of {@link RWAOpenAccountRequirements} that is still unfulfilled,
129
+ * defaults to union of all factory types.
130
+ * Can be discriminated by type.
131
+ **/
132
+ type RWAMissingOpenAccountRequirements<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeMissingOpenAccountRequirements, {
133
+ type: T;
134
+ }>;
135
+ /**
136
+ * Open credit account/Multicall extra params type for a RWA factory, defaults to union of all factory types.
137
+ * Can be discriminated by type.
138
+ **/
139
+ type RWAOperationArgs<T extends RWAFactoryType = RWAFactoryType> = Extract<SecuritizeOperationArgs, {
140
+ type: T;
141
+ }>;
142
+ //#endregion
143
+ export { RWAFactoryType, RWAMissingOpenAccountRequirements, RWAOpenAccountRequirements, RWAOperationArgs, RWA_FACTORY_SECURITIZE, RWA_FACTORY_TYPES, SECURITIZE_REGISTER_VAULT_TYPES, SecuritizeMissingOpenAccountRequirements, SecuritizeOpenAccountRequirements, SecuritizeOperationArgs, SecuritizeRegisterMessage, SecuritizeRegisterVaultMessage, SecuritizeSignature };
@@ -1,6 +1,8 @@
1
+ import { RWAOpenAccountRequirements } from "../../model/rwa.js";
2
+ import "../../model/index.js";
1
3
  import { RequestableWithdrawal } from "./withdrawal-compressor/types.js";
2
4
  import { Asset, CreditAccountData, CreditAccountTokensSlice, PermitResult } from "../base/types.js";
3
- import { GetOpenAccountRequirementsProps, RWAOpenAccountRequirements } from "../market/rwa/types.js";
5
+ import { GetOpenAccountRequirementsProps } from "../market/rwa/types.js";
4
6
  import "../market/rwa/index.js";
5
7
  import { PriceUpdate } from "../market/pricefeeds/types.js";
6
8
  import { PrepareUpdateQuotasProps } from "../market/credit/types.js";
@@ -1,4 +1,3 @@
1
- import { InvalidDelayedIntentError } from "./withdrawal-compressor/errors.js";
2
1
  import { ClaimableWithdrawal, CurrentWithdrawals, DelayedIntentExtended, GetExternalAccountCurrentWithdrawalsProps, GetWithdrawalRequestResultProps, IRedemptionLoggerContract, IWithdrawalCompressorContract, PendingWithdrawal, RedemptionLog, RequestableWithdrawal, WithdrawableAsset, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, toWithdrawalStatus } from "./withdrawal-compressor/types.js";
3
2
  import { CreditAccountDataCall, CreditAccountFilter, CreditAccountReadOptions, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsTarget, CreditManagerFilter, GetCreditAccountsArgs, GetCreditAccountsOptions } from "./credit-account-compressor/types.js";
4
3
  import { CreditAccountCompressor } from "./credit-account-compressor/CreditAccountCompressor.js";
@@ -20,11 +19,10 @@ import { AccountBotsService } from "./bots/AccountBotsService.js";
20
19
  import { PeripheryCompressorV310Contract } from "./bots/PeripheryCompressorV310Contract.js";
21
20
  import "./bots/index.js";
22
21
  import { CreditAccountsServiceV310 } from "./CreditAccountsServiceV310.js";
23
- import { borrowable } from "./intents/guards.js";
24
22
  import { LeverageBand } from "./intents/leverage-band.js";
25
23
  import { CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, roundUpQuota } from "./quota-utils.js";
26
24
  import { AccountCalculatorOperation } from "./intents/operations.js";
27
- import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
25
+ import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./intents/types.js";
28
26
  import { OpenStrategyProps, OpenStrategyState } from "./intents/open-strategy.js";
29
27
  import { fetchCreditAccountSlice, toCreditAccountSlice } from "./intents/utils/credit-account-slice.js";
30
28
  import { isPhantomToken } from "./intents/utils/pick-token.js";
@@ -34,4 +32,4 @@ import { BuildLiquidationTxProps, BuildLiquidationTxPropsBase, GetLiquidatableAc
34
32
  import { LiquidationsService } from "./liquidations/LiquidationsService.js";
35
33
  import { MultichainLiquidationsService } from "./liquidations/MultichainLiquidationsService.js";
36
34
  import "./liquidations/index.js";
37
- export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, InvalidDelayedIntentError, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteRefusals, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, borrowable, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
35
+ export { AbstractWithdrawalCompressorContract, AccountBotsService, type AccountCalculatorOperation, AccountToCheck, type AddCollateralIntent, type AdjustLeverageIntent, AssembleCaOperationsProps, AssembleClaimDelayedCallsProps, AssembleCloseCreditAccountCallsProps, AssembleRepayCreditAccountCallsProps, AssembleStartDelayedWithdrawalCallsProps, BotStatusCall, BotsDirectResponse, BuildLiquidationTxProps, BuildLiquidationTxPropsBase, CMSlice, CalcDefaultQuotaProps, CalcQuotaUpdateProps, CalcRecommendedQuotaProps, ClaimFarmRewardsProps, type ClaimRemainder, ClaimableWithdrawal, CloseCreditAccountResult, ConnectedBotsCall, ConnectedBotsPerAccount, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountDataCall, CreditAccountFilter, CreditAccountOperationResult, CreditAccountOperationsService, CreditAccountReadOptions, type CreditAccountSlice, CreditAccountsCall, CreditAccountsQuery, CreditAccountsReadOptions, CreditAccountsServiceV310, CreditAccountsTarget, CreditManagerFilter, CreditManagerOperationResult, CurrentWithdrawals, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, type DelayableIntent, DelayedIntentExtended, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, EncodableCreditAccountOperation, type FinishIntentProps, type FinishIntentResult, FullyLiquidateProps, FullyLiquidateResult, GetApprovalAddressProps, GetConnectedBotsResponse, GetConnectedBotsResult, GetConnectedMigrationBotsResult, GetCreditAccountsArgs, GetCreditAccountsOptions, GetExternalAccountCurrentWithdrawalsProps, GetLiquidatableAccountsProps, GetLiquidationDetailsProps, GetLiquidationDetailsPropsBase, GetLiquidationPositionsProps, GetLiquidationPositionsPropsBase, GetWithdrawalRequestResultProps, ICreditAccountsService, IRedemptionLoggerContract, IWithdrawalCompressorContract, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, type LeverageBand, LiquidationsService, LoadRWALiquidatorsProps, MulticallWithFailure, MultichainLiquidationsService, OnchainLiquidationCall, OnchainLiquidationData, OnchainLiquidationOutput, OnchainRequestableWithdrawal, OpenCAProps, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, PartiallyLiquidateProps, type PathLossRate, PendingWithdrawal, PeripheryCompressorV310Contract, PreviewDelayedWithdrawalProps, RWALiquidatorInfo, RedemptionLog, RedemptionLoggerV310Contract, type RepayStrategyIntent, RequestableWithdrawal, type ResumableIntent, Rewards, type RouteErrors, SetBotProps, SetBotResult, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, WithdrawableAsset, WithdrawalCompressorLocation, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WithdrawalCompressorVersion, WithdrawalOutput, WithdrawalStatus, WithdrawalsState, calcDefaultQuota, calcQuotaUpdate, calcRecommendedQuota, createRedemptionLogger, createWithdrawalCompressor, decodeDelayedIntent, encodeDelayedIntent, fetchCreditAccountSlice, getWithdrawalCompressorAddress, iCreditAccountAbi, isPhantomToken, roundUpQuota, toClaimableWithdrawal, toCreditAccountSlice, toPendingWithdrawal, toRequestableWithdrawal, toWithdrawalStatus };
@@ -2,7 +2,6 @@ import { Asset } from "../../base/types.js";
2
2
  import { MarketSuite } from "../../market/MarketSuite.js";
3
3
  import { CreditSuite } from "../../market/credit/CreditSuite.js";
4
4
  import { OnchainSDK } from "../../OnchainSDK.js";
5
- import { BorrowLimitBinding } from "../../validation/refusal.js";
6
5
  import "../../index.js";
7
6
  //#region src/onchain/accounts/intents/guards.d.ts
8
7
  /**
@@ -24,16 +23,6 @@ import "../../index.js";
24
23
  * every intent the engine previews would revert on arrival.
25
24
  */
26
25
  declare function assertMarketOperable(suite: CreditSuite): void;
27
- /**
28
- * What the pool will hand this manager in one transaction: the tightest of its
29
- * free liquidity, the manager's remaining debt limit and the per-block cap the
30
- * facade puts on a single borrow. A zero multiplier switches borrowing off
31
- * outright, which reads here as nothing being available.
32
- */
33
- declare function borrowable(suite: CreditSuite): {
34
- limit: bigint;
35
- binding: BorrowLimitBinding;
36
- };
37
26
  /** The pool has to be able to lend what the plan means to draw. */
38
27
  declare function assertCanBorrow(sdk: OnchainSDK, suite: CreditSuite, amount: bigint): void;
39
28
  /**
@@ -60,19 +49,20 @@ declare function assertGrowthAllowed(args: {
60
49
  * and reverts if the collateral does not cover it, so a plan that lands the
61
50
  * account below water is refused here.
62
51
  *
63
- * The bar is the facade's own `1.0`, because this guard answers one question:
64
- * would the transaction revert. It is deliberately not `MIN_HF_LIMITED`, and
65
- * the three bars in this codebase are three different jobs:
52
+ * The threshold is the facade's own `1.0`, because this guard answers one
53
+ * question: would the transaction revert. It is deliberately not
54
+ * `MIN_HF_LIMITED`, and the three thresholds in this codebase are three
55
+ * different jobs:
66
56
  *
67
57
  * - here, `1.0` — what the facade enforces, so what a plan must clear to land;
68
58
  * - `maxWithdrawCollateral` sizes at `MIN_HF_LIMITED + 2` — a *sizing* helper
69
- * leaving headroom, which is not the same as a validity check;
59
+ * leaving a margin, which is not the same as a validity check;
70
60
  * - a form refuses at or below `MIN_HF_LIMITED` (`MIN_HEALTH_FACTOR_FORM`).
71
61
  *
72
62
  * Raising this one to `MIN_HF_LIMITED` was tried and reverted: it made
73
63
  * `maxWithdraw` hand back a ceiling this guard then refused, and it blocked
74
64
  * small top-ups of an account sitting in `[1.0, 1.01)` — the very operations
75
- * that rescue it. A form wanting the stricter bar has `validateHF`.
65
+ * that rescue it. A form wanting the stricter threshold has `validateHF`.
76
66
  *
77
67
  * Note that a position already underwater cannot be nursed back one step at a
78
68
  * time — the check is on where the transaction ends, not on whether it
@@ -89,6 +79,6 @@ declare function assertCollateralised(healthFactorBps: number, safePrices: boole
89
79
  * A quota can only be raised as far as the market still has room for: past the
90
80
  * token's limit the keeper takes nothing more, whoever is asking.
91
81
  */
92
- declare function assertQuotaHeadroom(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
82
+ declare function assertQuotaAvailable(sdk: OnchainSDK, market: MarketSuite, increases: readonly Asset[]): void;
93
83
  //#endregion
94
- export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaHeadroom, borrowable };
84
+ export { assertCanBorrow, assertCollateralised, assertGrowthAllowed, assertMarketOperable, assertQuotaAvailable };
@@ -1,9 +1,10 @@
1
+ import { SDKError } from "../../../model/result.js";
2
+ import "../../../model/index.js";
1
3
  import { SDKConstruct } from "../../base/SDKConstruct.js";
2
- import { PreviewRefusal } from "../../validation/refusal.js";
3
- import { borrowable } from "./guards.js";
4
+ import { IntentValidationError } from "../../validation/raise.js";
4
5
  import { LeverageBand, LeverageBandProps } from "./leverage-band.js";
5
6
  import { AccountCalculatorOperation } from "./operations.js";
6
- import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteRefusals, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./types.js";
7
+ import { AddCollateralIntent, AdjustLeverageIntent, ClaimRemainder, CreditAccountSlice, DelayableIntent, DelayedRoute, DelayedStart, DelayedStartResult, DepositStrategyIntent, FinishIntentProps, FinishIntentResult, InstantRoute, IntentPreviewResult, IntentRoutesResult, OperationState, PathLossRate, RepayStrategyIntent, ResumableIntent, RouteErrors, StartIntent, StartIntentProps, WithdrawAssetIntent, WithdrawCeilings, WithdrawStrategyIntent } from "./types.js";
7
8
  import { OpenStrategyProps, OpenStrategyState } from "./open-strategy.js";
8
9
  import { fetchCreditAccountSlice, toCreditAccountSlice } from "./utils/credit-account-slice.js";
9
10
  import { isPhantomToken } from "./utils/pick-token.js";
@@ -19,7 +20,7 @@ import { Address } from "viem";
19
20
  type OpenStrategyPreviewResult = {
20
21
  ok: true;
21
22
  state: OpenStrategyState;
22
- } | PreviewRefusal;
23
+ } | SDKError<IntentValidationError>;
23
24
  /** An intent plus everything previewing it needs. */
24
25
  type StartProps = StartIntentProps & {
25
26
  intent: StartIntent;
@@ -37,15 +38,15 @@ declare class CreditAccountOperationsService extends SDKConstruct {
37
38
  * Previews an operation on an existing account.
38
39
  *
39
40
  * @param props - Intent plus account slice, quota reserve and slippage
40
- * @returns Operations, projected state and calldata, or `{ ok: false, reason }`
41
+ * @returns Operations, projected state and calldata, or `{ ok: false, error }`
41
42
  * when the intent cannot be satisfied (e.g. the account lacks the source
42
43
  * balance)
43
44
  */
44
45
  startIntent(props: StartProps): Promise<IntentPreviewResult>;
45
46
  /**
46
47
  * Both ends of what a `WITHDRAW` can take out, in underlying: the largest
47
- * partial withdrawal that keeps leverage and stays inside the facade's debt
48
- * band, and the net value an exit hands over. They are reported together
48
+ * partial withdrawal that keeps leverage and stays inside the facade's
49
+ * `debtLimits`, and the net value an exit hands over. They are reported together
49
50
  * because a withdraw form needs both — the range it may offer, and the one
50
51
  * amount past it that is allowed — and because the distance between them is
51
52
  * the account's own, not a constant a caller could assume.
@@ -78,8 +79,8 @@ declare class CreditAccountOperationsService extends SDKConstruct {
78
79
  *
79
80
  * A credit manager's `maxLeverage` follows from the liquidation threshold
80
81
  * alone, so it is the same for a hundred dollars and for a million. What a
81
- * given deposit reaches is decided by the debt it implies and by the band
82
- * the market puts that debt in — the range a leverage slider should offer.
82
+ * given deposit reaches is decided by the debt it implies and by the
83
+ * `debtLimits` the market puts that debt in — the range a leverage slider should offer.
83
84
  *
84
85
  * Unlike the other ceilings here this one reads no account: opening has none
85
86
  * yet, and adjusting measures against the net value the caller already
@@ -96,9 +97,9 @@ declare class CreditAccountOperationsService extends SDKConstruct {
96
97
  * while its health factor stays at `targetHF` — the ceiling a
97
98
  * withdraw-collateral form should offer. Thresholds, prices and quota
98
99
  * activity come from the account's market, valued the way the facade values
99
- * a call that pays out; zero debt frees the whole balance.
100
+ * a call that withdraws collateral; zero debt frees the whole balance.
100
101
  *
101
- * The default is {@link MIN_HF_LIMITED}, the bar a form holds an
102
+ * The default is {@link MIN_HF_LIMITED}, the threshold a form holds an
102
103
  * account to.
103
104
  *
104
105
  * @param props - Account slice, the SDK holding its market, the collateral
@@ -115,8 +116,8 @@ declare class CreditAccountOperationsService extends SDKConstruct {
115
116
  *
116
117
  * Sits apart from {@link startIntent} because it is a different trade route,
117
118
  * not a different intent: the request goes to the issuer instead of the
118
- * router, and the proceeds — hence the repayment and the payout — arrive days
119
- * later. Both routes of one intent are quoted together by
119
+ * router, and what it sells for — hence the repayment and the withdrawal —
120
+ * arrives days later. Both routes of one intent are quoted together by
120
121
  * {@link intentRoutes}; this is the one to call when the delayed route is the
121
122
  * only one of interest.
122
123
  *
@@ -128,7 +129,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
128
129
  *
129
130
  * @param props - Intent plus account slice, quota reserve and slippage
130
131
  * @returns The request transaction, the state it ends in and what it recorded
131
- * for the tail, or `{ ok: false, reason }` — `noDelayedRoute` when this route
132
+ * for the tail, or `{ ok: false, error }` — `noDelayedRoute` when this route
132
133
  * does not exist for the account at all
133
134
  */
134
135
  startDelayedIntent(props: StartIntentProps & {
@@ -141,7 +142,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
141
142
  * Which routes an account has depends on the intent and the token it sells,
142
143
  * and a form has to know before it can offer a choice — so both are quoted
143
144
  * from the same request and each is reported on its own. A route the account
144
- * cannot take comes back `undefined` with its refusal in `refused`; only when
145
+ * cannot take comes back `undefined` with its error in `errors`; only when
145
146
  * neither answers is the whole result `{ ok: false }`.
146
147
  *
147
148
  * A route that could not be quoted at all — a pathfinder with no path out of
@@ -151,7 +152,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
151
152
  *
152
153
  * @param props - A withdraw or adjust-leverage intent plus account slice,
153
154
  * quota reserve and slippage
154
- * @returns Whichever routes are viable, or `{ ok: false, reason }` when none is
155
+ * @returns Whichever routes are viable, or `{ ok: false, error }` when none is
155
156
  */
156
157
  intentRoutes(props: StartIntentProps & {
157
158
  intent: DelayableIntent;
@@ -166,7 +167,7 @@ declare class CreditAccountOperationsService extends SDKConstruct {
166
167
  * catch up.
167
168
  *
168
169
  * A claim that brought only part of what the request queued — a legacy Mellow
169
- * multivault, which pays out what it holds liquid and re-queues the rest — is
170
+ * multivault, which hands over what it holds liquid and re-queues the rest — is
170
171
  * served in proportion, and what it did not settle comes back as `remainder`:
171
172
  * the withdrawal still in flight and the intent to finish it with.
172
173
  *
@@ -185,10 +186,10 @@ declare class CreditAccountOperationsService extends SDKConstruct {
185
186
  *
186
187
  * @param props - Credit manager, wallet collateral, target token and leverage
187
188
  * @returns Debt, position size, projected balances and quotas for both the
188
- * expected and the floor branch, or `{ ok: false, reason }` when the requested
189
+ * expected and the floor branch, or `{ ok: false, error }` when the requested
189
190
  * leverage or the resulting debt is not viable
190
191
  */
191
192
  openStrategyIntent(props: OpenStrategyProps): Promise<OpenStrategyPreviewResult>;
192
193
  }
193
194
  //#endregion
194
- export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type ClaimRemainder, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type RouteRefusals, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, borrowable, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };
195
+ export { type AccountCalculatorOperation, type AddCollateralIntent, type AdjustLeverageIntent, type ClaimRemainder, CreditAccountOperationsService, type CreditAccountSlice, type DelayableIntent, type DelayedRoute, type DelayedStart, type DelayedStartResult, type DepositStrategyIntent, type FinishIntentProps, type FinishIntentResult, type InstantRoute, type IntentPreviewResult, type IntentRoutesResult, type LeverageBand, OpenStrategyPreviewResult, type OpenStrategyProps, type OpenStrategyState, type OperationState, type PathLossRate, type RepayStrategyIntent, type ResumableIntent, type RouteErrors, type StartIntent, type WithdrawAssetIntent, type WithdrawCeilings, type WithdrawStrategyIntent, fetchCreditAccountSlice, isPhantomToken, toCreditAccountSlice };