@morpho-org/morpho-sdk 10.4.0 → 10.5.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (221) hide show
  1. package/lib/cjs/abis.d.ts +1 -1
  2. package/lib/cjs/abis.js +5 -1
  3. package/lib/cjs/actions/blue/common.js +12 -3
  4. package/lib/cjs/blue/abis.d.ts +1 -1
  5. package/lib/cjs/blue/abis.js +5 -1
  6. package/lib/cjs/blue/entities.d.ts +4 -4
  7. package/lib/cjs/blue/entities.js +3 -1
  8. package/lib/cjs/blue/errors.d.ts +2 -2
  9. package/lib/cjs/blue/errors.js +5 -1
  10. package/lib/cjs/blue/fetch.d.ts +2 -2
  11. package/lib/cjs/blue/fetch.js +3 -1
  12. package/lib/cjs/blue/utils.d.ts +1 -1
  13. package/lib/cjs/blue/utils.js +2 -1
  14. package/lib/cjs/entities/index.d.ts +4 -4
  15. package/lib/cjs/entities/index.js +3 -1
  16. package/lib/cjs/entities/midnight/midnight.d.ts +100 -103
  17. package/lib/cjs/entities/midnight/midnight.js +99 -99
  18. package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
  19. package/lib/cjs/entities/vaultV2/vaultV2.d.ts +34 -8
  20. package/lib/cjs/entities/vaultV2/vaultV2.js +39 -2
  21. package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -2
  22. package/lib/cjs/entities/vaultV2BlueReallocationData.js +6 -2
  23. package/lib/cjs/errors.d.ts +4 -4
  24. package/lib/cjs/errors.js +7 -5
  25. package/lib/cjs/fetch.d.ts +2 -2
  26. package/lib/cjs/fetch.js +3 -1
  27. package/lib/cjs/helpers/deadShares.js +3 -0
  28. package/lib/cjs/helpers/validate.d.ts +11 -1
  29. package/lib/cjs/midnight/errors.d.ts +2 -1
  30. package/lib/cjs/midnight/errors.js +5 -4
  31. package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
  32. package/lib/cjs/transactionPlan/assemble.js +25 -0
  33. package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
  34. package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
  35. package/lib/cjs/transactionPlan/blue/repay.js +10 -24
  36. package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
  37. package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
  38. package/lib/cjs/transactionPlan/blue/stored.js +87 -0
  39. package/lib/cjs/transactionPlan/blue/supply.js +7 -22
  40. package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  41. package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
  42. package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
  43. package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
  44. package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
  45. package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  46. package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
  47. package/lib/cjs/transactionPlan/deposit.js +4 -7
  48. package/lib/cjs/transactionPlan/intent.d.ts +1 -1
  49. package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +1 -1
  50. package/lib/cjs/transactionPlan/midnight/makeBorrow.js +1 -1
  51. package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +1 -1
  52. package/lib/cjs/transactionPlan/midnight/makeLend.js +1 -1
  53. package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +1 -1
  54. package/lib/cjs/transactionPlan/midnight/makeRepay.js +1 -1
  55. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
  56. package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
  57. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
  58. package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
  59. package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
  60. package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +1 -1
  61. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
  62. package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
  63. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
  64. package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
  65. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
  66. package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
  67. package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +2 -2
  68. package/lib/cjs/transactionPlan/midnight/takeBorrow.js +2 -2
  69. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  70. package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
  71. package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
  72. package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +1 -1
  73. package/lib/cjs/transactionPlan/permit.d.ts +15 -2
  74. package/lib/cjs/transactionPlan/permit.js +26 -68
  75. package/lib/cjs/transactionPlan/plan.d.ts +51 -1
  76. package/lib/cjs/transactionPlan/plan.js +56 -13
  77. package/lib/cjs/transactionPlan/redeem.js +4 -7
  78. package/lib/cjs/transactionPlan/types.d.ts +4 -3
  79. package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
  80. package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
  81. package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
  82. package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
  83. package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
  84. package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
  85. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  86. package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
  87. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  88. package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
  89. package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
  90. package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  91. package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
  92. package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
  93. package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
  94. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  95. package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
  96. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  97. package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
  98. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  99. package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
  100. package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
  101. package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
  102. package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  103. package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
  104. package/lib/cjs/transactionPlan/withdraw.js +4 -7
  105. package/lib/cjs/types/error.d.ts +2 -1
  106. package/lib/cjs/types/error.js +3 -2
  107. package/lib/cjs/utils.d.ts +2 -2
  108. package/lib/cjs/utils.js +4 -2
  109. package/lib/cjs/version.d.ts +1 -1
  110. package/lib/cjs/version.js +1 -1
  111. package/lib/esm/abis.d.ts +1 -1
  112. package/lib/esm/abis.js +1 -1
  113. package/lib/esm/actions/blue/common.js +13 -4
  114. package/lib/esm/blue/abis.d.ts +1 -1
  115. package/lib/esm/blue/abis.js +1 -1
  116. package/lib/esm/blue/entities.d.ts +4 -4
  117. package/lib/esm/blue/entities.js +2 -2
  118. package/lib/esm/blue/errors.d.ts +2 -2
  119. package/lib/esm/blue/errors.js +2 -2
  120. package/lib/esm/blue/fetch.d.ts +2 -2
  121. package/lib/esm/blue/fetch.js +2 -2
  122. package/lib/esm/blue/utils.d.ts +1 -1
  123. package/lib/esm/blue/utils.js +1 -1
  124. package/lib/esm/entities/index.d.ts +4 -4
  125. package/lib/esm/entities/index.js +2 -2
  126. package/lib/esm/entities/midnight/midnight.d.ts +100 -103
  127. package/lib/esm/entities/midnight/midnight.js +99 -99
  128. package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
  129. package/lib/esm/entities/vaultV2/vaultV2.d.ts +34 -8
  130. package/lib/esm/entities/vaultV2/vaultV2.js +40 -3
  131. package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -2
  132. package/lib/esm/entities/vaultV2BlueReallocationData.js +6 -2
  133. package/lib/esm/errors.d.ts +4 -4
  134. package/lib/esm/errors.js +4 -4
  135. package/lib/esm/fetch.d.ts +2 -2
  136. package/lib/esm/fetch.js +2 -2
  137. package/lib/esm/helpers/deadShares.js +4 -1
  138. package/lib/esm/helpers/validate.d.ts +11 -1
  139. package/lib/esm/midnight/errors.d.ts +2 -1
  140. package/lib/esm/midnight/errors.js +2 -1
  141. package/lib/esm/transactionPlan/assemble.d.ts +24 -0
  142. package/lib/esm/transactionPlan/assemble.js +21 -0
  143. package/lib/esm/transactionPlan/blue/borrow.js +15 -65
  144. package/lib/esm/transactionPlan/blue/refinance.js +10 -12
  145. package/lib/esm/transactionPlan/blue/repay.js +11 -25
  146. package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
  147. package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
  148. package/lib/esm/transactionPlan/blue/stored.js +80 -0
  149. package/lib/esm/transactionPlan/blue/supply.js +7 -22
  150. package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
  151. package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
  152. package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
  153. package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
  154. package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
  155. package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
  156. package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
  157. package/lib/esm/transactionPlan/deposit.js +5 -8
  158. package/lib/esm/transactionPlan/intent.d.ts +1 -1
  159. package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +1 -1
  160. package/lib/esm/transactionPlan/midnight/makeBorrow.js +1 -1
  161. package/lib/esm/transactionPlan/midnight/makeLend.d.ts +1 -1
  162. package/lib/esm/transactionPlan/midnight/makeLend.js +1 -1
  163. package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +1 -1
  164. package/lib/esm/transactionPlan/midnight/makeRepay.js +1 -1
  165. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
  166. package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
  167. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
  168. package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
  169. package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
  170. package/lib/esm/transactionPlan/midnight/supplyCollateral.js +1 -1
  171. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
  172. package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
  173. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
  174. package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
  175. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
  176. package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
  177. package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +2 -2
  178. package/lib/esm/transactionPlan/midnight/takeBorrow.js +2 -2
  179. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
  180. package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
  181. package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
  182. package/lib/esm/transactionPlan/midnight/takeWithdraw.js +1 -1
  183. package/lib/esm/transactionPlan/permit.d.ts +15 -2
  184. package/lib/esm/transactionPlan/permit.js +25 -68
  185. package/lib/esm/transactionPlan/plan.d.ts +51 -1
  186. package/lib/esm/transactionPlan/plan.js +55 -13
  187. package/lib/esm/transactionPlan/redeem.js +5 -8
  188. package/lib/esm/transactionPlan/types.d.ts +4 -3
  189. package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
  190. package/lib/esm/transactionPlan/vaultBinding.js +65 -0
  191. package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
  192. package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
  193. package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
  194. package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
  195. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
  196. package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
  197. package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
  198. package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
  199. package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
  200. package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
  201. package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
  202. package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
  203. package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
  204. package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
  205. package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
  206. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
  207. package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
  208. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
  209. package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
  210. package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
  211. package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
  212. package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
  213. package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
  214. package/lib/esm/transactionPlan/withdraw.js +5 -8
  215. package/lib/esm/types/error.d.ts +2 -1
  216. package/lib/esm/types/error.js +3 -2
  217. package/lib/esm/utils.d.ts +2 -2
  218. package/lib/esm/utils.js +2 -2
  219. package/lib/esm/version.d.ts +1 -1
  220. package/lib/esm/version.js +1 -1
  221. package/package.json +7 -7
package/lib/cjs/errors.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- 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.InvalidMidnightEcrecoverSignatureError = 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.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = void 0;
3
+ 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.InvalidMidnightEcrecoverSignatureError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnresolvedBlockNumberError = 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.InvalidBlueVaultV2MidnightAdapterMarketsError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
4
+ exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = 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; } });
9
10
  Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
10
11
  Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
11
12
  Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
@@ -34,6 +35,7 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
34
35
  Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
35
36
  Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
36
37
  Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
38
+ Object.defineProperty(exports, "UnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
37
39
  Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
38
40
  var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
39
41
  Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
@@ -44,9 +46,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
44
46
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
45
47
  Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
46
48
  Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
47
- Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
48
- Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
49
- Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
50
49
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
51
50
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
52
51
  Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -69,6 +68,9 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
69
68
  Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
70
69
  Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
71
70
  Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
71
+ Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
72
+ Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
73
+ Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
72
74
  Object.defineProperty(exports, "MissingLocalePartError", { enumerable: true, get: function () { return morpho_ts_1.MissingLocalePartError; } });
73
75
  Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
74
76
  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, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
1
+ export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MidnightAdapter, 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, 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, fetchVaultV2MidnightAdapter, 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,11 +1,12 @@
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.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;
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;
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; } });
9
10
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
10
11
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
11
12
  Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
@@ -29,6 +30,7 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
29
30
  Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
30
31
  Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
31
32
  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; } });
32
34
  Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
33
35
  Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
34
36
  Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
@@ -193,6 +193,9 @@ function getDeadSharesAbsoluteCap(id, { absoluteCaps, entity, adapter, }) {
193
193
  }
194
194
  /** Checks the currently allocated positions of one supported adapter. @internal */
195
195
  function assertAdapterDeadShares(adapter, { absoluteCaps, entity, }) {
196
+ if (adapter instanceof blue_sdk_1.AccrualVaultV2MidnightAdapter) {
197
+ return;
198
+ }
196
199
  if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter) {
197
200
  const id = blue_sdk_1.VaultV2MorphoVaultV1Adapter.adapterCapId(adapter.address);
198
201
  if (getDeadSharesAbsoluteCap(id, {
@@ -497,8 +497,18 @@ export declare const validateRepayShares: (params: {
497
497
  repayShares: bigint;
498
498
  marketId: MarketId;
499
499
  }) => void;
500
+ /** Plain allocation fields shared by reallocation validation and stored withdrawal plans. @internal */
501
+ export type BlueReallocationInput = Omit<VaultV2BlueReallocation, "from"> & {
502
+ readonly from: {
503
+ readonly type: "market";
504
+ readonly adapter: Address;
505
+ readonly marketParams: Readonly<InputMarketParams>;
506
+ } | Extract<VaultV2BlueReallocation["from"], {
507
+ type: "idle";
508
+ }>;
509
+ };
500
510
  /** @internal */
501
- export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<VaultV2BlueReallocation>, { targetMarketId, maxPenalty, }: {
511
+ export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<BlueReallocationInput>, { targetMarketId, maxPenalty, }: {
502
512
  readonly targetMarketId: MarketId;
503
513
  readonly maxPenalty?: bigint;
504
514
  }) => void;
@@ -1 +1,2 @@
1
- export { ChainIdMismatchError, InvalidEcrecoverSignatureError, 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
+ export { ChainIdMismatchError, InvalidEcrecoverSignatureError, 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,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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.InvalidEcrecoverSignatureError = exports.ChainIdMismatchError = void 0;
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.InvalidEcrecoverSignatureError = 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, "InvalidEcrecoverSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureError; } });
@@ -10,9 +10,6 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
10
10
  Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
11
11
  Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
12
12
  Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
13
- Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
14
- Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
15
- Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
16
13
  Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
17
14
  Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
18
15
  Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
@@ -30,3 +27,7 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
30
27
  Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
31
28
  Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
32
29
  Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
30
+ var morpho_ts_1 = require("@morpho-org/morpho-ts");
31
+ Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
32
+ Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
33
+ Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
@@ -0,0 +1,24 @@
1
+ import type { Address } from "viem";
2
+ import type { Intent } from "./intent.js";
3
+ import type { TransactionPlan } from "./types.js";
4
+ /**
5
+ * @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
6
+ * the intent has one.
7
+ */
8
+ export declare function planHeader({ chainId, account }: {
9
+ readonly chainId: number;
10
+ readonly account: Address;
11
+ }, { expiresAt, calldataOrigin }: Pick<Intent, "expiresAt" | "calldataOrigin">): {
12
+ readonly version: 2;
13
+ readonly chainId: number;
14
+ readonly account: `0x${string}`;
15
+ readonly expiresAt: number;
16
+ readonly calldataOrigin?: `0x${string}` | undefined;
17
+ };
18
+ /**
19
+ * @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
20
+ * passed in is frozen or shared with the plan.
21
+ */
22
+ export declare function freezePlan(plan: TransactionPlan, { detach }: {
23
+ readonly detach: boolean;
24
+ }): TransactionPlan;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.planHeader = planHeader;
4
+ exports.freezePlan = freezePlan;
5
+ const morpho_ts_1 = require("@morpho-org/morpho-ts");
6
+ /**
7
+ * @internal The stored plan header: version, chain, account, expiry, and the calldata origin when
8
+ * the intent has one.
9
+ */
10
+ function planHeader({ chainId, account }, { expiresAt, calldataOrigin }) {
11
+ return {
12
+ version: 2,
13
+ chainId,
14
+ account,
15
+ expiresAt,
16
+ ...(calldataOrigin && { calldataOrigin }),
17
+ };
18
+ }
19
+ /**
20
+ * @internal Deeply freezes a prepared plan. `detach` copies it first, so no object the caller
21
+ * passed in is frozen or shared with the plan.
22
+ */
23
+ function freezePlan(plan, { detach }) {
24
+ return (0, morpho_ts_1.deepFreeze)(detach ? structuredClone(plan) : plan);
25
+ }
@@ -9,9 +9,11 @@ const common_js_1 = require("../../actions/bundles/common.js");
9
9
  const getBlueBundlesV1QuoteTimestamp_js_1 = require("../../helpers/getBlueBundlesV1QuoteTimestamp.js");
10
10
  const index_js_1 = require("../../helpers/index.js");
11
11
  const validate_js_1 = require("../../helpers/validate.js");
12
+ const assemble_js_1 = require("../assemble.js");
12
13
  const error_js_1 = require("../error.js");
13
14
  const validation_js_1 = require("../validation.js");
14
15
  const prepare_js_1 = require("./prepare.js");
16
+ const stored_js_1 = require("./stored.js");
15
17
  /**
16
18
  * Prepares a BlueBundlesV1 borrow against existing collateral. No token allowance is needed.
17
19
  * Health uses the expiry, floored at max(now, lastUpdate), like the entity handle.
@@ -123,12 +125,8 @@ async function prepareBlueBorrow(client, { chainId, account, marketId, marketDat
123
125
  reason: "expected prepared borrow inputs",
124
126
  });
125
127
  }
126
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
127
- version: 2,
128
- account: inputs.account,
129
- chainId: inputs.chainId,
130
- expiresAt: intent.expiresAt,
131
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
128
+ return (0, assemble_js_1.freezePlan)({
129
+ ...(0, assemble_js_1.planHeader)({ chainId: inputs.chainId, account: inputs.account }, intent),
132
130
  steps: [
133
131
  ...steps,
134
132
  {
@@ -140,14 +138,14 @@ async function prepareBlueBorrow(client, { chainId, account, marketId, marketDat
140
138
  ...inputs,
141
139
  authorizationNonce: signatureRequests.find((request) => request.id === morphoAuthorizationRequestId)?.args.nonce ?? 0n,
142
140
  },
143
- signatureRequestIds: morphoAuthorizationRequestId
144
- ? { morphoAuthorization: morphoAuthorizationRequestId }
145
- : {},
141
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
142
+ morphoAuthorization: morphoAuthorizationRequestId,
143
+ }),
146
144
  },
147
145
  },
148
146
  ],
149
147
  signatureRequests,
150
- }));
148
+ }, { detach: true });
151
149
  }
152
150
  /** @internal Encodes a prepared borrow without state reads or signing. */
153
151
  function buildBlueBorrow(action, requests) {
@@ -190,26 +188,6 @@ function buildBlueBorrow(action, requests) {
190
188
  },
191
189
  });
192
190
  }
193
- function validateMarket(value, path) {
194
- const market = (0, validation_js_1.getPlanObject)(value, path);
195
- (0, validation_js_1.validatePlanFields)(market, {
196
- path,
197
- fields: {
198
- id: "hex",
199
- loanToken: "address",
200
- collateralToken: "address",
201
- oracle: "address",
202
- irm: "address",
203
- lltv: "uint256 bigint",
204
- },
205
- });
206
- if (typeof market.id !== "string" || market.id.length !== 66) {
207
- throw new error_js_1.InvalidTransactionPlanError({
208
- path: `${path}.id`,
209
- reason: "expected a 32-byte market ID",
210
- });
211
- }
212
- }
213
191
  /** @internal Validates the stored borrow recipe, including each allocator input. */
214
192
  function validateBorrowPlanAction(action, path) {
215
193
  const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
@@ -220,47 +198,19 @@ function validateBorrowPlanAction(action, path) {
220
198
  borrowAssets: "uint256 bigint",
221
199
  authorizationNonce: "uint256 bigint",
222
200
  maxLtv: "uint256 bigint",
223
- deadline: "uint256 bigint",
224
- referralFeePct: "uint256 bigint",
225
- referralFeeRecipient: "address",
201
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
226
202
  reallocations: "array",
227
203
  },
228
204
  });
229
- validateMarket(inputs.marketParams, `${path}.inputs.marketParams`);
205
+ (0, stored_js_1.validateStoredBlueMarket)(inputs.marketParams, `${path}.inputs.marketParams`);
230
206
  if (inputs.maxPenalty !== undefined) {
231
207
  (0, validation_js_1.validatePlanField)(inputs.maxPenalty, {
232
208
  path: `${path}.inputs.maxPenalty`,
233
209
  type: "uint256 bigint",
234
210
  });
235
211
  }
236
- for (const [index, value] of inputs.reallocations.entries()) {
237
- const entryPath = `${path}.inputs.reallocations[${index}]`;
238
- const entry = (0, validation_js_1.getPlanObject)(value, entryPath);
239
- (0, validation_js_1.validatePlanFields)(entry, {
240
- path: entryPath,
241
- fields: {
242
- vault: "address",
243
- assets: "uint256 bigint",
244
- penalty: "uint256 bigint",
245
- },
246
- });
247
- (0, validation_js_1.validatePlanFields)((0, validation_js_1.getPlanObject)(entry.to, `${entryPath}.to`), {
248
- path: `${entryPath}.to`,
249
- fields: { adapter: "address" },
250
- });
251
- const from = (0, validation_js_1.getPlanObject)(entry.from, `${entryPath}.from`);
252
- if (from.type !== "market" && from.type !== "idle") {
253
- throw new error_js_1.InvalidTransactionPlanError({
254
- path: `${entryPath}.from.type`,
255
- reason: "expected market or idle",
256
- });
257
- }
258
- if (from.type === "market") {
259
- (0, validation_js_1.validatePlanFields)(from, {
260
- path: `${entryPath}.from`,
261
- fields: { adapter: "address" },
262
- });
263
- validateMarket(from.marketParams, `${entryPath}.from.marketParams`);
264
- }
265
- }
212
+ (0, stored_js_1.validateStoredReallocations)(inputs.reallocations, {
213
+ path: `${path}.inputs.reallocations`,
214
+ marketParams: stored_js_1.validateStoredBlueMarket,
215
+ });
266
216
  }
@@ -10,10 +10,12 @@ const refinance_js_1 = require("../../actions/blue/refinance.js");
10
10
  const refinanceValidation_js_1 = require("../../actions/blue/refinanceValidation.js");
11
11
  const index_js_1 = require("../../helpers/index.js");
12
12
  const parse_js_1 = require("../../helpers/parse.js");
13
+ const assemble_js_1 = require("../assemble.js");
13
14
  const error_js_1 = require("../error.js");
14
15
  const validation_js_1 = require("../validation.js");
15
16
  const prepare_js_1 = require("./prepare.js");
16
17
  const refinanceValidation_js_2 = require("./refinanceValidation.js");
18
+ const stored_js_1 = require("./stored.js");
17
19
  /**
18
20
  * Prepares a full Blue borrow-position migration. Fetch both market and position snapshots at the
19
21
  * same block and pass that block's timestamp as `now`. Penalties and fees increase destination debt;
@@ -157,20 +159,18 @@ async function prepareBlueRefinance(client, params) {
157
159
  ...(maxPenalty !== undefined && { maxPenalty }),
158
160
  ...(request && { authorizationNonce: request.args.nonce }),
159
161
  },
160
- signatureRequestIds: request === undefined ? {} : { morphoAuthorization: request.id },
162
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
163
+ morphoAuthorization: request?.id,
164
+ }),
161
165
  };
162
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
163
- version: 2,
164
- account,
165
- chainId,
166
- expiresAt: intent.expiresAt,
167
- ...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
166
+ return (0, assemble_js_1.freezePlan)({
167
+ ...(0, assemble_js_1.planHeader)({ chainId, account }, intent),
168
168
  steps: [
169
169
  ...steps,
170
170
  { id, label: "Refinance Blue borrow position", action },
171
171
  ],
172
172
  signatureRequests,
173
- }));
173
+ }, { detach: true });
174
174
  }
175
175
  function validatePlanMarketParams(value, path) {
176
176
  const params = (0, validation_js_1.getPlanObject)(value, path);
@@ -246,9 +246,7 @@ function validateRefinancePlanAction(action, path) {
246
246
  path: `${path}.inputs`,
247
247
  fields: {
248
248
  maxLtv: "uint256 bigint",
249
- deadline: "uint256 bigint",
250
- referralFeePct: "uint256 bigint",
251
- referralFeeRecipient: "address",
249
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
252
250
  reallocations: "array",
253
251
  },
254
252
  });
@@ -14,10 +14,12 @@ const parse_js_1 = require("../../helpers/parse.js");
14
14
  const quoteBlueRepay_js_1 = require("../../helpers/quoteBlueRepay.js");
15
15
  const validate_js_1 = require("../../helpers/validate.js");
16
16
  const index_js_1 = require("../../types/index.js");
17
+ const assemble_js_1 = require("../assemble.js");
17
18
  const error_js_1 = require("../error.js");
18
19
  const permit_js_1 = require("../permit.js");
19
20
  const validation_js_1 = require("../validation.js");
20
21
  const prepare_js_1 = require("./prepare.js");
22
+ const stored_js_1 = require("./stored.js");
21
23
  /**
22
24
  * Prepares an asset, share, or full Blue repayment through BlueBundlesV1, never Permit2.
23
25
  * Share quotes accrue the supplied position to expiry, at most two hours from the reference time.
@@ -139,12 +141,8 @@ async function prepareBlueRepay(client, { chainId, account, marketId, marketData
139
141
  reason: "expected resolved repayment inputs",
140
142
  });
141
143
  }
142
- return (0, morpho_ts_1.deepFreeze)(structuredClone({
143
- version: 2,
144
- chainId: params.chainId,
145
- account: params.account,
146
- expiresAt: resolvedIntent.expiresAt,
147
- calldataOrigin: resolvedIntent.calldataOrigin,
144
+ return (0, assemble_js_1.freezePlan)({
145
+ ...(0, assemble_js_1.planHeader)({ chainId: params.chainId, account: params.account }, resolvedIntent),
148
146
  steps: [
149
147
  ...steps,
150
148
  {
@@ -153,14 +151,14 @@ async function prepareBlueRepay(client, { chainId, account, marketId, marketData
153
151
  action: {
154
152
  type: "blueRepay",
155
153
  inputs,
156
- signatureRequestIds: signatureRequests.length
157
- ? { tokenPermit: signatureRequests[0]?.id }
158
- : {},
154
+ signatureRequestIds: (0, stored_js_1.signatureRoles)({
155
+ tokenPermit: signatureRequests[0]?.id,
156
+ }),
159
157
  },
160
158
  },
161
159
  ],
162
160
  signatureRequests,
163
- }));
161
+ }, { detach: true });
164
162
  }
165
163
  /** @internal Checks a repayment permit against the fixed token pull. */
166
164
  function validateBlueRepayPermit(request, action) {
@@ -203,9 +201,7 @@ function validateBlueRepayPlanAction(action, path) {
203
201
  repayAssets: "uint256 bigint",
204
202
  repayShares: "uint256 bigint",
205
203
  maxRepayAssets: "uint256 bigint",
206
- deadline: "uint256 bigint",
207
- referralFeePct: "uint256 bigint",
208
- referralFeeRecipient: "address",
204
+ ...stored_js_1.BUNDLES_COMMON_FIELDS,
209
205
  },
210
206
  });
211
207
  if (inputs.nativeAssets !== undefined) {
@@ -214,16 +210,6 @@ function validateBlueRepayPlanAction(action, path) {
214
210
  fields: { nativeAssets: "uint256 bigint" },
215
211
  });
216
212
  }
217
- const market = (0, validation_js_1.getPlanObject)(inputs.marketParams, `${path}.inputs.marketParams`);
218
- (0, validation_js_1.validatePlanFields)(market, {
219
- path: `${path}.inputs.marketParams`,
220
- fields: {
221
- loanToken: "address",
222
- collateralToken: "address",
223
- oracle: "address",
224
- irm: "address",
225
- lltv: "uint256 bigint",
226
- },
227
- });
213
+ (0, stored_js_1.validateStoredBlueMarketParams)(inputs.marketParams, `${path}.inputs.marketParams`);
228
214
  (0, validation_js_1.getPlanObject)(action.signatureRequestIds, `${path}.signatureRequestIds`);
229
215
  }