@morpho-org/morpho-sdk 10.1.0-next.0 → 10.2.0

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 (580) hide show
  1. package/README.md +6 -2
  2. package/lib/cjs/abis.d.ts +1 -1
  3. package/lib/cjs/abis.js +1 -5
  4. package/lib/cjs/actions/blue/borrow.d.ts +13 -4
  5. package/lib/cjs/actions/blue/borrow.internal.d.ts +13 -0
  6. package/lib/cjs/actions/blue/borrow.internal.js +36 -0
  7. package/lib/cjs/actions/blue/borrow.js +12 -18
  8. package/lib/cjs/actions/blue/common.d.ts +53 -28
  9. package/lib/cjs/actions/blue/common.js +36 -35
  10. package/lib/cjs/actions/blue/encode.d.ts +23 -0
  11. package/lib/cjs/actions/blue/encode.js +171 -0
  12. package/lib/cjs/actions/blue/refinance.d.ts +14 -5
  13. package/lib/cjs/actions/blue/refinance.internal.d.ts +42 -0
  14. package/lib/cjs/actions/blue/refinance.internal.js +65 -0
  15. package/lib/cjs/actions/blue/refinance.js +13 -65
  16. package/lib/cjs/actions/blue/refinanceValidation.d.ts +6 -6
  17. package/lib/cjs/actions/blue/refinanceValidation.js +10 -8
  18. package/lib/cjs/actions/blue/repay.d.ts +5 -4
  19. package/lib/cjs/actions/blue/repay.internal.d.ts +13 -0
  20. package/lib/cjs/actions/blue/repay.internal.js +38 -0
  21. package/lib/cjs/actions/blue/repay.js +5 -19
  22. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +6 -5
  23. package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
  24. package/lib/cjs/actions/blue/repayWithdrawCollateral.internal.js +112 -0
  25. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +6 -118
  26. package/lib/cjs/actions/blue/signatures.d.ts +30 -0
  27. package/lib/cjs/actions/blue/signatures.js +90 -0
  28. package/lib/cjs/actions/blue/supply.d.ts +6 -4
  29. package/lib/cjs/actions/blue/supply.internal.d.ts +32 -0
  30. package/lib/cjs/actions/blue/supply.internal.js +101 -0
  31. package/lib/cjs/actions/blue/supply.js +6 -69
  32. package/lib/cjs/actions/blue/supplyCollateral.d.ts +5 -4
  33. package/lib/cjs/actions/blue/supplyCollateral.internal.d.ts +13 -0
  34. package/lib/cjs/actions/blue/supplyCollateral.internal.js +37 -0
  35. package/lib/cjs/actions/blue/supplyCollateral.js +5 -19
  36. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +15 -6
  37. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
  38. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +98 -0
  39. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +13 -108
  40. package/lib/cjs/actions/blue/withdraw.d.ts +15 -6
  41. package/lib/cjs/actions/blue/withdraw.internal.d.ts +56 -0
  42. package/lib/cjs/actions/blue/withdraw.internal.js +87 -0
  43. package/lib/cjs/actions/blue/withdraw.js +13 -80
  44. package/lib/cjs/actions/blue/withdrawBuyCallback.d.ts +2 -2
  45. package/lib/cjs/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
  46. package/lib/cjs/actions/blue/withdrawBuyCallback.internal.js +58 -0
  47. package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -39
  48. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
  49. package/lib/cjs/actions/blue/withdrawCollateral.internal.d.ts +16 -0
  50. package/lib/cjs/actions/blue/withdrawCollateral.internal.js +39 -0
  51. package/lib/cjs/actions/blue/withdrawCollateral.js +5 -19
  52. package/lib/cjs/actions/bundles/common.d.ts +9 -0
  53. package/lib/cjs/actions/bundles/common.js +18 -6
  54. package/lib/cjs/actions/bundles/index.d.ts +1 -1
  55. package/lib/cjs/actions/bundles/index.js +3 -16
  56. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
  57. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +59 -60
  58. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +22 -1
  59. package/lib/cjs/actions/midnight/cancelAndMake.js +46 -87
  60. package/lib/cjs/actions/midnight/cancelOffers.d.ts +11 -0
  61. package/lib/cjs/actions/midnight/cancelOffers.js +22 -4
  62. package/lib/cjs/actions/midnight/encode.d.ts +36 -0
  63. package/lib/cjs/actions/midnight/encode.js +554 -0
  64. package/lib/cjs/actions/midnight/index.d.ts +14 -13
  65. package/lib/cjs/actions/midnight/index.js +29 -13
  66. package/lib/cjs/actions/midnight/parse.d.ts +35 -0
  67. package/lib/cjs/actions/midnight/parse.js +73 -0
  68. package/lib/cjs/actions/midnight/parseCollateralBatch.d.ts +58 -0
  69. package/lib/cjs/actions/midnight/parseCollateralBatch.js +216 -0
  70. package/lib/cjs/actions/midnight/redeem.d.ts +16 -3
  71. package/lib/cjs/actions/midnight/redeem.js +22 -51
  72. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
  73. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +42 -67
  74. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +40 -5
  75. package/lib/cjs/actions/midnight/supplyCollateral.js +60 -54
  76. package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +3 -3
  77. package/lib/cjs/actions/midnight/supplyCollateralBatch.js +3 -62
  78. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
  79. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +39 -67
  80. package/lib/cjs/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
  81. package/lib/cjs/actions/midnight/supplyCollateralWithNative.js +142 -0
  82. package/lib/cjs/actions/midnight/takeBorrow.d.ts +17 -2
  83. package/lib/cjs/actions/midnight/takeBorrow.js +25 -56
  84. package/lib/cjs/actions/midnight/takeLend.d.ts +21 -1
  85. package/lib/cjs/actions/midnight/takeLend.js +30 -58
  86. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
  87. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +34 -62
  88. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +17 -2
  89. package/lib/cjs/actions/midnight/takeWithdraw.js +77 -115
  90. package/lib/cjs/actions/midnight/withdrawCollateral.d.ts +16 -3
  91. package/lib/cjs/actions/midnight/withdrawCollateral.js +25 -56
  92. package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
  93. package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +3 -71
  94. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
  95. package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +39 -19
  96. package/lib/cjs/actions/requirements/blue/index.d.ts +1 -1
  97. package/lib/cjs/actions/requirements/blue/index.js +3 -15
  98. package/lib/cjs/actions/requirements/chainCheck.d.ts +5 -0
  99. package/lib/cjs/actions/requirements/chainCheck.js +10 -0
  100. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
  101. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +40 -27
  102. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
  103. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +36 -17
  104. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
  105. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +44 -9
  106. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
  107. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +61 -24
  108. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
  109. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +25 -4
  110. package/lib/cjs/actions/requirements/encode/index.d.ts +5 -5
  111. package/lib/cjs/actions/requirements/encode/index.js +11 -19
  112. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +26 -11
  113. package/lib/cjs/actions/requirements/getRequirementsApproval.js +40 -12
  114. package/lib/cjs/actions/requirements/index.d.ts +1 -1
  115. package/lib/cjs/actions/requirements/index.js +3 -1
  116. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
  117. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +34 -19
  118. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
  119. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +26 -12
  120. package/lib/cjs/actions/requirements/midnight/index.d.ts +2 -2
  121. package/lib/cjs/actions/requirements/midnight/index.js +5 -16
  122. package/lib/cjs/actions/vaultV1/deposit.d.ts +23 -1
  123. package/lib/cjs/actions/vaultV1/deposit.js +48 -11
  124. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +18 -1
  125. package/lib/cjs/actions/vaultV1/inKindRedeem.js +36 -16
  126. package/lib/cjs/actions/vaultV1/index.d.ts +5 -5
  127. package/lib/cjs/actions/vaultV1/index.js +11 -19
  128. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +24 -2
  129. package/lib/cjs/actions/vaultV1/migrateToV2.js +51 -12
  130. package/lib/cjs/actions/vaultV1/redeem.d.ts +22 -2
  131. package/lib/cjs/actions/vaultV1/redeem.js +30 -8
  132. package/lib/cjs/actions/vaultV1/withdraw.d.ts +21 -1
  133. package/lib/cjs/actions/vaultV1/withdraw.js +30 -8
  134. package/lib/cjs/actions/vaultV2/deposit.d.ts +23 -1
  135. package/lib/cjs/actions/vaultV2/deposit.js +48 -11
  136. package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +20 -2
  137. package/lib/cjs/actions/vaultV2/forceRedeem.js +39 -8
  138. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +25 -2
  139. package/lib/cjs/actions/vaultV2/forceWithdraw.js +38 -15
  140. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +18 -1
  141. package/lib/cjs/actions/vaultV2/inKindRedeem.js +35 -15
  142. package/lib/cjs/actions/vaultV2/index.d.ts +6 -6
  143. package/lib/cjs/actions/vaultV2/index.js +13 -20
  144. package/lib/cjs/actions/vaultV2/redeem.d.ts +22 -2
  145. package/lib/cjs/actions/vaultV2/redeem.js +30 -8
  146. package/lib/cjs/actions/vaultV2/withdraw.d.ts +21 -1
  147. package/lib/cjs/actions/vaultV2/withdraw.js +30 -8
  148. package/lib/cjs/blue/abis.d.ts +1 -1
  149. package/lib/cjs/blue/abis.js +1 -5
  150. package/lib/cjs/blue/entities.d.ts +4 -4
  151. package/lib/cjs/blue/entities.js +1 -3
  152. package/lib/cjs/blue/errors.d.ts +2 -2
  153. package/lib/cjs/blue/errors.js +1 -5
  154. package/lib/cjs/blue/fetch.d.ts +2 -2
  155. package/lib/cjs/blue/fetch.js +1 -3
  156. package/lib/cjs/blue/utils.d.ts +1 -1
  157. package/lib/cjs/blue/utils.js +1 -2
  158. package/lib/cjs/constants.d.ts +1 -1
  159. package/lib/cjs/constants.js +2 -0
  160. package/lib/cjs/entities/blue/blue.d.ts +118 -28
  161. package/lib/cjs/entities/blue/blue.js +503 -416
  162. package/lib/cjs/entities/index.d.ts +4 -4
  163. package/lib/cjs/entities/index.js +1 -3
  164. package/lib/cjs/entities/midnight/midnight.d.ts +117 -41
  165. package/lib/cjs/entities/midnight/midnight.js +472 -843
  166. package/lib/cjs/entities/midnight/parse.d.ts +74 -0
  167. package/lib/cjs/entities/midnight/parse.js +336 -0
  168. package/lib/cjs/entities/midnight/prepare.d.ts +47 -0
  169. package/lib/cjs/entities/midnight/prepare.js +293 -0
  170. package/lib/cjs/entities/midnight/publication.d.ts +7 -3
  171. package/lib/cjs/entities/midnight/publication.js +10 -7
  172. package/lib/cjs/entities/midnight/types.d.ts +7 -0
  173. package/lib/cjs/entities/requirements/assertContractCode.d.ts +10 -5
  174. package/lib/cjs/entities/requirements/assertContractCode.js +24 -15
  175. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
  176. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +59 -51
  177. package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -3
  178. package/lib/cjs/entities/requirements/getErc2612Permit.js +20 -4
  179. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
  180. package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +24 -7
  181. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
  182. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +27 -7
  183. package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
  184. package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
  185. package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
  186. package/lib/cjs/entities/requirements/index.d.ts +2 -2
  187. package/lib/cjs/entities/requirements/index.js +5 -16
  188. package/lib/cjs/entities/requirements/validateNativeRequirements.d.ts +21 -0
  189. package/lib/cjs/entities/requirements/validateNativeRequirements.js +37 -0
  190. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
  191. package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +1 -7
  192. package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
  193. package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
  194. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +29 -46
  195. package/lib/cjs/entities/vaultV1/vaultV1.js +234 -159
  196. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
  197. package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +9 -4
  198. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
  199. package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +1 -7
  200. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -92
  201. package/lib/cjs/entities/vaultV2/vaultV2.js +230 -188
  202. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +13 -5
  203. package/lib/cjs/entities/vaultV2BlueReallocationData.js +21 -27
  204. package/lib/cjs/errors.d.ts +4 -4
  205. package/lib/cjs/errors.js +5 -7
  206. package/lib/cjs/fetch.d.ts +2 -2
  207. package/lib/cjs/fetch.js +1 -3
  208. package/lib/cjs/helpers/constant.d.ts +2 -0
  209. package/lib/cjs/helpers/constant.js +3 -1
  210. package/lib/cjs/helpers/deadShares.js +0 -3
  211. package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
  212. package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
  213. package/lib/cjs/helpers/index.d.ts +1 -1
  214. package/lib/cjs/helpers/index.js +2 -1
  215. package/lib/cjs/helpers/parse.d.ts +33 -0
  216. package/lib/cjs/helpers/parse.js +71 -0
  217. package/lib/cjs/helpers/parseMidnight.d.ts +48 -0
  218. package/lib/cjs/helpers/parseMidnight.js +95 -0
  219. package/lib/cjs/helpers/parseMidnightMaker.d.ts +44 -0
  220. package/lib/cjs/helpers/parseMidnightMaker.js +154 -0
  221. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
  222. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
  223. package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
  224. package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
  225. package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
  226. package/lib/cjs/helpers/reallocationPenalty.js +32 -0
  227. package/lib/cjs/helpers/referralFee.d.ts +2 -1
  228. package/lib/cjs/helpers/referralFee.js +5 -1
  229. package/lib/cjs/helpers/validate.d.ts +34 -6
  230. package/lib/cjs/helpers/validate.js +52 -9
  231. package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
  232. package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
  233. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
  234. package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +4 -4
  235. package/lib/cjs/helpers/validateMidnightPublication.d.ts +17 -1
  236. package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
  237. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
  238. package/lib/cjs/index.d.ts +1 -0
  239. package/lib/cjs/midnight/errors.d.ts +1 -2
  240. package/lib/cjs/midnight/errors.js +4 -5
  241. package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
  242. package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
  243. package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
  244. package/lib/cjs/transactionPlan/blue/refinance.js +36 -11
  245. package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
  246. package/lib/cjs/transactionPlan/blue/repay.js +3 -3
  247. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
  248. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +35 -7
  249. package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
  250. package/lib/cjs/transactionPlan/blue/supply.js +1 -2
  251. package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
  252. package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
  253. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
  254. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
  255. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +17 -7
  256. package/lib/cjs/transactionPlan/blue/withdraw.js +28 -9
  257. package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
  258. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +17 -9
  259. package/lib/cjs/transactionPlan/deposit.js +4 -0
  260. package/lib/cjs/transactionPlan/intent.d.ts +1 -1
  261. package/lib/cjs/transactionPlan/intent.js +4 -2
  262. package/lib/cjs/transactionPlan/plan.d.ts +8 -4
  263. package/lib/cjs/transactionPlan/plan.js +8 -4
  264. package/lib/cjs/transactionPlan/types.d.ts +6 -0
  265. package/lib/cjs/transactionPlan/validation.d.ts +1 -1
  266. package/lib/cjs/transactionPlan/validation.js +3 -0
  267. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +5 -5
  268. package/lib/cjs/transactionPlan/vaultv1/deposit.js +5 -5
  269. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
  270. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
  271. package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
  272. package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
  273. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
  274. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
  275. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
  276. package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
  277. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
  278. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
  279. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
  280. package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
  281. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
  282. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
  283. package/lib/cjs/types/action.d.ts +13 -2
  284. package/lib/cjs/types/error.d.ts +27 -8
  285. package/lib/cjs/types/error.js +42 -12
  286. package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
  287. package/lib/cjs/utils.d.ts +2 -2
  288. package/lib/cjs/utils.js +2 -4
  289. package/lib/cjs/version.d.ts +1 -1
  290. package/lib/cjs/version.js +1 -1
  291. package/lib/esm/abis.d.ts +1 -1
  292. package/lib/esm/abis.js +1 -1
  293. package/lib/esm/actions/blue/borrow.d.ts +13 -4
  294. package/lib/esm/actions/blue/borrow.internal.d.ts +13 -0
  295. package/lib/esm/actions/blue/borrow.internal.js +31 -0
  296. package/lib/esm/actions/blue/borrow.js +12 -18
  297. package/lib/esm/actions/blue/common.d.ts +53 -28
  298. package/lib/esm/actions/blue/common.js +36 -34
  299. package/lib/esm/actions/blue/encode.d.ts +23 -0
  300. package/lib/esm/actions/blue/encode.js +164 -0
  301. package/lib/esm/actions/blue/refinance.d.ts +14 -5
  302. package/lib/esm/actions/blue/refinance.internal.d.ts +42 -0
  303. package/lib/esm/actions/blue/refinance.internal.js +59 -0
  304. package/lib/esm/actions/blue/refinance.js +13 -65
  305. package/lib/esm/actions/blue/refinanceValidation.d.ts +6 -6
  306. package/lib/esm/actions/blue/refinanceValidation.js +11 -9
  307. package/lib/esm/actions/blue/repay.d.ts +5 -4
  308. package/lib/esm/actions/blue/repay.internal.d.ts +13 -0
  309. package/lib/esm/actions/blue/repay.internal.js +33 -0
  310. package/lib/esm/actions/blue/repay.js +5 -19
  311. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +6 -5
  312. package/lib/esm/actions/blue/repayWithdrawCollateral.internal.d.ts +61 -0
  313. package/lib/esm/actions/blue/repayWithdrawCollateral.internal.js +104 -0
  314. package/lib/esm/actions/blue/repayWithdrawCollateral.js +6 -118
  315. package/lib/esm/actions/blue/signatures.d.ts +30 -0
  316. package/lib/esm/actions/blue/signatures.js +82 -0
  317. package/lib/esm/actions/blue/supply.d.ts +6 -4
  318. package/lib/esm/actions/blue/supply.internal.d.ts +32 -0
  319. package/lib/esm/actions/blue/supply.internal.js +95 -0
  320. package/lib/esm/actions/blue/supply.js +6 -69
  321. package/lib/esm/actions/blue/supplyCollateral.d.ts +5 -4
  322. package/lib/esm/actions/blue/supplyCollateral.internal.d.ts +13 -0
  323. package/lib/esm/actions/blue/supplyCollateral.internal.js +32 -0
  324. package/lib/esm/actions/blue/supplyCollateral.js +5 -19
  325. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +15 -6
  326. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +65 -0
  327. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +91 -0
  328. package/lib/esm/actions/blue/supplyCollateralBorrow.js +13 -108
  329. package/lib/esm/actions/blue/withdraw.d.ts +15 -6
  330. package/lib/esm/actions/blue/withdraw.internal.d.ts +56 -0
  331. package/lib/esm/actions/blue/withdraw.internal.js +80 -0
  332. package/lib/esm/actions/blue/withdraw.js +13 -80
  333. package/lib/esm/actions/blue/withdrawBuyCallback.d.ts +2 -2
  334. package/lib/esm/actions/blue/withdrawBuyCallback.internal.d.ts +20 -0
  335. package/lib/esm/actions/blue/withdrawBuyCallback.internal.js +53 -0
  336. package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -39
  337. package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
  338. package/lib/esm/actions/blue/withdrawCollateral.internal.d.ts +16 -0
  339. package/lib/esm/actions/blue/withdrawCollateral.internal.js +34 -0
  340. package/lib/esm/actions/blue/withdrawCollateral.js +5 -19
  341. package/lib/esm/actions/bundles/common.d.ts +9 -0
  342. package/lib/esm/actions/bundles/common.js +15 -4
  343. package/lib/esm/actions/bundles/index.d.ts +1 -1
  344. package/lib/esm/actions/bundles/index.js +1 -1
  345. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +14 -0
  346. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +58 -61
  347. package/lib/esm/actions/midnight/cancelAndMake.d.ts +22 -1
  348. package/lib/esm/actions/midnight/cancelAndMake.js +43 -85
  349. package/lib/esm/actions/midnight/cancelOffers.d.ts +11 -0
  350. package/lib/esm/actions/midnight/cancelOffers.js +18 -2
  351. package/lib/esm/actions/midnight/encode.d.ts +36 -0
  352. package/lib/esm/actions/midnight/encode.js +539 -0
  353. package/lib/esm/actions/midnight/index.d.ts +14 -13
  354. package/lib/esm/actions/midnight/index.js +14 -13
  355. package/lib/esm/actions/midnight/parse.d.ts +35 -0
  356. package/lib/esm/actions/midnight/parse.js +68 -0
  357. package/lib/esm/actions/midnight/parseCollateralBatch.d.ts +58 -0
  358. package/lib/esm/actions/midnight/parseCollateralBatch.js +209 -0
  359. package/lib/esm/actions/midnight/redeem.d.ts +16 -3
  360. package/lib/esm/actions/midnight/redeem.js +20 -50
  361. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +13 -0
  362. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +38 -64
  363. package/lib/esm/actions/midnight/supplyCollateral.d.ts +40 -5
  364. package/lib/esm/actions/midnight/supplyCollateral.js +57 -53
  365. package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +3 -3
  366. package/lib/esm/actions/midnight/supplyCollateralBatch.js +3 -62
  367. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +24 -0
  368. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +34 -63
  369. package/lib/esm/actions/midnight/supplyCollateralWithNative.d.ts +77 -0
  370. package/lib/esm/actions/midnight/supplyCollateralWithNative.js +137 -0
  371. package/lib/esm/actions/midnight/takeBorrow.d.ts +17 -2
  372. package/lib/esm/actions/midnight/takeBorrow.js +21 -53
  373. package/lib/esm/actions/midnight/takeLend.d.ts +21 -1
  374. package/lib/esm/actions/midnight/takeLend.js +27 -56
  375. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -2
  376. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +31 -60
  377. package/lib/esm/actions/midnight/takeWithdraw.d.ts +17 -2
  378. package/lib/esm/actions/midnight/takeWithdraw.js +76 -115
  379. package/lib/esm/actions/midnight/withdrawCollateral.d.ts +16 -3
  380. package/lib/esm/actions/midnight/withdrawCollateral.js +23 -55
  381. package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +3 -3
  382. package/lib/esm/actions/midnight/withdrawCollateralBatch.js +3 -71
  383. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +13 -0
  384. package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +36 -18
  385. package/lib/esm/actions/requirements/blue/index.d.ts +1 -1
  386. package/lib/esm/actions/requirements/blue/index.js +1 -1
  387. package/lib/esm/actions/requirements/chainCheck.d.ts +5 -0
  388. package/lib/esm/actions/requirements/chainCheck.js +6 -0
  389. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -0
  390. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +36 -25
  391. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +11 -1
  392. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +33 -16
  393. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +14 -1
  394. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +41 -8
  395. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +10 -0
  396. package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +59 -24
  397. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +10 -0
  398. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +21 -2
  399. package/lib/esm/actions/requirements/encode/index.d.ts +5 -5
  400. package/lib/esm/actions/requirements/encode/index.js +5 -5
  401. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +26 -11
  402. package/lib/esm/actions/requirements/getRequirementsApproval.js +38 -12
  403. package/lib/esm/actions/requirements/index.d.ts +1 -1
  404. package/lib/esm/actions/requirements/index.js +1 -1
  405. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +11 -0
  406. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +31 -18
  407. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -0
  408. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +22 -10
  409. package/lib/esm/actions/requirements/midnight/index.d.ts +2 -2
  410. package/lib/esm/actions/requirements/midnight/index.js +2 -2
  411. package/lib/esm/actions/vaultV1/deposit.d.ts +23 -1
  412. package/lib/esm/actions/vaultV1/deposit.js +45 -10
  413. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +18 -1
  414. package/lib/esm/actions/vaultV1/inKindRedeem.js +33 -15
  415. package/lib/esm/actions/vaultV1/index.d.ts +5 -5
  416. package/lib/esm/actions/vaultV1/index.js +5 -5
  417. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +24 -2
  418. package/lib/esm/actions/vaultV1/migrateToV2.js +49 -12
  419. package/lib/esm/actions/vaultV1/redeem.d.ts +22 -2
  420. package/lib/esm/actions/vaultV1/redeem.js +28 -8
  421. package/lib/esm/actions/vaultV1/withdraw.d.ts +21 -1
  422. package/lib/esm/actions/vaultV1/withdraw.js +28 -8
  423. package/lib/esm/actions/vaultV2/deposit.d.ts +23 -1
  424. package/lib/esm/actions/vaultV2/deposit.js +45 -10
  425. package/lib/esm/actions/vaultV2/forceRedeem.d.ts +20 -2
  426. package/lib/esm/actions/vaultV2/forceRedeem.js +35 -6
  427. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +25 -2
  428. package/lib/esm/actions/vaultV2/forceWithdraw.js +35 -14
  429. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +18 -1
  430. package/lib/esm/actions/vaultV2/inKindRedeem.js +32 -14
  431. package/lib/esm/actions/vaultV2/index.d.ts +6 -6
  432. package/lib/esm/actions/vaultV2/index.js +6 -6
  433. package/lib/esm/actions/vaultV2/redeem.d.ts +22 -2
  434. package/lib/esm/actions/vaultV2/redeem.js +28 -8
  435. package/lib/esm/actions/vaultV2/withdraw.d.ts +21 -1
  436. package/lib/esm/actions/vaultV2/withdraw.js +28 -8
  437. package/lib/esm/blue/abis.d.ts +1 -1
  438. package/lib/esm/blue/abis.js +1 -1
  439. package/lib/esm/blue/entities.d.ts +4 -4
  440. package/lib/esm/blue/entities.js +2 -2
  441. package/lib/esm/blue/errors.d.ts +2 -2
  442. package/lib/esm/blue/errors.js +2 -2
  443. package/lib/esm/blue/fetch.d.ts +2 -2
  444. package/lib/esm/blue/fetch.js +2 -2
  445. package/lib/esm/blue/utils.d.ts +1 -1
  446. package/lib/esm/blue/utils.js +1 -1
  447. package/lib/esm/constants.d.ts +1 -1
  448. package/lib/esm/constants.js +1 -1
  449. package/lib/esm/entities/blue/blue.d.ts +118 -28
  450. package/lib/esm/entities/blue/blue.js +485 -398
  451. package/lib/esm/entities/index.d.ts +4 -4
  452. package/lib/esm/entities/index.js +2 -2
  453. package/lib/esm/entities/midnight/midnight.d.ts +117 -41
  454. package/lib/esm/entities/midnight/midnight.js +455 -826
  455. package/lib/esm/entities/midnight/parse.d.ts +74 -0
  456. package/lib/esm/entities/midnight/parse.js +320 -0
  457. package/lib/esm/entities/midnight/prepare.d.ts +47 -0
  458. package/lib/esm/entities/midnight/prepare.js +282 -0
  459. package/lib/esm/entities/midnight/publication.d.ts +7 -3
  460. package/lib/esm/entities/midnight/publication.js +7 -3
  461. package/lib/esm/entities/midnight/types.d.ts +7 -0
  462. package/lib/esm/entities/requirements/assertContractCode.d.ts +10 -5
  463. package/lib/esm/entities/requirements/assertContractCode.js +24 -15
  464. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +15 -0
  465. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +53 -47
  466. package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -3
  467. package/lib/esm/entities/requirements/getErc2612Permit.js +19 -4
  468. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +15 -0
  469. package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +20 -5
  470. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +14 -0
  471. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +23 -5
  472. package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +4 -3
  473. package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +4 -3
  474. package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +4 -3
  475. package/lib/esm/entities/requirements/index.d.ts +2 -2
  476. package/lib/esm/entities/requirements/index.js +2 -2
  477. package/lib/esm/entities/requirements/validateNativeRequirements.d.ts +21 -0
  478. package/lib/esm/entities/requirements/validateNativeRequirements.js +33 -0
  479. package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +2 -2
  480. package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +1 -7
  481. package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
  482. package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
  483. package/lib/esm/entities/vaultV1/vaultV1.d.ts +29 -46
  484. package/lib/esm/entities/vaultV1/vaultV1.js +214 -139
  485. package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +4 -0
  486. package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +10 -5
  487. package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +2 -2
  488. package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +1 -7
  489. package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -92
  490. package/lib/esm/entities/vaultV2/vaultV2.js +214 -172
  491. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +13 -5
  492. package/lib/esm/entities/vaultV2BlueReallocationData.js +19 -25
  493. package/lib/esm/errors.d.ts +4 -4
  494. package/lib/esm/errors.js +4 -4
  495. package/lib/esm/fetch.d.ts +2 -2
  496. package/lib/esm/fetch.js +2 -2
  497. package/lib/esm/helpers/constant.d.ts +2 -0
  498. package/lib/esm/helpers/constant.js +2 -0
  499. package/lib/esm/helpers/deadShares.js +1 -4
  500. package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
  501. package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
  502. package/lib/esm/helpers/index.d.ts +1 -1
  503. package/lib/esm/helpers/index.js +1 -1
  504. package/lib/esm/helpers/parse.d.ts +33 -0
  505. package/lib/esm/helpers/parse.js +61 -0
  506. package/lib/esm/helpers/parseMidnight.d.ts +48 -0
  507. package/lib/esm/helpers/parseMidnight.js +80 -0
  508. package/lib/esm/helpers/parseMidnightMaker.d.ts +44 -0
  509. package/lib/esm/helpers/parseMidnightMaker.js +147 -0
  510. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
  511. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
  512. package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
  513. package/lib/esm/helpers/quoteBlueRepay.js +21 -8
  514. package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
  515. package/lib/esm/helpers/reallocationPenalty.js +28 -0
  516. package/lib/esm/helpers/referralFee.d.ts +2 -1
  517. package/lib/esm/helpers/referralFee.js +5 -1
  518. package/lib/esm/helpers/validate.d.ts +34 -6
  519. package/lib/esm/helpers/validate.js +52 -11
  520. package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
  521. package/lib/esm/helpers/validateMidnightBounds.js +1 -2
  522. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +8 -0
  523. package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +2 -2
  524. package/lib/esm/helpers/validateMidnightPublication.d.ts +17 -1
  525. package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
  526. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
  527. package/lib/esm/index.d.ts +1 -0
  528. package/lib/esm/midnight/errors.d.ts +1 -2
  529. package/lib/esm/midnight/errors.js +1 -2
  530. package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
  531. package/lib/esm/transactionPlan/blue/borrow.js +27 -9
  532. package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
  533. package/lib/esm/transactionPlan/blue/refinance.js +37 -12
  534. package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
  535. package/lib/esm/transactionPlan/blue/repay.js +4 -4
  536. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
  537. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +36 -8
  538. package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
  539. package/lib/esm/transactionPlan/blue/supply.js +1 -2
  540. package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
  541. package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
  542. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
  543. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +25 -8
  544. package/lib/esm/transactionPlan/blue/withdraw.d.ts +17 -7
  545. package/lib/esm/transactionPlan/blue/withdraw.js +28 -9
  546. package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
  547. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +17 -9
  548. package/lib/esm/transactionPlan/deposit.js +5 -1
  549. package/lib/esm/transactionPlan/intent.d.ts +1 -1
  550. package/lib/esm/transactionPlan/intent.js +4 -2
  551. package/lib/esm/transactionPlan/plan.d.ts +8 -4
  552. package/lib/esm/transactionPlan/plan.js +8 -4
  553. package/lib/esm/transactionPlan/types.d.ts +6 -0
  554. package/lib/esm/transactionPlan/validation.d.ts +1 -1
  555. package/lib/esm/transactionPlan/validation.js +3 -0
  556. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +5 -5
  557. package/lib/esm/transactionPlan/vaultv1/deposit.js +5 -5
  558. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
  559. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
  560. package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
  561. package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
  562. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
  563. package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
  564. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
  565. package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
  566. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
  567. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
  568. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
  569. package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
  570. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
  571. package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
  572. package/lib/esm/types/action.d.ts +13 -2
  573. package/lib/esm/types/error.d.ts +27 -8
  574. package/lib/esm/types/error.js +38 -10
  575. package/lib/esm/types/sharedLiquidity.d.ts +7 -2
  576. package/lib/esm/utils.d.ts +2 -2
  577. package/lib/esm/utils.js +2 -2
  578. package/lib/esm/version.d.ts +1 -1
  579. package/lib/esm/version.js +1 -1
  580. package/package.json +7 -7
@@ -1,4 +1,4 @@
1
- import { type AccrualPosition, type Market, type MarketParams } from "@morpho-org/blue-sdk";
1
+ import { type AccrualPosition, type Market, MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Address } from "viem";
3
3
  import type { FetchParameters } from "../../types/data.js";
4
4
  import { type ActionOutput, type ActionRequirement, type AssetsOrSharesArgs, type BlueBorrowAction, type BlueRefinanceAction, type BlueRepayAction, type BlueRepayWithdrawCollateralAction, type BlueSupplyAction, type BlueSupplyCollateralAction, type BlueSupplyCollateralBorrowAction, type BlueWithdrawAction, type BlueWithdrawBuyCallbackAction, type BlueWithdrawCollateralAction, type MorphoClientType, type ReferenceTimestampParams, type RequirementSignature, type VaultV2BluePublicAllocatorOptions, type VaultV2BlueReallocation } from "../../types/index.js";
@@ -82,7 +82,7 @@ export interface BlueActions {
82
82
  * @param params.collateralAssets - Gross collateral assets supplied.
83
83
  * @param params.nativeAmount - Optional full native funding equal to `collateralAssets`.
84
84
  * @param params.deadline - Final call deadline in Unix seconds.
85
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
85
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
86
86
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
87
87
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen transaction.
88
88
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -93,8 +93,9 @@ export interface BlueActions {
93
93
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
94
94
  * @throws {ChainWNativeMissingError} when native funding is requested without registered wNative.
95
95
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
96
- * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
97
96
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
97
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
98
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
98
99
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
99
100
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
100
101
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
@@ -156,7 +157,7 @@ export interface BlueActions {
156
157
  * @param params.assets - Gross loan-token assets funded before the referral fee.
157
158
  * @param params.nativeAmount - Optional full native funding; must equal `assets` and requires wNative.
158
159
  * @param params.deadline - Final call deadline in Unix seconds.
159
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
160
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
160
161
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
161
162
  * @returns Lazy prerequisite resolution and a synchronous deep-frozen transaction builder.
162
163
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -167,8 +168,10 @@ export interface BlueActions {
167
168
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
168
169
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
169
170
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
170
- * @throws {InputExceedsMaxError} when `assets` or `deadline` exceeds `uint256`, when the referral fee is at least WAD.
171
+ * @throws {InputExceedsMaxError} when `assets` or `deadline` exceeds `uint256`.
171
172
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
173
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
174
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
172
175
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
173
176
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when the route cannot consume a supplied signature.
174
177
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
@@ -245,23 +248,30 @@ export interface BlueActions {
245
248
  * @param params.assets - Exact assets withdrawn, exclusive with `shares`.
246
249
  * @param params.shares - Exact shares burned, exclusive with `assets`.
247
250
  * @param params.reallocations - Optional Vault V2 reallocations executed before withdrawal.
251
+ * @param params.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
248
252
  * @param params.deadline - Final call deadline in Unix seconds.
249
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
253
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
250
254
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
251
255
  * @returns Lazy authorization resolution and a synchronous deep-frozen transaction builder.
256
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
252
257
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
253
258
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
254
259
  * @throws {ExpiredDeadlineError} when the deadline is stale.
255
260
  * @throws {MissingAccrualPositionError} when no position snapshot is provided at runtime.
256
- * @throws {MarketIdMismatchError} when `positionData` belongs to another market.
261
+ * @throws {MarketIdMismatchError} when `positionData` belongs to another market, or a
262
+ * reallocation source market's `id` does not hash from its tuple fields.
257
263
  * @throws {AccrualPositionUserMismatchError} when `positionData` belongs to another user.
258
264
  * @throws {NegativeInputError} when an amount, referral fee, or reallocation penalty is negative.
265
+ * Also thrown when maxPenalty is negative.
259
266
  * @throws {NonPositiveInputError} when no withdrawal mode or positive reallocation amount is provided.
260
267
  * @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
261
268
  * @throws {WithdrawExceedsSupplyError} when assets exceed the supplied balance.
262
269
  * @throws {WithdrawSharesExceedSupplyError} when shares exceed the owned balance.
263
270
  * @throws {InputExceedsMaxError} when a fee or reallocation exceeds its ABI bound.
271
+ * Also thrown when maxPenalty exceeds WAD or a reallocation penalty exceeds maxPenalty.
264
272
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
273
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
274
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
265
275
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
266
276
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
267
277
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -310,6 +320,8 @@ export interface BlueActions {
310
320
  readonly userAddress: Address;
311
321
  readonly positionData: AccrualPosition;
312
322
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
323
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
324
+ readonly maxPenalty?: bigint;
313
325
  readonly deadline: bigint;
314
326
  readonly referralFeePct?: bigint;
315
327
  readonly referralFeeRecipient?: Address;
@@ -395,23 +407,30 @@ export interface BlueActions {
395
407
  * @param params.borrowAssets - Gross loan assets borrowed before penalties and referral fees.
396
408
  * @param params.positionData - Pre-fetched position used for the health check.
397
409
  * @param params.reallocations - Optional Vault V2 reallocations before borrowing.
410
+ * @param params.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
398
411
  * @param params.deadline - Final call deadline in Unix seconds.
399
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
412
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
400
413
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
401
414
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction.
415
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
402
416
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
403
417
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
404
418
  * @throws {UnsupportedBlueMarketIrmError} when positive debt requires an unsupported IRM projection.
405
419
  * @throws {ExpiredDeadlineError} when the deadline is stale.
406
420
  * @throws {MissingAccrualPositionError} when no position snapshot is provided.
407
- * @throws {MarketIdMismatchError} when `positionData` belongs to another market.
421
+ * @throws {MarketIdMismatchError} when `positionData` belongs to another market, or a
422
+ * reallocation source market's `id` does not hash from its tuple fields.
408
423
  * @throws {AccrualPositionUserMismatchError} when `positionData` belongs to another user.
409
424
  * @throws {MissingMarketPriceError} when the health check has no oracle price.
410
425
  * @throws {BorrowExceedsSafeLtvError} when the resulting position exceeds buffered LLTV.
411
426
  * @throws {NonPositiveInputError} when `borrowAssets` is not positive.
412
427
  * @throws {NegativeInputError} when the borrow, fee, or a reallocation value is negative.
428
+ * Also thrown when maxPenalty is negative.
413
429
  * @throws {InputExceedsMaxError} when a fee, penalty, or reallocation exceeds its bound.
430
+ * Also thrown when maxPenalty exceeds WAD or a reallocation penalty exceeds maxPenalty.
414
431
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
432
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
433
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
415
434
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
416
435
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
417
436
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -459,6 +478,8 @@ export interface BlueActions {
459
478
  readonly borrowAssets: bigint;
460
479
  readonly positionData: AccrualPosition;
461
480
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
481
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
482
+ readonly maxPenalty?: bigint;
462
483
  readonly deadline: bigint;
463
484
  readonly referralFeePct?: bigint;
464
485
  readonly referralFeeRecipient?: Address;
@@ -476,7 +497,7 @@ export interface BlueActions {
476
497
  * @param params.repayShares - Exact shares, or `maxUint256` for a full repay.
477
498
  * @param params.nativeAmount - Optional full native funding equal to the derived repayment cap.
478
499
  * @param params.deadline - Final call deadline in Unix seconds.
479
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
500
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
480
501
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
481
502
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen transaction.
482
503
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -494,6 +515,8 @@ export interface BlueActions {
494
515
  * @throws {InputExceedsMaxError} when a fee is out of bounds or a share quote deadline is too far away.
495
516
  * @throws {MaxRepayAssetsBelowRepayAssetsError} when a signed share cap no longer covers the fresh quote.
496
517
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
518
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
519
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
497
520
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
498
521
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
499
522
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -565,7 +588,7 @@ export interface BlueActions {
565
588
  * @param params.positionData - Pre-fetched position used for balance and health validation.
566
589
  * @param params.collateralAssets - Collateral assets withdrawn.
567
590
  * @param params.deadline - Final call deadline in Unix seconds.
568
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
591
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
569
592
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
570
593
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction.
571
594
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -580,8 +603,9 @@ export interface BlueActions {
580
603
  * @throws {WithdrawMakesPositionUnhealthyError} when the result exceeds buffered LLTV.
581
604
  * @throws {NonPositiveInputError} when `collateralAssets` is not positive.
582
605
  * @throws {NegativeInputError} when collateral or the referral fee is negative.
583
- * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
584
606
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
607
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
608
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
585
609
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
586
610
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
587
611
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
@@ -646,7 +670,7 @@ export interface BlueActions {
646
670
  * @param params.collateralAssets - Collateral withdrawn, or zero for pure repay.
647
671
  * @param params.nativeAmount - Optional full native funding; must equal derived `maxRepayAssets`.
648
672
  * @param params.deadline - Final call deadline in Unix seconds; share mode is limited to the two-hour funding quote horizon.
649
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
673
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
650
674
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
651
675
  * @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
652
676
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -664,9 +688,11 @@ export interface BlueActions {
664
688
  * @throws {MissingMarketPriceError} when withdrawal health cannot be validated without an oracle price.
665
689
  * @throws {WithdrawMakesPositionUnhealthyError} when the post-repay withdrawal exceeds buffered LLTV.
666
690
  * @throws {ExpiredDeadlineError} when the deadline is stale.
667
- * @throws {InputExceedsMaxError} when the referral fee is at least WAD or a share-mode deadline exceeds the funding quote horizon.
691
+ * @throws {InputExceedsMaxError} when a share-mode deadline exceeds the funding quote horizon.
668
692
  * @throws {MaxRepayAssetsBelowRepayAssetsError} from `buildTx()` when a previously signed share-mode cap no longer covers the fresh derived minimum.
669
693
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
694
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
695
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
670
696
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
671
697
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
672
698
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -749,27 +775,34 @@ export interface BlueActions {
749
775
  * @param params.positionData - Pre-fetched position; required when `borrowAssets` is positive.
750
776
  * @param params.nativeAmount - Optional full native collateral funding; must equal `collateralAssets`.
751
777
  * @param params.reallocations - Optional Vault V2 reallocations; valid only for a borrow.
778
+ * @param params.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
752
779
  * @param params.deadline - Final call deadline in Unix seconds.
753
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
780
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
754
781
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
755
782
  * @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
783
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
756
784
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
757
785
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
758
786
  * @throws {UnsupportedBlueMarketIrmError} when positive debt requires an unsupported IRM projection.
759
787
  * @throws {MissingAccrualPositionError} when a borrow has no position snapshot.
760
- * @throws {MarketIdMismatchError} when `positionData` belongs to another market.
788
+ * @throws {MarketIdMismatchError} when `positionData` belongs to another market, or a
789
+ * reallocation source market's `id` does not hash from its tuple fields.
761
790
  * @throws {AccrualPositionUserMismatchError} when `positionData` belongs to another user.
762
791
  * @throws {MissingMarketPriceError} when a borrow cannot be validated without an oracle price.
763
792
  * @throws {BorrowExceedsSafeLtvError} when the resulting debt exceeds buffered LLTV.
764
793
  * @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
765
794
  * @throws {ExpiredDeadlineError} when the deadline is stale.
766
795
  * @throws {NegativeInputError} when an amount, native funding, referral fee, or reallocation penalty is negative.
796
+ * Also thrown when maxPenalty is negative.
767
797
  * @throws {NonPositiveInputError} when both legs or a reallocation amount is not positive.
768
798
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
769
799
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
770
800
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
771
801
  * @throws {InputExceedsMaxError} when a fee or reallocation exceeds its ABI bound.
802
+ * Also thrown when maxPenalty exceeds WAD or a reallocation penalty exceeds maxPenalty.
772
803
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
804
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
805
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
773
806
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
774
807
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
775
808
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -825,6 +858,8 @@ export interface BlueActions {
825
858
  readonly positionData?: AccrualPosition;
826
859
  readonly nativeAmount?: bigint;
827
860
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
861
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
862
+ readonly maxPenalty?: bigint;
828
863
  readonly deadline: bigint;
829
864
  readonly referralFeePct?: bigint;
830
865
  readonly referralFeeRecipient?: Address;
@@ -845,25 +880,32 @@ export interface BlueActions {
845
880
  * @param params.destination.marketParams - Distinct destination market with matching tokens.
846
881
  * @param params.destination.positionData - User's pre-fetched destination position.
847
882
  * @param params.reallocations - Optional Vault V2 reallocations into the destination.
883
+ * @param params.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound the total penalty added to destination debt.
848
884
  * @param params.deadline - Final call deadline in Unix seconds.
849
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
885
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
850
886
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
851
887
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction builder.
888
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
852
889
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
853
890
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
854
891
  * @throws {UnsupportedBlueMarketIrmError} when positive source or destination debt requires an unsupported IRM projection.
855
892
  * @throws {MissingAccrualPositionError} when either position snapshot is absent at runtime.
856
- * @throws {MarketIdMismatchError} when `destination.marketParams.id` does not hash from its tuple fields, or a position snapshot belongs to another market.
893
+ * @throws {MarketIdMismatchError} when a destination or reallocation source market's `id`
894
+ * does not hash from its tuple fields, or a position snapshot belongs to another market.
857
895
  * @throws {AccrualPositionUserMismatchError} when a position snapshot belongs to another user.
858
896
  * @throws {RefinanceSameMarketError} when source and destination IDs match.
859
897
  * @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
860
898
  * @throws {NegativeInputError} when a referral fee or reallocation penalty is negative.
899
+ * Also thrown when maxPenalty is negative.
861
900
  * @throws {NonPositiveInputError} when the source has no borrow shares or a reallocation amount is not positive.
862
901
  * @throws {MissingMarketPriceError} when destination health cannot be validated without an oracle price.
863
902
  * @throws {BorrowExceedsSafeLtvError} when the complete destination exceeds buffered LLTV.
864
903
  * @throws {ExpiredDeadlineError} when the deadline is stale.
865
904
  * @throws {InputExceedsMaxError} when a fee or reallocation exceeds its ABI bound.
905
+ * Also thrown when maxPenalty exceeds WAD or a reallocation penalty exceeds maxPenalty.
866
906
  * @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
907
+ * @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
908
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
867
909
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
868
910
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
869
911
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -923,6 +965,8 @@ export interface BlueActions {
923
965
  readonly positionData: AccrualPosition;
924
966
  };
925
967
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
968
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound the total penalty added to destination debt. */
969
+ readonly maxPenalty?: bigint;
926
970
  readonly deadline: bigint;
927
971
  readonly referralFeePct?: bigint;
928
972
  readonly referralFeeRecipient?: Address;
@@ -986,20 +1030,28 @@ export interface BlueActions {
986
1030
  * For `refinance`, compute the plan on the destination-market handle (for
987
1031
  * example, `client.morpho.blue(destination.marketParams, chainId)`), not the
988
1032
  * source-market handle. Pass the source position's `borrowAssets` accrued to
989
- * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
990
- * `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
1033
+ * the resolved plan expiry (or the required action deadline for entity
1034
+ * `refinance`) as `operation.amount`. With
1035
+ * `minTs = max(now, source.lastUpdate, destination.lastUpdate)`, the horizon is
1036
+ * `max(minTs, resolved expiry)`. For `prepareBlueRefinance`, omitted `expiresAt`
1037
+ * resolves to `now + 2h`, not `minTs + 2h`. Only when the resolved expiry exceeds
1038
+ * `minTs + 365 days`, use `minTs + 2h` for unlimited-deadline sentinel
1039
+ * compatibility. The optional `operation.referralFeePct` is WAD-scaled.
991
1040
  * The planner includes the referral fee and its own planned allocator-leg
992
1041
  * penalties in destination debt. Refinance never uses vaults with a 100%
993
- * penalty.
1042
+ * penalty. When executing the returned reallocations, pass the same explicit
1043
+ * maxPenalty to borrow, supplyCollateralBorrow, withdraw, or refinance.
994
1044
  *
995
1045
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
996
1046
  * @param params.options - Optional allocator discovery controls and operation to support.
997
1047
  * @returns Action-ready reallocations and their post-simulation state.
1048
+ * @throws {InvalidBigIntInputError} when options.maxPenalty is supplied but is not a bigint.
998
1049
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
999
1050
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1000
1051
  * @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
1001
1052
  * @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD, or a selected borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
1002
1053
  * @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
1054
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
1003
1055
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
1004
1056
  * @throws {UnknownReallocationMarketError} when a required market is absent.
1005
1057
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.
@@ -1029,6 +1081,7 @@ export declare class MorphoBlue implements BlueActions {
1029
1081
  private readonly client;
1030
1082
  readonly marketParams: MarketParams;
1031
1083
  private readonly chainId;
1084
+ private readonly parsedMarket;
1032
1085
  /**
1033
1086
  * Binds `client` to the market described by `marketParams` on `chainId`.
1034
1087
  *
@@ -1043,13 +1096,14 @@ export declare class MorphoBlue implements BlueActions {
1043
1096
  /**
1044
1097
  * Asserts that every registry contract this flow's transaction targets or names as
1045
1098
  * spender/authorized operator holds code, with one `eth_getCode` per distinct address
1046
- * before any other requirement read. Blue write flows probe `eth_chainId` only after a target
1047
- * has no code and report a chain mismatch when the RPC serves another chain.
1099
+ * before any other requirement read. Native-only funding validates the served chain
1100
+ * concurrently; other flows probe it here only when a target has no code.
1101
+ *
1102
+ * @param chainCheck - Chain validation shared within this operation.
1103
+ * @param nativeFundingOnly - Whether no token or authorization resolver checks the chain.
1048
1104
  */
1049
1105
  private assertWriteTargets;
1050
1106
  private getMaxLtv;
1051
- private getBlueBundlesV1QuoteTimestamp;
1052
- private quoteRepay;
1053
1107
  private getTokenRequirements;
1054
1108
  private getAuthorizationRequirements;
1055
1109
  getMarketData(parameters?: FetchParameters): Promise<Market>;
@@ -1075,11 +1129,15 @@ export declare class MorphoBlue implements BlueActions {
1075
1129
  readonly referralFeePct?: bigint;
1076
1130
  readonly referralFeeRecipient?: Address;
1077
1131
  } & ReferenceTimestampParams): ActionOutput<BlueSupplyAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1132
+ private parseSupplyParams;
1133
+ private supplyPrepared;
1078
1134
  /** {@inheritDoc BlueActions.withdraw} */
1079
1135
  withdraw(params: {
1080
1136
  readonly userAddress: Address;
1081
1137
  readonly positionData: AccrualPosition;
1082
1138
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
1139
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
1140
+ readonly maxPenalty?: bigint;
1083
1141
  readonly deadline: bigint;
1084
1142
  readonly referralFeePct?: bigint;
1085
1143
  readonly referralFeeRecipient?: Address;
@@ -1087,12 +1145,16 @@ export declare class MorphoBlue implements BlueActions {
1087
1145
  getRequirements: () => Promise<readonly ActionRequirement[]>;
1088
1146
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../index.js").Transaction<BlueWithdrawAction>>;
1089
1147
  };
1148
+ private parseWithdrawParams;
1149
+ private withdrawPrepared;
1090
1150
  /** {@inheritDoc BlueActions.withdrawBuyCallback} */
1091
1151
  withdrawBuyCallback(params: {
1092
1152
  readonly userAddress: Address;
1093
1153
  readonly callbackAddress: Address;
1094
1154
  readonly positionData: AccrualPosition;
1095
1155
  } & ReferenceTimestampParams): ActionOutput<BlueWithdrawBuyCallbackAction, undefined, undefined>;
1156
+ private parseWithdrawBuyCallbackParams;
1157
+ private withdrawBuyCallbackPrepared;
1096
1158
  /** {@inheritDoc BlueActions.supplyCollateral} */
1097
1159
  supplyCollateral(params: {
1098
1160
  readonly userAddress: Address;
@@ -1102,16 +1164,22 @@ export declare class MorphoBlue implements BlueActions {
1102
1164
  readonly referralFeePct?: bigint;
1103
1165
  readonly referralFeeRecipient?: Address;
1104
1166
  } & ReferenceTimestampParams): ActionOutput<BlueSupplyCollateralAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1167
+ private parseSupplyCollateralParams;
1168
+ private supplyCollateralPrepared;
1105
1169
  /** {@inheritDoc BlueActions.borrow} */
1106
1170
  borrow(params: {
1107
1171
  readonly userAddress: Address;
1108
1172
  readonly borrowAssets: bigint;
1109
1173
  readonly positionData: AccrualPosition;
1110
1174
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
1175
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
1176
+ readonly maxPenalty?: bigint;
1111
1177
  readonly deadline: bigint;
1112
1178
  readonly referralFeePct?: bigint;
1113
1179
  readonly referralFeeRecipient?: Address;
1114
1180
  } & ReferenceTimestampParams): ActionOutput<BlueBorrowAction, readonly RequirementSignature[], undefined>;
1181
+ private parseBorrowParams;
1182
+ private borrowPrepared;
1115
1183
  /** {@inheritDoc BlueActions.repay} */
1116
1184
  repay(params: {
1117
1185
  readonly userAddress: Address;
@@ -1127,6 +1195,8 @@ export declare class MorphoBlue implements BlueActions {
1127
1195
  readonly repayShares: bigint;
1128
1196
  readonly repayAssets?: never;
1129
1197
  })): ActionOutput<BlueRepayAction, readonly RequirementSignature[], BlueTokenRequirementsParams>;
1198
+ private parseRepayParams;
1199
+ private repayPrepared;
1130
1200
  /** {@inheritDoc BlueActions.withdrawCollateral} */
1131
1201
  withdrawCollateral(params: {
1132
1202
  readonly userAddress: Address;
@@ -1136,6 +1206,8 @@ export declare class MorphoBlue implements BlueActions {
1136
1206
  readonly referralFeePct?: bigint;
1137
1207
  readonly referralFeeRecipient?: Address;
1138
1208
  } & ReferenceTimestampParams): ActionOutput<BlueWithdrawCollateralAction, readonly RequirementSignature[], undefined>;
1209
+ private parseWithdrawCollateralParams;
1210
+ private withdrawCollateralPrepared;
1139
1211
  /** {@inheritDoc BlueActions.repayWithdrawCollateral} */
1140
1212
  repayWithdrawCollateral(params: {
1141
1213
  readonly userAddress: Address;
@@ -1158,6 +1230,8 @@ export declare class MorphoBlue implements BlueActions {
1158
1230
  getRequirements: (requirementsParams?: BlueTokenRequirementsParams) => Promise<readonly ActionRequirement[]>;
1159
1231
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../index.js").Transaction<BlueRepayWithdrawCollateralAction>>;
1160
1232
  };
1233
+ private parseRepayWithdrawCollateralParams;
1234
+ private repayWithdrawCollateralPrepared;
1161
1235
  /** {@inheritDoc BlueActions.supplyCollateralBorrow} */
1162
1236
  supplyCollateralBorrow(params: {
1163
1237
  readonly userAddress: Address;
@@ -1166,6 +1240,8 @@ export declare class MorphoBlue implements BlueActions {
1166
1240
  readonly positionData?: AccrualPosition;
1167
1241
  readonly nativeAmount?: bigint;
1168
1242
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
1243
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost. */
1244
+ readonly maxPenalty?: bigint;
1169
1245
  readonly deadline: bigint;
1170
1246
  readonly referralFeePct?: bigint;
1171
1247
  readonly referralFeeRecipient?: Address;
@@ -1173,6 +1249,8 @@ export declare class MorphoBlue implements BlueActions {
1173
1249
  getRequirements: (requirementsParams?: BlueTokenRequirementsParams) => Promise<readonly ActionRequirement[]>;
1174
1250
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../index.js").Transaction<BlueSupplyCollateralBorrowAction>>;
1175
1251
  };
1252
+ private parseSupplyCollateralBorrowParams;
1253
+ private supplyCollateralBorrowPrepared;
1176
1254
  /** {@inheritDoc BlueActions.refinance} */
1177
1255
  refinance(params: {
1178
1256
  readonly userAddress: Address;
@@ -1182,6 +1260,8 @@ export declare class MorphoBlue implements BlueActions {
1182
1260
  readonly positionData: AccrualPosition;
1183
1261
  };
1184
1262
  readonly reallocations?: Iterable<VaultV2BlueReallocation>;
1263
+ /** Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound the total penalty added to destination debt. */
1264
+ readonly maxPenalty?: bigint;
1185
1265
  readonly deadline: bigint;
1186
1266
  readonly referralFeePct?: bigint;
1187
1267
  readonly referralFeeRecipient?: Address;
@@ -1189,6 +1269,8 @@ export declare class MorphoBlue implements BlueActions {
1189
1269
  getRequirements: () => Promise<readonly ActionRequirement[]>;
1190
1270
  buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../index.js").Transaction<BlueRefinanceAction>>;
1191
1271
  };
1272
+ private parseRefinanceParams;
1273
+ private refinancePrepared;
1192
1274
  /**
1193
1275
  * Fetches Vault V2 BluePublicAllocator state for this target market.
1194
1276
  *
@@ -1267,20 +1349,28 @@ export declare class MorphoBlue implements BlueActions {
1267
1349
  * For `refinance`, compute the plan on the destination-market handle (for
1268
1350
  * example, `client.morpho.blue(destination.marketParams, chainId)`), not the
1269
1351
  * source-market handle. Pass the source position's `borrowAssets` accrued to
1270
- * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
1271
- * `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
1352
+ * the resolved plan expiry (or the required action deadline for entity
1353
+ * `refinance`) as `operation.amount`. With
1354
+ * `minTs = max(now, source.lastUpdate, destination.lastUpdate)`, the horizon is
1355
+ * `max(minTs, resolved expiry)`. For `prepareBlueRefinance`, omitted `expiresAt`
1356
+ * resolves to `now + 2h`, not `minTs + 2h`. Only when the resolved expiry exceeds
1357
+ * `minTs + 365 days`, use `minTs + 2h` for unlimited-deadline sentinel
1358
+ * compatibility. The optional `operation.referralFeePct` is WAD-scaled.
1272
1359
  * The planner includes the referral fee and its own planned allocator-leg
1273
1360
  * penalties in destination debt. Refinance never uses vaults with a 100%
1274
- * penalty.
1361
+ * penalty. When executing the returned reallocations, pass the same explicit
1362
+ * maxPenalty to borrow, supplyCollateralBorrow, withdraw, or refinance.
1275
1363
  *
1276
1364
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
1277
1365
  * @param params.options - Optional allocator discovery controls and operation to support.
1278
1366
  * @returns Action-ready reallocations and their post-simulation state.
1367
+ * @throws {InvalidBigIntInputError} when options.maxPenalty is supplied but is not a bigint.
1279
1368
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1280
1369
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1281
1370
  * @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
1282
1371
  * @throws {InputExceedsMaxError} when the allocator cap headroom, a utilization, or a penalty limit exceeds WAD, or a selected borrow/withdraw plan otherwise covers its shortfall but its planned penalty exceeds the operation amount.
1283
1372
  * @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
1373
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
1284
1374
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
1285
1375
  * @throws {UnknownReallocationMarketError} when a required market is absent.
1286
1376
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.