@morpho-org/morpho-sdk 5.2.0 → 5.3.1

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 (270) hide show
  1. package/README.md +46 -2
  2. package/lib/cjs/abis.d.ts +1 -0
  3. package/lib/cjs/abis.js +6 -1
  4. package/lib/cjs/actions/blue/borrow.d.ts +3 -7
  5. package/lib/cjs/actions/blue/borrow.js +5 -9
  6. package/lib/cjs/actions/blue/buildReallocationActions.d.ts +3 -4
  7. package/lib/cjs/actions/blue/buildReallocationActions.js +3 -4
  8. package/lib/cjs/actions/blue/refinance.d.ts +4 -8
  9. package/lib/cjs/actions/blue/refinance.js +10 -14
  10. package/lib/cjs/actions/blue/repay.d.ts +2 -5
  11. package/lib/cjs/actions/blue/repay.js +2 -5
  12. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -6
  13. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +4 -7
  14. package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +2 -5
  15. package/lib/cjs/actions/blue/resolveRepayFunding.js +15 -12
  16. package/lib/cjs/actions/blue/supply.d.ts +2 -4
  17. package/lib/cjs/actions/blue/supply.js +6 -8
  18. package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -3
  19. package/lib/cjs/actions/blue/supplyCollateral.js +5 -6
  20. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +4 -9
  21. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +9 -14
  22. package/lib/cjs/actions/blue/withdraw.d.ts +9 -7
  23. package/lib/cjs/actions/blue/withdraw.js +18 -10
  24. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
  25. package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
  26. package/lib/cjs/actions/index.d.ts +2 -0
  27. package/lib/cjs/actions/index.js +1 -0
  28. package/lib/cjs/actions/midnight/authorization.d.ts +37 -0
  29. package/lib/cjs/actions/midnight/authorization.js +69 -0
  30. package/lib/cjs/actions/midnight/cancelOffer.d.ts +38 -0
  31. package/lib/cjs/actions/midnight/cancelOffer.js +73 -0
  32. package/lib/cjs/actions/midnight/index.d.ts +11 -0
  33. package/lib/cjs/actions/midnight/index.js +27 -0
  34. package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
  35. package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +72 -0
  36. package/lib/cjs/actions/midnight/redeem.d.ts +43 -0
  37. package/lib/cjs/actions/midnight/redeem.js +79 -0
  38. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
  39. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +121 -0
  40. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
  41. package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +59 -0
  42. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +45 -0
  43. package/lib/cjs/actions/midnight/supplyCollateral.js +83 -0
  44. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
  45. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -0
  46. package/lib/cjs/actions/midnight/takeBorrow.d.ts +57 -0
  47. package/lib/cjs/actions/midnight/takeBorrow.js +110 -0
  48. package/lib/cjs/actions/midnight/takeLend.d.ts +57 -0
  49. package/lib/cjs/actions/midnight/takeLend.js +110 -0
  50. package/lib/cjs/actions/midnight/types.d.ts +39 -0
  51. package/lib/cjs/actions/midnight/types.js +15 -0
  52. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
  53. package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +5 -16
  54. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
  55. package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +10 -14
  56. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
  57. package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +11 -28
  58. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
  59. package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
  60. package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  61. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +10 -4
  62. package/lib/cjs/actions/requirements/getRequirementsApproval.js +10 -4
  63. package/lib/cjs/actions/requirements/index.d.ts +1 -0
  64. package/lib/cjs/actions/requirements/index.js +1 -0
  65. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
  66. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +76 -0
  67. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
  68. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +78 -0
  69. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
  70. package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +70 -0
  71. package/lib/cjs/actions/requirements/midnight/index.d.ts +3 -0
  72. package/lib/cjs/actions/requirements/midnight/index.js +19 -0
  73. package/lib/cjs/actions/vaultV1/deposit.d.ts +3 -4
  74. package/lib/cjs/actions/vaultV1/deposit.js +7 -8
  75. package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +2 -3
  76. package/lib/cjs/actions/vaultV1/migrateToV2.js +5 -6
  77. package/lib/cjs/actions/vaultV1/redeem.d.ts +1 -1
  78. package/lib/cjs/actions/vaultV1/redeem.js +2 -2
  79. package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
  80. package/lib/cjs/actions/vaultV1/withdraw.js +2 -2
  81. package/lib/cjs/actions/vaultV2/deposit.d.ts +3 -4
  82. package/lib/cjs/actions/vaultV2/deposit.js +7 -8
  83. package/lib/cjs/actions/vaultV2/forceRedeem.d.ts +2 -3
  84. package/lib/cjs/actions/vaultV2/forceRedeem.js +3 -4
  85. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  86. package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -2
  87. package/lib/cjs/actions/vaultV2/redeem.d.ts +1 -1
  88. package/lib/cjs/actions/vaultV2/redeem.js +2 -2
  89. package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
  90. package/lib/cjs/actions/vaultV2/withdraw.js +2 -2
  91. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  92. package/lib/cjs/client/morphoViemExtension.js +5 -2
  93. package/lib/cjs/constants.d.ts +1 -0
  94. package/lib/cjs/constants.js +15 -1
  95. package/lib/cjs/entities/blue/blue.d.ts +5 -5
  96. package/lib/cjs/entities/blue/blue.js +99 -80
  97. package/lib/cjs/entities/index.d.ts +1 -0
  98. package/lib/cjs/entities/index.js +15 -0
  99. package/lib/cjs/entities/midnight/index.d.ts +2 -0
  100. package/lib/cjs/entities/midnight/index.js +18 -0
  101. package/lib/cjs/entities/midnight/midnight.d.ts +402 -0
  102. package/lib/cjs/entities/midnight/midnight.js +1036 -0
  103. package/lib/cjs/entities/midnight/types.d.ts +164 -0
  104. package/lib/cjs/entities/midnight/types.js +2 -0
  105. package/lib/cjs/entities/vaultV1/vaultV1.js +10 -17
  106. package/lib/cjs/entities/vaultV2/vaultV2.js +19 -21
  107. package/lib/cjs/errors.d.ts +1 -0
  108. package/lib/cjs/errors.js +17 -1
  109. package/lib/cjs/helpers/encodeDeallocation.d.ts +1 -0
  110. package/lib/cjs/helpers/encodeDeallocation.js +2 -1
  111. package/lib/cjs/helpers/index.d.ts +4 -1
  112. package/lib/cjs/helpers/index.js +8 -1
  113. package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +34 -0
  114. package/lib/cjs/helpers/signAndVerifyTypedData.js +58 -0
  115. package/lib/cjs/helpers/validate.d.ts +40 -1
  116. package/lib/cjs/helpers/validate.js +47 -5
  117. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
  118. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +32 -0
  119. package/lib/cjs/helpers/validateMidnightMarket.d.ts +10 -0
  120. package/lib/cjs/helpers/validateMidnightMarket.js +24 -0
  121. package/lib/cjs/helpers/validateOfferSides.d.ts +21 -0
  122. package/lib/cjs/helpers/validateOfferSides.js +36 -0
  123. package/lib/cjs/helpers/validateRequirementSpender.d.ts +29 -0
  124. package/lib/cjs/helpers/validateRequirementSpender.js +49 -0
  125. package/lib/cjs/helpers/validateTakeableOffers.d.ts +18 -0
  126. package/lib/cjs/helpers/validateTakeableOffers.js +35 -0
  127. package/lib/cjs/midnight-api.d.ts +1 -0
  128. package/lib/cjs/midnight-api.js +17 -0
  129. package/lib/cjs/types/action.d.ts +189 -23
  130. package/lib/cjs/types/action.js +27 -7
  131. package/lib/cjs/types/client.d.ts +3 -2
  132. package/lib/cjs/types/error.d.ts +288 -119
  133. package/lib/cjs/types/error.js +259 -180
  134. package/lib/cjs/utils.d.ts +1 -0
  135. package/lib/cjs/utils.js +12 -2
  136. package/lib/esm/abis.d.ts +1 -0
  137. package/lib/esm/abis.js +1 -0
  138. package/lib/esm/actions/blue/borrow.d.ts +3 -7
  139. package/lib/esm/actions/blue/borrow.js +6 -10
  140. package/lib/esm/actions/blue/buildReallocationActions.d.ts +3 -4
  141. package/lib/esm/actions/blue/buildReallocationActions.js +3 -4
  142. package/lib/esm/actions/blue/refinance.d.ts +4 -8
  143. package/lib/esm/actions/blue/refinance.js +11 -15
  144. package/lib/esm/actions/blue/repay.d.ts +2 -5
  145. package/lib/esm/actions/blue/repay.js +2 -5
  146. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -6
  147. package/lib/esm/actions/blue/repayWithdrawCollateral.js +5 -8
  148. package/lib/esm/actions/blue/resolveRepayFunding.d.ts +2 -5
  149. package/lib/esm/actions/blue/resolveRepayFunding.js +16 -13
  150. package/lib/esm/actions/blue/supply.d.ts +2 -4
  151. package/lib/esm/actions/blue/supply.js +7 -9
  152. package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -3
  153. package/lib/esm/actions/blue/supplyCollateral.js +6 -7
  154. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +4 -9
  155. package/lib/esm/actions/blue/supplyCollateralBorrow.js +10 -15
  156. package/lib/esm/actions/blue/withdraw.d.ts +9 -7
  157. package/lib/esm/actions/blue/withdraw.js +19 -11
  158. package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
  159. package/lib/esm/actions/blue/withdrawCollateral.js +3 -3
  160. package/lib/esm/actions/index.d.ts +2 -0
  161. package/lib/esm/actions/index.js +1 -0
  162. package/lib/esm/actions/midnight/authorization.d.ts +37 -0
  163. package/lib/esm/actions/midnight/authorization.js +65 -0
  164. package/lib/esm/actions/midnight/cancelOffer.d.ts +38 -0
  165. package/lib/esm/actions/midnight/cancelOffer.js +69 -0
  166. package/lib/esm/actions/midnight/index.d.ts +11 -0
  167. package/lib/esm/actions/midnight/index.js +11 -0
  168. package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +52 -0
  169. package/lib/esm/actions/midnight/mempoolSubmitOffers.js +68 -0
  170. package/lib/esm/actions/midnight/redeem.d.ts +43 -0
  171. package/lib/esm/actions/midnight/redeem.js +75 -0
  172. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +53 -0
  173. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +117 -0
  174. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +40 -0
  175. package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +55 -0
  176. package/lib/esm/actions/midnight/supplyCollateral.d.ts +45 -0
  177. package/lib/esm/actions/midnight/supplyCollateral.js +79 -0
  178. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +51 -0
  179. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +124 -0
  180. package/lib/esm/actions/midnight/takeBorrow.d.ts +57 -0
  181. package/lib/esm/actions/midnight/takeBorrow.js +106 -0
  182. package/lib/esm/actions/midnight/takeLend.d.ts +57 -0
  183. package/lib/esm/actions/midnight/takeLend.js +106 -0
  184. package/lib/esm/actions/midnight/types.d.ts +39 -0
  185. package/lib/esm/actions/midnight/types.js +12 -0
  186. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -1
  187. package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +6 -17
  188. package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +5 -4
  189. package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +12 -16
  190. package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +2 -2
  191. package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +12 -29
  192. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +1 -1
  193. package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +5 -17
  194. package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
  195. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +10 -4
  196. package/lib/esm/actions/requirements/getRequirementsApproval.js +10 -4
  197. package/lib/esm/actions/requirements/index.d.ts +1 -0
  198. package/lib/esm/actions/requirements/index.js +1 -0
  199. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +49 -0
  200. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +72 -0
  201. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +44 -0
  202. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +74 -0
  203. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +42 -0
  204. package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +66 -0
  205. package/lib/esm/actions/requirements/midnight/index.d.ts +3 -0
  206. package/lib/esm/actions/requirements/midnight/index.js +3 -0
  207. package/lib/esm/actions/vaultV1/deposit.d.ts +3 -4
  208. package/lib/esm/actions/vaultV1/deposit.js +8 -9
  209. package/lib/esm/actions/vaultV1/migrateToV2.d.ts +2 -3
  210. package/lib/esm/actions/vaultV1/migrateToV2.js +6 -7
  211. package/lib/esm/actions/vaultV1/redeem.d.ts +1 -1
  212. package/lib/esm/actions/vaultV1/redeem.js +3 -3
  213. package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
  214. package/lib/esm/actions/vaultV1/withdraw.js +3 -3
  215. package/lib/esm/actions/vaultV2/deposit.d.ts +3 -4
  216. package/lib/esm/actions/vaultV2/deposit.js +8 -9
  217. package/lib/esm/actions/vaultV2/forceRedeem.d.ts +2 -3
  218. package/lib/esm/actions/vaultV2/forceRedeem.js +4 -5
  219. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  220. package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
  221. package/lib/esm/actions/vaultV2/redeem.d.ts +1 -1
  222. package/lib/esm/actions/vaultV2/redeem.js +3 -3
  223. package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
  224. package/lib/esm/actions/vaultV2/withdraw.js +3 -3
  225. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  226. package/lib/esm/client/morphoViemExtension.js +6 -3
  227. package/lib/esm/constants.d.ts +1 -0
  228. package/lib/esm/constants.js +1 -0
  229. package/lib/esm/entities/blue/blue.d.ts +5 -5
  230. package/lib/esm/entities/blue/blue.js +101 -82
  231. package/lib/esm/entities/index.d.ts +1 -0
  232. package/lib/esm/entities/index.js +1 -0
  233. package/lib/esm/entities/midnight/index.d.ts +2 -0
  234. package/lib/esm/entities/midnight/index.js +2 -0
  235. package/lib/esm/entities/midnight/midnight.d.ts +402 -0
  236. package/lib/esm/entities/midnight/midnight.js +1032 -0
  237. package/lib/esm/entities/midnight/types.d.ts +164 -0
  238. package/lib/esm/entities/midnight/types.js +1 -0
  239. package/lib/esm/entities/vaultV1/vaultV1.js +13 -20
  240. package/lib/esm/entities/vaultV2/vaultV2.js +9 -11
  241. package/lib/esm/errors.d.ts +1 -0
  242. package/lib/esm/errors.js +1 -0
  243. package/lib/esm/helpers/encodeDeallocation.d.ts +1 -0
  244. package/lib/esm/helpers/encodeDeallocation.js +3 -2
  245. package/lib/esm/helpers/index.d.ts +4 -1
  246. package/lib/esm/helpers/index.js +4 -1
  247. package/lib/esm/helpers/signAndVerifyTypedData.d.ts +34 -0
  248. package/lib/esm/helpers/signAndVerifyTypedData.js +54 -0
  249. package/lib/esm/helpers/validate.d.ts +40 -1
  250. package/lib/esm/helpers/validate.js +46 -5
  251. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +15 -0
  252. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +28 -0
  253. package/lib/esm/helpers/validateMidnightMarket.d.ts +10 -0
  254. package/lib/esm/helpers/validateMidnightMarket.js +20 -0
  255. package/lib/esm/helpers/validateOfferSides.d.ts +21 -0
  256. package/lib/esm/helpers/validateOfferSides.js +32 -0
  257. package/lib/esm/helpers/validateRequirementSpender.d.ts +29 -0
  258. package/lib/esm/helpers/validateRequirementSpender.js +45 -0
  259. package/lib/esm/helpers/validateTakeableOffers.d.ts +18 -0
  260. package/lib/esm/helpers/validateTakeableOffers.js +31 -0
  261. package/lib/esm/midnight-api.d.ts +1 -0
  262. package/lib/esm/midnight-api.js +1 -0
  263. package/lib/esm/types/action.d.ts +189 -23
  264. package/lib/esm/types/action.js +26 -7
  265. package/lib/esm/types/client.d.ts +3 -2
  266. package/lib/esm/types/error.d.ts +288 -119
  267. package/lib/esm/types/error.js +232 -154
  268. package/lib/esm/utils.d.ts +1 -0
  269. package/lib/esm/utils.js +1 -0
  270. package/package.json +11 -2
@@ -1,8 +1,108 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MissingPublicAllocatorConfigError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.ShareDivideByZeroError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.NonPositiveWithdrawCollateralAmountError = exports.NonPositiveRepayMaxSharePriceError = exports.NonPositiveRepayAmountError = exports.MutuallyExclusiveRepayAmountsError = exports.NativeAmountExceedsTransferAmountError = exports.TransferAmountNotEqualToAssetsError = exports.NonPositiveTransferAmountError = exports.UnsortedReallocationWithdrawalsError = exports.ReallocationWithdrawalOnTargetMarketError = exports.NonPositiveReallocationAmountError = exports.EmptyReallocationWithdrawalsError = exports.NegativeReallocationFeeError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeCollateralError = exports.NativeAmountOnNonWNativeAssetError = exports.ZeroCollateralAmountError = exports.NonPositiveBorrowAmountError = exports.VaultAddressMismatchError = exports.ZeroDepositAmountError = exports.NegativeNativeAmountError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.Permit2ExpirationMissingError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.NegativeSlippageToleranceError = exports.UnsupportedErc20ApprovalSpenderError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.NonPositiveMaxSharePriceError = exports.NonPositiveSharesAmountError = exports.NonPositiveAssetAmountError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.BundlerErrors = void 0;
4
- exports.RefinanceSharesMissingBorrowAssetsError = exports.RefinanceExceedsBorrowAssetsError = exports.RefinanceExceedsBorrowSharesError = exports.RefinanceExceedsCollateralError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.NegativeMaxRepaySharePriceError = exports.BorrowAmountAndSharesExclusiveError = exports.NegativeBorrowSharesError = exports.NegativeMinSharePriceError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.NegativeWithdrawMinSharePriceError = exports.NonPositiveWithdrawAmountError = exports.ZeroSupplyAmountError = exports.NegativeSupplyMaxSharePriceError = exports.NegativeSupplyAmountError = exports.NonPositiveMinBorrowSharePriceError = exports.UnknownReallocationPositionError = exports.UnknownReallocationVaultMarketConfigError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.DisabledReallocationMarketError = void 0;
3
+ exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeCollateralError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.Permit2ExpirationMissingError = exports.DepositSpenderMismatchError = exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.BundlerErrors = exports.NegativeMaxRepaySharePriceError = exports.NegativeBorrowSharesError = exports.NegativeMinSharePriceError = exports.NegativeWithdrawMinSharePriceError = exports.NegativeSupplyMaxSharePriceError = exports.NegativeSupplyAmountError = exports.NonPositiveMinBorrowSharePriceError = exports.NegativeReallocationFeeError = exports.NegativeNativeAmountError = exports.NegativeSlippageToleranceError = exports.NonPositiveWithdrawAmountError = exports.ZeroSupplyAmountError = exports.NonPositiveWithdrawCollateralAmountError = exports.NonPositiveRepayMaxSharePriceError = exports.NonPositiveRepayAmountError = exports.NonPositiveReallocationAmountError = exports.ZeroCollateralAmountError = exports.NonPositiveBorrowAmountError = exports.ZeroDepositAmountError = exports.NonPositiveMaxSharePriceError = exports.NonPositiveSharesAmountError = exports.NonPositiveAssetAmountError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
4
+ exports.RefinanceSharesMissingBorrowAssetsError = exports.RefinanceExceedsBorrowAssetsError = exports.RefinanceExceedsBorrowSharesError = exports.RefinanceExceedsCollateralError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.BorrowAmountAndSharesExclusiveError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.UnpreparedMidnightOfferRootSignatureError = exports.MidnightOfferRootOfferCountMismatchError = exports.MidnightOfferRootRatifierMismatchError = exports.MidnightOfferRootOwnerMismatchError = exports.MidnightOfferRootMismatchError = exports.MissingMidnightOfferRootSignatureError = exports.UnknownMidnightRatifierError = exports.MidnightTakeableOfferMarketMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.MidnightAmountExceedsMaxOfferCapError = exports.UnknownReallocationPositionError = exports.UnknownReallocationVaultMarketConfigError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.DisabledReallocationMarketError = exports.MissingPublicAllocatorConfigError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.ShareDivideByZeroError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.TransferAmountNotEqualToAssetsError = exports.UnsortedReallocationWithdrawalsError = exports.ReallocationWithdrawalOnTargetMarketError = exports.EmptyReallocationWithdrawalsError = exports.AccrualPositionUserMismatchError = void 0;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
+ /**
7
+ * Thrown when a morpho-sdk input that must be non-negative is negative.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { NegativeInputError } from "@morpho-org/morpho-sdk";
12
+ *
13
+ * const error = new NegativeInputError("amount", -1n);
14
+ * if (error instanceof NegativeInputError) {
15
+ * console.error(error.field, error.value);
16
+ * }
17
+ * ```
18
+ */
19
+ class NegativeInputError extends Error {
20
+ field;
21
+ value;
22
+ /**
23
+ * @param field - Public input field whose value is invalid.
24
+ * @param value - Negative bigint supplied for the field.
25
+ */
26
+ constructor(field, value) {
27
+ super(`Input "${field}" must be non-negative, got "${value}".`);
28
+ this.field = field;
29
+ this.value = value;
30
+ this.name = "NegativeInputError";
31
+ }
32
+ }
33
+ exports.NegativeInputError = NegativeInputError;
34
+ /**
35
+ * Thrown when a morpho-sdk input that must be positive is zero or negative.
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * import { NonPositiveInputError } from "@morpho-org/morpho-sdk";
40
+ *
41
+ * const error = new NonPositiveInputError("shares", 0n);
42
+ * if (error instanceof NonPositiveInputError) {
43
+ * console.error(error.field, error.value);
44
+ * }
45
+ * ```
46
+ */
47
+ class NonPositiveInputError extends Error {
48
+ field;
49
+ value;
50
+ /**
51
+ * @param field - Public input field whose value is invalid.
52
+ * @param value - Zero or negative bigint supplied for the field.
53
+ */
54
+ constructor(field, value) {
55
+ super(`Input "${field}" must be positive, got "${value}".`);
56
+ this.field = field;
57
+ this.value = value;
58
+ this.name = "NonPositiveInputError";
59
+ }
60
+ }
61
+ exports.NonPositiveInputError = NonPositiveInputError;
62
+ /** @deprecated Use {@link NonPositiveInputError}. */
63
+ exports.NonPositiveAssetAmountError = NonPositiveInputError;
64
+ /** @deprecated Use {@link NonPositiveInputError}. */
65
+ exports.NonPositiveSharesAmountError = NonPositiveInputError;
66
+ /** @deprecated Use {@link NonPositiveInputError}. */
67
+ exports.NonPositiveMaxSharePriceError = NonPositiveInputError;
68
+ /** @deprecated Use {@link NonPositiveInputError}. */
69
+ exports.ZeroDepositAmountError = NonPositiveInputError;
70
+ /** @deprecated Use {@link NonPositiveInputError}. */
71
+ exports.NonPositiveBorrowAmountError = NonPositiveInputError;
72
+ /** @deprecated Use {@link NonPositiveInputError}. */
73
+ exports.ZeroCollateralAmountError = NonPositiveInputError;
74
+ /** @deprecated Use {@link NonPositiveInputError}. */
75
+ exports.NonPositiveReallocationAmountError = NonPositiveInputError;
76
+ /** @deprecated Use {@link NonPositiveInputError}. */
77
+ exports.NonPositiveRepayAmountError = NonPositiveInputError;
78
+ /** @deprecated Use {@link NonPositiveInputError}. */
79
+ exports.NonPositiveRepayMaxSharePriceError = NonPositiveInputError;
80
+ /** @deprecated Use {@link NonPositiveInputError}. */
81
+ exports.NonPositiveWithdrawCollateralAmountError = NonPositiveInputError;
82
+ /** @deprecated Use {@link NonPositiveInputError}. */
83
+ exports.ZeroSupplyAmountError = NonPositiveInputError;
84
+ /** @deprecated Use {@link NonPositiveInputError}. */
85
+ exports.NonPositiveWithdrawAmountError = NonPositiveInputError;
86
+ /** @deprecated Use {@link NegativeInputError}. */
87
+ exports.NegativeSlippageToleranceError = NegativeInputError;
88
+ /** @deprecated Use {@link NegativeInputError}. */
89
+ exports.NegativeNativeAmountError = NegativeInputError;
90
+ /** @deprecated Use {@link NegativeInputError}. */
91
+ exports.NegativeReallocationFeeError = NegativeInputError;
92
+ /** @deprecated Use {@link NegativeInputError}. */
93
+ exports.NonPositiveMinBorrowSharePriceError = NegativeInputError;
94
+ /** @deprecated Use {@link NegativeInputError}. */
95
+ exports.NegativeSupplyAmountError = NegativeInputError;
96
+ /** @deprecated Use {@link NegativeInputError}. */
97
+ exports.NegativeSupplyMaxSharePriceError = NegativeInputError;
98
+ /** @deprecated Use {@link NegativeInputError}. */
99
+ exports.NegativeWithdrawMinSharePriceError = NegativeInputError;
100
+ /** @deprecated Use {@link NegativeInputError}. */
101
+ exports.NegativeMinSharePriceError = NegativeInputError;
102
+ /** @deprecated Use {@link NegativeInputError}. */
103
+ exports.NegativeBorrowSharesError = NegativeInputError;
104
+ /** @deprecated Use {@link NegativeInputError}. */
105
+ exports.NegativeMaxRepaySharePriceError = NegativeInputError;
6
106
  /**
7
107
  * Typed errors thrown while encoding supported Bundler3 actions.
8
108
  *
@@ -79,21 +179,21 @@ var BundlerErrors;
79
179
  /**
80
180
  * Thrown when `buildTx` receives more than one requirement signature of the same kind.
81
181
  *
82
- * A bundled path consumes at most one permit and one authorization signature; passing several of
83
- * the same kind is ambiguous and would silently drop all but the first, so it is rejected instead.
182
+ * A bundled path consumes at most one signature per accepted kind; passing several of the same
183
+ * kind is ambiguous and would silently drop all but the first, so it is rejected instead.
84
184
  *
85
185
  * @example
86
186
  * ```ts
87
187
  * import { AmbiguousRequirementSignaturesError } from "@morpho-org/morpho-sdk";
88
188
  *
89
189
  * if (error instanceof AmbiguousRequirementSignaturesError) {
90
- * // Pass a single permit (and at most one authorization) signature to buildTx.
190
+ * // Pass a single signature per accepted kind to buildTx.
91
191
  * }
92
192
  * ```
93
193
  */
94
194
  class AmbiguousRequirementSignaturesError extends Error {
95
195
  /**
96
- * @param kind - The over-supplied signature kind (`"permit"` or `"authorization"`).
196
+ * @param kind - The over-supplied signature kind.
97
197
  * @param count - How many signatures of that kind were received.
98
198
  */
99
199
  constructor(kind, count) {
@@ -102,9 +202,8 @@ class AmbiguousRequirementSignaturesError extends Error {
102
202
  }
103
203
  exports.AmbiguousRequirementSignaturesError = AmbiguousRequirementSignaturesError;
104
204
  /**
105
- * Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume
106
- * (for example an authorization signature on a plain supply path). Surfacing it prevents a signed
107
- * authorization or permit from being silently ignored.
205
+ * Thrown when `buildTx` receives a requirement signature of a kind the operation does not consume.
206
+ * Surfacing it prevents a signed requirement from being silently ignored.
108
207
  *
109
208
  * @example
110
209
  * ```ts
@@ -117,34 +216,13 @@ exports.AmbiguousRequirementSignaturesError = AmbiguousRequirementSignaturesErro
117
216
  */
118
217
  class UnexpectedRequirementSignatureError extends Error {
119
218
  /**
120
- * @param kind - The unexpected signature kind (`"permit"` or `"authorization"`).
219
+ * @param kind - The unexpected signature kind.
121
220
  */
122
221
  constructor(kind) {
123
222
  super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
124
223
  }
125
224
  }
126
225
  exports.UnexpectedRequirementSignatureError = UnexpectedRequirementSignatureError;
127
- /** Thrown when an asset amount is required to be positive but is zero or negative. */
128
- class NonPositiveAssetAmountError extends Error {
129
- constructor(origin) {
130
- super(`Asset amount must be positive for address ${origin}`);
131
- }
132
- }
133
- exports.NonPositiveAssetAmountError = NonPositiveAssetAmountError;
134
- /** Thrown when a shares amount is required to be positive but is zero or negative. */
135
- class NonPositiveSharesAmountError extends Error {
136
- constructor(vault) {
137
- super(`Shares amount must be positive for address: ${vault}`);
138
- }
139
- }
140
- exports.NonPositiveSharesAmountError = NonPositiveSharesAmountError;
141
- /** Thrown when a vault deposit's `maxSharePrice` slippage bound is zero or negative. */
142
- class NonPositiveMaxSharePriceError extends Error {
143
- constructor(vault) {
144
- super(`Max share price must be positive for vault: ${vault}`);
145
- }
146
- }
147
- exports.NonPositiveMaxSharePriceError = NonPositiveMaxSharePriceError;
148
226
  /** Thrown when a viem client's account address does not match the address required by the call. */
149
227
  class AddressMismatchError extends Error {
150
228
  constructor(clientAddress, argsAddress) {
@@ -159,6 +237,13 @@ class ChainIdMismatchError extends Error {
159
237
  }
160
238
  }
161
239
  exports.ChainIdMismatchError = ChainIdMismatchError;
240
+ /** Thrown when a runtime crypto API is required but unavailable. */
241
+ class CryptoUnavailableError extends Error {
242
+ constructor(feature) {
243
+ super(`Crypto API is required for ${feature} but is unavailable.`);
244
+ }
245
+ }
246
+ exports.CryptoUnavailableError = CryptoUnavailableError;
162
247
  /** Thrown when the viem client is missing a property the call requires (e.g. `account.address`). */
163
248
  class MissingClientPropertyError extends Error {
164
249
  constructor(property) {
@@ -188,17 +273,19 @@ class UnsupportedErc20ApprovalSpenderError extends Error {
188
273
  }
189
274
  }
190
275
  exports.UnsupportedErc20ApprovalSpenderError = UnsupportedErc20ApprovalSpenderError;
191
- /** Thrown when a slippage tolerance is negative. */
192
- class NegativeSlippageToleranceError extends Error {
193
- constructor(slippageTolerance) {
194
- super(`Slippage tolerance ${slippageTolerance} must not be negative`);
276
+ /** Thrown when a Midnight authorization requirement targets an unsupported operator. */
277
+ class UnsupportedMidnightAuthorizationTargetError extends Error {
278
+ constructor(params) {
279
+ super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
195
280
  }
196
281
  }
197
- exports.NegativeSlippageToleranceError = NegativeSlippageToleranceError;
198
- /** Thrown when a Morpho accrual position is missing for a market the call needs to read. */
282
+ exports.UnsupportedMidnightAuthorizationTargetError = UnsupportedMidnightAuthorizationTargetError;
283
+ /** Thrown when a Morpho accrual position required by a call is missing. */
199
284
  class MissingAccrualPositionError extends Error {
200
285
  constructor(market) {
201
- super(`Accrual position is missing for market: ${market}`);
286
+ super(market == null
287
+ ? "Accrual position is missing. Fetch the position data and try again."
288
+ : `Accrual position is missing for market: ${market}`);
202
289
  }
203
290
  }
204
291
  exports.MissingAccrualPositionError = MissingAccrualPositionError;
@@ -230,6 +317,20 @@ class DepositAssetMismatchError extends Error {
230
317
  }
231
318
  }
232
319
  exports.DepositAssetMismatchError = DepositAssetMismatchError;
320
+ /** Thrown when a deposit's owner differs from the owner the supplied permit / permit2 signature was issued for. */
321
+ class DepositOwnerMismatchError extends Error {
322
+ constructor(depositOwner, signatureOwner) {
323
+ super(`Deposit owner "${depositOwner}" does not match requirement signature owner "${signatureOwner}"`);
324
+ }
325
+ }
326
+ exports.DepositOwnerMismatchError = DepositOwnerMismatchError;
327
+ /** Thrown when a deposit's spender differs from the spender the supplied permit / permit2 signature was issued for. */
328
+ class DepositSpenderMismatchError extends Error {
329
+ constructor(depositSpender, signatureSpender) {
330
+ super(`Deposit spender "${depositSpender}" does not match requirement signature spender "${signatureSpender}"`);
331
+ }
332
+ }
333
+ exports.DepositSpenderMismatchError = DepositSpenderMismatchError;
233
334
  /** Thrown when a `permit2` requirement signature is missing the `expiration` field. */
234
335
  class Permit2ExpirationMissingError extends Error {
235
336
  constructor() {
@@ -251,20 +352,6 @@ class ChainWNativeMissingError extends Error {
251
352
  }
252
353
  }
253
354
  exports.ChainWNativeMissingError = ChainWNativeMissingError;
254
- /** Thrown when `nativeAmount` is negative. */
255
- class NegativeNativeAmountError extends Error {
256
- constructor(nativeAmount) {
257
- super(`Native amount must not be negative, got ${nativeAmount}`);
258
- }
259
- }
260
- exports.NegativeNativeAmountError = NegativeNativeAmountError;
261
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a vault deposit. */
262
- class ZeroDepositAmountError extends Error {
263
- constructor(vault) {
264
- super(`Total deposit amount must be positive for vault: ${vault}. Both amount and nativeAmount are zero.`);
265
- }
266
- }
267
- exports.ZeroDepositAmountError = ZeroDepositAmountError;
268
355
  /** Thrown when a vault entity's address does not match the vault address embedded in the call's args. */
269
356
  class VaultAddressMismatchError extends Error {
270
357
  constructor(vaultAddress, argsVaultAddress) {
@@ -272,20 +359,6 @@ class VaultAddressMismatchError extends Error {
272
359
  }
273
360
  }
274
361
  exports.VaultAddressMismatchError = VaultAddressMismatchError;
275
- /** Thrown when a market borrow amount is zero or negative. */
276
- class NonPositiveBorrowAmountError extends Error {
277
- constructor(market) {
278
- super(`Borrow amount must be positive for market: ${market}`);
279
- }
280
- }
281
- exports.NonPositiveBorrowAmountError = NonPositiveBorrowAmountError;
282
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a market collateral supply. */
283
- class ZeroCollateralAmountError extends Error {
284
- constructor(market) {
285
- super(`Total collateral amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
286
- }
287
- }
288
- exports.ZeroCollateralAmountError = ZeroCollateralAmountError;
289
362
  /** Thrown when an action uses `nativeAmount` but the target asset is not the chain's wNative. */
290
363
  class NativeAmountOnNonWNativeAssetError extends Error {
291
364
  constructor(asset, wNative) {
@@ -323,13 +396,6 @@ class AccrualPositionUserMismatchError extends Error {
323
396
  }
324
397
  }
325
398
  exports.AccrualPositionUserMismatchError = AccrualPositionUserMismatchError;
326
- /** Thrown when a reallocation's fee is negative. */
327
- class NegativeReallocationFeeError extends Error {
328
- constructor(vault) {
329
- super(`Reallocation fee must not be negative for vault: ${vault}`);
330
- }
331
- }
332
- exports.NegativeReallocationFeeError = NegativeReallocationFeeError;
333
399
  /** Thrown when a reallocation has no withdrawals. */
334
400
  class EmptyReallocationWithdrawalsError extends Error {
335
401
  constructor(vault) {
@@ -337,13 +403,6 @@ class EmptyReallocationWithdrawalsError extends Error {
337
403
  }
338
404
  }
339
405
  exports.EmptyReallocationWithdrawalsError = EmptyReallocationWithdrawalsError;
340
- /** Thrown when a reallocation withdrawal amount is zero or negative. */
341
- class NonPositiveReallocationAmountError extends Error {
342
- constructor(vault, market) {
343
- super(`Reallocation withdrawal amount must be positive for vault ${vault} on market ${market}`);
344
- }
345
- }
346
- exports.NonPositiveReallocationAmountError = NonPositiveReallocationAmountError;
347
406
  /** Thrown when a reallocation withdrawal references the operation's target market (which would be a no-op or self-deal). */
348
407
  class ReallocationWithdrawalOnTargetMarketError extends Error {
349
408
  constructor(vault, marketId) {
@@ -358,20 +417,6 @@ class UnsortedReallocationWithdrawalsError extends Error {
358
417
  }
359
418
  }
360
419
  exports.UnsortedReallocationWithdrawalsError = UnsortedReallocationWithdrawalsError;
361
- /**
362
- * Thrown when a market repay's `transferAmount` is zero or negative.
363
- *
364
- * @deprecated No longer thrown. The repay action layer no longer validates `transferAmount`
365
- * directly (assets mode uses {@link NonPositiveRepayAmountError}; shares mode allows a zero
366
- * ERC-20 transfer for fully-native repays). Retained as exported API for back-compat; slated
367
- * for removal in a future major.
368
- */
369
- class NonPositiveTransferAmountError extends Error {
370
- constructor(market) {
371
- super(`Transfer amount must be positive for market: ${market}`);
372
- }
373
- }
374
- exports.NonPositiveTransferAmountError = NonPositiveTransferAmountError;
375
420
  /**
376
421
  * Thrown when a market repay in assets mode has `transferAmount !== amount + nativeAmount` — the
377
422
  * pre-resolved ERC-20 pull plus the wrapped native must equal the assets repaid, so the bundle
@@ -383,21 +428,6 @@ class TransferAmountNotEqualToAssetsError extends Error {
383
428
  }
384
429
  }
385
430
  exports.TransferAmountNotEqualToAssetsError = TransferAmountNotEqualToAssetsError;
386
- /**
387
- * Thrown when a shares-mode repay's `nativeAmount` exceeds `transferAmount`, which
388
- * would make the ERC-20 amount to pull (`transferAmount − nativeAmount`) negative.
389
- *
390
- * @deprecated No longer thrown. A shares-mode repay now accepts a `nativeAmount` that
391
- * covers (or exceeds) the full repaid assets: it wraps the native, pulls no ERC-20, and
392
- * the bundle skims the residual wNative back to the receiver. This class is retained for
393
- * one minor for API stability and will be removed in the next major.
394
- */
395
- class NativeAmountExceedsTransferAmountError extends Error {
396
- constructor(params) {
397
- super(`Native amount ${params.nativeAmount} exceeds transfer amount ${params.transferAmount} for market: ${params.market}. Reduce nativeAmount to at most transferAmount.`);
398
- }
399
- }
400
- exports.NativeAmountExceedsTransferAmountError = NativeAmountExceedsTransferAmountError;
401
431
  /** Thrown when a market repay specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
402
432
  class MutuallyExclusiveRepayAmountsError extends Error {
403
433
  constructor(market) {
@@ -405,27 +435,6 @@ class MutuallyExclusiveRepayAmountsError extends Error {
405
435
  }
406
436
  }
407
437
  exports.MutuallyExclusiveRepayAmountsError = MutuallyExclusiveRepayAmountsError;
408
- /** Thrown when a market repay has non-positive amounts: both `assets` and `shares` are zero, or either is negative. */
409
- class NonPositiveRepayAmountError extends Error {
410
- constructor(market) {
411
- super(`Repay amount must be positive for market: ${market}`);
412
- }
413
- }
414
- exports.NonPositiveRepayAmountError = NonPositiveRepayAmountError;
415
- /** Thrown when a market repay's `maxSharePrice` slippage bound is zero or negative. */
416
- class NonPositiveRepayMaxSharePriceError extends Error {
417
- constructor(market) {
418
- super(`Max share price must be positive for market: ${market}`);
419
- }
420
- }
421
- exports.NonPositiveRepayMaxSharePriceError = NonPositiveRepayMaxSharePriceError;
422
- /** Thrown when a market `withdrawCollateral` amount is zero or negative. */
423
- class NonPositiveWithdrawCollateralAmountError extends Error {
424
- constructor(market) {
425
- super(`Withdraw collateral amount must be positive for market: ${market}`);
426
- }
427
- }
428
- exports.NonPositiveWithdrawCollateralAmountError = NonPositiveWithdrawCollateralAmountError;
429
438
  /** Thrown when a withdraw amount exceeds the position's available collateral. */
430
439
  class WithdrawExceedsCollateralError extends Error {
431
440
  constructor(params) {
@@ -555,48 +564,139 @@ class UnknownReallocationPositionError extends blue_sdk_1.UnknownDataError {
555
564
  }
556
565
  }
557
566
  exports.UnknownReallocationPositionError = UnknownReallocationPositionError;
558
- /** Thrown when a market borrow's `minSharePrice` slippage bound is negative. */
559
- class NonPositiveMinBorrowSharePriceError extends Error {
560
- constructor(market) {
561
- super(`Min share price must be non-negative for market: ${market}`);
567
+ /** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
568
+ class MidnightAmountExceedsMaxOfferCapError extends Error {
569
+ constructor(params) {
570
+ super(`Midnight ${params.label} "${params.amount}" exceeds maximum offer cap "${params.maxOfferCap}". Reduce the amount to the maximum offer cap or less.`);
562
571
  }
563
572
  }
564
- exports.NonPositiveMinBorrowSharePriceError = NonPositiveMinBorrowSharePriceError;
565
- /** Thrown when a market loan-asset supply amount is negative. */
566
- class NegativeSupplyAmountError extends Error {
567
- constructor(market) {
568
- super(`Supply amount must be non-negative for market: ${market}`);
573
+ exports.MidnightAmountExceedsMaxOfferCapError = MidnightAmountExceedsMaxOfferCapError;
574
+ /** Thrown when a Midnight flow needs at least one takeable offer. */
575
+ class EmptyMidnightTakeableOffersError extends Error {
576
+ constructor() {
577
+ super("Midnight takeable offers cannot be empty. Refresh the quote and try again.");
569
578
  }
570
579
  }
571
- exports.NegativeSupplyAmountError = NegativeSupplyAmountError;
572
- /** Thrown when a market loan-asset supply's `maxSharePrice` slippage bound is negative. */
573
- class NegativeSupplyMaxSharePriceError extends Error {
574
- constructor(market) {
575
- super(`Max share price must be non-negative for market: ${market}`);
580
+ exports.EmptyMidnightTakeableOffersError = EmptyMidnightTakeableOffersError;
581
+ /** Thrown when a Midnight offer has the wrong maker side for the requested flow. */
582
+ class MidnightOfferSideMismatchError extends Error {
583
+ constructor(params) {
584
+ super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
576
585
  }
577
586
  }
578
- exports.NegativeSupplyMaxSharePriceError = NegativeSupplyMaxSharePriceError;
579
- /** Thrown when both `amount` and `nativeAmount` resolve to zero on a market loan-asset supply. */
580
- class ZeroSupplyAmountError extends Error {
581
- constructor(market) {
582
- super(`Total supply amount must be positive for market: ${market}. Both amount and nativeAmount are zero.`);
587
+ exports.MidnightOfferSideMismatchError = MidnightOfferSideMismatchError;
588
+ /** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
589
+ class MidnightOfferMakerMismatchError extends Error {
590
+ constructor(params) {
591
+ super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
583
592
  }
584
593
  }
585
- exports.ZeroSupplyAmountError = ZeroSupplyAmountError;
586
- /** Thrown when a market loan-asset withdraw has both `assets` and `shares` zero, or either negative. */
587
- class NonPositiveWithdrawAmountError extends Error {
588
- constructor(market) {
589
- super(`Withdraw amount must be positive for market: ${market}`);
594
+ exports.MidnightOfferMakerMismatchError = MidnightOfferMakerMismatchError;
595
+ /** Thrown when a Midnight maker offer targets a different chain than the action flow. */
596
+ class MidnightOfferMarketChainMismatchError extends Error {
597
+ constructor(params) {
598
+ super(`Midnight offer "${params.index}" targets chain "${params.actualChainId}", expected "${params.expectedChainId}". Rebuild the offer set for the selected chain.`);
599
+ }
600
+ }
601
+ exports.MidnightOfferMarketChainMismatchError = MidnightOfferMarketChainMismatchError;
602
+ /** Thrown when a Midnight maker offer targets a different Midnight contract than the action flow. */
603
+ class MidnightOfferMarketAddressMismatchError extends Error {
604
+ constructor(params) {
605
+ super(`Midnight offer "${params.index}" targets Midnight "${params.actualMidnight}", expected "${params.expectedMidnight}". Rebuild the offer set for the selected chain.`);
606
+ }
607
+ }
608
+ exports.MidnightOfferMarketAddressMismatchError = MidnightOfferMarketAddressMismatchError;
609
+ /** Thrown when a Midnight market targets a different deployment than the selected chain. */
610
+ class MidnightMarketAddressMismatchError extends Error {
611
+ constructor(params) {
612
+ super(`Midnight market targets contract "${params.actualMidnight}", expected "${params.expectedMidnight}". Use market data from the selected chain deployment.`);
613
+ }
614
+ }
615
+ exports.MidnightMarketAddressMismatchError = MidnightMarketAddressMismatchError;
616
+ /** Thrown when a Midnight make-lend offer does not use the approved loan token. */
617
+ class MidnightOfferMarketLoanTokenMismatchError extends Error {
618
+ constructor(params) {
619
+ super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
620
+ }
621
+ }
622
+ exports.MidnightOfferMarketLoanTokenMismatchError = MidnightOfferMarketLoanTokenMismatchError;
623
+ /** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
624
+ class MidnightTakeableOfferMarketMismatchError extends Error {
625
+ constructor(params) {
626
+ super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
627
+ }
628
+ }
629
+ exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
630
+ /** Thrown when a Midnight offer tree uses an unsupported ratifier address. */
631
+ class UnknownMidnightRatifierError extends Error {
632
+ constructor(params) {
633
+ super(`Midnight offer tree uses ratifier "${params.ratifier}", expected "${params.ecrecoverRatifier}" or "${params.setterRatifier}". Rebuild the tree with a supported ratifier.`);
590
634
  }
591
635
  }
592
- exports.NonPositiveWithdrawAmountError = NonPositiveWithdrawAmountError;
593
- /** Thrown when a market loan-asset withdraw's `minSharePrice` slippage bound is negative. */
594
- class NegativeWithdrawMinSharePriceError extends Error {
636
+ exports.UnknownMidnightRatifierError = UnknownMidnightRatifierError;
637
+ /** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
638
+ class MissingMidnightOfferRootSignatureError extends Error {
639
+ constructor() {
640
+ super("Midnight offer root signature is missing. Sign the offer-root requirement before building the submit transaction.");
641
+ }
642
+ }
643
+ exports.MissingMidnightOfferRootSignatureError = MissingMidnightOfferRootSignatureError;
644
+ /** Thrown when a Midnight offer-root signature does not match the prepared tree root. */
645
+ class MidnightOfferRootMismatchError extends Error {
646
+ constructor(params) {
647
+ super(`Midnight offer root mismatch: expected "${params.expectedRoot}", got "${params.actualRoot}". Rebuild the flow and sign again.`);
648
+ }
649
+ }
650
+ exports.MidnightOfferRootMismatchError = MidnightOfferRootMismatchError;
651
+ /** Thrown when a Midnight offer-root signature was produced by another maker account. */
652
+ class MidnightOfferRootOwnerMismatchError extends Error {
653
+ constructor(params) {
654
+ super(`Midnight offer root owner mismatch: expected "${params.expectedOwner}", got "${params.actualOwner}". Rebuild the flow and sign again.`);
655
+ }
656
+ }
657
+ exports.MidnightOfferRootOwnerMismatchError = MidnightOfferRootOwnerMismatchError;
658
+ /** Thrown when a Midnight offer-root signature targets another ratifier. */
659
+ class MidnightOfferRootRatifierMismatchError extends Error {
660
+ constructor(params) {
661
+ super(`Midnight offer root ratifier mismatch: expected "${params.expectedRatifier}", got "${params.actualRatifier}". Rebuild the flow and sign again.`);
662
+ }
663
+ }
664
+ exports.MidnightOfferRootRatifierMismatchError = MidnightOfferRootRatifierMismatchError;
665
+ /** Thrown when a Midnight offer-root signature was produced for another offer count. */
666
+ class MidnightOfferRootOfferCountMismatchError extends Error {
667
+ constructor(params) {
668
+ super(`Midnight offer root offer-count mismatch: expected "${params.expectedOffers}", got "${params.actualOffers}". Rebuild the flow and sign again.`);
669
+ }
670
+ }
671
+ exports.MidnightOfferRootOfferCountMismatchError = MidnightOfferRootOfferCountMismatchError;
672
+ /** Thrown when a Midnight offer-root signature was not prepared by this maker flow. */
673
+ class UnpreparedMidnightOfferRootSignatureError extends Error {
674
+ constructor() {
675
+ super("Midnight offer root signature was not prepared for this offer tree. Sign this flow's offer-root requirement before building the submit transaction.");
676
+ }
677
+ }
678
+ exports.UnpreparedMidnightOfferRootSignatureError = UnpreparedMidnightOfferRootSignatureError;
679
+ /** Thrown when a Midnight redeem flow finds no credit units for the user. */
680
+ class NoMidnightCreditToRedeemError extends Error {
595
681
  constructor(market) {
596
- super(`Min share price must be non-negative for market: ${market}`);
682
+ super(`No Midnight credit is available to redeem for market "${market}".`);
683
+ }
684
+ }
685
+ exports.NoMidnightCreditToRedeemError = NoMidnightCreditToRedeemError;
686
+ /** Thrown when a Midnight redeem amount exceeds the user's accrued credit. */
687
+ class MidnightRedeemExceedsCreditError extends Error {
688
+ constructor(params) {
689
+ super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
597
690
  }
598
691
  }
599
- exports.NegativeWithdrawMinSharePriceError = NegativeWithdrawMinSharePriceError;
692
+ exports.MidnightRedeemExceedsCreditError = MidnightRedeemExceedsCreditError;
693
+ /** Thrown when a Midnight redeem amount exceeds the market's currently withdrawable liquidity. */
694
+ class InsufficientMidnightWithdrawableLiquidityError extends Error {
695
+ constructor(params) {
696
+ super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
697
+ }
698
+ }
699
+ exports.InsufficientMidnightWithdrawableLiquidityError = InsufficientMidnightWithdrawableLiquidityError;
600
700
  /** Thrown when a loan-asset withdraw specifies both `assets` and `shares` as non-zero (modes are mutually exclusive). */
601
701
  class MutuallyExclusiveWithdrawAmountsError extends Error {
602
702
  constructor(market) {
@@ -640,20 +740,6 @@ class VaultAssetMismatchError extends Error {
640
740
  }
641
741
  }
642
742
  exports.VaultAssetMismatchError = VaultAssetMismatchError;
643
- /** Thrown when a vault redeem's `minSharePrice` slippage bound is negative. */
644
- class NegativeMinSharePriceError extends Error {
645
- constructor(vault) {
646
- super(`Min share price must be non-negative for vault: ${vault}`);
647
- }
648
- }
649
- exports.NegativeMinSharePriceError = NegativeMinSharePriceError;
650
- /** Thrown when a refinance's `borrowShares` argument is negative. */
651
- class NegativeBorrowSharesError extends Error {
652
- constructor(market) {
653
- super(`Borrow shares must be non-negative for market: ${market}`);
654
- }
655
- }
656
- exports.NegativeBorrowSharesError = NegativeBorrowSharesError;
657
743
  /** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
658
744
  class BorrowAmountAndSharesExclusiveError extends Error {
659
745
  constructor(market) {
@@ -661,13 +747,6 @@ class BorrowAmountAndSharesExclusiveError extends Error {
661
747
  }
662
748
  }
663
749
  exports.BorrowAmountAndSharesExclusiveError = BorrowAmountAndSharesExclusiveError;
664
- /** Thrown when a refinance's `maxRepaySharePrice` slippage bound is negative. */
665
- class NegativeMaxRepaySharePriceError extends Error {
666
- constructor(market) {
667
- super(`Max repay share price must be non-negative for market: ${market}`);
668
- }
669
- }
670
- exports.NegativeMaxRepaySharePriceError = NegativeMaxRepaySharePriceError;
671
750
  /** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
672
751
  class RefinanceSameMarketError extends Error {
673
752
  constructor(market) {
@@ -1,6 +1,7 @@
1
1
  export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
2
2
  export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
3
3
  export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
4
+ export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
4
5
  export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
5
6
  export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
6
7
  export { computeReallocations } from "./helpers/computeReallocations.js";
package/lib/cjs/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateRepayShares = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinBorrowSharePrice = exports.computeMaxRepaySharePrice = exports.addTransactionMetadata = exports.computeReallocations = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = exports.createGetValue = exports.bigIntComparator = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.VaultUtils = exports.SharesMath = exports.MathLib = exports.MarketUtils = exports.CapacityLimitReason = exports.AdaptiveCurveIrmLib = void 0;
4
- exports.validateUserAddress = exports.validateSlippageTolerance = void 0;
3
+ exports.computeMaxRepaySharePrice = exports.addTransactionMetadata = exports.computeReallocations = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = exports.createGetValue = exports.bigIntComparator = exports.TreeUtils = exports.TickLib = exports.TakeAmountsLib = exports.SetterRatifierUtils = exports.RatifierUtils = exports.Payload = exports.OfferUtils = exports.GroupUtils = exports.EcrecoverRatifierUtils = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.VaultUtils = exports.SharesMath = exports.MathLib = exports.MarketUtils = exports.CapacityLimitReason = exports.AdaptiveCurveIrmLib = void 0;
4
+ exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validateReallocations = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinBorrowSharePrice = void 0;
5
5
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
7
7
  Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
@@ -21,6 +21,16 @@ Object.defineProperty(exports, "restructure", { enumerable: true, get: function
21
21
  Object.defineProperty(exports, "safeGetAddress", { enumerable: true, get: function () { return blue_sdk_viem_1.safeGetAddress; } });
22
22
  Object.defineProperty(exports, "safeParseNumber", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseNumber; } });
23
23
  Object.defineProperty(exports, "safeParseUnits", { enumerable: true, get: function () { return blue_sdk_viem_1.safeParseUnits; } });
24
+ var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
25
+ Object.defineProperty(exports, "EcrecoverRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.EcrecoverRatifierUtils; } });
26
+ Object.defineProperty(exports, "GroupUtils", { enumerable: true, get: function () { return midnight_sdk_1.GroupUtils; } });
27
+ Object.defineProperty(exports, "OfferUtils", { enumerable: true, get: function () { return midnight_sdk_1.OfferUtils; } });
28
+ Object.defineProperty(exports, "Payload", { enumerable: true, get: function () { return midnight_sdk_1.Payload; } });
29
+ Object.defineProperty(exports, "RatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.RatifierUtils; } });
30
+ Object.defineProperty(exports, "SetterRatifierUtils", { enumerable: true, get: function () { return midnight_sdk_1.SetterRatifierUtils; } });
31
+ Object.defineProperty(exports, "TakeAmountsLib", { enumerable: true, get: function () { return midnight_sdk_1.TakeAmountsLib; } });
32
+ Object.defineProperty(exports, "TickLib", { enumerable: true, get: function () { return midnight_sdk_1.TickLib; } });
33
+ Object.defineProperty(exports, "TreeUtils", { enumerable: true, get: function () { return midnight_sdk_1.TreeUtils; } });
24
34
  var morpho_ts_1 = require("@morpho-org/morpho-ts");
25
35
  Object.defineProperty(exports, "bigIntComparator", { enumerable: true, get: function () { return morpho_ts_1.bigIntComparator; } });
26
36
  Object.defineProperty(exports, "createGetValue", { enumerable: true, get: function () { return morpho_ts_1.createGetValue; } });