@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/MIGRATION-v5-to-v6.md +329 -15
  2. package/README.md +93 -47
  3. package/lib/cjs/abis.d.ts +227 -2
  4. package/lib/cjs/abis.js +156 -3
  5. package/lib/cjs/actions/blue/borrow.d.ts +1 -1
  6. package/lib/cjs/actions/blue/borrow.js +1 -1
  7. package/lib/cjs/actions/blue/common.d.ts +6 -19
  8. package/lib/cjs/actions/blue/common.js +28 -162
  9. package/lib/cjs/actions/blue/refinance.d.ts +1 -1
  10. package/lib/cjs/actions/blue/refinance.js +1 -1
  11. package/lib/cjs/actions/blue/repay.d.ts +3 -3
  12. package/lib/cjs/actions/blue/repay.js +1 -1
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
  14. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
  15. package/lib/cjs/actions/blue/supply.d.ts +3 -3
  16. package/lib/cjs/actions/blue/supply.js +3 -8
  17. package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
  18. package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
  21. package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
  22. package/lib/cjs/actions/blue/withdraw.js +1 -1
  23. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
  24. package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
  25. package/lib/cjs/actions/bundles/common.d.ts +230 -0
  26. package/lib/cjs/actions/bundles/common.js +507 -0
  27. package/lib/cjs/actions/bundles/index.d.ts +3 -0
  28. package/lib/cjs/actions/bundles/index.js +23 -0
  29. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  30. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
  31. package/lib/cjs/actions/index.d.ts +1 -0
  32. package/lib/cjs/actions/index.js +1 -0
  33. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  34. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  35. package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
  36. package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
  37. package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
  38. package/lib/cjs/actions/midnight/takeLend.js +2 -2
  39. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  40. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
  41. package/lib/cjs/actions/requirements/blue/index.d.ts +0 -2
  42. package/lib/cjs/actions/requirements/blue/index.js +0 -2
  43. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  44. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
  45. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  46. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
  47. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +19 -10
  48. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +43 -31
  49. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  50. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  51. package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
  52. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +27 -22
  53. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
  54. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
  55. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -1
  56. package/lib/cjs/actions/requirements/encode/index.js +1 -1
  57. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  58. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  59. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  60. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
  61. package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
  62. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
  63. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +28 -30
  64. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +20 -66
  65. package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
  66. package/lib/cjs/actions/vaultV1/deposit.js +110 -109
  67. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -0
  68. package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
  69. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
  70. package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
  71. package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
  72. package/lib/cjs/actions/vaultV1/redeem.js +56 -33
  73. package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
  74. package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
  75. package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
  76. package/lib/cjs/actions/vaultV2/deposit.js +111 -109
  77. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
  78. package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
  79. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
  80. package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
  81. package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
  82. package/lib/cjs/actions/vaultV2/redeem.js +56 -34
  83. package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
  84. package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
  85. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  86. package/lib/cjs/blue/abis.d.ts +5 -1
  87. package/lib/cjs/blue/abis.js +2 -0
  88. package/lib/cjs/blue/entities.d.ts +8 -2
  89. package/lib/cjs/blue/entities.js +1 -0
  90. package/lib/cjs/blue/errors.d.ts +1 -1
  91. package/lib/cjs/blue/errors.js +2 -1
  92. package/lib/cjs/blue/fetch.d.ts +3 -1
  93. package/lib/cjs/blue/fetch.js +1 -0
  94. package/lib/cjs/entities/blue/blue.d.ts +29 -20
  95. package/lib/cjs/entities/blue/blue.js +6 -1
  96. package/lib/cjs/entities/index.d.ts +9 -2
  97. package/lib/cjs/entities/index.js +16 -0
  98. package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
  99. package/lib/cjs/entities/midnight/midnight.js +20 -24
  100. package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
  101. package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +76 -75
  102. package/lib/{esm/actions/requirements/blue → cjs/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
  103. package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
  104. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  105. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
  106. package/lib/cjs/entities/requirements/index.d.ts +2 -0
  107. package/lib/cjs/entities/requirements/index.js +18 -0
  108. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +356 -101
  109. package/lib/cjs/entities/vaultV1/vaultV1.js +334 -120
  110. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
  111. package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
  112. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +359 -100
  113. package/lib/cjs/entities/vaultV2/vaultV2.js +448 -93
  114. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
  115. package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
  116. package/lib/cjs/errors.d.ts +1 -1
  117. package/lib/cjs/errors.js +3 -2
  118. package/lib/cjs/fetch.d.ts +3 -1
  119. package/lib/cjs/fetch.js +1 -0
  120. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
  121. package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
  122. package/lib/cjs/helpers/index.d.ts +4 -1
  123. package/lib/cjs/helpers/index.js +14 -1
  124. package/lib/cjs/helpers/metadata.d.ts +3 -5
  125. package/lib/cjs/helpers/metadata.js +4 -6
  126. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  127. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
  128. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  129. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
  130. package/lib/cjs/helpers/referralFee.d.ts +21 -0
  131. package/lib/cjs/helpers/referralFee.js +35 -0
  132. package/lib/cjs/helpers/slippage.d.ts +136 -1
  133. package/lib/cjs/helpers/slippage.js +188 -0
  134. package/lib/cjs/helpers/validate.d.ts +67 -8
  135. package/lib/cjs/helpers/validate.js +94 -9
  136. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  137. package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
  138. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  139. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
  140. package/lib/cjs/index.d.ts +1 -0
  141. package/lib/cjs/index.js +1 -0
  142. package/lib/cjs/types/action.d.ts +273 -82
  143. package/lib/cjs/types/action.js +12 -12
  144. package/lib/cjs/types/error.d.ts +349 -23
  145. package/lib/cjs/types/error.js +393 -39
  146. package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
  147. package/lib/cjs/utils.d.ts +3 -1
  148. package/lib/cjs/utils.js +10 -1
  149. package/lib/esm/abis.d.ts +227 -2
  150. package/lib/esm/abis.js +157 -2
  151. package/lib/esm/actions/blue/borrow.d.ts +1 -1
  152. package/lib/esm/actions/blue/borrow.js +1 -1
  153. package/lib/esm/actions/blue/common.d.ts +6 -19
  154. package/lib/esm/actions/blue/common.js +30 -164
  155. package/lib/esm/actions/blue/refinance.d.ts +1 -1
  156. package/lib/esm/actions/blue/refinance.js +1 -1
  157. package/lib/esm/actions/blue/repay.d.ts +3 -3
  158. package/lib/esm/actions/blue/repay.js +1 -1
  159. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
  160. package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
  161. package/lib/esm/actions/blue/supply.d.ts +3 -3
  162. package/lib/esm/actions/blue/supply.js +5 -10
  163. package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
  164. package/lib/esm/actions/blue/supplyCollateral.js +1 -1
  165. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
  166. package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
  167. package/lib/esm/actions/blue/withdraw.d.ts +1 -1
  168. package/lib/esm/actions/blue/withdraw.js +1 -1
  169. package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
  170. package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
  171. package/lib/esm/actions/bundles/common.d.ts +230 -0
  172. package/lib/esm/actions/bundles/common.js +494 -0
  173. package/lib/esm/actions/bundles/index.d.ts +3 -0
  174. package/lib/esm/actions/bundles/index.js +2 -0
  175. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  176. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
  177. package/lib/esm/actions/index.d.ts +1 -0
  178. package/lib/esm/actions/index.js +1 -0
  179. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  180. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  181. package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
  182. package/lib/esm/actions/midnight/takeBorrow.js +2 -2
  183. package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
  184. package/lib/esm/actions/midnight/takeLend.js +2 -2
  185. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  186. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
  187. package/lib/esm/actions/requirements/blue/index.d.ts +0 -2
  188. package/lib/esm/actions/requirements/blue/index.js +0 -2
  189. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  190. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +22 -22
  191. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  192. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
  193. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +19 -10
  194. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +44 -32
  195. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  196. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  197. package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
  198. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +25 -20
  199. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
  200. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
  201. package/lib/esm/actions/requirements/encode/index.d.ts +1 -1
  202. package/lib/esm/actions/requirements/encode/index.js +1 -1
  203. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  204. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  205. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  206. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
  207. package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
  208. package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
  209. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +28 -30
  210. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +21 -67
  211. package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
  212. package/lib/esm/actions/vaultV1/deposit.js +112 -111
  213. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -0
  214. package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
  215. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
  216. package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
  217. package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
  218. package/lib/esm/actions/vaultV1/redeem.js +56 -33
  219. package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
  220. package/lib/esm/actions/vaultV1/withdraw.js +86 -34
  221. package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
  222. package/lib/esm/actions/vaultV2/deposit.js +113 -111
  223. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
  224. package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
  225. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
  226. package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
  227. package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
  228. package/lib/esm/actions/vaultV2/redeem.js +56 -34
  229. package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
  230. package/lib/esm/actions/vaultV2/withdraw.js +86 -35
  231. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  232. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
  233. package/lib/esm/blue/abis.d.ts +5 -1
  234. package/lib/esm/blue/abis.js +5 -1
  235. package/lib/esm/blue/entities.d.ts +8 -2
  236. package/lib/esm/blue/entities.js +3 -1
  237. package/lib/esm/blue/errors.d.ts +1 -1
  238. package/lib/esm/blue/errors.js +1 -1
  239. package/lib/esm/blue/fetch.d.ts +3 -1
  240. package/lib/esm/blue/fetch.js +3 -1
  241. package/lib/esm/entities/blue/blue.d.ts +29 -20
  242. package/lib/esm/entities/blue/blue.js +7 -2
  243. package/lib/esm/entities/index.d.ts +9 -2
  244. package/lib/esm/entities/index.js +4 -1
  245. package/lib/esm/entities/midnight/midnight.d.ts +2 -2
  246. package/lib/esm/entities/midnight/midnight.js +20 -24
  247. package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
  248. package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +67 -66
  249. package/lib/{cjs/actions/requirements/blue → esm/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
  250. package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
  251. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  252. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
  253. package/lib/esm/entities/requirements/index.d.ts +2 -0
  254. package/lib/esm/entities/requirements/index.js +2 -0
  255. package/lib/esm/entities/vaultV1/vaultV1.d.ts +356 -101
  256. package/lib/esm/entities/vaultV1/vaultV1.js +338 -124
  257. package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
  258. package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
  259. package/lib/esm/entities/vaultV2/vaultV2.d.ts +359 -100
  260. package/lib/esm/entities/vaultV2/vaultV2.js +452 -97
  261. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
  262. package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
  263. package/lib/esm/errors.d.ts +1 -1
  264. package/lib/esm/errors.js +1 -1
  265. package/lib/esm/fetch.d.ts +3 -1
  266. package/lib/esm/fetch.js +3 -1
  267. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
  268. package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
  269. package/lib/esm/helpers/index.d.ts +4 -1
  270. package/lib/esm/helpers/index.js +4 -1
  271. package/lib/esm/helpers/metadata.d.ts +3 -5
  272. package/lib/esm/helpers/metadata.js +4 -6
  273. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  274. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
  275. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  276. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
  277. package/lib/esm/helpers/referralFee.d.ts +21 -0
  278. package/lib/esm/helpers/referralFee.js +31 -0
  279. package/lib/esm/helpers/slippage.d.ts +136 -1
  280. package/lib/esm/helpers/slippage.js +186 -2
  281. package/lib/esm/helpers/validate.d.ts +67 -8
  282. package/lib/esm/helpers/validate.js +92 -10
  283. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  284. package/lib/esm/helpers/validateRequirementSpender.js +1 -0
  285. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  286. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
  287. package/lib/esm/index.d.ts +1 -0
  288. package/lib/esm/index.js +1 -0
  289. package/lib/esm/types/action.d.ts +273 -82
  290. package/lib/esm/types/action.js +11 -11
  291. package/lib/esm/types/error.d.ts +349 -23
  292. package/lib/esm/types/error.js +377 -31
  293. package/lib/esm/types/sharedLiquidity.d.ts +2 -2
  294. package/lib/esm/utils.d.ts +3 -1
  295. package/lib/esm/utils.js +3 -1
  296. package/package.json +7 -7
@@ -3,7 +3,66 @@
3
3
  Version 6 keeps the Blue entity at `client.morpho.blue(marketParams, chainId)` and preserves its
4
4
  write-method names while routing them through five direct BlueBundlesV1 entrypoints. Blue reads and
5
5
  versioned reallocation-data helpers remain on the same entity. There is no parallel BlueBundlesV1
6
- extension or automatic fallback to the v5 route.
6
+ extension or automatic fallback to the v5 route. Version 6 also reshapes Vault V2 `forceWithdraw`
7
+ to route through the standalone `VaultExitBundlesV1` periphery. This guide covers the Blue write
8
+ rerouting and the Vault V2 `forceWithdraw` route replacement alongside the other v6 breaks
9
+ documented in the sections below.
10
+
11
+ ## Vault V1 and Vault V2 deposits
12
+
13
+ `MorphoVaultV1.deposit`, `MorphoVaultV2.deposit`, `vaultV1Deposit`, and `vaultV2Deposit` keep their
14
+ names but now route through the chain's registered VaultBundlesV1 contract instead of Bundler3 and
15
+ GeneralAdapter1.
16
+
17
+ > **Chain availability.** Vault deposits and withdrawals require the `bundles.vaultBundlesV1`
18
+ > deployment on the target chain. On a registered chain without it, including Fraxtal,
19
+ > `MorphoVaultV1.deposit()`, `MorphoVaultV2.deposit()`, `MorphoVaultV1.withdraw()`, and
20
+ > `MorphoVaultV2.withdraw()` throw `UnknownAddressError` synchronously at handle creation,
21
+ > before `getRequirements()` or `buildTx()` can be called. This is a breaking loss of deposit
22
+ > and withdrawal functionality on chains previously supported through Bundler3/GeneralAdapter1
23
+ > deposits and direct vault withdrawals; there is no automatic fallback. Confirm coverage before
24
+ > upgrading with `getChainAddresses(chainId).bundles?.vaultBundlesV1 != null`. Stay on v5 if your
25
+ > application needs deposits or withdrawals on an affected chain until VaultBundlesV1 is deployed
26
+ > and registered in the SDK.
27
+
28
+ As checked on 2026-09-07, the [official deployment list](https://docs.morpho.org/developers/contracts/addresses/#bundles)
29
+ and the [SDK registry](../morpho-ts/src/addresses.ts) list VaultBundlesV1 on 13 chains: Ethereum,
30
+ Arbitrum, Base, HyperEVM, Katana, Monad, Optimism, Polygon, Robinhood, Stable, Tempo, Unichain, and
31
+ World Chain. Bundler3 availability alone does not imply support for v6 vault deposits or withdrawals.
32
+
33
+ Update deposit inputs as follows:
34
+
35
+ | v5 | v6 |
36
+ | --- | --- |
37
+ | `amount` plus optional additive `nativeAmount` | Choose exactly one positive `amount` or `nativeAmount`. |
38
+ | Low-level `args.recipient` | Remove it. VaultBundlesV1 mints shares to `msg.sender`; `userAddress` must be the signing and submitting account. |
39
+ | Optional Bundler3 `PermitRequirementSignature` | Use an ERC-2612 or Permit2 SignatureTransfer requirement returned by the prepared entity handle. |
40
+ | No deadline or referral fee | Entity methods accept an optional `deadline` that defaults to two hours from preparation; low-level builders require it. Both surfaces accept optional `referralFeePct` and `referralFeeRecipient`. |
41
+
42
+ For ERC-20 funding, approvals and ERC-2612 permits now name VaultBundlesV1 as spender. Permit2
43
+ keeps its ERC-20 approval on canonical Permit2, while its one-time SignatureTransfer payload names
44
+ VaultBundlesV1. Resolve requirements and build from the same prepared handle so its captured nonce,
45
+ deadline, asset, owner, amount, and spender remain consistent:
46
+
47
+ ```ts
48
+ const deposit = vault.deposit({
49
+ amount: 1_000_000n,
50
+ userAddress,
51
+ vaultData,
52
+ referralFeePct,
53
+ referralFeeRecipient,
54
+ });
55
+
56
+ const requirements = await deposit.getRequirements({ permit2Nonce });
57
+ // Submit approval transactions or sign the returned token requirement first.
58
+ const tx = deposit.buildTx(requirementSignature ? [requirementSignature] : undefined);
59
+ ```
60
+
61
+ Deposit action metadata no longer contains `recipient`. It now reports the gross `amount`, optional
62
+ `nativeAmount`, `maxSharePrice`, `referralFeePct`, `referralFeeRecipient`, exact
63
+ `referralFeeAssets`, resulting `netAssets`, and `deadline`.
64
+
65
+ ## Blue write routing
7
66
 
8
67
  > **Chain availability.** The direct BlueBundlesV1 route requires the `bundles.blueBundlesV1`
9
68
  > deployment on the target chain. On a registered chain without it (the previous Bundler3-routed
@@ -13,6 +72,57 @@ extension or automatic fallback to the v5 route.
13
72
  > `validateWriteCommon`). Confirm coverage before upgrading, for example
14
73
  > `getChainAddresses(chainId).bundles?.blueBundlesV1 != null`.
15
74
 
75
+ Version 6 also preserves the Vault V1 and Vault V2 method and builder names while routing `deposit`,
76
+ `withdraw`, and `redeem` through VaultBundlesV1. Vault V1 `migrateToV2` uses the same fixed route.
77
+
78
+ > **Chain availability.** The VaultBundlesV1 route requires the `bundles.vaultBundlesV1` deployment
79
+ > on the target chain. On a registered chain without it (Celo, for example, still registers
80
+ > MetaMorpho and Vault V2 deployments), **every** routed vault write — Vault V1 `deposit`,
81
+ > `withdraw`, `redeem`, and `migrateToV2`, and Vault V2 `deposit`, `withdraw`, and `redeem` — throws
82
+ > `UnknownAddressError` synchronously at handle creation, where v5 built a direct vault or Bundler3
83
+ > call. Confirm coverage before upgrading, for example
84
+ > `getChainAddresses(chainId).bundles?.vaultBundlesV1 != null`. Vault `inKindRedeem` is unaffected:
85
+ > it already routed through `bundles.vaultExitBundlesV1` in v5, and its chain coverage is unchanged.
86
+
87
+ ## Update Vault V1 and Vault V2 methods
88
+
89
+ | Stable method | v5 input/workflow | v6 input/workflow |
90
+ | --- | --- | --- |
91
+ | `deposit` | Additive `amount` and `nativeAmount`; Bundler3/GeneralAdapter1 requirements. | Supply exactly one of `amount` or `nativeAmount`; optionally set `deadline`, `referralFeePct`, and `referralFeeRecipient`. Token requirements authorize VaultBundlesV1 and may return Permit2 SignatureTransfer. |
92
+ | `withdraw` | Direct vault withdrawal with no share requirement. | Exact-assets VaultBundlesV1 exit. Optionally set `slippageTolerance`, `deadline`, and referral fields; resolve a vault-share approval or ERC-2612 permit before building. |
93
+ | `redeem` | Direct vault redemption with no share requirement. | Exact-shares VaultBundlesV1 exit. Optionally set `deadline` and referral fields; resolve a vault-share approval or ERC-2612 permit before building. |
94
+ | `migrateToV2` (Vault V1 only) | Share-denominated Bundler3 migration with a source `minSharePriceVaultV1`. | Keep the existing `shares` mode or supply the new `assets` alternative; remove the source share-price bound; optionally set `slippageTolerance`, `deadline`, and referral fields. Resolve source-vault share authorization before building. The destination deposit retains its onchain maximum-share-price bound. |
95
+
96
+ `userAddress` now means the account that will submit the transaction. VaultBundlesV1 always deposits
97
+ for, burns shares from, and pays `msg.sender`; arbitrary `recipient` and `onBehalf` values are no
98
+ longer supported. Keep `userAddress` equal to the eventual signer, including when preparing a
99
+ transaction with a public client.
100
+
101
+ The lazy workflow now applies to Vault V1 exits as well as deposits: await `getRequirements()`, send
102
+ any returned approval transactions or collect the returned signature, and pass collected signatures
103
+ to `buildTx(signatures)`. Deposit requirement options accept `useSimplePermit` and an explicit
104
+ `permit2Nonce`; exit requirements use the vault share token's ERC-2612 permit. The built transaction
105
+ targets VaultBundlesV1 rather than Bundler3 or the vault itself.
106
+
107
+ Pure builder names remain stable, but their `args` objects change:
108
+
109
+ | Stable builder | v6 `args` fields |
110
+ | --- | --- |
111
+ | `vaultV1Deposit` | Exclusive `amount`/`nativeAmount`, `maxSharePrice`, `userAddress`, optional bundles token `requirementSignature`, required `deadline`, and optional referral fields. |
112
+ | `vaultV1Withdraw` | `amount`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
113
+ | `vaultV1Redeem` | `shares`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
114
+ | `vaultV1MigrateToV2` | Exclusive `assets`/`shares`, `targetVault`, `targetAsset`, `maxSharePriceVaultV2`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
115
+ | `vaultV2Deposit` | Exclusive `amount`/`nativeAmount`, `maxSharePrice`, `userAddress`, optional bundles token `requirementSignature`, required `deadline`, and optional referral fields. |
116
+ | `vaultV2Withdraw` | `amount`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
117
+ | `vaultV2Redeem` | `shares`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
118
+
119
+ Every vault builder replaces v5's `recipient` and `onBehalf` with a single `userAddress` that must be
120
+ the eventual `msg.sender`, and `vault` now takes `{ chainId, address }` (plus `asset` on the deposit
121
+ and migration builders) so the builder can resolve the VaultBundlesV1 address for the target chain.
122
+
123
+ Vault V1 deposit and migration destination bounds are forecast through the selected deadline, so an
124
+ explicit deadline beyond the two-hour default remains covered by the computed maximum share price.
125
+
16
126
  ## Update Blue methods
17
127
 
18
128
  | Stable method | v5 input | v6 input |
@@ -30,7 +140,38 @@ extension or automatic fallback to the v5 route.
30
140
  The two combined methods require at least one non-zero leg. See the dedicated **Blue refinance**
31
141
  section below for that method's larger shape change.
32
142
 
33
- ## Update pure action builder inputs and metadata
143
+ ## Vault V1 and V2 withdrawals
144
+
145
+ The established `withdraw` methods and the `vaultV1Withdraw` / `vaultV2Withdraw` builder names stay
146
+ stable, but now encode one direct VaultBundlesV1 call instead of a direct vault call.
147
+
148
+ > **Chain availability.** Both entity `withdraw()` methods require `bundles.vaultBundlesV1` and
149
+ > throw `UnknownAddressError` synchronously at handle creation on registered chains without it,
150
+ > including Fraxtal. Stay on v5 if your application needs withdrawals on an affected chain until
151
+ > VaultBundlesV1 is deployed and registered in the SDK, even if your application makes no deposits.
152
+
153
+ | Flow | v5 input | v6 input |
154
+ | --- | --- | --- |
155
+ | `withdraw` | `amount`, `userAddress` | Keep `amount` and `userAddress`; remove the implicit `recipient` / `onBehalf` (VaultBundlesV1 burns `msg.sender`'s shares and pays `msg.sender`); add optional `slippageTolerance`, `deadline`, and referral-fee fields. |
156
+
157
+ `withdraw` now returns `{ buildTx, getRequirements }` instead of `{ buildTx }`. VaultBundlesV1 spends
158
+ the caller's vault shares, so the withdrawal needs a vault-share allowance for VaultBundlesV1 — a
159
+ prerequisite v5 withdrawals did not have. Await `getRequirements()` and satisfy it before calling
160
+ `buildTx()`, or the withdrawal reverts:
161
+
162
+ - Without signature support, it returns one ERC-20 approval transaction to send first.
163
+ - With `supportSignature: true`, it returns one signable ERC-2612 shares permit; pass the signature
164
+ to `buildTx([sharesPermit])` and it is folded into the VaultBundlesV1 call.
165
+
166
+ The allowance is the only cap on the burn, since asset-mode calldata carries no maximum-shares
167
+ argument. `getRequirements()` therefore derives an exact cap from the vault snapshot, the deadline,
168
+ and `slippageTolerance` (default 0.03%), and returns an approval or permit for exactly that amount
169
+ whenever the current allowance differs — including when a larger leftover approval already exists.
170
+
171
+ `getRequirements()` re-validates the deadline on every call, so a prepared withdrawal reused after
172
+ its deadline throws `ExpiredDeadlineError` rather than returning cached prerequisites.
173
+
174
+ ## Blue pure action builder inputs and metadata
34
175
 
35
176
  Direct action consumers keep the root-barrel builder and parameter-type names, but must replace
36
177
  their `args` objects as follows. `metadata` is unchanged.
@@ -96,7 +237,8 @@ The destinations are different:
96
237
 
97
238
  - Classic ERC-20 approvals and ERC-2612 permits now authorize BlueBundlesV1.
98
239
  - Permit2 keeps its ERC-20 approval on canonical Permit2, but the SignatureTransfer payload names
99
- BlueBundlesV1 as spender. Explicit Permit2 nonces are now required — see the subsection below.
240
+ BlueBundlesV1 as spender. The SDK resolves the lowest unused Permit2 nonce by default — see the
241
+ subsection below.
100
242
  - Morpho authorization now grants BlueBundlesV1 operator rights instead of GeneralAdapter1.
101
243
  - Without signature support, saturated full-repay requirements use the token's reusable maximum
102
244
  allowance so a later bounded debt quote remains covered; BlueBundlesV1 still refunds unused
@@ -108,23 +250,59 @@ Update simulations and analytics for the v6 action-field changes. Do not assert
108
250
  Bundler3/GeneralAdapter1 destinations or inspect Bundler3 sub-actions for these
109
251
  high-level writes.
110
252
 
111
- ### Permit2 SignatureTransfer requires an explicit nonce
253
+ ### Permit2 SignatureTransfer resolves the nonce automatically
112
254
 
113
- SignatureTransfer consumes an owner-global unordered nonce rather than an allowance, so the SDK no
114
- longer allocates one implicitly. For a client with `supportSignature: true`, the default supply
115
- requirement path selects Permit2 and `supply(...).getRequirements()` now throws
116
- `MissingPermit2TransferFromNonceError` when no nonce is supplied. Pass an unused nonce explicitly:
255
+ SignatureTransfer consumes an owner-global unordered nonce rather than an allowance. For a client
256
+ with `supportSignature: true`, the default supply requirement path selects Permit2 and
257
+ `supply(...).getRequirements()` resolves the lowest unused nonce for `userAddress` automatically — no
258
+ nonce argument is required:
117
259
 
118
260
  ```ts
119
261
  const requirements = await market
120
262
  .supply({ userAddress, assets, deadline })
121
- .getRequirements({ permit2Nonce });
263
+ .getRequirements();
122
264
  ```
123
265
 
124
- Allocate any `uint256` whose Permit2 `nonceBitmap` bit is still unset for `userAddress` (each nonce
125
- is single-use; a consumed one throws `Permit2TransferFromNonceAlreadyUsedError`). To skip Permit2
126
- for ERC-2612 tokens, pass `getRequirements({ useSimplePermit: true })`, which prefers a one-signature
127
- ERC-2612 permit and needs no nonce.
266
+ Pass `getRequirements({ permit2Nonce })` to pin an explicit `uint256` whose Permit2 `nonceBitmap` bit
267
+ is still unset for `userAddress` (each nonce is single-use; a consumed one throws
268
+ `Permit2SignatureTransferNonceAlreadyUsedError`). An owner whose every nonce at or after the scan
269
+ start is consumed throws `NoUnusedPermit2NonceError`. To skip Permit2 for ERC-2612 tokens, pass
270
+ `getRequirements({ useSimplePermit: true })`, which prefers a one-signature ERC-2612 permit and needs
271
+ no nonce.
272
+
273
+ ### Signature requirements expose `action.typedData`; low-level encoders take `owner`
274
+
275
+ Every signable requirement action (`PermitAction`, `Permit2Action`,
276
+ `Permit2SignatureTransferAction`, `AuthorizationAction`, `MidnightOfferRootSignatureAction`) now
277
+ carries the deep-frozen EIP-712 payload that `sign()` signs, so it can be inspected or displayed
278
+ before signing:
279
+
280
+ ```ts
281
+ const requirement = (await output.getRequirements()).find(isRequirementSignature);
282
+ if (requirement == null) return; // nothing to sign (only on-chain approvals, or none)
283
+
284
+ const typedData = requirement.action.typedData; // exact EIP-712 payload `sign()` will sign
285
+ const signed = await requirement.sign(walletClient, owner);
286
+ const tx = output.buildTx([signed]); // Midnight outputs take the single signature instead
287
+ ```
288
+
289
+ `requirement.action.typedData` is typed as required on a `Requirement`, so no null check is needed.
290
+ It is the exact `TypedDataDefinition` that `sign()` signs; signing itself still goes through
291
+ `Requirement.sign(client, userAddress)`.
292
+
293
+ Because the permit and authorization payloads embed the owner and are built eagerly, two exported
294
+ low-level encoders take a new required `owner` parameter, and `getGeneralAdapterRequirementsPermit`
295
+ forwards it. Their `sign(client, userAddress)` rejects a `userAddress` different from `owner` with
296
+ `AddressMismatchError`.
297
+
298
+ | v5 call | v6 call |
299
+ | --- | --- |
300
+ | `encodeErc20Permit(client, { token, spender, amount, chainId, nonce })` | `encodeErc20Permit(client, { token, owner, spender, amount, chainId, nonce })` |
301
+ | `encodeBlueSignatureAuthorization(client, { authorized, isAuthorized, chainId, nonce })` | `encodeBlueSignatureAuthorization(client, { owner, authorized, isAuthorized, chainId, nonce })` |
302
+ | `getGeneralAdapterRequirementsPermit(client, { token, chainId, args, nonce })` | `getGeneralAdapterRequirementsPermit(client, { token, owner, chainId, args, nonce })` |
303
+
304
+ High-level entity flows (`client.morpho.blue(...)`, vault deposits, Midnight) already supply the
305
+ owner and need no changes.
128
306
 
129
307
  ## Blue refinance
130
308
 
@@ -191,11 +369,147 @@ The `BlueReallocationPlan` union is removed. High-level Blue write inputs accept
191
369
  `Iterable<VaultV2BlueReallocation>` directly; for explicit low-level Vault V1 composition, use
192
370
  `VaultV1Reallocation[]`.
193
371
 
372
+ ## Vault V2 `forceWithdraw`
373
+
374
+ `MorphoVaultV2.forceWithdraw` and the pure `vaultV2ForceWithdraw` action now route through the
375
+ standalone `VaultExitBundlesV1` periphery instead of a `VaultV2.multicall` of caller-supplied
376
+ `forceDeallocate` calls. The contract computes its own deallocations and bounds the realized exit
377
+ share price. `forceRedeem` is unchanged and stays on the vault multicall.
378
+
379
+ | Was (v5) | Now (v6) |
380
+ | --- | --- |
381
+ | `forceWithdraw({ deallocations, withdraw: { amount }, userAddress })` | `forceWithdraw({ exitAssets, vaultData, userAddress, adapter?, deadline?, slippageTolerance?, minSharePriceE27?, referralFeePct?, referralFeeRecipient? })` |
382
+ | Returns `{ buildTx }` | Returns an `ActionOutput` — `{ getRequirements(), buildTx(signatures?) }` (`buildTx` stays synchronous) |
383
+ | `withdraw.amount` was the net payout | `exitAssets` is **penalty-inclusive**; quote the split with the new `previewVaultV2ForceWithdraw` |
384
+ | `tx.to` is the vault | `tx.to` is `VaultExitBundlesV1` |
385
+ | No approval needed (the vault burned `msg.sender`'s own shares) | A vault-share allowance or ERC-2612 permit **to `VaultExitBundlesV1`** is now required |
386
+
387
+ ### Pure action
388
+
389
+ The pure action's call shape changes alongside the entity method:
390
+
391
+ ```ts
392
+ // v5
393
+ vaultV2ForceWithdraw({
394
+ vault: { address: vaultAddress },
395
+ args: {
396
+ deallocations: [{ adapter, marketParams, amount: 500_000n }],
397
+ withdraw: { amount: 500_000n, recipient },
398
+ onBehalf,
399
+ },
400
+ });
401
+
402
+ // v6
403
+ vaultV2ForceWithdraw({
404
+ vault: { chainId, address: vaultAddress },
405
+ args: {
406
+ adapter,
407
+ exitAssets: 500_000n,
408
+ minSharePriceE27,
409
+ userAddress,
410
+ deadline,
411
+ },
412
+ });
413
+ ```
414
+
415
+ `chainId` is now required so the action can resolve the registered periphery address and apply
416
+ `chainId` validation.
417
+
418
+ Migration steps:
419
+
420
+ - Fetch a `vaultData` snapshot (`vault.getData()`) and pass it in. The vault must have exactly one
421
+ `MorphoMarketV1AdapterV2` and route liquidity through that same adapter or none; multi-adapter and
422
+ legacy-adapter vaults must use `forceRedeem` or a plain `withdraw`.
423
+ - Convert your net-payout amount to a penalty-inclusive `exitAssets` and drop the caller-supplied
424
+ `deallocations` and market ordering — the contract derives them.
425
+ - Resolve `getRequirements()` before `buildTx()` to obtain the new vault-share approval or permit to
426
+ `VaultExitBundlesV1`, and make sure the vault's `receiveAssetsGate` allows that periphery.
427
+ - Update `VaultV2ForceWithdrawAction` decoding: `deallocations` and `withdraw` are gone; `adapter`,
428
+ `exitAssets`, `minSharePriceE27`, `referralFeePct`, `referralFeeRecipient`, and `deadline` are new.
429
+ - Stop batching exits: only one VaultExitBundlesV1 call can execute per transaction, because its
430
+ `initiator` guard is transient and never cleared.
431
+ - `InKindRedeemRequiresSingleAdapterError` and `UnsupportedInKindAdapterError` are deprecated aliases
432
+ of `VaultV2SingleAdapterRequiredError` and `VaultV2UnsupportedExitAdapterError`; `instanceof` keeps
433
+ working for both names.
434
+
435
+ See the [`TIB-2026-08-28-vault-exit-force-withdraw`](https://github.com/morpho-org/sdks/blob/main/docs/tibs/TIB-2026-08-28-vault-exit-force-withdraw.md)
436
+ decision record for the full rationale.
437
+
438
+ ## Update Vault V1 and Vault V2 writes
439
+
440
+ Vault V1 and Vault V2 keep their existing `deposit`, `withdraw`, and `redeem` names, while Vault V1
441
+ keeps `migrateToV2`. In v6 these methods encode one direct `VaultBundlesV1` call instead of a direct
442
+ ERC-4626 call or Bundler3 multicall.
443
+
444
+ - Deposits accept exactly one of `amount` and `nativeAmount`. Split a former additive ETH + WETH
445
+ deposit into two transactions. Classic approvals and ERC-2612 permits now authorize
446
+ VaultBundlesV1; Permit2 uses SignatureTransfer with a nonce the SDK resolves by default (pass
447
+ `permit2Nonce` to override).
448
+ - Remove `recipient` from deposits and remove `recipient` and `onBehalf` from exits. VaultBundlesV1
449
+ always operates for and pays `msg.sender`. `userAddress` now means the account that must submit the
450
+ transaction. A connected builder account may prepare a transaction for a different submitter;
451
+ identity-bound signature helpers still enforce `userAddress` when signing.
452
+ - `withdraw` and `redeem` now return a full `ActionOutput`. Call `getRequirements()` and satisfy the
453
+ exact vault-share approval or ERC-2612 permit before calling `buildTx(signatures)`.
454
+ - Vault calls gain `deadline`, `referralFeePct`, and `referralFeeRecipient`. Entity deadlines default
455
+ to two hours; pure builder callers provide them explicitly. Amounts remain gross, and fixed-asset
456
+ action metadata reports `referralFeeAssets` and `netAssets`.
457
+ - `migrateToV2` accepts exactly one of `assets` and `shares`, removes `recipient` and source
458
+ `minSharePriceVaultV1`, and retains only the destination `maxSharePriceVaultV2` bound.
459
+
460
+ VaultBundlesV1 permits only one call to itself in a transaction. Do not put two vault calls into one
461
+ Safe multisend or EIP-5792 batch; use `migrateToV2` for an atomic V1-to-V2 move. Permissioned Vault
462
+ V2 deployments must allow VaultBundlesV1 in both send-assets and receive-assets gates. Because gates
463
+ can inspect the bundle's transient initiator, validate them by simulating the finalized transaction
464
+ after satisfying requirements rather than by pre-reading the gate.
465
+
466
+ ```ts
467
+ const withdrawal = vault.withdraw({ amount, userAddress });
468
+ const signatures = [];
469
+ for (const requirement of await withdrawal.getRequirements()) {
470
+ if ("sign" in requirement) {
471
+ signatures.push(await requirement.sign(walletClient, userAddress));
472
+ } else {
473
+ const hash = await walletClient.sendTransaction(requirement);
474
+ await publicClient.waitForTransactionReceipt({ hash });
475
+ }
476
+ }
477
+ const transaction = withdrawal.buildTx(signatures);
478
+ ```
479
+
194
480
  ## Upgrade checklist
195
481
 
482
+ - Confirm `bundles.vaultBundlesV1` coverage for vault deposits and withdrawals and
483
+ `bundles.blueBundlesV1` coverage for Blue writes on every chain your application supports.
484
+ Stay on v5 if you need vault deposits or withdrawals on a chain without VaultBundlesV1.
196
485
  - Update every Blue write call using the table above; method names remain stable.
197
486
  - Remove Blue slippage and PublicAllocator V1 write inputs.
198
487
  - Re-run approval and Morpho-authorization setup against the new spender/operator.
199
- - Update transaction decoding, simulation fixtures, and action metadata fields; discriminator
200
- names remain stable.
488
+ - Update transaction decoding, simulation fixtures, and action metadata fields; the `type`
489
+ discriminators remain stable, including `"vaultV2ForceWithdraw"`.
201
490
  - Test native funding, full repay, and full-position migration paths used by the application.
491
+ - Migrate Vault V2 `forceWithdraw` to the penalty-inclusive `exitAssets` + `vaultData` shape,
492
+ resolve its new `getRequirements()`, and authorize vault shares to `VaultExitBundlesV1`.
493
+ - Test the multi-adapter and legacy-adapter `forceWithdraw` fallbacks (`forceRedeem` / plain
494
+ `withdraw`) used by the application.
495
+
496
+ ## Fixed-bundles token requirement APIs
497
+
498
+ The Blue-only fixed-bundles requirement surface is generalized into a shared surface used by both
499
+ BlueBundlesV1 and VaultBundlesV1.
500
+
501
+ | v5 symbol | v6 replacement |
502
+ | --- | --- |
503
+ | `getBlueBundlesV1TokenRequirements` (action-layer) | `getBundlesTokenRequirements` (entity-layer; reads state, so it now lives under `entities/requirements` instead of `actions/requirements/blue`). Takes the same funding parameters plus a `spender` naming the registered fixed bundles deployment (BlueBundlesV1 or VaultBundlesV1). |
504
+ | `BlueBundlesV1TokenSignatureRequirement` / `BlueBundlesV1TokenRequirementSignature` | `BundlesTokenSignatureRequirement` / `BundlesTokenRequirementSignature` |
505
+ | `encodeErc20Permit2TransferFrom` | `encodeErc20Permit2SignatureTransfer` |
506
+ | Action discriminator `"permit2TransferFrom"` | `"permit2SignatureTransfer"` |
507
+ | `Permit2TransferFromAction` / `Permit2TransferFromRequirementSignature` | `Permit2SignatureTransferAction` / `Permit2SignatureTransferRequirementSignature` |
508
+ | `isPermit2TransferFromSignature` | `isPermit2SignatureTransferSignature` |
509
+ | `selectRequirementSignatures` option and result field `permit2TransferFrom` | `permit2SignatureTransfer` |
510
+ | `MissingPermit2TransferFromNonceError` | Removed — the nonce is resolved automatically; catch `NoUnusedPermit2NonceError` only if every nonce is consumed |
511
+ | `Permit2TransferFromNonceAlreadyUsedError` | `Permit2SignatureTransferNonceAlreadyUsedError` (old name kept as a `@deprecated` alias) |
512
+
513
+ Update call sites and `switch`/discriminated-union checks on `action.type` to the new
514
+ `"permit2SignatureTransfer"` tag; the signed payload shape (`nonce`, `deadline`, `signature`) is
515
+ unchanged.
package/README.md CHANGED
@@ -7,7 +7,13 @@
7
7
 
8
8
  > 📖 **Full documentation → [docs.morpho.org/developers/sdks/morpho-sdk](https://docs.morpho.org/developers/sdks/morpho-sdk/)**
9
9
 
10
- Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**, and **Midnight** fixed-rate markets on every chain where Morpho is deployed. Custom deployments can be added with `registerCustomAddresses` from `@morpho-org/morpho-sdk/addresses`.
10
+ Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**, and **Midnight** fixed-rate markets on chains with the required protocol and periphery deployments. Custom deployments can be added with `registerCustomAddresses` from `@morpho-org/morpho-sdk/addresses`.
11
+
12
+ ## Deprecated flows
13
+
14
+ All Vault V1 PublicAllocator surfaces are deprecated, including raw ABIs, addresses, configs, fetchers, planning APIs, and Bundler3 composition. Use Vault V2 BluePublicAllocator APIs: `getVaultV2BlueReallocationData()` fetches the state and `getVaultV2BlueReallocations()` prepares a plan for a Blue action.
15
+
16
+ The legacy `morphoToken` address and MORPHO wrapping entries in `ethereumGeneralAdapter1Abi` are also deprecated. Use the current MORPHO token directly. Deprecated APIs remain available until the next major release; general Vault V1 operations and other token wrapping flows remain supported.
11
17
 
12
18
  ## Installation
13
19
 
@@ -15,22 +21,21 @@ Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**,
15
21
  pnpm add @morpho-org/morpho-sdk
16
22
  ```
17
23
 
18
- Upgrading from v5? Read the [v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating Blue
19
- write integrations.
24
+ Upgrading from v5? Read the [v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating vault
25
+ deposit or Blue write integrations.
20
26
 
21
27
  ## Actions
22
28
 
23
- Each entity exposes a set of actions. Vault deposits route through Bundler3 via `GeneralAdapter1`;
24
- Blue writes call BlueBundlesV1 directly; the remaining rows identify their direct destination.
29
+ Each entity exposes a set of actions. Common vault writes call VaultBundlesV1, Blue writes call
30
+ BlueBundlesV1, and the remaining rows identify their destination.
25
31
 
26
32
  | Entity | Actions | Route |
27
33
  | --- | --- | --- |
28
- | **VaultV1** (MetaMorpho) | `deposit`, `migrateToV2` | Bundler3 → GeneralAdapter1 |
29
- | | `withdraw`, `redeem` | Direct call |
34
+ | **VaultV1** (MetaMorpho) | `deposit`, `withdraw`, `redeem`, `migrateToV2` | VaultBundlesV1 |
30
35
  | | `inKindRedeem` | VaultExitBundlesV1 |
31
- | **VaultV2** | `deposit` | Bundler3 → GeneralAdapter1 |
32
- | | `withdraw`, `redeem` | Direct call |
33
- | | `forceWithdraw`, `forceRedeem` | Vault multicall |
36
+ | **VaultV2** | `deposit`, `withdraw`, `redeem` | VaultBundlesV1 |
37
+ | | `forceWithdraw` | VaultExitBundlesV1 |
38
+ | | `forceRedeem` | Vault multicall |
34
39
  | | `inKindRedeem` | VaultExitBundlesV1 |
35
40
  | **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
36
41
  | **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `repayWithdrawCollateral` | Midnight Bundles |
@@ -44,17 +49,20 @@ Robinhood Chain. Custom deployments can still be configured with `registerCustom
44
49
  ## How it works
45
50
 
46
51
  Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`. All Blue
47
- writes use this lazy shape while still encoding one direct BlueBundlesV1 call. Vault
48
- `inKindRedeem` uses this shape so callers can await `getRequirements()` to check live Blue liquidity
49
- and share authorization before invoking `buildTx()`. Calling `buildTx()` directly skips those
50
- RPC-backed pre-flight checks. Other direct calls — vault `withdraw` / `redeem`, `forceWithdraw` /
51
- `forceRedeem` — have no prerequisites and return only `{ buildTx }`.
52
+ writes use this lazy shape while still encoding one direct BlueBundlesV1 call. Vault deposits,
53
+ `withdraw`, and `redeem` use the same shape for token or exact vault-share authorization to
54
+ VaultBundlesV1. Vault `inKindRedeem` and `forceWithdraw` use it so callers can await
55
+ `getRequirements()` to check share authorization to VaultExitBundlesV1 — and, for `inKindRedeem`,
56
+ live Blue liquidity — before invoking `buildTx()`. Calling `buildTx()` directly skips those
57
+ RPC-backed pre-flight checks. `forceRedeem` remains a direct Vault V2 multicall without
58
+ prerequisites.
52
59
 
53
60
  - **`getRequirements()`** — async; the on-chain prerequisites to satisfy first: ERC-20 approvals, permit / Permit2 signatures, Morpho authorization, or (for Midnight) operator authorization and offer-root signatures.
54
61
  - **`buildTx(signatures?)`** — synchronous; the final, deep-frozen viem transaction. Pass any signatures collected from the requirements.
55
62
 
56
63
  ```typescript
57
- const { buildTx, getRequirements } = await vault.deposit({ amount, userAddress });
64
+ const vaultData = await vault.getData();
65
+ const { buildTx, getRequirements } = vault.deposit({ amount, userAddress, vaultData });
58
66
 
59
67
  const requirements = await getRequirements();
60
68
  // Send each approval tx and collect each signature, then:
@@ -63,12 +71,12 @@ const tx = buildTx([permitSignature]);
63
71
 
64
72
  Enable off-chain approvals (permit / Permit2) with `morphoViemExtension({ supportSignature: true })`.
65
73
 
66
- ### `userAddress` must be the signer
74
+ ### `userAddress` is the eventual submitter
67
75
 
68
- `userAddress` must be the account that signs and sends the transaction. Builders don't enforce
69
- this, but the signature helpers do — `sign()` throws `AddressMismatchError` when the wallet's
70
- account differs. BlueBundlesV1 always operates on `msg.sender`, so a Blue transaction must be sent
71
- by that same account.
76
+ `userAddress` must be the account that eventually signs and sends the transaction. A connected
77
+ builder account may prepare a direct bundles call for a different submitter; signature helpers
78
+ enforce the expected identity at `sign()`. VaultBundlesV1 and BlueBundlesV1 always operate on
79
+ `msg.sender`.
72
80
 
73
81
  ## Usage
74
82
 
@@ -101,30 +109,73 @@ Create an entity — every factory takes a chain ID as its last argument:
101
109
 
102
110
  ### Vault deposit / withdraw
103
111
 
104
- Deposit routes through the bundler and may require an approval or permit:
112
+ Deposit calls VaultBundlesV1 and may require an approval or permit. ERC-20 approvals and ERC-2612
113
+ permits authorize VaultBundlesV1. Permit2 SignatureTransfer also names VaultBundlesV1 as spender,
114
+ while the ERC-20 approval prerequisite targets canonical Permit2.
105
115
 
106
116
  ```typescript
107
117
  const vault = client.morpho.vaultV2("0xVault...", 1);
108
-
109
- const { buildTx, getRequirements } = await vault.deposit({
118
+ const vaultData = await vault.getData();
119
+ const { buildTx, getRequirements } = vault.deposit({
110
120
  amount: 1000000000000000000n,
111
121
  userAddress: "0xUser...",
122
+ vaultData,
112
123
  });
113
124
  const requirements = await getRequirements();
114
125
  const tx = buildTx([permitSignature]);
115
126
  ```
116
127
 
117
- Withdraw is a direct vault call with no requirements:
128
+ Withdraw is a VaultBundlesV1 call that burns the caller's shares, so it needs the exact share
129
+ allowance returned by `getRequirements()`:
118
130
 
119
131
  ```typescript
120
- const { buildTx } = vault.withdraw({
121
- amount: 500000000000000000n,
122
- userAddress: "0xUser...",
123
- });
124
- const tx = buildTx();
132
+ import { morphoViemExtension } from "@morpho-org/morpho-sdk";
133
+ import {
134
+ createPublicClient,
135
+ createWalletClient,
136
+ custom,
137
+ http,
138
+ type EIP1193Provider,
139
+ } from "viem";
140
+ import { mainnet } from "viem/chains";
141
+
142
+ async function withdrawUsdc(provider: EIP1193Provider, supportSignature = false) {
143
+ const client = createPublicClient({ chain: mainnet, transport: http() }).extend(
144
+ morphoViemExtension({ supportSignature }),
145
+ );
146
+ const walletClient = createWalletClient({ chain: mainnet, transport: custom(provider) });
147
+ const [userAddress] = await walletClient.requestAddresses();
148
+ if (!userAddress) throw new Error("Connect a wallet account before withdrawing.");
149
+ const vault = client.morpho.vaultV2("0x04422053aDDbc9bB2759b248B574e3FCA76Bc145", mainnet.id);
150
+ const withdrawal = vault.withdraw({ amount: 500_000n, userAddress });
151
+ const requirements = await withdrawal.getRequirements();
152
+ const requirement = requirements[0];
153
+
154
+ if (requirement && "sign" in requirement) {
155
+ // With signature support enabled, sign the vault-share permit for this handle.
156
+ const signedPermit = await requirement.sign(walletClient, userAddress);
157
+ return walletClient.sendTransaction({
158
+ ...withdrawal.buildTx([signedPermit]),
159
+ account: userAddress,
160
+ });
161
+ }
162
+
163
+ for (const approval of requirements) {
164
+ if ("to" in approval) {
165
+ const hash = await walletClient.sendTransaction({ ...approval, account: userAddress });
166
+ const receipt = await client.waitForTransactionReceipt({ hash });
167
+ if (receipt.status !== "success") throw new Error("The share approval reverted.");
168
+ }
169
+ }
170
+ // Approval is confirmed, or the exact allowance was already in place.
171
+ return walletClient.sendTransaction({ ...withdrawal.buildTx(), account: userAddress });
172
+ }
173
+ // await withdrawUsdc(provider) returns the withdrawal transaction hash.
174
+ // Pass true as the second argument to use a signed share permit instead of an approval.
125
175
  ```
126
176
 
127
- For wNative vaults, pass `nativeAmount` instead of `amount` to deposit native ETH (wrapped automatically).
177
+ For wNative vaults, pass `nativeAmount` instead of `amount`. The transaction sends that amount as
178
+ `tx.value` to VaultBundlesV1, which wraps it internally; native deposits require no token permit.
128
179
 
129
180
  ### Blue: BlueBundlesV1 writes
130
181
 
@@ -171,10 +222,6 @@ instant liquidation. Blue writes do not accept `slippageTolerance`, `minSharePri
171
222
  > low-level Bundler3 composition remain available only as deprecated compatibility surfaces and
172
223
  > will be removed in the next major.
173
224
 
174
- > All SDK surfaces for the Vault V1 shared-liquidity algorithm and its PublicAllocator Bundler3
175
- > composition are deprecated and will be removed in the next major. Use Vault V2
176
- > BluePublicAllocator reallocations.
177
-
178
225
  ### Midnight: take a fixed-rate offer
179
226
 
180
227
  Protocol-specific names are qualified in shared facades, for example `fetchBluePosition` and `fetchMidnightPosition` from `@morpho-org/morpho-sdk/fetch`. Raw upstream names remain available under `/blue/{abis,addresses,constants,entities,errors,fetch,types,utils}` and `/midnight/{abis,constants,entities,errors,fetch,types,utils}`.
@@ -219,11 +266,11 @@ graph LR
219
266
  MV1 --> V1IKR[vaultV1InKindRedeem]
220
267
  MV1 --> V1M[vaultV1MigrateToV2]
221
268
 
222
- V1D -->|nativeTransfer + wrapNative + erc4626Deposit| B1[Bundler3]
223
- V1W -->|direct call| MM[MetaMorpho]
224
- V1R -->|direct call| MM
269
+ V1D --> VBV1[VaultBundlesV1]
270
+ V1W --> VBV1
271
+ V1R --> VBV1
272
+ V1M --> VBV1
225
273
  V1IKR -->|direct call| VEB[VaultExitBundlesV1]
226
- V1M -->|erc20TransferFrom + erc4626Redeem + erc4626Deposit| B1
227
274
  end
228
275
 
229
276
  subgraph VaultV2 Flow
@@ -235,12 +282,12 @@ graph LR
235
282
  MV2 --> V2FW[vaultV2ForceWithdraw]
236
283
  MV2 --> V2FR[vaultV2ForceRedeem]
237
284
 
238
- V2D -->|nativeTransfer + wrapNative + erc4626Deposit| B2[Bundler3]
239
- V2W -->|direct call| V2C[VaultV2 Contract]
240
- V2R -->|direct call| V2C
285
+ V2D --> VBV1
286
+ V2W --> VBV1
287
+ V2R --> VBV1
241
288
  V2IKR -->|direct call| VEB
242
- V2FW -->|multicall| V2C
243
- V2FR -->|multicall| V2C
289
+ V2FW -->|direct call| VEB
290
+ V2FR -->|multicall| V2C[VaultV2 Contract]
244
291
  end
245
292
 
246
293
  subgraph Blue Flow
@@ -288,10 +335,9 @@ graph LR
288
335
  MM1 -.->|approval / permit / authorization| REQ
289
336
  MN1 -.->|approval / authorization / root signature or ratification| REQ
290
337
 
291
- style B1 fill:#e8f5e9,stroke:#4caf50
292
- style B2 fill:#e8f5e9,stroke:#4caf50
338
+ style VBV1 fill:#e8f5e9,stroke:#4caf50
293
339
  style BBV1 fill:#e8f5e9,stroke:#4caf50
294
- style MM fill:#fff3e0,stroke:#ff9800
340
+ style VEB fill:#fff3e0,stroke:#ff9800
295
341
  style V2C fill:#e3f2fd,stroke:#2196f3
296
342
  style REQ fill:#f3e5f5,stroke:#9c27b0
297
343
  style BPA fill:#fff9c4,stroke:#f9a825