@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
@@ -10,7 +10,6 @@ const index_js_1 = require("../../actions/index.js");
10
10
  const index_js_2 = require("../../helpers/index.js");
11
11
  const index_js_3 = require("../../types/index.js");
12
12
  const index_js_4 = require("../requirements/index.js");
13
- const vaultV1ReallocationData_js_1 = require("../vaultV1ReallocationData.js");
14
13
  const vaultV2BlueReallocationData_js_1 = require("../vaultV2BlueReallocationData.js");
15
14
  class MorphoBlue {
16
15
  client;
@@ -81,7 +80,6 @@ class MorphoBlue {
81
80
  (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
82
81
  return (0, blue_sdk_viem_1.fetchMarket)(this.marketParams.id, this.client.viemClient, {
83
82
  ...parameters,
84
- chainId: this.chainId,
85
83
  deployless: this.client.options.supportDeployless,
86
84
  });
87
85
  }
@@ -90,7 +88,6 @@ class MorphoBlue {
90
88
  return (0, blue_sdk_viem_1.fetchAccrualPosition)(userAddress, this.marketParams.id, this.client.viemClient, {
91
89
  ...parameters,
92
90
  deployless: this.client.options.supportDeployless,
93
- chainId: this.chainId,
94
91
  });
95
92
  }
96
93
  /** {@inheritDoc BlueActions.supply} */
@@ -441,14 +438,7 @@ class MorphoBlue {
441
438
  ? this.getTokenRequirements({
442
439
  token: this.marketParams.loanToken,
443
440
  amount: maxRepayAssets,
444
- // A caller-requested reusable approval wins; a full repay otherwise defaults to
445
- // the token's reusable cap. Checksum the key so a differently-cased loan token
446
- // (common from subgraphs/APIs) resolves that cap instead of falling back to
447
- // maxUint256, which UNI/ONDO/COMP/FLUID reject.
448
- approvalAmount: requirementsParams?.approvalAmount ??
449
- (saturatedRepay
450
- ? (index_js_2.MAX_TOKEN_APPROVALS[this.chainId]?.[(0, viem_1.getAddress)(this.marketParams.loanToken)] ?? viem_1.maxUint256)
451
- : undefined),
441
+ approvalAmount: requirementsParams?.approvalAmount,
452
442
  userAddress,
453
443
  deadline,
454
444
  useSimplePermit: requirementsParams?.useSimplePermit,
@@ -662,120 +652,6 @@ class MorphoBlue {
662
652
  },
663
653
  };
664
654
  }
665
- /**
666
- * Fetches all on-chain inputs needed to compute public allocator reallocations.
667
- *
668
- * @param params.vaultAddresses - Vaults to inspect for source-market liquidity.
669
- * @param params.block.number - Block number used for every RPC read.
670
- * @param params.block.timestamp - Timestamp corresponding to the fetched block.
671
- * @returns Reallocation data ready for {@link getVaultV1Reallocations}.
672
- * @throws {ChainIdMismatchError} when the client chain does not match this market.
673
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
674
- * {@link getVaultV2BlueReallocationData}.
675
- * @example
676
- * ```ts
677
- * import { markets, vaults } from "@morpho-org/morpho-test";
678
- * import { createPublicClient, http } from "viem";
679
- * import { mainnet } from "viem/chains";
680
- * import { morphoViemExtension } from "@morpho-org/morpho-sdk";
681
- * import type { VaultV1ReallocationData } from "@morpho-org/morpho-sdk/entities";
682
- *
683
- * const client = createPublicClient({ chain: mainnet, transport: http() })
684
- * .extend(morphoViemExtension());
685
- * const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
686
- * const block = await client.getBlock();
687
- * const data: VaultV1ReallocationData = await market.getVaultV1ReallocationData({
688
- * vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
689
- * block,
690
- * });
691
- * ```
692
- */
693
- async getVaultV1ReallocationData({ vaultAddresses, block, }) {
694
- (0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
695
- const client = this.client.viemClient;
696
- const fetchParams = {
697
- blockNumber: block.number,
698
- chainId: this.chainId,
699
- deployless: this.client.options.supportDeployless,
700
- };
701
- const targetMarketId = this.marketParams.id;
702
- // Phase 1: Fetch the target market and all vaults at `block.number` in
703
- // parallel so every row of the resulting state comes from the same epoch
704
- // and the planner never trusts a caller-owned target-market snapshot.
705
- const [targetMarket, vaults] = await Promise.all([
706
- (0, blue_sdk_viem_1.fetchMarket)(targetMarketId, client, fetchParams),
707
- Promise.all(vaultAddresses.map((addr) => (0, blue_sdk_viem_1.fetchVault)(addr, client, fetchParams))),
708
- ]);
709
- const allMarketIds = new Set([targetMarketId]);
710
- const vaultMarketPairs = [];
711
- for (const vault of vaults) {
712
- // Always include target market pair so its config/position is fetched
713
- // even when the target market is only in the vault's supplyQueue.
714
- vaultMarketPairs.push({ vault: vault.address, marketId: targetMarketId });
715
- for (const mid of vault.withdrawQueue) {
716
- allMarketIds.add(mid);
717
- if (mid !== targetMarketId) {
718
- vaultMarketPairs.push({ vault: vault.address, marketId: mid });
719
- }
720
- }
721
- }
722
- // Phase 2: Fetch all source markets, vault configs, and positions in parallel.
723
- const sourceMarketIds = [...allMarketIds].filter((mid) => mid !== targetMarketId);
724
- const [markets, configs, positions] = await Promise.all([
725
- Promise.all(sourceMarketIds.map((mid) => (0, blue_sdk_viem_1.fetchMarket)(mid, client, fetchParams))),
726
- Promise.all(vaultMarketPairs.map(({ vault, marketId: mid }) => (0, blue_sdk_viem_1.fetchVaultMarketConfig)(vault, mid, client, fetchParams).then((config) => ({ vault, mid, config })))),
727
- Promise.all(vaultMarketPairs.map(({ vault, marketId: mid }) => (0, blue_sdk_viem_1.fetchPosition)(vault, mid, client, fetchParams).then((position) => ({
728
- vault,
729
- mid,
730
- position,
731
- })))),
732
- ]);
733
- // Assemble records for VaultV1ReallocationData.
734
- const marketsRecord = {
735
- [targetMarketId]: targetMarket,
736
- };
737
- for (const m of markets) {
738
- marketsRecord[m.id] = m;
739
- }
740
- const vaultsRecord = {};
741
- for (const v of vaults) {
742
- vaultsRecord[v.address] = v;
743
- }
744
- const vaultMarketConfigsRecord = {};
745
- for (const { vault, mid, config } of configs) {
746
- (vaultMarketConfigsRecord[vault] ??= {})[mid] = config;
747
- }
748
- const positionsRecord = {};
749
- for (const { vault, mid, position } of positions) {
750
- (positionsRecord[vault] ??= {})[mid] = position;
751
- }
752
- return new vaultV1ReallocationData_js_1.VaultV1ReallocationData({
753
- chainId: this.chainId,
754
- markets: marketsRecord,
755
- vaults: vaultsRecord,
756
- vaultMarketConfigs: vaultMarketConfigsRecord,
757
- positions: positionsRecord,
758
- });
759
- }
760
- /**
761
- * Fetches Vault V1 PublicAllocator state using the deprecated unversioned name.
762
- *
763
- * @param params.vaultAddresses - Addresses of MetaMorpho vaults that allocate to this market.
764
- * @param params.block.number - Block number used for every RPC read.
765
- * @param params.block.timestamp - Timestamp corresponding to the fetched block.
766
- * @returns A `VaultV1ReallocationData` snapshot populated from one block.
767
- * @throws {ChainIdMismatchError} when the client chain does not match this market.
768
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
769
- * {@link getVaultV2BlueReallocationData}.
770
- * @example
771
- * ```ts
772
- * const data = await market.getReallocationData({ vaultAddresses, block });
773
- * // Equivalent to market.getVaultV1ReallocationData({ vaultAddresses, block }).
774
- * ```
775
- */
776
- getReallocationData(params) {
777
- return this.getVaultV1ReallocationData(params);
778
- }
779
655
  /**
780
656
  * Fetches Vault V2 BluePublicAllocator state for this target market.
781
657
  *
@@ -854,84 +730,6 @@ class MorphoBlue {
854
730
  ])),
855
731
  });
856
732
  }
857
- /**
858
- * Computes Vault V1 PublicAllocator reallocations for this market.
859
- *
860
- * Pass `{ borrowAmount }` for a borrow (legacy alias, equivalent to `{ operation: "borrow", amount }`)
861
- * or `{ operation, amount }` for a borrow or loan-asset withdraw.
862
- *
863
- * @param params - Reallocation computation parameters.
864
- * @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
865
- * @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
866
- * @param params.amount - The borrow or withdraw amount used to compute the post-state utilization.
867
- * @param params.borrowAmount - {@deprecated Pass `{ operation: "borrow", amount }` instead.}
868
- * @param params.options - Optional allocator and utilization options.
869
- * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
870
- * @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
871
- * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
872
- * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
873
- * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
874
- * @throws {UnknownReallocationMarketError} when the target market is absent from the reallocation data.
875
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
876
- * {@link getVaultV2BlueReallocations}.
877
- * @example
878
- * ```ts
879
- * const reallocations = market.getVaultV1Reallocations({
880
- * reallocationData,
881
- * operation: "borrow",
882
- * amount: 1_000_000n,
883
- * });
884
- * ```
885
- */
886
- getVaultV1Reallocations(params) {
887
- (0, index_js_2.validateChainId)(params.reallocationData.chainId, this.chainId);
888
- const marketId = this.marketParams.id;
889
- const options = { enabled: true, ...params.options };
890
- if (params.borrowAmount !== undefined) {
891
- return (0, index_js_2.computeVaultV1Reallocations)({
892
- reallocationData: params.reallocationData,
893
- marketId,
894
- operation: "borrow",
895
- amount: params.borrowAmount,
896
- options,
897
- });
898
- }
899
- return (0, index_js_2.computeVaultV1Reallocations)({
900
- reallocationData: params.reallocationData,
901
- marketId,
902
- operation: params.operation,
903
- amount: params.amount,
904
- options,
905
- });
906
- }
907
- /**
908
- * Computes Vault V1 PublicAllocator reallocations using the deprecated unversioned name.
909
- *
910
- * @param params.reallocationData - State returned by {@link getVaultV1ReallocationData}.
911
- * @param params.operation - The operation driving the reallocation (`"borrow"` or `"withdraw"`).
912
- * @param params.amount - The borrow or withdraw amount used to compute post-state utilization.
913
- * @param params.borrowAmount - Deprecated borrow amount alias.
914
- * @param params.options - Optional allocator and utilization options.
915
- * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
916
- * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
917
- * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
918
- * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
919
- * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
920
- * @throws {UnknownReallocationMarketError} when the target market is absent.
921
- * @deprecated Vault V1 shared-liquidity planning will be removed in the next major. Use
922
- * {@link getVaultV2BlueReallocations}.
923
- * @example
924
- * ```ts
925
- * const reallocations = market.getReallocations({
926
- * reallocationData,
927
- * operation: "borrow",
928
- * amount: 1_000_000n,
929
- * });
930
- * ```
931
- */
932
- getReallocations(params) {
933
- return this.getVaultV1Reallocations(params);
934
- }
935
733
  /**
936
734
  * Computes Vault V2 BluePublicAllocator reallocations for this market.
937
735
  *
@@ -939,6 +737,7 @@ class MorphoBlue {
939
737
  * @param params.options - Optional allocator discovery controls and operation to support.
940
738
  * @returns Action-ready reallocations and their post-simulation state.
941
739
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
740
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
942
741
  * @throws {NegativeInputError} when a utilization or penalty limit is negative.
943
742
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
944
743
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
@@ -1,69 +1,12 @@
1
- export type { IAccrualPosition as IBlueAccrualPosition,
2
- /** @deprecated Use `IBlueAccrualPosition` or the raw Blue subpath. */
3
- IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket,
4
- /** @deprecated Use `IBlueMarket` or the raw Blue subpath. */
5
- IMarket, IMarketParams as IBlueMarketParams,
6
- /** @deprecated Use `IBlueMarketParams` or the raw Blue subpath. */
7
- IMarketParams, IPosition as IBluePosition,
8
- /** @deprecated Use `IBluePosition` or the raw Blue subpath. */
9
- IPosition, IPreLiquidationParams as IBluePreLiquidationParams,
10
- /** @deprecated Use `IBluePreLiquidationParams` or the raw Blue subpath. */
11
- IPreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition,
12
- /** @deprecated Use `IBluePreLiquidationPosition` or the raw Blue subpath. */
13
- IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
14
- export { AccrualPosition as BlueAccrualPosition,
15
- /** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
16
- AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket,
17
- /** @deprecated Use `BlueMarket` or the raw Blue subpath. */
18
- Market, MarketParams as BlueMarketParams,
19
- /** @deprecated Use `BlueMarketParams` or the raw Blue subpath. */
20
- MarketParams, Position as BluePosition,
21
- /** @deprecated Use `BluePosition` or the raw Blue subpath. */
22
- Position, PreLiquidationParams as BluePreLiquidationParams,
23
- /** @deprecated Use `BluePreLiquidationParams` or the raw Blue subpath. */
24
- PreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition,
25
- /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
26
- PreLiquidationPosition, Token, User as BlueUser,
27
- /** @deprecated Use `BlueUser` or the raw Blue subpath. */
28
- User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
1
+ export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition, IPreLiquidationParams as IBluePreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
2
+ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition, PreLiquidationParams as BluePreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
29
3
  export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
30
4
  export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
31
5
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
32
6
  export { MorphoBlue } from "./blue/index.js";
33
- export type { GetOffersDataParams as MidnightGetOffersDataParams,
34
- /** @deprecated Use `MidnightGetOffersDataParams`. */
35
- GetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams,
36
- /** @deprecated Use `MidnightGetPositionDataParams`. */
37
- GetPositionDataParams, MakeLendParams as MidnightMakeLendParams,
38
- /** @deprecated Use `MidnightMakeLendParams`. */
39
- MakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput,
40
- /** @deprecated Use `MidnightMakeOffersOutput`. */
41
- MakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams,
42
- /** @deprecated Use `MidnightMakeOffersParams`. */
43
- MakeOffersParams, MarketActionParams as MidnightMarketActionParams,
44
- /** @deprecated Use `MidnightMarketActionParams`. */
45
- MarketActionParams, OffersData as MidnightOffersData,
46
- /** @deprecated Use `MidnightOffersData`. */
47
- OffersData, OfferValidationParams as MidnightOfferValidationParams,
48
- /** @deprecated Use `MidnightOfferValidationParams`. */
49
- OfferValidationParams, RedeemParams as MidnightRedeemParams,
50
- /** @deprecated Use `MidnightRedeemParams`. */
51
- RedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams,
52
- /** @deprecated Use `MidnightRepayWithdrawCollateralParams`. */
53
- RepayWithdrawCollateralParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams,
54
- /** @deprecated Use `MidnightSupplyCollateralMakeBorrowParams`. */
55
- SupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams,
56
- /** @deprecated Use `MidnightSupplyCollateralParams`. */
57
- SupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams,
58
- /** @deprecated Use `MidnightSupplyCollateralTakeBorrowParams`. */
59
- SupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams,
60
- /** @deprecated Use `MidnightTakeBorrowParams`. */
61
- TakeBorrowParams, TakeLendParams as MidnightTakeLendParams,
62
- /** @deprecated Use `MidnightTakeLendParams`. */
63
- TakeLendParams, } from "./midnight/index.js";
7
+ export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, } from "./midnight/index.js";
64
8
  export { type MidnightActionOutput, type MidnightActionSignatures, type MidnightActions, MorphoMidnight, } from "./midnight/index.js";
65
9
  export * from "./requirements/index.js";
66
10
  export { MorphoVaultV1 } from "./vaultV1/index.js";
67
- export { type InputReallocationData, type InputVaultV1ReallocationData, ReallocationData, VaultV1ReallocationData, } from "./vaultV1ReallocationData.js";
68
11
  export { MorphoVaultV2 } from "./vaultV2/index.js";
69
12
  export { type InputVaultV2BlueReallocationData, VaultV2BlueReallocationData, } from "./vaultV2BlueReallocationData.js";
@@ -14,12 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketPublicAllocatorConfig = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.BlueUser = exports.Token = exports.PreLiquidationPosition = exports.BluePreLiquidationPosition = exports.PreLiquidationParams = exports.BluePreLiquidationParams = exports.Position = exports.BluePosition = exports.MarketParams = exports.BlueMarketParams = exports.Market = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = exports.BlueAccrualPosition = void 0;
18
- exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.VaultV1ReallocationData = exports.ReallocationData = void 0;
17
+ exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
19
18
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
20
19
  Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
21
- /** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
22
- Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
23
20
  Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
24
21
  Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
25
22
  Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
@@ -31,29 +28,16 @@ Object.defineProperty(exports, "Eip5267Domain", { enumerable: true, get: functio
31
28
  Object.defineProperty(exports, "ExchangeRateWrappedToken", { enumerable: true, get: function () { return blue_sdk_1.ExchangeRateWrappedToken; } });
32
29
  Object.defineProperty(exports, "Holding", { enumerable: true, get: function () { return blue_sdk_1.Holding; } });
33
30
  Object.defineProperty(exports, "BlueMarket", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
34
- /** @deprecated Use `BlueMarket` or the raw Blue subpath. */
35
- Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
36
31
  Object.defineProperty(exports, "BlueMarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
37
- /** @deprecated Use `BlueMarketParams` or the raw Blue subpath. */
38
- Object.defineProperty(exports, "MarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
39
32
  Object.defineProperty(exports, "BluePosition", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
40
- /** @deprecated Use `BluePosition` or the raw Blue subpath. */
41
- Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
42
33
  Object.defineProperty(exports, "BluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
43
- /** @deprecated Use `BluePreLiquidationParams` or the raw Blue subpath. */
44
- Object.defineProperty(exports, "PreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
45
34
  Object.defineProperty(exports, "BluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
46
- /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
47
- Object.defineProperty(exports, "PreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
48
35
  Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
49
36
  Object.defineProperty(exports, "BlueUser", { enumerable: true, get: function () { return blue_sdk_1.User; } });
50
- /** @deprecated Use `BlueUser` or the raw Blue subpath. */
51
- Object.defineProperty(exports, "User", { enumerable: true, get: function () { return blue_sdk_1.User; } });
52
37
  Object.defineProperty(exports, "Vault", { enumerable: true, get: function () { return blue_sdk_1.Vault; } });
53
38
  Object.defineProperty(exports, "VaultConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultConfig; } });
54
39
  Object.defineProperty(exports, "VaultMarketAllocation", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketAllocation; } });
55
40
  Object.defineProperty(exports, "VaultMarketConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketConfig; } });
56
- Object.defineProperty(exports, "VaultMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultMarketPublicAllocatorConfig; } });
57
41
  Object.defineProperty(exports, "VaultToken", { enumerable: true, get: function () { return blue_sdk_1.VaultToken; } });
58
42
  Object.defineProperty(exports, "VaultUser", { enumerable: true, get: function () { return blue_sdk_1.VaultUser; } });
59
43
  Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2; } });
@@ -79,9 +63,6 @@ Object.defineProperty(exports, "MorphoMidnight", { enumerable: true, get: functi
79
63
  __exportStar(require("./requirements/index.js"), exports);
80
64
  var index_js_3 = require("./vaultV1/index.js");
81
65
  Object.defineProperty(exports, "MorphoVaultV1", { enumerable: true, get: function () { return index_js_3.MorphoVaultV1; } });
82
- var vaultV1ReallocationData_js_1 = require("./vaultV1ReallocationData.js");
83
- Object.defineProperty(exports, "ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.ReallocationData; } });
84
- Object.defineProperty(exports, "VaultV1ReallocationData", { enumerable: true, get: function () { return vaultV1ReallocationData_js_1.VaultV1ReallocationData; } });
85
66
  var index_js_4 = require("./vaultV2/index.js");
86
67
  Object.defineProperty(exports, "MorphoVaultV2", { enumerable: true, get: function () { return index_js_4.MorphoVaultV2; } });
87
68
  var vaultV2BlueReallocationData_js_1 = require("./vaultV2BlueReallocationData.js");
@@ -550,7 +550,6 @@ class MorphoMidnight {
550
550
  }
551
551
  });
552
552
  const midnight = (0, morpho_ts_1.getChainAddress)(this.chainId, "midnight");
553
- const signedPayloads = new Map();
554
553
  return {
555
554
  groups: data.groups,
556
555
  root: data.tree.root,
@@ -567,14 +566,12 @@ class MorphoMidnight {
567
566
  })));
568
567
  requirements.push(...(await this.getRatifierRequirements({
569
568
  offersData: data,
570
- signedPayloads,
571
569
  })));
572
570
  return requirements;
573
571
  },
574
572
  buildTx: (signatures) => this.buildSubmitOffersTx({
575
573
  offersData: data,
576
574
  signatures,
577
- signedPayloads,
578
575
  }),
579
576
  };
580
577
  }
@@ -605,7 +602,6 @@ class MorphoMidnight {
605
602
  validation: params.validation,
606
603
  });
607
604
  (0, validateOfferSides_js_1.validateOfferSides)(data.tree.offers, false);
608
- const signedPayloads = new Map();
609
605
  return {
610
606
  groups: data.groups,
611
607
  root: data.tree.root,
@@ -613,13 +609,11 @@ class MorphoMidnight {
613
609
  getRequirements: async () => {
614
610
  return await this.getRatifierRequirements({
615
611
  offersData: data,
616
- signedPayloads,
617
612
  });
618
613
  },
619
614
  buildTx: (signatures) => this.buildSubmitOffersTx({
620
615
  offersData: data,
621
616
  signatures,
622
- signedPayloads,
623
617
  }),
624
618
  };
625
619
  }
@@ -677,7 +671,6 @@ class MorphoMidnight {
677
671
  }
678
672
  }
679
673
  const midnight = (0, morpho_ts_1.getChainAddress)(this.chainId, "midnight");
680
- const signedPayloads = new Map();
681
674
  return {
682
675
  groups: data.groups,
683
676
  root: data.tree.root,
@@ -702,7 +695,6 @@ class MorphoMidnight {
702
695
  }),
703
696
  ...(await this.getRatifierRequirements({
704
697
  offersData: data,
705
- signedPayloads,
706
698
  })),
707
699
  ];
708
700
  return requirements;
@@ -710,7 +702,6 @@ class MorphoMidnight {
710
702
  buildTx: (signatures) => this.buildSubmitOffersTx({
711
703
  offersData: data,
712
704
  signatures,
713
- signedPayloads,
714
705
  }),
715
706
  };
716
707
  }
@@ -910,6 +901,18 @@ class MorphoMidnight {
910
901
  requirements.push(authorization);
911
902
  if (data.ratifierType === "ecrecover") {
912
903
  const chainId = this.chainId;
904
+ // The offer-tree EIP-712 payload is signed over the tree, not the signer, so it is fully
905
+ // determined at build time and stored on the action for external signing.
906
+ const treeTypedData = midnight_sdk_1.EcrecoverRatifierUtils.typedData({
907
+ tree: data.tree,
908
+ chainId,
909
+ });
910
+ const typedData = (0, morpho_ts_1.deepFreeze)({
911
+ domain: treeTypedData.domain,
912
+ types: treeTypedData.types,
913
+ primaryType: treeTypedData.primaryType,
914
+ message: treeTypedData.message,
915
+ });
913
916
  const action = {
914
917
  type: "midnightOfferRootSignature",
915
918
  args: {
@@ -917,32 +920,23 @@ class MorphoMidnight {
917
920
  ratifier: data.ratifier,
918
921
  offers: data.tree.offers.length,
919
922
  },
923
+ typedData,
920
924
  };
921
925
  requirements.push({
922
926
  action,
923
927
  async sign(client, userAddress) {
924
- const typedData = midnight_sdk_1.EcrecoverRatifierUtils.typedData({
925
- tree: data.tree,
926
- chainId,
927
- });
928
- const typedDataDefinition = {
929
- domain: typedData.domain,
930
- types: typedData.types,
931
- primaryType: typedData.primaryType,
932
- message: typedData.message,
933
- };
934
928
  const signature = await (0, signAndVerifyTypedData_js_1.signAndVerifyTypedData)({
935
929
  client,
936
930
  userAddress,
937
- typedData: typedDataDefinition,
931
+ typedData,
938
932
  });
933
+ // Derive the ratification payload `buildTx()` submits.
939
934
  const items = await midnight_sdk_1.EcrecoverRatifierUtils.ratify({
940
935
  tree: data.tree,
941
936
  account: userAddress,
942
937
  signature,
943
938
  });
944
939
  const payload = await midnight_sdk_1.Payload.encode(items);
945
- params.signedPayloads.set(signature.toLowerCase(), payload);
946
940
  return (0, morpho_ts_1.deepFreeze)({
947
941
  args: {
948
942
  owner: userAddress,
@@ -1010,11 +1004,13 @@ class MorphoMidnight {
1010
1004
  actualOffers: signature.action.args.offers,
1011
1005
  });
1012
1006
  }
1013
- const signedPayload = params.signedPayloads.get(signature.args.signature.toLowerCase());
1014
- if (signedPayload == null) {
1007
+ // The payload is carried on the signature the caller hands to buildTx, so
1008
+ // a prepared offer-root requirement can be signed on one instance and
1009
+ // submitted from another without sharing in-memory state.
1010
+ if (signature.args.payload == null) {
1015
1011
  throw new index_js_4.UnpreparedMidnightOfferRootSignatureError();
1016
1012
  }
1017
- payload = signedPayload;
1013
+ payload = signature.args.payload;
1018
1014
  }
1019
1015
  else {
1020
1016
  (0, index_js_4.selectRequirementSignatures)(collectedSignatures, {});
@@ -22,7 +22,7 @@ export interface GetBundlesTokenRequirementsParams {
22
22
  readonly supportDeployless?: boolean;
23
23
  /** Prefer ERC-2612 when the token exposes a compatible nonce. */
24
24
  readonly useSimplePermit?: boolean;
25
- /** Explicit unused Permit2 SignatureTransfer unordered nonce. */
25
+ /** Explicit unused uint256 nonce; defaults to the lowest unused nonce found via getUnusedPermit2Nonce. */
26
26
  readonly permit2Nonce?: bigint;
27
27
  }
28
28
  /**
@@ -31,8 +31,8 @@ export interface GetBundlesTokenRequirementsParams {
31
31
  *
32
32
  * Reads only the allowance and nonce state required by the selected path. Permit2 keeps the
33
33
  * ERC-20 allowance on canonical Permit2 while the one-time signed transfer names the bundles contract
34
- * as spender. Permit2 SignatureTransfer requires an explicit unused unordered nonce so concurrent
35
- * requirements never silently sign the same owner-global nonce.
34
+ * as spender. The resolver picks the lowest unused unordered nonce by default; concurrent flows for
35
+ * the same owner should pass explicit nonces.
36
36
  *
37
37
  * @param viemClient - Connected viem client used for allowance and nonce reads.
38
38
  * @param params - Token requirement parameters.
@@ -46,7 +46,8 @@ export interface GetBundlesTokenRequirementsParams {
46
46
  * @param params.supportSignature - Whether ERC-2612 or Permit2 signatures may be requested.
47
47
  * @param params.supportDeployless - Whether ERC-2612 metadata reads may use deployless calls.
48
48
  * @param params.useSimplePermit - Prefer ERC-2612 when its nonce probe succeeds.
49
- * @param params.permit2Nonce - Explicit unused uint256 nonce required when Permit2 is selected.
49
+ * @param params.permit2Nonce - Explicit unused uint256 nonce; defaults to the lowest unused nonce
50
+ * found via {@link getUnusedPermit2Nonce}.
50
51
  * @returns Ordered deep-frozen approval transactions and/or signable token requirements.
51
52
  * @throws {ChainIdMismatchError} when the connected client targets another chain.
52
53
  * @throws {NegativeInputError} when `amount` or `permit2Nonce` is negative.
@@ -55,7 +56,8 @@ export interface GetBundlesTokenRequirementsParams {
55
56
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
56
57
  * @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's registered
57
58
  * BlueBundlesV1 or VaultBundlesV1 deployment, including for a zero-amount request.
58
- * @throws {MissingPermit2SignatureTransferNonceError} when Permit2 is selected without a nonce.
59
+ * @throws {NoUnusedPermit2NonceError} when every Permit2 nonce for the owner is consumed and none
60
+ * was passed explicitly.
59
61
  * @throws {Permit2SignatureTransferNonceAlreadyUsedError} when `permit2Nonce` is already consumed.
60
62
  * @throws {InputExceedsMaxError} when `amount`, `deadline`, or `permit2Nonce` exceeds uint256.
61
63
  * @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount` is below `amount`.
@@ -79,7 +81,6 @@ export interface GetBundlesTokenRequirementsParams {
79
81
  * chainId: mainnet.id,
80
82
  * deadline: 1_900_000_000n,
81
83
  * supportSignature: true,
82
- * permit2Nonce: 42n,
83
84
  * });
84
85
  * // requirements contains approvals and/or signable bundles token requirements.
85
86
  * ```