@morpho-org/morpho-sdk 8.3.0 → 9.0.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 (155) hide show
  1. package/MIGRATION-v8-to-v9.md +54 -0
  2. package/README.md +13 -7
  3. package/lib/cjs/actions/bundles/common.d.ts +4 -7
  4. package/lib/cjs/actions/bundles/common.js +8 -14
  5. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  6. package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -8
  7. package/lib/cjs/actions/midnight/authorization.d.ts +3 -1
  8. package/lib/cjs/actions/midnight/authorization.js +11 -1
  9. package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -0
  10. package/lib/cjs/actions/midnight/cancelAndMake.js +10 -2
  11. package/lib/cjs/actions/midnight/redeem.d.ts +3 -1
  12. package/lib/cjs/actions/midnight/redeem.js +9 -3
  13. package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  14. package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +7 -3
  15. package/lib/cjs/actions/midnight/supplyCollateral.d.ts +4 -1
  16. package/lib/cjs/actions/midnight/supplyCollateral.js +10 -3
  17. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  18. package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +9 -3
  19. package/lib/cjs/actions/midnight/takeBorrow.d.ts +3 -1
  20. package/lib/cjs/actions/midnight/takeBorrow.js +9 -3
  21. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
  22. package/lib/cjs/actions/midnight/takeLend.js +7 -2
  23. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  24. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +8 -2
  25. package/lib/cjs/actions/midnight/takeWithdraw.d.ts +3 -1
  26. package/lib/cjs/actions/midnight/takeWithdraw.js +10 -3
  27. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  28. package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +5 -7
  29. package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +7 -11
  30. package/lib/cjs/actions/requirements/getRequirementsApproval.js +8 -15
  31. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  32. package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +11 -8
  33. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  34. package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  35. package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -1
  36. package/lib/cjs/actions/vaultV1/inKindRedeem.js +1 -1
  37. package/lib/cjs/actions/vaultV1/withdraw.d.ts +4 -4
  38. package/lib/cjs/actions/vaultV1/withdraw.js +4 -4
  39. package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
  40. package/lib/cjs/actions/vaultV2/forceWithdraw.js +1 -1
  41. package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -1
  42. package/lib/cjs/actions/vaultV2/inKindRedeem.js +1 -1
  43. package/lib/cjs/actions/vaultV2/withdraw.d.ts +4 -4
  44. package/lib/cjs/actions/vaultV2/withdraw.js +4 -4
  45. package/lib/cjs/entities/blue/blue.d.ts +2 -12
  46. package/lib/cjs/entities/blue/blue.js +0 -4
  47. package/lib/cjs/entities/midnight/midnight.d.ts +56 -17
  48. package/lib/cjs/entities/midnight/midnight.js +131 -52
  49. package/lib/cjs/entities/midnight/types.d.ts +2 -9
  50. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  51. package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +0 -7
  52. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  53. package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -20
  54. package/lib/cjs/entities/vaultV1/vaultV1.d.ts +40 -37
  55. package/lib/cjs/entities/vaultV1/vaultV1.js +5 -34
  56. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +36 -34
  57. package/lib/cjs/entities/vaultV2/vaultV2.js +8 -34
  58. package/lib/cjs/helpers/encodeMidnightCalldata.d.ts +48 -0
  59. package/lib/cjs/helpers/encodeMidnightCalldata.js +74 -0
  60. package/lib/cjs/helpers/slippage.d.ts +9 -25
  61. package/lib/cjs/helpers/slippage.js +10 -27
  62. package/lib/cjs/helpers/validate.d.ts +1 -0
  63. package/lib/cjs/helpers/validate.js +5 -0
  64. package/lib/cjs/helpers/validateMidnightAccount.d.ts +34 -0
  65. package/lib/cjs/helpers/validateMidnightAccount.js +47 -0
  66. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  67. package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +4 -0
  68. package/lib/cjs/helpers/validateMidnightMarket.d.ts +2 -0
  69. package/lib/cjs/helpers/validateMidnightMarket.js +5 -0
  70. package/lib/cjs/helpers/validateMidnightPublication.d.ts +11 -0
  71. package/lib/cjs/helpers/validateMidnightPublication.js +12 -1
  72. package/lib/cjs/helpers/validateMidnightReceiver.d.ts +1 -0
  73. package/lib/cjs/helpers/validateMidnightReceiver.js +8 -0
  74. package/lib/cjs/helpers/validateTakeableOffers.d.ts +2 -1
  75. package/lib/cjs/helpers/validateTakeableOffers.js +4 -3
  76. package/lib/cjs/types/action.d.ts +3 -1
  77. package/lib/cjs/types/error.d.ts +56 -5
  78. package/lib/cjs/types/error.js +139 -10
  79. package/lib/esm/actions/bundles/common.d.ts +4 -7
  80. package/lib/esm/actions/bundles/common.js +8 -14
  81. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
  82. package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -9
  83. package/lib/esm/actions/midnight/authorization.d.ts +3 -1
  84. package/lib/esm/actions/midnight/authorization.js +12 -2
  85. package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -0
  86. package/lib/esm/actions/midnight/cancelAndMake.js +11 -3
  87. package/lib/esm/actions/midnight/redeem.d.ts +3 -1
  88. package/lib/esm/actions/midnight/redeem.js +10 -4
  89. package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
  90. package/lib/esm/actions/midnight/repayWithdrawCollateral.js +8 -4
  91. package/lib/esm/actions/midnight/supplyCollateral.d.ts +4 -1
  92. package/lib/esm/actions/midnight/supplyCollateral.js +11 -4
  93. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
  94. package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +10 -4
  95. package/lib/esm/actions/midnight/takeBorrow.d.ts +3 -1
  96. package/lib/esm/actions/midnight/takeBorrow.js +10 -4
  97. package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
  98. package/lib/esm/actions/midnight/takeLend.js +8 -3
  99. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  100. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +9 -3
  101. package/lib/esm/actions/midnight/takeWithdraw.d.ts +3 -1
  102. package/lib/esm/actions/midnight/takeWithdraw.js +11 -4
  103. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
  104. package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -8
  105. package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +7 -11
  106. package/lib/esm/actions/requirements/getRequirementsApproval.js +9 -16
  107. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
  108. package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +12 -9
  109. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
  110. package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
  111. package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -1
  112. package/lib/esm/actions/vaultV1/inKindRedeem.js +1 -1
  113. package/lib/esm/actions/vaultV1/withdraw.d.ts +4 -4
  114. package/lib/esm/actions/vaultV1/withdraw.js +4 -4
  115. package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
  116. package/lib/esm/actions/vaultV2/forceWithdraw.js +1 -1
  117. package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -1
  118. package/lib/esm/actions/vaultV2/inKindRedeem.js +1 -1
  119. package/lib/esm/actions/vaultV2/withdraw.d.ts +4 -4
  120. package/lib/esm/actions/vaultV2/withdraw.js +4 -4
  121. package/lib/esm/entities/blue/blue.d.ts +2 -12
  122. package/lib/esm/entities/blue/blue.js +0 -4
  123. package/lib/esm/entities/midnight/midnight.d.ts +56 -17
  124. package/lib/esm/entities/midnight/midnight.js +132 -53
  125. package/lib/esm/entities/midnight/types.d.ts +2 -9
  126. package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
  127. package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +1 -8
  128. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
  129. package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +9 -21
  130. package/lib/esm/entities/vaultV1/vaultV1.d.ts +40 -37
  131. package/lib/esm/entities/vaultV1/vaultV1.js +6 -35
  132. package/lib/esm/entities/vaultV2/vaultV2.d.ts +36 -34
  133. package/lib/esm/entities/vaultV2/vaultV2.js +8 -34
  134. package/lib/esm/helpers/encodeMidnightCalldata.d.ts +48 -0
  135. package/lib/esm/helpers/encodeMidnightCalldata.js +69 -0
  136. package/lib/esm/helpers/slippage.d.ts +9 -25
  137. package/lib/esm/helpers/slippage.js +9 -25
  138. package/lib/esm/helpers/validate.d.ts +1 -0
  139. package/lib/esm/helpers/validate.js +5 -0
  140. package/lib/esm/helpers/validateMidnightAccount.d.ts +34 -0
  141. package/lib/esm/helpers/validateMidnightAccount.js +43 -0
  142. package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
  143. package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +4 -0
  144. package/lib/esm/helpers/validateMidnightMarket.d.ts +2 -0
  145. package/lib/esm/helpers/validateMidnightMarket.js +5 -0
  146. package/lib/esm/helpers/validateMidnightPublication.d.ts +11 -0
  147. package/lib/esm/helpers/validateMidnightPublication.js +10 -0
  148. package/lib/esm/helpers/validateMidnightReceiver.d.ts +1 -0
  149. package/lib/esm/helpers/validateMidnightReceiver.js +8 -0
  150. package/lib/esm/helpers/validateTakeableOffers.d.ts +2 -1
  151. package/lib/esm/helpers/validateTakeableOffers.js +4 -3
  152. package/lib/esm/types/action.d.ts +3 -1
  153. package/lib/esm/types/error.d.ts +56 -5
  154. package/lib/esm/types/error.js +134 -6
  155. package/package.json +4 -3
@@ -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,6 +1693,7 @@ 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;
@@ -1653,6 +1701,7 @@ exports.EmptyBlueParkingMarketError = EmptyBlueParkingMarketError;
1653
1701
  class ZeroBlueParkingSharesError extends Error {
1654
1702
  constructor(params) {
1655
1703
  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.`);
1704
+ this.name = "ZeroBlueParkingSharesError";
1656
1705
  }
1657
1706
  }
1658
1707
  exports.ZeroBlueParkingSharesError = ZeroBlueParkingSharesError;
@@ -1660,6 +1709,7 @@ exports.ZeroBlueParkingSharesError = ZeroBlueParkingSharesError;
1660
1709
  class MidnightTakeableOfferMarketMismatchError extends Error {
1661
1710
  constructor(params) {
1662
1711
  super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
1712
+ this.name = "MidnightTakeableOfferMarketMismatchError";
1663
1713
  }
1664
1714
  }
1665
1715
  exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
@@ -1667,6 +1717,7 @@ exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMi
1667
1717
  class MidnightOfferRatifierMismatchError extends Error {
1668
1718
  constructor(params) {
1669
1719
  super(`Midnight offer "${params.index}" uses ratifier "${params.actualRatifier}", expected "${params.expectedRatifier}" for its tree type. Rebuild the offer with the tree's ratifier.`);
1720
+ this.name = "MidnightOfferRatifierMismatchError";
1670
1721
  }
1671
1722
  }
1672
1723
  exports.MidnightOfferRatifierMismatchError = MidnightOfferRatifierMismatchError;
@@ -1674,6 +1725,7 @@ exports.MidnightOfferRatifierMismatchError = MidnightOfferRatifierMismatchError;
1674
1725
  class MidnightReplacementGroupCancelledError extends Error {
1675
1726
  constructor(params) {
1676
1727
  super(`Midnight offer group "${params.group}" is both published and cancelled. Give replacement offers a fresh group.`);
1728
+ this.name = "MidnightReplacementGroupCancelledError";
1677
1729
  }
1678
1730
  }
1679
1731
  exports.MidnightReplacementGroupCancelledError = MidnightReplacementGroupCancelledError;
@@ -1681,6 +1733,7 @@ exports.MidnightReplacementGroupCancelledError = MidnightReplacementGroupCancell
1681
1733
  class NoMidnightCreditToRedeemError extends Error {
1682
1734
  constructor(market) {
1683
1735
  super(`No Midnight credit is available to redeem for market "${market}".`);
1736
+ this.name = "NoMidnightCreditToRedeemError";
1684
1737
  }
1685
1738
  }
1686
1739
  exports.NoMidnightCreditToRedeemError = NoMidnightCreditToRedeemError;
@@ -1688,6 +1741,7 @@ exports.NoMidnightCreditToRedeemError = NoMidnightCreditToRedeemError;
1688
1741
  class MidnightRedeemExceedsCreditError extends Error {
1689
1742
  constructor(params) {
1690
1743
  super(`Midnight redeem amount exceeds position credit on market "${params.market}": units "${params.units}", credit "${params.credit}". Redeem less or refresh the position data.`);
1744
+ this.name = "MidnightRedeemExceedsCreditError";
1691
1745
  }
1692
1746
  }
1693
1747
  exports.MidnightRedeemExceedsCreditError = MidnightRedeemExceedsCreditError;
@@ -1695,6 +1749,7 @@ exports.MidnightRedeemExceedsCreditError = MidnightRedeemExceedsCreditError;
1695
1749
  class InsufficientMidnightWithdrawableLiquidityError extends Error {
1696
1750
  constructor(params) {
1697
1751
  super(`Midnight withdrawable liquidity is insufficient on market "${params.market}": units "${params.units}", withdrawable "${params.withdrawable}". Try again later or redeem less.`);
1752
+ this.name = "InsufficientMidnightWithdrawableLiquidityError";
1698
1753
  }
1699
1754
  }
1700
1755
  exports.InsufficientMidnightWithdrawableLiquidityError = InsufficientMidnightWithdrawableLiquidityError;
@@ -1761,6 +1816,7 @@ exports.MidnightInvalidAccountAddressError = MidnightInvalidAccountAddressError;
1761
1816
  class MutuallyExclusiveWithdrawAmountsError extends Error {
1762
1817
  constructor(market) {
1763
1818
  super(`Exactly one of assets or shares must be non-zero for market: ${market}. Both were provided.`);
1819
+ this.name = "MutuallyExclusiveWithdrawAmountsError";
1764
1820
  }
1765
1821
  }
1766
1822
  exports.MutuallyExclusiveWithdrawAmountsError = MutuallyExclusiveWithdrawAmountsError;
@@ -1768,6 +1824,7 @@ exports.MutuallyExclusiveWithdrawAmountsError = MutuallyExclusiveWithdrawAmounts
1768
1824
  class WithdrawExceedsSupplyError extends Error {
1769
1825
  constructor(params) {
1770
1826
  super(`Withdraw amount ${params.withdrawAmount} exceeds available supply ${params.available} for market: ${params.market}. Reduce withdraw amount.`);
1827
+ this.name = "WithdrawExceedsSupplyError";
1771
1828
  }
1772
1829
  }
1773
1830
  exports.WithdrawExceedsSupplyError = WithdrawExceedsSupplyError;
@@ -1775,6 +1832,7 @@ exports.WithdrawExceedsSupplyError = WithdrawExceedsSupplyError;
1775
1832
  class WithdrawSharesExceedSupplyError extends Error {
1776
1833
  constructor(params) {
1777
1834
  super(`Withdraw shares ${params.withdrawShares} exceed owned supply shares ${params.supplyShares} for market: ${params.market}. Reduce withdraw shares.`);
1835
+ this.name = "WithdrawSharesExceedSupplyError";
1778
1836
  }
1779
1837
  }
1780
1838
  exports.WithdrawSharesExceedSupplyError = WithdrawSharesExceedSupplyError;
@@ -1790,6 +1848,7 @@ class ReallocationWithdrawExceedsMarketSupplyError extends Error {
1790
1848
  constructor(params) {
1791
1849
  super(`Withdraw amount "${params.withdrawAmount}" exceeds market total supply "${params.totalSupplyAssets}" on market ${params.marketId}. Reduce the withdraw amount.`);
1792
1850
  this.params = params;
1851
+ this.name = "ReallocationWithdrawExceedsMarketSupplyError";
1793
1852
  }
1794
1853
  }
1795
1854
  exports.ReallocationWithdrawExceedsMarketSupplyError = ReallocationWithdrawExceedsMarketSupplyError;
@@ -1797,6 +1856,7 @@ exports.ReallocationWithdrawExceedsMarketSupplyError = ReallocationWithdrawExcee
1797
1856
  class VaultAssetMismatchError extends Error {
1798
1857
  constructor(sourceAsset, targetAsset) {
1799
1858
  super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
1859
+ this.name = "VaultAssetMismatchError";
1800
1860
  }
1801
1861
  }
1802
1862
  exports.VaultAssetMismatchError = VaultAssetMismatchError;
@@ -1804,6 +1864,7 @@ exports.VaultAssetMismatchError = VaultAssetMismatchError;
1804
1864
  class RefinanceSameMarketError extends Error {
1805
1865
  constructor(market) {
1806
1866
  super(`Refinance source and target market ${market} are identical. Refinance requires a different target market.`);
1867
+ this.name = "RefinanceSameMarketError";
1807
1868
  }
1808
1869
  }
1809
1870
  exports.RefinanceSameMarketError = RefinanceSameMarketError;
@@ -1811,6 +1872,7 @@ exports.RefinanceSameMarketError = RefinanceSameMarketError;
1811
1872
  class RefinanceTokenMismatchError extends Error {
1812
1873
  constructor(sourceMarket, targetMarket) {
1813
1874
  super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
1875
+ this.name = "RefinanceTokenMismatchError";
1814
1876
  }
1815
1877
  }
1816
1878
  exports.RefinanceTokenMismatchError = RefinanceTokenMismatchError;
@@ -1818,6 +1880,7 @@ exports.RefinanceTokenMismatchError = RefinanceTokenMismatchError;
1818
1880
  class MidnightOfferNotReduceOnlyError extends Error {
1819
1881
  constructor(params) {
1820
1882
  super(`Midnight exit offer "${params.index}" must have reduceOnly=true. Rebuild the offer tree for the exit intent.`);
1883
+ this.name = "MidnightOfferNotReduceOnlyError";
1821
1884
  }
1822
1885
  }
1823
1886
  exports.MidnightOfferNotReduceOnlyError = MidnightOfferNotReduceOnlyError;
@@ -1862,3 +1925,69 @@ class MissingContractCodeError extends Error {
1862
1925
  }
1863
1926
  }
1864
1927
  exports.MissingContractCodeError = MissingContractCodeError;
1928
+ /**
1929
+ * Thrown when a Midnight flow is prepared for the zero address. Midnight would revert
1930
+ * `Unauthorized()`, and requirements resolved for the zero address can never be sent.
1931
+ *
1932
+ * @example
1933
+ * ```ts
1934
+ * import { MidnightZeroAccountError } from "@morpho-org/morpho-sdk";
1935
+ *
1936
+ * const error = new MidnightZeroAccountError("accountAddress");
1937
+ * // error.field === "accountAddress"
1938
+ * ```
1939
+ */
1940
+ class MidnightZeroAccountError extends Error {
1941
+ field;
1942
+ /**
1943
+ * @param field - Account field containing the zero address: `accountAddress` for an entity
1944
+ * method, `owner` for a requirement helper. A zero `onBehalf` on a direct Midnight call throws
1945
+ * {@link MidnightZeroOnBehalfError} instead.
1946
+ */
1947
+ constructor(field) {
1948
+ super(`Midnight "${field}" cannot be the zero address. Pass the account that sends the transaction.`);
1949
+ this.field = field;
1950
+ this.name = "MidnightZeroAccountError";
1951
+ }
1952
+ }
1953
+ exports.MidnightZeroAccountError = MidnightZeroAccountError;
1954
+ /**
1955
+ * Thrown when a Midnight builder or `MorphoMidnight` method cannot ABI-encode its calldata,
1956
+ * offer tree or market id, for example a `bytes32` field that is not 32 bytes, an integer
1957
+ * outside its Solidity type or a malformed address. Wraps the viem error as `cause`.
1958
+ *
1959
+ * @example
1960
+ * ```ts
1961
+ * import { MidnightCalldataEncodingError } from "@morpho-org/morpho-sdk";
1962
+ * import { BaseError } from "viem";
1963
+ *
1964
+ * const error = new MidnightCalldataEncodingError(
1965
+ * "midnightBundlesV2CancelAndMake",
1966
+ * new BaseError("bad bytes32"),
1967
+ * );
1968
+ * // error.input === "midnightBundlesV2CancelAndMake"
1969
+ * ```
1970
+ */
1971
+ class MidnightCalldataEncodingError extends Error {
1972
+ input;
1973
+ cause;
1974
+ /**
1975
+ * @param input - Input that could not be encoded: the contract function whose calldata
1976
+ * failed, `"offers"` for offer-tree hashing, `"marketId"` for market-id hashing, or the name
1977
+ * of the malformed address input, such as `"accountAddress"`, `"onBehalf"`, `"owner"`,
1978
+ * `"receiver"`, `"collateralReceiver"`, `"referralFeeRecipient"`, `"market.midnight"`,
1979
+ * `"authorized"`, `"publication.ratifier"`, `"loanToken"`, `"market.loanToken"`,
1980
+ * `"market.collateralParams[i].token"`, `"positionData.user"`, `"spender"` or `"token"` (a token
1981
+ * pulled with native funding, or the token checked by
1982
+ * `getMidnightApprovalRequirements`). `"blueMarket"` reports the Blue market encoding in
1983
+ * `supplyBlueMakeLend`: a malformed address or an out-of-range `lltv`.
1984
+ * @param cause - viem encoding error.
1985
+ */
1986
+ constructor(input, cause) {
1987
+ super(`Cannot encode Midnight input "${input}": ${cause.shortMessage} Check bytes32 sizes, integer ranges and addresses in the inputs.`, { cause });
1988
+ this.input = input;
1989
+ this.cause = cause;
1990
+ this.name = "MidnightCalldataEncodingError";
1991
+ }
1992
+ }
1993
+ exports.MidnightCalldataEncodingError = MidnightCalldataEncodingError;