@morpho-org/morpho-sdk 9.8.0 → 10.0.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 (303) hide show
  1. package/MIGRATION-v9-to-v10.md +114 -0
  2. package/README.md +109 -13
  3. package/lib/cjs/actions/blue/common.js +4 -2
  4. package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
  5. package/lib/cjs/actions/bundles/common.js +20 -14
  6. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  7. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
  8. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -1
  9. package/lib/cjs/actions/midnight/cancelAndMake.js +2 -1
  10. package/lib/cjs/actions/midnight/cancelOffers.d.ts +54 -0
  11. package/lib/cjs/actions/midnight/cancelOffers.js +108 -0
  12. package/lib/cjs/actions/midnight/index.d.ts +1 -0
  13. package/lib/cjs/actions/midnight/index.js +1 -0
  14. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
  15. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  16. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
  17. package/lib/cjs/actions/midnight/takeBorrow.d.ts +1 -1
  18. package/lib/cjs/actions/midnight/takeBorrow.js +3 -2
  19. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -1
  20. package/lib/cjs/actions/midnight/takeLend.js +3 -2
  21. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  22. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
  23. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +1 -1
  24. package/lib/cjs/actions/midnight/takeWithdraw.js +3 -2
  25. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
  26. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  27. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  28. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  29. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  30. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  31. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +3 -3
  32. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  33. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +5 -13
  34. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  35. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  36. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  37. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  38. package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
  39. package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
  40. package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
  41. package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
  42. package/lib/cjs/entities/blue/blue.d.ts +34 -28
  43. package/lib/cjs/entities/blue/blue.js +107 -77
  44. package/lib/cjs/entities/midnight/deadline.d.ts +2 -2
  45. package/lib/cjs/entities/midnight/deadline.js +4 -3
  46. package/lib/cjs/entities/midnight/midnight.d.ts +49 -51
  47. package/lib/cjs/entities/midnight/midnight.js +158 -138
  48. package/lib/cjs/entities/midnight/publication.d.ts +2 -0
  49. package/lib/cjs/entities/midnight/publication.js +193 -138
  50. package/lib/cjs/entities/midnight/types.d.ts +4 -4
  51. package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
  52. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  53. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +24 -28
  54. package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
  55. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
  56. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  57. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  58. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
  59. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  60. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
  61. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  62. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
  63. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  64. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
  65. package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  66. package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
  67. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -12
  68. package/lib/cjs/entities/vaultV1/vaultV1.js +90 -194
  69. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  70. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
  71. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  72. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
  73. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +16 -16
  74. package/lib/cjs/entities/vaultV2/vaultV2.js +94 -385
  75. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +14 -0
  76. package/lib/cjs/entities/vaultV2BlueReallocationData.js +1599 -883
  77. package/lib/cjs/errors.d.ts +1 -1
  78. package/lib/cjs/errors.js +2 -1
  79. package/lib/cjs/helpers/deadShares.js +83 -47
  80. package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
  81. package/lib/cjs/helpers/metadata.d.ts +14 -2
  82. package/lib/cjs/helpers/metadata.js +49 -8
  83. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +44 -27
  84. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +11 -2
  85. package/lib/cjs/helpers/utilization.js +10 -5
  86. package/lib/cjs/helpers/validate.js +88 -67
  87. package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
  88. package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
  89. package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
  90. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +177 -104
  91. package/lib/cjs/helpers/validatePositiveInput.js +2 -1
  92. package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
  93. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +40 -22
  94. package/lib/cjs/index.d.ts +2 -2
  95. package/lib/cjs/index.js +10 -1
  96. package/lib/cjs/transactionPlan/approval.js +12 -1
  97. package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
  98. package/lib/cjs/transactionPlan/deposit.js +139 -0
  99. package/lib/cjs/transactionPlan/error.d.ts +10 -8
  100. package/lib/cjs/transactionPlan/error.js +10 -8
  101. package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
  102. package/lib/cjs/transactionPlan/index.d.ts +18 -0
  103. package/lib/cjs/transactionPlan/index.js +23 -5
  104. package/lib/cjs/transactionPlan/intent.d.ts +3 -3
  105. package/lib/cjs/transactionPlan/intent.js +14 -7
  106. package/lib/cjs/transactionPlan/permit.d.ts +1 -1
  107. package/lib/cjs/transactionPlan/permit.js +86 -20
  108. package/lib/cjs/transactionPlan/plan.d.ts +16 -6
  109. package/lib/cjs/transactionPlan/plan.js +77 -24
  110. package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
  111. package/lib/cjs/transactionPlan/redeem.js +63 -0
  112. package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
  113. package/lib/cjs/transactionPlan/requirements.js +12 -6
  114. package/lib/cjs/transactionPlan/serde.d.ts +2 -2
  115. package/lib/cjs/transactionPlan/serde.js +45 -19
  116. package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
  117. package/lib/cjs/transactionPlan/shareSpending.js +50 -0
  118. package/lib/cjs/transactionPlan/types.d.ts +117 -11
  119. package/lib/cjs/transactionPlan/validateActions.js +11 -1
  120. package/lib/cjs/transactionPlan/validation.js +6 -3
  121. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
  122. package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
  123. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  124. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
  125. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  126. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
  127. package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
  128. package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
  129. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  130. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
  131. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +18 -33
  132. package/lib/cjs/transactionPlan/vaultv2/deposit.js +19 -143
  133. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  134. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
  135. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  136. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
  137. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  138. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
  139. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
  140. package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
  141. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +18 -29
  142. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +21 -126
  143. package/lib/cjs/transactionPlan/version.js +2 -1
  144. package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
  145. package/lib/cjs/transactionPlan/withdraw.js +94 -0
  146. package/lib/cjs/types/action.d.ts +26 -2
  147. package/lib/cjs/types/action.js +17 -9
  148. package/lib/cjs/types/error.d.ts +8 -1
  149. package/lib/cjs/types/error.js +21 -6
  150. package/lib/cjs/types/metadata.d.ts +12 -2
  151. package/lib/cjs/version.d.ts +1 -1
  152. package/lib/cjs/version.js +1 -1
  153. package/lib/esm/actions/blue/common.js +4 -2
  154. package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
  155. package/lib/esm/actions/bundles/common.js +20 -14
  156. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
  157. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +3 -2
  158. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -1
  159. package/lib/esm/actions/midnight/cancelAndMake.js +2 -1
  160. package/lib/esm/actions/midnight/cancelOffers.d.ts +54 -0
  161. package/lib/esm/actions/midnight/cancelOffers.js +104 -0
  162. package/lib/esm/actions/midnight/index.d.ts +1 -0
  163. package/lib/esm/actions/midnight/index.js +1 -0
  164. package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
  165. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
  166. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +3 -2
  167. package/lib/esm/actions/midnight/takeBorrow.d.ts +1 -1
  168. package/lib/esm/actions/midnight/takeBorrow.js +3 -2
  169. package/lib/esm/actions/midnight/takeLend.d.ts +1 -1
  170. package/lib/esm/actions/midnight/takeLend.js +3 -2
  171. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  172. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +3 -2
  173. package/lib/esm/actions/midnight/takeWithdraw.d.ts +1 -1
  174. package/lib/esm/actions/midnight/takeWithdraw.js +3 -2
  175. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
  176. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
  177. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
  178. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
  179. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
  180. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
  181. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +3 -3
  182. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
  183. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +7 -15
  184. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
  185. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
  186. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
  187. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
  188. package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
  189. package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
  190. package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
  191. package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
  192. package/lib/esm/entities/blue/blue.d.ts +34 -28
  193. package/lib/esm/entities/blue/blue.js +107 -77
  194. package/lib/esm/entities/midnight/deadline.d.ts +2 -2
  195. package/lib/esm/entities/midnight/deadline.js +4 -3
  196. package/lib/esm/entities/midnight/midnight.d.ts +49 -51
  197. package/lib/esm/entities/midnight/midnight.js +159 -139
  198. package/lib/esm/entities/midnight/publication.d.ts +2 -0
  199. package/lib/esm/entities/midnight/publication.js +193 -138
  200. package/lib/esm/entities/midnight/types.d.ts +4 -4
  201. package/lib/esm/entities/requirements/assertContractCode.js +4 -2
  202. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
  203. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +25 -29
  204. package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
  205. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -4
  206. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
  207. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
  208. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
  209. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
  210. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
  211. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
  212. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
  213. package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
  214. package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
  215. package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
  216. package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
  217. package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -12
  218. package/lib/esm/entities/vaultV1/vaultV1.js +96 -200
  219. package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
  220. package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
  221. package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
  222. package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
  223. package/lib/esm/entities/vaultV2/vaultV2.d.ts +16 -16
  224. package/lib/esm/entities/vaultV2/vaultV2.js +102 -393
  225. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +14 -0
  226. package/lib/esm/entities/vaultV2BlueReallocationData.js +1599 -883
  227. package/lib/esm/errors.d.ts +1 -1
  228. package/lib/esm/errors.js +1 -1
  229. package/lib/esm/helpers/deadShares.js +83 -47
  230. package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
  231. package/lib/esm/helpers/metadata.d.ts +14 -2
  232. package/lib/esm/helpers/metadata.js +48 -8
  233. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +44 -27
  234. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +11 -2
  235. package/lib/esm/helpers/utilization.js +10 -5
  236. package/lib/esm/helpers/validate.js +88 -67
  237. package/lib/esm/helpers/validateMidnightBounds.js +2 -1
  238. package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
  239. package/lib/esm/helpers/validateMidnightPublication.js +4 -2
  240. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +176 -103
  241. package/lib/esm/helpers/validatePositiveInput.js +2 -1
  242. package/lib/esm/helpers/validateTakeableOffers.js +2 -1
  243. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +40 -22
  244. package/lib/esm/index.d.ts +2 -2
  245. package/lib/esm/index.js +1 -1
  246. package/lib/esm/transactionPlan/approval.js +13 -2
  247. package/lib/esm/transactionPlan/deposit.d.ts +22 -0
  248. package/lib/esm/transactionPlan/deposit.js +135 -0
  249. package/lib/esm/transactionPlan/error.d.ts +10 -8
  250. package/lib/esm/transactionPlan/error.js +10 -8
  251. package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
  252. package/lib/esm/transactionPlan/index.d.ts +18 -0
  253. package/lib/esm/transactionPlan/index.js +9 -0
  254. package/lib/esm/transactionPlan/intent.d.ts +3 -3
  255. package/lib/esm/transactionPlan/intent.js +14 -7
  256. package/lib/esm/transactionPlan/permit.d.ts +1 -1
  257. package/lib/esm/transactionPlan/permit.js +86 -20
  258. package/lib/esm/transactionPlan/plan.d.ts +16 -6
  259. package/lib/esm/transactionPlan/plan.js +73 -20
  260. package/lib/esm/transactionPlan/redeem.d.ts +18 -0
  261. package/lib/esm/transactionPlan/redeem.js +59 -0
  262. package/lib/esm/transactionPlan/requirements.d.ts +4 -3
  263. package/lib/esm/transactionPlan/requirements.js +12 -6
  264. package/lib/esm/transactionPlan/serde.d.ts +2 -2
  265. package/lib/esm/transactionPlan/serde.js +45 -19
  266. package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
  267. package/lib/esm/transactionPlan/shareSpending.js +47 -0
  268. package/lib/esm/transactionPlan/types.d.ts +117 -11
  269. package/lib/esm/transactionPlan/validateActions.js +11 -1
  270. package/lib/esm/transactionPlan/validation.js +6 -3
  271. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
  272. package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
  273. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
  274. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
  275. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
  276. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
  277. package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
  278. package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
  279. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
  280. package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
  281. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +18 -33
  282. package/lib/esm/transactionPlan/vaultv2/deposit.js +21 -144
  283. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
  284. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
  285. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
  286. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
  287. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
  288. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
  289. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
  290. package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
  291. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +18 -29
  292. package/lib/esm/transactionPlan/vaultv2/withdraw.js +23 -127
  293. package/lib/esm/transactionPlan/version.js +2 -1
  294. package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
  295. package/lib/esm/transactionPlan/withdraw.js +90 -0
  296. package/lib/esm/types/action.d.ts +26 -2
  297. package/lib/esm/types/action.js +17 -9
  298. package/lib/esm/types/error.d.ts +8 -1
  299. package/lib/esm/types/error.js +21 -6
  300. package/lib/esm/types/metadata.d.ts +12 -2
  301. package/lib/esm/version.d.ts +1 -1
  302. package/lib/esm/version.js +1 -1
  303. package/package.json +15 -14
@@ -57,8 +57,9 @@ export const midnightWithdrawCollateralBatch = (params) => {
57
57
  // Direct batches require one entry per index rather than summing duplicates.
58
58
  validateMidnightCollateralBatch(params.collateralWithdrawals, new EmptyMidnightCollateralWithdrawalsError());
59
59
  const calls = params.collateralWithdrawals.map(({ collateralIndex, assets }) => {
60
- if (assets <= 0n)
60
+ if (assets <= 0n) {
61
61
  throw new NonPositiveInputError("assets", assets);
62
+ }
62
63
  validateMidnightUint128Field("assets", assets);
63
64
  // Reject indexes not configured on the market.
64
65
  MarketUtils.getCollateralByIndex(params.market, collateralIndex);
@@ -83,8 +84,9 @@ export const midnightWithdrawCollateralBatch = (params) => {
83
84
  args: [calls],
84
85
  }),
85
86
  };
86
- if (params.metadata)
87
+ if (params.metadata) {
87
88
  tx = addTransactionMetadata(tx, params.metadata);
89
+ }
88
90
  return deepFreeze({
89
91
  ...tx,
90
92
  action: {
@@ -1,6 +1,6 @@
1
1
  import type { Client } from "viem";
2
2
  import { type Address } from "viem";
3
- import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, type Requirement, type Transaction } from "../../../types/index.js";
3
+ import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, type ReferenceTimestampParams, type Requirement, type Transaction } from "../../../types/index.js";
4
4
  /**
5
5
  * Resolves whether a supported operator needs Blue authorization for the given user, and returns
6
6
  * the requirement to satisfy it when it does.
@@ -18,7 +18,7 @@ import { type AuthorizationRequirementSignature, type BlueAuthorizationAction, t
18
18
  * @param params.authorized - Operator to authorize. Defaults to the chain's registered
19
19
  * BlueBundlesV1 deployment and must match it.
20
20
  * @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
21
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
21
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
22
22
  * @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
23
23
  * transaction so the destination route can consume the signed authorization.
24
24
  * @returns A deep-frozen `Transaction<BlueAuthorizationAction>`, a signable authorization
@@ -63,5 +63,4 @@ export declare const getBlueAuthorizationRequirement: (params: {
63
63
  readonly supportSignature?: boolean;
64
64
  readonly authorized?: Address;
65
65
  readonly deadline?: bigint;
66
- readonly now?: bigint;
67
- }) => Promise<Readonly<Transaction<BlueAuthorizationAction>> | Requirement<AuthorizationRequirementSignature> | null>;
66
+ } & ReferenceTimestampParams) => Promise<Readonly<Transaction<BlueAuthorizationAction>> | Requirement<AuthorizationRequirementSignature> | null>;
@@ -23,7 +23,7 @@ import { validateClientChainId } from "../validateClientChainId.js";
23
23
  * @param params.authorized - Operator to authorize. Defaults to the chain's registered
24
24
  * BlueBundlesV1 deployment and must match it.
25
25
  * @param params.deadline - Optional signature deadline forwarded to the authorization encoder.
26
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
26
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
27
27
  * @param params.supportSignature - When `true`, return a signable `Requirement` instead of a
28
28
  * transaction so the destination route can consume the signed authorization.
29
29
  * @returns A deep-frozen `Transaction<BlueAuthorizationAction>`, a signable authorization
@@ -1,8 +1,8 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
2
  import { type Client } from "viem";
3
- import { type AuthorizationRequirementSignature, type Requirement } from "../../../types/index.js";
3
+ import { type AuthorizationRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
4
4
  /** Parameters for {@link encodeBlueSignatureAuthorization}. */
5
- interface EncodeBlueSignatureAuthorizationParams {
5
+ interface EncodeBlueSignatureAuthorizationParams extends ReferenceTimestampParams {
6
6
  /** Account granting the authorization and signing it (the Morpho `authorizer`). */
7
7
  owner: Address;
8
8
  /** BlueBundlesV1 operator to authorize on Morpho; must be the chain's registered deployment. */
@@ -15,8 +15,6 @@ interface EncodeBlueSignatureAuthorizationParams {
15
15
  isAuthorized?: boolean;
16
16
  /** Signature deadline in seconds. Defaults to two hours from now. */
17
17
  deadline?: bigint;
18
- /** Timestamp the deadline is validated against; defaults to the current time. */
19
- now?: bigint;
20
18
  }
21
19
  /**
22
20
  * Builds a Morpho authorization `Requirement` that, once signed, lets BlueBundlesV1 operate on
@@ -26,7 +24,7 @@ interface EncodeBlueSignatureAuthorizationParams {
26
24
  * typed data, verifies it against the connected account, and returns a deep-frozen
27
25
  * `RequirementSignature` the selected transaction route consumes. The requirement's
28
26
  * `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
29
- * Deadline defaults to two hours from `Time.timestamp()`.
27
+ * Deadline defaults to two hours from `params.now` (the deprecated fallback uses the device clock).
30
28
  * The operator pin applies to grants and revocations alike: revoking a previously registered
31
29
  * operator is outside this helper's scope.
32
30
  *
@@ -40,7 +38,7 @@ interface EncodeBlueSignatureAuthorizationParams {
40
38
  * @param params.nonce - The owner's current Morpho authorization nonce.
41
39
  * @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
42
40
  * @param params.deadline - Optional signature deadline in seconds.
43
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
41
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
44
42
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
45
43
  * `sign(client, userAddress)` produces the deep-frozen signature.
46
44
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
@@ -12,7 +12,7 @@ import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOpe
12
12
  * typed data, verifies it against the connected account, and returns a deep-frozen
13
13
  * `RequirementSignature` the selected transaction route consumes. The requirement's
14
14
  * `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
15
- * Deadline defaults to two hours from `Time.timestamp()`.
15
+ * Deadline defaults to two hours from `params.now` (the deprecated fallback uses the device clock).
16
16
  * The operator pin applies to grants and revocations alike: revoking a previously registered
17
17
  * operator is outside this helper's scope.
18
18
  *
@@ -26,7 +26,7 @@ import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOpe
26
26
  * @param params.nonce - The owner's current Morpho authorization nonce.
27
27
  * @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
28
28
  * @param params.deadline - Optional signature deadline in seconds.
29
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
29
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
30
30
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
31
31
  * `sign(client, userAddress)` produces the deep-frozen signature.
32
32
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
@@ -84,7 +84,7 @@ export const encodeBlueSignatureAuthorization = async (viemClient, params) => {
84
84
  throw new ExpiredDeadlineError(params.deadline, timestamp);
85
85
  }
86
86
  }
87
- const deadline = params.deadline ?? Time.timestamp() + Time.s.from.h(2n);
87
+ const deadline = params.deadline ?? (params.now ?? Time.timestamp()) + Time.s.from.h(2n);
88
88
  const typedData = deepFreeze(getAuthorizationTypedData({ authorizer: owner, authorized, isAuthorized, nonce, deadline }, chainId));
89
89
  const action = {
90
90
  type: "authorization",
@@ -1,8 +1,8 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
2
  import type { Client } from "viem";
3
- import { type Erc2612RequirementSignature, type Requirement } from "../../../types/index.js";
3
+ import { type Erc2612RequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
4
4
  /** Parameters for {@link encodeErc20Permit}. */
5
- interface EncodeErc20PermitParams {
5
+ interface EncodeErc20PermitParams extends ReferenceTimestampParams {
6
6
  token: Address;
7
7
  /** Account that owns the tokens and signs the permit. */
8
8
  owner: Address;
@@ -12,8 +12,6 @@ interface EncodeErc20PermitParams {
12
12
  nonce: bigint;
13
13
  supportDeployless?: boolean;
14
14
  deadline?: bigint;
15
- /** Timestamp the deadline is validated against; defaults to the current time. */
16
- now?: bigint;
17
15
  }
18
16
  /**
19
17
  * Builds an EIP-2612 permit `Requirement` that, once signed, lets a supported SDK spender pull
@@ -23,7 +21,7 @@ interface EncodeErc20PermitParams {
23
21
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
24
22
  * the selected transaction route can consume. The requirement's `action.typedData` holds that
25
23
  * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
26
- * hours from `Time.timestamp()`.
24
+ * hours from `params.now` (the deprecated fallback uses the device clock).
27
25
  *
28
26
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
29
27
  * @param params - Permit encoding parameters.
@@ -36,7 +34,7 @@ interface EncodeErc20PermitParams {
36
34
  * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
37
35
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
38
36
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
39
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
37
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
40
38
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
41
39
  * `sign(client, userAddress)` produces the deep-frozen signature.
42
40
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
@@ -13,7 +13,7 @@ import { validateClientChainId } from "../validateClientChainId.js";
13
13
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
14
14
  * the selected transaction route can consume. The requirement's `action.typedData` holds that
15
15
  * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
16
- * hours from `Time.timestamp()`.
16
+ * hours from `params.now` (the deprecated fallback uses the device clock).
17
17
  *
18
18
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
19
19
  * @param params - Permit encoding parameters.
@@ -26,7 +26,7 @@ import { validateClientChainId } from "../validateClientChainId.js";
26
26
  * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
27
27
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
28
28
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
29
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
29
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
30
30
  * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
31
31
  * `sign(client, userAddress)` produces the deep-frozen signature.
32
32
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`, or when the RPC
@@ -93,7 +93,7 @@ export const encodeErc20Permit = async (viemClient, params) => {
93
93
  throw new ExpiredDeadlineError(params.deadline, timestamp);
94
94
  }
95
95
  }
96
- const deadline = params.deadline ?? Time.timestamp() + Time.s.from.h(2n);
96
+ const deadline = params.deadline ?? (params.now ?? Time.timestamp()) + Time.s.from.h(2n);
97
97
  await validateClientChainId(viemClient, chainId);
98
98
  const tokenData = await fetchToken(token, viemClient, {
99
99
  deployless: supportDeployless,
@@ -1,10 +1,10 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
- import { type Permit2SignatureTransferRequirementSignature, type Requirement } from "../../../types/index.js";
2
+ import { type Permit2SignatureTransferRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
3
3
  /**
4
4
  * Parameters for {@link encodeErc20Permit2SignatureTransfer}.
5
5
  * @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
6
6
  */
7
- export interface EncodeErc20Permit2SignatureTransferParams {
7
+ export interface EncodeErc20Permit2SignatureTransferParams extends ReferenceTimestampParams {
8
8
  /** ERC-20 token pulled through Permit2. */
9
9
  readonly token: Address;
10
10
  /** Registered fixed bundles deployment receiving permission to pull the token. */
@@ -17,8 +17,6 @@ export interface EncodeErc20Permit2SignatureTransferParams {
17
17
  readonly nonce: bigint;
18
18
  /** Signature expiration timestamp in seconds. */
19
19
  readonly deadline: bigint;
20
- /** Timestamp the deadline is validated against; defaults to the current time. */
21
- readonly now?: bigint;
22
20
  }
23
21
  /**
24
22
  * Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
@@ -34,7 +32,7 @@ export interface EncodeErc20Permit2SignatureTransferParams {
34
32
  * @param params.chainId - Target chain id.
35
33
  * @param params.nonce - Unused Permit2 unordered nonce.
36
34
  * @param params.deadline - Signature expiration timestamp in seconds.
37
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
35
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
38
36
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
39
37
  * `sign(client, userAddress)` returns a deep-frozen signature result.
40
38
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
@@ -62,7 +60,8 @@ export interface EncodeErc20Permit2SignatureTransferParams {
62
60
  * amount: 1_000_000n,
63
61
  * chainId: mainnet.id,
64
62
  * nonce: 0n,
65
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
63
+ * now: (await client.getBlock()).timestamp,
64
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
66
65
  * });
67
66
  * // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
68
67
  * ```
@@ -1,10 +1,9 @@
1
1
  import { getPermit2TransferFromTypedData } from "@morpho-org/blue-sdk-viem";
2
2
  import { deepFreeze, getChainAddress, Time } from "@morpho-org/morpho-ts";
3
- import { maxUint256 } from "viem";
4
3
  import { signAndVerifyTypedData } from "../../../helpers/signAndVerifyTypedData.js";
5
- import { validateUint256Field } from "../../../helpers/validate.js";
4
+ import { validateDeadline, validateUint256Field, } from "../../../helpers/validate.js";
6
5
  import { validateRequirementSpender } from "../../../helpers/validateRequirementSpender.js";
7
- import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } from "../../../types/index.js";
6
+ import { ExpiredDeadlineError, } from "../../../types/index.js";
8
7
  /**
9
8
  * Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
10
9
  *
@@ -19,7 +18,7 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
19
18
  * @param params.chainId - Target chain id.
20
19
  * @param params.nonce - Unused Permit2 unordered nonce.
21
20
  * @param params.deadline - Signature expiration timestamp in seconds.
22
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
21
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
23
22
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
24
23
  * `sign(client, userAddress)` returns a deep-frozen signature result.
25
24
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
@@ -47,7 +46,8 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
47
46
  * amount: 1_000_000n,
48
47
  * chainId: mainnet.id,
49
48
  * nonce: 0n,
50
- * deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
49
+ * now: (await client.getBlock()).timestamp,
50
+ * deadline: (await client.getBlock()).timestamp + 3_600n,
51
51
  * });
52
52
  * // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
53
53
  * ```
@@ -61,16 +61,8 @@ export const encodeErc20Permit2SignatureTransfer = (params) => {
61
61
  // this public encoder must reject the same out-of-range inputs itself.
62
62
  validateUint256Field("amount", amount);
63
63
  validateUint256Field("nonce", nonce);
64
- if (deadline <= 0n) {
65
- throw new NonPositiveInputError("deadline", deadline);
66
- }
67
- if (deadline > maxUint256) {
68
- throw new InputExceedsMaxError({
69
- field: "deadline",
70
- value: deadline,
71
- max: maxUint256,
72
- });
73
- }
64
+ // Reject deadlines outside the positive uint256 range before signing.
65
+ validateDeadline(deadline);
74
66
  // Reject an already-expired deadline before signing so a direct caller is never walked through a
75
67
  // wallet EIP-712 prompt for a SignatureTransfer that Permit2 would revert with `SignatureExpired`.
76
68
  // The sibling encodeErc20Permit and the token-requirement resolver enforce the same guard.
@@ -1,7 +1,7 @@
1
1
  import { type Address, Token } from "@morpho-org/blue-sdk";
2
- import { type PermitRequirementSignature, type Requirement } from "../../../types/index.js";
2
+ import { type PermitRequirementSignature, type ReferenceTimestampParams, type Requirement } from "../../../types/index.js";
3
3
  /** Parameters for {@link encodeVaultSharesPermit}. */
4
- export interface EncodeVaultSharesPermitParams {
4
+ export interface EncodeVaultSharesPermitParams extends ReferenceTimestampParams {
5
5
  /** Vault share token, including V1 permit-domain metadata when available. */
6
6
  readonly vault: Token;
7
7
  /** Vault generation, which selects the standard V1 or two-field V2 domain. */
@@ -16,8 +16,6 @@ export interface EncodeVaultSharesPermitParams {
16
16
  readonly nonce: bigint;
17
17
  /** Shared permit and bundle deadline. */
18
18
  readonly deadline: bigint;
19
- /** Timestamp the deadline is validated against; defaults to the current time. */
20
- readonly now?: bigint;
21
19
  }
22
20
  /**
23
21
  * Builds an unlimited ERC-2612 shares-permit requirement used by a vault exit.
@@ -33,7 +31,7 @@ export interface EncodeVaultSharesPermitParams {
33
31
  * @param params.chainId - Chain on which the vault and spender are deployed.
34
32
  * @param params.nonce - Current vault permit nonce for the owner.
35
33
  * @param params.deadline - Shared permit and bundle deadline.
36
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
34
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
37
35
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
38
36
  * can be embedded in fixed vault-bundles calldata.
39
37
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
@@ -20,7 +20,7 @@ import { ExpiredDeadlineError, } from "../../../types/index.js";
20
20
  * @param params.chainId - Chain on which the vault and spender are deployed.
21
21
  * @param params.nonce - Current vault permit nonce for the owner.
22
22
  * @param params.deadline - Shared permit and bundle deadline.
23
- * @param params.now - Timestamp the deadline is validated against; defaults to the current time.
23
+ * @param params.now - See {@link ReferenceTimestampParams.now}.
24
24
  * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
25
25
  * can be embedded in fixed vault-bundles calldata.
26
26
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
@@ -59,31 +59,34 @@ import { ExpiredDeadlineError, } from "../../../types/index.js";
59
59
  export const encodeVaultSharesPermit = (params) => {
60
60
  const { vault: inputVault, version, spender, owner, chainId, nonce, deadline, } = params;
61
61
  const inputDomain = inputVault.eip5267Domain;
62
+ let eip5267Domain;
63
+ if (version === "vaultV2") {
64
+ eip5267Domain = new Eip5267Domain({
65
+ // Only the bitmap-selected fields enter Vault V2's domain separator.
66
+ fields: "0x0c",
67
+ name: "",
68
+ version: "",
69
+ chainId: BigInt(chainId),
70
+ verifyingContract: inputVault.address,
71
+ salt: zeroHash,
72
+ extensions: [],
73
+ });
74
+ }
75
+ else if (inputDomain != null) {
76
+ eip5267Domain = new Eip5267Domain({
77
+ fields: inputDomain.fields,
78
+ name: inputDomain.name,
79
+ version: inputDomain.version,
80
+ chainId: inputDomain.chainId,
81
+ verifyingContract: inputDomain.verifyingContract,
82
+ salt: inputDomain.salt,
83
+ extensions: [...inputDomain.extensions],
84
+ });
85
+ }
62
86
  const vault = new Token({
63
87
  address: inputVault.address,
64
88
  name: inputVault.name,
65
- eip5267Domain: version === "vaultV2"
66
- ? new Eip5267Domain({
67
- // Only the bitmap-selected fields enter Vault V2's domain separator.
68
- fields: "0x0c",
69
- name: "",
70
- version: "",
71
- chainId: BigInt(chainId),
72
- verifyingContract: inputVault.address,
73
- salt: zeroHash,
74
- extensions: [],
75
- })
76
- : inputDomain == null
77
- ? undefined
78
- : new Eip5267Domain({
79
- fields: inputDomain.fields,
80
- name: inputDomain.name,
81
- version: inputDomain.version,
82
- chainId: inputDomain.chainId,
83
- verifyingContract: inputDomain.verifyingContract,
84
- salt: inputDomain.salt,
85
- extensions: [...inputDomain.extensions],
86
- }),
89
+ eip5267Domain,
87
90
  });
88
91
  // Bind the permit to one of the registered fixed vault bundles deployments.
89
92
  validateRequirementSpender({
@@ -69,8 +69,9 @@ export const getMidnightApprovalRequirements = async (params) => {
69
69
  spender: params.spender,
70
70
  allowed: ["midnight", "midnightBundlesV2"],
71
71
  });
72
- if (params.amount === 0n)
72
+ if (params.amount === 0n) {
73
73
  return [];
74
+ }
74
75
  await validateClientChainId(params.viemClient, params.chainId);
75
76
  const allowance = await readContract(params.viemClient, {
76
77
  address: params.token,
@@ -65,8 +65,9 @@ export const getMidnightAuthorizationRequirement = async (params) => {
65
65
  functionName: "isAuthorized",
66
66
  args: [params.owner, params.authorized],
67
67
  });
68
- if (isAuthorized)
68
+ if (isAuthorized) {
69
69
  return null;
70
+ }
70
71
  return deepFreeze({
71
72
  to: midnight,
72
73
  value: 0n,
@@ -44,11 +44,13 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
44
44
  * ```
45
45
  */
46
46
  export const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
47
- if (args.amount <= 0n)
47
+ if (args.amount <= 0n) {
48
48
  throw new NonPositiveInputError("amount", args.amount);
49
+ }
49
50
  validateDeadline(args.deadline);
50
- if (args.marketParamsList.length === 0)
51
+ if (args.marketParamsList.length === 0) {
51
52
  throw new EmptyMarketParamsListError();
53
+ }
52
54
  const to = getChainAddress(vault.chainId, "bundles.vaultExitBundlesV1");
53
55
  const marketParamsList = args.marketParamsList.map((marketParams) => ({
54
56
  loanToken: marketParams.loanToken,
@@ -79,8 +81,9 @@ export const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
79
81
  ],
80
82
  }),
81
83
  };
82
- if (metadata)
84
+ if (metadata) {
83
85
  tx = addTransactionMetadata(tx, metadata);
86
+ }
84
87
  return deepFreeze({
85
88
  ...tx,
86
89
  action: {
@@ -87,7 +87,7 @@ export const vaultV1MigrateToV2 = (params) => {
87
87
  throw new AmountAndSharesExclusiveError();
88
88
  }
89
89
  const selectedAmount = assets ?? shares ?? 0n;
90
- const amountField = assets != null ? "assets" : "shares";
90
+ const amountField = assets == null ? "shares" : "assets";
91
91
  // Validation only; rejects non-positive migration amounts.
92
92
  validatePositiveInput(amountField, selectedAmount);
93
93
  // Validation only; rejects non-positive share-price bounds.
@@ -74,8 +74,9 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
74
74
  * ```
75
75
  */
76
76
  export const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
77
- if (args.exitAssets <= 0n)
77
+ if (args.exitAssets <= 0n) {
78
78
  throw new NonPositiveInputError("exitAssets", args.exitAssets);
79
+ }
79
80
  validateUint256Field("exitAssets", args.exitAssets);
80
81
  validateDeadline(args.deadline);
81
82
  // `0n` stays valid — it is the intentional "no on-chain bound" opt-out — but a value the uint256
@@ -109,8 +110,9 @@ export const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
109
110
  ],
110
111
  }),
111
112
  };
112
- if (metadata)
113
+ if (metadata) {
113
114
  tx = addTransactionMetadata(tx, metadata);
115
+ }
114
116
  return deepFreeze({
115
117
  ...tx,
116
118
  action: {
@@ -45,8 +45,9 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
45
45
  * ```
46
46
  */
47
47
  export const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
48
- if (args.amount <= 0n)
48
+ if (args.amount <= 0n) {
49
49
  throw new NonPositiveInputError("amount", args.amount);
50
+ }
50
51
  validateDeadline(args.deadline);
51
52
  const to = getChainAddress(vault.chainId, "bundles.vaultExitBundlesV1");
52
53
  const marketParamsList = args.marketParamsList.map((marketParams) => ({
@@ -79,8 +80,9 @@ export const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
79
80
  ],
80
81
  }),
81
82
  };
82
- if (metadata)
83
+ if (metadata) {
83
84
  tx = addTransactionMetadata(tx, metadata);
85
+ }
84
86
  return deepFreeze({
85
87
  ...tx,
86
88
  action: {