@morpho-org/morpho-sdk 10.3.1 → 10.5.0-next.0

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 (344) hide show
  1. package/README.md +169 -5
  2. package/lib/cjs/abis.d.ts +1 -1
  3. package/lib/cjs/abis.js +5 -1
  4. package/lib/cjs/actions/blue/common.js +12 -3
  5. package/lib/cjs/actions/midnight/redeem.d.ts +20 -3
  6. package/lib/cjs/actions/midnight/redeem.js +58 -1
  7. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  8. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +41 -0
  9. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -2
  10. package/lib/cjs/actions/midnight/withdrawCollateral.js +26 -1
  11. package/lib/cjs/blue/abis.d.ts +1 -1
  12. package/lib/cjs/blue/abis.js +5 -1
  13. package/lib/cjs/blue/entities.d.ts +4 -4
  14. package/lib/cjs/blue/entities.js +3 -1
  15. package/lib/cjs/blue/errors.d.ts +2 -2
  16. package/lib/cjs/blue/errors.js +5 -1
  17. package/lib/cjs/blue/fetch.d.ts +2 -2
  18. package/lib/cjs/blue/fetch.js +3 -1
  19. package/lib/cjs/blue/utils.d.ts +1 -1
  20. package/lib/cjs/blue/utils.js +2 -1
  21. package/lib/cjs/entities/index.d.ts +4 -4
  22. package/lib/cjs/entities/index.js +3 -1
  23. package/lib/cjs/entities/midnight/midnight.d.ts +100 -103
  24. package/lib/cjs/entities/midnight/midnight.js +99 -99
  25. package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
  26. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
  27. package/lib/cjs/entities/vaultV2/vaultV2.js +39 -2
  28. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -2
  29. package/lib/cjs/entities/vaultV2BlueReallocationData.js +6 -2
  30. package/lib/cjs/errors.d.ts +4 -4
  31. package/lib/cjs/errors.js +7 -5
  32. package/lib/cjs/fetch.d.ts +2 -2
  33. package/lib/cjs/fetch.js +3 -1
  34. package/lib/cjs/helpers/callback.d.ts +3 -2
  35. package/lib/cjs/helpers/callback.js +4 -20
  36. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  37. package/lib/cjs/helpers/computeMidnightPostWithdrawalCollateral.js +30 -0
  38. package/lib/cjs/helpers/deadShares.js +3 -0
  39. package/lib/cjs/helpers/parseMidnightMaker.d.ts +21 -0
  40. package/lib/cjs/helpers/parseMidnightMaker.js +41 -1
  41. package/lib/cjs/helpers/validate.d.ts +60 -2
  42. package/lib/cjs/helpers/validate.js +87 -1
  43. package/lib/cjs/helpers/validateMidnightPublication.d.ts +10 -0
  44. package/lib/cjs/helpers/validateMidnightPublication.js +18 -1
  45. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  46. package/lib/cjs/helpers/validateMidnightTakeableOfferFields.js +85 -0
  47. package/lib/cjs/index.d.ts +2 -2
  48. package/lib/cjs/index.js +23 -1
  49. package/lib/cjs/midnight/errors.d.ts +2 -1
  50. package/lib/cjs/midnight/errors.js +5 -4
  51. package/lib/cjs/midnight/utils.d.ts +1 -1
  52. package/lib/cjs/midnight/utils.js +2 -1
  53. package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
  54. package/lib/cjs/transactionPlan/assemble.js +25 -0
  55. package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
  56. package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
  57. package/lib/cjs/transactionPlan/blue/repay.js +10 -24
  58. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
  59. package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
  60. package/lib/cjs/transactionPlan/blue/stored.js +87 -0
  61. package/lib/cjs/transactionPlan/blue/supply.js +7 -22
  62. package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  63. package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
  64. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
  65. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
  66. package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
  67. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  68. package/lib/cjs/transactionPlan/blue/withdrawBuyCallback.js +264 -0
  69. package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  70. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
  71. package/lib/cjs/transactionPlan/deposit.js +4 -7
  72. package/lib/cjs/transactionPlan/error.d.ts +27 -0
  73. package/lib/cjs/transactionPlan/error.js +30 -1
  74. package/lib/cjs/transactionPlan/index.d.ts +40 -1
  75. package/lib/cjs/transactionPlan/index.js +46 -5
  76. package/lib/cjs/transactionPlan/intent.d.ts +1 -1
  77. package/lib/cjs/transactionPlan/midnight/authorization.d.ts +15 -0
  78. package/lib/cjs/transactionPlan/midnight/authorization.js +45 -0
  79. package/lib/cjs/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  80. package/lib/cjs/transactionPlan/midnight/cancelOffers.js +125 -0
  81. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  82. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +126 -0
  83. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +140 -0
  84. package/lib/cjs/transactionPlan/midnight/makeLend.js +176 -0
  85. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +118 -0
  86. package/lib/cjs/transactionPlan/midnight/makeRepay.js +118 -0
  87. package/lib/cjs/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  88. package/lib/cjs/transactionPlan/midnight/makeWithdraw.js +126 -0
  89. package/lib/cjs/transactionPlan/midnight/makerPublication.d.ts +55 -0
  90. package/lib/cjs/transactionPlan/midnight/makerPublication.js +315 -0
  91. package/lib/cjs/transactionPlan/midnight/market.d.ts +49 -0
  92. package/lib/cjs/transactionPlan/midnight/market.js +120 -0
  93. package/lib/cjs/transactionPlan/midnight/prepare.d.ts +244 -0
  94. package/lib/cjs/transactionPlan/midnight/prepare.js +547 -0
  95. package/lib/cjs/transactionPlan/midnight/publicationState.d.ts +24 -0
  96. package/lib/cjs/transactionPlan/midnight/publicationState.js +50 -0
  97. package/lib/cjs/transactionPlan/midnight/redeem.d.ts +102 -0
  98. package/lib/cjs/transactionPlan/midnight/redeem.js +170 -0
  99. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  100. package/lib/cjs/transactionPlan/midnight/reduceOnlySellFeasibility.js +51 -0
  101. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  102. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +328 -0
  103. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  104. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +199 -0
  105. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  106. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +190 -0
  107. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  108. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +221 -0
  109. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  110. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +179 -0
  111. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  112. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +259 -0
  113. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  114. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +545 -0
  115. package/lib/cjs/transactionPlan/midnight/takeLend.d.ts +99 -0
  116. package/lib/cjs/transactionPlan/midnight/takeLend.js +263 -0
  117. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  118. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +440 -0
  119. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  120. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +240 -0
  121. package/lib/cjs/transactionPlan/midnight/validation.d.ts +22 -0
  122. package/lib/cjs/transactionPlan/midnight/validation.js +158 -0
  123. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  124. package/lib/cjs/transactionPlan/midnight/withdrawCollateral.js +228 -0
  125. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  126. package/lib/cjs/transactionPlan/midnight/withdrawCollateralBatch.js +232 -0
  127. package/lib/cjs/transactionPlan/permit.d.ts +15 -2
  128. package/lib/cjs/transactionPlan/permit.js +26 -68
  129. package/lib/cjs/transactionPlan/plan.d.ts +99 -15
  130. package/lib/cjs/transactionPlan/plan.js +159 -31
  131. package/lib/cjs/transactionPlan/redeem.js +4 -7
  132. package/lib/cjs/transactionPlan/requirements.d.ts +7 -4
  133. package/lib/cjs/transactionPlan/requirements.js +2 -2
  134. package/lib/cjs/transactionPlan/serde.d.ts +13 -2
  135. package/lib/cjs/transactionPlan/serde.js +68 -21
  136. package/lib/cjs/transactionPlan/types.d.ts +151 -3
  137. package/lib/cjs/transactionPlan/validateActions.d.ts +3 -1
  138. package/lib/cjs/transactionPlan/validateActions.js +31 -3
  139. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  140. package/lib/cjs/transactionPlan/validation.js +37 -1
  141. package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
  142. package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
  143. package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
  144. package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
  145. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
  146. package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
  147. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  148. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
  149. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  150. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
  151. package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
  152. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  153. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
  154. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
  155. package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
  156. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  157. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
  158. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  159. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
  160. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  161. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
  162. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
  163. package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
  164. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  165. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
  166. package/lib/cjs/transactionPlan/withdraw.js +4 -7
  167. package/lib/cjs/types/error.d.ts +4 -1
  168. package/lib/cjs/types/error.js +5 -2
  169. package/lib/cjs/utils.d.ts +2 -2
  170. package/lib/cjs/utils.js +4 -2
  171. package/lib/cjs/version.d.ts +1 -1
  172. package/lib/cjs/version.js +1 -1
  173. package/lib/esm/abis.d.ts +1 -1
  174. package/lib/esm/abis.js +1 -1
  175. package/lib/esm/actions/blue/common.js +13 -4
  176. package/lib/esm/actions/midnight/redeem.d.ts +20 -3
  177. package/lib/esm/actions/midnight/redeem.js +56 -0
  178. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +24 -1
  179. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +40 -0
  180. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -2
  181. package/lib/esm/actions/midnight/withdrawCollateral.js +25 -1
  182. package/lib/esm/blue/abis.d.ts +1 -1
  183. package/lib/esm/blue/abis.js +1 -1
  184. package/lib/esm/blue/entities.d.ts +4 -4
  185. package/lib/esm/blue/entities.js +2 -2
  186. package/lib/esm/blue/errors.d.ts +2 -2
  187. package/lib/esm/blue/errors.js +2 -2
  188. package/lib/esm/blue/fetch.d.ts +2 -2
  189. package/lib/esm/blue/fetch.js +2 -2
  190. package/lib/esm/blue/utils.d.ts +1 -1
  191. package/lib/esm/blue/utils.js +1 -1
  192. package/lib/esm/entities/index.d.ts +4 -4
  193. package/lib/esm/entities/index.js +2 -2
  194. package/lib/esm/entities/midnight/midnight.d.ts +100 -103
  195. package/lib/esm/entities/midnight/midnight.js +99 -99
  196. package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
  197. package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
  198. package/lib/esm/entities/vaultV2/vaultV2.js +40 -3
  199. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -2
  200. package/lib/esm/entities/vaultV2BlueReallocationData.js +6 -2
  201. package/lib/esm/errors.d.ts +4 -4
  202. package/lib/esm/errors.js +4 -4
  203. package/lib/esm/fetch.d.ts +2 -2
  204. package/lib/esm/fetch.js +2 -2
  205. package/lib/esm/helpers/callback.d.ts +3 -2
  206. package/lib/esm/helpers/callback.js +5 -21
  207. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.d.ts +17 -0
  208. package/lib/esm/helpers/computeMidnightPostWithdrawalCollateral.js +27 -0
  209. package/lib/esm/helpers/deadShares.js +4 -1
  210. package/lib/esm/helpers/parseMidnightMaker.d.ts +21 -0
  211. package/lib/esm/helpers/parseMidnightMaker.js +40 -1
  212. package/lib/esm/helpers/validate.d.ts +60 -2
  213. package/lib/esm/helpers/validate.js +84 -1
  214. package/lib/esm/helpers/validateMidnightPublication.d.ts +10 -0
  215. package/lib/esm/helpers/validateMidnightPublication.js +16 -0
  216. package/lib/esm/helpers/validateMidnightTakeableOfferFields.d.ts +28 -0
  217. package/lib/esm/helpers/validateMidnightTakeableOfferFields.js +81 -0
  218. package/lib/esm/index.d.ts +2 -2
  219. package/lib/esm/index.js +1 -1
  220. package/lib/esm/midnight/errors.d.ts +2 -1
  221. package/lib/esm/midnight/errors.js +2 -1
  222. package/lib/esm/midnight/utils.d.ts +1 -1
  223. package/lib/esm/midnight/utils.js +1 -1
  224. package/lib/esm/transactionPlan/assemble.d.ts +24 -0
  225. package/lib/esm/transactionPlan/assemble.js +21 -0
  226. package/lib/esm/transactionPlan/blue/borrow.js +15 -65
  227. package/lib/esm/transactionPlan/blue/refinance.js +10 -12
  228. package/lib/esm/transactionPlan/blue/repay.js +11 -25
  229. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
  230. package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
  231. package/lib/esm/transactionPlan/blue/stored.js +80 -0
  232. package/lib/esm/transactionPlan/blue/supply.js +7 -22
  233. package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  234. package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
  235. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
  236. package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
  237. package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
  238. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.d.ts +101 -0
  239. package/lib/esm/transactionPlan/blue/withdrawBuyCallback.js +259 -0
  240. package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  241. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
  242. package/lib/esm/transactionPlan/deposit.js +5 -8
  243. package/lib/esm/transactionPlan/error.d.ts +27 -0
  244. package/lib/esm/transactionPlan/error.js +28 -0
  245. package/lib/esm/transactionPlan/index.d.ts +40 -1
  246. package/lib/esm/transactionPlan/index.js +20 -1
  247. package/lib/esm/transactionPlan/intent.d.ts +1 -1
  248. package/lib/esm/transactionPlan/midnight/authorization.d.ts +15 -0
  249. package/lib/esm/transactionPlan/midnight/authorization.js +40 -0
  250. package/lib/esm/transactionPlan/midnight/cancelOffers.d.ts +80 -0
  251. package/lib/esm/transactionPlan/midnight/cancelOffers.js +120 -0
  252. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +104 -0
  253. package/lib/esm/transactionPlan/midnight/makeBorrow.js +123 -0
  254. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +140 -0
  255. package/lib/esm/transactionPlan/midnight/makeLend.js +172 -0
  256. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +118 -0
  257. package/lib/esm/transactionPlan/midnight/makeRepay.js +115 -0
  258. package/lib/esm/transactionPlan/midnight/makeWithdraw.d.ts +104 -0
  259. package/lib/esm/transactionPlan/midnight/makeWithdraw.js +123 -0
  260. package/lib/esm/transactionPlan/midnight/makerPublication.d.ts +55 -0
  261. package/lib/esm/transactionPlan/midnight/makerPublication.js +310 -0
  262. package/lib/esm/transactionPlan/midnight/market.d.ts +49 -0
  263. package/lib/esm/transactionPlan/midnight/market.js +112 -0
  264. package/lib/esm/transactionPlan/midnight/prepare.d.ts +244 -0
  265. package/lib/esm/transactionPlan/midnight/prepare.js +536 -0
  266. package/lib/esm/transactionPlan/midnight/publicationState.d.ts +24 -0
  267. package/lib/esm/transactionPlan/midnight/publicationState.js +47 -0
  268. package/lib/esm/transactionPlan/midnight/redeem.d.ts +102 -0
  269. package/lib/esm/transactionPlan/midnight/redeem.js +165 -0
  270. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.d.ts +25 -0
  271. package/lib/esm/transactionPlan/midnight/reduceOnlySellFeasibility.js +47 -0
  272. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +162 -0
  273. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +323 -0
  274. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +155 -0
  275. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +196 -0
  276. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +96 -0
  277. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +185 -0
  278. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +112 -0
  279. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +216 -0
  280. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +129 -0
  281. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +176 -0
  282. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +115 -0
  283. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +254 -0
  284. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +304 -0
  285. package/lib/esm/transactionPlan/midnight/takeBorrow.js +539 -0
  286. package/lib/esm/transactionPlan/midnight/takeLend.d.ts +99 -0
  287. package/lib/esm/transactionPlan/midnight/takeLend.js +258 -0
  288. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +175 -0
  289. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +435 -0
  290. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +139 -0
  291. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +236 -0
  292. package/lib/esm/transactionPlan/midnight/validation.d.ts +22 -0
  293. package/lib/esm/transactionPlan/midnight/validation.js +151 -0
  294. package/lib/esm/transactionPlan/midnight/withdrawCollateral.d.ts +130 -0
  295. package/lib/esm/transactionPlan/midnight/withdrawCollateral.js +223 -0
  296. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.d.ts +142 -0
  297. package/lib/esm/transactionPlan/midnight/withdrawCollateralBatch.js +227 -0
  298. package/lib/esm/transactionPlan/permit.d.ts +15 -2
  299. package/lib/esm/transactionPlan/permit.js +25 -68
  300. package/lib/esm/transactionPlan/plan.d.ts +99 -15
  301. package/lib/esm/transactionPlan/plan.js +154 -27
  302. package/lib/esm/transactionPlan/redeem.js +5 -8
  303. package/lib/esm/transactionPlan/requirements.d.ts +7 -4
  304. package/lib/esm/transactionPlan/requirements.js +2 -2
  305. package/lib/esm/transactionPlan/serde.d.ts +13 -2
  306. package/lib/esm/transactionPlan/serde.js +49 -2
  307. package/lib/esm/transactionPlan/types.d.ts +151 -3
  308. package/lib/esm/transactionPlan/validateActions.d.ts +3 -1
  309. package/lib/esm/transactionPlan/validateActions.js +31 -3
  310. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  311. package/lib/esm/transactionPlan/validation.js +38 -2
  312. package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
  313. package/lib/esm/transactionPlan/vaultBinding.js +65 -0
  314. package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
  315. package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
  316. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
  317. package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
  318. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  319. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
  320. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  321. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
  322. package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
  323. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  324. package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
  325. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
  326. package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
  327. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  328. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
  329. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  330. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
  331. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  332. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
  333. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
  334. package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
  335. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  336. package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
  337. package/lib/esm/transactionPlan/withdraw.js +5 -8
  338. package/lib/esm/types/error.d.ts +4 -1
  339. package/lib/esm/types/error.js +5 -2
  340. package/lib/esm/utils.d.ts +2 -2
  341. package/lib/esm/utils.js +2 -2
  342. package/lib/esm/version.d.ts +1 -1
  343. package/lib/esm/version.js +1 -1
  344. package/package.json +7 -7
package/README.md CHANGED
@@ -380,16 +380,21 @@ including requests with existing signatures. It allows extra keys. Malformed JSO
380
380
  references throw `InvalidTransactionPlanError` with a JSON `path` and `reason`; unsupported versions
381
381
  and action types retain their dedicated errors. Serialization remains unchecked. Parsing verifies
382
382
  stored signatures against their expected signers offline and rejects signatures from the wrong
383
- signer. It uses no clock or RPC and does not check expiry, live state or action-layer business
384
- constraints. A successful parse does not prove intent or protect unsigned fields, so integrators
385
- must still protect stored plans.
383
+ signer. Midnight maker publications, `midnightSupplyCollateralTakeBorrow` and
384
+ `midnightTakeRepayWithdrawCollateral` also rerun their builders' static input checks on restore, so
385
+ a stored recipe that fails those checks throws `InvalidTransactionPlanError` there. Building can
386
+ still fail on a restored plan: deployment lookups such as the Midnight bundle address run only in
387
+ `buildTransactions`. Parsing uses no clock or RPC and does not check expiry, live state or other
388
+ action-layer business constraints. A successful parse does not prove intent or protect unsigned
389
+ fields, so integrators must still protect stored plans.
386
390
 
387
391
  Supported action types are `erc20Approval`, `morphoAuthorization`, `blueSupply`,
388
392
  `blueSupplyCollateral`, `blueBorrow`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueWithdraw`,
389
- `blueWithdrawCollateral`, `blueRepayWithdrawCollateral`, `blueRefinance`, `vaultV1Deposit`, `vaultV1Withdraw`,
393
+ `blueWithdrawCollateral`, `blueWithdrawBuyCallback`, `blueRepayWithdrawCollateral`, `blueRefinance`, `vaultV1Deposit`, `vaultV1Withdraw`,
390
394
  `vaultV1Redeem`, `vaultV1InKindRedeem`, `vaultV1MigrateToV2`,
391
395
  `vaultV2Deposit`, `vaultV2Withdraw`, `vaultV2Redeem`,
392
- `vaultV2ForceWithdraw`, `vaultV2ForceRedeem` and `vaultV2InKindRedeem`. Builders return plain `Readonly<Transaction>` objects without step metadata.
396
+ `vaultV2ForceWithdraw`, `vaultV2ForceRedeem`, `vaultV2InKindRedeem`, `midnightAuthorization`,
397
+ `midnightTakeLend`, `midnightTakeBorrow`, `midnightSupplyCollateralTakeBorrow`, `midnightTakeWithdraw`, `midnightTakeRepayWithdrawCollateral`, `midnightSupplyCollateral`, `midnightSupplyCollateralWithNative`, `midnightSupplyCollateralBatch`, `midnightWithdrawCollateral`, `midnightWithdrawCollateralBatch`, `midnightRedeem`, `midnightCancelOffers`, `midnightRepayWithdrawCollateral`, `midnightMakeBorrow`, `midnightMakeLend`, `midnightMakeWithdraw`, `midnightMakeRepay`, `midnightSupplyCollateralMakeBorrow` and `midnightSupplyBlueMakeLend`. Builders return plain `Readonly<Transaction>` objects without step metadata.
393
398
 
394
399
  | Prepare function | Operation |
395
400
  | --- | --- |
@@ -400,8 +405,28 @@ Supported action types are `erc20Approval`, `morphoAuthorization`, `blueSupply`,
400
405
  | `prepareBlueRepay` | Repay Blue debt by assets or shares |
401
406
  | `prepareBlueWithdraw` | Withdraw supplied loan assets from a Blue market |
402
407
  | `prepareBlueWithdrawCollateral` | Withdraw collateral from a Blue market |
408
+ | `prepareBlueWithdrawBuyCallback` | Withdraw a BlueBuyCallback's whole supply position to its owner |
403
409
  | `prepareBlueRepayWithdrawCollateral` | Repay, withdraw collateral, or perform both atomically on Blue |
404
410
  | `prepareBlueRefinance` | Move a Blue borrow position to another market |
411
+ | `prepareMidnightTakeLend` | Lend at a fixed rate on Midnight by taking caller-quoted borrow offers |
412
+ | `prepareMidnightSupplyCollateral` | Supply the selected collateral directly to a Midnight market |
413
+ | `prepareMidnightSupplyCollateralBatch` | Supply several collaterals atomically to a Midnight market |
414
+ | `prepareMidnightSupplyCollateralWithNative` | Supply wNative collateral to a Midnight market, funded partly or fully with native ETH |
415
+ | `prepareMidnightRedeem` | Redeem credit from a caller-fetched Midnight position |
416
+ | `prepareMidnightWithdrawCollateral` | Withdraw one collateral directly from a caller-fetched Midnight position |
417
+ | `prepareMidnightWithdrawCollateralBatch` | Withdraw several collaterals atomically from a caller-fetched Midnight position |
418
+ | `prepareMidnightTakeBorrow` | Borrow from lend-side Midnight offers against an existing position |
419
+ | `prepareMidnightSupplyCollateralTakeBorrow` | Supply collateral and borrow from lend-side Midnight offers atomically |
420
+ | `prepareMidnightMakeBorrow` | Publish resting Midnight borrow offers without supplying collateral |
421
+ | `prepareMidnightSupplyCollateralMakeBorrow` | Supply collateral and publish resting Midnight borrow offers atomically |
422
+ | `prepareMidnightMakeLend` | Publish resting Midnight lend offers funded by the maker when filled |
423
+ | `prepareMidnightSupplyBlueMakeLend` | Supply loan assets to the maker's BlueBuyCallback and publish resting Midnight lend offers atomically |
424
+ | `prepareMidnightMakeWithdraw` | Publish resting Midnight reduce-only sell offers against existing credit |
425
+ | `prepareMidnightMakeRepay` | Publish resting Midnight reduce-only buy offers against existing debt |
426
+ | `prepareMidnightTakeWithdraw` | Withdraw Midnight credit using lend-side offers without opening debt |
427
+ | `prepareMidnightTakeRepayWithdrawCollateral` | Repay Midnight debt by taking borrow offers, optionally repaying the rest directly and withdrawing collateral |
428
+ | `prepareMidnightCancelOffers` | Cancel Midnight offer groups in full with a direct Midnight call |
429
+ | `prepareMidnightRepayWithdrawCollateral` | Repay Midnight debt directly or withdraw collateral without filling offers |
405
430
  | `prepareVaultV2Deposit` | Deposit assets into Vault V2 |
406
431
  | `prepareVaultV2Withdraw` | Withdraw assets from Vault V2 |
407
432
  | `prepareVaultV2Redeem` | Redeem an exact number of Vault V2 shares |
@@ -426,6 +451,145 @@ With insufficient ERC-20 allowance, it requests an unlimited approval or an exac
426
451
  permit for BlueBundlesV1. Native funding is available only for wNative collateral, needs neither
427
452
  approval nor permit, and stores `nativeAssets` equal to `collateralAssets`.
428
453
 
454
+ `prepareMidnightSupplyCollateralBatch` supplies a nonempty ordered list of `collateralSupplies`, one
455
+ per index, in one Midnight core multicall. For each token whose allowance is below that token's total,
456
+ it adds the approval steps to Midnight core that the token requires (usually one unlimited approval,
457
+ possibly a reset to zero first or a capped amount). It needs no authorization or signature request;
458
+ `expiresAt` is not an on-chain deadline.
459
+
460
+ `prepareMidnightSupplyCollateralWithNative` supplies `collateralAssets` of the wNative collateral at
461
+ `collateralIndex` through MidnightBundlesV2. A positive `nativeAmount`, at most `collateralAssets`, is
462
+ sent as transaction value and wrapped to the account; the bundle then pulls the full
463
+ `collateralAssets` as wNative, so the wallet's own wNative balance covers only
464
+ `collateralAssets - nativeAmount`. It adds an unlimited wNative approval to MidnightBundlesV2 when the
465
+ allowance is below `collateralAssets`, and a Midnight authorization of the bundle when it is missing.
466
+ Unlike the entity, it takes no `reservedCollateralAssets`, so the allowance check keeps no reserve
467
+ for a later maker operation. Simulate the whole sequence before asking the wallet for either
468
+ permission. It needs no signature requests, and `expiresAt` is the on-chain bundle deadline.
469
+
470
+ `prepareBlueWithdrawBuyCallback` takes the callback's market and position snapshots and
471
+ `callbackAddress`; `account` must be the callback's owner. It fixes every supply share in the
472
+ snapshot on one `blueWithdrawBuyCallback` step, a direct Morpho Blue `withdraw` with no approval,
473
+ authorization or signature request. Preparation rejects a callback the registered factory did not
474
+ create, another owner, or a revoked Blue authorization. It takes no referral fee, `supportSignature`
475
+ or `deployless`, and `expiresAt` is plan metadata only. Those checks run only at preparation:
476
+ `parseTransactionPlan` and `buildTransactions` are offline, and the built `withdraw` pays
477
+ `plan.account`. Restore only plans from a trusted source, send only from `plan.account` (reject a
478
+ plan whose `account` is not the connected wallet), and simulate before sending. The step withdraws
479
+ the snapshot's share count, not the position at send time: shares added later stay in the callback,
480
+ and a smaller position makes the withdrawal revert.
481
+
482
+ `prepareMidnightRedeem` takes a caller-fetched `positionData: AccrualPosition` bound to the
483
+ plan account and market. It fixes explicit `units` or defaults to the accrued face value.
484
+ `receiver` defaults to the account. This direct withdrawal needs no approvals or signature
485
+ requests, and `expiresAt` is plan metadata, not an on-chain deadline.
486
+
487
+ `prepareMidnightWithdrawCollateral` takes the sender's market and position snapshots from one
488
+ block, plus `collateralPrices` when the position has debt. It applies the entity
489
+ `withdrawCollateral` checks: `assets: maxUint256` withdraws the snapshot balance at
490
+ `collateralIndex`, and the remaining collateral must cover the debt at LLTV minus
491
+ `DEFAULT_LLTV_BUFFER`. `receiver` defaults to the account. The direct Midnight call needs no
492
+ approvals, authorizations or signature requests, and `expiresAt` is not an on-chain deadline.
493
+ `prepareMidnightWithdrawCollateralBatch` does the same for a nonempty ordered list of
494
+ `collateralWithdrawals`, one per index, in one Midnight core multicall to a shared `receiver`.
495
+
496
+ To withdraw credit into lend offers instead, fetch the owner-bound position at the reference
497
+ block and request a quote on the bid side. Pass the offers from `quote.data.takeableOffers`;
498
+ if the quote is empty, preparation throws `EmptyMidnightTakeableOffersError`.
499
+
500
+ ```ts
501
+ import { buildTransactions, prepareMidnightTakeWithdraw, type TransactionPlan } from "@morpho-org/morpho-sdk";
502
+ import { fetchMidnightAccrualPosition } from "@morpho-org/morpho-sdk/fetch";
503
+ import { MidnightApi } from "@morpho-org/morpho-sdk/midnight-api";
504
+ import { type Address, type Hash, createPublicClient, http } from "viem";
505
+ import { base } from "viem/chains";
506
+
507
+ async function prepareWithdrawal(account: Address, marketId: Hash) {
508
+ const client = createPublicClient({ chain: base, transport: http() });
509
+ const block = await client.getBlock();
510
+ const positionData = await fetchMidnightAccrualPosition(client, {
511
+ marketId,
512
+ user: account,
513
+ blockNumber: block.number,
514
+ });
515
+ const marketData = positionData.market;
516
+ const assets = 1_000_000n;
517
+ const maxUnits = 1_100_000n;
518
+ // Quote the unit ceiling: fees come out of the proceeds, so fills sized to the net
519
+ // assets could not deliver them.
520
+ const quote = await new MidnightApi().fetchBookQuote({
521
+ marketId,
522
+ side: "bids",
523
+ units: maxUnits,
524
+ taker: account,
525
+ });
526
+ const plan: TransactionPlan = await prepareMidnightTakeWithdraw(client, {
527
+ chainId: base.id,
528
+ account,
529
+ marketData,
530
+ positionData,
531
+ now: block.timestamp,
532
+ target: { type: "assets", assets, maxUnits },
533
+ takeableOffers: quote.data.takeableOffers,
534
+ });
535
+ // Simulate, then send in order from plan.account on plan.chainId.
536
+ return buildTransactions(plan);
537
+ }
538
+ ```
539
+
540
+ `prepareMidnightMakeBorrow` publishes caller-created PriceRatifierV1 or RateRatifierV1 sell offers
541
+ without supplying collateral or borrowing immediately. It needs no token approval or root
542
+ signature. See the [TransactionPlan guide](src/transactionPlan/README.md#midnight-maker-borrow-offers)
543
+ for a tree example, offline restoration, and which authorizations persist.
544
+
545
+ `prepareMidnightMakeLend` publishes caller-created buy offers without moving loan tokens.
546
+ Midnight core pulls the maker's tokens when someone fills the offers, so the plan may add a
547
+ core token approval for the offered and reserved budget. It never approves the bundle to spend
548
+ tokens or uses native ETH. See the [TransactionPlan guide](src/transactionPlan/README.md#midnight-maker-lend-offers)
549
+ for a tree example and the lifetime of the approval and grants.
550
+
551
+ `prepareMidnightMakeWithdraw` publishes caller-created PriceRatifierV1 or RateRatifierV1
552
+ reduce-only sell offers against existing maker credit. It does not withdraw funds or
553
+ decrease credit on publication. See the [TransactionPlan guide](src/transactionPlan/README.md#midnight-maker-withdrawal-offers)
554
+ for a tree example, offline restoration, and which authorizations persist.
555
+
556
+ `prepareMidnightMakeRepay` publishes caller-created PriceRatifierV1 or RateRatifierV1
557
+ reduce-only buy offers against existing maker debt. It may add a core token approval for
558
+ later fills but does not repay debt or move tokens on publication. See the
559
+ [TransactionPlan guide](src/transactionPlan/README.md#midnight-maker-repayment-offers)
560
+ for a tree example, offline restoration, and which approvals and authorizations persist.
561
+
562
+ `prepareMidnightSupplyCollateralMakeBorrow` supplies collateral and activates the maker's
563
+ PriceRatifierV1 or RateRatifierV1 sell-offer root in one bundle. It does not fill an offer,
564
+ create debt, or disburse loan assets. Collateral indexes are zero-based positions
565
+ in ascending collateral token address order. See the [TransactionPlan guide](src/transactionPlan/README.md#midnight-collateral-backed-maker-borrow-offers)
566
+ for a tree example, wrapped-native funding, and which approvals and authorizations persist.
567
+
568
+ `prepareMidnightSupplyBlueMakeLend` parks loan assets on Blue for the maker's BlueBuyCallback
569
+ and activates the maker's lend-offer root in the same bundle, without filling an offer. See
570
+ the [TransactionPlan guide](src/transactionPlan/README.md#midnight-blue-backed-maker-lend-offers)
571
+ for the callback-bound tree, offline restoration, and persistent approvals and authorizations.
572
+
573
+ `prepareMidnightRepayWithdrawCollateral` takes the sender's market and position snapshots from
574
+ the same block.
575
+ Use `repay: { type: "assets", assets }` for an exact repayment (zero for a collateral-only
576
+ withdrawal), or `repay: { type: "full", maxBuyerAssets }` to close the debt under a finite cap.
577
+ Both amounts are in the loan token's smallest units. Withdrawals are optional and go to the
578
+ sender unless you set `collateralReceiver`. There are no offer fills, referral fees, or signature
579
+ requests. The bundle requires allowance for the full pull even if you provide `nativeAmount`
580
+ in wei for a wrapped-native loan, plus a standalone authorization if not already granted.
581
+ If allowance is insufficient, the plan requests an unlimited (`maxUint256`, subject to
582
+ `MAX_TOKEN_APPROVALS`) ERC-20 approval to MidnightBundlesV2. Once granted, the approval does
583
+ not expire with the plan.
584
+ See the [TransactionPlan guide](src/transactionPlan/README.md#midnight-repayment-and-collateral-withdrawal)
585
+ for a repayment example, collateral indexes, oracle prices, and expiry defaults.
586
+
587
+ `prepareMidnightCancelOffers` takes `account` and a nonempty list of distinct 32-byte `groups`,
588
+ fixed on one `midnightCancelOffers` step with no approvals, authorization or signature requests.
589
+ One group builds a bare Midnight `setConsumed(group, maxUint128, account)`; two or more build one
590
+ Midnight core `multicall`. It never targets MidnightBundlesV2, and `account` or a Midnight-authorized
591
+ operator must send it. `expiresAt` is plan metadata only, not an onchain deadline.
592
+
429
593
  `prepareVaultV2ForceRedeem` takes `vaultAddress` and top-level `shares`, with no snapshot.
430
594
  Caller-supplied `deallocations[].assets` and `shares` are fixed on one `vaultV2ForceRedeem` step
431
595
  with no approvals or signature requests. It accepts neither `supportSignature` nor `deployless`.
package/lib/cjs/abis.d.ts CHANGED
@@ -33,7 +33,7 @@ export declare const bundlesPermitParameters: {
33
33
  }];
34
34
  };
35
35
  export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
36
- export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
36
+ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
37
37
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
38
38
  preLiquidationAbi as bluePreLiquidationAbi,
39
39
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
package/lib/cjs/abis.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.midnightBlueBuyCallbackAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = exports.bundlesPermitParameters = exports.BundlesPermitKind = void 0;
3
+ exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.midnightBlueBuyCallbackAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.midnightAdapterRateRatifierV1Abi = exports.midnightAdapterPriceRatifierV1Abi = exports.midnightAdapterFactoryAbi = exports.midnightAdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = exports.bundlesPermitParameters = exports.BundlesPermitKind = void 0;
4
4
  /** Numeric permit kinds consumed by `TokenLib.pullToken`. */
5
5
  exports.BundlesPermitKind = {
6
6
  None: 0,
@@ -33,6 +33,10 @@ Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true,
33
33
  Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
34
34
  Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
35
35
  Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
36
+ Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
37
+ Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
38
+ Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
39
+ Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
36
40
  Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
37
41
  Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
38
42
  Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
@@ -109,9 +109,18 @@ const parseBlueAllocations = (reallocations, { marketParams: targetMarketParams,
109
109
  targetMarketId: targetMarketParams.id,
110
110
  maxPenalty,
111
111
  });
112
- // Hoisted out of the map: idle sources all reference the same synthetic idle market, whose
113
- // construction eagerly hashes the market id — computing it once per call instead of per entry.
114
- const idleMarketParams = (0, parse_js_1.parseBlueMarket)(blue_sdk_1.MarketParams.idle(targetMarketParams.loanToken));
112
+ const idle = {
113
+ loanToken: targetMarketParams.loanToken,
114
+ collateralToken: viem_1.zeroAddress,
115
+ oracle: viem_1.zeroAddress,
116
+ irm: viem_1.zeroAddress,
117
+ lltv: 0n,
118
+ };
119
+ const idleMarketParams = (0, parse_js_1.parseBlueMarket)({
120
+ ...idle,
121
+ id: blue_sdk_1.MarketUtils.getMarketId(idle),
122
+ liquidationIncentiveFactor: blue_sdk_1.MarketUtils.getLiquidationIncentiveFactor(idle),
123
+ });
115
124
  const publicAllocations = snapshots.map((reallocation) => {
116
125
  if (reallocation.from.type === "market" &&
117
126
  !(0, viem_1.isAddressEqual)(reallocation.from.marketParams.loanToken, targetMarketParams.loanToken)) {
@@ -1,7 +1,7 @@
1
- import type { MarketInput } from "@morpho-org/midnight-sdk";
2
- import type { Address } from "viem";
1
+ import type { AccrualPosition, MarketInput } from "@morpho-org/midnight-sdk";
2
+ import { type Address } from "viem";
3
3
  import { type MidnightMarket } from "../../helpers/parseMidnight.js";
4
- import type { Metadata, MidnightRedeemAction, Transaction } from "../../types/index.js";
4
+ import { type Metadata, type MidnightRedeemAction, type Transaction } from "../../types/index.js";
5
5
  /** Parameters for encoding a direct Midnight credit redemption. */
6
6
  export interface MidnightRedeemParams {
7
7
  readonly chainId: number;
@@ -63,4 +63,21 @@ export interface ParsedMidnightRedeem extends Omit<MidnightRedeemParams, "market
63
63
  }
64
64
  /** Parses static redeem constraints using the existing error order. @internal */
65
65
  export declare const parseMidnightRedeem: (params: MidnightRedeemParams) => ParsedMidnightRedeem;
66
+ /** Owner-bound position snapshot and optional amounts for a redemption. @internal */
67
+ export interface MidnightRedeemPreparationParams {
68
+ readonly chainId: number;
69
+ readonly accountAddress: Address;
70
+ readonly positionData: AccrualPosition;
71
+ readonly units?: bigint;
72
+ readonly receiver?: Address;
73
+ readonly now: bigint;
74
+ readonly metadata?: Metadata;
75
+ }
76
+ /**
77
+ * Owns redemption defaults and snapshot-dependent amount constraints in the same order as the
78
+ * entity `redeem`, then mints the complete redeem contract. Used by TransactionPlan preparation;
79
+ * the entity keeps its own copy of these checks.
80
+ * @internal
81
+ */
82
+ export declare const parseMidnightRedeemPreparation: (params: MidnightRedeemPreparationParams) => ParsedMidnightRedeem;
66
83
  export {};
@@ -1,9 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMidnightRedeem = exports.midnightRedeem = void 0;
3
+ exports.parseMidnightRedeemPreparation = exports.parseMidnightRedeem = exports.midnightRedeem = void 0;
4
+ const blue_sdk_1 = require("@morpho-org/blue-sdk");
4
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ const viem_1 = require("viem");
5
7
  const parseMidnight_js_1 = require("../../helpers/parseMidnight.js");
8
+ const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAccount.js");
6
9
  const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
10
+ const index_js_1 = require("../../types/index.js");
7
11
  const encode_js_1 = require("./encode.js");
8
12
  const parse_js_1 = require("./parse.js");
9
13
  /**
@@ -75,3 +79,56 @@ const parseMidnightRedeem = (params) => {
75
79
  });
76
80
  };
77
81
  exports.parseMidnightRedeem = parseMidnightRedeem;
82
+ /**
83
+ * Owns redemption defaults and snapshot-dependent amount constraints in the same order as the
84
+ * entity `redeem`, then mints the complete redeem contract. Used by TransactionPlan preparation;
85
+ * the entity keeps its own copy of these checks.
86
+ * @internal
87
+ */
88
+ const parseMidnightRedeemPreparation = (params) => {
89
+ const address = (0, parseMidnight_js_1.parseMidnightAddress)("accountAddress", params.accountAddress);
90
+ if (!params.positionData) {
91
+ throw new index_js_1.MissingAccrualPositionError();
92
+ }
93
+ if (params.positionData.user != null) {
94
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)("positionData.user", params.positionData.user);
95
+ }
96
+ if (params.positionData.user == null ||
97
+ !(0, viem_1.isAddressEqual)(params.positionData.user, address)) {
98
+ throw new index_js_1.AccrualPositionUserMismatchError(params.positionData.user ?? "unbound", address);
99
+ }
100
+ const marketData = params.positionData.market;
101
+ // Reject market/deployment errors before snapshot accrual and amount checks.
102
+ const market = (0, parseMidnight_js_1.parseMidnightMarket)(marketData, params.chainId);
103
+ const accrued = params.positionData.accrueInterest(blue_sdk_1.MathLib.max(params.now, params.positionData.lastAccrual));
104
+ const units = params.units ?? accrued.faceValue;
105
+ if (params.units === undefined && units <= 0n) {
106
+ throw new index_js_1.NoMidnightCreditToRedeemError(marketData.id);
107
+ }
108
+ // Bound the resolved amount before checking credit and liquidity.
109
+ (0, parseMidnight_js_1.parseMidnightPositiveAmount)("units", units);
110
+ if (accrued.credit < units) {
111
+ throw new index_js_1.MidnightRedeemExceedsCreditError({
112
+ market: marketData.id,
113
+ units,
114
+ credit: accrued.credit,
115
+ });
116
+ }
117
+ if (marketData.withdrawable < units) {
118
+ throw new index_js_1.InsufficientMidnightWithdrawableLiquidityError({
119
+ market: marketData.id,
120
+ units,
121
+ withdrawable: marketData.withdrawable,
122
+ });
123
+ }
124
+ // The owning action constructor mints the complete contract only after snapshot checks.
125
+ return (0, exports.parseMidnightRedeem)({
126
+ chainId: params.chainId,
127
+ market: market.struct,
128
+ units,
129
+ onBehalf: address,
130
+ receiver: params.receiver ?? address,
131
+ metadata: params.metadata,
132
+ });
133
+ };
134
+ exports.parseMidnightRedeemPreparation = parseMidnightRedeemPreparation;
@@ -1,5 +1,6 @@
1
- import { type MarketInput } from "@morpho-org/midnight-sdk";
1
+ import { type MarketInput, MarketUtils } from "@morpho-org/midnight-sdk";
2
2
  import { type Address } from "viem";
3
+ import { encodeMidnightMarketId } from "../../helpers/encodeMidnightCalldata.js";
3
4
  import { type Metadata, type MidnightSupplyCollateralWithNativeAction, type Transaction } from "../../types/index.js";
4
5
  /** Parameters for encoding a Midnight collateral supply. */
5
6
  export interface MidnightSupplyCollateralWithNativeParams {
@@ -75,3 +76,25 @@ export declare function prepareMidnightSupplyCollateralWithNative(params: Midnig
75
76
  token: `0x${string}`;
76
77
  tx: Transaction<MidnightSupplyCollateralWithNativeAction>;
77
78
  };
79
+ /** Owned native collateral supply inputs, checked in the encoder's order. @internal */
80
+ export interface ParsedMidnightSupplyCollateralWithNative {
81
+ readonly chainId: number;
82
+ readonly market: ReturnType<typeof MarketUtils.toStruct>;
83
+ readonly marketId: ReturnType<typeof encodeMidnightMarketId>;
84
+ readonly collateralIndex: bigint;
85
+ readonly assets: bigint;
86
+ /** wNative collateral pulled from the sender. */
87
+ readonly token: Address;
88
+ readonly accountAddress: Address;
89
+ /** Native funding sent as transaction value. */
90
+ readonly value: bigint;
91
+ readonly wrappedNative: Address;
92
+ readonly deadline: bigint;
93
+ }
94
+ /**
95
+ * Parses a native collateral supply with the same checks, in the same order, as
96
+ * `midnightSupplyCollateralWithNative`, without encoding the bundle call. Resolving
97
+ * MidnightBundlesV2 is left to the caller. `assetsField` names the amount in its errors, so a
98
+ * caller can report its own parameter name. @internal
99
+ */
100
+ export declare function parseMidnightSupplyCollateralWithNative(params: Omit<MidnightSupplyCollateralWithNativeParams, "metadata">, assetsField?: "assets" | "collateralAssets"): ParsedMidnightSupplyCollateralWithNative;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.midnightSupplyCollateralWithNative = void 0;
4
4
  exports.prepareMidnightSupplyCollateralWithNative = prepareMidnightSupplyCollateralWithNative;
5
+ exports.parseMidnightSupplyCollateralWithNative = parseMidnightSupplyCollateralWithNative;
5
6
  const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
6
7
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
7
8
  const viem_1 = require("viem");
@@ -140,3 +141,43 @@ function prepareMidnightSupplyCollateralWithNative(params) {
140
141
  }),
141
142
  };
142
143
  }
144
+ /**
145
+ * Parses a native collateral supply with the same checks, in the same order, as
146
+ * `midnightSupplyCollateralWithNative`, without encoding the bundle call. Resolving
147
+ * MidnightBundlesV2 is left to the caller. `assetsField` names the amount in its errors, so a
148
+ * caller can report its own parameter name. @internal
149
+ */
150
+ function parseMidnightSupplyCollateralWithNative(params, assetsField = "assets") {
151
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)("accountAddress", params.accountAddress);
152
+ const assets = (0, parseMidnight_js_1.parseMidnightNativeCollateralAmount)(assetsField, params.assets);
153
+ if ((0, viem_1.isAddressEqual)(params.accountAddress, viem_1.zeroAddress)) {
154
+ throw new index_js_2.MidnightZeroOnBehalfError("accountAddress");
155
+ }
156
+ (0, validateMidnightMarket_js_1.validateMidnightMarket)({ market: params.market, chainId: params.chainId });
157
+ const market = (0, encodeMidnightCalldata_js_1.wrapMidnightEncoding)("marketId", () => midnight_sdk_1.MarketUtils.toStruct(params.market));
158
+ const marketId = (0, encodeMidnightCalldata_js_1.encodeMidnightMarketId)(market);
159
+ const collateralIndex = params.collateralIndex ?? 0n;
160
+ const { token } = midnight_sdk_1.MarketUtils.getCollateralByIndex(market, collateralIndex);
161
+ if (params.nativeAmount === 0n || params.nativeAmount === undefined) {
162
+ throw new index_js_2.NonPositiveInputError("nativeAmount", params.nativeAmount ?? 0n);
163
+ }
164
+ const { value, wrappedNative } = (0, validate_js_1.validateMidnightNativeAmount)({
165
+ chainId: params.chainId,
166
+ nativeAmount: params.nativeAmount,
167
+ pulls: [{ token, assets }],
168
+ });
169
+ const deadline = params.deadline ?? 0n;
170
+ (0, validate_js_1.validateDeadline)(deadline);
171
+ return (0, morpho_ts_1.deepFreeze)({
172
+ chainId: params.chainId,
173
+ market,
174
+ marketId,
175
+ collateralIndex,
176
+ assets,
177
+ token,
178
+ accountAddress: params.accountAddress,
179
+ value,
180
+ wrappedNative,
181
+ deadline,
182
+ });
183
+ }
@@ -1,5 +1,5 @@
1
- import type { MarketInput } from "@morpho-org/midnight-sdk";
2
- import type { Address } from "viem";
1
+ import type { AccrualPosition, Market, MarketInput } from "@morpho-org/midnight-sdk";
2
+ import { type Address } from "viem";
3
3
  import { type MidnightMarket } from "../../helpers/parseMidnight.js";
4
4
  import type { Metadata, MidnightWithdrawCollateralAction, Transaction } from "../../types/index.js";
5
5
  /** Parameters for encoding a direct Midnight collateral withdrawal. */
@@ -60,4 +60,18 @@ export interface ParsedMidnightWithdrawCollateral extends Omit<MidnightWithdrawC
60
60
  }
61
61
  /** Parses static withdrawCollateral constraints using the existing error order. @internal */
62
62
  export declare const parseMidnightWithdrawCollateral: (params: MidnightWithdrawCollateralParams) => ParsedMidnightWithdrawCollateral;
63
+ /** Complete raw withdrawal preparation; domain snapshots stay caller-owned. @internal */
64
+ export interface MidnightWithdrawCollateralPreparationParams extends Omit<MidnightWithdrawCollateralParams, "market" | "onBehalf" | "receiver"> {
65
+ readonly accountAddress: Address;
66
+ readonly marketData: Market;
67
+ readonly positionData: AccrualPosition;
68
+ /** Defaults to `accountAddress`. */
69
+ readonly receiver?: Address;
70
+ }
71
+ /**
72
+ * Owns the snapshot-bound withdrawal checks in entity order: account, market, position binding,
73
+ * collateral index, `maxUint256` resolution to the snapshot balance, then the direct-call checks.
74
+ * Balance and health checks against the snapshot are left to the caller. @internal
75
+ */
76
+ export declare const parseMidnightWithdrawCollateralPreparation: (params: MidnightWithdrawCollateralPreparationParams) => ParsedMidnightWithdrawCollateral;
63
77
  export {};
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMidnightWithdrawCollateral = exports.midnightWithdrawCollateral = void 0;
3
+ exports.parseMidnightWithdrawCollateralPreparation = exports.parseMidnightWithdrawCollateral = exports.midnightWithdrawCollateral = void 0;
4
4
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
+ const viem_1 = require("viem");
5
6
  const parseMidnight_js_1 = require("../../helpers/parseMidnight.js");
6
7
  const validateMidnightReceiver_js_1 = require("../../helpers/validateMidnightReceiver.js");
7
8
  const encode_js_1 = require("./encode.js");
@@ -72,3 +73,27 @@ const parseMidnightWithdrawCollateral = (params) => {
72
73
  });
73
74
  };
74
75
  exports.parseMidnightWithdrawCollateral = parseMidnightWithdrawCollateral;
76
+ /**
77
+ * Owns the snapshot-bound withdrawal checks in entity order: account, market, position binding,
78
+ * collateral index, `maxUint256` resolution to the snapshot balance, then the direct-call checks.
79
+ * Balance and health checks against the snapshot are left to the caller. @internal
80
+ */
81
+ const parseMidnightWithdrawCollateralPreparation = (params) => {
82
+ const onBehalf = (0, parseMidnight_js_1.parseMidnightAccount)("accountAddress", params.accountAddress);
83
+ const market = (0, parseMidnight_js_1.parseMidnightMarket)(params.marketData, params.chainId);
84
+ // Bind the supplied snapshot before interpreting its collateral balances.
85
+ (0, parseMidnight_js_1.validateMidnightPositionBinding)(params);
86
+ const collateral = (0, parseMidnight_js_1.parseMidnightCollateral)(market, params.collateralIndex ?? 0n);
87
+ const available = params.positionData.collateral[Number(collateral.index)] ?? 0n;
88
+ const action = (0, exports.parseMidnightWithdrawCollateral)({
89
+ chainId: params.chainId,
90
+ market: market.struct,
91
+ assets: params.assets === viem_1.maxUint256 ? available : params.assets,
92
+ onBehalf,
93
+ receiver: params.receiver ?? onBehalf,
94
+ collateralIndex: collateral.index,
95
+ metadata: params.metadata,
96
+ });
97
+ return action;
98
+ };
99
+ exports.parseMidnightWithdrawCollateralPreparation = parseMidnightWithdrawCollateralPreparation;
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
3
+ exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.midnightAdapterRateRatifierV1Abi = exports.midnightAdapterPriceRatifierV1Abi = exports.midnightAdapterFactoryAbi = exports.midnightAdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "marketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
6
6
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
@@ -13,6 +13,10 @@ Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true,
13
13
  Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
14
14
  Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
15
15
  Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
16
+ Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
17
+ Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
18
+ Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
19
+ Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
16
20
  Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
17
21
  Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
18
22
  Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
@@ -1,10 +1,10 @@
1
- export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
1
+ export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  IPreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
6
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
5
+ IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterMidnightMarket, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
7
7
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
8
8
  PreLiquidationParams,
9
9
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
10
- PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
10
+ PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,10 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.Token = exports.PreLiquidationPosition = exports.PreLiquidationParams = exports.Position = exports.MarketParams = exports.Market = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = void 0;
3
+ exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2MidnightAdapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.Token = exports.PreLiquidationPosition = exports.PreLiquidationParams = exports.Position = exports.MarketParams = exports.Market = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2MidnightAdapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = void 0;
4
4
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
5
5
  Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
6
6
  Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
7
7
  Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
8
+ Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
8
9
  Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
9
10
  Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
10
11
  Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
@@ -32,6 +33,7 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
32
33
  Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
33
34
  Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
34
35
  Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
36
+ Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
35
37
  Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
36
38
  Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
37
39
  Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
@@ -1,4 +1,4 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, InvalidPositionAccrualStateError, InvalidPositionLossFactorError, InvalidVaultV2MidnightAdapterMarketsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
4
- export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
4
+ export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";