@morpho-org/morpho-sdk 9.6.0-next.0 → 9.7.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.
- package/MIGRATION-v6-to-v7.md +1 -1
- package/README.md +123 -3
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/cjs/actions/bundles/common.js +39 -32
- package/lib/cjs/actions/midnight/cancelAndMake.js +20 -98
- package/lib/cjs/actions/midnight/index.d.ts +2 -0
- package/lib/cjs/actions/midnight/index.js +2 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +5 -6
- package/lib/cjs/actions/midnight/supplyCollateralBatch.d.ts +39 -0
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +91 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +31 -32
- package/lib/cjs/actions/midnight/takeBorrow.js +24 -23
- package/lib/cjs/actions/midnight/takeLend.js +24 -23
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
- package/lib/cjs/actions/midnight/takeWithdraw.js +24 -23
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +104 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
- package/lib/cjs/actions/vaultV1/migrateToV2.js +7 -7
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/index.d.ts +5 -5
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +77 -3
- package/lib/cjs/entities/midnight/midnight.js +174 -0
- package/lib/cjs/entities/midnight/types.d.ts +16 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +12 -46
- package/lib/cjs/entities/requirements/getErc2612Permit.d.ts +7 -0
- package/lib/cjs/entities/requirements/getErc2612Permit.js +60 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -3
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +10 -35
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -33
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +6 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.js +0 -2
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +1 -0
- package/lib/cjs/helpers/signAndVerifyTypedData.js +12 -5
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
- package/lib/cjs/helpers/validateMidnightCancelAndMakePublication.js +129 -0
- package/lib/cjs/helpers/validateMidnightCollateralBatch.d.ts +15 -0
- package/lib/cjs/helpers/validateMidnightCollateralBatch.js +28 -0
- package/lib/cjs/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
- package/lib/cjs/helpers/validateMidnightCollateralSupplies.js +28 -0
- package/lib/cjs/helpers/validatePositiveInput.d.ts +10 -0
- package/lib/cjs/helpers/validatePositiveInput.js +18 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +18 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +5 -5
- package/lib/cjs/transactionPlan/approval.d.ts +2 -0
- package/lib/cjs/transactionPlan/approval.js +16 -0
- package/lib/cjs/transactionPlan/error.d.ts +145 -0
- package/lib/cjs/transactionPlan/error.js +186 -0
- package/lib/cjs/transactionPlan/getTokenPermit.d.ts +11 -0
- package/lib/cjs/transactionPlan/getTokenPermit.js +18 -0
- package/lib/cjs/transactionPlan/index.d.ts +9 -0
- package/lib/cjs/transactionPlan/index.js +24 -0
- package/lib/cjs/transactionPlan/intent.d.ts +51 -0
- package/lib/cjs/transactionPlan/intent.js +54 -0
- package/lib/cjs/transactionPlan/permit.d.ts +13 -0
- package/lib/cjs/transactionPlan/permit.js +145 -0
- package/lib/cjs/transactionPlan/plan.d.ts +99 -0
- package/lib/cjs/transactionPlan/plan.js +232 -0
- package/lib/cjs/transactionPlan/requirements.d.ts +44 -0
- package/lib/cjs/transactionPlan/requirements.js +79 -0
- package/lib/cjs/transactionPlan/serde.d.ts +33 -0
- package/lib/cjs/transactionPlan/serde.js +205 -0
- package/lib/cjs/transactionPlan/types.d.ts +91 -0
- package/lib/cjs/transactionPlan/types.js +2 -0
- package/lib/cjs/transactionPlan/validateActions.d.ts +8 -0
- package/lib/cjs/transactionPlan/validateActions.js +19 -0
- package/lib/cjs/transactionPlan/validation.d.ts +17 -0
- package/lib/cjs/transactionPlan/validation.js +70 -0
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +81 -0
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +211 -0
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +77 -0
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +190 -0
- package/lib/cjs/transactionPlan/version.d.ts +2 -0
- package/lib/cjs/transactionPlan/version.js +9 -0
- package/lib/cjs/types/action.d.ts +18 -3
- package/lib/cjs/types/error.d.ts +23 -2
- package/lib/cjs/types/error.js +45 -5
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/esm/actions/bundles/common.js +39 -32
- package/lib/esm/actions/midnight/cancelAndMake.js +25 -103
- package/lib/esm/actions/midnight/index.d.ts +2 -0
- package/lib/esm/actions/midnight/index.js +2 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +5 -6
- package/lib/esm/actions/midnight/supplyCollateralBatch.d.ts +39 -0
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +87 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +33 -34
- package/lib/esm/actions/midnight/takeBorrow.js +25 -24
- package/lib/esm/actions/midnight/takeLend.js +25 -24
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +20 -19
- package/lib/esm/actions/midnight/takeWithdraw.js +25 -24
- package/lib/esm/actions/midnight/withdrawCollateralBatch.d.ts +44 -0
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +100 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +1 -0
- package/lib/esm/actions/vaultV1/migrateToV2.js +8 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/index.d.ts +5 -5
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +77 -3
- package/lib/esm/entities/midnight/midnight.js +176 -2
- package/lib/esm/entities/midnight/types.d.ts +16 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +14 -48
- package/lib/esm/entities/requirements/getErc2612Permit.d.ts +7 -0
- package/lib/esm/entities/requirements/getErc2612Permit.js +57 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -3
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +10 -35
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -33
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +1 -3
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +1 -0
- package/lib/esm/helpers/signAndVerifyTypedData.js +13 -6
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.d.ts +68 -0
- package/lib/esm/helpers/validateMidnightCancelAndMakePublication.js +124 -0
- package/lib/esm/helpers/validateMidnightCollateralBatch.d.ts +15 -0
- package/lib/esm/helpers/validateMidnightCollateralBatch.js +25 -0
- package/lib/esm/helpers/validateMidnightCollateralSupplies.d.ts +17 -0
- package/lib/esm/helpers/validateMidnightCollateralSupplies.js +24 -0
- package/lib/esm/helpers/validatePositiveInput.d.ts +10 -0
- package/lib/esm/helpers/validatePositiveInput.js +14 -0
- package/lib/esm/index.d.ts +2 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/approval.d.ts +2 -0
- package/lib/esm/transactionPlan/approval.js +13 -0
- package/lib/esm/transactionPlan/error.d.ts +145 -0
- package/lib/esm/transactionPlan/error.js +175 -0
- package/lib/esm/transactionPlan/getTokenPermit.d.ts +11 -0
- package/lib/esm/transactionPlan/getTokenPermit.js +15 -0
- package/lib/esm/transactionPlan/index.d.ts +9 -0
- package/lib/esm/transactionPlan/index.js +5 -0
- package/lib/esm/transactionPlan/intent.d.ts +51 -0
- package/lib/esm/transactionPlan/intent.js +51 -0
- package/lib/esm/transactionPlan/permit.d.ts +13 -0
- package/lib/esm/transactionPlan/permit.js +140 -0
- package/lib/esm/transactionPlan/plan.d.ts +99 -0
- package/lib/esm/transactionPlan/plan.js +226 -0
- package/lib/esm/transactionPlan/requirements.d.ts +44 -0
- package/lib/esm/transactionPlan/requirements.js +74 -0
- package/lib/esm/transactionPlan/serde.d.ts +33 -0
- package/lib/esm/transactionPlan/serde.js +201 -0
- package/lib/esm/transactionPlan/types.d.ts +91 -0
- package/lib/esm/transactionPlan/types.js +1 -0
- package/lib/esm/transactionPlan/validateActions.d.ts +8 -0
- package/lib/esm/transactionPlan/validateActions.js +16 -0
- package/lib/esm/transactionPlan/validation.d.ts +17 -0
- package/lib/esm/transactionPlan/validation.js +64 -0
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +81 -0
- package/lib/esm/transactionPlan/vaultv2/deposit.js +206 -0
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +77 -0
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +185 -0
- package/lib/esm/transactionPlan/version.d.ts +2 -0
- package/lib/esm/transactionPlan/version.js +6 -0
- package/lib/esm/types/action.d.ts +18 -3
- package/lib/esm/types/error.d.ts +23 -2
- package/lib/esm/types/error.js +40 -3
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +8 -7
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError,
|
|
5
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureError as InvalidMidnightEcrecoverSignatureError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError,
|
|
7
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, RetriesExhaustedError, RetryStoppedError, } from "@morpho-org/morpho-ts";
|
package/lib/cjs/errors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.
|
|
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.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;
|
|
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; } });
|
|
@@ -35,16 +34,19 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
|
|
|
35
34
|
Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
|
|
36
35
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
37
36
|
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; } });
|
|
39
37
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
|
40
38
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
41
39
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
40
|
+
Object.defineProperty(exports, "InvalidMidnightEcrecoverSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureError; } });
|
|
42
41
|
Object.defineProperty(exports, "InvalidMidnightEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
|
|
43
42
|
Object.defineProperty(exports, "InvalidMidnightMarketParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMarketParameterError; } });
|
|
44
43
|
Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiQuoteTargetError; } });
|
|
45
44
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
46
45
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
47
46
|
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; } });
|
|
48
50
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
49
51
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
50
52
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -67,9 +69,6 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
|
|
|
67
69
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
|
|
68
70
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
|
|
69
71
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
70
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
71
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
72
|
-
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
73
72
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
74
73
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
|
75
74
|
Object.defineProperty(exports, "RetriesExhaustedError", { enumerable: true, get: function () { return morpho_ts_1.RetriesExhaustedError; } });
|
package/lib/cjs/fetch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter,
|
|
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,
|
|
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.
|
|
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; } });
|
|
@@ -156,8 +156,6 @@ function validateVaultV2DeadShares(vault, path = []) {
|
|
|
156
156
|
return cap;
|
|
157
157
|
};
|
|
158
158
|
for (const adapter of vault.accrualAdapters) {
|
|
159
|
-
if (adapter instanceof blue_sdk_1.AccrualVaultV2MidnightAdapter)
|
|
160
|
-
continue;
|
|
161
159
|
if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter) {
|
|
162
160
|
const id = blue_sdk_1.VaultV2MorphoVaultV1Adapter.adapterCapId(adapter.address);
|
|
163
161
|
if (capOf(id, adapter.address) > 0n)
|
|
@@ -16,6 +16,7 @@ import type { Address, Hex, TypedDataDefinition, WalletClient } from "viem";
|
|
|
16
16
|
* @throws {AddressMismatchError} when the wallet client account differs from `userAddress`.
|
|
17
17
|
* @throws {ChainIdMismatchError} when the wallet client targets a different chain than the typed-data domain.
|
|
18
18
|
* @throws {InvalidSignatureError} when the signature does not recover to `userAddress`.
|
|
19
|
+
* @throws {MalformedSignatureError} when verification throws; preserves the original error as `cause` with redacted signature diagnostics. Extends `InvalidSignatureError`.
|
|
19
20
|
* @example
|
|
20
21
|
* ```ts
|
|
21
22
|
* import { signAndVerifyTypedData } from "@morpho-org/morpho-sdk";
|
|
@@ -22,6 +22,7 @@ const validate_js_1 = require("./validate.js");
|
|
|
22
22
|
* @throws {AddressMismatchError} when the wallet client account differs from `userAddress`.
|
|
23
23
|
* @throws {ChainIdMismatchError} when the wallet client targets a different chain than the typed-data domain.
|
|
24
24
|
* @throws {InvalidSignatureError} when the signature does not recover to `userAddress`.
|
|
25
|
+
* @throws {MalformedSignatureError} when verification throws; preserves the original error as `cause` with redacted signature diagnostics. Extends `InvalidSignatureError`.
|
|
25
26
|
* @example
|
|
26
27
|
* ```ts
|
|
27
28
|
* import { signAndVerifyTypedData } from "@morpho-org/morpho-sdk";
|
|
@@ -45,11 +46,17 @@ const signAndVerifyTypedData = async (params) => {
|
|
|
45
46
|
...typedData,
|
|
46
47
|
account,
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
let isValid;
|
|
50
|
+
try {
|
|
51
|
+
isValid = await (0, viem_1.verifyTypedData)({
|
|
52
|
+
...typedData,
|
|
53
|
+
address: userAddress,
|
|
54
|
+
signature,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
catch (cause) {
|
|
58
|
+
throw new index_js_1.MalformedSignatureError({ signature, cause });
|
|
59
|
+
}
|
|
53
60
|
if (!isValid) {
|
|
54
61
|
throw new index_js_1.InvalidSignatureError();
|
|
55
62
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { MidnightCancelAndMakeParams } from "../types/midnightCancelAndMake.js";
|
|
2
|
+
/**
|
|
3
|
+
* Validates publication content after snapshot and hex-shape validation.
|
|
4
|
+
*
|
|
5
|
+
* @param params - Publication, chain deployment, and groups cancelled by this bundle.
|
|
6
|
+
* @returns Nothing when publication content and funding inputs are valid.
|
|
7
|
+
* @throws {InvalidTreeError} when the root is zero, payload empty, or groups empty.
|
|
8
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
9
|
+
* @throws {MidnightCalldataEncodingError} when the ratifier or collateral market address is malformed.
|
|
10
|
+
* @throws {UnsupportedMidnightAuthorizationTargetError} when the ratifier is not supported.
|
|
11
|
+
* @throws {MidnightReplacementGroupCancelledError} when a published group is cancelled.
|
|
12
|
+
* @throws {NonPositiveInputError} when Blue funding or a collateral supply is not positive.
|
|
13
|
+
* @throws {InputExceedsMaxError} when funding or collateral supply totals exceed uint128.
|
|
14
|
+
* @throws {EmptyMidnightCollateralSuppliesError} when collateral supplies are empty.
|
|
15
|
+
* @throws {ChainIdMismatchError} when the collateral market targets another chain.
|
|
16
|
+
* @throws {MidnightMarketAddressMismatchError} when its Midnight deployment differs.
|
|
17
|
+
* @throws {UnknownCollateralIndexError} when a supply index is not configured.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
export declare const validateMidnightCancelAndMakePublication: ({ publication, chainId, cancelledGroups, }: {
|
|
21
|
+
readonly publication: NonNullable<MidnightCancelAndMakeParams["publication"]>;
|
|
22
|
+
readonly chainId: number;
|
|
23
|
+
readonly cancelledGroups: ReadonlySet<string>;
|
|
24
|
+
}) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Copies validated publication fields and supplies zero ABI defaults for omitted steps.
|
|
27
|
+
*
|
|
28
|
+
* @param publication - Snapshotted publication, or undefined for cancellation only.
|
|
29
|
+
* @returns ABI defaults and copied publication fields, without mutating the input.
|
|
30
|
+
* @internal
|
|
31
|
+
*/
|
|
32
|
+
export declare const normalizeMidnightCancelAndMakePublication: (publication: MidnightCancelAndMakeParams["publication"]) => {
|
|
33
|
+
supplies: {
|
|
34
|
+
collateralIndex: bigint;
|
|
35
|
+
assets: bigint;
|
|
36
|
+
}[];
|
|
37
|
+
blueSupply: {
|
|
38
|
+
market: {
|
|
39
|
+
loanToken: `0x${string}`;
|
|
40
|
+
collateralToken: `0x${string}`;
|
|
41
|
+
oracle: `0x${string}`;
|
|
42
|
+
irm: `0x${string}`;
|
|
43
|
+
lltv: bigint;
|
|
44
|
+
};
|
|
45
|
+
assets: bigint;
|
|
46
|
+
callbackSalt: `0x${string}`;
|
|
47
|
+
} | undefined;
|
|
48
|
+
signature: import("../index.js").MidnightRootActivationSignature;
|
|
49
|
+
blueMarket: {
|
|
50
|
+
readonly loanToken: "0x0000000000000000000000000000000000000000";
|
|
51
|
+
readonly collateralToken: "0x0000000000000000000000000000000000000000";
|
|
52
|
+
readonly oracle: "0x0000000000000000000000000000000000000000";
|
|
53
|
+
readonly irm: "0x0000000000000000000000000000000000000000";
|
|
54
|
+
readonly lltv: 0n;
|
|
55
|
+
} | {
|
|
56
|
+
loanToken: `0x${string}`;
|
|
57
|
+
collateralToken: `0x${string}`;
|
|
58
|
+
oracle: `0x${string}`;
|
|
59
|
+
irm: `0x${string}`;
|
|
60
|
+
lltv: bigint;
|
|
61
|
+
};
|
|
62
|
+
assetsToPark: bigint;
|
|
63
|
+
callbackSalt: `0x${string}`;
|
|
64
|
+
ratifier: `0x${string}`;
|
|
65
|
+
root: `0x${string}`;
|
|
66
|
+
groups: `0x${string}`[];
|
|
67
|
+
payload: `0x${string}`;
|
|
68
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeMidnightCancelAndMakePublication = exports.validateMidnightCancelAndMakePublication = void 0;
|
|
4
|
+
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
+
const viem_1 = require("viem");
|
|
7
|
+
const index_js_1 = require("../types/index.js");
|
|
8
|
+
const validateMidnightAccount_js_1 = require("./validateMidnightAccount.js");
|
|
9
|
+
const validateMidnightBounds_js_1 = require("./validateMidnightBounds.js");
|
|
10
|
+
const validateMidnightCollateralSupplies_js_1 = require("./validateMidnightCollateralSupplies.js");
|
|
11
|
+
const validateMidnightMarket_js_1 = require("./validateMidnightMarket.js");
|
|
12
|
+
const validatePositiveInput_js_1 = require("./validatePositiveInput.js");
|
|
13
|
+
/** Blue market argument for `MidnightBundlesV2` calls that park no loan assets. */
|
|
14
|
+
const emptyBlueMarket = {
|
|
15
|
+
loanToken: viem_1.zeroAddress,
|
|
16
|
+
collateralToken: viem_1.zeroAddress,
|
|
17
|
+
oracle: viem_1.zeroAddress,
|
|
18
|
+
irm: viem_1.zeroAddress,
|
|
19
|
+
lltv: 0n,
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Validates publication content after snapshot and hex-shape validation.
|
|
23
|
+
*
|
|
24
|
+
* @param params - Publication, chain deployment, and groups cancelled by this bundle.
|
|
25
|
+
* @returns Nothing when publication content and funding inputs are valid.
|
|
26
|
+
* @throws {InvalidTreeError} when the root is zero, payload empty, or groups empty.
|
|
27
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
28
|
+
* @throws {MidnightCalldataEncodingError} when the ratifier or collateral market address is malformed.
|
|
29
|
+
* @throws {UnsupportedMidnightAuthorizationTargetError} when the ratifier is not supported.
|
|
30
|
+
* @throws {MidnightReplacementGroupCancelledError} when a published group is cancelled.
|
|
31
|
+
* @throws {NonPositiveInputError} when Blue funding or a collateral supply is not positive.
|
|
32
|
+
* @throws {InputExceedsMaxError} when funding or collateral supply totals exceed uint128.
|
|
33
|
+
* @throws {EmptyMidnightCollateralSuppliesError} when collateral supplies are empty.
|
|
34
|
+
* @throws {ChainIdMismatchError} when the collateral market targets another chain.
|
|
35
|
+
* @throws {MidnightMarketAddressMismatchError} when its Midnight deployment differs.
|
|
36
|
+
* @throws {UnknownCollateralIndexError} when a supply index is not configured.
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
const validateMidnightCancelAndMakePublication = ({ publication, chainId, cancelledGroups, }) => {
|
|
40
|
+
if (publication.root === viem_1.zeroHash) {
|
|
41
|
+
throw new midnight_sdk_1.InvalidTreeError("Offer root cannot be zero.");
|
|
42
|
+
}
|
|
43
|
+
if (publication.payload === "0x") {
|
|
44
|
+
throw new midnight_sdk_1.InvalidTreeError("Offer payload cannot be empty.");
|
|
45
|
+
}
|
|
46
|
+
if (publication.groups.length === 0) {
|
|
47
|
+
throw new midnight_sdk_1.InvalidTreeError("Offer groups cannot be empty.");
|
|
48
|
+
}
|
|
49
|
+
const { priceRatifierV1, rateRatifierV1 } = (0, morpho_ts_1.getChainAddresses)(chainId);
|
|
50
|
+
const supportedTargets = [priceRatifierV1, rateRatifierV1].filter((target) => target != null);
|
|
51
|
+
(0, validateMidnightAccount_js_1.validateMidnightAddress)("publication.ratifier", publication.ratifier);
|
|
52
|
+
if (!supportedTargets.some((target) => (0, viem_1.isAddressEqual)(publication.ratifier, target))) {
|
|
53
|
+
throw new index_js_1.UnsupportedMidnightAuthorizationTargetError({
|
|
54
|
+
authorized: publication.ratifier,
|
|
55
|
+
chainId,
|
|
56
|
+
supportedTargets,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
for (const group of publication.groups) {
|
|
60
|
+
if (cancelledGroups.has(group.toLowerCase())) {
|
|
61
|
+
throw new index_js_1.MidnightReplacementGroupCancelledError({ group });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (publication.blueSupply != null) {
|
|
65
|
+
// Validation only; rejects non-positive Blue supply amounts.
|
|
66
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)("blueSupply.assets", publication.blueSupply.assets);
|
|
67
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("blueSupply.assets", publication.blueSupply.assets);
|
|
68
|
+
}
|
|
69
|
+
if (publication.collateral != null) {
|
|
70
|
+
if (publication.collateral.supplies.length === 0) {
|
|
71
|
+
throw new index_js_1.EmptyMidnightCollateralSuppliesError();
|
|
72
|
+
}
|
|
73
|
+
(0, validateMidnightMarket_js_1.validateMidnightMarket)({
|
|
74
|
+
market: publication.collateral.market,
|
|
75
|
+
chainId,
|
|
76
|
+
});
|
|
77
|
+
// Validation only; checks supply entries and their per-index totals.
|
|
78
|
+
(0, validateMidnightCollateralSupplies_js_1.validateMidnightCollateralSupplies)({
|
|
79
|
+
market: publication.collateral.market,
|
|
80
|
+
field: "collateral.supplies",
|
|
81
|
+
supplies: publication.collateral.supplies,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
exports.validateMidnightCancelAndMakePublication = validateMidnightCancelAndMakePublication;
|
|
86
|
+
/**
|
|
87
|
+
* Copies validated publication fields and supplies zero ABI defaults for omitted steps.
|
|
88
|
+
*
|
|
89
|
+
* @param publication - Snapshotted publication, or undefined for cancellation only.
|
|
90
|
+
* @returns ABI defaults and copied publication fields, without mutating the input.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
const normalizeMidnightCancelAndMakePublication = (publication) => {
|
|
94
|
+
const supplies = (publication?.collateral?.supplies ?? []).map(({ collateralIndex, assets }) => ({ collateralIndex, assets }));
|
|
95
|
+
const blueSupply = publication?.blueSupply == null
|
|
96
|
+
? undefined
|
|
97
|
+
: {
|
|
98
|
+
market: {
|
|
99
|
+
loanToken: publication.blueSupply.market.loanToken,
|
|
100
|
+
collateralToken: publication.blueSupply.market.collateralToken,
|
|
101
|
+
oracle: publication.blueSupply.market.oracle,
|
|
102
|
+
irm: publication.blueSupply.market.irm,
|
|
103
|
+
lltv: publication.blueSupply.market.lltv,
|
|
104
|
+
},
|
|
105
|
+
assets: publication.blueSupply.assets,
|
|
106
|
+
callbackSalt: publication.blueSupply.callbackSalt,
|
|
107
|
+
};
|
|
108
|
+
const signature = publication?.rootSignature ?? {
|
|
109
|
+
height: 0n,
|
|
110
|
+
nonce: 0n,
|
|
111
|
+
deadline: 0n,
|
|
112
|
+
v: 0,
|
|
113
|
+
r: viem_1.zeroHash,
|
|
114
|
+
s: viem_1.zeroHash,
|
|
115
|
+
};
|
|
116
|
+
return {
|
|
117
|
+
supplies,
|
|
118
|
+
blueSupply,
|
|
119
|
+
signature,
|
|
120
|
+
blueMarket: blueSupply?.market ?? emptyBlueMarket,
|
|
121
|
+
assetsToPark: blueSupply?.assets ?? 0n,
|
|
122
|
+
callbackSalt: blueSupply?.callbackSalt ?? viem_1.zeroHash,
|
|
123
|
+
ratifier: publication?.ratifier ?? viem_1.zeroAddress,
|
|
124
|
+
root: publication?.root ?? viem_1.zeroHash,
|
|
125
|
+
groups: [...(publication?.groups ?? [])],
|
|
126
|
+
payload: publication?.payload ?? "0x",
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
exports.normalizeMidnightCancelAndMakePublication = normalizeMidnightCancelAndMakePublication;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MidnightCollateralTransfer } from "../types/action.js";
|
|
2
|
+
/**
|
|
3
|
+
* Rejects empty batches and repeated collateral indexes.
|
|
4
|
+
* @internal
|
|
5
|
+
* @param transfers - Ordered collateral transfers.
|
|
6
|
+
* @param emptyError - Operation-specific error thrown for an empty batch.
|
|
7
|
+
* @returns Nothing.
|
|
8
|
+
* @throws `emptyError` when `transfers` is empty.
|
|
9
|
+
* @throws {DuplicateMidnightCollateralIndexError} when an index appears twice.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* validateMidnightCollateralBatch(supplies, new EmptyMidnightCollateralSuppliesError());
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function validateMidnightCollateralBatch(transfers: readonly MidnightCollateralTransfer[], emptyError: Error): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateMidnightCollateralBatch = validateMidnightCollateralBatch;
|
|
4
|
+
const error_js_1 = require("../types/error.js");
|
|
5
|
+
/**
|
|
6
|
+
* Rejects empty batches and repeated collateral indexes.
|
|
7
|
+
* @internal
|
|
8
|
+
* @param transfers - Ordered collateral transfers.
|
|
9
|
+
* @param emptyError - Operation-specific error thrown for an empty batch.
|
|
10
|
+
* @returns Nothing.
|
|
11
|
+
* @throws `emptyError` when `transfers` is empty.
|
|
12
|
+
* @throws {DuplicateMidnightCollateralIndexError} when an index appears twice.
|
|
13
|
+
* @example
|
|
14
|
+
* ```ts
|
|
15
|
+
* validateMidnightCollateralBatch(supplies, new EmptyMidnightCollateralSuppliesError());
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
function validateMidnightCollateralBatch(transfers, emptyError) {
|
|
19
|
+
if (transfers.length === 0)
|
|
20
|
+
throw emptyError;
|
|
21
|
+
const indexes = new Set();
|
|
22
|
+
for (const { collateralIndex } of transfers) {
|
|
23
|
+
if (indexes.has(collateralIndex)) {
|
|
24
|
+
throw new error_js_1.DuplicateMidnightCollateralIndexError(collateralIndex);
|
|
25
|
+
}
|
|
26
|
+
indexes.add(collateralIndex);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type MarketInput } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import type { MidnightCollateralTransfer } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Validates collateral supply entries and their per-index totals.
|
|
5
|
+
*
|
|
6
|
+
* @param params - Market, error-field prefix, and collateral supplies.
|
|
7
|
+
* @returns Nothing when every entry and total is valid; accepts an empty list.
|
|
8
|
+
* @throws {NonPositiveInputError} when an entry is not positive.
|
|
9
|
+
* @throws {InputExceedsMaxError} when an entry or per-index sum exceeds uint128.
|
|
10
|
+
* @throws {UnknownCollateralIndexError} when an index is not configured on the market.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
export declare const validateMidnightCollateralSupplies: (params: {
|
|
14
|
+
readonly market: MarketInput;
|
|
15
|
+
readonly field: string;
|
|
16
|
+
readonly supplies: readonly MidnightCollateralTransfer[];
|
|
17
|
+
}) => void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateMidnightCollateralSupplies = void 0;
|
|
4
|
+
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
+
const validateMidnightBounds_js_1 = require("./validateMidnightBounds.js");
|
|
6
|
+
const validatePositiveInput_js_1 = require("./validatePositiveInput.js");
|
|
7
|
+
/**
|
|
8
|
+
* Validates collateral supply entries and their per-index totals.
|
|
9
|
+
*
|
|
10
|
+
* @param params - Market, error-field prefix, and collateral supplies.
|
|
11
|
+
* @returns Nothing when every entry and total is valid; accepts an empty list.
|
|
12
|
+
* @throws {NonPositiveInputError} when an entry is not positive.
|
|
13
|
+
* @throws {InputExceedsMaxError} when an entry or per-index sum exceeds uint128.
|
|
14
|
+
* @throws {UnknownCollateralIndexError} when an index is not configured on the market.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
const validateMidnightCollateralSupplies = (params) => {
|
|
18
|
+
for (const [index, { collateralIndex, assets },] of params.supplies.entries()) {
|
|
19
|
+
const field = `${params.field}[${index}].assets`;
|
|
20
|
+
// Validation only; rejects non-positive supply amounts.
|
|
21
|
+
(0, validatePositiveInput_js_1.validatePositiveInput)(field, assets);
|
|
22
|
+
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)(field, assets);
|
|
23
|
+
// Validation only; rejects indices not configured on the market.
|
|
24
|
+
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
25
|
+
}
|
|
26
|
+
(0, validateMidnightBounds_js_1.validateMidnightCollateralSupplySums)(params.field, params.supplies);
|
|
27
|
+
};
|
|
28
|
+
exports.validateMidnightCollateralSupplies = validateMidnightCollateralSupplies;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Requires a strictly positive input amount.
|
|
3
|
+
*
|
|
4
|
+
* @param field - Input field name used in the error.
|
|
5
|
+
* @param value - Candidate amount.
|
|
6
|
+
* @returns Nothing when the amount is positive.
|
|
7
|
+
* @throws {NonPositiveInputError} when the amount is zero or negative.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export declare const validatePositiveInput: (field: string, value: bigint) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePositiveInput = void 0;
|
|
4
|
+
const error_js_1 = require("../types/error.js");
|
|
5
|
+
/**
|
|
6
|
+
* Requires a strictly positive input amount.
|
|
7
|
+
*
|
|
8
|
+
* @param field - Input field name used in the error.
|
|
9
|
+
* @param value - Candidate amount.
|
|
10
|
+
* @returns Nothing when the amount is positive.
|
|
11
|
+
* @throws {NonPositiveInputError} when the amount is zero or negative.
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
14
|
+
const validatePositiveInput = (field, value) => {
|
|
15
|
+
if (value <= 0n)
|
|
16
|
+
throw new error_js_1.NonPositiveInputError(field, value);
|
|
17
|
+
};
|
|
18
|
+
exports.validatePositiveInput = validatePositiveInput;
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { validateClientChainId } from "./actions/requirements/validateClientChai
|
|
|
3
3
|
export * from "./client/index.js";
|
|
4
4
|
export * from "./entities/requirements/index.js";
|
|
5
5
|
export * from "./helpers/index.js";
|
|
6
|
+
export type { Action, Funding, IntentParams, ReferralFee, SignatureRequest, Step, TransactionPlan, VaultV2DepositPlanParams, VaultV2WithdrawPlanParams, } from "./transactionPlan/index.js";
|
|
7
|
+
export { applySignatures, buildTransaction, buildTransactions, getPendingSignatureRequests, IncompleteTransactionPlanError, InvalidCalldataOriginError, InvalidTransactionPlanError, NonIntegerInputError, parseTransactionPlan, prepareVaultV2Deposit, prepareVaultV2Withdraw, serializeTransactionPlan, TransactionPlanSignatureMismatchError, UnsupportedTransactionPlanActionError, UnsupportedTransactionPlanVersionError, ZeroAccountError, } from "./transactionPlan/index.js";
|
|
6
8
|
export * from "./types/index.js";
|
package/lib/cjs/index.js
CHANGED
|
@@ -14,11 +14,28 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.validateClientChainId = void 0;
|
|
17
|
+
exports.ZeroAccountError = exports.UnsupportedTransactionPlanVersionError = exports.UnsupportedTransactionPlanActionError = exports.TransactionPlanSignatureMismatchError = exports.serializeTransactionPlan = exports.prepareVaultV2Withdraw = exports.prepareVaultV2Deposit = exports.parseTransactionPlan = exports.NonIntegerInputError = exports.InvalidTransactionPlanError = exports.InvalidCalldataOriginError = exports.IncompleteTransactionPlanError = exports.getPendingSignatureRequests = exports.buildTransactions = exports.buildTransaction = exports.applySignatures = exports.validateClientChainId = void 0;
|
|
18
18
|
__exportStar(require("./actions/index.js"), exports);
|
|
19
19
|
var validateClientChainId_js_1 = require("./actions/requirements/validateClientChainId.js");
|
|
20
20
|
Object.defineProperty(exports, "validateClientChainId", { enumerable: true, get: function () { return validateClientChainId_js_1.validateClientChainId; } });
|
|
21
21
|
__exportStar(require("./client/index.js"), exports);
|
|
22
22
|
__exportStar(require("./entities/requirements/index.js"), exports);
|
|
23
23
|
__exportStar(require("./helpers/index.js"), exports);
|
|
24
|
+
var index_js_1 = require("./transactionPlan/index.js");
|
|
25
|
+
Object.defineProperty(exports, "applySignatures", { enumerable: true, get: function () { return index_js_1.applySignatures; } });
|
|
26
|
+
Object.defineProperty(exports, "buildTransaction", { enumerable: true, get: function () { return index_js_1.buildTransaction; } });
|
|
27
|
+
Object.defineProperty(exports, "buildTransactions", { enumerable: true, get: function () { return index_js_1.buildTransactions; } });
|
|
28
|
+
Object.defineProperty(exports, "getPendingSignatureRequests", { enumerable: true, get: function () { return index_js_1.getPendingSignatureRequests; } });
|
|
29
|
+
Object.defineProperty(exports, "IncompleteTransactionPlanError", { enumerable: true, get: function () { return index_js_1.IncompleteTransactionPlanError; } });
|
|
30
|
+
Object.defineProperty(exports, "InvalidCalldataOriginError", { enumerable: true, get: function () { return index_js_1.InvalidCalldataOriginError; } });
|
|
31
|
+
Object.defineProperty(exports, "InvalidTransactionPlanError", { enumerable: true, get: function () { return index_js_1.InvalidTransactionPlanError; } });
|
|
32
|
+
Object.defineProperty(exports, "NonIntegerInputError", { enumerable: true, get: function () { return index_js_1.NonIntegerInputError; } });
|
|
33
|
+
Object.defineProperty(exports, "parseTransactionPlan", { enumerable: true, get: function () { return index_js_1.parseTransactionPlan; } });
|
|
34
|
+
Object.defineProperty(exports, "prepareVaultV2Deposit", { enumerable: true, get: function () { return index_js_1.prepareVaultV2Deposit; } });
|
|
35
|
+
Object.defineProperty(exports, "prepareVaultV2Withdraw", { enumerable: true, get: function () { return index_js_1.prepareVaultV2Withdraw; } });
|
|
36
|
+
Object.defineProperty(exports, "serializeTransactionPlan", { enumerable: true, get: function () { return index_js_1.serializeTransactionPlan; } });
|
|
37
|
+
Object.defineProperty(exports, "TransactionPlanSignatureMismatchError", { enumerable: true, get: function () { return index_js_1.TransactionPlanSignatureMismatchError; } });
|
|
38
|
+
Object.defineProperty(exports, "UnsupportedTransactionPlanActionError", { enumerable: true, get: function () { return index_js_1.UnsupportedTransactionPlanActionError; } });
|
|
39
|
+
Object.defineProperty(exports, "UnsupportedTransactionPlanVersionError", { enumerable: true, get: function () { return index_js_1.UnsupportedTransactionPlanVersionError; } });
|
|
40
|
+
Object.defineProperty(exports, "ZeroAccountError", { enumerable: true, get: function () { return index_js_1.ZeroAccountError; } });
|
|
24
41
|
__exportStar(require("./types/index.js"), exports);
|
|
@@ -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, 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,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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;
|
|
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
|
+
Object.defineProperty(exports, "InvalidEcrecoverSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureError; } });
|
|
6
7
|
Object.defineProperty(exports, "InvalidEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
|
|
7
8
|
Object.defineProperty(exports, "InvalidMarketParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMarketParameterError; } });
|
|
8
9
|
Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiQuoteTargetError; } });
|
|
9
10
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
10
11
|
Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
11
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; } });
|
|
12
16
|
Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
13
17
|
Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
14
18
|
Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -26,7 +30,3 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
|
|
|
26
30
|
Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
|
|
27
31
|
Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
|
|
28
32
|
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; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateApprovalPlanAction = validateApprovalPlanAction;
|
|
4
|
+
const validation_js_1 = require("./validation.js");
|
|
5
|
+
/** @internal Validates the stored ERC-20 approval action's input shape. */
|
|
6
|
+
function validateApprovalPlanAction(action, path) {
|
|
7
|
+
const inputs = (0, validation_js_1.getPlanObject)(action.inputs, `${path}.inputs`);
|
|
8
|
+
(0, validation_js_1.validatePlanFields)(inputs, {
|
|
9
|
+
path: `${path}.inputs`,
|
|
10
|
+
fields: {
|
|
11
|
+
token: "address",
|
|
12
|
+
spender: "address",
|
|
13
|
+
amount: "uint256 bigint",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
}
|