@morpho-org/morpho-sdk 10.1.0 → 10.3.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 (260) hide show
  1. package/README.md +126 -140
  2. package/lib/cjs/abis.d.ts +34 -0
  3. package/lib/cjs/abis.js +21 -1
  4. package/lib/cjs/actions/blue/borrow.d.ts +11 -3
  5. package/lib/cjs/actions/blue/borrow.internal.js +1 -0
  6. package/lib/cjs/actions/blue/borrow.js +8 -2
  7. package/lib/cjs/actions/blue/common.d.ts +4 -1
  8. package/lib/cjs/actions/blue/common.js +17 -3
  9. package/lib/cjs/actions/blue/refinance.d.ts +11 -3
  10. package/lib/cjs/actions/blue/refinance.internal.js +4 -1
  11. package/lib/cjs/actions/blue/refinance.js +8 -2
  12. package/lib/cjs/actions/blue/refinanceValidation.d.ts +3 -2
  13. package/lib/cjs/actions/blue/refinanceValidation.js +10 -6
  14. package/lib/cjs/actions/blue/repay.d.ts +4 -3
  15. package/lib/cjs/actions/blue/repay.js +3 -2
  16. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +4 -3
  17. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +3 -2
  18. package/lib/cjs/actions/blue/supply.d.ts +5 -3
  19. package/lib/cjs/actions/blue/supply.js +4 -2
  20. package/lib/cjs/actions/blue/supplyCollateral.d.ts +4 -3
  21. package/lib/cjs/actions/blue/supplyCollateral.js +3 -2
  22. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +11 -3
  23. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
  24. package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +5 -1
  25. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +8 -2
  26. package/lib/cjs/actions/blue/withdraw.d.ts +11 -3
  27. package/lib/cjs/actions/blue/withdraw.internal.js +4 -1
  28. package/lib/cjs/actions/blue/withdraw.js +8 -2
  29. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
  30. package/lib/cjs/actions/blue/withdrawCollateral.js +3 -2
  31. package/lib/cjs/actions/bundles/common.d.ts +2 -8
  32. package/lib/cjs/actions/bundles/common.js +8 -20
  33. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +0 -1
  34. package/lib/cjs/actions/midnight/takeBorrow.js +0 -1
  35. package/lib/cjs/actions/midnight/takeLend.js +0 -1
  36. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +0 -1
  37. package/lib/cjs/actions/midnight/takeWithdraw.js +0 -1
  38. package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -1
  39. package/lib/cjs/actions/vaultV1/deposit.js +2 -1
  40. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +3 -2
  41. package/lib/cjs/actions/vaultV1/migrateToV2.js +2 -1
  42. package/lib/cjs/actions/vaultV1/redeem.d.ts +3 -2
  43. package/lib/cjs/actions/vaultV1/redeem.js +2 -1
  44. package/lib/cjs/actions/vaultV1/withdraw.d.ts +2 -1
  45. package/lib/cjs/actions/vaultV1/withdraw.js +2 -1
  46. package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -1
  47. package/lib/cjs/actions/vaultV2/deposit.js +2 -1
  48. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +2 -1
  49. package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -1
  50. package/lib/cjs/actions/vaultV2/redeem.d.ts +3 -2
  51. package/lib/cjs/actions/vaultV2/redeem.js +2 -1
  52. package/lib/cjs/actions/vaultV2/withdraw.d.ts +2 -1
  53. package/lib/cjs/actions/vaultV2/withdraw.js +2 -1
  54. package/lib/cjs/constants.d.ts +1 -1
  55. package/lib/cjs/constants.js +2 -0
  56. package/lib/cjs/entities/blue/blue.d.ts +83 -20
  57. package/lib/cjs/entities/blue/blue.js +38 -12
  58. package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
  59. package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
  60. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -6
  61. package/lib/cjs/entities/vaultV1/vaultV1.js +6 -0
  62. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +12 -7
  63. package/lib/cjs/entities/vaultV2/vaultV2.js +4 -0
  64. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +11 -2
  65. package/lib/cjs/entities/vaultV2BlueReallocationData.js +19 -21
  66. package/lib/cjs/helpers/constant.d.ts +2 -0
  67. package/lib/cjs/helpers/constant.js +3 -1
  68. package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
  69. package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
  70. package/lib/cjs/helpers/index.d.ts +1 -1
  71. package/lib/cjs/helpers/index.js +2 -1
  72. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
  73. package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
  74. package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
  75. package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
  76. package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
  77. package/lib/cjs/helpers/reallocationPenalty.js +32 -0
  78. package/lib/cjs/helpers/referralFee.d.ts +2 -1
  79. package/lib/cjs/helpers/referralFee.js +5 -1
  80. package/lib/cjs/helpers/validate.d.ts +31 -4
  81. package/lib/cjs/helpers/validate.js +48 -9
  82. package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
  83. package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
  84. package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
  85. package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
  86. package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
  87. package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
  88. package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
  89. package/lib/cjs/transactionPlan/blue/refinance.js +20 -3
  90. package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
  91. package/lib/cjs/transactionPlan/blue/repay.js +1 -2
  92. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
  93. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
  94. package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
  95. package/lib/cjs/transactionPlan/blue/supply.js +1 -2
  96. package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
  97. package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
  98. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
  99. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
  100. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +15 -5
  101. package/lib/cjs/transactionPlan/blue/withdraw.js +25 -6
  102. package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
  103. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +11 -7
  104. package/lib/cjs/transactionPlan/deposit.js +4 -0
  105. package/lib/cjs/transactionPlan/intent.d.ts +1 -1
  106. package/lib/cjs/transactionPlan/intent.js +4 -2
  107. package/lib/cjs/transactionPlan/plan.d.ts +8 -4
  108. package/lib/cjs/transactionPlan/plan.js +8 -4
  109. package/lib/cjs/transactionPlan/types.d.ts +6 -0
  110. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +3 -3
  111. package/lib/cjs/transactionPlan/vaultv1/deposit.js +3 -3
  112. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
  113. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
  114. package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
  115. package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
  116. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
  117. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
  118. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
  119. package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
  120. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
  121. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
  122. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
  123. package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
  124. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
  125. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
  126. package/lib/cjs/types/error.d.ts +7 -6
  127. package/lib/cjs/types/error.js +10 -9
  128. package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
  129. package/lib/cjs/version.d.ts +1 -1
  130. package/lib/cjs/version.js +1 -1
  131. package/lib/esm/abis.d.ts +34 -0
  132. package/lib/esm/abis.js +20 -0
  133. package/lib/esm/actions/blue/borrow.d.ts +11 -3
  134. package/lib/esm/actions/blue/borrow.internal.js +1 -0
  135. package/lib/esm/actions/blue/borrow.js +8 -2
  136. package/lib/esm/actions/blue/common.d.ts +4 -1
  137. package/lib/esm/actions/blue/common.js +17 -3
  138. package/lib/esm/actions/blue/refinance.d.ts +11 -3
  139. package/lib/esm/actions/blue/refinance.internal.js +4 -1
  140. package/lib/esm/actions/blue/refinance.js +8 -2
  141. package/lib/esm/actions/blue/refinanceValidation.d.ts +3 -2
  142. package/lib/esm/actions/blue/refinanceValidation.js +10 -6
  143. package/lib/esm/actions/blue/repay.d.ts +4 -3
  144. package/lib/esm/actions/blue/repay.js +3 -2
  145. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +4 -3
  146. package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -2
  147. package/lib/esm/actions/blue/supply.d.ts +5 -3
  148. package/lib/esm/actions/blue/supply.js +4 -2
  149. package/lib/esm/actions/blue/supplyCollateral.d.ts +4 -3
  150. package/lib/esm/actions/blue/supplyCollateral.js +3 -2
  151. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +11 -3
  152. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
  153. package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +5 -1
  154. package/lib/esm/actions/blue/supplyCollateralBorrow.js +8 -2
  155. package/lib/esm/actions/blue/withdraw.d.ts +11 -3
  156. package/lib/esm/actions/blue/withdraw.internal.js +4 -1
  157. package/lib/esm/actions/blue/withdraw.js +8 -2
  158. package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
  159. package/lib/esm/actions/blue/withdrawCollateral.js +3 -2
  160. package/lib/esm/actions/bundles/common.d.ts +2 -8
  161. package/lib/esm/actions/bundles/common.js +4 -17
  162. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +1 -2
  163. package/lib/esm/actions/midnight/takeBorrow.js +1 -2
  164. package/lib/esm/actions/midnight/takeLend.js +1 -2
  165. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -2
  166. package/lib/esm/actions/midnight/takeWithdraw.js +1 -2
  167. package/lib/esm/actions/vaultV1/deposit.d.ts +2 -1
  168. package/lib/esm/actions/vaultV1/deposit.js +2 -1
  169. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +3 -2
  170. package/lib/esm/actions/vaultV1/migrateToV2.js +2 -1
  171. package/lib/esm/actions/vaultV1/redeem.d.ts +3 -2
  172. package/lib/esm/actions/vaultV1/redeem.js +2 -1
  173. package/lib/esm/actions/vaultV1/withdraw.d.ts +2 -1
  174. package/lib/esm/actions/vaultV1/withdraw.js +2 -1
  175. package/lib/esm/actions/vaultV2/deposit.d.ts +2 -1
  176. package/lib/esm/actions/vaultV2/deposit.js +2 -1
  177. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +2 -1
  178. package/lib/esm/actions/vaultV2/forceWithdraw.js +2 -1
  179. package/lib/esm/actions/vaultV2/redeem.d.ts +3 -2
  180. package/lib/esm/actions/vaultV2/redeem.js +2 -1
  181. package/lib/esm/actions/vaultV2/withdraw.d.ts +2 -1
  182. package/lib/esm/actions/vaultV2/withdraw.js +2 -1
  183. package/lib/esm/constants.d.ts +1 -1
  184. package/lib/esm/constants.js +1 -1
  185. package/lib/esm/entities/blue/blue.d.ts +83 -20
  186. package/lib/esm/entities/blue/blue.js +38 -12
  187. package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
  188. package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
  189. package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -6
  190. package/lib/esm/entities/vaultV1/vaultV1.js +7 -1
  191. package/lib/esm/entities/vaultV2/vaultV2.d.ts +12 -7
  192. package/lib/esm/entities/vaultV2/vaultV2.js +5 -1
  193. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +11 -2
  194. package/lib/esm/entities/vaultV2BlueReallocationData.js +17 -19
  195. package/lib/esm/helpers/constant.d.ts +2 -0
  196. package/lib/esm/helpers/constant.js +2 -0
  197. package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
  198. package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
  199. package/lib/esm/helpers/index.d.ts +1 -1
  200. package/lib/esm/helpers/index.js +1 -1
  201. package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
  202. package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
  203. package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
  204. package/lib/esm/helpers/quoteBlueRepay.js +21 -8
  205. package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
  206. package/lib/esm/helpers/reallocationPenalty.js +28 -0
  207. package/lib/esm/helpers/referralFee.d.ts +2 -1
  208. package/lib/esm/helpers/referralFee.js +5 -1
  209. package/lib/esm/helpers/validate.d.ts +31 -4
  210. package/lib/esm/helpers/validate.js +48 -11
  211. package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
  212. package/lib/esm/helpers/validateMidnightBounds.js +1 -2
  213. package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
  214. package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
  215. package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
  216. package/lib/esm/transactionPlan/blue/borrow.js +27 -9
  217. package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
  218. package/lib/esm/transactionPlan/blue/refinance.js +20 -3
  219. package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
  220. package/lib/esm/transactionPlan/blue/repay.js +1 -2
  221. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
  222. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
  223. package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
  224. package/lib/esm/transactionPlan/blue/supply.js +1 -2
  225. package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
  226. package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
  227. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
  228. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
  229. package/lib/esm/transactionPlan/blue/withdraw.d.ts +15 -5
  230. package/lib/esm/transactionPlan/blue/withdraw.js +25 -6
  231. package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
  232. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +11 -7
  233. package/lib/esm/transactionPlan/deposit.js +5 -1
  234. package/lib/esm/transactionPlan/intent.d.ts +1 -1
  235. package/lib/esm/transactionPlan/intent.js +4 -2
  236. package/lib/esm/transactionPlan/plan.d.ts +8 -4
  237. package/lib/esm/transactionPlan/plan.js +8 -4
  238. package/lib/esm/transactionPlan/types.d.ts +6 -0
  239. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +3 -3
  240. package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -3
  241. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
  242. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
  243. package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
  244. package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
  245. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
  246. package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
  247. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
  248. package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
  249. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
  250. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
  251. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
  252. package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
  253. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
  254. package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
  255. package/lib/esm/types/error.d.ts +7 -6
  256. package/lib/esm/types/error.js +11 -10
  257. package/lib/esm/types/sharedLiquidity.d.ts +7 -2
  258. package/lib/esm/version.d.ts +1 -1
  259. package/lib/esm/version.js +1 -1
  260. package/package.json +3 -3
@@ -46,7 +46,7 @@ export type VaultV2WithdrawInput = {
46
46
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
47
47
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
48
48
  * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
49
- * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
49
+ * @param params.args.referralFeePct - Optional WAD-scaled fee from 0% to 10%, inclusive, defaulting to zero.
50
50
  * The fee is rounded down and deducted from the gross withdrawn assets.
51
51
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
52
52
  * when `referralFeePct > 0n`.
@@ -61,6 +61,7 @@ export type VaultV2WithdrawInput = {
61
61
  * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
62
62
  * @throws {NegativeInputError} when `referralFeePct` is negative.
63
63
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
64
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
64
65
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
65
66
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
66
67
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
@@ -18,7 +18,7 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getPars
18
18
  * @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
19
19
  * @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
20
20
  * and the registered VaultBundlesV1 spender. Omit when the share allowance meets the required amount.
21
- * @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
21
+ * @param params.args.referralFeePct - Optional WAD-scaled fee from 0% to 10%, inclusive, defaulting to zero.
22
22
  * The fee is rounded down and deducted from the gross withdrawn assets.
23
23
  * @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
24
24
  * when `referralFeePct > 0n`.
@@ -33,6 +33,7 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getPars
33
33
  * @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
34
34
  * @throws {NegativeInputError} when `referralFeePct` is negative.
35
35
  * @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
36
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
36
37
  * @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
37
38
  * @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
38
39
  * @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
@@ -1,4 +1,4 @@
1
1
  export { DEAD_ADDRESS, DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./helpers/constant.js";
@@ -1,4 +1,4 @@
1
1
  export { DEAD_ADDRESS, DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
2
2
  export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
3
3
  export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
4
- export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, } from "./helpers/constant.js";
4
+ export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./helpers/constant.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,10 +248,12 @@ 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.
@@ -257,12 +262,16 @@ export interface BlueActions {
257
262
  * reallocation source market's `id` does not hash from its tuple fields.
258
263
  * @throws {AccrualPositionUserMismatchError} when `positionData` belongs to another user.
259
264
  * @throws {NegativeInputError} when an amount, referral fee, or reallocation penalty is negative.
265
+ * Also thrown when maxPenalty is negative.
260
266
  * @throws {NonPositiveInputError} when no withdrawal mode or positive reallocation amount is provided.
261
267
  * @throws {MutuallyExclusiveWithdrawAmountsError} when assets and shares are both nonzero.
262
268
  * @throws {WithdrawExceedsSupplyError} when assets exceed the supplied balance.
263
269
  * @throws {WithdrawSharesExceedSupplyError} when shares exceed the owned balance.
264
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.
265
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.
266
275
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
267
276
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
268
277
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -311,6 +320,8 @@ export interface BlueActions {
311
320
  readonly userAddress: Address;
312
321
  readonly positionData: AccrualPosition;
313
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;
314
325
  readonly deadline: bigint;
315
326
  readonly referralFeePct?: bigint;
316
327
  readonly referralFeeRecipient?: Address;
@@ -396,10 +407,12 @@ export interface BlueActions {
396
407
  * @param params.borrowAssets - Gross loan assets borrowed before penalties and referral fees.
397
408
  * @param params.positionData - Pre-fetched position used for the health check.
398
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.
399
411
  * @param params.deadline - Final call deadline in Unix seconds.
400
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
412
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
401
413
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
402
414
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction.
415
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
403
416
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
404
417
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
405
418
  * @throws {UnsupportedBlueMarketIrmError} when positive debt requires an unsupported IRM projection.
@@ -412,8 +425,12 @@ export interface BlueActions {
412
425
  * @throws {BorrowExceedsSafeLtvError} when the resulting position exceeds buffered LLTV.
413
426
  * @throws {NonPositiveInputError} when `borrowAssets` is not positive.
414
427
  * @throws {NegativeInputError} when the borrow, fee, or a reallocation value is negative.
428
+ * Also thrown when maxPenalty is negative.
415
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.
416
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.
417
434
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
418
435
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
419
436
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -461,6 +478,8 @@ export interface BlueActions {
461
478
  readonly borrowAssets: bigint;
462
479
  readonly positionData: AccrualPosition;
463
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;
464
483
  readonly deadline: bigint;
465
484
  readonly referralFeePct?: bigint;
466
485
  readonly referralFeeRecipient?: Address;
@@ -478,7 +497,7 @@ export interface BlueActions {
478
497
  * @param params.repayShares - Exact shares, or `maxUint256` for a full repay.
479
498
  * @param params.nativeAmount - Optional full native funding equal to the derived repayment cap.
480
499
  * @param params.deadline - Final call deadline in Unix seconds.
481
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
500
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
482
501
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
483
502
  * @returns Lazy token prerequisite resolution and a synchronous deep-frozen transaction.
484
503
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -496,6 +515,8 @@ export interface BlueActions {
496
515
  * @throws {InputExceedsMaxError} when a fee is out of bounds or a share quote deadline is too far away.
497
516
  * @throws {MaxRepayAssetsBelowRepayAssetsError} when a signed share cap no longer covers the fresh quote.
498
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.
499
520
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
500
521
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
501
522
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -567,7 +588,7 @@ export interface BlueActions {
567
588
  * @param params.positionData - Pre-fetched position used for balance and health validation.
568
589
  * @param params.collateralAssets - Collateral assets withdrawn.
569
590
  * @param params.deadline - Final call deadline in Unix seconds.
570
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
591
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
571
592
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
572
593
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction.
573
594
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -582,8 +603,9 @@ export interface BlueActions {
582
603
  * @throws {WithdrawMakesPositionUnhealthyError} when the result exceeds buffered LLTV.
583
604
  * @throws {NonPositiveInputError} when `collateralAssets` is not positive.
584
605
  * @throws {NegativeInputError} when collateral or the referral fee is negative.
585
- * @throws {InputExceedsMaxError} when the referral fee is at least WAD.
586
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.
587
609
  * @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple authorization signatures are supplied.
588
610
  * @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a token signature is supplied.
589
611
  * @throws {DepositOwnerMismatchError} from `buildTx()` when the signed owner differs from `userAddress`.
@@ -648,7 +670,7 @@ export interface BlueActions {
648
670
  * @param params.collateralAssets - Collateral withdrawn, or zero for pure repay.
649
671
  * @param params.nativeAmount - Optional full native funding; must equal derived `maxRepayAssets`.
650
672
  * @param params.deadline - Final call deadline in Unix seconds; share mode is limited to the two-hour funding quote horizon.
651
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
673
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
652
674
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
653
675
  * @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
654
676
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
@@ -666,9 +688,11 @@ export interface BlueActions {
666
688
  * @throws {MissingMarketPriceError} when withdrawal health cannot be validated without an oracle price.
667
689
  * @throws {WithdrawMakesPositionUnhealthyError} when the post-repay withdrawal exceeds buffered LLTV.
668
690
  * @throws {ExpiredDeadlineError} when the deadline is stale.
669
- * @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.
670
692
  * @throws {MaxRepayAssetsBelowRepayAssetsError} from `buildTx()` when a previously signed share-mode cap no longer covers the fresh derived minimum.
671
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.
672
696
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
673
697
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
674
698
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
@@ -751,10 +775,12 @@ export interface BlueActions {
751
775
  * @param params.positionData - Pre-fetched position; required when `borrowAssets` is positive.
752
776
  * @param params.nativeAmount - Optional full native collateral funding; must equal `collateralAssets`.
753
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.
754
779
  * @param params.deadline - Final call deadline in Unix seconds.
755
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
780
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
756
781
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
757
782
  * @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
783
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
758
784
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
759
785
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
760
786
  * @throws {UnsupportedBlueMarketIrmError} when positive debt requires an unsupported IRM projection.
@@ -767,12 +793,16 @@ export interface BlueActions {
767
793
  * @throws {ReallocationsRequireBorrowError} when reallocations accompany no borrow.
768
794
  * @throws {ExpiredDeadlineError} when the deadline is stale.
769
795
  * @throws {NegativeInputError} when an amount, native funding, referral fee, or reallocation penalty is negative.
796
+ * Also thrown when maxPenalty is negative.
770
797
  * @throws {NonPositiveInputError} when both legs or a reallocation amount is not positive.
771
798
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
772
799
  * @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
773
800
  * @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
774
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.
775
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.
776
806
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
777
807
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
778
808
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -828,6 +858,8 @@ export interface BlueActions {
828
858
  readonly positionData?: AccrualPosition;
829
859
  readonly nativeAmount?: bigint;
830
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;
831
863
  readonly deadline: bigint;
832
864
  readonly referralFeePct?: bigint;
833
865
  readonly referralFeeRecipient?: Address;
@@ -848,10 +880,12 @@ export interface BlueActions {
848
880
  * @param params.destination.marketParams - Distinct destination market with matching tokens.
849
881
  * @param params.destination.positionData - User's pre-fetched destination position.
850
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.
851
884
  * @param params.deadline - Final call deadline in Unix seconds.
852
- * @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
885
+ * @param params.referralFeePct - Optional WAD-scaled referral fee at most 10%.
853
886
  * @param params.referralFeeRecipient - Recipient required for a positive fee.
854
887
  * @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction builder.
888
+ * @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
855
889
  * @throws {ChainIdMismatchError} when the client targets another chain, or from
856
890
  * `getRequirements()` when the RPC reports another chain via `eth_chainId`.
857
891
  * @throws {UnsupportedBlueMarketIrmError} when positive source or destination debt requires an unsupported IRM projection.
@@ -862,12 +896,16 @@ export interface BlueActions {
862
896
  * @throws {RefinanceSameMarketError} when source and destination IDs match.
863
897
  * @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
864
898
  * @throws {NegativeInputError} when a referral fee or reallocation penalty is negative.
899
+ * Also thrown when maxPenalty is negative.
865
900
  * @throws {NonPositiveInputError} when the source has no borrow shares or a reallocation amount is not positive.
866
901
  * @throws {MissingMarketPriceError} when destination health cannot be validated without an oracle price.
867
902
  * @throws {BorrowExceedsSafeLtvError} when the complete destination exceeds buffered LLTV.
868
903
  * @throws {ExpiredDeadlineError} when the deadline is stale.
869
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.
870
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.
871
909
  * @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
872
910
  * @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
873
911
  * @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
@@ -927,6 +965,8 @@ export interface BlueActions {
927
965
  readonly positionData: AccrualPosition;
928
966
  };
929
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;
930
970
  readonly deadline: bigint;
931
971
  readonly referralFeePct?: bigint;
932
972
  readonly referralFeeRecipient?: Address;
@@ -990,20 +1030,28 @@ export interface BlueActions {
990
1030
  * For `refinance`, compute the plan on the destination-market handle (for
991
1031
  * example, `client.morpho.blue(destination.marketParams, chainId)`), not the
992
1032
  * source-market handle. Pass the source position's `borrowAssets` accrued to
993
- * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
994
- * `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.
995
1040
  * The planner includes the referral fee and its own planned allocator-leg
996
1041
  * penalties in destination debt. Refinance never uses vaults with a 100%
997
- * penalty.
1042
+ * penalty. When executing the returned reallocations, pass the same explicit
1043
+ * maxPenalty to borrow, supplyCollateralBorrow, withdraw, or refinance.
998
1044
  *
999
1045
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
1000
1046
  * @param params.options - Optional allocator discovery controls and operation to support.
1001
1047
  * @returns Action-ready reallocations and their post-simulation state.
1048
+ * @throws {InvalidBigIntInputError} when options.maxPenalty is supplied but is not a bigint.
1002
1049
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1003
1050
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1004
1051
  * @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
1005
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.
1006
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.
1007
1055
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
1008
1056
  * @throws {UnknownReallocationMarketError} when a required market is absent.
1009
1057
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.
@@ -1056,7 +1104,6 @@ export declare class MorphoBlue implements BlueActions {
1056
1104
  */
1057
1105
  private assertWriteTargets;
1058
1106
  private getMaxLtv;
1059
- private getBlueBundlesV1QuoteTimestamp;
1060
1107
  private getTokenRequirements;
1061
1108
  private getAuthorizationRequirements;
1062
1109
  getMarketData(parameters?: FetchParameters): Promise<Market>;
@@ -1089,6 +1136,8 @@ export declare class MorphoBlue implements BlueActions {
1089
1136
  readonly userAddress: Address;
1090
1137
  readonly positionData: AccrualPosition;
1091
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;
1092
1141
  readonly deadline: bigint;
1093
1142
  readonly referralFeePct?: bigint;
1094
1143
  readonly referralFeeRecipient?: Address;
@@ -1123,6 +1172,8 @@ export declare class MorphoBlue implements BlueActions {
1123
1172
  readonly borrowAssets: bigint;
1124
1173
  readonly positionData: AccrualPosition;
1125
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;
1126
1177
  readonly deadline: bigint;
1127
1178
  readonly referralFeePct?: bigint;
1128
1179
  readonly referralFeeRecipient?: Address;
@@ -1189,6 +1240,8 @@ export declare class MorphoBlue implements BlueActions {
1189
1240
  readonly positionData?: AccrualPosition;
1190
1241
  readonly nativeAmount?: bigint;
1191
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;
1192
1245
  readonly deadline: bigint;
1193
1246
  readonly referralFeePct?: bigint;
1194
1247
  readonly referralFeeRecipient?: Address;
@@ -1207,6 +1260,8 @@ export declare class MorphoBlue implements BlueActions {
1207
1260
  readonly positionData: AccrualPosition;
1208
1261
  };
1209
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;
1210
1265
  readonly deadline: bigint;
1211
1266
  readonly referralFeePct?: bigint;
1212
1267
  readonly referralFeeRecipient?: Address;
@@ -1294,20 +1349,28 @@ export declare class MorphoBlue implements BlueActions {
1294
1349
  * For `refinance`, compute the plan on the destination-market handle (for
1295
1350
  * example, `client.morpho.blue(destination.marketParams, chainId)`), not the
1296
1351
  * source-market handle. Pass the source position's `borrowAssets` accrued to
1297
- * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
1298
- * `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.
1299
1359
  * The planner includes the referral fee and its own planned allocator-leg
1300
1360
  * penalties in destination debt. Refinance never uses vaults with a 100%
1301
- * penalty.
1361
+ * penalty. When executing the returned reallocations, pass the same explicit
1362
+ * maxPenalty to borrow, supplyCollateralBorrow, withdraw, or refinance.
1302
1363
  *
1303
1364
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
1304
1365
  * @param params.options - Optional allocator discovery controls and operation to support.
1305
1366
  * @returns Action-ready reallocations and their post-simulation state.
1367
+ * @throws {InvalidBigIntInputError} when options.maxPenalty is supplied but is not a bigint.
1306
1368
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
1307
1369
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
1308
1370
  * @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
1309
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.
1310
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.
1311
1374
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
1312
1375
  * @throws {UnknownReallocationMarketError} when a required market is absent.
1313
1376
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.
@@ -14,6 +14,7 @@ import { buildBlueWithdraw, parseBlueWithdrawMode, parseBlueWithdrawPenalty, } f
14
14
  import { buildBlueWithdrawBuyCallback, } from "../../actions/blue/withdrawBuyCallback.internal.js";
15
15
  import { getParsedBlueAuthorizationRequirement, parseBlueAuthorizationRequirement, } from "../../actions/requirements/blue/getBlueAuthorizationRequirement.js";
16
16
  import { createChainCheck, } from "../../actions/requirements/chainCheck.js";
17
+ import { getBlueBundlesV1QuoteTimestamp } from "../../helpers/getBlueBundlesV1QuoteTimestamp.js";
17
18
  import { DEFAULT_LLTV_BUFFER, validateAccrualPosition, validateChainId, validatePositionHealth, validatePositionHealthAfterWithdraw, validateWithdrawAmount, validateWithdrawShares, } from "../../helpers/index.js";
18
19
  import { resolveTransactionMetadata } from "../../helpers/metadata.js";
19
20
  import { parseBlueMarket, parseNativeFunding, parseNonnegative, parseUint256, parseUint256Max, } from "../../helpers/parse.js";
@@ -96,9 +97,6 @@ export class MorphoBlue {
96
97
  getMaxLtv(marketParams = this.parsedMarket) {
97
98
  return MathLib.zeroFloorSub(marketParams.lltv, DEFAULT_LLTV_BUFFER);
98
99
  }
99
- getBlueBundlesV1QuoteTimestamp(lastUpdate, now = Time.timestamp()) {
100
- return MathLib.max(now, lastUpdate) + Time.s.from.h(2n);
101
- }
102
100
  async getTokenRequirements(chainCheck, params) {
103
101
  // Reject expiry before continuing this call.
104
102
  this.validateDeadline(params.deadline, params.now);
@@ -250,7 +248,10 @@ export class MorphoBlue {
250
248
  marketId: this.parsedMarket.id,
251
249
  });
252
250
  }
253
- const allocations = parseBlueWithdrawPenalty(parseBlueAllocations([...(params.reallocations ?? [])], this.parsedMarket), mode);
251
+ const allocations = parseBlueWithdrawPenalty(parseBlueAllocations([...(params.reallocations ?? [])], {
252
+ marketParams: this.parsedMarket,
253
+ maxPenalty: params.maxPenalty,
254
+ }), mode);
254
255
  const reallocationPenaltyAssets = allocations.penaltyAssets;
255
256
  const expectedWithdrawAssets = assets > 0n ? assets : positionData.market.toSupplyAssets(shares, "Down");
256
257
  if (shares > 0n && reallocationPenaltyAssets > expectedWithdrawAssets) {
@@ -446,7 +447,7 @@ export class MorphoBlue {
446
447
  return this.borrowPrepared(this.parseBorrowParams(params));
447
448
  }
448
449
  parseBorrowParams(params) {
449
- const { userAddress, borrowAssets, positionData, reallocations, deadline, referralFeePct, referralFeeRecipient, } = params;
450
+ const { userAddress, borrowAssets, positionData, reallocations, maxPenalty, deadline, referralFeePct, referralFeeRecipient, } = params;
450
451
  const normalizedReallocations = [...(reallocations ?? [])];
451
452
  return {
452
453
  ...this.parseSupplyCollateralBorrowParams({
@@ -456,6 +457,7 @@ export class MorphoBlue {
456
457
  borrowAssets,
457
458
  positionData,
458
459
  reallocations: normalizedReallocations,
460
+ maxPenalty,
459
461
  deadline,
460
462
  referralFeePct,
461
463
  referralFeeRecipient,
@@ -579,9 +581,16 @@ export class MorphoBlue {
579
581
  repayShares,
580
582
  deadline,
581
583
  now: createdAt,
584
+ healthTimestamp: collateralAssets > 0n
585
+ ? getBlueBundlesV1QuoteTimestamp({
586
+ lastUpdate: positionData.market.lastUpdate,
587
+ now: createdAt,
588
+ deadline,
589
+ })
590
+ : undefined,
582
591
  });
583
- const referralFeeAssets = getBlueBundlesV1ReferralFeeAssets(expectedRepayAssets, referralFeePct);
584
- const maxRepayAssets = expectedRepayAssets + referralFeeAssets;
592
+ const maxRepayAssets = expectedRepayAssets +
593
+ getBlueBundlesV1ReferralFeeAssets(expectedRepayAssets, referralFeePct);
585
594
  const nativeValue = parseNativeFunding({
586
595
  chainId: this.chainId,
587
596
  token: this.parsedMarket.loanToken,
@@ -686,6 +695,7 @@ export class MorphoBlue {
686
695
  collateralAssets,
687
696
  borrowAssets,
688
697
  reallocations: [...(params.reallocations ?? [])],
698
+ maxPenalty: params.maxPenalty,
689
699
  });
690
700
  const allocations = parseBlueSupplyCollateralBorrowAllocations(this.parsedMarket, mode);
691
701
  if (borrowAssets > 0n) {
@@ -700,7 +710,11 @@ export class MorphoBlue {
700
710
  });
701
711
  // Reject resulting debt above the buffered LLTV.
702
712
  validatePositionHealth({
703
- positionData: positionData.accrueInterest(this.getBlueBundlesV1QuoteTimestamp(positionData.market.lastUpdate, createdAt)),
713
+ positionData: positionData.accrueInterest(getBlueBundlesV1QuoteTimestamp({
714
+ lastUpdate: positionData.market.lastUpdate,
715
+ now: createdAt,
716
+ deadline: normalized.deadline,
717
+ })),
704
718
  additionalCollateral: collateralAssets,
705
719
  borrowAmount: borrowAssets,
706
720
  marketId: this.parsedMarket.id,
@@ -808,7 +822,10 @@ export class MorphoBlue {
808
822
  expectedMarketId: destinationMarketParams.id,
809
823
  expectedUser: userAddress,
810
824
  });
811
- const allocations = parseBlueAllocations([...(params.reallocations ?? [])], markets.destinationMarketParams);
825
+ const allocations = parseBlueAllocations([...(params.reallocations ?? [])], {
826
+ marketParams: markets.destinationMarketParams,
827
+ maxPenalty: params.maxPenalty,
828
+ });
812
829
  validateBlueRefinanceQuote({
813
830
  destinationMarketParams,
814
831
  sourcePosition: positionData,
@@ -816,6 +833,7 @@ export class MorphoBlue {
816
833
  penaltyAssets: allocations.penaltyAssets,
817
834
  referralFeePct,
818
835
  now: createdAt,
836
+ deadline: normalized.deadline,
819
837
  });
820
838
  const input = {
821
839
  ...markets,
@@ -978,20 +996,28 @@ export class MorphoBlue {
978
996
  * For `refinance`, compute the plan on the destination-market handle (for
979
997
  * example, `client.morpho.blue(destination.marketParams, chainId)`), not the
980
998
  * source-market handle. Pass the source position's `borrowAssets` accrued to
981
- * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
982
- * `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
999
+ * the resolved plan expiry (or the required action deadline for entity
1000
+ * `refinance`) as `operation.amount`. With
1001
+ * `minTs = max(now, source.lastUpdate, destination.lastUpdate)`, the horizon is
1002
+ * `max(minTs, resolved expiry)`. For `prepareBlueRefinance`, omitted `expiresAt`
1003
+ * resolves to `now + 2h`, not `minTs + 2h`. Only when the resolved expiry exceeds
1004
+ * `minTs + 365 days`, use `minTs + 2h` for unlimited-deadline sentinel
1005
+ * compatibility. The optional `operation.referralFeePct` is WAD-scaled.
983
1006
  * The planner includes the referral fee and its own planned allocator-leg
984
1007
  * penalties in destination debt. Refinance never uses vaults with a 100%
985
- * penalty.
1008
+ * penalty. When executing the returned reallocations, pass the same explicit
1009
+ * maxPenalty to borrow, supplyCollateralBorrow, withdraw, or refinance.
986
1010
  *
987
1011
  * @param params.reallocationData - State returned by {@link getVaultV2BlueReallocationData}.
988
1012
  * @param params.options - Optional allocator discovery controls and operation to support.
989
1013
  * @returns Action-ready reallocations and their post-simulation state.
1014
+ * @throws {InvalidBigIntInputError} when options.maxPenalty is supplied but is not a bigint.
990
1015
  * @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
991
1016
  * @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
992
1017
  * @throws {NegativeInputError} when the cap-accrual buffer, allocator cap headroom, utilization, penalty limit, or referral-fee percentage is negative.
993
1018
  * @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.
994
1019
  * @throws {ReferralFeePctExceededError} when the referral-fee percentage is at least WAD.
1020
+ * @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
995
1021
  * @throws {NonPositiveInputError} when an enabled operation amount is not positive.
996
1022
  * @throws {UnknownReallocationMarketError} when a required market is absent.
997
1023
  * @throws {UnknownReallocationVaultError} when configured vault state is absent.
@@ -6,6 +6,8 @@ import type { VaultV1MigrateToV2AmountArgs } from "../../types/index.js";
6
6
  * price bound uses assets net of the referral fee. Neither snapshot is mutated.
7
7
  * @param params - Source, target, exclusive amount, fee, slippage, deadline and preparation time.
8
8
  * @returns The destination maximum share price and minimum source share allowance.
9
+ * @throws {InvalidBigIntInputError} when `now` is not a bigint.
10
+ * @throws {InputExceedsMaxError} when the deadline exceeds seven days after preparation.
9
11
  */
10
12
  export declare function computeVaultV1MigrateToV2Quote(params: VaultV1MigrateToV2AmountArgs & {
11
13
  readonly sourceVault: AccrualVault;
@@ -1,15 +1,20 @@
1
1
  import { MathLib, } from "@morpho-org/blue-sdk";
2
2
  import { getBundlesReferralFeeAssets } from "../../actions/bundles/common.js";
3
3
  import { computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "../../helpers/slippage.js";
4
+ import { validateVaultDepositDeadline } from "../../helpers/validate.js";
4
5
  /**
5
6
  * @internal Quotes a migration from validated snapshots and intent without reading chain state.
6
7
  * The source accrues interest and performance fees before a shares-mode conversion; the target
7
8
  * price bound uses assets net of the referral fee. Neither snapshot is mutated.
8
9
  * @param params - Source, target, exclusive amount, fee, slippage, deadline and preparation time.
9
10
  * @returns The destination maximum share price and minimum source share allowance.
11
+ * @throws {InvalidBigIntInputError} when `now` is not a bigint.
12
+ * @throws {InputExceedsMaxError} when the deadline exceeds seven days after preparation.
10
13
  */
11
14
  export function computeVaultV1MigrateToV2Quote(params) {
12
15
  const { sourceVault, targetVault, assets, shares, referralFeePct, slippageTolerance, deadline, now, } = params;
16
+ // Bound the destination's forward-accrued deposit price.
17
+ validateVaultDepositDeadline(deadline, { now });
13
18
  const grossAssets = assets ??
14
19
  sourceVault
15
20
  .accrueInterest(sourceVault.allocations