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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (296) hide show
  1. package/MIGRATION-v5-to-v6.md +329 -15
  2. package/README.md +93 -47
  3. package/lib/cjs/abis.d.ts +227 -2
  4. package/lib/cjs/abis.js +156 -3
  5. package/lib/cjs/actions/blue/borrow.d.ts +1 -1
  6. package/lib/cjs/actions/blue/borrow.js +1 -1
  7. package/lib/cjs/actions/blue/common.d.ts +6 -19
  8. package/lib/cjs/actions/blue/common.js +28 -162
  9. package/lib/cjs/actions/blue/refinance.d.ts +1 -1
  10. package/lib/cjs/actions/blue/refinance.js +1 -1
  11. package/lib/cjs/actions/blue/repay.d.ts +3 -3
  12. package/lib/cjs/actions/blue/repay.js +1 -1
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
  14. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
  15. package/lib/cjs/actions/blue/supply.d.ts +3 -3
  16. package/lib/cjs/actions/blue/supply.js +3 -8
  17. package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
  18. package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
  19. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
  21. package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
  22. package/lib/cjs/actions/blue/withdraw.js +1 -1
  23. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
  24. package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
  25. package/lib/cjs/actions/bundles/common.d.ts +230 -0
  26. package/lib/cjs/actions/bundles/common.js +507 -0
  27. package/lib/cjs/actions/bundles/index.d.ts +3 -0
  28. package/lib/cjs/actions/bundles/index.js +23 -0
  29. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  30. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
  31. package/lib/cjs/actions/index.d.ts +1 -0
  32. package/lib/cjs/actions/index.js +1 -0
  33. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  34. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  35. package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
  36. package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
  37. package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
  38. package/lib/cjs/actions/midnight/takeLend.js +2 -2
  39. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  40. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
  41. package/lib/cjs/actions/requirements/blue/index.d.ts +0 -2
  42. package/lib/cjs/actions/requirements/blue/index.js +0 -2
  43. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  44. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
  45. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  46. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
  47. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +19 -10
  48. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +43 -31
  49. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  50. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  51. package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
  52. package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +27 -22
  53. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
  54. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
  55. package/lib/cjs/actions/requirements/encode/index.d.ts +1 -1
  56. package/lib/cjs/actions/requirements/encode/index.js +1 -1
  57. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  58. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  59. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  60. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
  61. package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
  62. package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
  63. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +28 -30
  64. package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +20 -66
  65. package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
  66. package/lib/cjs/actions/vaultV1/deposit.js +110 -109
  67. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -0
  68. package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
  69. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
  70. package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
  71. package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
  72. package/lib/cjs/actions/vaultV1/redeem.js +56 -33
  73. package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
  74. package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
  75. package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
  76. package/lib/cjs/actions/vaultV2/deposit.js +111 -109
  77. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
  78. package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
  79. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
  80. package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
  81. package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
  82. package/lib/cjs/actions/vaultV2/redeem.js +56 -34
  83. package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
  84. package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
  85. package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  86. package/lib/cjs/blue/abis.d.ts +5 -1
  87. package/lib/cjs/blue/abis.js +2 -0
  88. package/lib/cjs/blue/entities.d.ts +8 -2
  89. package/lib/cjs/blue/entities.js +1 -0
  90. package/lib/cjs/blue/errors.d.ts +1 -1
  91. package/lib/cjs/blue/errors.js +2 -1
  92. package/lib/cjs/blue/fetch.d.ts +3 -1
  93. package/lib/cjs/blue/fetch.js +1 -0
  94. package/lib/cjs/entities/blue/blue.d.ts +29 -20
  95. package/lib/cjs/entities/blue/blue.js +6 -1
  96. package/lib/cjs/entities/index.d.ts +9 -2
  97. package/lib/cjs/entities/index.js +16 -0
  98. package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
  99. package/lib/cjs/entities/midnight/midnight.js +20 -24
  100. package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
  101. package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +76 -75
  102. package/lib/{esm/actions/requirements/blue → cjs/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
  103. package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
  104. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  105. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
  106. package/lib/cjs/entities/requirements/index.d.ts +2 -0
  107. package/lib/cjs/entities/requirements/index.js +18 -0
  108. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +356 -101
  109. package/lib/cjs/entities/vaultV1/vaultV1.js +334 -120
  110. package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
  111. package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
  112. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +359 -100
  113. package/lib/cjs/entities/vaultV2/vaultV2.js +448 -93
  114. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
  115. package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
  116. package/lib/cjs/errors.d.ts +1 -1
  117. package/lib/cjs/errors.js +3 -2
  118. package/lib/cjs/fetch.d.ts +3 -1
  119. package/lib/cjs/fetch.js +1 -0
  120. package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
  121. package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
  122. package/lib/cjs/helpers/index.d.ts +4 -1
  123. package/lib/cjs/helpers/index.js +14 -1
  124. package/lib/cjs/helpers/metadata.d.ts +3 -5
  125. package/lib/cjs/helpers/metadata.js +4 -6
  126. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  127. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
  128. package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  129. package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
  130. package/lib/cjs/helpers/referralFee.d.ts +21 -0
  131. package/lib/cjs/helpers/referralFee.js +35 -0
  132. package/lib/cjs/helpers/slippage.d.ts +136 -1
  133. package/lib/cjs/helpers/slippage.js +188 -0
  134. package/lib/cjs/helpers/validate.d.ts +67 -8
  135. package/lib/cjs/helpers/validate.js +94 -9
  136. package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
  137. package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
  138. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  139. package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
  140. package/lib/cjs/index.d.ts +1 -0
  141. package/lib/cjs/index.js +1 -0
  142. package/lib/cjs/types/action.d.ts +273 -82
  143. package/lib/cjs/types/action.js +12 -12
  144. package/lib/cjs/types/error.d.ts +349 -23
  145. package/lib/cjs/types/error.js +393 -39
  146. package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
  147. package/lib/cjs/utils.d.ts +3 -1
  148. package/lib/cjs/utils.js +10 -1
  149. package/lib/esm/abis.d.ts +227 -2
  150. package/lib/esm/abis.js +157 -2
  151. package/lib/esm/actions/blue/borrow.d.ts +1 -1
  152. package/lib/esm/actions/blue/borrow.js +1 -1
  153. package/lib/esm/actions/blue/common.d.ts +6 -19
  154. package/lib/esm/actions/blue/common.js +30 -164
  155. package/lib/esm/actions/blue/refinance.d.ts +1 -1
  156. package/lib/esm/actions/blue/refinance.js +1 -1
  157. package/lib/esm/actions/blue/repay.d.ts +3 -3
  158. package/lib/esm/actions/blue/repay.js +1 -1
  159. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
  160. package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
  161. package/lib/esm/actions/blue/supply.d.ts +3 -3
  162. package/lib/esm/actions/blue/supply.js +5 -10
  163. package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
  164. package/lib/esm/actions/blue/supplyCollateral.js +1 -1
  165. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
  166. package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
  167. package/lib/esm/actions/blue/withdraw.d.ts +1 -1
  168. package/lib/esm/actions/blue/withdraw.js +1 -1
  169. package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
  170. package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
  171. package/lib/esm/actions/bundles/common.d.ts +230 -0
  172. package/lib/esm/actions/bundles/common.js +494 -0
  173. package/lib/esm/actions/bundles/index.d.ts +3 -0
  174. package/lib/esm/actions/bundles/index.js +2 -0
  175. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
  176. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
  177. package/lib/esm/actions/index.d.ts +1 -0
  178. package/lib/esm/actions/index.js +1 -0
  179. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
  180. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
  181. package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
  182. package/lib/esm/actions/midnight/takeBorrow.js +2 -2
  183. package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
  184. package/lib/esm/actions/midnight/takeLend.js +2 -2
  185. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
  186. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
  187. package/lib/esm/actions/requirements/blue/index.d.ts +0 -2
  188. package/lib/esm/actions/requirements/blue/index.js +0 -2
  189. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
  190. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +22 -22
  191. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
  192. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
  193. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +19 -10
  194. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +44 -32
  195. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
  196. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
  197. package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
  198. package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +25 -20
  199. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
  200. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
  201. package/lib/esm/actions/requirements/encode/index.d.ts +1 -1
  202. package/lib/esm/actions/requirements/encode/index.js +1 -1
  203. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
  204. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
  205. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
  206. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
  207. package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
  208. package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
  209. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +28 -30
  210. package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +21 -67
  211. package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
  212. package/lib/esm/actions/vaultV1/deposit.js +112 -111
  213. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -0
  214. package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
  215. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
  216. package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
  217. package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
  218. package/lib/esm/actions/vaultV1/redeem.js +56 -33
  219. package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
  220. package/lib/esm/actions/vaultV1/withdraw.js +86 -34
  221. package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
  222. package/lib/esm/actions/vaultV2/deposit.js +113 -111
  223. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
  224. package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
  225. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
  226. package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
  227. package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
  228. package/lib/esm/actions/vaultV2/redeem.js +56 -34
  229. package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
  230. package/lib/esm/actions/vaultV2/withdraw.js +86 -35
  231. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
  232. package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
  233. package/lib/esm/blue/abis.d.ts +5 -1
  234. package/lib/esm/blue/abis.js +5 -1
  235. package/lib/esm/blue/entities.d.ts +8 -2
  236. package/lib/esm/blue/entities.js +3 -1
  237. package/lib/esm/blue/errors.d.ts +1 -1
  238. package/lib/esm/blue/errors.js +1 -1
  239. package/lib/esm/blue/fetch.d.ts +3 -1
  240. package/lib/esm/blue/fetch.js +3 -1
  241. package/lib/esm/entities/blue/blue.d.ts +29 -20
  242. package/lib/esm/entities/blue/blue.js +7 -2
  243. package/lib/esm/entities/index.d.ts +9 -2
  244. package/lib/esm/entities/index.js +4 -1
  245. package/lib/esm/entities/midnight/midnight.d.ts +2 -2
  246. package/lib/esm/entities/midnight/midnight.js +20 -24
  247. package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
  248. package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +67 -66
  249. package/lib/{cjs/actions/requirements/blue → esm/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
  250. package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
  251. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
  252. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
  253. package/lib/esm/entities/requirements/index.d.ts +2 -0
  254. package/lib/esm/entities/requirements/index.js +2 -0
  255. package/lib/esm/entities/vaultV1/vaultV1.d.ts +356 -101
  256. package/lib/esm/entities/vaultV1/vaultV1.js +338 -124
  257. package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
  258. package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
  259. package/lib/esm/entities/vaultV2/vaultV2.d.ts +359 -100
  260. package/lib/esm/entities/vaultV2/vaultV2.js +452 -97
  261. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
  262. package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
  263. package/lib/esm/errors.d.ts +1 -1
  264. package/lib/esm/errors.js +1 -1
  265. package/lib/esm/fetch.d.ts +3 -1
  266. package/lib/esm/fetch.js +3 -1
  267. package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
  268. package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
  269. package/lib/esm/helpers/index.d.ts +4 -1
  270. package/lib/esm/helpers/index.js +4 -1
  271. package/lib/esm/helpers/metadata.d.ts +3 -5
  272. package/lib/esm/helpers/metadata.js +4 -6
  273. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
  274. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
  275. package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
  276. package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
  277. package/lib/esm/helpers/referralFee.d.ts +21 -0
  278. package/lib/esm/helpers/referralFee.js +31 -0
  279. package/lib/esm/helpers/slippage.d.ts +136 -1
  280. package/lib/esm/helpers/slippage.js +186 -2
  281. package/lib/esm/helpers/validate.d.ts +67 -8
  282. package/lib/esm/helpers/validate.js +92 -10
  283. package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
  284. package/lib/esm/helpers/validateRequirementSpender.js +1 -0
  285. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
  286. package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
  287. package/lib/esm/index.d.ts +1 -0
  288. package/lib/esm/index.js +1 -0
  289. package/lib/esm/types/action.d.ts +273 -82
  290. package/lib/esm/types/action.js +11 -11
  291. package/lib/esm/types/error.d.ts +349 -23
  292. package/lib/esm/types/error.js +377 -31
  293. package/lib/esm/types/sharedLiquidity.d.ts +2 -2
  294. package/lib/esm/utils.d.ts +3 -1
  295. package/lib/esm/utils.js +3 -1
  296. package/package.json +7 -7
@@ -1,54 +1,105 @@
1
- import { vaultV2Abi } from "@morpho-org/blue-sdk-viem";
2
- import { deepFreeze } from "@morpho-org/morpho-ts";
1
+ import { getChainAddress } from "@morpho-org/morpho-ts";
3
2
  import { encodeFunctionData } from "viem";
4
- import { addTransactionMetadata } from "../../helpers/index.js";
3
+ import { vaultBundlesV1Abi } from "../../abis.js";
4
+ import { validateUint256Field } from "../../helpers/validate.js";
5
5
  import { NonPositiveInputError, } from "../../types/index.js";
6
+ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBundlesSharesPermit, normalizeBundlesCommonParams, } from "../bundles/common.js";
6
7
  /**
7
- * Prepares a withdraw transaction for a VaultV2 contract.
8
+ * Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
8
9
  *
9
- * Direct vault call — not routed through the bundler. Withdraw has no inflation-attack surface,
10
- * so skipping the bundler avoids an unnecessary approval and keeps the UX clean.
10
+ * This low-level builder does not bind `permit.value` to a share cap; use
11
+ * `MorphoVaultV2.withdraw().buildTx()` to validate it against the cap from `getRequirements()`.
11
12
  *
12
- * @param params.vault.address - The VaultV2 address.
13
- * @param params.args.amount - Amount of underlying assets to withdraw.
14
- * @param params.args.recipient - Address that receives the withdrawn assets.
15
- * @param params.args.onBehalf - Address whose shares are burned.
16
- * @param params.metadata - Optional analytics metadata attached to the transaction.
17
- * @returns A deep-frozen `Transaction<VaultV2WithdrawAction>` with `to`, `value`, `data`, and the
18
- * typed `action` discriminator the simulation layer consumes.
19
- * @throws {NonPositiveInputError} when `amount <= 0n`.
13
+ * @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
14
+ * @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
15
+ * @param params.args.amount - Positive gross withdrawal in underlying asset base units, before fees.
16
+ * @param params.args.userAddress - Share owner and transaction sender; receives the net withdrawn assets.
17
+ * @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
18
+ * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
19
+ * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
20
+ * and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
21
+ * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
22
+ * The fee is rounded down and deducted from the gross withdrawn assets.
23
+ * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
24
+ * when `referralFeePct > 0n`.
25
+ * @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
26
+ * execution reverts. This pure builder does not check the current time.
27
+ * @param params.metadata - Optional analytics metadata appended to the transaction calldata.
28
+ * @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
29
+ * @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
30
+ * @returns A deep-frozen `Transaction<VaultV2WithdrawAction>` targeting VaultBundlesV1, with
31
+ * `to`, `value: 0n`, `data`, and gross/fee/net withdrawal action metadata.
32
+ * @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
33
+ * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
34
+ * @throws {NegativeInputError} when `referralFeePct` is negative.
35
+ * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
36
+ * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
37
+ * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
38
+ * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
39
+ * @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
40
+ * @throws {viem.BaseError} when transaction encoding fails.
20
41
  * @example
21
42
  * ```ts
22
43
  * import { vaultV2Withdraw } from "@morpho-org/morpho-sdk";
44
+ * import type { Address } from "viem";
45
+ * import { mainnet } from "viem/chains";
23
46
  *
24
- * const tx = vaultV2Withdraw({
25
- * vault: { address: vaultAddress },
26
- * args: { amount: 500_000n, recipient, onBehalf },
27
- * });
28
- * // tx satisfies Readonly<Transaction<VaultV2WithdrawAction>>
47
+ * export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
48
+ * const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
49
+ * // Set the exact vault-share allowance before submitting; the entity API derives that cap.
50
+ * const tx = vaultV2Withdraw({
51
+ * vault: { chainId: mainnet.id, address: vault },
52
+ * args: { amount: 1_000_000n, userAddress, deadline },
53
+ * });
54
+ * // tx satisfies Readonly<Transaction<VaultV2WithdrawAction>>
55
+ * return tx;
56
+ * }
29
57
  * ```
30
58
  */
31
- export const vaultV2Withdraw = ({ vault: { address: vaultAddress }, args: { amount, recipient, onBehalf }, metadata, }) => {
32
- if (amount <= 0n) {
33
- throw new NonPositiveInputError("amount", amount);
59
+ export const vaultV2Withdraw = (params) => {
60
+ if (params.args.amount <= 0n) {
61
+ throw new NonPositiveInputError("amount", params.args.amount);
34
62
  }
35
- let tx = {
36
- to: vaultAddress,
63
+ // Validate the ABI bound before encoding to preserve the SDK's typed errors.
64
+ validateUint256Field("amount", params.args.amount);
65
+ const common = normalizeBundlesCommonParams(params.args);
66
+ const spender = getChainAddress(params.vault.chainId, "bundles.vaultBundlesV1");
67
+ const sharesPermit = getBundlesSharesPermit({
68
+ vault: params.vault.address,
69
+ deadline: common.deadline,
70
+ owner: params.args.userAddress,
71
+ spender,
72
+ requirementSignature: params.args.requirementSignature,
73
+ });
74
+ const referralFeeAssets = getBundlesReferralFeeAssets(params.args.amount, common.referralFeePct);
75
+ return finalizeVaultBundlesV1Transaction({
76
+ chainId: params.vault.chainId,
77
+ value: 0n,
37
78
  data: encodeFunctionData({
38
- abi: vaultV2Abi,
39
- functionName: "withdraw",
40
- args: [amount, recipient, onBehalf],
79
+ abi: vaultBundlesV1Abi,
80
+ functionName: "vaultBundlesV1Withdraw",
81
+ args: [
82
+ params.vault.address,
83
+ params.args.amount,
84
+ 0n,
85
+ sharesPermit,
86
+ common.referralFeePct,
87
+ common.referralFeeRecipient,
88
+ common.deadline,
89
+ ],
41
90
  }),
42
- value: 0n,
43
- };
44
- if (metadata) {
45
- tx = addTransactionMetadata(tx, metadata);
46
- }
47
- return deepFreeze({
48
- ...tx,
49
91
  action: {
50
92
  type: "vaultV2Withdraw",
51
- args: { vault: vaultAddress, amount, recipient },
93
+ args: {
94
+ vault: params.vault.address,
95
+ amount: params.args.amount,
96
+ referralFeePct: common.referralFeePct,
97
+ referralFeeRecipient: common.referralFeeRecipient,
98
+ referralFeeAssets,
99
+ netAssets: params.args.amount - referralFeeAssets,
100
+ deadline: common.deadline,
101
+ },
52
102
  },
103
+ metadata: params.metadata,
53
104
  });
54
105
  };
@@ -2,7 +2,10 @@ import { VaultMarketPublicAllocatorConfig as BlueVaultMarketPublicAllocatorConfi
2
2
  import { fetchVaultMarketPublicAllocatorConfig } from "@morpho-org/blue-sdk-viem";
3
3
  declare module "@morpho-org/blue-sdk" {
4
4
  namespace VaultMarketPublicAllocatorConfig {
5
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/fetch`. */
5
6
  let fetch: typeof fetchVaultMarketPublicAllocatorConfig;
6
7
  }
7
8
  }
8
- export { BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
9
+ export {
10
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/entities`. */
11
+ BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
@@ -2,4 +2,6 @@ import { VaultMarketPublicAllocatorConfig as BlueVaultMarketPublicAllocatorConfi
2
2
  import { fetchVaultMarketPublicAllocatorConfig } from "@morpho-org/blue-sdk-viem";
3
3
  BlueVaultMarketPublicAllocatorConfig.fetch =
4
4
  fetchVaultMarketPublicAllocatorConfig;
5
- export { BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
5
+ export {
6
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/entities`. */
7
+ BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
@@ -1,2 +1,6 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
3
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
4
+ publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi,
5
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
6
+ vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
@@ -1,2 +1,6 @@
1
1
  export { marketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi, publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi, vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
2
+ export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
3
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
4
+ publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi,
5
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
6
+ vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
@@ -1,2 +1,8 @@
1
- export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, 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";
2
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, 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, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig,
2
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BlueMarketPublicAllocatorConfig`. */
3
+ IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType,
4
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BluePublicAllocatorConfig`. */
5
+ VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
6
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
7
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
8
+ VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1 +1,3 @@
1
- export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
1
+ export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
2
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
3
+ VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
@@ -1,2 +1,2 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
2
2
  export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1,2 +1,2 @@
1
- export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
1
+ export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
2
2
  export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
@@ -1 +1,3 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
2
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
3
+ fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -1 +1,3 @@
1
- export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
1
+ export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
2
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
3
+ fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
@@ -30,7 +30,7 @@ type VaultV2BlueReallocationsParams = {
30
30
  export interface BlueTokenRequirementsParams {
31
31
  /** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
32
32
  readonly useSimplePermit?: boolean;
33
- /** Explicit unused Permit2 SignatureTransfer unordered nonce. */
33
+ /** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
34
34
  readonly permit2Nonce?: bigint;
35
35
  /**
36
36
  * Classic ERC-20 allowance to set when an approval is needed, enabling a reusable approval (for
@@ -77,15 +77,15 @@ export interface BlueActions {
77
77
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
78
78
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
79
79
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
80
- * @throws {MissingPermit2TransferFromNonceError} from `getRequirements()` when Permit2 is selected without a nonce.
81
- * @throws {Permit2TransferFromNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
80
+ * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
81
+ * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
82
82
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
83
83
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
84
84
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
85
85
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the collateral token.
86
86
  * @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `collateralAssets`.
87
87
  * @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
88
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
88
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
89
89
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
90
90
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
91
91
  * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or token metadata read fails.
@@ -141,8 +141,8 @@ export interface BlueActions {
141
141
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
142
142
  * @throws {InputExceedsMaxError} when `assets` or `deadline` exceeds `uint256`, when the referral fee is at least WAD, or from `getRequirements()` when an explicit `permit2Nonce` exceeds `uint256`.
143
143
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
144
- * @throws {MissingPermit2TransferFromNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
145
- * @throws {Permit2TransferFromNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
144
+ * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
145
+ * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
146
146
  * @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic `approvalAmount` is below the funded `assets`.
147
147
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
148
148
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when the route cannot consume a supplied signature.
@@ -150,7 +150,7 @@ export interface BlueActions {
150
150
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
151
151
  * @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `assets`.
152
152
  * @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
153
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
153
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
154
154
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
155
155
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
156
156
  * @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, or token metadata read fails.
@@ -221,7 +221,7 @@ export interface BlueActions {
221
221
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
222
222
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-authorization signature is supplied.
223
223
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
224
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
224
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
225
225
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
226
226
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
227
227
  * @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
@@ -295,7 +295,7 @@ export interface BlueActions {
295
295
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
296
296
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
297
297
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
298
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
298
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
299
299
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
300
300
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
301
301
  * @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
@@ -350,6 +350,7 @@ export interface BlueActions {
350
350
  * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
351
351
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
352
352
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen transaction.
353
+ * @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
353
354
  * @throws {ChainIdMismatchError} when the client targets another chain.
354
355
  * @throws {ExpiredDeadlineError} when the deadline is stale.
355
356
  * @throws {MissingAccrualPositionError} when no position snapshot is provided.
@@ -366,15 +367,15 @@ export interface BlueActions {
366
367
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
367
368
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
368
369
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
369
- * @throws {MissingPermit2TransferFromNonceError} from `getRequirements()` when Permit2 is selected without a nonce.
370
- * @throws {Permit2TransferFromNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
370
+ * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
371
+ * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
371
372
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
372
373
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an authorization signature is supplied.
373
374
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
374
375
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
375
376
  * @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from the derived funding cap.
376
377
  * @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
377
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
378
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
378
379
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
379
380
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
380
381
  * @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or token metadata read fails.
@@ -447,7 +448,7 @@ export interface BlueActions {
447
448
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
448
449
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
449
450
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
450
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
451
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
451
452
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
452
453
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
453
454
  * @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
@@ -508,6 +509,7 @@ export interface BlueActions {
508
509
  * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
509
510
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
510
511
  * @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
512
+ * @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
511
513
  * @throws {ChainIdMismatchError} when the client targets another chain.
512
514
  * @throws {MissingAccrualPositionError} when no position snapshot is provided at runtime.
513
515
  * @throws {MarketIdMismatchError} when `positionData` belongs to another market.
@@ -527,15 +529,15 @@ export interface BlueActions {
527
529
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
528
530
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
529
531
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
530
- * @throws {MissingPermit2TransferFromNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
531
- * @throws {Permit2TransferFromNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
532
+ * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
533
+ * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
532
534
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
533
535
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
534
536
  * @throws {DepositOwnerMismatchError} from `buildTx()` when a signed owner differs from `userAddress`.
535
537
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the loan token.
536
538
  * @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from the derived funding cap.
537
539
  * @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
538
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
540
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
539
541
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
540
542
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
541
543
  * @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, token metadata, or authorization read fails.
@@ -625,15 +627,15 @@ export interface BlueActions {
625
627
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
626
628
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
627
629
  * @throws {ReallocationLoanTokenMismatchError} when a source uses another loan token.
628
- * @throws {MissingPermit2TransferFromNonceError} from `getRequirements()` when Permit2 is selected without an explicit nonce.
629
- * @throws {Permit2TransferFromNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
630
+ * @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
631
+ * @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
630
632
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
631
633
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
632
634
  * @throws {DepositOwnerMismatchError} from `buildTx()` when a signed owner differs from `userAddress`.
633
635
  * @throws {DepositAssetMismatchError} from `buildTx()` when the signed asset differs from the collateral token.
634
636
  * @throws {DepositAmountMismatchError} from `buildTx()` when the signed amount differs from `collateralAssets`.
635
637
  * @throws {DepositSpenderMismatchError} from `buildTx()` when the signed spender is not BlueBundlesV1.
636
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
638
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when a signature cannot be encoded safely.
637
639
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
638
640
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
639
641
  * @throws {viem.BaseError} from `getRequirements()` when a required allowance, nonce, token metadata, or authorization read fails.
@@ -692,6 +694,7 @@ export interface BlueActions {
692
694
  * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
693
695
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
694
696
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction builder.
697
+ * @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
695
698
  * @throws {ChainIdMismatchError} when the client targets another chain.
696
699
  * @throws {MissingAccrualPositionError} when either position snapshot is absent at runtime.
697
700
  * @throws {MarketIdMismatchError} when a position snapshot belongs to another market.
@@ -714,7 +717,7 @@ export interface BlueActions {
714
717
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
715
718
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-authorization signature is supplied.
716
719
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
717
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
720
+ * @throws {BundlesRequirementSignatureMismatchError} from `buildTx()` when authorization cannot be encoded safely.
718
721
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
719
722
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
720
723
  * @throws {viem.BaseError} from `getRequirements()` when authorization reads fail.
@@ -857,6 +860,7 @@ export interface BlueActions {
857
860
  * Pass the fetched block timestamp to compute reallocations at the same block.
858
861
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
859
862
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
863
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
860
864
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
861
865
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds the target market supply.
862
866
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
@@ -883,6 +887,7 @@ export interface BlueActions {
883
887
  * @param params.options - Optional allocator and utilization options.
884
888
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
885
889
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
890
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
886
891
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
887
892
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
888
893
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
@@ -906,6 +911,7 @@ export interface BlueActions {
906
911
  * @param params.options - Optional allocator discovery controls and operation to support.
907
912
  * @returns Action-ready reallocations and their post-simulation state.
908
913
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
914
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
909
915
  * @throws {NegativeInputError} when a utilization or penalty limit is negative.
910
916
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
911
917
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
@@ -1181,6 +1187,7 @@ export declare class MorphoBlue implements BlueActions {
1181
1187
  * @param params.options - Optional allocator and utilization options.
1182
1188
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
1183
1189
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
1190
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1184
1191
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
1185
1192
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
1186
1193
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
@@ -1207,6 +1214,7 @@ export declare class MorphoBlue implements BlueActions {
1207
1214
  * @param params.options - Optional allocator and utilization options.
1208
1215
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
1209
1216
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1217
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1210
1218
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
1211
1219
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
1212
1220
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
@@ -1230,6 +1238,7 @@ export declare class MorphoBlue implements BlueActions {
1230
1238
  * @param params.options - Optional allocator discovery controls and operation to support.
1231
1239
  * @returns Action-ready reallocations and their post-simulation state.
1232
1240
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1241
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1233
1242
  * @throws {NegativeInputError} when a utilization or penalty limit is negative.
1234
1243
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
1235
1244
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
@@ -3,9 +3,10 @@ import { fetchAccrualPosition, fetchAccrualVaultV2, fetchMarket, fetchPosition,
3
3
  import { getChainAddress, Time } from "@morpho-org/morpho-ts";
4
4
  import { getAddress, isAddressEqual, maxUint256 } from "viem";
5
5
  import { getBlueBundlesV1PenaltyAssets, getBlueBundlesV1PublicAllocations, getBlueBundlesV1ReferralFeeAssets, normalizeBlueBundlesV1CommonParams, selectBlueBundlesV1RequirementSignatures, validateBlueBundlesV1NativeFunding, } from "../../actions/blue/common.js";
6
- import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral, getBlueAuthorizationRequirement, getBlueBundlesV1TokenRequirements, } from "../../actions/index.js";
6
+ import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral, getBlueAuthorizationRequirement, } from "../../actions/index.js";
7
7
  import { computeVaultV1Reallocations, DEFAULT_LLTV_BUFFER, MAX_TOKEN_APPROVALS, validateAccrualPosition, validateChainId, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateWithdrawAmount, validateWithdrawShares, } from "../../helpers/index.js";
8
8
  import { ExpiredDeadlineError, InputExceedsMaxError, MaxRepayAssetsBelowRepayAssetsError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeInputError, NonPositiveInputError, ReallocationsRequireBorrowError, RefinanceSameMarketError, RefinanceTokenMismatchError, } from "../../types/index.js";
9
+ import { getBundlesTokenRequirements } from "../requirements/index.js";
9
10
  import { VaultV1ReallocationData } from "../vaultV1ReallocationData.js";
10
11
  import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
11
12
  export class MorphoBlue {
@@ -47,8 +48,9 @@ export class MorphoBlue {
47
48
  }
48
49
  async getTokenRequirements(params) {
49
50
  this.validateDeadline(params.deadline);
50
- return getBlueBundlesV1TokenRequirements(this.client.viemClient, {
51
+ return getBundlesTokenRequirements(this.client.viemClient, {
51
52
  token: params.token,
53
+ spender: getChainAddress(this.chainId, "bundles.blueBundlesV1"),
52
54
  amount: params.amount,
53
55
  owner: params.userAddress,
54
56
  chainId: this.chainId,
@@ -863,6 +865,7 @@ export class MorphoBlue {
863
865
  * @param params.options - Optional allocator and utilization options.
864
866
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
865
867
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
868
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
866
869
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
867
870
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
868
871
  * @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
@@ -909,6 +912,7 @@ export class MorphoBlue {
909
912
  * @param params.options - Optional allocator and utilization options.
910
913
  * @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
911
914
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
915
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
912
916
  * @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
913
917
  * @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
914
918
  * @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
@@ -934,6 +938,7 @@ export class MorphoBlue {
934
938
  * @param params.options - Optional allocator discovery controls and operation to support.
935
939
  * @returns Action-ready reallocations and their post-simulation state.
936
940
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
941
+ * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
937
942
  * @throws {NegativeInputError} when a utilization or penalty limit is negative.
938
943
  * @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
939
944
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
@@ -10,7 +10,11 @@ IPosition, IPreLiquidationParams as IBluePreLiquidationParams,
10
10
  /** @deprecated Use `IBluePreLiquidationParams` or the raw Blue subpath. */
11
11
  IPreLiquidationParams, IPreLiquidationPosition as IBluePreLiquidationPosition,
12
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";
13
+ IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig,
14
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BlueMarketPublicAllocatorConfig`. */
15
+ IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType,
16
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BluePublicAllocatorConfig`. */
17
+ VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
14
18
  export { AccrualPosition as BlueAccrualPosition,
15
19
  /** @deprecated Use `BlueAccrualPosition` or the raw Blue subpath. */
16
20
  AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket,
@@ -25,7 +29,9 @@ PreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition,
25
29
  /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
26
30
  PreLiquidationPosition, Token, User as BlueUser,
27
31
  /** @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";
32
+ User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
33
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
34
+ VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
29
35
  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
36
  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
37
  export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
@@ -62,6 +68,7 @@ TakeBorrowParams, TakeLendParams as MidnightTakeLendParams,
62
68
  /** @deprecated Use `MidnightTakeLendParams`. */
63
69
  TakeLendParams, } from "./midnight/index.js";
64
70
  export { type MidnightActionOutput, type MidnightActionSignatures, type MidnightActions, MorphoMidnight, } from "./midnight/index.js";
71
+ export * from "./requirements/index.js";
65
72
  export { MorphoVaultV1 } from "./vaultV1/index.js";
66
73
  export { type InputReallocationData, type InputVaultV1ReallocationData, ReallocationData, VaultV1ReallocationData, } from "./vaultV1ReallocationData.js";
67
74
  export { MorphoVaultV2 } from "./vaultV2/index.js";
@@ -12,10 +12,13 @@ PreLiquidationParams, PreLiquidationPosition as BluePreLiquidationPosition,
12
12
  /** @deprecated Use `BluePreLiquidationPosition` or the raw Blue subpath. */
13
13
  PreLiquidationPosition, Token, User as BlueUser,
14
14
  /** @deprecated Use `BlueUser` or the raw Blue subpath. */
15
- User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
15
+ User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
16
+ /** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
17
+ VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
16
18
  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";
17
19
  export { MorphoBlue } from "./blue/index.js";
18
20
  export { MorphoMidnight, } from "./midnight/index.js";
21
+ export * from "./requirements/index.js";
19
22
  export { MorphoVaultV1 } from "./vaultV1/index.js";
20
23
  export { ReallocationData, VaultV1ReallocationData, } from "./vaultV1ReallocationData.js";
21
24
  export { MorphoVaultV2 } from "./vaultV2/index.js";
@@ -20,8 +20,8 @@ import type { GetOffersDataParams, GetPositionDataParams, MakeLendParams, MakeOf
20
20
  * const output = midnight.takeLend({
21
21
  * accountAddress: lender,
22
22
  * marketData,
23
- * assets: BigInt(quote.data.availableAssets),
24
- * minUnits: BigInt(quote.data.availableUnits),
23
+ * assets: 1_000_000n,
24
+ * minUnits: 900_000n,
25
25
  * takeableOffers: quote.data.takeableOffers,
26
26
  * deadline: maxUint256,
27
27
  * });