@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,24 +1,11 @@
1
1
  import { MarketParams, MathLib, VaultV2BluePublicAllocatorConfigUtils, } from "@morpho-org/blue-sdk";
2
2
  import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
3
- import { compactSignatureToSignature, encodeAbiParameters, isAddressEqual, maxUint256, 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
- import { AmbiguousRequirementSignaturesError, BlueBundlesV1RequirementSignatureMismatchError, DepositAmountMismatchError, DepositAssetMismatchError, DepositOwnerMismatchError, DepositSpenderMismatchError, InputExceedsMaxError, MissingReferralFeeRecipientError, NativeFundingAmountMismatchError, NegativeInputError, NonPositiveInputError, ReallocationLoanTokenMismatchError, selectRequirementSignatures, UnexpectedRequirementSignatureError, } from "../../types/index.js";
7
- /**
8
- * BlueBundlesV1 token-permit discriminator carried in the encoded permit struct: `none` (0) skips
9
- * the pull, `erc2612` (1) is an ERC-2612 permit, `permit2TransferFrom` (2) is a Permit2
10
- * SignatureTransfer. Named so a transposed literal can't silently route a permit to the wrong branch.
11
- * @internal
12
- */
13
- const BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND = {
14
- none: 0,
15
- erc2612: 1,
16
- permit2TransferFrom: 2,
17
- };
18
- const EMPTY_TOKEN_PERMIT = {
19
- kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.none,
20
- data: "0x",
21
- };
6
+ import { AmbiguousRequirementSignaturesError, BundlesRequirementSignatureMismatchError, DepositOwnerMismatchError, NativeFundingAmountMismatchError, NegativeInputError, ReallocationLoanTokenMismatchError, selectRequirementSignatures, UnexpectedRequirementSignatureError, } from "../../types/index.js";
7
+ import { normalizeBundlesCommonParams, normalizeBundlesSignature, } from "../bundles/common.js";
8
+ import { getBundlesTokenPermit, } from "../bundles/index.js";
22
9
  const EMPTY_SIGNED_AUTHORIZATION = {
23
10
  signature: { v: 0, r: zeroHash, s: zeroHash },
24
11
  nonce: 0n,
@@ -26,35 +13,10 @@ const EMPTY_SIGNED_AUTHORIZATION = {
26
13
  };
27
14
  /** @internal */
28
15
  export const normalizeBlueBundlesV1CommonParams = (params) => {
29
- if (params.deadline <= 0n) {
30
- throw new NonPositiveInputError("deadline", params.deadline);
31
- }
32
- if (params.deadline > maxUint256) {
33
- throw new InputExceedsMaxError({
34
- field: "deadline",
35
- value: params.deadline,
36
- max: maxUint256,
37
- });
38
- }
39
- const referralFeePct = params.referralFeePct ?? 0n;
40
- if (referralFeePct < 0n) {
41
- throw new NegativeInputError("referralFeePct", referralFeePct);
42
- }
43
- if (referralFeePct >= MathLib.WAD) {
44
- throw new InputExceedsMaxError({
45
- field: "referralFeePct",
46
- value: referralFeePct,
47
- max: MathLib.WAD - 1n,
48
- });
49
- }
50
- if (referralFeePct > 0n &&
51
- (params.referralFeeRecipient == null ||
52
- isAddressEqual(params.referralFeeRecipient, zeroAddress))) {
53
- throw new MissingReferralFeeRecipientError();
54
- }
16
+ const normalized = normalizeBundlesCommonParams(params);
55
17
  return {
56
- referralFeePct,
57
- referralFeeRecipient: params.referralFeeRecipient ?? zeroAddress,
18
+ referralFeePct: normalized.referralFeePct,
19
+ referralFeeRecipient: normalized.referralFeeRecipient,
58
20
  };
59
21
  };
60
22
  /** @internal */
@@ -76,88 +38,13 @@ export const validateBlueBundlesV1NativeFunding = (params) => {
76
38
  };
77
39
  /** @internal */
78
40
  export const getBlueBundlesV1TokenPermit = (params) => {
79
- const { requirementSignature } = params;
80
- if (requirementSignature == null)
81
- return EMPTY_TOKEN_PERMIT;
82
- const spender = getChainAddress(params.chainId, "bundles.blueBundlesV1");
83
- if (!isAddressEqual(requirementSignature.args.owner, params.userAddress)) {
84
- throw new DepositOwnerMismatchError(params.userAddress, requirementSignature.args.owner);
85
- }
86
- if (!isAddressEqual(requirementSignature.args.asset, params.token)) {
87
- throw new DepositAssetMismatchError(params.token, requirementSignature.args.asset);
88
- }
89
- if (requirementSignature.args.amount !== params.amount) {
90
- throw new DepositAmountMismatchError(params.amount, requirementSignature.args.amount);
91
- }
92
- if (!isAddressEqual(requirementSignature.action.args.spender, spender)) {
93
- throw new DepositSpenderMismatchError(spender, requirementSignature.action.args.spender);
94
- }
95
- if (requirementSignature.action.args.amount !== params.amount) {
96
- throw new DepositAmountMismatchError(params.amount, requirementSignature.action.args.amount);
97
- }
98
- if (requirementSignature.action.args.deadline !==
99
- requirementSignature.args.deadline) {
100
- throw new BlueBundlesV1RequirementSignatureMismatchError({
101
- field: "deadline",
102
- expected: String(requirementSignature.args.deadline),
103
- actual: String(requirementSignature.action.args.deadline),
104
- });
105
- }
106
- if (requirementSignature.action.type === "permit2TransferFrom") {
107
- return {
108
- kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.permit2TransferFrom,
109
- data: encodeAbiParameters([
110
- { type: "uint256", name: "nonce" },
111
- { type: "uint256", name: "deadline" },
112
- { type: "bytes", name: "signature" },
113
- ], [
114
- requirementSignature.args.nonce,
115
- requirementSignature.args.deadline,
116
- requirementSignature.args.signature,
117
- ]),
118
- };
119
- }
120
- if (requirementSignature.action.type !== "permit") {
121
- throw new BlueBundlesV1RequirementSignatureMismatchError({
122
- field: "type",
123
- expected: "permit or permit2TransferFrom",
124
- actual: requirementSignature.action.type,
125
- });
126
- }
127
- const serializedSignature = requirementSignature.args.signature;
128
- let parsed;
129
- try {
130
- parsed =
131
- size(serializedSignature) === 64
132
- ? compactSignatureToSignature(parseCompactSignature(serializedSignature))
133
- : parseSignature(serializedSignature);
134
- }
135
- catch (cause) {
136
- throw new BlueBundlesV1RequirementSignatureMismatchError({
137
- field: "signature",
138
- expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
139
- actual: serializedSignature,
140
- cause,
141
- });
142
- }
143
- const v = parsed.v ??
144
- (parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
145
- if (v == null) {
146
- throw new BlueBundlesV1RequirementSignatureMismatchError({
147
- field: "signature",
148
- expected: "a signature containing v or yParity",
149
- actual: serializedSignature,
150
- });
151
- }
152
- return {
153
- kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.erc2612,
154
- data: encodeAbiParameters([
155
- { type: "uint256", name: "deadline" },
156
- { type: "uint8", name: "v" },
157
- { type: "bytes32", name: "r" },
158
- { type: "bytes32", name: "s" },
159
- ], [requirementSignature.args.deadline, Number(v), parsed.r, parsed.s]),
160
- };
41
+ return getBundlesTokenPermit({
42
+ userAddress: params.userAddress,
43
+ token: params.token,
44
+ spender: getChainAddress(params.chainId, "bundles.blueBundlesV1"),
45
+ amount: params.amount,
46
+ requirementSignature: params.requirementSignature,
47
+ });
161
48
  };
162
49
  /** @internal */
163
50
  export const getBlueBundlesV1SignedAuthorization = (params) => {
@@ -169,28 +56,28 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
169
56
  throw new DepositOwnerMismatchError(params.userAddress, authorizationSignature.args.owner);
170
57
  }
171
58
  if (!isAddressEqual(authorizationSignature.args.authorized, authorized)) {
172
- throw new BlueBundlesV1RequirementSignatureMismatchError({
59
+ throw new BundlesRequirementSignatureMismatchError({
173
60
  field: "authorized",
174
61
  expected: authorized,
175
62
  actual: authorizationSignature.args.authorized,
176
63
  });
177
64
  }
178
65
  if (!isAddressEqual(authorizationSignature.action.args.authorized, authorized)) {
179
- throw new BlueBundlesV1RequirementSignatureMismatchError({
66
+ throw new BundlesRequirementSignatureMismatchError({
180
67
  field: "authorized",
181
68
  expected: authorized,
182
69
  actual: authorizationSignature.action.args.authorized,
183
70
  });
184
71
  }
185
72
  if (!authorizationSignature.args.isAuthorized) {
186
- throw new BlueBundlesV1RequirementSignatureMismatchError({
73
+ throw new BundlesRequirementSignatureMismatchError({
187
74
  field: "isAuthorized",
188
75
  expected: "true",
189
76
  actual: String(authorizationSignature.args.isAuthorized),
190
77
  });
191
78
  }
192
79
  if (!authorizationSignature.action.args.isAuthorized) {
193
- throw new BlueBundlesV1RequirementSignatureMismatchError({
80
+ throw new BundlesRequirementSignatureMismatchError({
194
81
  field: "isAuthorized",
195
82
  expected: "true",
196
83
  actual: String(authorizationSignature.action.args.isAuthorized),
@@ -198,39 +85,18 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
198
85
  }
199
86
  if (authorizationSignature.action.args.deadline !==
200
87
  authorizationSignature.args.deadline) {
201
- throw new BlueBundlesV1RequirementSignatureMismatchError({
88
+ throw new BundlesRequirementSignatureMismatchError({
202
89
  field: "deadline",
203
90
  expected: String(authorizationSignature.args.deadline),
204
91
  actual: String(authorizationSignature.action.args.deadline),
205
92
  });
206
93
  }
207
- const serializedSignature = authorizationSignature.args.signature;
208
- let parsed;
209
- try {
210
- parsed =
211
- size(serializedSignature) === 64
212
- ? compactSignatureToSignature(parseCompactSignature(serializedSignature))
213
- : parseSignature(serializedSignature);
214
- }
215
- catch (cause) {
216
- throw new BlueBundlesV1RequirementSignatureMismatchError({
217
- field: "signature",
218
- expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
219
- actual: serializedSignature,
220
- cause,
221
- });
222
- }
223
- const v = parsed.v ??
224
- (parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
225
- if (v == null) {
226
- throw new BlueBundlesV1RequirementSignatureMismatchError({
227
- field: "signature",
228
- expected: "a signature containing v or yParity",
229
- actual: serializedSignature,
230
- });
231
- }
94
+ const signature = normalizeBundlesSignature(authorizationSignature.args.signature, (details) => new BundlesRequirementSignatureMismatchError({
95
+ field: "signature",
96
+ ...details,
97
+ }));
232
98
  return {
233
- signature: { v: Number(v), r: parsed.r, s: parsed.s },
99
+ signature,
234
100
  nonce: authorizationSignature.args.nonce,
235
101
  deadline: authorizationSignature.args.deadline,
236
102
  };
@@ -271,24 +137,24 @@ export const getBlueBundlesV1ReferralFeeAssets = (assets, referralFeePct) => ref
271
137
  : MathLib.mulDivDown(assets, referralFeePct, MathLib.WAD - referralFeePct);
272
138
  /** @internal */
273
139
  export const selectBlueBundlesV1RequirementSignatures = (signatures, accepts) => {
274
- const { permit, permit2TransferFrom, authorization } = selectRequirementSignatures(signatures, {
140
+ const { permit, permit2SignatureTransfer, authorization } = selectRequirementSignatures(signatures, {
275
141
  permit: accepts.token,
276
- permit2TransferFrom: accepts.token,
142
+ permit2SignatureTransfer: accepts.token,
277
143
  authorization: accepts.authorization,
278
144
  });
279
145
  if (permit?.action.type === "permit2") {
280
- throw new BlueBundlesV1RequirementSignatureMismatchError({
146
+ throw new BundlesRequirementSignatureMismatchError({
281
147
  field: "type",
282
- expected: "permit or permit2TransferFrom",
148
+ expected: "permit or permit2SignatureTransfer",
283
149
  actual: permit.action.type,
284
150
  });
285
151
  }
286
- if (permit != null && permit2TransferFrom != null) {
152
+ if (permit != null && permit2SignatureTransfer != null) {
287
153
  throw new AmbiguousRequirementSignaturesError("permit", 2);
288
154
  }
289
155
  return {
290
156
  token: permit ??
291
- permit2TransferFrom,
157
+ permit2SignatureTransfer,
292
158
  authorization,
293
159
  };
294
160
  };
@@ -69,7 +69,7 @@ export interface BlueRefinanceParams {
69
69
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
70
70
  * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
71
71
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
72
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
72
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
73
73
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
74
74
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
75
75
  * @example
@@ -39,7 +39,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
39
39
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
40
40
  * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
41
41
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
42
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
42
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
43
43
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
44
44
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
45
45
  * @example
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import type { BlueBundlesV1TokenRequirementSignature, BlueRepayAction, Metadata, Transaction } from "../../types/index.js";
3
+ import type { BlueRepayAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueRepay}. */
5
5
  export interface BlueRepayParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -27,7 +27,7 @@ export interface BlueRepayParams {
27
27
  /** Recipient required when `referralFeePct` is positive. */
28
28
  readonly referralFeeRecipient?: Address;
29
29
  /** Optional loan-token ERC-2612 or Permit2 SignatureTransfer result. */
30
- readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
30
+ readonly requirementSignature?: BundlesTokenRequirementSignature;
31
31
  };
32
32
  /** Optional transaction metadata suffix. */
33
33
  readonly metadata?: Metadata;
@@ -65,7 +65,7 @@ export interface BlueRepayParams {
65
65
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
66
66
  * @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
67
67
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
68
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
68
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
69
69
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
70
70
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
71
71
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -34,7 +34,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
34
34
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
35
35
  * @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
36
36
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
37
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
37
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
38
38
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
39
39
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
40
40
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import { type AuthorizationRequirementSignature, type BlueBundlesV1TokenRequirementSignature, type BlueRepayWithdrawCollateralAction, type Metadata, type Transaction } from "../../types/index.js";
3
+ import { type AuthorizationRequirementSignature, type BlueRepayWithdrawCollateralAction, type BundlesTokenRequirementSignature, type Metadata, type Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueRepayWithdrawCollateral}. */
5
5
  export interface BlueRepayWithdrawCollateralParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -31,7 +31,7 @@ export interface BlueRepayWithdrawCollateralParams {
31
31
  /** Recipient required when `referralFeePct` is positive. */
32
32
  readonly referralFeeRecipient?: Address;
33
33
  /** Optional loan-token ERC-2612 or Permit2 SignatureTransfer result. */
34
- readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
34
+ readonly requirementSignature?: BundlesTokenRequirementSignature;
35
35
  /** Optional Morpho authorization signature for BlueBundlesV1. */
36
36
  readonly authorizationSignature?: AuthorizationRequirementSignature;
37
37
  };
@@ -77,7 +77,7 @@ export interface BlueRepayWithdrawCollateralParams {
77
77
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
78
78
  * @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
79
79
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
80
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be bound safely.
80
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
81
81
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
82
82
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
83
83
  * @example
@@ -42,7 +42,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
42
42
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
43
43
  * @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
44
44
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
45
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be bound safely.
45
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
46
46
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
47
47
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
48
48
  * @example
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import type { BlueBundlesV1TokenRequirementSignature, BlueSupplyAction, Metadata, Transaction } from "../../types/index.js";
3
+ import type { BlueSupplyAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueSupply}. */
5
5
  export interface BlueSupplyParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -23,7 +23,7 @@ export interface BlueSupplyParams {
23
23
  /** Recipient required when `referralFeePct` is positive. */
24
24
  readonly referralFeeRecipient?: Address;
25
25
  /** Optional ERC-2612 or Permit2 SignatureTransfer requirement result. */
26
- readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
26
+ readonly requirementSignature?: BundlesTokenRequirementSignature;
27
27
  };
28
28
  /** Optional transaction metadata suffix. */
29
29
  readonly metadata?: Metadata;
@@ -59,7 +59,7 @@ export interface BlueSupplyParams {
59
59
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
60
60
  * @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
61
61
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
62
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when the signature kind or encoding is invalid.
62
+ * @throws {BundlesRequirementSignatureMismatchError} when the signature kind or encoding is invalid.
63
63
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
64
64
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
65
65
  * @example
@@ -1,6 +1,7 @@
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.
@@ -33,7 +34,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
33
34
  * @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
34
35
  * @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
35
36
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
36
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when the signature kind or encoding is invalid.
37
+ * @throws {BundlesRequirementSignatureMismatchError} when the signature kind or encoding is invalid.
37
38
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
38
39
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
39
40
  * @example
@@ -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,
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import type { BlueBundlesV1TokenRequirementSignature, BlueSupplyCollateralAction, Metadata, Transaction } from "../../types/index.js";
3
+ import type { BlueSupplyCollateralAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
4
4
  /** Parameters for {@link blueSupplyCollateral}. */
5
5
  export interface BlueSupplyCollateralParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -23,7 +23,7 @@ export interface BlueSupplyCollateralParams {
23
23
  /** Recipient required when `referralFeePct` is positive. */
24
24
  readonly referralFeeRecipient?: Address;
25
25
  /** Optional collateral ERC-2612 or Permit2 SignatureTransfer result. */
26
- readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
26
+ readonly requirementSignature?: BundlesTokenRequirementSignature;
27
27
  };
28
28
  /** Optional transaction metadata suffix. */
29
29
  readonly metadata?: Metadata;
@@ -57,7 +57,7 @@ export interface BlueSupplyCollateralParams {
57
57
  * @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
58
58
  * @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
59
59
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
60
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
60
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
61
61
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
62
62
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
63
63
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -30,7 +30,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
30
30
  * @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
31
31
  * @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
32
32
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
33
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
33
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
34
34
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
35
35
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
36
36
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
@@ -1,6 +1,6 @@
1
1
  import type { MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
- import { type AuthorizationRequirementSignature, type BlueBundlesV1TokenRequirementSignature, type BlueSupplyCollateralBorrowAction, type Metadata, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
3
+ import { type AuthorizationRequirementSignature, type BlueSupplyCollateralBorrowAction, type BundlesTokenRequirementSignature, type Metadata, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
4
4
  /** Parameters for {@link blueSupplyCollateralBorrow}. */
5
5
  export interface BlueSupplyCollateralBorrowParams {
6
6
  /** Chain and scoped Morpho Blue market. */
@@ -29,7 +29,7 @@ export interface BlueSupplyCollateralBorrowParams {
29
29
  /** Recipient required when `referralFeePct` is positive. */
30
30
  readonly referralFeeRecipient?: Address;
31
31
  /** Optional collateral ERC-2612 or Permit2 SignatureTransfer result. */
32
- readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
32
+ readonly requirementSignature?: BundlesTokenRequirementSignature;
33
33
  /** Optional Morpho authorization signature for BlueBundlesV1. */
34
34
  readonly authorizationSignature?: AuthorizationRequirementSignature;
35
35
  };
@@ -78,7 +78,7 @@ export interface BlueSupplyCollateralBorrowParams {
78
78
  * @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
79
79
  * @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
80
80
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
81
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be bound safely.
81
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
82
82
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
83
83
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
84
84
  * @example
@@ -45,7 +45,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
45
45
  * @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
46
46
  * @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
47
47
  * @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
48
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be bound safely.
48
+ * @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
49
49
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
50
50
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
51
51
  * @example
@@ -64,7 +64,7 @@ export interface BlueWithdrawParams {
64
64
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
65
65
  * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
66
66
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
67
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
67
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
68
68
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
69
69
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
70
70
  * @example
@@ -37,7 +37,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
37
37
  * @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
38
38
  * @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
39
39
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
40
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
40
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
41
41
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
42
42
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
43
43
  * @example
@@ -52,7 +52,7 @@ export interface BlueWithdrawCollateralParams {
52
52
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
53
53
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
54
54
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
55
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
55
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
56
56
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
57
57
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
58
58
  * @example
@@ -24,7 +24,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
24
24
  * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
25
25
  * @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
26
26
  * @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
27
- * @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
27
+ * @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
28
28
  * @throws {UnsupportedChainIdError} when the chain is absent from the registry.
29
29
  * @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
30
30
  * @example