@morpho-org/morpho-sdk 8.3.0 → 9.1.0-next.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 (203) hide show
  1. package/MIGRATION-v8-to-v9.md +54 -0
  2. package/README.md +13 -7
  3. package/lib/cjs/abis.d.ts +1 -1
  4. package/lib/cjs/abis.js +5 -1
  5. package/lib/cjs/actions/bundles/common.d.ts +4 -7
  6. package/lib/cjs/actions/bundles/common.js +8 -14
  7. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  8. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -8
  9. package/lib/cjs/actions/midnight/authorization.d.ts +3 -1
  10. package/lib/cjs/actions/midnight/authorization.js +11 -1
  11. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -0
  12. package/lib/cjs/actions/midnight/cancelAndMake.js +10 -2
  13. package/lib/cjs/actions/midnight/redeem.d.ts +3 -1
  14. package/lib/cjs/actions/midnight/redeem.js +9 -3
  15. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  16. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +7 -3
  17. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +4 -1
  18. package/lib/cjs/actions/midnight/supplyCollateral.js +10 -3
  19. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  20. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +9 -3
  21. package/lib/cjs/actions/midnight/takeBorrow.d.ts +3 -1
  22. package/lib/cjs/actions/midnight/takeBorrow.js +9 -3
  23. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
  24. package/lib/cjs/actions/midnight/takeLend.js +7 -2
  25. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  26. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +8 -2
  27. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +3 -1
  28. package/lib/cjs/actions/midnight/takeWithdraw.js +10 -3
  29. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  30. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +5 -7
  31. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +7 -11
  32. package/lib/cjs/actions/requirements/getRequirementsApproval.js +8 -15
  33. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  34. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +11 -8
  35. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  36. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  37. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -1
  38. package/lib/cjs/actions/vaultV1/inKindRedeem.js +1 -1
  39. package/lib/cjs/actions/vaultV1/withdraw.d.ts +4 -4
  40. package/lib/cjs/actions/vaultV1/withdraw.js +4 -4
  41. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  42. package/lib/cjs/actions/vaultV2/forceWithdraw.js +1 -1
  43. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -1
  44. package/lib/cjs/actions/vaultV2/inKindRedeem.js +1 -1
  45. package/lib/cjs/actions/vaultV2/withdraw.d.ts +4 -4
  46. package/lib/cjs/actions/vaultV2/withdraw.js +4 -4
  47. package/lib/cjs/blue/abis.d.ts +1 -1
  48. package/lib/cjs/blue/abis.js +5 -1
  49. package/lib/cjs/blue/entities.d.ts +4 -4
  50. package/lib/cjs/blue/entities.js +3 -1
  51. package/lib/cjs/blue/errors.d.ts +2 -2
  52. package/lib/cjs/blue/errors.js +5 -1
  53. package/lib/cjs/blue/fetch.d.ts +2 -2
  54. package/lib/cjs/blue/fetch.js +3 -1
  55. package/lib/cjs/blue/utils.d.ts +1 -1
  56. package/lib/cjs/blue/utils.js +2 -1
  57. package/lib/cjs/entities/blue/blue.d.ts +2 -12
  58. package/lib/cjs/entities/blue/blue.js +0 -4
  59. package/lib/cjs/entities/index.d.ts +4 -4
  60. package/lib/cjs/entities/index.js +3 -1
  61. package/lib/cjs/entities/midnight/midnight.d.ts +63 -18
  62. package/lib/cjs/entities/midnight/midnight.js +138 -53
  63. package/lib/cjs/entities/midnight/types.d.ts +3 -10
  64. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  65. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +0 -7
  66. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  67. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -20
  68. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +40 -37
  69. package/lib/cjs/entities/vaultV1/vaultV1.js +5 -34
  70. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +69 -43
  71. package/lib/cjs/entities/vaultV2/vaultV2.js +41 -35
  72. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
  73. package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
  74. package/lib/cjs/errors.d.ts +4 -4
  75. package/lib/cjs/errors.js +10 -5
  76. package/lib/cjs/fetch.d.ts +2 -2
  77. package/lib/cjs/fetch.js +3 -1
  78. package/lib/cjs/helpers/encodeMidnightCalldata.d.ts +48 -0
  79. package/lib/cjs/helpers/encodeMidnightCalldata.js +74 -0
  80. package/lib/cjs/helpers/slippage.d.ts +9 -25
  81. package/lib/cjs/helpers/slippage.js +10 -27
  82. package/lib/cjs/helpers/validate.d.ts +1 -0
  83. package/lib/cjs/helpers/validate.js +5 -0
  84. package/lib/cjs/helpers/validateMidnightAccount.d.ts +34 -0
  85. package/lib/cjs/helpers/validateMidnightAccount.js +47 -0
  86. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  87. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +4 -0
  88. package/lib/cjs/helpers/validateMidnightMarket.d.ts +2 -0
  89. package/lib/cjs/helpers/validateMidnightMarket.js +5 -0
  90. package/lib/cjs/helpers/validateMidnightPublication.d.ts +11 -0
  91. package/lib/cjs/helpers/validateMidnightPublication.js +12 -1
  92. package/lib/cjs/helpers/validateMidnightReceiver.d.ts +1 -0
  93. package/lib/cjs/helpers/validateMidnightReceiver.js +8 -0
  94. package/lib/cjs/helpers/validateTakeableOffers.d.ts +2 -1
  95. package/lib/cjs/helpers/validateTakeableOffers.js +4 -3
  96. package/lib/cjs/midnight/errors.d.ts +2 -1
  97. package/lib/cjs/midnight/errors.js +5 -4
  98. package/lib/cjs/types/action.d.ts +3 -1
  99. package/lib/cjs/types/error.d.ts +60 -6
  100. package/lib/cjs/types/error.js +143 -11
  101. package/lib/cjs/utils.d.ts +2 -2
  102. package/lib/cjs/utils.js +4 -2
  103. package/lib/esm/abis.d.ts +1 -1
  104. package/lib/esm/abis.js +1 -1
  105. package/lib/esm/actions/bundles/common.d.ts +4 -7
  106. package/lib/esm/actions/bundles/common.js +8 -14
  107. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  108. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -9
  109. package/lib/esm/actions/midnight/authorization.d.ts +3 -1
  110. package/lib/esm/actions/midnight/authorization.js +12 -2
  111. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -0
  112. package/lib/esm/actions/midnight/cancelAndMake.js +11 -3
  113. package/lib/esm/actions/midnight/redeem.d.ts +3 -1
  114. package/lib/esm/actions/midnight/redeem.js +10 -4
  115. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  116. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +8 -4
  117. package/lib/esm/actions/midnight/supplyCollateral.d.ts +4 -1
  118. package/lib/esm/actions/midnight/supplyCollateral.js +11 -4
  119. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  120. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +10 -4
  121. package/lib/esm/actions/midnight/takeBorrow.d.ts +3 -1
  122. package/lib/esm/actions/midnight/takeBorrow.js +10 -4
  123. package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
  124. package/lib/esm/actions/midnight/takeLend.js +8 -3
  125. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  126. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +9 -3
  127. package/lib/esm/actions/midnight/takeWithdraw.d.ts +3 -1
  128. package/lib/esm/actions/midnight/takeWithdraw.js +11 -4
  129. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  130. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -8
  131. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +7 -11
  132. package/lib/esm/actions/requirements/getRequirementsApproval.js +9 -16
  133. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  134. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +12 -9
  135. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  136. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  137. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -1
  138. package/lib/esm/actions/vaultV1/inKindRedeem.js +1 -1
  139. package/lib/esm/actions/vaultV1/withdraw.d.ts +4 -4
  140. package/lib/esm/actions/vaultV1/withdraw.js +4 -4
  141. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  142. package/lib/esm/actions/vaultV2/forceWithdraw.js +1 -1
  143. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -1
  144. package/lib/esm/actions/vaultV2/inKindRedeem.js +1 -1
  145. package/lib/esm/actions/vaultV2/withdraw.d.ts +4 -4
  146. package/lib/esm/actions/vaultV2/withdraw.js +4 -4
  147. package/lib/esm/blue/abis.d.ts +1 -1
  148. package/lib/esm/blue/abis.js +1 -1
  149. package/lib/esm/blue/entities.d.ts +4 -4
  150. package/lib/esm/blue/entities.js +2 -2
  151. package/lib/esm/blue/errors.d.ts +2 -2
  152. package/lib/esm/blue/errors.js +2 -2
  153. package/lib/esm/blue/fetch.d.ts +2 -2
  154. package/lib/esm/blue/fetch.js +2 -2
  155. package/lib/esm/blue/utils.d.ts +1 -1
  156. package/lib/esm/blue/utils.js +1 -1
  157. package/lib/esm/entities/blue/blue.d.ts +2 -12
  158. package/lib/esm/entities/blue/blue.js +0 -4
  159. package/lib/esm/entities/index.d.ts +4 -4
  160. package/lib/esm/entities/index.js +2 -2
  161. package/lib/esm/entities/midnight/midnight.d.ts +63 -18
  162. package/lib/esm/entities/midnight/midnight.js +139 -54
  163. package/lib/esm/entities/midnight/types.d.ts +3 -10
  164. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  165. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +1 -8
  166. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  167. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +9 -21
  168. package/lib/esm/entities/vaultV1/vaultV1.d.ts +40 -37
  169. package/lib/esm/entities/vaultV1/vaultV1.js +6 -35
  170. package/lib/esm/entities/vaultV2/vaultV2.d.ts +69 -43
  171. package/lib/esm/entities/vaultV2/vaultV2.js +41 -35
  172. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
  173. package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
  174. package/lib/esm/errors.d.ts +4 -4
  175. package/lib/esm/errors.js +4 -4
  176. package/lib/esm/fetch.d.ts +2 -2
  177. package/lib/esm/fetch.js +2 -2
  178. package/lib/esm/helpers/encodeMidnightCalldata.d.ts +48 -0
  179. package/lib/esm/helpers/encodeMidnightCalldata.js +69 -0
  180. package/lib/esm/helpers/slippage.d.ts +9 -25
  181. package/lib/esm/helpers/slippage.js +9 -25
  182. package/lib/esm/helpers/validate.d.ts +1 -0
  183. package/lib/esm/helpers/validate.js +5 -0
  184. package/lib/esm/helpers/validateMidnightAccount.d.ts +34 -0
  185. package/lib/esm/helpers/validateMidnightAccount.js +43 -0
  186. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  187. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +4 -0
  188. package/lib/esm/helpers/validateMidnightMarket.d.ts +2 -0
  189. package/lib/esm/helpers/validateMidnightMarket.js +5 -0
  190. package/lib/esm/helpers/validateMidnightPublication.d.ts +11 -0
  191. package/lib/esm/helpers/validateMidnightPublication.js +10 -0
  192. package/lib/esm/helpers/validateMidnightReceiver.d.ts +1 -0
  193. package/lib/esm/helpers/validateMidnightReceiver.js +8 -0
  194. package/lib/esm/helpers/validateTakeableOffers.d.ts +2 -1
  195. package/lib/esm/helpers/validateTakeableOffers.js +4 -3
  196. package/lib/esm/midnight/errors.d.ts +2 -1
  197. package/lib/esm/midnight/errors.js +2 -1
  198. package/lib/esm/types/action.d.ts +3 -1
  199. package/lib/esm/types/error.d.ts +60 -6
  200. package/lib/esm/types/error.js +138 -7
  201. package/lib/esm/utils.d.ts +2 -2
  202. package/lib/esm/utils.js +2 -2
  203. package/package.json +8 -7
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.UnsupportedRequirementSignatureError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.MaxRepayAssetsBelowRepayAssetsError = exports.ReallocationsRequireBorrowError = exports.UnsupportedAuthorizationOperatorError = exports.ReallocationLoanTokenMismatchError = exports.SameVaultMigrationError = exports.AmountAndSharesExclusiveError = exports.MixedBundlesFundingError = exports.MidnightReferralFeePctExceededError = exports.ReferralFeePctExceededError = exports.ReferralFeeRecipientMissingError = exports.NativeFundingAmountMismatchError = exports.NoUnusedPermit2NonceError = exports.Permit2SignatureTransferNonceAlreadyUsedError = exports.BundlesRequirementSignatureMismatchError = exports.BundlesPermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.VaultV2ForceWithdrawFeeSharesExceedBurnError = exports.VaultV2ForceWithdrawSharePriceBelowFloorError = exports.VaultV2ForceWithdrawZeroSharePriceError = exports.VaultV2ForceWithdrawZeroWithdrawalError = exports.VaultV2ForceWithdrawCoverageError = exports.VaultV2UndecodableLiquidityDataError = exports.VaultV2UnsupportedLiquidityAdapterError = exports.VaultV2UnsupportedExitAdapterError = exports.AdapterNotPartOfVaultError = exports.VaultV2SingleAdapterRequiredError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
4
- exports.MidnightOfferMarketChainMismatchError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightContractReceiverError = exports.MidnightZeroOnBehalfError = exports.MidnightZeroReceiverError = exports.MidnightRepayExceedsDebtError = exports.MidnightContinuousFeeAboveMaxError = exports.MidnightTakeTargetUnreachableError = exports.MidnightTakeableOffersNotFillableError = exports.UnboundedMidnightTakeInputError = exports.MidnightOfferSellerReceiverMismatchError = exports.MidnightOfferContinuousFeeCapError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferReduceOnlyError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.DuplicateMidnightGroupCancellationError = exports.EmptyMidnightCollateralSuppliesError = exports.EmptyMidnightGroupCancellationsError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = exports.DepositOwnerMismatchError = void 0;
5
- exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferMarketMismatchError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = void 0;
3
+ exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnsupportedRequirementSignatureError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.MaxRepayAssetsBelowRepayAssetsError = exports.ReallocationsRequireBorrowError = exports.UnsupportedAuthorizationOperatorError = exports.ReallocationLoanTokenMismatchError = exports.SameVaultMigrationError = exports.AmountAndSharesExclusiveError = exports.MixedBundlesFundingError = exports.MidnightReferralFeePctExceededError = exports.ReferralFeePctExceededError = exports.ReferralFeeRecipientMissingError = exports.NativeFundingAmountMismatchError = exports.NoUnusedPermit2NonceError = exports.Permit2SignatureTransferNonceAlreadyUsedError = exports.BundlesRequirementSignatureMismatchError = exports.BundlesPermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.VaultV2ForceWithdrawFeeSharesExceedBurnError = exports.VaultV2ForceWithdrawSharePriceBelowFloorError = exports.VaultV2ForceWithdrawZeroSharePriceError = exports.VaultV2ForceWithdrawZeroWithdrawalError = exports.VaultV2ForceWithdrawCoverageError = exports.VaultV2UndecodableLiquidityDataError = exports.VaultV2UnsupportedLiquidityAdapterError = exports.VaultV2UnsupportedExitAdapterError = exports.AdapterNotPartOfVaultError = exports.VaultV2SingleAdapterRequiredError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
4
+ exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightContractReceiverError = exports.MidnightZeroOnBehalfError = exports.MidnightZeroReceiverError = exports.MidnightRepayExceedsDebtError = exports.MidnightContinuousFeeAboveMaxError = exports.MidnightTakeTargetUnreachableError = exports.MidnightTakeableOffersNotFillableError = exports.UnboundedMidnightTakeInputError = exports.MidnightOfferSellerReceiverMismatchError = exports.MidnightOfferContinuousFeeCapError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferReduceOnlyError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.DuplicateMidnightGroupCancellationError = exports.EmptyMidnightCollateralSuppliesError = exports.EmptyMidnightGroupCancellationsError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = void 0;
5
+ exports.MidnightCalldataEncodingError = exports.MidnightZeroAccountError = exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferMarketMismatchError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = void 0;
6
6
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
7
7
  const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
8
8
  const constant_js_1 = require("../helpers/constant.js");
@@ -834,6 +834,7 @@ class AmbiguousRequirementSignaturesError extends Error {
834
834
  */
835
835
  constructor(kind, count) {
836
836
  super(`Expected at most one ${kind} signature but received ${count}. Pass a single ${kind} signature to buildTx.`);
837
+ this.name = "AmbiguousRequirementSignaturesError";
837
838
  }
838
839
  }
839
840
  exports.AmbiguousRequirementSignaturesError = AmbiguousRequirementSignaturesError;
@@ -856,6 +857,7 @@ class UnexpectedRequirementSignatureError extends Error {
856
857
  */
857
858
  constructor(kind) {
858
859
  super(`Received a ${kind} signature that this operation does not consume. Remove it from the buildTx signatures array.`);
860
+ this.name = "UnexpectedRequirementSignatureError";
859
861
  }
860
862
  }
861
863
  exports.UnexpectedRequirementSignatureError = UnexpectedRequirementSignatureError;
@@ -868,6 +870,7 @@ class UnsupportedRequirementSignatureError extends Error {
868
870
  constructor(type) {
869
871
  super(`Received a requirement signature with unsupported action type "${type}". Re-run getRequirements() and sign the current requirements.`);
870
872
  this.type = type;
873
+ this.name = "UnsupportedRequirementSignatureError";
871
874
  }
872
875
  }
873
876
  exports.UnsupportedRequirementSignatureError = UnsupportedRequirementSignatureError;
@@ -875,6 +878,7 @@ exports.UnsupportedRequirementSignatureError = UnsupportedRequirementSignatureEr
875
878
  class AddressMismatchError extends Error {
876
879
  constructor(clientAddress, argsAddress) {
877
880
  super(`Address mismatch between client: ${clientAddress} and args: ${argsAddress}`);
881
+ this.name = "AddressMismatchError";
878
882
  }
879
883
  }
880
884
  exports.AddressMismatchError = AddressMismatchError;
@@ -882,6 +886,7 @@ exports.AddressMismatchError = AddressMismatchError;
882
886
  class ChainIdMismatchError extends Error {
883
887
  constructor(clientChainId, argsChainId) {
884
888
  super(`Chain ID mismatch between client: ${clientChainId} and args: ${argsChainId}`);
889
+ this.name = "ChainIdMismatchError";
885
890
  }
886
891
  }
887
892
  exports.ChainIdMismatchError = ChainIdMismatchError;
@@ -889,6 +894,7 @@ exports.ChainIdMismatchError = ChainIdMismatchError;
889
894
  class CryptoUnavailableError extends Error {
890
895
  constructor(feature) {
891
896
  super(`Crypto API is required for ${feature} but is unavailable.`);
897
+ this.name = "CryptoUnavailableError";
892
898
  }
893
899
  }
894
900
  exports.CryptoUnavailableError = CryptoUnavailableError;
@@ -896,16 +902,10 @@ exports.CryptoUnavailableError = CryptoUnavailableError;
896
902
  class MissingClientPropertyError extends Error {
897
903
  constructor(property) {
898
904
  super(`A required ${property} is missing from the client.`);
905
+ this.name = "MissingClientPropertyError";
899
906
  }
900
907
  }
901
908
  exports.MissingClientPropertyError = MissingClientPropertyError;
902
- /** Thrown when an approval amount is smaller than the spend amount it must cover. */
903
- class ApprovalAmountLessThanSpendAmountError extends Error {
904
- constructor() {
905
- super("Approval amount is less than spend amount");
906
- }
907
- }
908
- exports.ApprovalAmountLessThanSpendAmountError = ApprovalAmountLessThanSpendAmountError;
909
909
  /** Thrown when a requirement encoder targets an unsupported spender. */
910
910
  class UnsupportedErc20ApprovalSpenderError extends Error {
911
911
  constructor(params) {
@@ -913,6 +913,7 @@ class UnsupportedErc20ApprovalSpenderError extends Error {
913
913
  .filter((address) => address != null)
914
914
  .join('", "');
915
915
  super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
916
+ this.name = "UnsupportedErc20ApprovalSpenderError";
916
917
  }
917
918
  }
918
919
  exports.UnsupportedErc20ApprovalSpenderError = UnsupportedErc20ApprovalSpenderError;
@@ -920,6 +921,7 @@ exports.UnsupportedErc20ApprovalSpenderError = UnsupportedErc20ApprovalSpenderEr
920
921
  class UnsupportedMidnightAuthorizationTargetError extends Error {
921
922
  constructor(params) {
922
923
  super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
924
+ this.name = "UnsupportedMidnightAuthorizationTargetError";
923
925
  }
924
926
  }
925
927
  exports.UnsupportedMidnightAuthorizationTargetError = UnsupportedMidnightAuthorizationTargetError;
@@ -929,6 +931,7 @@ class MissingAccrualPositionError extends Error {
929
931
  super(market == null
930
932
  ? "Accrual position is missing. Fetch the position data and try again."
931
933
  : `Accrual position is missing for market: ${market}`);
934
+ this.name = "MissingAccrualPositionError";
932
935
  }
933
936
  }
934
937
  exports.MissingAccrualPositionError = MissingAccrualPositionError;
@@ -936,6 +939,7 @@ exports.MissingAccrualPositionError = MissingAccrualPositionError;
936
939
  class ExcessiveSlippageToleranceError extends Error {
937
940
  constructor(slippageTolerance) {
938
941
  super(`Slippage tolerance ${slippageTolerance} exceeds maximum allowed (10%)`);
942
+ this.name = "ExcessiveSlippageToleranceError";
939
943
  }
940
944
  }
941
945
  exports.ExcessiveSlippageToleranceError = ExcessiveSlippageToleranceError;
@@ -943,6 +947,7 @@ exports.ExcessiveSlippageToleranceError = ExcessiveSlippageToleranceError;
943
947
  class EmptyDeallocationsError extends Error {
944
948
  constructor(vault) {
945
949
  super(`Deallocations list cannot be empty for vault: ${vault}`);
950
+ this.name = "EmptyDeallocationsError";
946
951
  }
947
952
  }
948
953
  exports.EmptyDeallocationsError = EmptyDeallocationsError;
@@ -950,6 +955,7 @@ exports.EmptyDeallocationsError = EmptyDeallocationsError;
950
955
  class DepositAmountMismatchError extends Error {
951
956
  constructor(depositAmount, signatureAmount) {
952
957
  super(`Deposit amount "${depositAmount}" does not match requirement signature amount "${signatureAmount}"`);
958
+ this.name = "DepositAmountMismatchError";
953
959
  }
954
960
  }
955
961
  exports.DepositAmountMismatchError = DepositAmountMismatchError;
@@ -957,6 +963,7 @@ exports.DepositAmountMismatchError = DepositAmountMismatchError;
957
963
  class DepositAssetMismatchError extends Error {
958
964
  constructor(depositAsset, signatureAsset) {
959
965
  super(`Deposit asset "${depositAsset}" does not match requirement signature asset "${signatureAsset}"`);
966
+ this.name = "DepositAssetMismatchError";
960
967
  }
961
968
  }
962
969
  exports.DepositAssetMismatchError = DepositAssetMismatchError;
@@ -964,6 +971,7 @@ exports.DepositAssetMismatchError = DepositAssetMismatchError;
964
971
  class DepositOwnerMismatchError extends Error {
965
972
  constructor(depositOwner, signatureOwner) {
966
973
  super(`Deposit owner "${depositOwner}" does not match requirement signature owner "${signatureOwner}"`);
974
+ this.name = "DepositOwnerMismatchError";
967
975
  }
968
976
  }
969
977
  exports.DepositOwnerMismatchError = DepositOwnerMismatchError;
@@ -971,6 +979,7 @@ exports.DepositOwnerMismatchError = DepositOwnerMismatchError;
971
979
  class DepositSpenderMismatchError extends Error {
972
980
  constructor(depositSpender, signatureSpender) {
973
981
  super(`Deposit spender "${depositSpender}" does not match requirement signature spender "${signatureSpender}"`);
982
+ this.name = "DepositSpenderMismatchError";
974
983
  }
975
984
  }
976
985
  exports.DepositSpenderMismatchError = DepositSpenderMismatchError;
@@ -978,6 +987,7 @@ exports.DepositSpenderMismatchError = DepositSpenderMismatchError;
978
987
  class NativeAmountOnNonWNativeVaultError extends Error {
979
988
  constructor(vaultAsset, wNative) {
980
989
  super(`Cannot use nativeAmount: vault asset ${vaultAsset} is not the wrapped native token ${wNative}`);
990
+ this.name = "NativeAmountOnNonWNativeVaultError";
981
991
  }
982
992
  }
983
993
  exports.NativeAmountOnNonWNativeVaultError = NativeAmountOnNonWNativeVaultError;
@@ -985,6 +995,7 @@ exports.NativeAmountOnNonWNativeVaultError = NativeAmountOnNonWNativeVaultError;
985
995
  class ChainWNativeMissingError extends Error {
986
996
  constructor(chainId) {
987
997
  super(`Chain ${chainId} does not have a configured wrapped native token (wNative)`);
998
+ this.name = "ChainWNativeMissingError";
988
999
  }
989
1000
  }
990
1001
  exports.ChainWNativeMissingError = ChainWNativeMissingError;
@@ -992,6 +1003,7 @@ exports.ChainWNativeMissingError = ChainWNativeMissingError;
992
1003
  class VaultAddressMismatchError extends Error {
993
1004
  constructor(vaultAddress, argsVaultAddress) {
994
1005
  super(`Vault address mismatch between vault: ${vaultAddress} and args: ${argsVaultAddress}`);
1006
+ this.name = "VaultAddressMismatchError";
995
1007
  }
996
1008
  }
997
1009
  exports.VaultAddressMismatchError = VaultAddressMismatchError;
@@ -999,6 +1011,7 @@ exports.VaultAddressMismatchError = VaultAddressMismatchError;
999
1011
  class NativeAmountOnNonWNativeAssetError extends Error {
1000
1012
  constructor(asset, wNative) {
1001
1013
  super(`Cannot use nativeAmount: asset ${asset} is not the wrapped native token ${wNative}`);
1014
+ this.name = "NativeAmountOnNonWNativeAssetError";
1002
1015
  }
1003
1016
  }
1004
1017
  exports.NativeAmountOnNonWNativeAssetError = NativeAmountOnNonWNativeAssetError;
@@ -1006,6 +1019,7 @@ exports.NativeAmountOnNonWNativeAssetError = NativeAmountOnNonWNativeAssetError;
1006
1019
  class BorrowExceedsSafeLtvError extends Error {
1007
1020
  constructor(borrowAmount, maxSafeBorrow) {
1008
1021
  super(`Borrow amount ${borrowAmount} exceeds safe maximum ${maxSafeBorrow} (LLTV minus buffer). Reduce borrow or increase collateral.`);
1022
+ this.name = "BorrowExceedsSafeLtvError";
1009
1023
  }
1010
1024
  }
1011
1025
  exports.BorrowExceedsSafeLtvError = BorrowExceedsSafeLtvError;
@@ -1013,6 +1027,7 @@ exports.BorrowExceedsSafeLtvError = BorrowExceedsSafeLtvError;
1013
1027
  class MissingMarketPriceError extends Error {
1014
1028
  constructor(market) {
1015
1029
  super(`Oracle price unavailable for market ${market}. Cannot validate position health.`);
1030
+ this.name = "MissingMarketPriceError";
1016
1031
  }
1017
1032
  }
1018
1033
  exports.MissingMarketPriceError = MissingMarketPriceError;
@@ -1020,6 +1035,7 @@ exports.MissingMarketPriceError = MissingMarketPriceError;
1020
1035
  class MarketIdMismatchError extends Error {
1021
1036
  constructor(marketId, expectedMarketId) {
1022
1037
  super(`Market ${marketId} does not match expected market ${expectedMarketId}`);
1038
+ this.name = "MarketIdMismatchError";
1023
1039
  }
1024
1040
  }
1025
1041
  exports.MarketIdMismatchError = MarketIdMismatchError;
@@ -1027,6 +1043,7 @@ exports.MarketIdMismatchError = MarketIdMismatchError;
1027
1043
  class AccrualPositionUserMismatchError extends Error {
1028
1044
  constructor(positionUser, expectedUser) {
1029
1045
  super(`Accrual position user ${positionUser} does not match expected user ${expectedUser}`);
1046
+ this.name = "AccrualPositionUserMismatchError";
1030
1047
  }
1031
1048
  }
1032
1049
  exports.AccrualPositionUserMismatchError = AccrualPositionUserMismatchError;
@@ -1034,6 +1051,7 @@ exports.AccrualPositionUserMismatchError = AccrualPositionUserMismatchError;
1034
1051
  class ReallocationWithdrawalOnTargetMarketError extends Error {
1035
1052
  constructor(vault, marketId) {
1036
1053
  super(`Reallocation withdrawal cannot include the target market ${marketId} for vault ${vault}.`);
1054
+ this.name = "ReallocationWithdrawalOnTargetMarketError";
1037
1055
  }
1038
1056
  }
1039
1057
  exports.ReallocationWithdrawalOnTargetMarketError = ReallocationWithdrawalOnTargetMarketError;
@@ -1156,6 +1174,7 @@ exports.InconsistentReallocationPenaltyError = InconsistentReallocationPenaltyEr
1156
1174
  class MutuallyExclusiveRepayAmountsError extends Error {
1157
1175
  constructor(market) {
1158
1176
  super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
1177
+ this.name = "MutuallyExclusiveRepayAmountsError";
1159
1178
  }
1160
1179
  }
1161
1180
  exports.MutuallyExclusiveRepayAmountsError = MutuallyExclusiveRepayAmountsError;
@@ -1163,6 +1182,7 @@ exports.MutuallyExclusiveRepayAmountsError = MutuallyExclusiveRepayAmountsError;
1163
1182
  class WithdrawExceedsCollateralError extends Error {
1164
1183
  constructor(params) {
1165
1184
  super(`Withdraw amount ${params.withdrawAmount} exceeds available collateral ${params.available} for market: ${params.market}`);
1185
+ this.name = "WithdrawExceedsCollateralError";
1166
1186
  }
1167
1187
  }
1168
1188
  exports.WithdrawExceedsCollateralError = WithdrawExceedsCollateralError;
@@ -1170,6 +1190,7 @@ exports.WithdrawExceedsCollateralError = WithdrawExceedsCollateralError;
1170
1190
  class WithdrawMakesPositionUnhealthyError extends Error {
1171
1191
  constructor(params) {
1172
1192
  super(`Withdrawing ${params.withdrawAmount} collateral would make position unhealthy. Max safe borrow after withdrawal: ${params.maxSafeBorrow}. Actual Borrow assets: ${params.borrowAssets}.`);
1193
+ this.name = "WithdrawMakesPositionUnhealthyError";
1173
1194
  }
1174
1195
  }
1175
1196
  exports.WithdrawMakesPositionUnhealthyError = WithdrawMakesPositionUnhealthyError;
@@ -1177,6 +1198,7 @@ exports.WithdrawMakesPositionUnhealthyError = WithdrawMakesPositionUnhealthyErro
1177
1198
  class RepayExceedsDebtError extends Error {
1178
1199
  constructor(params) {
1179
1200
  super(`Repay amount ${params.repayAmount} exceeds outstanding debt ${params.debt} for market: ${params.market}`);
1201
+ this.name = "RepayExceedsDebtError";
1180
1202
  }
1181
1203
  }
1182
1204
  exports.RepayExceedsDebtError = RepayExceedsDebtError;
@@ -1184,6 +1206,7 @@ exports.RepayExceedsDebtError = RepayExceedsDebtError;
1184
1206
  class InvalidSignatureError extends Error {
1185
1207
  constructor() {
1186
1208
  super("Signature verification failed: the signed data does not match the expected signer address");
1209
+ this.name = "InvalidSignatureError";
1187
1210
  }
1188
1211
  }
1189
1212
  exports.InvalidSignatureError = InvalidSignatureError;
@@ -1191,6 +1214,7 @@ exports.InvalidSignatureError = InvalidSignatureError;
1191
1214
  class RepaySharesExceedDebtError extends Error {
1192
1215
  constructor(params) {
1193
1216
  super(`Repay shares ${params.repayShares} exceed outstanding borrow shares ${params.borrowShares} for market: ${params.market}`);
1217
+ this.name = "RepaySharesExceedDebtError";
1194
1218
  }
1195
1219
  }
1196
1220
  exports.RepaySharesExceedDebtError = RepaySharesExceedDebtError;
@@ -1206,6 +1230,7 @@ class InsufficientSharedLiquidityError extends Error {
1206
1230
  constructor(params) {
1207
1231
  super(`Shared liquidity is insufficient on market ${params.marketId}: shortfall "${params.shortfall}", available "${params.available}". Reduce the operation amount or wait for additional vault liquidity.`);
1208
1232
  this.params = params;
1233
+ this.name = "InsufficientSharedLiquidityError";
1209
1234
  }
1210
1235
  }
1211
1236
  exports.InsufficientSharedLiquidityError = InsufficientSharedLiquidityError;
@@ -1218,6 +1243,7 @@ class UnknownReallocationMarketError extends blue_sdk_1.UnknownDataError {
1218
1243
  constructor(marketId) {
1219
1244
  super(`unknown reallocation market "${marketId}"`);
1220
1245
  this.marketId = marketId;
1246
+ this.name = "UnknownReallocationMarketError";
1221
1247
  }
1222
1248
  }
1223
1249
  exports.UnknownReallocationMarketError = UnknownReallocationMarketError;
@@ -1230,6 +1256,7 @@ class UnknownReallocationVaultError extends blue_sdk_1.UnknownDataError {
1230
1256
  constructor(vault) {
1231
1257
  super(`unknown reallocation vault "${vault}"`);
1232
1258
  this.vault = vault;
1259
+ this.name = "UnknownReallocationVaultError";
1233
1260
  }
1234
1261
  }
1235
1262
  exports.UnknownReallocationVaultError = UnknownReallocationVaultError;
@@ -1245,6 +1272,7 @@ class UnknownReallocationAllocationError extends blue_sdk_1.UnknownDataError {
1245
1272
  super(`unknown reallocation allocation "${id}" for vault "${vault}"`);
1246
1273
  this.vault = vault;
1247
1274
  this.id = id;
1275
+ this.name = "UnknownReallocationAllocationError";
1248
1276
  }
1249
1277
  }
1250
1278
  exports.UnknownReallocationAllocationError = UnknownReallocationAllocationError;
@@ -1255,6 +1283,7 @@ class UnknownReallocationPublicAllocatorConfigError extends blue_sdk_1.UnknownDa
1255
1283
  constructor(vault) {
1256
1284
  super(`unknown public allocator configuration for vault "${vault}"`);
1257
1285
  this.vault = vault;
1286
+ this.name = "UnknownReallocationPublicAllocatorConfigError";
1258
1287
  }
1259
1288
  }
1260
1289
  exports.UnknownReallocationPublicAllocatorConfigError = UnknownReallocationPublicAllocatorConfigError;
@@ -1265,6 +1294,7 @@ class UnknownReallocationActiveAdaptersError extends blue_sdk_1.UnknownDataError
1265
1294
  constructor(vault) {
1266
1295
  super(`unknown active adapters for reallocation vault "${vault}"`);
1267
1296
  this.vault = vault;
1297
+ this.name = "UnknownReallocationActiveAdaptersError";
1268
1298
  }
1269
1299
  }
1270
1300
  exports.UnknownReallocationActiveAdaptersError = UnknownReallocationActiveAdaptersError;
@@ -1280,6 +1310,7 @@ class UnknownReallocationMarketPublicAllocatorConfigError extends blue_sdk_1.Unk
1280
1310
  super(`unknown public allocator configuration "${adapterMarketCapId}" for vault "${vault}"`);
1281
1311
  this.vault = vault;
1282
1312
  this.adapterMarketCapId = adapterMarketCapId;
1313
+ this.name = "UnknownReallocationMarketPublicAllocatorConfigError";
1283
1314
  }
1284
1315
  }
1285
1316
  exports.UnknownReallocationMarketPublicAllocatorConfigError = UnknownReallocationMarketPublicAllocatorConfigError;
@@ -1295,6 +1326,7 @@ class UnknownReallocationAdapterError extends blue_sdk_1.UnknownDataError {
1295
1326
  super(`unknown reallocation adapter "${adapter}" for vault "${vault}"`);
1296
1327
  this.vault = vault;
1297
1328
  this.adapter = adapter;
1329
+ this.name = "UnknownReallocationAdapterError";
1298
1330
  }
1299
1331
  }
1300
1332
  exports.UnknownReallocationAdapterError = UnknownReallocationAdapterError;
@@ -1304,6 +1336,7 @@ class ReallocationAllocationUnderflowError extends Error {
1304
1336
  constructor(params) {
1305
1337
  super(`Reallocation change "${params.change}" exceeds allocation "${params.allocation}" for id "${params.id}" on vault "${params.vault}". Refresh the reallocation data and recompute the plan.`);
1306
1338
  this.params = params;
1339
+ this.name = "ReallocationAllocationUnderflowError";
1307
1340
  }
1308
1341
  }
1309
1342
  exports.ReallocationAllocationUnderflowError = ReallocationAllocationUnderflowError;
@@ -1313,6 +1346,7 @@ class ReallocationAdapterSupplySharesUnderflowError extends Error {
1313
1346
  constructor(params) {
1314
1347
  super(`Reallocation withdraw shares "${params.withdrawnShares}" exceed adapter supply shares "${params.supplyShares}" on market "${params.marketId}" for adapter "${params.adapter}". Refresh the reallocation data and recompute the plan.`);
1315
1348
  this.params = params;
1349
+ this.name = "ReallocationAdapterSupplySharesUnderflowError";
1316
1350
  }
1317
1351
  }
1318
1352
  exports.ReallocationAdapterSupplySharesUnderflowError = ReallocationAdapterSupplySharesUnderflowError;
@@ -1320,6 +1354,7 @@ exports.ReallocationAdapterSupplySharesUnderflowError = ReallocationAdapterSuppl
1320
1354
  class EmptyMidnightGroupCancellationsError extends Error {
1321
1355
  constructor() {
1322
1356
  super("Midnight group cancellations cannot be empty. Pass at least one offer group to cancel.");
1357
+ this.name = "EmptyMidnightGroupCancellationsError";
1323
1358
  }
1324
1359
  }
1325
1360
  exports.EmptyMidnightGroupCancellationsError = EmptyMidnightGroupCancellationsError;
@@ -1327,6 +1362,7 @@ exports.EmptyMidnightGroupCancellationsError = EmptyMidnightGroupCancellationsEr
1327
1362
  class EmptyMidnightCollateralSuppliesError extends Error {
1328
1363
  constructor() {
1329
1364
  super("Midnight collateral supplies cannot be empty. Pass at least one collateral supply, or use `makeBorrow` to publish without collateral.");
1365
+ this.name = "EmptyMidnightCollateralSuppliesError";
1330
1366
  }
1331
1367
  }
1332
1368
  exports.EmptyMidnightCollateralSuppliesError = EmptyMidnightCollateralSuppliesError;
@@ -1334,6 +1370,7 @@ exports.EmptyMidnightCollateralSuppliesError = EmptyMidnightCollateralSuppliesEr
1334
1370
  class DuplicateMidnightGroupCancellationError extends Error {
1335
1371
  constructor(params) {
1336
1372
  super(`Midnight group cancellation "${params.index}" repeats group "${params.group}". Pass each offer group once.`);
1373
+ this.name = "DuplicateMidnightGroupCancellationError";
1337
1374
  }
1338
1375
  }
1339
1376
  exports.DuplicateMidnightGroupCancellationError = DuplicateMidnightGroupCancellationError;
@@ -1341,6 +1378,7 @@ exports.DuplicateMidnightGroupCancellationError = DuplicateMidnightGroupCancella
1341
1378
  class EmptyMidnightTakeableOffersError extends Error {
1342
1379
  constructor() {
1343
1380
  super("Midnight takeable offers cannot be empty. Refresh the quote and try again.");
1381
+ this.name = "EmptyMidnightTakeableOffersError";
1344
1382
  }
1345
1383
  }
1346
1384
  exports.EmptyMidnightTakeableOffersError = EmptyMidnightTakeableOffersError;
@@ -1348,6 +1386,7 @@ exports.EmptyMidnightTakeableOffersError = EmptyMidnightTakeableOffersError;
1348
1386
  class MidnightOfferSideMismatchError extends Error {
1349
1387
  constructor(params) {
1350
1388
  super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
1389
+ this.name = "MidnightOfferSideMismatchError";
1351
1390
  }
1352
1391
  }
1353
1392
  exports.MidnightOfferSideMismatchError = MidnightOfferSideMismatchError;
@@ -1355,6 +1394,7 @@ exports.MidnightOfferSideMismatchError = MidnightOfferSideMismatchError;
1355
1394
  class MidnightOfferReduceOnlyError extends Error {
1356
1395
  constructor(params) {
1357
1396
  super(`Midnight offer "${params.index}" is reduce-only. Rebuild the offer with reduceOnly=false; reduce-only exits need a dedicated exit flow.`);
1397
+ this.name = "MidnightOfferReduceOnlyError";
1358
1398
  }
1359
1399
  }
1360
1400
  exports.MidnightOfferReduceOnlyError = MidnightOfferReduceOnlyError;
@@ -1362,6 +1402,7 @@ exports.MidnightOfferReduceOnlyError = MidnightOfferReduceOnlyError;
1362
1402
  class MidnightOfferMakerMismatchError extends Error {
1363
1403
  constructor(params) {
1364
1404
  super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
1405
+ this.name = "MidnightOfferMakerMismatchError";
1365
1406
  }
1366
1407
  }
1367
1408
  exports.MidnightOfferMakerMismatchError = MidnightOfferMakerMismatchError;
@@ -1604,6 +1645,7 @@ exports.MidnightTakeDeadlineTooFarError = MidnightTakeDeadlineTooFarError;
1604
1645
  class MidnightOfferMarketChainMismatchError extends Error {
1605
1646
  constructor(params) {
1606
1647
  super(`Midnight offer "${params.index}" targets chain "${params.actualChainId}", expected "${params.expectedChainId}". Rebuild the offer set for the selected chain.`);
1648
+ this.name = "MidnightOfferMarketChainMismatchError";
1607
1649
  }
1608
1650
  }
1609
1651
  exports.MidnightOfferMarketChainMismatchError = MidnightOfferMarketChainMismatchError;
@@ -1611,6 +1653,7 @@ exports.MidnightOfferMarketChainMismatchError = MidnightOfferMarketChainMismatch
1611
1653
  class MidnightOfferMarketAddressMismatchError extends Error {
1612
1654
  constructor(params) {
1613
1655
  super(`Midnight offer "${params.index}" targets Midnight "${params.actualMidnight}", expected "${params.expectedMidnight}". Rebuild the offer set for the selected chain.`);
1656
+ this.name = "MidnightOfferMarketAddressMismatchError";
1614
1657
  }
1615
1658
  }
1616
1659
  exports.MidnightOfferMarketAddressMismatchError = MidnightOfferMarketAddressMismatchError;
@@ -1618,6 +1661,7 @@ exports.MidnightOfferMarketAddressMismatchError = MidnightOfferMarketAddressMism
1618
1661
  class MidnightMarketAddressMismatchError extends Error {
1619
1662
  constructor(params) {
1620
1663
  super(`Midnight market targets contract "${params.actualMidnight}", expected "${params.expectedMidnight}". Use market data from the selected chain deployment.`);
1664
+ this.name = "MidnightMarketAddressMismatchError";
1621
1665
  }
1622
1666
  }
1623
1667
  exports.MidnightMarketAddressMismatchError = MidnightMarketAddressMismatchError;
@@ -1625,6 +1669,7 @@ exports.MidnightMarketAddressMismatchError = MidnightMarketAddressMismatchError;
1625
1669
  class MidnightOfferMarketLoanTokenMismatchError extends Error {
1626
1670
  constructor(params) {
1627
1671
  super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
1672
+ this.name = "MidnightOfferMarketLoanTokenMismatchError";
1628
1673
  }
1629
1674
  }
1630
1675
  exports.MidnightOfferMarketLoanTokenMismatchError = MidnightOfferMarketLoanTokenMismatchError;
@@ -1632,6 +1677,7 @@ exports.MidnightOfferMarketLoanTokenMismatchError = MidnightOfferMarketLoanToken
1632
1677
  class MidnightOfferCallbackMismatchError extends Error {
1633
1678
  constructor(params) {
1634
1679
  super(`Midnight offer "${params.index}" uses callback "${params.actualCallback}", expected the maker's BlueBuyCallback "${params.expectedCallback}". Rebuild the offer with the derived callback.`);
1680
+ this.name = "MidnightOfferCallbackMismatchError";
1635
1681
  }
1636
1682
  }
1637
1683
  exports.MidnightOfferCallbackMismatchError = MidnightOfferCallbackMismatchError;
@@ -1639,6 +1685,7 @@ exports.MidnightOfferCallbackMismatchError = MidnightOfferCallbackMismatchError;
1639
1685
  class MidnightOfferCallbackDataMismatchError extends Error {
1640
1686
  constructor(params) {
1641
1687
  super(`Midnight offer "${params.index}" uses callback data "${params.actualCallbackData}", expected "${params.expectedCallbackData}". Set the callback data to the ABI-encoded Blue market the assets are parked in.`);
1688
+ this.name = "MidnightOfferCallbackDataMismatchError";
1642
1689
  }
1643
1690
  }
1644
1691
  exports.MidnightOfferCallbackDataMismatchError = MidnightOfferCallbackDataMismatchError;
@@ -1646,13 +1693,18 @@ exports.MidnightOfferCallbackDataMismatchError = MidnightOfferCallbackDataMismat
1646
1693
  class EmptyBlueParkingMarketError extends Error {
1647
1694
  constructor(params) {
1648
1695
  super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
1696
+ this.name = "EmptyBlueParkingMarketError";
1649
1697
  }
1650
1698
  }
1651
1699
  exports.EmptyBlueParkingMarketError = EmptyBlueParkingMarketError;
1652
- /** Thrown when parked assets would mint no Morpho Blue supply shares. */
1700
+ /**
1701
+ * Thrown when parked assets would mint no Morpho Blue supply shares at preparation time; see
1702
+ * `MorphoMidnight.supplyBlueMakeLend` for why this is not an execution-time guarantee.
1703
+ */
1653
1704
  class ZeroBlueParkingSharesError extends Error {
1654
1705
  constructor(params) {
1655
1706
  super(`Supplying "${params.assets}" assets to Morpho Blue market "${params.marketId}" mints zero supply shares at its current share price; park more assets or choose another market.`);
1707
+ this.name = "ZeroBlueParkingSharesError";
1656
1708
  }
1657
1709
  }
1658
1710
  exports.ZeroBlueParkingSharesError = ZeroBlueParkingSharesError;
@@ -1660,6 +1712,7 @@ exports.ZeroBlueParkingSharesError = ZeroBlueParkingSharesError;
1660
1712
  class MidnightTakeableOfferMarketMismatchError extends Error {
1661
1713
  constructor(params) {
1662
1714
  super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
1715
+ this.name = "MidnightTakeableOfferMarketMismatchError";
1663
1716
  }
1664
1717
  }
1665
1718
  exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
@@ -1667,6 +1720,7 @@ exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMi
1667
1720
  class MidnightOfferRatifierMismatchError extends Error {
1668
1721
  constructor(params) {
1669
1722
  super(`Midnight offer "${params.index}" uses ratifier "${params.actualRatifier}", expected "${params.expectedRatifier}" for its tree type. Rebuild the offer with the tree's ratifier.`);
1723
+ this.name = "MidnightOfferRatifierMismatchError";
1670
1724
  }
1671
1725
  }
1672
1726
  exports.MidnightOfferRatifierMismatchError = MidnightOfferRatifierMismatchError;
@@ -1674,6 +1728,7 @@ exports.MidnightOfferRatifierMismatchError = MidnightOfferRatifierMismatchError;
1674
1728
  class MidnightReplacementGroupCancelledError extends Error {
1675
1729
  constructor(params) {
1676
1730
  super(`Midnight offer group "${params.group}" is both published and cancelled. Give replacement offers a fresh group.`);
1731
+ this.name = "MidnightReplacementGroupCancelledError";
1677
1732
  }
1678
1733
  }
1679
1734
  exports.MidnightReplacementGroupCancelledError = MidnightReplacementGroupCancelledError;
@@ -1681,6 +1736,7 @@ exports.MidnightReplacementGroupCancelledError = MidnightReplacementGroupCancell
1681
1736
  class NoMidnightCreditToRedeemError extends Error {
1682
1737
  constructor(market) {
1683
1738
  super(`No Midnight credit is available to redeem for market "${market}".`);
1739
+ this.name = "NoMidnightCreditToRedeemError";
1684
1740
  }
1685
1741
  }
1686
1742
  exports.NoMidnightCreditToRedeemError = NoMidnightCreditToRedeemError;
@@ -1688,6 +1744,7 @@ exports.NoMidnightCreditToRedeemError = NoMidnightCreditToRedeemError;
1688
1744
  class MidnightRedeemExceedsCreditError extends Error {
1689
1745
  constructor(params) {
1690
1746
  super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
1747
+ this.name = "MidnightRedeemExceedsCreditError";
1691
1748
  }
1692
1749
  }
1693
1750
  exports.MidnightRedeemExceedsCreditError = MidnightRedeemExceedsCreditError;
@@ -1695,6 +1752,7 @@ exports.MidnightRedeemExceedsCreditError = MidnightRedeemExceedsCreditError;
1695
1752
  class InsufficientMidnightWithdrawableLiquidityError extends Error {
1696
1753
  constructor(params) {
1697
1754
  super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
1755
+ this.name = "InsufficientMidnightWithdrawableLiquidityError";
1698
1756
  }
1699
1757
  }
1700
1758
  exports.InsufficientMidnightWithdrawableLiquidityError = InsufficientMidnightWithdrawableLiquidityError;
@@ -1761,6 +1819,7 @@ exports.MidnightInvalidAccountAddressError = MidnightInvalidAccountAddressError;
1761
1819
  class MutuallyExclusiveWithdrawAmountsError extends Error {
1762
1820
  constructor(market) {
1763
1821
  super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
1822
+ this.name = "MutuallyExclusiveWithdrawAmountsError";
1764
1823
  }
1765
1824
  }
1766
1825
  exports.MutuallyExclusiveWithdrawAmountsError = MutuallyExclusiveWithdrawAmountsError;
@@ -1768,6 +1827,7 @@ exports.MutuallyExclusiveWithdrawAmountsError = MutuallyExclusiveWithdrawAmounts
1768
1827
  class WithdrawExceedsSupplyError extends Error {
1769
1828
  constructor(params) {
1770
1829
  super(`Withdraw amount ${params.withdrawAmount} exceeds available supply ${params.available} for market: ${params.market}. Reduce withdraw amount.`);
1830
+ this.name = "WithdrawExceedsSupplyError";
1771
1831
  }
1772
1832
  }
1773
1833
  exports.WithdrawExceedsSupplyError = WithdrawExceedsSupplyError;
@@ -1775,6 +1835,7 @@ exports.WithdrawExceedsSupplyError = WithdrawExceedsSupplyError;
1775
1835
  class WithdrawSharesExceedSupplyError extends Error {
1776
1836
  constructor(params) {
1777
1837
  super(`Withdraw shares ${params.withdrawShares} exceed owned supply shares ${params.supplyShares} for market: ${params.market}. Reduce withdraw shares.`);
1838
+ this.name = "WithdrawSharesExceedSupplyError";
1778
1839
  }
1779
1840
  }
1780
1841
  exports.WithdrawSharesExceedSupplyError = WithdrawSharesExceedSupplyError;
@@ -1790,6 +1851,7 @@ class ReallocationWithdrawExceedsMarketSupplyError extends Error {
1790
1851
  constructor(params) {
1791
1852
  super(`Withdraw amount "${params.withdrawAmount}" exceeds market total supply "${params.totalSupplyAssets}" on market ${params.marketId}. Reduce the withdraw amount.`);
1792
1853
  this.params = params;
1854
+ this.name = "ReallocationWithdrawExceedsMarketSupplyError";
1793
1855
  }
1794
1856
  }
1795
1857
  exports.ReallocationWithdrawExceedsMarketSupplyError = ReallocationWithdrawExceedsMarketSupplyError;
@@ -1797,6 +1859,7 @@ exports.ReallocationWithdrawExceedsMarketSupplyError = ReallocationWithdrawExcee
1797
1859
  class VaultAssetMismatchError extends Error {
1798
1860
  constructor(sourceAsset, targetAsset) {
1799
1861
  super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
1862
+ this.name = "VaultAssetMismatchError";
1800
1863
  }
1801
1864
  }
1802
1865
  exports.VaultAssetMismatchError = VaultAssetMismatchError;
@@ -1804,6 +1867,7 @@ exports.VaultAssetMismatchError = VaultAssetMismatchError;
1804
1867
  class RefinanceSameMarketError extends Error {
1805
1868
  constructor(market) {
1806
1869
  super(`Refinance source and target market ${market} are identical. Refinance requires a different target market.`);
1870
+ this.name = "RefinanceSameMarketError";
1807
1871
  }
1808
1872
  }
1809
1873
  exports.RefinanceSameMarketError = RefinanceSameMarketError;
@@ -1811,6 +1875,7 @@ exports.RefinanceSameMarketError = RefinanceSameMarketError;
1811
1875
  class RefinanceTokenMismatchError extends Error {
1812
1876
  constructor(sourceMarket, targetMarket) {
1813
1877
  super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
1878
+ this.name = "RefinanceTokenMismatchError";
1814
1879
  }
1815
1880
  }
1816
1881
  exports.RefinanceTokenMismatchError = RefinanceTokenMismatchError;
@@ -1818,6 +1883,7 @@ exports.RefinanceTokenMismatchError = RefinanceTokenMismatchError;
1818
1883
  class MidnightOfferNotReduceOnlyError extends Error {
1819
1884
  constructor(params) {
1820
1885
  super(`Midnight exit offer "${params.index}" must have reduceOnly=true. Rebuild the offer tree for the exit intent.`);
1886
+ this.name = "MidnightOfferNotReduceOnlyError";
1821
1887
  }
1822
1888
  }
1823
1889
  exports.MidnightOfferNotReduceOnlyError = MidnightOfferNotReduceOnlyError;
@@ -1862,3 +1928,69 @@ class MissingContractCodeError extends Error {
1862
1928
  }
1863
1929
  }
1864
1930
  exports.MissingContractCodeError = MissingContractCodeError;
1931
+ /**
1932
+ * Thrown when a Midnight flow is prepared for the zero address. Midnight would revert
1933
+ * `Unauthorized()`, and requirements resolved for the zero address can never be sent.
1934
+ *
1935
+ * @example
1936
+ * ```ts
1937
+ * import { MidnightZeroAccountError } from "@morpho-org/morpho-sdk";
1938
+ *
1939
+ * const error = new MidnightZeroAccountError("accountAddress");
1940
+ * // error.field === "accountAddress"
1941
+ * ```
1942
+ */
1943
+ class MidnightZeroAccountError extends Error {
1944
+ field;
1945
+ /**
1946
+ * @param field - Account field containing the zero address: `accountAddress` for an entity
1947
+ * method, `owner` for a requirement helper. A zero `onBehalf` on a direct Midnight call throws
1948
+ * {@link MidnightZeroOnBehalfError} instead.
1949
+ */
1950
+ constructor(field) {
1951
+ super(`Midnight "${field}" cannot be the zero address. Pass the account that sends the transaction.`);
1952
+ this.field = field;
1953
+ this.name = "MidnightZeroAccountError";
1954
+ }
1955
+ }
1956
+ exports.MidnightZeroAccountError = MidnightZeroAccountError;
1957
+ /**
1958
+ * Thrown when a Midnight builder or `MorphoMidnight` method cannot ABI-encode its calldata,
1959
+ * offer tree or market id, for example a `bytes32` field that is not 32 bytes, an integer
1960
+ * outside its Solidity type or a malformed address. Wraps the viem error as `cause`.
1961
+ *
1962
+ * @example
1963
+ * ```ts
1964
+ * import { MidnightCalldataEncodingError } from "@morpho-org/morpho-sdk";
1965
+ * import { BaseError } from "viem";
1966
+ *
1967
+ * const error = new MidnightCalldataEncodingError(
1968
+ * "midnightBundlesV2CancelAndMake",
1969
+ * new BaseError("bad bytes32"),
1970
+ * );
1971
+ * // error.input === "midnightBundlesV2CancelAndMake"
1972
+ * ```
1973
+ */
1974
+ class MidnightCalldataEncodingError extends Error {
1975
+ input;
1976
+ cause;
1977
+ /**
1978
+ * @param input - Input that could not be encoded: the contract function whose calldata
1979
+ * failed, `"offers"` for offer-tree hashing, `"marketId"` for market-id hashing, or the name
1980
+ * of the malformed address input, such as `"accountAddress"`, `"onBehalf"`, `"owner"`,
1981
+ * `"receiver"`, `"collateralReceiver"`, `"referralFeeRecipient"`, `"market.midnight"`,
1982
+ * `"authorized"`, `"publication.ratifier"`, `"loanToken"`, `"market.loanToken"`,
1983
+ * `"market.collateralParams[i].token"`, `"positionData.user"`, `"spender"` or `"token"` (a token
1984
+ * pulled with native funding, or the token checked by
1985
+ * `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
1986
+ * `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
1987
+ * @param cause - viem encoding error.
1988
+ */
1989
+ constructor(input, cause) {
1990
+ super(`Cannot encode Midnight input "${input}": ${cause.shortMessage} Check bytes32 sizes, integer ranges and addresses in the inputs.`, { cause });
1991
+ this.input = input;
1992
+ this.cause = cause;
1993
+ this.name = "MidnightCalldataEncodingError";
1994
+ }
1995
+ }
1996
+ exports.MidnightCalldataEncodingError = MidnightCalldataEncodingError;