@morpho-org/morpho-sdk 9.1.0-next.0 → 9.1.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 (126) hide show
  1. package/README.md +3 -1
  2. package/lib/cjs/abis.d.ts +1 -1
  3. package/lib/cjs/abis.js +1 -5
  4. package/lib/cjs/actions/blue/borrow.d.ts +1 -0
  5. package/lib/cjs/actions/blue/borrow.js +1 -0
  6. package/lib/cjs/actions/blue/refinance.d.ts +1 -0
  7. package/lib/cjs/actions/blue/refinance.js +3 -0
  8. package/lib/cjs/actions/blue/repay.d.ts +1 -0
  9. package/lib/cjs/actions/blue/repay.js +1 -0
  10. package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +1 -0
  11. package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -0
  12. package/lib/cjs/actions/blue/supply.d.ts +1 -0
  13. package/lib/cjs/actions/blue/supply.js +2 -0
  14. package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -0
  15. package/lib/cjs/actions/blue/supplyCollateral.js +1 -0
  16. package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +1 -0
  17. package/lib/cjs/actions/blue/supplyCollateralBorrow.js +2 -0
  18. package/lib/cjs/actions/blue/withdraw.d.ts +1 -0
  19. package/lib/cjs/actions/blue/withdraw.js +2 -0
  20. package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -0
  21. package/lib/cjs/actions/blue/withdrawCollateral.js +1 -0
  22. package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
  23. package/lib/cjs/actions/midnight/takeLend.js +1 -0
  24. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  25. package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
  26. package/lib/cjs/blue/abis.d.ts +1 -1
  27. package/lib/cjs/blue/abis.js +1 -5
  28. package/lib/cjs/blue/entities.d.ts +4 -4
  29. package/lib/cjs/blue/entities.js +1 -3
  30. package/lib/cjs/blue/errors.d.ts +2 -2
  31. package/lib/cjs/blue/errors.js +2 -5
  32. package/lib/cjs/blue/fetch.d.ts +2 -2
  33. package/lib/cjs/blue/fetch.js +1 -3
  34. package/lib/cjs/blue/utils.d.ts +1 -1
  35. package/lib/cjs/blue/utils.js +1 -2
  36. package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
  37. package/lib/cjs/client/morphoViemExtension.js +1 -7
  38. package/lib/cjs/entities/blue/blue.d.ts +43 -7
  39. package/lib/cjs/entities/blue/blue.js +27 -3
  40. package/lib/cjs/entities/index.d.ts +4 -4
  41. package/lib/cjs/entities/index.js +1 -3
  42. package/lib/cjs/entities/midnight/midnight.d.ts +7 -5
  43. package/lib/cjs/entities/midnight/midnight.js +7 -5
  44. package/lib/cjs/entities/midnight/types.d.ts +8 -1
  45. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +12 -34
  46. package/lib/cjs/entities/vaultV2/vaultV2.js +9 -38
  47. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +43 -18
  48. package/lib/cjs/entities/vaultV2BlueReallocationData.js +210 -79
  49. package/lib/cjs/errors.d.ts +4 -4
  50. package/lib/cjs/errors.js +6 -10
  51. package/lib/cjs/fetch.d.ts +2 -2
  52. package/lib/cjs/fetch.js +1 -3
  53. package/lib/cjs/helpers/validate.d.ts +11 -1
  54. package/lib/cjs/helpers/validate.js +17 -1
  55. package/lib/cjs/helpers/validateTakeableOffers.d.ts +4 -2
  56. package/lib/cjs/helpers/validateTakeableOffers.js +12 -1
  57. package/lib/cjs/midnight/errors.d.ts +1 -2
  58. package/lib/cjs/midnight/errors.js +4 -5
  59. package/lib/cjs/types/error.d.ts +6 -0
  60. package/lib/cjs/types/error.js +9 -1
  61. package/lib/cjs/types/sharedLiquidity.d.ts +27 -11
  62. package/lib/cjs/utils.d.ts +2 -2
  63. package/lib/cjs/utils.js +2 -4
  64. package/lib/esm/abis.d.ts +1 -1
  65. package/lib/esm/abis.js +1 -1
  66. package/lib/esm/actions/blue/borrow.d.ts +1 -0
  67. package/lib/esm/actions/blue/borrow.js +1 -0
  68. package/lib/esm/actions/blue/refinance.d.ts +1 -0
  69. package/lib/esm/actions/blue/refinance.js +4 -1
  70. package/lib/esm/actions/blue/repay.d.ts +1 -0
  71. package/lib/esm/actions/blue/repay.js +1 -0
  72. package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +1 -0
  73. package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -1
  74. package/lib/esm/actions/blue/supply.d.ts +1 -0
  75. package/lib/esm/actions/blue/supply.js +3 -1
  76. package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -0
  77. package/lib/esm/actions/blue/supplyCollateral.js +1 -0
  78. package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +1 -0
  79. package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -1
  80. package/lib/esm/actions/blue/withdraw.d.ts +1 -0
  81. package/lib/esm/actions/blue/withdraw.js +3 -1
  82. package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -0
  83. package/lib/esm/actions/blue/withdrawCollateral.js +1 -0
  84. package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
  85. package/lib/esm/actions/midnight/takeLend.js +1 -0
  86. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
  87. package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
  88. package/lib/esm/blue/abis.d.ts +1 -1
  89. package/lib/esm/blue/abis.js +1 -1
  90. package/lib/esm/blue/entities.d.ts +4 -4
  91. package/lib/esm/blue/entities.js +2 -2
  92. package/lib/esm/blue/errors.d.ts +2 -2
  93. package/lib/esm/blue/errors.js +2 -2
  94. package/lib/esm/blue/fetch.d.ts +2 -2
  95. package/lib/esm/blue/fetch.js +2 -2
  96. package/lib/esm/blue/utils.d.ts +1 -1
  97. package/lib/esm/blue/utils.js +1 -1
  98. package/lib/esm/client/morphoViemExtension.d.ts +1 -1
  99. package/lib/esm/client/morphoViemExtension.js +1 -7
  100. package/lib/esm/entities/blue/blue.d.ts +43 -7
  101. package/lib/esm/entities/blue/blue.js +27 -3
  102. package/lib/esm/entities/index.d.ts +4 -4
  103. package/lib/esm/entities/index.js +2 -2
  104. package/lib/esm/entities/midnight/midnight.d.ts +7 -5
  105. package/lib/esm/entities/midnight/midnight.js +7 -5
  106. package/lib/esm/entities/midnight/types.d.ts +8 -1
  107. package/lib/esm/entities/vaultV2/vaultV2.d.ts +12 -34
  108. package/lib/esm/entities/vaultV2/vaultV2.js +10 -39
  109. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +43 -18
  110. package/lib/esm/entities/vaultV2BlueReallocationData.js +211 -80
  111. package/lib/esm/errors.d.ts +4 -4
  112. package/lib/esm/errors.js +4 -4
  113. package/lib/esm/fetch.d.ts +2 -2
  114. package/lib/esm/fetch.js +2 -2
  115. package/lib/esm/helpers/validate.d.ts +11 -1
  116. package/lib/esm/helpers/validate.js +15 -0
  117. package/lib/esm/helpers/validateTakeableOffers.d.ts +4 -2
  118. package/lib/esm/helpers/validateTakeableOffers.js +13 -2
  119. package/lib/esm/midnight/errors.d.ts +1 -2
  120. package/lib/esm/midnight/errors.js +1 -2
  121. package/lib/esm/types/error.d.ts +6 -0
  122. package/lib/esm/types/error.js +7 -0
  123. package/lib/esm/types/sharedLiquidity.d.ts +27 -11
  124. package/lib/esm/utils.d.ts +2 -2
  125. package/lib/esm/utils.js +2 -2
  126. package/package.json +6 -6
package/lib/cjs/errors.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.BlueUnresolvedBlockNumberError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueVaultV2MidnightAdapterMarketsError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
4
- exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidPositionAccrualStateError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = void 0;
3
+ exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
4
+ exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = void 0;
5
5
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
7
7
  Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
8
8
  Object.defineProperty(exports, "InvalidBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
9
- Object.defineProperty(exports, "InvalidBlueVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
10
9
  Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
11
10
  Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
12
11
  Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
@@ -32,9 +31,9 @@ Object.defineProperty(exports, "MalformedTokenMetadataError", { enumerable: true
32
31
  Object.defineProperty(exports, "BlueMarketParamsIdMismatchError", { enumerable: true, get: function () { return blue_sdk_viem_1.MarketParamsIdMismatchError; } });
33
32
  Object.defineProperty(exports, "MissingPermitDomainNameError", { enumerable: true, get: function () { return blue_sdk_viem_1.MissingPermitDomainNameError; } });
34
33
  Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, get: function () { return blue_sdk_viem_1.NonTupleReturnValueError; } });
34
+ Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
35
35
  Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
36
36
  Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
37
- Object.defineProperty(exports, "BlueUnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
38
37
  Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
39
38
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
40
39
  Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
@@ -44,6 +43,9 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
44
43
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
45
44
  Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
46
45
  Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
46
+ Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
47
+ Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
48
+ Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
47
49
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
48
50
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
49
51
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -66,11 +68,5 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
66
68
  Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
67
69
  Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
68
70
  Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
69
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
70
- Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
71
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
72
- Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
73
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
74
- Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
75
71
  Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
76
72
  Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
@@ -1,6 +1,6 @@
1
- export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
1
+ export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
2
2
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
3
3
  fetchPreLiquidationParams as fetchBluePreLiquidationParams,
4
4
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
5
- fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
5
+ fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
6
6
  export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
package/lib/cjs/fetch.js CHANGED
@@ -1,12 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2MidnightAdapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2MidnightAdapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
3
+ exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
4
4
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
5
5
  Object.defineProperty(exports, "fetchBlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
6
6
  Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
7
7
  Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
8
8
  Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
9
- Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
10
9
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
11
10
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
12
11
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
@@ -30,7 +29,6 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
30
29
  Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
31
30
  Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
32
31
  Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
33
- Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
34
32
  Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
35
33
  Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
36
34
  Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
@@ -1,4 +1,4 @@
1
- import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
1
+ import { type AccrualPosition, type MarketId, type MarketParams } from "@morpho-org/blue-sdk";
2
2
  import { type Market as MidnightMarket, type MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
3
3
  import { type Address } from "viem";
4
4
  import { type VaultV2BlueReallocation } from "../types/index.js";
@@ -15,6 +15,16 @@ import { type VaultV2BlueReallocation } from "../types/index.js";
15
15
  * @internal
16
16
  */
17
17
  export declare const validateUint256Field: (field: string, value: bigint) => void;
18
+ /**
19
+ * Rejects market params whose cached `id` does not hash from their five tuple fields, so a
20
+ * hand-built or mutated object cannot make the SDK describe one market while calldata targets another.
21
+ *
22
+ * @param marketParams - Market params whose `id` must equal the id derived from the tuple.
23
+ * @returns Nothing when `marketParams.id` matches the derived id.
24
+ * @throws {MarketIdMismatchError} when `marketParams.id` differs from the derived id.
25
+ * @internal
26
+ */
27
+ export declare const validateMarketParamsId: (marketParams: MarketParams) => void;
18
28
  /**
19
29
  * Rejects a deadline that no periphery can honour: the contracts read `0` as "unset" and the ABI
20
30
  * slot is a `uint256`. Callers that also need the deadline to be in the future layer their own
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateUint256Field = void 0;
3
+ exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateMarketParamsId = exports.validateUint256Field = void 0;
4
4
  exports.validateUserAddress = validateUserAddress;
5
5
  const blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
@@ -39,6 +39,22 @@ const validateUint256Field = (field, value) => {
39
39
  }
40
40
  };
41
41
  exports.validateUint256Field = validateUint256Field;
42
+ /**
43
+ * Rejects market params whose cached `id` does not hash from their five tuple fields, so a
44
+ * hand-built or mutated object cannot make the SDK describe one market while calldata targets another.
45
+ *
46
+ * @param marketParams - Market params whose `id` must equal the id derived from the tuple.
47
+ * @returns Nothing when `marketParams.id` matches the derived id.
48
+ * @throws {MarketIdMismatchError} when `marketParams.id` differs from the derived id.
49
+ * @internal
50
+ */
51
+ const validateMarketParamsId = (marketParams) => {
52
+ const derivedId = blue_sdk_1.MarketUtils.getMarketId(marketParams);
53
+ if (marketParams.id !== derivedId) {
54
+ throw new index_js_1.MarketIdMismatchError(marketParams.id, derivedId);
55
+ }
56
+ };
57
+ exports.validateMarketParamsId = validateMarketParamsId;
42
58
  /**
43
59
  * Rejects a deadline that no periphery can honour: the contracts read `0` as "unset" and the ABI
44
60
  * slot is a `uint256`. Callers that also need the deadline to be in the future layer their own
@@ -7,13 +7,15 @@ import type { MarketInput, OfferStruct } from "@morpho-org/midnight-sdk";
7
7
  * @throws {EmptyMidnightTakeableOffersError} when no offers are provided.
8
8
  * @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
9
9
  * @throws {MidnightTakeableOfferMarketMismatchError} when an offer belongs to another market.
10
- * @throws {MidnightCalldataEncodingError} when a market cannot be ABI-encoded.
10
+ * @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
11
+ * @throws {MidnightCalldataEncodingError} when a market cannot be ABI-encoded or a sell offer's
12
+ * `receiverIfMakerIsSeller` is not an address.
11
13
  * @internal
12
14
  */
13
15
  export declare const validateTakeableOffers: (params: {
14
16
  readonly market: MarketInput;
15
17
  readonly takeableOffers: readonly {
16
- readonly offer: Pick<OfferStruct, "buy" | "market">;
18
+ readonly offer: Pick<OfferStruct, "buy" | "market" | "receiverIfMakerIsSeller">;
17
19
  }[];
18
20
  readonly expectedBuy: boolean;
19
21
  }) => `0x${string}`;
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateTakeableOffers = void 0;
4
+ const viem_1 = require("viem");
4
5
  const index_js_1 = require("../types/index.js");
5
6
  const encodeMidnightCalldata_js_1 = require("./encodeMidnightCalldata.js");
7
+ const validateMidnightAccount_js_1 = require("./validateMidnightAccount.js");
6
8
  const validateOfferSides_js_1 = require("./validateOfferSides.js");
7
9
  /**
8
10
  * Validates the pure invariants shared by Midnight take entity and action layers.
@@ -12,7 +14,9 @@ const validateOfferSides_js_1 = require("./validateOfferSides.js");
12
14
  * @throws {EmptyMidnightTakeableOffersError} when no offers are provided.
13
15
  * @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
14
16
  * @throws {MidnightTakeableOfferMarketMismatchError} when an offer belongs to another market.
15
- * @throws {MidnightCalldataEncodingError} when a market cannot be ABI-encoded.
17
+ * @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
18
+ * @throws {MidnightCalldataEncodingError} when a market cannot be ABI-encoded or a sell offer's
19
+ * `receiverIfMakerIsSeller` is not an address.
16
20
  * @internal
17
21
  */
18
22
  const validateTakeableOffers = (params) => {
@@ -30,6 +34,13 @@ const validateTakeableOffers = (params) => {
30
34
  actualMarket: actualMarketId,
31
35
  });
32
36
  }
37
+ if (take.offer.buy)
38
+ continue;
39
+ // Reject a malformed address before viem compares it.
40
+ (0, validateMidnightAccount_js_1.validateMidnightAddress)(`takeableOffers[${index}].offer.receiverIfMakerIsSeller`, take.offer.receiverIfMakerIsSeller);
41
+ if ((0, viem_1.isAddressEqual)(take.offer.receiverIfMakerIsSeller, viem_1.zeroAddress)) {
42
+ throw new index_js_1.MidnightTakeableOfferZeroSellerReceiverError({ index });
43
+ }
33
44
  }
34
45
  return marketId;
35
46
  };
@@ -1,2 +1 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
2
- export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
1
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
3
+ exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
4
4
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
5
5
  Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
6
6
  Object.defineProperty(exports, "InvalidEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
@@ -9,6 +9,9 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
9
9
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
10
10
  Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
11
11
  Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
12
+ Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
13
+ Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
14
+ Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
12
15
  Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
13
16
  Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
14
17
  Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -26,7 +29,3 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
26
29
  Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
27
30
  Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
28
31
  Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
29
- var morpho_ts_1 = require("@morpho-org/morpho-ts");
30
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
31
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
32
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
@@ -1340,6 +1340,12 @@ export declare class MidnightTakeableOfferMarketMismatchError extends Error {
1340
1340
  actualMarket: string;
1341
1341
  });
1342
1342
  }
1343
+ /** Thrown when a quoted Midnight sell offer routes its seller proceeds to the zero address. */
1344
+ export declare class MidnightTakeableOfferZeroSellerReceiverError extends Error {
1345
+ constructor(params: {
1346
+ index: number;
1347
+ });
1348
+ }
1343
1349
  /** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
1344
1350
  export declare class MidnightOfferRatifierMismatchError extends Error {
1345
1351
  constructor(params: {
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
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
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;
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.MidnightTakeableOfferZeroSellerReceiverError = 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");
@@ -1716,6 +1716,14 @@ class MidnightTakeableOfferMarketMismatchError extends Error {
1716
1716
  }
1717
1717
  }
1718
1718
  exports.MidnightTakeableOfferMarketMismatchError = MidnightTakeableOfferMarketMismatchError;
1719
+ /** Thrown when a quoted Midnight sell offer routes its seller proceeds to the zero address. */
1720
+ class MidnightTakeableOfferZeroSellerReceiverError extends Error {
1721
+ constructor(params) {
1722
+ super(`Midnight takeable offer "${params.index}" routes seller proceeds to the zero address. Drop the offer or refresh the quote.`);
1723
+ this.name = "MidnightTakeableOfferZeroSellerReceiverError";
1724
+ }
1725
+ }
1726
+ exports.MidnightTakeableOfferZeroSellerReceiverError = MidnightTakeableOfferZeroSellerReceiverError;
1719
1727
  /** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
1720
1728
  class MidnightOfferRatifierMismatchError extends Error {
1721
1729
  constructor(params) {
@@ -5,12 +5,15 @@ export interface VaultV2BluePublicAllocatorOptions {
5
5
  /** Whether Vault V2 public allocator discovery is enabled. */
6
6
  readonly enabled?: boolean;
7
7
  /**
8
- * Timestamp at which market and Vault V2 state is evaluated. Canonical state
9
- * and the returned post-state stay at this timestamp; only target-market cap
10
- * checks reserve interest on the vault's existing allocation through this
11
- * timestamp plus `capAccrualBuffer`. For market-source reallocations the
12
- * source position's interest is also reserved on cap ids shared with the
13
- * target, and reserves persist across every leg of a plan.
8
+ * Timestamp at which market and Vault V2 state is evaluated. Defaults to the
9
+ * snapshot's timestamp (the fetched block's timestamp), never earlier than
10
+ * the latest market/vault `lastUpdate`; when the snapshot has no timestamp,
11
+ * defaults to the latest market/vault `lastUpdate`. Canonical state and the
12
+ * returned post-state stay at this timestamp; only target-market cap checks
13
+ * reserve interest on the vault's existing allocation through this timestamp
14
+ * plus `capAccrualBuffer`. For market-source reallocations the source
15
+ * position's interest is also reserved on cap ids shared with the target, and
16
+ * reserves persist across every leg of a plan.
14
17
  */
15
18
  readonly timestamp?: BigIntish;
16
19
  /**
@@ -53,16 +56,29 @@ export interface VaultV2BluePublicAllocatorOptions {
53
56
  readonly reallocatableVaults?: Iterable<Address>;
54
57
  /**
55
58
  * Maximum utilization source markets may reach during friendly discovery,
56
- * scaled by WAD. The amount-aware planner falls back to 100% only when the
57
- * friendly phase cannot cover the operation's absolute shortfall.
59
+ * scaled by WAD. Within each penalty tier, the amount-aware planner falls
60
+ * back to 100% only when that tier's friendly pass leaves an absolute
61
+ * shortfall.
58
62
  *
59
63
  * @default 90% (900000000000000000n)
60
64
  */
61
65
  readonly maxWithdrawalUtilization?: bigint;
62
66
  /**
63
- * Maximum proportional vault-asset penalty accepted for each
64
- * BluePublicAllocator call, scaled by WAD. Vaults with a higher configured
65
- * penalty are ignored. Must not exceed WAD (100%).
67
+ * Maximum proportional vault-asset penalty accepted per call, scaled by
68
+ * WAD; higher-penalty vaults are ignored. Must not exceed WAD. Operation
69
+ * plans consider penalty tiers ascending, free first. Each tier uses friendly
70
+ * source utilization (90% by default) before 100%; positive tiers cover only
71
+ * the remaining absolute shortfall. Free capacity inside
72
+ * `allocatorCapHeadroom` stays unused, so a penalized leg can cover it.
73
+ * Getters count all vaults up to this limit. For `refinance`, compute the
74
+ * plan on the destination-market handle (for example,
75
+ * `client.morpho.blue(destination.marketParams, chainId)`), not the source
76
+ * handle. Pass the source position's `borrowAssets` accrued to
77
+ * `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
78
+ * `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
79
+ * The planner includes the referral fee and its own allocator-leg penalties
80
+ * in destination debt, so penalized legs also cover their own penalty.
81
+ * Refinance never uses vaults with a 100% penalty.
66
82
  *
67
83
  * @default 0n
68
84
  */
@@ -3,7 +3,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
6
- getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2MidnightAdapterUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
6
+ getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
7
7
  export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
8
8
  export { EcrecoverRatifier as MidnightEcrecoverRatifier,
9
9
  /** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
@@ -17,7 +17,7 @@ RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier
17
17
  /** @deprecated Use MidnightSetterRatifier with a tagged tree. */
18
18
  SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
19
19
  export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
20
- export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, MidnightPositionLib, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
20
+ export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
21
21
  export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
22
22
  export { addTransactionMetadata } from "./helpers/metadata.js";
23
23
  export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
package/lib/cjs/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2MidnightAdapterUtils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.BlueSharesMath = exports.MathLib = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.BlueAdaptiveCurveIrmLib = void 0;
4
- exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.MidnightPositionLib = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = exports.createHasValue = void 0;
3
+ exports.createHasValue = exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.BlueSharesMath = exports.MathLib = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.BlueAdaptiveCurveIrmLib = void 0;
4
+ exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = void 0;
5
5
  var blue_sdk_1 = require("@morpho-org/blue-sdk");
6
6
  Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
7
7
  Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "BlueSharesMath", { enumerable: true, get: functi
15
15
  Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
16
16
  Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
17
17
  Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
18
- Object.defineProperty(exports, "VaultV2MidnightAdapterUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapterUtils; } });
19
18
  Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
20
19
  var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
21
20
  Object.defineProperty(exports, "catchRevertOnly", { enumerable: true, get: function () { return blue_sdk_viem_1.catchRevertOnly; } });
@@ -77,7 +76,6 @@ Object.defineProperty(exports, "isDefined", { enumerable: true, get: function ()
77
76
  Object.defineProperty(exports, "isNotNull", { enumerable: true, get: function () { return morpho_ts_1.isNotNull; } });
78
77
  Object.defineProperty(exports, "isNotUndefined", { enumerable: true, get: function () { return morpho_ts_1.isNotUndefined; } });
79
78
  Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return morpho_ts_1.keys; } });
80
- Object.defineProperty(exports, "MidnightPositionLib", { enumerable: true, get: function () { return morpho_ts_1.MidnightPositionLib; } });
81
79
  Object.defineProperty(exports, "mergeEntries", { enumerable: true, get: function () { return morpho_ts_1.mergeEntries; } });
82
80
  Object.defineProperty(exports, "retryPromiseLinearBackoff", { enumerable: true, get: function () { return morpho_ts_1.retryPromiseLinearBackoff; } });
83
81
  Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return morpho_ts_1.Time; } });
package/lib/esm/abis.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi as bluePreLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
package/lib/esm/abis.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
2
- export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
2
+ export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
3
3
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
4
4
  preLiquidationAbi as bluePreLiquidationAbi,
5
5
  /** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
@@ -50,6 +50,7 @@ export interface BlueBorrowParams {
50
50
  * @param params.metadata - Optional transaction metadata.
51
51
  * @returns A deep-frozen `Readonly<Transaction<BlueBorrowAction>>` whose calldata invokes the
52
52
  * combined BlueBundlesV1 entrypoint with a zero collateral leg.
53
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
53
54
  * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
54
55
  * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
55
56
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
@@ -20,6 +20,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
20
20
  * @param params.metadata - Optional transaction metadata.
21
21
  * @returns A deep-frozen `Readonly<Transaction<BlueBorrowAction>>` whose calldata invokes the
22
22
  * combined BlueBundlesV1 entrypoint with a zero collateral leg.
23
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
23
24
  * @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
24
25
  * @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
25
26
  * @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
@@ -56,6 +56,7 @@ export interface BlueRefinanceParams {
56
56
  * @param params.metadata - Optional transaction metadata.
57
57
  * @returns A deep-frozen `Readonly<Transaction<BlueRefinanceAction>>` whose
58
58
  * `to` address is BlueBundlesV1 and whose `action` records the normalized migration inputs.
59
+ * @throws {MarketIdMismatchError} when either market's `id` does not hash from its tuple fields.
59
60
  * @throws {RefinanceSameMarketError} when source and destination IDs match.
60
61
  * @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
61
62
  * @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
@@ -1,6 +1,6 @@
1
1
  import { encodeFunctionData, isAddressEqual } from "viem";
2
2
  import { blueBundlesV1Abi } from "../../abis.js";
3
- import { validateUint256Field } from "../../helpers/validate.js";
3
+ import { validateMarketParamsId, validateUint256Field, } from "../../helpers/validate.js";
4
4
  import { RefinanceSameMarketError, RefinanceTokenMismatchError, } from "../../types/index.js";
5
5
  import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlueBundlesV1PublicAllocations, getBlueBundlesV1SignedAuthorization, normalizeBlueBundlesV1CommonParams, } from "./common.js";
6
6
  /**
@@ -26,6 +26,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
26
26
  * @param params.metadata - Optional transaction metadata.
27
27
  * @returns A deep-frozen `Readonly<Transaction<BlueRefinanceAction>>` whose
28
28
  * `to` address is BlueBundlesV1 and whose `action` records the normalized migration inputs.
29
+ * @throws {MarketIdMismatchError} when either market's `id` does not hash from its tuple fields.
29
30
  * @throws {RefinanceSameMarketError} when source and destination IDs match.
30
31
  * @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
31
32
  * @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
@@ -64,6 +65,8 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
64
65
  */
65
66
  export const blueRefinance = (params) => {
66
67
  const { chainId, sourceMarketParams, destinationMarketParams } = params.market;
68
+ validateMarketParamsId(sourceMarketParams);
69
+ validateMarketParamsId(destinationMarketParams);
67
70
  const { userAddress, maxLtv, authorizationSignature } = params.args;
68
71
  if (sourceMarketParams.id === destinationMarketParams.id) {
69
72
  throw new RefinanceSameMarketError(sourceMarketParams.id);
@@ -53,6 +53,7 @@ export interface BlueRepayParams {
53
53
  * @param params.metadata - Optional transaction metadata.
54
54
  * @returns A deep-frozen `Readonly<Transaction<BlueRepayAction>>` whose calldata invokes the
55
55
  * combined BlueBundlesV1 entrypoint with a zero collateral-withdrawal leg.
56
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
56
57
  * @throws {NegativeInputError} when an amount or fee is negative.
57
58
  * @throws {MutuallyExclusiveRepayAmountsError} when assets and shares are both nonzero.
58
59
  * @throws {NonPositiveInputError} when repayment, funding, or deadline is not positive.
@@ -22,6 +22,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
22
22
  * @param params.metadata - Optional transaction metadata.
23
23
  * @returns A deep-frozen `Readonly<Transaction<BlueRepayAction>>` whose calldata invokes the
24
24
  * combined BlueBundlesV1 entrypoint with a zero collateral-withdrawal leg.
25
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
25
26
  * @throws {NegativeInputError} when an amount or fee is negative.
26
27
  * @throws {MutuallyExclusiveRepayAmountsError} when assets and shares are both nonzero.
27
28
  * @throws {NonPositiveInputError} when repayment, funding, or deadline is not positive.
@@ -63,6 +63,7 @@ export interface BlueRepayWithdrawCollateralParams {
63
63
  * @param params.metadata - Optional transaction metadata.
64
64
  * @returns A deep-frozen `Readonly<Transaction<BlueRepayWithdrawCollateralAction>>`
65
65
  * whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
66
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
66
67
  * @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
67
68
  * @throws {MutuallyExclusiveRepayAmountsError} when assets and shares are both nonzero.
68
69
  * @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
@@ -1,6 +1,6 @@
1
1
  import { encodeFunctionData } from "viem";
2
2
  import { blueBundlesV1Abi } from "../../abis.js";
3
- import { validateUint256Field } from "../../helpers/validate.js";
3
+ import { validateMarketParamsId, validateUint256Field, } from "../../helpers/validate.js";
4
4
  import { InputExceedsMaxError, MaxRepayAssetsBelowRepayAssetsError, MutuallyExclusiveRepayAmountsError, NonPositiveInputError, UnexpectedRequirementSignatureError, } from "../../types/index.js";
5
5
  import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, getBlueBundlesV1SignedAuthorization, getBlueBundlesV1TokenPermit, normalizeBlueBundlesV1CommonParams, validateBlueBundlesV1NativeFunding, } from "./common.js";
6
6
  /**
@@ -28,6 +28,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
28
28
  * @param params.metadata - Optional transaction metadata.
29
29
  * @returns A deep-frozen `Readonly<Transaction<BlueRepayWithdrawCollateralAction>>`
30
30
  * whose `to` address is BlueBundlesV1 and whose `action` records the normalized inputs.
31
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
31
32
  * @throws {NegativeInputError} when an amount, `maxLtv`, native value, or fee is negative.
32
33
  * @throws {MutuallyExclusiveRepayAmountsError} when assets and shares are both nonzero.
33
34
  * @throws {NonPositiveInputError} when both operation legs are zero, repay funding is absent, or the deadline is invalid.
@@ -70,6 +71,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
70
71
  */
71
72
  export const blueRepayWithdrawCollateral = (params) => {
72
73
  const { chainId, marketParams } = params.market;
74
+ validateMarketParamsId(marketParams);
73
75
  const { userAddress, repayAssets, repayShares, maxRepayAssets, collateralAssets, maxLtv, requirementSignature, authorizationSignature, } = params.args;
74
76
  for (const [field, value] of [
75
77
  ["repayAssets", repayAssets],
@@ -47,6 +47,7 @@ export interface BlueSupplyParams {
47
47
  * @param params.metadata - Optional transaction metadata.
48
48
  * @returns A deep-frozen `Readonly<Transaction<BlueSupplyAction>>` whose `to` address is
49
49
  * BlueBundlesV1 and whose `action` records the normalized supply inputs.
50
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
50
51
  * @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
51
52
  * @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
52
53
  * @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
@@ -1,6 +1,6 @@
1
1
  import { encodeFunctionData } from "viem";
2
2
  import { blueBundlesV1Abi } from "../../abis.js";
3
- import { validateUint256Field } from "../../helpers/validate.js";
3
+ import { validateMarketParamsId, validateUint256Field, } from "../../helpers/validate.js";
4
4
  import { NonPositiveInputError } from "../../types/index.js";
5
5
  import { getBundlesReferralFeeAssets } from "../bundles/common.js";
6
6
  import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normalizeBlueBundlesV1CommonParams, validateBlueBundlesV1NativeFunding, } from "./common.js";
@@ -23,6 +23,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
23
23
  * @param params.metadata - Optional transaction metadata.
24
24
  * @returns A deep-frozen `Readonly<Transaction<BlueSupplyAction>>` whose `to` address is
25
25
  * BlueBundlesV1 and whose `action` records the normalized supply inputs.
26
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
26
27
  * @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
27
28
  * @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
28
29
  * @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
@@ -59,6 +60,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
59
60
  */
60
61
  export const blueSupply = (params) => {
61
62
  const { chainId, marketParams } = params.market;
63
+ validateMarketParamsId(marketParams);
62
64
  const { assets, userAddress, requirementSignature } = params.args;
63
65
  if (assets <= 0n) {
64
66
  throw new NonPositiveInputError("assets", assets);
@@ -47,6 +47,7 @@ export interface BlueSupplyCollateralParams {
47
47
  * @param params.metadata - Optional transaction metadata.
48
48
  * @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralAction>>` whose calldata
49
49
  * invokes the combined BlueBundlesV1 entrypoint with a zero borrow leg.
50
+ * @throws {MarketIdMismatchError} when `marketParams.id` does not hash from its tuple fields.
50
51
  * @throws {NegativeInputError} when an amount or fee is negative.
51
52
  * @throws {NonPositiveInputError} when collateral or deadline is not positive.
52
53
  * @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.