@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
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateMidnightTakeableOfferFields = void 0;
4
+ const viem_1 = require("viem");
5
+ const index_js_1 = require("../types/index.js");
6
+ const validateMidnightAccount_js_1 = require("./validateMidnightAccount.js");
7
+ const OFFER_ADDRESS_FIELDS = [
8
+ "maker",
9
+ "callback",
10
+ "receiverIfMakerIsSeller",
11
+ "ratifier",
12
+ ];
13
+ const OFFER_UINT256_FIELDS = [
14
+ "start",
15
+ "expiry",
16
+ "tick",
17
+ "continuousFeeCap",
18
+ ];
19
+ const OFFER_CAP_FIELDS = ["maxUnits", "maxAssets"];
20
+ const BYTES32_PATTERN = /^0x[0-9a-fA-F]{64}$/;
21
+ const validateUint256 = (field, value) => {
22
+ if (typeof value !== "bigint") {
23
+ throw new index_js_1.MidnightCalldataEncodingError(field, new viem_1.BaseError(`Invalid bigint value: "${String(value)}".`));
24
+ }
25
+ if (value < 0n || value > viem_1.maxUint256) {
26
+ throw new index_js_1.MidnightCalldataEncodingError(field, new viem_1.IntegerOutOfRangeError({
27
+ max: `${viem_1.maxUint256}n`,
28
+ min: "0n",
29
+ signed: false,
30
+ size: 32,
31
+ value: `${value}n`,
32
+ }));
33
+ }
34
+ };
35
+ const validateBytes = (field, value) => {
36
+ if (!(0, viem_1.isHex)(value) || value.length % 2 !== 0) {
37
+ throw new index_js_1.MidnightCalldataEncodingError(field, new viem_1.InvalidHexValueError(value));
38
+ }
39
+ };
40
+ /**
41
+ * Parses the fields of each taken offer fill that `MidnightBundlesV2` ABI-encodes and that the
42
+ * side, market and cap guards do not already check, so a malformed offer is rejected before any
43
+ * read or encoding.
44
+ *
45
+ * Integer and address bounds are the ABI's: `start`, `expiry`, `tick`, `continuousFeeCap` and
46
+ * the fill's `units` are `uint256` bigints; the `maxUnits` and `maxAssets` caps are bigints whose
47
+ * `uint128` bounds the action parser checks; `maker`, `callback`, `receiverIfMakerIsSeller` and
48
+ * `ratifier` are addresses (checksummed when mixed-case); `group` is exactly 32 bytes of `0x` hex;
49
+ * `reduceOnly` is a boolean. `callbackData` and `ratifierData` must be even-length `0x` hex.
50
+ *
51
+ * @param takeableOffers - Offers selected for a Midnight take.
52
+ * @returns Nothing when every offer field can be encoded.
53
+ * @throws {MidnightCalldataEncodingError} when a field is malformed; `input` is its path, such as
54
+ * `"takeableOffers[0].offer.maker"`.
55
+ * @internal
56
+ */
57
+ const validateMidnightTakeableOfferFields = (takeableOffers) => {
58
+ for (const [index, { units, offer, ratifierData },] of takeableOffers.entries()) {
59
+ const path = `takeableOffers[${index}]`;
60
+ for (const field of OFFER_ADDRESS_FIELDS) {
61
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)(`${path}.offer.${field}`, offer[field]);
62
+ }
63
+ for (const field of OFFER_UINT256_FIELDS) {
64
+ validateUint256(`${path}.offer.${field}`, offer[field]);
65
+ }
66
+ for (const field of OFFER_CAP_FIELDS) {
67
+ validateUint256(`${path}.offer.${field}`, offer[field]);
68
+ }
69
+ if (typeof offer.group !== "string" || !BYTES32_PATTERN.test(offer.group)) {
70
+ throw new index_js_1.MidnightCalldataEncodingError(`${path}.offer.group`, (0, viem_1.isHex)(offer.group, { strict: true })
71
+ ? new viem_1.AbiEncodingBytesSizeMismatchError({
72
+ expectedSize: 32,
73
+ value: offer.group,
74
+ })
75
+ : new viem_1.InvalidHexValueError(offer.group));
76
+ }
77
+ validateBytes(`${path}.offer.callbackData`, offer.callbackData);
78
+ if (typeof offer.reduceOnly !== "boolean") {
79
+ throw new index_js_1.MidnightCalldataEncodingError(`${path}.offer.reduceOnly`, new viem_1.BaseError(`Invalid boolean value: "${offer.reduceOnly}".`));
80
+ }
81
+ validateBytes(`${path}.ratifierData`, ratifierData);
82
+ validateUint256(`${path}.units`, units);
83
+ }
84
+ };
85
+ exports.validateMidnightTakeableOfferFields = validateMidnightTakeableOfferFields;
@@ -4,7 +4,7 @@ export * from "./client/index.js";
4
4
  export type { SupplyCollateralWithNativeParams } from "./entities/midnight/types.js";
5
5
  export * from "./entities/requirements/index.js";
6
6
  export * from "./helpers/index.js";
7
- export type { Action, BlueBorrowPlanParams, BlueMarketSnapshot, BluePositionSnapshot, BlueRefinancePlanParams, BlueRepayPlanParams, BlueRepayWithdrawCollateralPlanParams, BlueSupplyCollateralBorrowPlanParams, BlueSupplyCollateralPlanParams, BlueSupplyPlanParams, BlueWithdrawCollateralPlanParams, BlueWithdrawPlanParams, Funding, IntentParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV1DepositPlanParams, VaultV1InKindRedeemPlanParams, VaultV1MigrateToV2PlanParams, VaultV1RedeemPlanParams, VaultV1WithdrawPlanParams, VaultV2DepositPlanParams, VaultV2ForceRedeemPlanParams, VaultV2ForceWithdrawPlanParams, VaultV2InKindRedeemPlanParams, VaultV2RedeemPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
8
- export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawCollateral, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
7
+ export type { Action, BlueBorrowPlanParams, BlueMarketSnapshot, BluePositionSnapshot, BlueRefinancePlanParams, BlueRepayPlanParams, BlueRepayWithdrawCollateralPlanParams, BlueSupplyCollateralBorrowPlanParams, BlueSupplyCollateralPlanParams, BlueSupplyPlanParams, BlueWithdrawBuyCallbackPlanParams, BlueWithdrawCollateralPlanParams, BlueWithdrawPlanParams, Funding, IntentParams, MidnightCancelOffersPlanParams, MidnightMakeBorrowPlanParams, MidnightMakeLendPlanParams, MidnightMakeRepayPlanParams, MidnightMakerPublicationPlanParams, MidnightMakeWithdrawPlanParams, MidnightRedeemPlanParams, MidnightRepayWithdrawCollateralPlanParams, MidnightSupplyBlueMakeLendPlanParams, MidnightSupplyCollateralBatchPlanParams, MidnightSupplyCollateralMakeBorrowPlanParams, MidnightSupplyCollateralPlanParams, MidnightSupplyCollateralTakeBorrowPlanParams, MidnightSupplyCollateralWithNativePlanParams, MidnightTakeBorrowPlanParams, MidnightTakeLendPlanParams, MidnightTakeRepayWithdrawCollateralPlanParams, MidnightTakeWithdrawPlanParams, MidnightWithdrawCollateralBatchPlanParams, MidnightWithdrawCollateralPlanParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV1DepositPlanParams, VaultV1InKindRedeemPlanParams, VaultV1MigrateToV2PlanParams, VaultV1RedeemPlanParams, VaultV1WithdrawPlanParams, VaultV2DepositPlanParams, VaultV2ForceRedeemPlanParams, VaultV2ForceWithdrawPlanParams, VaultV2InKindRedeemPlanParams, VaultV2RedeemPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
8
+ export { applySignatures, BlueSnapshotChainMismatchError, BlueSnapshotStateMismatchError, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, MidnightTakeCreditInsufficientError, NonIntegerInputError, parseTransactionPlan, prepareBlueBorrow, prepareBlueRefinance, prepareBlueRepay, prepareBlueRepayWithdrawCollateral, prepareBlueSupply, prepareBlueSupplyCollateral, prepareBlueSupplyCollateralBorrow, prepareBlueWithdraw, prepareBlueWithdrawBuyCallback, prepareBlueWithdrawCollateral, prepareMidnightCancelOffers, prepareMidnightMakeBorrow, prepareMidnightMakeLend, prepareMidnightMakeRepay, prepareMidnightMakeWithdraw, prepareMidnightRedeem, prepareMidnightRepayWithdrawCollateral, prepareMidnightSupplyBlueMakeLend, prepareMidnightSupplyCollateral, prepareMidnightSupplyCollateralBatch, prepareMidnightSupplyCollateralMakeBorrow, prepareMidnightSupplyCollateralTakeBorrow, prepareMidnightSupplyCollateralWithNative, prepareMidnightTakeBorrow, prepareMidnightTakeLend, prepareMidnightTakeRepayWithdrawCollateral, prepareMidnightTakeWithdraw, prepareMidnightWithdrawCollateral, prepareMidnightWithdrawCollateralBatch, prepareVaultV1Deposit, prepareVaultV1InKindRedeem, prepareVaultV1MigrateToV2, prepareVaultV1Redeem, prepareVaultV1Withdraw, prepareVaultV2Deposit, prepareVaultV2ForceRedeem, prepareVaultV2ForceWithdraw, prepareVaultV2InKindRedeem, prepareVaultV2Redeem, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, validateBlueMarketSnapshot, ZeroAccountError, } from "./transactionPlan/index.js";
9
9
  export * from "./types/index.js";
10
10
  export { version } from "./version.js";
package/lib/cjs/index.js CHANGED
@@ -14,7 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.version = exports.ZeroAccountError = exports.validateBlueMarketSnapshot = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.serializeTransactionPlan = exports.prepareVaultV2Withdraw = exports.prepareVaultV2Redeem = exports.prepareVaultV2InKindRedeem = exports.prepareVaultV2ForceWithdraw = exports.prepareVaultV2ForceRedeem = exports.prepareVaultV2Deposit = exports.prepareVaultV1Withdraw = exports.prepareVaultV1Redeem = exports.prepareVaultV1MigrateToV2 = exports.prepareVaultV1InKindRedeem = exports.prepareVaultV1Deposit = exports.prepareBlueWithdrawCollateral = exports.prepareBlueWithdraw = exports.prepareBlueSupplyCollateralBorrow = exports.prepareBlueSupplyCollateral = exports.prepareBlueSupply = exports.prepareBlueRepayWithdrawCollateral = exports.prepareBlueRepay = exports.prepareBlueRefinance = exports.prepareBlueBorrow = exports.parseTransactionPlan = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.BlueSnapshotStateMismatchError = exports.BlueSnapshotChainMismatchError = exports.applySignatures = exports.validateClientChainId = void 0;
17
+ exports.prepareVaultV2ForceWithdraw = exports.prepareVaultV2ForceRedeem = exports.prepareVaultV2Deposit = exports.prepareVaultV1Withdraw = exports.prepareVaultV1Redeem = exports.prepareVaultV1MigrateToV2 = exports.prepareVaultV1InKindRedeem = exports.prepareVaultV1Deposit = exports.prepareMidnightWithdrawCollateralBatch = exports.prepareMidnightWithdrawCollateral = exports.prepareMidnightTakeWithdraw = exports.prepareMidnightTakeRepayWithdrawCollateral = exports.prepareMidnightTakeLend = exports.prepareMidnightTakeBorrow = exports.prepareMidnightSupplyCollateralWithNative = exports.prepareMidnightSupplyCollateralTakeBorrow = exports.prepareMidnightSupplyCollateralMakeBorrow = exports.prepareMidnightSupplyCollateralBatch = exports.prepareMidnightSupplyCollateral = exports.prepareMidnightSupplyBlueMakeLend = exports.prepareMidnightRepayWithdrawCollateral = exports.prepareMidnightRedeem = exports.prepareMidnightMakeWithdraw = exports.prepareMidnightMakeRepay = exports.prepareMidnightMakeLend = exports.prepareMidnightMakeBorrow = exports.prepareMidnightCancelOffers = exports.prepareBlueWithdrawCollateral = exports.prepareBlueWithdrawBuyCallback = exports.prepareBlueWithdraw = exports.prepareBlueSupplyCollateralBorrow = exports.prepareBlueSupplyCollateral = exports.prepareBlueSupply = exports.prepareBlueRepayWithdrawCollateral = exports.prepareBlueRepay = exports.prepareBlueRefinance = exports.prepareBlueBorrow = exports.parseTransactionPlan = exports.NonIntegerInputError = exports.MidnightTakeCreditInsufficientError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.BlueSnapshotStateMismatchError = exports.BlueSnapshotChainMismatchError = exports.applySignatures = exports.validateClientChainId = void 0;
18
+ exports.version = exports.ZeroAccountError = exports.validateBlueMarketSnapshot = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.serializeTransactionPlan = exports.prepareVaultV2Withdraw = exports.prepareVaultV2Redeem = exports.prepareVaultV2InKindRedeem = void 0;
18
19
  __exportStar(require("./actions/index.js"), exports);
19
20
  var validateClientChainId_js_1 = require("./actions/requirements/validateClientChainId.js");
20
21
  Object.defineProperty(exports, "validateClientChainId", { enumerable: true, get: function () { return validateClientChainId_js_1.validateClientChainId; } });
@@ -31,6 +32,7 @@ Object.defineProperty(exports, "getPendingSignatureRequests", { enumerable: true
31
32
  Object.defineProperty(exports, "IncompleteTransactionPlanError", { enumerable: true, get: function () { return index_js_1.IncompleteTransactionPlanError; } });
32
33
  Object.defineProperty(exports, "InvalidCalldataOriginError", { enumerable: true, get: function () { return index_js_1.InvalidCalldataOriginError; } });
33
34
  Object.defineProperty(exports, "InvalidTransactionPlanError", { enumerable: true, get: function () { return index_js_1.InvalidTransactionPlanError; } });
35
+ Object.defineProperty(exports, "MidnightTakeCreditInsufficientError", { enumerable: true, get: function () { return index_js_1.MidnightTakeCreditInsufficientError; } });
34
36
  Object.defineProperty(exports, "NonIntegerInputError", { enumerable: true, get: function () { return index_js_1.NonIntegerInputError; } });
35
37
  Object.defineProperty(exports, "parseTransactionPlan", { enumerable: true, get: function () { return index_js_1.parseTransactionPlan; } });
36
38
  Object.defineProperty(exports, "prepareBlueBorrow", { enumerable: true, get: function () { return index_js_1.prepareBlueBorrow; } });
@@ -41,7 +43,27 @@ Object.defineProperty(exports, "prepareBlueSupply", { enumerable: true, get: fun
41
43
  Object.defineProperty(exports, "prepareBlueSupplyCollateral", { enumerable: true, get: function () { return index_js_1.prepareBlueSupplyCollateral; } });
42
44
  Object.defineProperty(exports, "prepareBlueSupplyCollateralBorrow", { enumerable: true, get: function () { return index_js_1.prepareBlueSupplyCollateralBorrow; } });
43
45
  Object.defineProperty(exports, "prepareBlueWithdraw", { enumerable: true, get: function () { return index_js_1.prepareBlueWithdraw; } });
46
+ Object.defineProperty(exports, "prepareBlueWithdrawBuyCallback", { enumerable: true, get: function () { return index_js_1.prepareBlueWithdrawBuyCallback; } });
44
47
  Object.defineProperty(exports, "prepareBlueWithdrawCollateral", { enumerable: true, get: function () { return index_js_1.prepareBlueWithdrawCollateral; } });
48
+ Object.defineProperty(exports, "prepareMidnightCancelOffers", { enumerable: true, get: function () { return index_js_1.prepareMidnightCancelOffers; } });
49
+ Object.defineProperty(exports, "prepareMidnightMakeBorrow", { enumerable: true, get: function () { return index_js_1.prepareMidnightMakeBorrow; } });
50
+ Object.defineProperty(exports, "prepareMidnightMakeLend", { enumerable: true, get: function () { return index_js_1.prepareMidnightMakeLend; } });
51
+ Object.defineProperty(exports, "prepareMidnightMakeRepay", { enumerable: true, get: function () { return index_js_1.prepareMidnightMakeRepay; } });
52
+ Object.defineProperty(exports, "prepareMidnightMakeWithdraw", { enumerable: true, get: function () { return index_js_1.prepareMidnightMakeWithdraw; } });
53
+ Object.defineProperty(exports, "prepareMidnightRedeem", { enumerable: true, get: function () { return index_js_1.prepareMidnightRedeem; } });
54
+ Object.defineProperty(exports, "prepareMidnightRepayWithdrawCollateral", { enumerable: true, get: function () { return index_js_1.prepareMidnightRepayWithdrawCollateral; } });
55
+ Object.defineProperty(exports, "prepareMidnightSupplyBlueMakeLend", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyBlueMakeLend; } });
56
+ Object.defineProperty(exports, "prepareMidnightSupplyCollateral", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyCollateral; } });
57
+ Object.defineProperty(exports, "prepareMidnightSupplyCollateralBatch", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyCollateralBatch; } });
58
+ Object.defineProperty(exports, "prepareMidnightSupplyCollateralMakeBorrow", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyCollateralMakeBorrow; } });
59
+ Object.defineProperty(exports, "prepareMidnightSupplyCollateralTakeBorrow", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyCollateralTakeBorrow; } });
60
+ Object.defineProperty(exports, "prepareMidnightSupplyCollateralWithNative", { enumerable: true, get: function () { return index_js_1.prepareMidnightSupplyCollateralWithNative; } });
61
+ Object.defineProperty(exports, "prepareMidnightTakeBorrow", { enumerable: true, get: function () { return index_js_1.prepareMidnightTakeBorrow; } });
62
+ Object.defineProperty(exports, "prepareMidnightTakeLend", { enumerable: true, get: function () { return index_js_1.prepareMidnightTakeLend; } });
63
+ Object.defineProperty(exports, "prepareMidnightTakeRepayWithdrawCollateral", { enumerable: true, get: function () { return index_js_1.prepareMidnightTakeRepayWithdrawCollateral; } });
64
+ Object.defineProperty(exports, "prepareMidnightTakeWithdraw", { enumerable: true, get: function () { return index_js_1.prepareMidnightTakeWithdraw; } });
65
+ Object.defineProperty(exports, "prepareMidnightWithdrawCollateral", { enumerable: true, get: function () { return index_js_1.prepareMidnightWithdrawCollateral; } });
66
+ Object.defineProperty(exports, "prepareMidnightWithdrawCollateralBatch", { enumerable: true, get: function () { return index_js_1.prepareMidnightWithdrawCollateralBatch; } });
45
67
  Object.defineProperty(exports, "prepareVaultV1Deposit", { enumerable: true, get: function () { return index_js_1.prepareVaultV1Deposit; } });
46
68
  Object.defineProperty(exports, "prepareVaultV1InKindRedeem", { enumerable: true, get: function () { return index_js_1.prepareVaultV1InKindRedeem; } });
47
69
  Object.defineProperty(exports, "prepareVaultV1MigrateToV2", { enumerable: true, get: function () { return index_js_1.prepareVaultV1MigrateToV2; } });
@@ -1 +1,2 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
2
+ export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.InvalidEcrecoverSignatureError = exports.ChainIdMismatchError = void 0;
3
+ exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.InvalidEcrecoverSignatureError = exports.ChainIdMismatchError = void 0;
4
4
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
5
5
  Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
6
6
  Object.defineProperty(exports, "InvalidEcrecoverSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureError; } });
@@ -10,9 +10,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
10
10
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
11
11
  Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
12
12
  Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
13
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
14
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
15
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
16
13
  Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
17
14
  Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
18
15
  Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -30,3 +27,7 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
30
27
  Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
31
28
  Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
32
29
  Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
30
+ var morpho_ts_1 = require("@morpho-org/morpho-ts");
31
+ Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
32
+ Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
33
+ Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
@@ -1,6 +1,6 @@
1
1
  export { EcrecoverRatifier,
2
2
  /** @deprecated Use EcrecoverRatifier with a tagged tree. */
3
- EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
3
+ EcrecoverRatifierUtils, eip712Digest, GroupUtils, getBlueBuyCallbackAddress, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, PriceRatifierV1,
4
4
  /** @deprecated Use PriceRatifierV1. */
5
5
  PriceRatifierV1Utils, RateRatifierV1,
6
6
  /** @deprecated Use RateRatifierV1. */
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TreeUtils = exports.TickLib = exports.TakeAmountsLib = exports.SetterRatifierUtils = exports.SetterRatifier = exports.RatifierUtils = exports.Ratifier = exports.RateRatifierV1Utils = exports.RateRatifierV1 = exports.PriceRatifierV1Utils = exports.PriceRatifierV1 = exports.PositionUtils = exports.Payload = exports.OfferUtils = exports.OfferChainUtils = exports.MarketUtils = exports.GroupUtils = exports.eip712Digest = exports.EcrecoverRatifierUtils = exports.EcrecoverRatifier = void 0;
3
+ exports.TreeUtils = exports.TickLib = exports.TakeAmountsLib = exports.SetterRatifierUtils = exports.SetterRatifier = exports.RatifierUtils = exports.Ratifier = exports.RateRatifierV1Utils = exports.RateRatifierV1 = exports.PriceRatifierV1Utils = exports.PriceRatifierV1 = exports.PositionUtils = exports.Payload = exports.OfferUtils = exports.OfferChainUtils = exports.MarketUtils = exports.getBlueBuyCallbackAddress = exports.GroupUtils = exports.eip712Digest = exports.EcrecoverRatifierUtils = exports.EcrecoverRatifier = void 0;
4
4
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
5
5
  Object.defineProperty(exports, "EcrecoverRatifier", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifier; } });
6
6
  /** @deprecated Use EcrecoverRatifier with a tagged tree. */
7
7
  Object.defineProperty(exports, "EcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
8
8
  Object.defineProperty(exports, "eip712Digest", { enumerable: true, get: function () { return midnight_sdk_1.eip712Digest; } });
9
9
  Object.defineProperty(exports, "GroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
10
+ Object.defineProperty(exports, "getBlueBuyCallbackAddress", { enumerable: true, get: function () { return midnight_sdk_1.getBlueBuyCallbackAddress; } });
10
11
  Object.defineProperty(exports, "MarketUtils", { enumerable: true, get: function () { return midnight_sdk_1.MarketUtils; } });
11
12
  Object.defineProperty(exports, "OfferChainUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferChainUtils; } });
12
13
  Object.defineProperty(exports, "OfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
@@ -0,0 +1,24 @@
1
+ import type { Address } from "viem";
2
+ import type { Intent } from "./intent.js";
3
+ import type { TransactionPlan } from "./types.js";
4
+ /**
5
+ * @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
6
+ * the intent has one.
7
+ */
8
+ export declare function planHeader({ chainId, account }: {
9
+ readonly chainId: number;
10
+ readonly account: Address;
11
+ }, { expiresAt, calldataOrigin }: Pick<Intent, "expiresAt" | "calldataOrigin">): {
12
+ readonly version: 2;
13
+ readonly chainId: number;
14
+ readonly account: `0x${string}`;
15
+ readonly expiresAt: number;
16
+ readonly calldataOrigin?: `0x${string}` | undefined;
17
+ };
18
+ /**
19
+ * @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
20
+ * passed in is frozen or shared with the plan.
21
+ */
22
+ export declare function freezePlan(plan: TransactionPlan, { detach }: {
23
+ readonly detach: boolean;
24
+ }): TransactionPlan;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.planHeader = planHeader;
4
+ exports.freezePlan = freezePlan;
5
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ /**
7
+ * @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
8
+ * the intent has one.
9
+ */
10
+ function planHeader({ chainId, account }, { expiresAt, calldataOrigin }) {
11
+ return {
12
+ version: 2,
13
+ chainId,
14
+ account,
15
+ expiresAt,
16
+ ...(calldataOrigin && { calldataOrigin }),
17
+ };
18
+ }
19
+ /**
20
+ * @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
21
+ * passed in is frozen or shared with the plan.
22
+ */
23
+ function freezePlan(plan, { detach }) {
24
+ return (0, morpho_ts_1.deepFreeze)(detach ? structuredClone(plan) : plan);
25
+ }
@@ -9,9 +9,11 @@ const common_js_1 = require("../../actions/bundles/common.js");
9
9
  const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundlesV1QuoteTimestamp.js");
10
10
  const index_js_1 = require("../../helpers/index.js");
11
11
  const validate_js_1 = require("../../helpers/validate.js");
12
+ const assemble_js_1 = require("../assemble.js");
12
13
  const error_js_1 = require("../error.js");
13
14
  const validation_js_1 = require("../validation.js");
14
15
  const prepare_js_1 = require("./prepare.js");
16
+ const stored_js_1 = require("./stored.js");
15
17
  /**
16
18
  * Prepares a BlueBundlesV1 borrow against existing collateral. No token allowance is needed.
17
19
  * Health uses the expiry, floored at max(now, lastUpdate), like the entity handle.
@@ -123,12 +125,8 @@ async function prepareBlueBorrow(client, { chainId, account, marketId, marketDat
123
125
  reason: "expected prepared borrow inputs",
124
126
  });
125
127
  }
126
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
127
- version: 2,
128
- account: inputs.account,
129
- chainId: inputs.chainId,
130
- expiresAt: intent.expiresAt,
131
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
128
+ return (0, assemble_js_1.freezePlan)({
129
+ ...(0, assemble_js_1.planHeader)({ chainId: inputs.chainId, account: inputs.account }, intent),
132
130
  steps: [
133
131
  ...steps,
134
132
  {
@@ -140,14 +138,14 @@ async function prepareBlueBorrow(client, { chainId, account, marketId, marketDat
140
138
  ...inputs,
141
139
  authorizationNonce: signatureRequests.find((request) => request.id === morphoAuthorizationRequestId)?.args.nonce ?? 0n,
142
140
  },
143
- signatureRequestIds: morphoAuthorizationRequestId
144
- ? { morphoAuthorization: morphoAuthorizationRequestId }
145
- : {},
141
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
142
+ morphoAuthorization: morphoAuthorizationRequestId,
143
+ }),
146
144
  },
147
145
  },
148
146
  ],
149
147
  signatureRequests,
150
- }));
148
+ }, { detach: true });
151
149
  }
152
150
  /** @internal Encodes a prepared borrow without state reads or signing. */
153
151
  function buildBlueBorrow(action, requests) {
@@ -190,26 +188,6 @@ function buildBlueBorrow(action, requests) {
190
188
  },
191
189
  });
192
190
  }
193
- function validateMarket(value, path) {
194
- const market = (0, validation_js_1.getPlanObject)(value, path);
195
- (0, validation_js_1.validatePlanFields)(market, {
196
- path,
197
- fields: {
198
- id: "hex",
199
- loanToken: "address",
200
- collateralToken: "address",
201
- oracle: "address",
202
- irm: "address",
203
- lltv: "uint256 bigint",
204
- },
205
- });
206
- if (typeof market.id !== "string" || market.id.length !== 66) {
207
- throw new error_js_1.InvalidTransactionPlanError({
208
- path: `${path}.id`,
209
- reason: "expected a 32-byte market ID",
210
- });
211
- }
212
- }
213
191
  /** @internal Validates the stored borrow recipe, including each allocator input. */
214
192
  function validateBorrowPlanAction(action, path) {
215
193
  const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
@@ -220,47 +198,19 @@ function validateBorrowPlanAction(action, path) {
220
198
  borrowAssets: "uint256 bigint",
221
199
  authorizationNonce: "uint256 bigint",
222
200
  maxLtv: "uint256 bigint",
223
- deadline: "uint256 bigint",
224
- referralFeePct: "uint256 bigint",
225
- referralFeeRecipient: "address",
201
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
226
202
  reallocations: "array",
227
203
  },
228
204
  });
229
- validateMarket(inputs.marketParams, `${path}.inputs.marketParams`);
205
+ (0, stored_js_1.validateStoredBlueMarket)(inputs.marketParams, `${path}.inputs.marketParams`);
230
206
  if (inputs.maxPenalty !== undefined) {
231
207
  (0, validation_js_1.validatePlanField)(inputs.maxPenalty, {
232
208
  path: `${path}.inputs.maxPenalty`,
233
209
  type: "uint256 bigint",
234
210
  });
235
211
  }
236
- for (const [index, value] of inputs.reallocations.entries()) {
237
- const entryPath = `${path}.inputs.reallocations[${index}]`;
238
- const entry = (0, validation_js_1.getPlanObject)(value, entryPath);
239
- (0, validation_js_1.validatePlanFields)(entry, {
240
- path: entryPath,
241
- fields: {
242
- vault: "address",
243
- assets: "uint256 bigint",
244
- penalty: "uint256 bigint",
245
- },
246
- });
247
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(entry.to, `${entryPath}.to`), {
248
- path: `${entryPath}.to`,
249
- fields: { adapter: "address" },
250
- });
251
- const from = (0, validation_js_1.getPlanObject)(entry.from, `${entryPath}.from`);
252
- if (from.type !== "market" && from.type !== "idle") {
253
- throw new error_js_1.InvalidTransactionPlanError({
254
- path: `${entryPath}.from.type`,
255
- reason: "expected market or idle",
256
- });
257
- }
258
- if (from.type === "market") {
259
- (0, validation_js_1.validatePlanFields)(from, {
260
- path: `${entryPath}.from`,
261
- fields: { adapter: "address" },
262
- });
263
- validateMarket(from.marketParams, `${entryPath}.from.marketParams`);
264
- }
265
- }
212
+ (0, stored_js_1.validateStoredReallocations)(inputs.reallocations, {
213
+ path: `${path}.inputs.reallocations`,
214
+ marketParams: stored_js_1.validateStoredBlueMarket,
215
+ });
266
216
  }
@@ -10,10 +10,12 @@ const refinance_js_1 = require("../../actions/blue/refinance.js");
10
10
  const refinanceValidation_js_1 = require("../../actions/blue/refinanceValidation.js");
11
11
  const index_js_1 = require("../../helpers/index.js");
12
12
  const parse_js_1 = require("../../helpers/parse.js");
13
+ const assemble_js_1 = require("../assemble.js");
13
14
  const error_js_1 = require("../error.js");
14
15
  const validation_js_1 = require("../validation.js");
15
16
  const prepare_js_1 = require("./prepare.js");
16
17
  const refinanceValidation_js_2 = require("./refinanceValidation.js");
18
+ const stored_js_1 = require("./stored.js");
17
19
  /**
18
20
  * Prepares a full Blue borrow-position migration. Fetch both market and position snapshots at the
19
21
  * same block and pass that block's timestamp as `now`. Penalties and fees increase destination debt;
@@ -157,20 +159,18 @@ async function prepareBlueRefinance(client, params) {
157
159
  ...(maxPenalty !== undefined && { maxPenalty }),
158
160
  ...(request && { authorizationNonce: request.args.nonce }),
159
161
  },
160
- signatureRequestIds: request === undefined ? {} : { morphoAuthorization: request.id },
162
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
163
+ morphoAuthorization: request?.id,
164
+ }),
161
165
  };
162
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
163
- version: 2,
164
- account,
165
- chainId,
166
- expiresAt: intent.expiresAt,
167
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
166
+ return (0, assemble_js_1.freezePlan)({
167
+ ...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
168
168
  steps: [
169
169
  ...steps,
170
170
  { id, label: "Refinance Blue borrow position", action },
171
171
  ],
172
172
  signatureRequests,
173
- }));
173
+ }, { detach: true });
174
174
  }
175
175
  function validatePlanMarketParams(value, path) {
176
176
  const params = (0, validation_js_1.getPlanObject)(value, path);
@@ -246,9 +246,7 @@ function validateRefinancePlanAction(action, path) {
246
246
  path: `${path}.inputs`,
247
247
  fields: {
248
248
  maxLtv: "uint256 bigint",
249
- deadline: "uint256 bigint",
250
- referralFeePct: "uint256 bigint",
251
- referralFeeRecipient: "address",
249
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
252
250
  reallocations: "array",
253
251
  },
254
252
  });
@@ -14,10 +14,12 @@ const parse_js_1 = require("../../helpers/parse.js");
14
14
  const quoteBlueRepay_js_1 = require("../../helpers/quoteBlueRepay.js");
15
15
  const validate_js_1 = require("../../helpers/validate.js");
16
16
  const index_js_1 = require("../../types/index.js");
17
+ const assemble_js_1 = require("../assemble.js");
17
18
  const error_js_1 = require("../error.js");
18
19
  const permit_js_1 = require("../permit.js");
19
20
  const validation_js_1 = require("../validation.js");
20
21
  const prepare_js_1 = require("./prepare.js");
22
+ const stored_js_1 = require("./stored.js");
21
23
  /**
22
24
  * Prepares an asset, share, or full Blue repayment through BlueBundlesV1, never Permit2.
23
25
  * Share quotes accrue the supplied position to expiry, at most two hours from the reference time.
@@ -139,12 +141,8 @@ async function prepareBlueRepay(client, { chainId, account, marketId, marketData
139
141
  reason: "expected resolved repayment inputs",
140
142
  });
141
143
  }
142
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
143
- version: 2,
144
- chainId: params.chainId,
145
- account: params.account,
146
- expiresAt: resolvedIntent.expiresAt,
147
- calldataOrigin: resolvedIntent.calldataOrigin,
144
+ return (0, assemble_js_1.freezePlan)({
145
+ ...(0, assemble_js_1.planHeader)({ chainId: params.chainId, account: params.account }, resolvedIntent),
148
146
  steps: [
149
147
  ...steps,
150
148
  {
@@ -153,14 +151,14 @@ async function prepareBlueRepay(client, { chainId, account, marketId, marketData
153
151
  action: {
154
152
  type: "blueRepay",
155
153
  inputs,
156
- signatureRequestIds: signatureRequests.length
157
- ? { tokenPermit: signatureRequests[0]?.id }
158
- : {},
154
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
155
+ tokenPermit: signatureRequests[0]?.id,
156
+ }),
159
157
  },
160
158
  },
161
159
  ],
162
160
  signatureRequests,
163
- }));
161
+ }, { detach: true });
164
162
  }
165
163
  /** @internal Checks a repayment permit against the fixed token pull. */
166
164
  function validateBlueRepayPermit(request, action) {
@@ -203,9 +201,7 @@ function validateBlueRepayPlanAction(action, path) {
203
201
  repayAssets: "uint256 bigint",
204
202
  repayShares: "uint256 bigint",
205
203
  maxRepayAssets: "uint256 bigint",
206
- deadline: "uint256 bigint",
207
- referralFeePct: "uint256 bigint",
208
- referralFeeRecipient: "address",
204
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
209
205
  },
210
206
  });
211
207
  if (inputs.nativeAssets !== undefined) {
@@ -214,16 +210,6 @@ function validateBlueRepayPlanAction(action, path) {
214
210
  fields: { nativeAssets: "uint256 bigint" },
215
211
  });
216
212
  }
217
- const market = (0, validation_js_1.getPlanObject)(inputs.marketParams, `${path}.inputs.marketParams`);
218
- (0, validation_js_1.validatePlanFields)(market, {
219
- path: `${path}.inputs.marketParams`,
220
- fields: {
221
- loanToken: "address",
222
- collateralToken: "address",
223
- oracle: "address",
224
- irm: "address",
225
- lltv: "uint256 bigint",
226
- },
227
- });
213
+ (0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
228
214
  (0, validation_js_1.getPlanObject)(action.signatureRequestIds, `${path}.signatureRequestIds`);
229
215
  }