@morpho-org/morpho-sdk 6.0.0-next.1 → 6.0.0-next.3

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 (305) hide show
  1. package/MIGRATION-v5-to-v6.md +199 -34
  2. package/README.md +23 -15
  3. package/lib/cjs/abis.d.ts +3 -2829
  4. package/lib/cjs/abis.js +1 -1938
  5. package/lib/cjs/actions/blue/borrow.d.ts +3 -2
  6. package/lib/cjs/actions/blue/borrow.js +3 -2
  7. package/lib/cjs/actions/blue/common.js +6 -35
  8. package/lib/cjs/actions/blue/refinance.d.ts +2 -2
  9. package/lib/cjs/actions/blue/refinance.js +2 -2
  10. package/lib/cjs/actions/blue/repay.d.ts +1 -1
  11. package/lib/cjs/actions/blue/repay.js +1 -1
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
  14. package/lib/cjs/actions/blue/supply.d.ts +2 -2
  15. package/lib/cjs/actions/blue/supply.js +4 -9
  16. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
  17. package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
  18. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
  20. package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
  21. package/lib/cjs/actions/blue/withdraw.js +3 -3
  22. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
  23. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  24. package/lib/cjs/actions/bundles/common.d.ts +38 -4
  25. package/lib/cjs/actions/bundles/common.js +91 -35
  26. package/lib/cjs/actions/index.d.ts +0 -1
  27. package/lib/cjs/actions/index.js +0 -1
  28. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +9 -8
  29. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +17 -26
  30. package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
  31. package/lib/cjs/actions/requirements/blue/index.js +0 -1
  32. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +20 -14
  33. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +24 -25
  34. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  35. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
  36. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +21 -12
  37. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -38
  38. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
  39. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
  40. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
  41. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
  42. package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
  43. package/lib/cjs/actions/requirements/encode/index.js +0 -1
  44. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
  45. package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
  46. package/lib/cjs/actions/requirements/index.d.ts +0 -1
  47. package/lib/cjs/actions/requirements/index.js +0 -1
  48. package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
  49. package/lib/cjs/actions/vaultV1/deposit.js +1 -2
  50. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +6 -4
  51. package/lib/cjs/actions/vaultV1/inKindRedeem.js +12 -8
  52. package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
  53. package/lib/cjs/actions/vaultV2/deposit.js +1 -2
  54. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
  55. package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
  56. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +6 -4
  57. package/lib/cjs/actions/vaultV2/inKindRedeem.js +12 -8
  58. package/lib/cjs/augment.d.ts +0 -1
  59. package/lib/cjs/augment.js +0 -1
  60. package/lib/cjs/blue/abis.d.ts +1 -1
  61. package/lib/cjs/blue/abis.js +1 -5
  62. package/lib/cjs/blue/entities.d.ts +2 -2
  63. package/lib/cjs/blue/entities.js +1 -2
  64. package/lib/cjs/blue/errors.d.ts +1 -1
  65. package/lib/cjs/blue/errors.js +2 -1
  66. package/lib/cjs/blue/fetch.d.ts +1 -1
  67. package/lib/cjs/blue/fetch.js +1 -2
  68. package/lib/cjs/blue/types.d.ts +2 -4
  69. package/lib/cjs/blue/utils.d.ts +1 -3
  70. package/lib/cjs/blue/utils.js +1 -3
  71. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  72. package/lib/cjs/client/morphoViemExtension.js +1 -1
  73. package/lib/cjs/constants.d.ts +3 -37
  74. package/lib/cjs/constants.js +1 -39
  75. package/lib/cjs/entities/blue/blue.d.ts +38 -264
  76. package/lib/cjs/entities/blue/blue.js +2 -203
  77. package/lib/cjs/entities/index.d.ts +3 -60
  78. package/lib/cjs/entities/index.js +1 -20
  79. package/lib/cjs/entities/midnight/midnight.js +20 -24
  80. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
  81. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +19 -14
  82. package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
  83. package/lib/cjs/entities/requirements/index.d.ts +1 -0
  84. package/lib/cjs/entities/requirements/index.js +1 -0
  85. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +18 -6
  86. package/lib/cjs/entities/vaultV1/vaultV1.js +25 -8
  87. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +154 -35
  88. package/lib/cjs/entities/vaultV2/vaultV2.js +249 -23
  89. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
  90. package/lib/cjs/entities/vaultV2BlueReallocationData.js +50 -34
  91. package/lib/cjs/errors.d.ts +2 -46
  92. package/lib/cjs/errors.js +2 -46
  93. package/lib/cjs/fetch.d.ts +1 -15
  94. package/lib/cjs/fetch.js +1 -16
  95. package/lib/cjs/helpers/constant.d.ts +0 -2
  96. package/lib/cjs/helpers/constant.js +0 -2
  97. package/lib/cjs/helpers/index.d.ts +4 -3
  98. package/lib/cjs/helpers/index.js +10 -9
  99. package/lib/cjs/helpers/metadata.d.ts +3 -5
  100. package/lib/cjs/helpers/metadata.js +4 -6
  101. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  102. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
  103. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  104. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
  105. package/lib/cjs/helpers/slippage.d.ts +34 -90
  106. package/lib/cjs/helpers/slippage.js +52 -137
  107. package/lib/cjs/helpers/utilization.d.ts +12 -10
  108. package/lib/cjs/helpers/utilization.js +27 -12
  109. package/lib/cjs/helpers/validate.d.ts +66 -32
  110. package/lib/cjs/helpers/validate.js +84 -57
  111. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  112. package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
  113. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  114. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
  115. package/lib/cjs/types/action.d.ts +102 -68
  116. package/lib/cjs/types/action.js +11 -4
  117. package/lib/cjs/types/error.d.ts +332 -385
  118. package/lib/cjs/types/error.js +369 -412
  119. package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
  120. package/lib/cjs/types.d.ts +2 -18
  121. package/lib/cjs/utils.d.ts +8 -35
  122. package/lib/cjs/utils.js +11 -36
  123. package/lib/esm/abis.d.ts +3 -2829
  124. package/lib/esm/abis.js +3 -1935
  125. package/lib/esm/actions/blue/borrow.d.ts +3 -2
  126. package/lib/esm/actions/blue/borrow.js +3 -2
  127. package/lib/esm/actions/blue/common.js +8 -37
  128. package/lib/esm/actions/blue/refinance.d.ts +2 -2
  129. package/lib/esm/actions/blue/refinance.js +2 -2
  130. package/lib/esm/actions/blue/repay.d.ts +1 -1
  131. package/lib/esm/actions/blue/repay.js +1 -1
  132. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
  133. package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
  134. package/lib/esm/actions/blue/supply.d.ts +2 -2
  135. package/lib/esm/actions/blue/supply.js +6 -11
  136. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
  137. package/lib/esm/actions/blue/supplyCollateral.js +2 -2
  138. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
  139. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
  140. package/lib/esm/actions/blue/withdraw.d.ts +3 -3
  141. package/lib/esm/actions/blue/withdraw.js +3 -3
  142. package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
  143. package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
  144. package/lib/esm/actions/bundles/common.d.ts +38 -4
  145. package/lib/esm/actions/bundles/common.js +91 -36
  146. package/lib/esm/actions/index.d.ts +0 -1
  147. package/lib/esm/actions/index.js +0 -1
  148. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +9 -8
  149. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +20 -29
  150. package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
  151. package/lib/esm/actions/requirements/blue/index.js +0 -1
  152. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +20 -14
  153. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +25 -26
  154. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
  155. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
  156. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +21 -12
  157. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -39
  158. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
  159. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
  160. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
  161. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
  162. package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
  163. package/lib/esm/actions/requirements/encode/index.js +0 -1
  164. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
  165. package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
  166. package/lib/esm/actions/requirements/index.d.ts +0 -1
  167. package/lib/esm/actions/requirements/index.js +0 -1
  168. package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
  169. package/lib/esm/actions/vaultV1/deposit.js +1 -2
  170. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +6 -4
  171. package/lib/esm/actions/vaultV1/inKindRedeem.js +12 -8
  172. package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
  173. package/lib/esm/actions/vaultV2/deposit.js +1 -2
  174. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
  175. package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
  176. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +6 -4
  177. package/lib/esm/actions/vaultV2/inKindRedeem.js +12 -8
  178. package/lib/esm/augment.d.ts +0 -1
  179. package/lib/esm/augment.js +0 -1
  180. package/lib/esm/blue/abis.d.ts +1 -1
  181. package/lib/esm/blue/abis.js +1 -1
  182. package/lib/esm/blue/entities.d.ts +2 -2
  183. package/lib/esm/blue/entities.js +1 -1
  184. package/lib/esm/blue/errors.d.ts +1 -1
  185. package/lib/esm/blue/errors.js +1 -1
  186. package/lib/esm/blue/fetch.d.ts +1 -1
  187. package/lib/esm/blue/fetch.js +1 -1
  188. package/lib/esm/blue/types.d.ts +2 -4
  189. package/lib/esm/blue/utils.d.ts +1 -3
  190. package/lib/esm/blue/utils.js +1 -3
  191. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  192. package/lib/esm/client/morphoViemExtension.js +1 -1
  193. package/lib/esm/constants.d.ts +3 -37
  194. package/lib/esm/constants.js +3 -37
  195. package/lib/esm/entities/blue/blue.d.ts +38 -264
  196. package/lib/esm/entities/blue/blue.js +5 -206
  197. package/lib/esm/entities/index.d.ts +3 -60
  198. package/lib/esm/entities/index.js +1 -16
  199. package/lib/esm/entities/midnight/midnight.js +20 -24
  200. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
  201. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +20 -15
  202. package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
  203. package/lib/esm/entities/requirements/index.d.ts +1 -0
  204. package/lib/esm/entities/requirements/index.js +1 -0
  205. package/lib/esm/entities/vaultV1/vaultV1.d.ts +18 -6
  206. package/lib/esm/entities/vaultV1/vaultV1.js +29 -12
  207. package/lib/esm/entities/vaultV2/vaultV2.d.ts +154 -35
  208. package/lib/esm/entities/vaultV2/vaultV2.js +256 -30
  209. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
  210. package/lib/esm/entities/vaultV2BlueReallocationData.js +48 -32
  211. package/lib/esm/errors.d.ts +2 -46
  212. package/lib/esm/errors.js +2 -46
  213. package/lib/esm/fetch.d.ts +1 -15
  214. package/lib/esm/fetch.js +1 -15
  215. package/lib/esm/helpers/constant.d.ts +0 -2
  216. package/lib/esm/helpers/constant.js +0 -2
  217. package/lib/esm/helpers/index.d.ts +4 -3
  218. package/lib/esm/helpers/index.js +4 -3
  219. package/lib/esm/helpers/metadata.d.ts +3 -5
  220. package/lib/esm/helpers/metadata.js +4 -6
  221. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  222. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
  223. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  224. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
  225. package/lib/esm/helpers/slippage.d.ts +34 -90
  226. package/lib/esm/helpers/slippage.js +52 -134
  227. package/lib/esm/helpers/utilization.d.ts +12 -10
  228. package/lib/esm/helpers/utilization.js +26 -11
  229. package/lib/esm/helpers/validate.d.ts +66 -32
  230. package/lib/esm/helpers/validate.js +83 -57
  231. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  232. package/lib/esm/helpers/validateRequirementSpender.js +1 -3
  233. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  234. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
  235. package/lib/esm/types/action.d.ts +102 -68
  236. package/lib/esm/types/action.js +12 -5
  237. package/lib/esm/types/error.d.ts +332 -385
  238. package/lib/esm/types/error.js +355 -392
  239. package/lib/esm/types/sharedLiquidity.d.ts +1 -117
  240. package/lib/esm/types.d.ts +2 -18
  241. package/lib/esm/utils.d.ts +8 -35
  242. package/lib/esm/utils.js +7 -34
  243. package/package.json +7 -15
  244. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -42
  245. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -83
  246. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  247. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -151
  248. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -37
  249. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -50
  250. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  251. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
  252. package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
  253. package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
  254. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  255. package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
  256. package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  257. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
  258. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -44
  259. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -43
  260. package/lib/cjs/actions/signatures/index.d.ts +0 -3
  261. package/lib/cjs/actions/signatures/index.js +0 -19
  262. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -8
  263. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
  264. package/lib/cjs/bundler/actions.d.ts +0 -797
  265. package/lib/cjs/bundler/actions.js +0 -1371
  266. package/lib/cjs/bundler/index.d.ts +0 -2
  267. package/lib/cjs/bundler/index.js +0 -18
  268. package/lib/cjs/bundler/types.d.ts +0 -235
  269. package/lib/cjs/bundler/types.js +0 -2
  270. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -326
  271. package/lib/cjs/entities/vaultV1ReallocationData.js +0 -542
  272. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -78
  273. package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -243
  274. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -42
  275. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -79
  276. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
  277. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -147
  278. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -37
  279. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -46
  280. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
  281. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
  282. package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
  283. package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
  284. package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
  285. package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
  286. package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
  287. package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
  288. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -44
  289. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -39
  290. package/lib/esm/actions/signatures/index.d.ts +0 -3
  291. package/lib/esm/actions/signatures/index.js +0 -3
  292. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -8
  293. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -5
  294. package/lib/esm/bundler/actions.d.ts +0 -797
  295. package/lib/esm/bundler/actions.js +0 -1368
  296. package/lib/esm/bundler/index.d.ts +0 -2
  297. package/lib/esm/bundler/index.js +0 -2
  298. package/lib/esm/bundler/types.d.ts +0 -235
  299. package/lib/esm/bundler/types.js +0 -1
  300. package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -326
  301. package/lib/esm/entities/vaultV1ReallocationData.js +0 -544
  302. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -78
  303. package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -239
  304. /package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
  305. /package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
@@ -1,9 +1,11 @@
1
1
  import type { Address } from "@morpho-org/blue-sdk";
2
- import { type Client } from "viem";
2
+ import type { Client } from "viem";
3
3
  import { type Erc2612RequirementSignature, type Requirement } from "../../../types/index.js";
4
4
  /** Parameters for {@link encodeErc20Permit}. */
5
5
  interface EncodeErc20PermitParams {
6
6
  token: Address;
7
+ /** Account that owns the tokens and signs the permit. */
8
+ owner: Address;
7
9
  spender: Address;
8
10
  amount: bigint;
9
11
  chainId: number;
@@ -17,30 +19,34 @@ interface EncodeErc20PermitParams {
17
19
  *
18
20
  * Reads token metadata via `fetchToken`. The returned `Requirement.sign()` produces the EIP-712
19
21
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
20
- * the selected transaction route can consume. Deadline defaults to two hours from
21
- * `Time.timestamp()`.
22
+ * the selected transaction route can consume. The requirement's `action.typedData` holds that
23
+ * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
24
+ * hours from `Time.timestamp()`.
22
25
  *
23
26
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
24
27
  * @param params - Permit encoding parameters.
25
28
  * @param params.token - ERC-20 token address (must support EIP-2612).
26
- * @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
27
- * VaultBundlesV1, or BlueBundlesV1 for the chain.
29
+ * @param params.owner - Account that owns the tokens and signs the permit.
30
+ * @param params.spender - Permit spender. Must be MidnightBundles, VaultBundlesV1, or
31
+ * BlueBundlesV1 for the chain.
28
32
  * @param params.amount - Permit allowance amount.
29
33
  * @param params.chainId - Target chain id.
30
- * @param params.nonce - The user's current EIP-2612 nonce on `token`.
34
+ * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
31
35
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
32
36
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
33
- * @returns A `Requirement` whose `sign(client, userAddress)` produces the deep-frozen signature.
37
+ * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
38
+ * `sign(client, userAddress)` produces the deep-frozen signature.
34
39
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
35
40
  * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
36
- * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not GeneralAdapter1,
37
- * MidnightBundles, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
41
+ * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not MidnightBundles,
42
+ * VaultBundlesV1, or BlueBundlesV1 for `chainId`.
38
43
  * @throws {NonPositiveInputError} when an explicit `deadline` is not positive.
39
44
  * @throws {InputExceedsMaxError} when an explicit `deadline` exceeds `uint256`.
40
45
  * @throws {ExpiredDeadlineError} when an explicit `deadline` is positive but not in the future.
41
46
  * @throws {viem.BaseError} when the token metadata read fails with no fallback left.
42
47
  * @throws {MissingClientPropertyError} from `sign()` when the client has no `account.address`.
43
- * @throws {AddressMismatchError} from `sign()` when the client account differs from `userAddress`.
48
+ * @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
49
+ * client account differs from `userAddress`.
44
50
  * @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
45
51
  * @example
46
52
  * ```ts
@@ -51,12 +57,15 @@ interface EncodeErc20PermitParams {
51
57
  * const client = createWalletClient({ chain: mainnet, transport: http() });
52
58
  * const requirement = await encodeErc20Permit(client, {
53
59
  * token: USDC, // Must implement standard ERC-2612. DAI is routed through Permit2 by requirement helpers.
54
- * spender: generalAdapter1,
60
+ * owner,
61
+ * spender: blueBundlesV1,
55
62
  * amount: 1_000_000n,
56
63
  * chainId: 1,
57
64
  * nonce: 0n,
58
65
  * });
59
- * // requirement satisfies Requirement
66
+ * // Inspect the EIP-712 payload, then sign via the requirement:
67
+ * const typedData = requirement.action.typedData;
68
+ * const signed = await requirement.sign(client, owner);
60
69
  * ```
61
70
  */
62
71
  export declare const encodeErc20Permit: (viemClient: Client, params: EncodeErc20PermitParams) => Promise<Requirement<Erc2612RequirementSignature>>;
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.encodeErc20Permit = void 0;
4
4
  const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
5
5
  const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
- const viem_1 = require("viem");
7
6
  const signAndVerifyTypedData_js_1 = require("../../../helpers/signAndVerifyTypedData.js");
7
+ const validate_js_1 = require("../../../helpers/validate.js");
8
8
  const validateRequirementSpender_js_1 = require("../../../helpers/validateRequirementSpender.js");
9
9
  const index_js_1 = require("../../../types/index.js");
10
10
  /**
@@ -13,30 +13,34 @@ const index_js_1 = require("../../../types/index.js");
13
13
  *
14
14
  * Reads token metadata via `fetchToken`. The returned `Requirement.sign()` produces the EIP-712
15
15
  * signature, verifies it against the connected account, and returns a `RequirementSignature`
16
- * the selected transaction route can consume. Deadline defaults to two hours from
17
- * `Time.timestamp()`.
16
+ * the selected transaction route can consume. The requirement's `action.typedData` holds that
17
+ * EIP-712 payload so it can be inspected or displayed before signing. Deadline defaults to two
18
+ * hours from `Time.timestamp()`.
18
19
  *
19
20
  * @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
20
21
  * @param params - Permit encoding parameters.
21
22
  * @param params.token - ERC-20 token address (must support EIP-2612).
22
- * @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
23
- * VaultBundlesV1, or BlueBundlesV1 for the chain.
23
+ * @param params.owner - Account that owns the tokens and signs the permit.
24
+ * @param params.spender - Permit spender. Must be MidnightBundles, VaultBundlesV1, or
25
+ * BlueBundlesV1 for the chain.
24
26
  * @param params.amount - Permit allowance amount.
25
27
  * @param params.chainId - Target chain id.
26
- * @param params.nonce - The user's current EIP-2612 nonce on `token`.
28
+ * @param params.nonce - The owner's current EIP-2612 nonce on `token`.
27
29
  * @param params.supportDeployless - Whether `fetchToken` should use deployless multicall.
28
30
  * @param params.deadline - Signature expiration timestamp. Defaults to two hours from now.
29
- * @returns A `Requirement` whose `sign(client, userAddress)` produces the deep-frozen signature.
31
+ * @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
32
+ * `sign(client, userAddress)` produces the deep-frozen signature.
30
33
  * @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
31
34
  * @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
32
- * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not GeneralAdapter1,
33
- * MidnightBundles, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
35
+ * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not MidnightBundles,
36
+ * VaultBundlesV1, or BlueBundlesV1 for `chainId`.
34
37
  * @throws {NonPositiveInputError} when an explicit `deadline` is not positive.
35
38
  * @throws {InputExceedsMaxError} when an explicit `deadline` exceeds `uint256`.
36
39
  * @throws {ExpiredDeadlineError} when an explicit `deadline` is positive but not in the future.
37
40
  * @throws {viem.BaseError} when the token metadata read fails with no fallback left.
38
41
  * @throws {MissingClientPropertyError} from `sign()` when the client has no `account.address`.
39
- * @throws {AddressMismatchError} from `sign()` when the client account differs from `userAddress`.
42
+ * @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
43
+ * client account differs from `userAddress`.
40
44
  * @throws {InvalidSignatureError} from `sign()` when EIP-712 verification fails.
41
45
  * @example
42
46
  * ```ts
@@ -47,44 +51,33 @@ const index_js_1 = require("../../../types/index.js");
47
51
  * const client = createWalletClient({ chain: mainnet, transport: http() });
48
52
  * const requirement = await encodeErc20Permit(client, {
49
53
  * token: USDC, // Must implement standard ERC-2612. DAI is routed through Permit2 by requirement helpers.
50
- * spender: generalAdapter1,
54
+ * owner,
55
+ * spender: blueBundlesV1,
51
56
  * amount: 1_000_000n,
52
57
  * chainId: 1,
53
58
  * nonce: 0n,
54
59
  * });
55
- * // requirement satisfies Requirement
60
+ * // Inspect the EIP-712 payload, then sign via the requirement:
61
+ * const typedData = requirement.action.typedData;
62
+ * const signed = await requirement.sign(client, owner);
56
63
  * ```
57
64
  */
58
65
  const encodeErc20Permit = async (viemClient, params) => {
59
- const { token, spender, amount, chainId, nonce, supportDeployless } = params;
66
+ const { token, owner, spender, amount, chainId, nonce, supportDeployless } = params;
60
67
  if (viemClient.chain?.id !== chainId) {
61
68
  throw new index_js_1.ChainIdMismatchError(viemClient.chain?.id, chainId);
62
69
  }
63
70
  (0, validateRequirementSpender_js_1.validateRequirementSpender)({
64
71
  chainId,
65
72
  spender,
66
- allowed: [
67
- "generalAdapter1",
68
- "midnightBundles",
69
- "vaultBundlesV1",
70
- "blueBundlesV1",
71
- ],
73
+ allowed: ["midnightBundles", "vaultBundlesV1", "blueBundlesV1"],
72
74
  });
73
75
  const now = morpho_ts_1.Time.timestamp();
74
76
  // Validate an explicit deadline before the token-metadata read: this exported encoder can be
75
77
  // called independently of the BlueBundlesV1 resolver, and an out-of-range or already-expired
76
78
  // deadline otherwise surfaces only as a downstream wallet typed-data error or an on-chain revert.
77
79
  if (params.deadline != null) {
78
- if (params.deadline <= 0n) {
79
- throw new index_js_1.NonPositiveInputError("deadline", params.deadline);
80
- }
81
- if (params.deadline > viem_1.maxUint256) {
82
- throw new index_js_1.InputExceedsMaxError({
83
- field: "deadline",
84
- value: params.deadline,
85
- max: viem_1.maxUint256,
86
- });
87
- }
80
+ (0, validate_js_1.validateDeadline)(params.deadline);
88
81
  if (params.deadline <= now) {
89
82
  throw new index_js_1.ExpiredDeadlineError(params.deadline, now);
90
83
  }
@@ -93,6 +86,18 @@ const encodeErc20Permit = async (viemClient, params) => {
93
86
  const tokenData = await (0, blue_sdk_viem_1.fetchToken)(token, viemClient, {
94
87
  deployless: supportDeployless,
95
88
  });
89
+ const permitTypedData = (0, blue_sdk_viem_1.getPermitTypedData)({
90
+ erc20: tokenData,
91
+ owner,
92
+ spender,
93
+ allowance: amount,
94
+ nonce,
95
+ deadline,
96
+ }, chainId);
97
+ const typedData = (0, morpho_ts_1.deepFreeze)({
98
+ ...permitTypedData,
99
+ domain: { ...permitTypedData.domain },
100
+ });
96
101
  const action = {
97
102
  type: "permit",
98
103
  args: {
@@ -101,18 +106,14 @@ const encodeErc20Permit = async (viemClient, params) => {
101
106
  deadline,
102
107
  nonce,
103
108
  },
109
+ typedData,
104
110
  };
105
111
  return {
106
112
  action,
107
113
  async sign(client, userAddress) {
108
- const typedData = (0, blue_sdk_viem_1.getPermitTypedData)({
109
- erc20: tokenData,
110
- owner: userAddress,
111
- spender,
112
- allowance: amount,
113
- nonce,
114
- deadline,
115
- }, chainId);
114
+ // The permit's owner is fixed at build time (the fetched nonce is owner-specific), so a
115
+ // different signer cannot produce a valid signature for it.
116
+ (0, validate_js_1.validateUserAddress)(userAddress, owner);
116
117
  const signature = await (0, signAndVerifyTypedData_js_1.signAndVerifyTypedData)({
117
118
  client,
118
119
  userAddress,
@@ -120,7 +121,7 @@ const encodeErc20Permit = async (viemClient, params) => {
120
121
  });
121
122
  return (0, morpho_ts_1.deepFreeze)({
122
123
  args: {
123
- owner: userAddress,
124
+ owner,
124
125
  signature,
125
126
  deadline,
126
127
  amount,
@@ -19,7 +19,8 @@ export interface EncodeErc20Permit2SignatureTransferParams {
19
19
  * Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
20
20
  *
21
21
  * Unlike Permit2 AllowanceTransfer, this signs a one-time `uint256` amount and unordered nonce;
22
- * it has no managed allowance expiration.
22
+ * it has no managed allowance expiration. The requirement's `action.typedData` holds the EIP-712
23
+ * payload so it can be inspected or displayed before signing.
23
24
  *
24
25
  * @param params - SignatureTransfer parameters.
25
26
  * @param params.token - ERC-20 token pulled through Permit2.
@@ -28,7 +29,8 @@ export interface EncodeErc20Permit2SignatureTransferParams {
28
29
  * @param params.chainId - Target chain id.
29
30
  * @param params.nonce - Unused Permit2 unordered nonce.
30
31
  * @param params.deadline - Signature expiration timestamp in seconds.
31
- * @returns A requirement whose `sign(client, userAddress)` returns a deep-frozen signature result.
32
+ * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
33
+ * `sign(client, userAddress)` returns a deep-frozen signature result.
32
34
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
33
35
  * @throws {NonPositiveInputError} when `deadline` is not positive.
34
36
  * @throws {InputExceedsMaxError} when `amount`, `nonce`, or `deadline` exceeds `uint256`.
@@ -12,7 +12,8 @@ const index_js_1 = require("../../../types/index.js");
12
12
  * Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
13
13
  *
14
14
  * Unlike Permit2 AllowanceTransfer, this signs a one-time `uint256` amount and unordered nonce;
15
- * it has no managed allowance expiration.
15
+ * it has no managed allowance expiration. The requirement's `action.typedData` holds the EIP-712
16
+ * payload so it can be inspected or displayed before signing.
16
17
  *
17
18
  * @param params - SignatureTransfer parameters.
18
19
  * @param params.token - ERC-20 token pulled through Permit2.
@@ -21,7 +22,8 @@ const index_js_1 = require("../../../types/index.js");
21
22
  * @param params.chainId - Target chain id.
22
23
  * @param params.nonce - Unused Permit2 unordered nonce.
23
24
  * @param params.deadline - Signature expiration timestamp in seconds.
24
- * @returns A requirement whose `sign(client, userAddress)` returns a deep-frozen signature result.
25
+ * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose
26
+ * `sign(client, userAddress)` returns a deep-frozen signature result.
25
27
  * @throws {NegativeInputError} when `amount` or `nonce` is negative.
26
28
  * @throws {NonPositiveInputError} when `deadline` is not positive.
27
29
  * @throws {InputExceedsMaxError} when `amount`, `nonce`, or `deadline` exceeds `uint256`.
@@ -87,20 +89,23 @@ const encodeErc20Permit2SignatureTransfer = (params) => {
87
89
  // sign a domain-less separator that Permit2 can never accept. The resolver gates on permit2 != null;
88
90
  // this exported encoder is reachable directly, so it must reject the same unsupported chain itself.
89
91
  (0, morpho_ts_1.getChainAddress)(chainId, "permit2"); // throws UnknownAddressError when Permit2 is unregistered
92
+ // Permit2 SignatureTransfer signs over `PermitTransferFrom` (permitted, spender, nonce,
93
+ // deadline), which does not include the owner, so the payload is fully determined at build time.
94
+ const typedData = (0, morpho_ts_1.deepFreeze)((0, blue_sdk_viem_1.getPermit2TransferFromTypedData)({
95
+ erc20: token,
96
+ allowance: amount,
97
+ spender,
98
+ nonce,
99
+ deadline,
100
+ }, chainId));
90
101
  const action = {
91
102
  type: "permit2SignatureTransfer",
92
103
  args: { spender, amount, nonce, deadline },
104
+ typedData,
93
105
  };
94
106
  return {
95
107
  action,
96
108
  async sign(client, userAddress) {
97
- const typedData = (0, blue_sdk_viem_1.getPermit2TransferFromTypedData)({
98
- erc20: token,
99
- allowance: amount,
100
- spender,
101
- nonce,
102
- deadline,
103
- }, chainId);
104
109
  const signature = await (0, signAndVerifyTypedData_js_1.signAndVerifyTypedData)({
105
110
  client,
106
111
  userAddress,
@@ -23,7 +23,8 @@ export interface EncodeVaultSharesPermitParams {
23
23
  * Builds the bounded ERC-2612 shares-permit requirement used by an in-kind vault exit.
24
24
  *
25
25
  * Vault V1 uses the standard token permit domain. Vault V2 uses its protocol-specific domain with
26
- * only `chainId` and `verifyingContract`.
26
+ * only `chainId` and `verifyingContract`. The requirement's `action.typedData` holds the EIP-712
27
+ * payload so it can be inspected or displayed before signing.
27
28
  *
28
29
  * @param params.vault - Vault share token, including V1 permit-domain metadata when available.
29
30
  * @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
@@ -33,16 +34,18 @@ export interface EncodeVaultSharesPermitParams {
33
34
  * @param params.nonce - Current vault permit nonce for the owner.
34
35
  * @param params.amount - Vault-share allowance to authorize.
35
36
  * @param params.deadline - Shared permit and bundle deadline.
36
- * @returns A requirement whose `sign()` result can be embedded in fixed vault-bundles calldata.
37
+ * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
38
+ * can be embedded in fixed vault-bundles calldata.
37
39
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
38
40
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
39
41
  * @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
40
- * @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
42
+ * @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
43
+ * wallet account differs from `userAddress`.
41
44
  * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
42
45
  * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
43
- * @throws {InvalidPermitDomainChainIdError} from `sign()` when a Vault V1 permit domain targets another chain or omits `chainId`.
44
- * @throws {InvalidPermitDomainVerifyingContractError} from `sign()` when a Vault V1 permit domain targets another token or omits `verifyingContract`.
45
- * @throws {UnsupportedPermitDomainExtensionsError} from `sign()` when a Vault V1 permit domain advertises unsupported extensions.
46
+ * @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
47
+ * @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
48
+ * @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
46
49
  * @example
47
50
  * ```ts
48
51
  * import { encodeVaultSharesPermit } from "@morpho-org/morpho-sdk";
@@ -12,7 +12,8 @@ const validateRequirementSpender_js_1 = require("../../../helpers/validateRequir
12
12
  * Builds the bounded ERC-2612 shares-permit requirement used by an in-kind vault exit.
13
13
  *
14
14
  * Vault V1 uses the standard token permit domain. Vault V2 uses its protocol-specific domain with
15
- * only `chainId` and `verifyingContract`.
15
+ * only `chainId` and `verifyingContract`. The requirement's `action.typedData` holds the EIP-712
16
+ * payload so it can be inspected or displayed before signing.
16
17
  *
17
18
  * @param params.vault - Vault share token, including V1 permit-domain metadata when available.
18
19
  * @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
@@ -22,16 +23,18 @@ const validateRequirementSpender_js_1 = require("../../../helpers/validateRequir
22
23
  * @param params.nonce - Current vault permit nonce for the owner.
23
24
  * @param params.amount - Vault-share allowance to authorize.
24
25
  * @param params.deadline - Shared permit and bundle deadline.
25
- * @returns A requirement whose `sign()` result can be embedded in fixed vault-bundles calldata.
26
+ * @returns A requirement whose `action.typedData` is the EIP-712 payload and whose `sign()` result
27
+ * can be embedded in fixed vault-bundles calldata.
26
28
  * @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
27
29
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
28
30
  * @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
29
- * @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
31
+ * @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
32
+ * wallet account differs from `userAddress`.
30
33
  * @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
31
34
  * @throws {InvalidSignatureError} from `sign()` when signature recovery fails.
32
- * @throws {InvalidPermitDomainChainIdError} from `sign()` when a Vault V1 permit domain targets another chain or omits `chainId`.
33
- * @throws {InvalidPermitDomainVerifyingContractError} from `sign()` when a Vault V1 permit domain targets another token or omits `verifyingContract`.
34
- * @throws {UnsupportedPermitDomainExtensionsError} from `sign()` when a Vault V1 permit domain advertises unsupported extensions.
35
+ * @throws {InvalidPermitDomainChainIdError} when a Vault V1 permit domain targets another chain or omits `chainId`.
36
+ * @throws {InvalidPermitDomainVerifyingContractError} when a Vault V1 permit domain targets another token or omits `verifyingContract`.
37
+ * @throws {UnsupportedPermitDomainExtensionsError} when a Vault V1 permit domain advertises unsupported extensions.
35
38
  * @example
36
39
  * ```ts
37
40
  * import { encodeVaultSharesPermit } from "@morpho-org/morpho-sdk";
@@ -85,6 +88,18 @@ const encodeVaultSharesPermit = (params) => {
85
88
  spender,
86
89
  allowed: ["vaultExitBundlesV1", "vaultBundlesV1"],
87
90
  });
91
+ const permitTypedData = (0, blue_sdk_viem_1.getPermitTypedData)({
92
+ owner,
93
+ spender,
94
+ allowance: amount,
95
+ nonce,
96
+ deadline,
97
+ erc20: vault,
98
+ }, chainId);
99
+ const typedData = (0, morpho_ts_1.deepFreeze)({
100
+ ...permitTypedData,
101
+ domain: { ...permitTypedData.domain },
102
+ });
88
103
  const action = {
89
104
  type: "permit",
90
105
  args: {
@@ -93,23 +108,13 @@ const encodeVaultSharesPermit = (params) => {
93
108
  deadline,
94
109
  nonce,
95
110
  },
111
+ typedData,
96
112
  };
97
113
  return {
98
114
  action,
99
115
  async sign(client, userAddress) {
100
116
  // The bundle spends msg.sender's shares, so another signer cannot authorize this exit.
101
117
  (0, validate_js_1.validateUserAddress)(userAddress, owner);
102
- const permit = {
103
- owner,
104
- spender,
105
- allowance: amount,
106
- nonce,
107
- deadline,
108
- };
109
- const typedData = (0, blue_sdk_viem_1.getPermitTypedData)({
110
- ...permit,
111
- erc20: vault,
112
- }, chainId);
113
118
  const signature = await (0, signAndVerifyTypedData_js_1.signAndVerifyTypedData)({
114
119
  client,
115
120
  userAddress,
@@ -1,6 +1,5 @@
1
1
  export * from "./encodeBlueSignatureAuthorization.js";
2
2
  export * from "./encodeErc20Approval.js";
3
3
  export * from "./encodeErc20Permit.js";
4
- export * from "./encodeErc20Permit2Approve.js";
5
4
  export * from "./encodeErc20Permit2SignatureTransfer.js";
6
5
  export * from "./encodeVaultSharesPermit.js";
@@ -17,6 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./encodeBlueSignatureAuthorization.js"), exports);
18
18
  __exportStar(require("./encodeErc20Approval.js"), exports);
19
19
  __exportStar(require("./encodeErc20Permit.js"), exports);
20
- __exportStar(require("./encodeErc20Permit2Approve.js"), exports);
21
20
  __exportStar(require("./encodeErc20Permit2SignatureTransfer.js"), exports);
22
21
  __exportStar(require("./encodeVaultSharesPermit.js"), exports);
@@ -5,8 +5,8 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
5
5
  * allowance.
6
6
  *
7
7
  * The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
8
- * GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and
9
- * BlueBundlesV1 addresses when configured.
8
+ * Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and BlueBundlesV1
9
+ * addresses when configured.
10
10
  *
11
11
  * Returns an empty array when the allowance already covers `spendAmount`. When the token is in
12
12
  * `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
@@ -19,9 +19,8 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
19
19
  * @param params.args.spendAmount - The amount the bundle will actually pull.
20
20
  * @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
21
21
  * may be `maxUint256` for reusable Permit2 or saturated-share-repay approvals).
22
- * @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
23
- * Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
24
- * `chainId`.
22
+ * @param params.args.spender - Address that will be granted the approval. Must be Permit2,
23
+ * Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
25
24
  * @param params.allowances - The user's current allowance of `address` for `spender`.
26
25
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
27
26
  * followed by the new approval. Empty when no approval is needed.
@@ -35,7 +34,7 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
35
34
  * const txs = getRequirementsApproval({
36
35
  * address: USDC,
37
36
  * chainId: 1,
38
- * args: { approvalAmount: 1_000_000n, spendAmount: 1_000_000n, spender: generalAdapter1 },
37
+ * args: { approvalAmount: 1_000_000n, spendAmount: 1_000_000n, spender: blueBundlesV1 },
39
38
  * allowances: 0n,
40
39
  * });
41
40
  * // txs satisfies Readonly<Transaction<ERC20ApprovalAction>>[]
@@ -10,8 +10,8 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
10
10
  * allowance.
11
11
  *
12
12
  * The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
13
- * GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and
14
- * BlueBundlesV1 addresses when configured.
13
+ * Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and BlueBundlesV1
14
+ * addresses when configured.
15
15
  *
16
16
  * Returns an empty array when the allowance already covers `spendAmount`. When the token is in
17
17
  * `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
@@ -24,9 +24,8 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
24
24
  * @param params.args.spendAmount - The amount the bundle will actually pull.
25
25
  * @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
26
26
  * may be `maxUint256` for reusable Permit2 or saturated-share-repay approvals).
27
- * @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
28
- * Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
29
- * `chainId`.
27
+ * @param params.args.spender - Address that will be granted the approval. Must be Permit2,
28
+ * Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
30
29
  * @param params.allowances - The user's current allowance of `address` for `spender`.
31
30
  * @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
32
31
  * followed by the new approval. Empty when no approval is needed.
@@ -40,7 +39,7 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
40
39
  * const txs = getRequirementsApproval({
41
40
  * address: USDC,
42
41
  * chainId: 1,
43
- * args: { approvalAmount: 1_000_000n, spendAmount: 1_000_000n, spender: generalAdapter1 },
42
+ * args: { approvalAmount: 1_000_000n, spendAmount: 1_000_000n, spender: blueBundlesV1 },
44
43
  * allowances: 0n,
45
44
  * });
46
45
  * // txs satisfies Readonly<Transaction<ERC20ApprovalAction>>[]
@@ -1,5 +1,4 @@
1
1
  export * from "./blue/index.js";
2
2
  export * from "./encode/index.js";
3
- export * from "./generalAdapter/index.js";
4
3
  export * from "./getRequirementsApproval.js";
5
4
  export * from "./midnight/index.js";
@@ -16,6 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./blue/index.js"), exports);
18
18
  __exportStar(require("./encode/index.js"), exports);
19
- __exportStar(require("./generalAdapter/index.js"), exports);
20
19
  __exportStar(require("./getRequirementsApproval.js"), exports);
21
20
  __exportStar(require("./midnight/index.js"), exports);
@@ -52,8 +52,7 @@ export interface VaultV1DepositParams {
52
52
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD; it extends
53
53
  * {@link InputExceedsMaxError}, so either class catches it.
54
54
  * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
55
- * @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit or a
56
- * Permit2 AllowanceTransfer signature is supplied.
55
+ * @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit.
57
56
  * @throws {InputExceedsMaxError} when funding, `maxSharePrice`, or `deadline` exceeds uint256.
58
57
  * @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
59
58
  * @throws {DepositAssetMismatchError} when the signed asset differs from the vault asset.
@@ -41,8 +41,7 @@ const common_js_1 = require("../bundles/common.js");
41
41
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD; it extends
42
42
  * {@link InputExceedsMaxError}, so either class catches it.
43
43
  * @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
44
- * @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit or a
45
- * Permit2 AllowanceTransfer signature is supplied.
44
+ * @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit.
46
45
  * @throws {InputExceedsMaxError} when funding, `maxSharePrice`, or `deadline` exceeds uint256.
47
46
  * @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
48
47
  * @throws {DepositAssetMismatchError} when the signed asset differs from the vault asset.
@@ -27,19 +27,21 @@ export interface VaultV1InKindRedeemParams {
27
27
  * @param params.vault.address - Target Vault V1 address.
28
28
  * @param params.args.amount - Asset-denominated amount to exit.
29
29
  * @param params.args.marketParamsList - Ordered markets consumed greedily by the contract.
30
- * @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
31
- * VaultExitBundlesV1 burns `msg.sender`'s vault shares, so the submitting account must equal this
32
- * address.
30
+ * @param params.args.userAddress - Redeeming account, recorded in action metadata and validated as
31
+ * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
32
+ * `msg.sender`'s vault shares, so the submitting account must equal this address.
33
33
  * @param params.args.deadline - Permit and bundle deadline.
34
34
  * @param params.args.requirementSignature - Optional bounded Vault V1 shares permit.
35
35
  * @param params.metadata - Optional analytics metadata.
36
36
  * @returns A deep-frozen `Readonly<Transaction<VaultV1InKindRedeemAction>>` with `to`, `value`,
37
37
  * `data`, and the typed action discriminator.
38
38
  * @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
39
+ * @throws {InputExceedsMaxError} when the bundle or permit deadline exceeds `uint256`.
39
40
  * @throws {EmptyMarketParamsListError} when no markets are supplied.
40
41
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
41
42
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
42
- * @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
43
+ * @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
44
+ * spender, or signature encoding, or when its signed and action amounts or deadlines disagree.
43
45
  * @example
44
46
  * ```ts
45
47
  * import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
@@ -5,8 +5,9 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
5
5
  const viem_1 = require("viem");
6
6
  const abis_js_1 = require("../../abis.js");
7
7
  const index_js_1 = require("../../helpers/index.js");
8
+ const validate_js_1 = require("../../helpers/validate.js");
8
9
  const index_js_2 = require("../../types/index.js");
9
- const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultExitBundlesV1PermitStruct.js");
10
+ const common_js_1 = require("../bundles/common.js");
10
11
  /**
11
12
  * Prepares a Vault V1 in-kind redemption into Morpho Blue supply positions.
12
13
  *
@@ -18,19 +19,21 @@ const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultEx
18
19
  * @param params.vault.address - Target Vault V1 address.
19
20
  * @param params.args.amount - Asset-denominated amount to exit.
20
21
  * @param params.args.marketParamsList - Ordered markets consumed greedily by the contract.
21
- * @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
22
- * VaultExitBundlesV1 burns `msg.sender`'s vault shares, so the submitting account must equal this
23
- * address.
22
+ * @param params.args.userAddress - Redeeming account, recorded in action metadata and validated as
23
+ * the expected owner of an optional `requirementSignature` permit. VaultExitBundlesV1 burns
24
+ * `msg.sender`'s vault shares, so the submitting account must equal this address.
24
25
  * @param params.args.deadline - Permit and bundle deadline.
25
26
  * @param params.args.requirementSignature - Optional bounded Vault V1 shares permit.
26
27
  * @param params.metadata - Optional analytics metadata.
27
28
  * @returns A deep-frozen `Readonly<Transaction<VaultV1InKindRedeemAction>>` with `to`, `value`,
28
29
  * `data`, and the typed action discriminator.
29
30
  * @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
31
+ * @throws {InputExceedsMaxError} when the bundle or permit deadline exceeds `uint256`.
30
32
  * @throws {EmptyMarketParamsListError} when no markets are supplied.
31
33
  * @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
32
34
  * @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
33
- * @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
35
+ * @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
36
+ * spender, or signature encoding, or when its signed and action amounts or deadlines disagree.
34
37
  * @example
35
38
  * ```ts
36
39
  * import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
@@ -45,8 +48,7 @@ const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultEx
45
48
  const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
46
49
  if (args.amount <= 0n)
47
50
  throw new index_js_2.NonPositiveInputError("amount", args.amount);
48
- if (args.deadline <= 0n)
49
- throw new index_js_2.NonPositiveInputError("deadline", args.deadline);
51
+ (0, validate_js_1.validateDeadline)(args.deadline);
50
52
  if (args.marketParamsList.length === 0)
51
53
  throw new index_js_2.EmptyMarketParamsListError();
52
54
  const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
@@ -57,9 +59,11 @@ const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
57
59
  irm: marketParams.irm,
58
60
  lltv: marketParams.lltv,
59
61
  }));
60
- const sharesPermit = (0, getVaultExitBundlesV1PermitStruct_js_1.getVaultExitBundlesV1PermitStruct)({
62
+ const sharesPermit = (0, common_js_1.getBundlesSharesPermit)({
61
63
  vault: vault.address,
62
64
  deadline: args.deadline,
65
+ owner: args.userAddress,
66
+ spender: to,
63
67
  requirementSignature: args.requirementSignature,
64
68
  });
65
69
  let tx = {