@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
@@ -34,7 +34,7 @@ export interface BlueBorrowParams {
34
34
  * Encodes a pure borrow through BlueBundlesV1.
35
35
  *
36
36
  * Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
37
- * penalties and referral fees reduce the assets received, and no Bundler3 action is encoded.
37
+ * penalties and referral fees reduce the assets received.
38
38
  *
39
39
  * @param params - Borrow encoding parameters.
40
40
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -53,8 +53,9 @@ export interface BlueBorrowParams {
53
53
  * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
54
54
  * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
55
55
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
56
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
56
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
57
57
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
58
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
58
59
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
59
60
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
60
61
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -4,7 +4,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
4
4
  * Encodes a pure borrow through BlueBundlesV1.
5
5
  *
6
6
  * Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
7
- * penalties and referral fees reduce the assets received, and no Bundler3 action is encoded.
7
+ * penalties and referral fees reduce the assets received.
8
8
  *
9
9
  * @param params - Borrow encoding parameters.
10
10
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -23,8 +23,9 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
23
23
  * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
24
24
  * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
25
25
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
26
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
26
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
27
27
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
28
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
28
29
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
29
30
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
30
31
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -1,10 +1,10 @@
1
1
  import { MarketParams, MathLib, VaultV2BluePublicAllocatorConfigUtils, } from "@morpho-org/blue-sdk";
2
2
  import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
3
- import { compactSignatureToSignature, isAddressEqual, parseCompactSignature, parseSignature, size, zeroAddress, zeroHash, } from "viem";
3
+ import { isAddressEqual, zeroAddress, zeroHash, } from "viem";
4
4
  import { addTransactionMetadata, validateNativeAsset, } from "../../helpers/index.js";
5
5
  import { validateVaultV2BlueReallocations } from "../../helpers/validate.js";
6
6
  import { AmbiguousRequirementSignaturesError, BundlesRequirementSignatureMismatchError, DepositOwnerMismatchError, NativeFundingAmountMismatchError, NegativeInputError, ReallocationLoanTokenMismatchError, selectRequirementSignatures, UnexpectedRequirementSignatureError, } from "../../types/index.js";
7
- import { normalizeBundlesCommonParams } from "../bundles/common.js";
7
+ import { normalizeBundlesCommonParams, normalizeBundlesSignature, } from "../bundles/common.js";
8
8
  import { getBundlesTokenPermit, } from "../bundles/index.js";
9
9
  const EMPTY_SIGNED_AUTHORIZATION = {
10
10
  signature: { v: 0, r: zeroHash, s: zeroHash },
@@ -91,33 +91,12 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
91
91
  actual: String(authorizationSignature.action.args.deadline),
92
92
  });
93
93
  }
94
- const serializedSignature = authorizationSignature.args.signature;
95
- let parsed;
96
- try {
97
- parsed =
98
- size(serializedSignature) === 64
99
- ? compactSignatureToSignature(parseCompactSignature(serializedSignature))
100
- : parseSignature(serializedSignature);
101
- }
102
- catch (cause) {
103
- throw new BundlesRequirementSignatureMismatchError({
104
- field: "signature",
105
- expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
106
- actual: serializedSignature,
107
- cause,
108
- });
109
- }
110
- const v = parsed.v ??
111
- (parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
112
- if (v == null) {
113
- throw new BundlesRequirementSignatureMismatchError({
114
- field: "signature",
115
- expected: "a signature containing v or yParity",
116
- actual: serializedSignature,
117
- });
118
- }
94
+ const signature = normalizeBundlesSignature(authorizationSignature.args.signature, (details) => new BundlesRequirementSignatureMismatchError({
95
+ field: "signature",
96
+ ...details,
97
+ }));
119
98
  return {
120
- signature: { v: Number(v), r: parsed.r, s: parsed.s },
99
+ signature,
121
100
  nonce: authorizationSignature.args.nonce,
122
101
  deadline: authorizationSignature.args.deadline,
123
102
  };
@@ -163,19 +142,11 @@ export const selectBlueBundlesV1RequirementSignatures = (signatures, accepts) =>
163
142
  permit2SignatureTransfer: accepts.token,
164
143
  authorization: accepts.authorization,
165
144
  });
166
- if (permit?.action.type === "permit2") {
167
- throw new BundlesRequirementSignatureMismatchError({
168
- field: "type",
169
- expected: "permit or permit2SignatureTransfer",
170
- actual: permit.action.type,
171
- });
172
- }
173
145
  if (permit != null && permit2SignatureTransfer != null) {
174
146
  throw new AmbiguousRequirementSignaturesError("permit", 2);
175
147
  }
176
148
  return {
177
- token: permit ??
178
- permit2SignatureTransfer,
149
+ token: permit ?? permit2SignatureTransfer,
179
150
  authorization,
180
151
  };
181
152
  };
@@ -61,9 +61,9 @@ export interface BlueRefinanceParams {
61
61
  * @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
62
62
  * @throws {NonPositiveInputError} when the deadline or a reallocation amount is not positive.
63
63
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
64
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
64
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
65
65
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
66
- * @throws {InvalidReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
66
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
67
67
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
68
68
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
69
69
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
@@ -31,9 +31,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
31
31
  * @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
32
32
  * @throws {NonPositiveInputError} when the deadline or a reallocation amount is not positive.
33
33
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
34
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
34
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
35
35
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
36
- * @throws {InvalidReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
36
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
37
37
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
38
38
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
39
39
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
@@ -67,7 +67,7 @@ export interface BlueRepayParams {
67
67
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
68
68
  * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
69
69
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
70
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
70
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
71
71
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
72
72
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
73
73
  * @example
@@ -36,7 +36,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
36
36
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
37
37
  * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
38
38
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
39
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
39
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
40
40
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
41
41
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
42
42
  * @example
@@ -43,7 +43,7 @@ export interface BlueRepayWithdrawCollateralParams {
43
43
  *
44
44
  * `maxRepayAssets` funds the live repayment plus fee and BlueBundlesV1 refunds the unused amount.
45
45
  * A saturated `repayShares = maxUint256` closes the live remaining debt. This route has no
46
- * Bundler3 share-price bound or `slippageTolerance` input.
46
+ * share-price bound or `slippageTolerance` input.
47
47
  *
48
48
  * @param params - Combined-operation encoding parameters.
49
49
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -68,7 +68,7 @@ export interface BlueRepayWithdrawCollateralParams {
68
68
  * @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
69
69
  * @throws {MaxRepayAssetsBelowRepayAssetsError} when exact-asset funding cannot cover the repayment and referral fee.
70
70
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
71
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
71
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
72
72
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
73
73
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
74
74
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -8,7 +8,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
8
8
  *
9
9
  * `maxRepayAssets` funds the live repayment plus fee and BlueBundlesV1 refunds the unused amount.
10
10
  * A saturated `repayShares = maxUint256` closes the live remaining debt. This route has no
11
- * Bundler3 share-price bound or `slippageTolerance` input.
11
+ * share-price bound or `slippageTolerance` input.
12
12
  *
13
13
  * @param params - Combined-operation encoding parameters.
14
14
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -33,7 +33,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
33
33
  * @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
34
34
  * @throws {MaxRepayAssetsBelowRepayAssetsError} when exact-asset funding cannot cover the repayment and referral fee.
35
35
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
36
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
36
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
37
37
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
38
38
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
39
39
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -32,7 +32,7 @@ export interface BlueSupplyParams {
32
32
  * Encodes a direct BlueBundlesV1 loan-asset supply transaction.
33
33
  *
34
34
  * `assets` is the gross funded amount; BlueBundlesV1 deducts the referral fee before supplying.
35
- * This route has no Bundler3 share-price bound or `slippageTolerance` input.
35
+ * This route has no share-price bound or `slippageTolerance` input.
36
36
  *
37
37
  * @param params - Supply encoding parameters.
38
38
  * @param params.market.chainId - Chain containing the BlueBundlesV1 deployment.
@@ -50,7 +50,7 @@ export interface BlueSupplyParams {
50
50
  * @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
51
51
  * @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
52
52
  * @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
53
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
53
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
54
54
  * @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
55
55
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
56
56
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -1,12 +1,13 @@
1
- import { encodeFunctionData, maxUint256 } from "viem";
1
+ import { encodeFunctionData } from "viem";
2
2
  import { blueBundlesV1Abi } from "../../abis.js";
3
- import { InputExceedsMaxError, NonPositiveInputError, } from "../../types/index.js";
3
+ import { validateUint256Field } from "../../helpers/validate.js";
4
+ import { NonPositiveInputError } from "../../types/index.js";
4
5
  import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normalizeBlueBundlesV1CommonParams, validateBlueBundlesV1NativeFunding, } from "./common.js";
5
6
  /**
6
7
  * Encodes a direct BlueBundlesV1 loan-asset supply transaction.
7
8
  *
8
9
  * `assets` is the gross funded amount; BlueBundlesV1 deducts the referral fee before supplying.
9
- * This route has no Bundler3 share-price bound or `slippageTolerance` input.
10
+ * This route has no share-price bound or `slippageTolerance` input.
10
11
  *
11
12
  * @param params - Supply encoding parameters.
12
13
  * @param params.market.chainId - Chain containing the BlueBundlesV1 deployment.
@@ -24,7 +25,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
24
25
  * @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
25
26
  * @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
26
27
  * @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
27
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
28
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
28
29
  * @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
29
30
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
30
31
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -61,13 +62,7 @@ export const blueSupply = (params) => {
61
62
  if (assets <= 0n) {
62
63
  throw new NonPositiveInputError("assets", assets);
63
64
  }
64
- if (assets > maxUint256) {
65
- throw new InputExceedsMaxError({
66
- field: "assets",
67
- value: assets,
68
- max: maxUint256,
69
- });
70
- }
65
+ validateUint256Field("assets", assets);
71
66
  const common = {
72
67
  chainId,
73
68
  userAddress,
@@ -32,7 +32,7 @@ export interface BlueSupplyCollateralParams {
32
32
  * Encodes a pure collateral supply through BlueBundlesV1.
33
33
  *
34
34
  * Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
35
- * cap. Native funding is exclusive with ERC-20 funding and no Bundler3 action is encoded.
35
+ * cap. Native funding is exclusive with ERC-20 funding.
36
36
  *
37
37
  * @param params - Collateral-supply encoding parameters.
38
38
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -59,7 +59,7 @@ export interface BlueSupplyCollateralParams {
59
59
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
60
60
  * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
61
61
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
62
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
62
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
63
63
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
64
64
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
65
65
  * @example
@@ -5,7 +5,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
5
5
  * Encodes a pure collateral supply through BlueBundlesV1.
6
6
  *
7
7
  * Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
8
- * cap. Native funding is exclusive with ERC-20 funding and no Bundler3 action is encoded.
8
+ * cap. Native funding is exclusive with ERC-20 funding.
9
9
  *
10
10
  * @param params - Collateral-supply encoding parameters.
11
11
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -32,7 +32,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
32
32
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
33
33
  * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
34
34
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
35
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
35
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
36
36
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
37
37
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
38
38
  * @example
@@ -40,7 +40,7 @@ export interface BlueSupplyCollateralBorrowParams {
40
40
  * Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
41
41
  *
42
42
  * Reallocations are Vault V2-only and require a borrow leg. Penalties and referral fees reduce
43
- * borrow proceeds. This route has no Bundler3 share-price bound or `slippageTolerance` input.
43
+ * borrow proceeds. This route has no share-price bound or `slippageTolerance` input.
44
44
  *
45
45
  * @param params - Combined-operation encoding parameters.
46
46
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -64,8 +64,9 @@ export interface BlueSupplyCollateralBorrowParams {
64
64
  * or a reallocation amount is not positive.
65
65
  * @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
66
66
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
67
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
67
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
68
68
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
69
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
69
70
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
70
71
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
71
72
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -7,7 +7,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
7
7
  * Encodes a direct BlueBundlesV1 collateral supply and/or borrow transaction.
8
8
  *
9
9
  * Reallocations are Vault V2-only and require a borrow leg. Penalties and referral fees reduce
10
- * borrow proceeds. This route has no Bundler3 share-price bound or `slippageTolerance` input.
10
+ * borrow proceeds. This route has no share-price bound or `slippageTolerance` input.
11
11
  *
12
12
  * @param params - Combined-operation encoding parameters.
13
13
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -31,8 +31,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
31
31
  * or a reallocation amount is not positive.
32
32
  * @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
33
33
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its ABI bound.
34
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
34
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
35
35
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
36
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
36
37
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
37
38
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
38
39
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -35,7 +35,7 @@ export interface BlueWithdrawParams {
35
35
  *
36
36
  * Vault V2 allocator penalties and referral fees reduce the assets received. Shares mode has no
37
37
  * saturated full-close sentinel or onchain minimum-assets guarantee, and this route has no
38
- * Bundler3 share-price bound or `slippageTolerance` input.
38
+ * share-price bound or `slippageTolerance` input.
39
39
  *
40
40
  * @param params - Withdrawal encoding parameters.
41
41
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -56,9 +56,9 @@ export interface BlueWithdrawParams {
56
56
  * @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
57
57
  * reallocation amount is provided.
58
58
  * @throws {InputExceedsMaxError} when a withdraw amount, fee, reallocation amount, or penalty exceeds its ABI bound.
59
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
59
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
60
60
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
61
- * @throws {InvalidReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
61
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
62
62
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
63
63
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
64
64
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -8,7 +8,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
8
8
  *
9
9
  * Vault V2 allocator penalties and referral fees reduce the assets received. Shares mode has no
10
10
  * saturated full-close sentinel or onchain minimum-assets guarantee, and this route has no
11
- * Bundler3 share-price bound or `slippageTolerance` input.
11
+ * share-price bound or `slippageTolerance` input.
12
12
  *
13
13
  * @param params - Withdrawal encoding parameters.
14
14
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -29,9 +29,9 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
29
29
  * @throws {NonPositiveInputError} when neither mode, no valid deadline, or a non-positive
30
30
  * reallocation amount is provided.
31
31
  * @throws {InputExceedsMaxError} when a withdraw amount, fee, reallocation amount, or penalty exceeds its ABI bound.
32
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
32
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
33
33
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
34
- * @throws {InvalidReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
34
+ * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
35
35
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
36
36
  * @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
37
37
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
@@ -32,7 +32,7 @@ export interface BlueWithdrawCollateralParams {
32
32
  * Encodes a pure collateral withdrawal through BlueBundlesV1.
33
33
  *
34
34
  * Delegates to {@link blueRepayWithdrawCollateral} with a zero repay leg. BlueBundlesV1 enforces
35
- * the supplied post-operation LTV, and no standalone Morpho or Bundler3 call is encoded.
35
+ * the supplied post-operation LTV, and no standalone Morpho call is encoded.
36
36
  *
37
37
  * @param params - Collateral-withdrawal encoding parameters.
38
38
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -50,7 +50,7 @@ export interface BlueWithdrawCollateralParams {
50
50
  * @throws {NegativeInputError} when collateral, LTV, or fee is negative.
51
51
  * @throws {NonPositiveInputError} when collateral or deadline is not positive.
52
52
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
53
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
53
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
54
54
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
55
55
  * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
56
56
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -4,7 +4,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
4
4
  * Encodes a pure collateral withdrawal through BlueBundlesV1.
5
5
  *
6
6
  * Delegates to {@link blueRepayWithdrawCollateral} with a zero repay leg. BlueBundlesV1 enforces
7
- * the supplied post-operation LTV, and no standalone Morpho or Bundler3 call is encoded.
7
+ * the supplied post-operation LTV, and no standalone Morpho call is encoded.
8
8
  *
9
9
  * @param params - Collateral-withdrawal encoding parameters.
10
10
  * @param params.market.chainId - Chain containing BlueBundlesV1.
@@ -22,7 +22,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
22
22
  * @throws {NegativeInputError} when collateral, LTV, or fee is negative.
23
23
  * @throws {NonPositiveInputError} when collateral or deadline is not positive.
24
24
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
25
- * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
25
+ * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
26
26
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
27
27
  * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
28
28
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -96,11 +96,12 @@ export declare const resolveBundlesFunding: (params: BundlesFundingArgs) => {
96
96
  * @param params.amount - Exact pull amount in the token's smallest unit; must match both signed amount fields.
97
97
  * @param params.requirementSignature - Optional signed ERC-2612 or Permit2 SignatureTransfer requirement; omit for allowance funding.
98
98
  * @returns An empty, ERC-2612, or Permit2 SignatureTransfer token permit.
99
- * @throws {UnexpectedRequirementSignatureError} when Permit2 AllowanceTransfer is supplied.
100
99
  * @throws {DepositOwnerMismatchError} when the signature owner differs from `userAddress`.
101
100
  * @throws {DepositAssetMismatchError} when the signed token differs from `token`.
102
101
  * @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
103
102
  * @throws {DepositSpenderMismatchError} when the signed spender differs from `spender`.
103
+ * @throws {UnsupportedRequirementSignatureError} when the signature's action type is neither
104
+ * "permit" nor "permit2SignatureTransfer".
104
105
  * @throws {BundlesRequirementSignatureMismatchError} when signature metadata is malformed.
105
106
  * @example
106
107
  * ```ts
@@ -123,8 +124,21 @@ export declare const getBundlesTokenPermit: (params: {
123
124
  readonly amount: bigint;
124
125
  readonly requirementSignature?: TokenRequirementSignature;
125
126
  }) => BundlesTokenPermit;
126
- /** @internal Normalizes a compact or serialized ECDSA signature for bundles permit tuples. */
127
- export declare const normalizeBundlesSignature: (serializedSignature: Hex) => {
127
+ /**
128
+ * Normalizes a compact or serialized ECDSA signature for bundles permit tuples.
129
+ *
130
+ * @internal
131
+ *
132
+ * @param serializedSignature - Compact or serialized ECDSA signature.
133
+ * @param onInvalid - Error factory used when parsing or extracting the recovery identifier fails.
134
+ * @returns The normalized signature tuple.
135
+ * @throws {BundlesPermitMismatchError} when the signature is malformed.
136
+ */
137
+ export declare const normalizeBundlesSignature: (serializedSignature: Hex, onInvalid?: (details: {
138
+ readonly expected: string;
139
+ readonly actual: Hex;
140
+ readonly cause?: unknown;
141
+ }) => Error) => {
128
142
  readonly v: number;
129
143
  readonly r: Hex;
130
144
  readonly s: Hex;
@@ -140,7 +154,10 @@ export declare const normalizeBundlesSignature: (serializedSignature: Hex) => {
140
154
  * @param params.amount - Optional exact share allowance in the vault share token's smallest unit.
141
155
  * @param params.requirementSignature - Optional signed ERC-2612 share requirement; omit for the empty-permit sentinel.
142
156
  * @returns The signed share permit or the contract's empty-permit sentinel.
143
- * @throws {BundlesPermitMismatchError} when the requirement kind, token, or signature is invalid.
157
+ * @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
158
+ * @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
159
+ * @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount or
160
+ * deadline, or signature is invalid.
144
161
  * @example
145
162
  * ```ts
146
163
  * import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
@@ -188,6 +205,23 @@ export declare const selectBundlesSharesRequirementSignature: (signatures: reado
188
205
  readonly requiredShareAllowance: bigint | undefined;
189
206
  readonly expectedRequirement?: PermitAction;
190
207
  }) => Erc2612RequirementSignature | undefined;
208
+ /**
209
+ * Selects the ERC-2612 vault-share permit for one exit from its immutable operation fields alone.
210
+ *
211
+ * @internal
212
+ *
213
+ * @param signatures - Signatures passed to the operation's `buildTx` function.
214
+ * @param expected - Immutable spender, amount, and deadline required by the operation.
215
+ * @returns The matching ERC-2612 signature, or `undefined` when no signature is supplied.
216
+ * @throws {BundlesPermitMismatchError} when the signature is not ERC-2612 or its spender, amount or
217
+ * deadline differ from the operation's. The nonce is not checked here: it is onchain state the
218
+ * vault's `permit` verifies at execution.
219
+ */
220
+ export declare const selectBundlesSharesPermitSignature: (signatures: readonly RequirementSignature[] | undefined, expected: {
221
+ readonly spender: Address;
222
+ readonly amount: bigint;
223
+ readonly deadline: bigint;
224
+ }) => Erc2612RequirementSignature | undefined;
191
225
  /** @internal Returns the exact referral fee deducted from a fixed gross asset amount. */
192
226
  export declare const getBundlesReferralFeeAssets: (assets: bigint, referralFeePct: bigint) => bigint;
193
227
  /** @internal Finalizes a direct VaultBundlesV1 transaction with metadata and immutable action data. */