@morpho-org/morpho-sdk 7.1.0-next.1 → 8.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v7-to-v8.md +290 -0
- package/README.md +11 -6
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +17 -71
- package/lib/cjs/actions/midnight/cancelAndMake.js +41 -29
- package/lib/cjs/actions/midnight/redeem.d.ts +8 -1
- package/lib/cjs/actions/midnight/redeem.js +18 -1
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +24 -2
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/supplyCollateral.js +3 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +49 -14
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +18 -5
- package/lib/cjs/actions/midnight/takeBorrow.js +44 -12
- package/lib/cjs/actions/midnight/takeLend.d.ts +10 -5
- package/lib/cjs/actions/midnight/takeLend.js +27 -9
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +51 -27
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +14 -5
- package/lib/cjs/actions/midnight/takeWithdraw.js +40 -9
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +17 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
- package/lib/cjs/actions/requirements/validateClientChainId.d.ts +26 -0
- package/lib/cjs/actions/requirements/validateClientChainId.js +34 -0
- 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 +3 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/types.d.ts +1 -1
- package/lib/cjs/blue/utils.d.ts +2 -2
- package/lib/cjs/blue/utils.js +5 -2
- package/lib/cjs/entities/blue/blue.d.ts +109 -27
- package/lib/cjs/entities/blue/blue.js +103 -28
- package/lib/cjs/entities/index.d.ts +5 -5
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/deadline.d.ts +15 -0
- package/lib/cjs/entities/midnight/deadline.js +24 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +427 -72
- package/lib/cjs/entities/midnight/midnight.js +864 -186
- package/lib/cjs/entities/midnight/publication.d.ts +134 -0
- package/lib/cjs/entities/midnight/publication.js +404 -0
- package/lib/cjs/entities/midnight/types.d.ts +26 -5
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +49 -0
- package/lib/cjs/entities/requirements/assertContractCode.js +79 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +45 -18
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +5 -2
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +63 -11
- package/lib/cjs/entities/vaultV1/vaultV1.js +52 -15
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +62 -44
- package/lib/cjs/entities/vaultV2/vaultV2.js +53 -48
- 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 +7 -10
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +5 -0
- package/lib/cjs/helpers/constant.js +6 -1
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/validate.d.ts +163 -8
- package/lib/cjs/helpers/validate.js +179 -8
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +47 -0
- package/lib/cjs/helpers/validateMidnightBounds.js +79 -0
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +12 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +144 -0
- package/lib/cjs/helpers/validateMidnightReceiver.d.ts +29 -0
- package/lib/cjs/helpers/validateMidnightReceiver.js +84 -0
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +231 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/types/error.d.ts +197 -4
- package/lib/cjs/types/error.js +265 -5
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +1 -0
- package/lib/cjs/types/midnightCancelAndMake.d.ts +70 -0
- package/lib/cjs/types/midnightCancelAndMake.js +2 -0
- package/lib/cjs/types/midnightPublicationError.d.ts +332 -0
- package/lib/cjs/types/midnightPublicationError.js +376 -0
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/utils.d.ts +4 -3
- package/lib/cjs/utils.js +8 -4
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +17 -71
- package/lib/esm/actions/midnight/cancelAndMake.js +42 -30
- package/lib/esm/actions/midnight/redeem.d.ts +8 -1
- package/lib/esm/actions/midnight/redeem.js +18 -1
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +24 -2
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/supplyCollateral.js +3 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +52 -17
- package/lib/esm/actions/midnight/takeBorrow.d.ts +18 -5
- package/lib/esm/actions/midnight/takeBorrow.js +47 -15
- package/lib/esm/actions/midnight/takeLend.d.ts +10 -5
- package/lib/esm/actions/midnight/takeLend.js +27 -9
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +52 -28
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +14 -5
- package/lib/esm/actions/midnight/takeWithdraw.js +41 -10
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +13 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +17 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
- package/lib/esm/actions/requirements/validateClientChainId.d.ts +26 -0
- package/lib/esm/actions/requirements/validateClientChainId.js +30 -0
- 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/types.d.ts +1 -1
- package/lib/esm/blue/utils.d.ts +2 -2
- package/lib/esm/blue/utils.js +2 -2
- package/lib/esm/entities/blue/blue.d.ts +109 -27
- package/lib/esm/entities/blue/blue.js +104 -29
- package/lib/esm/entities/index.d.ts +5 -5
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/deadline.d.ts +15 -0
- package/lib/esm/entities/midnight/deadline.js +20 -0
- package/lib/esm/entities/midnight/midnight.d.ts +427 -72
- package/lib/esm/entities/midnight/midnight.js +865 -187
- package/lib/esm/entities/midnight/publication.d.ts +134 -0
- package/lib/esm/entities/midnight/publication.js +397 -0
- package/lib/esm/entities/midnight/types.d.ts +26 -5
- package/lib/esm/entities/requirements/assertContractCode.d.ts +49 -0
- package/lib/esm/entities/requirements/assertContractCode.js +74 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +47 -20
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +5 -2
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +63 -11
- package/lib/esm/entities/vaultV1/vaultV1.js +53 -16
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +62 -44
- package/lib/esm/entities/vaultV2/vaultV2.js +54 -49
- 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/constant.d.ts +5 -0
- package/lib/esm/helpers/constant.js +5 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/validate.d.ts +163 -8
- package/lib/esm/helpers/validate.js +177 -7
- package/lib/esm/helpers/validateMidnightBounds.d.ts +47 -0
- package/lib/esm/helpers/validateMidnightBounds.js +72 -0
- package/lib/esm/helpers/validateMidnightPublication.d.ts +12 -0
- package/lib/esm/helpers/validateMidnightPublication.js +139 -0
- package/lib/esm/helpers/validateMidnightReceiver.d.ts +29 -0
- package/lib/esm/helpers/validateMidnightReceiver.js +80 -0
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +226 -0
- package/lib/esm/index.d.ts +1 -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/types/error.d.ts +197 -4
- package/lib/esm/types/error.js +253 -2
- package/lib/esm/types/index.d.ts +1 -0
- package/lib/esm/types/index.js +1 -0
- package/lib/esm/types/midnightCancelAndMake.d.ts +70 -0
- package/lib/esm/types/midnightCancelAndMake.js +1 -0
- package/lib/esm/types/midnightPublicationError.d.ts +332 -0
- package/lib/esm/types/midnightPublicationError.js +359 -0
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/utils.d.ts +4 -3
- package/lib/esm/utils.js +4 -3
- package/package.json +9 -8
package/lib/esm/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, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, NonTupleReturnValueError, 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, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, 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, } from "@morpho-org/morpho-ts";
|
package/lib/esm/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, NonTupleReturnValueError, 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";
|
|
6
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError,
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, 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
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/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/esm/fetch.js
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";
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
2
|
/** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
|
|
3
3
|
export declare const MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
|
|
4
|
+
/**
|
|
5
|
+
* Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare const MIDNIGHT_MAX_REFERRAL_FEE_PCT: bigint;
|
|
4
9
|
/** Maximum slippage tolerance: 10% */
|
|
5
10
|
export declare const MAX_SLIPPAGE_TOLERANCE: bigint;
|
|
6
11
|
/** Default maximum Vault V2 reallocation penalty: zero. */
|
|
@@ -3,6 +3,11 @@ import { Time } from "@morpho-org/morpho-ts";
|
|
|
3
3
|
import { maxUint96 } from "viem";
|
|
4
4
|
/** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
|
|
5
5
|
export const MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
|
|
6
|
+
/**
|
|
7
|
+
* Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const MIDNIGHT_MAX_REFERRAL_FEE_PCT = MathLib.WAD / 10n;
|
|
6
11
|
/** Maximum slippage tolerance: 10% */
|
|
7
12
|
export const MAX_SLIPPAGE_TOLERANCE = MathLib.WAD / 10n;
|
|
8
13
|
/** Default maximum Vault V2 reallocation penalty: zero. */
|
|
@@ -6,7 +6,7 @@ export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type
|
|
|
6
6
|
export { grossFromNetAssets } from "./referralFee.js";
|
|
7
7
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
|
8
8
|
export { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
|
|
9
|
-
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateMidnightNativeAmount, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
9
|
+
export { getMidnightMaxSafeDebt, validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateMidnightNativeAmount, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
10
10
|
export { validateOfferSides } from "./validateOfferSides.js";
|
|
11
11
|
export { type RequirementSpenderKey, validateRequirementSpender, } from "./validateRequirementSpender.js";
|
|
12
12
|
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawEligibility, type VaultV2ForceWithdrawPlan, } from "./vaultV2ForceWithdrawPlan.js";
|
package/lib/esm/helpers/index.js
CHANGED
|
@@ -6,7 +6,7 @@ export { previewVaultV2InKindRedeem, } from "./previewVaultV2InKindRedeem.js";
|
|
|
6
6
|
export { grossFromNetAssets } from "./referralFee.js";
|
|
7
7
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
|
8
8
|
export { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, } from "./slippage.js";
|
|
9
|
-
export { validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateMidnightNativeAmount, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
9
|
+
export { getMidnightMaxSafeDebt, validateAccrualPosition, validateChainId, validateMidnightMarketChainId, validateMidnightNativeAmount, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, validateWithdrawAmount, validateWithdrawShares, } from "./validate.js";
|
|
10
10
|
export { validateOfferSides } from "./validateOfferSides.js";
|
|
11
11
|
export { validateRequirementSpender, } from "./validateRequirementSpender.js";
|
|
12
12
|
export { computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, resolveVaultV2ForceWithdrawEligibility, } from "./vaultV2ForceWithdrawPlan.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type Market as MidnightMarket, type MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import { type VaultV2BlueReallocation } from "../types/index.js";
|
|
5
5
|
/**
|
|
@@ -110,21 +110,85 @@ export declare const validateMidnightMarketChainId: (market: MidnightMarketInput
|
|
|
110
110
|
export declare function validateUserAddress(clientAccountAddress: Address | undefined, userAddress: Address): asserts clientAccountAddress is Address;
|
|
111
111
|
/**
|
|
112
112
|
* Validates that the accrual position belongs to the expected market and user.
|
|
113
|
-
* Throws {@link MarketIdMismatchError} if the position's market ID
|
|
114
|
-
* does not match the expected market.
|
|
115
|
-
* Throws {@link AccrualPositionUserMismatchError} if the position's user
|
|
116
|
-
* does not match the expected user.
|
|
117
113
|
*
|
|
118
114
|
* @param params - Validation parameters.
|
|
119
115
|
* @param params.positionData - The accrual position to validate.
|
|
120
116
|
* @param params.expectedMarketId - The market ID the position must belong to.
|
|
121
117
|
* @param params.expectedUser - The user address the position must belong to.
|
|
118
|
+
* @returns Nothing when `positionData` belongs to the expected market and user.
|
|
119
|
+
* @throws {MarketIdMismatchError} when the position's market ID differs from `expectedMarketId`.
|
|
120
|
+
* @throws {AccrualPositionUserMismatchError} when the position's user address differs from
|
|
121
|
+
* `expectedUser`.
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
125
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
126
|
+
* import { validateAccrualPosition } from "@morpho-org/morpho-sdk";
|
|
127
|
+
* import type { Address } from "viem";
|
|
128
|
+
*
|
|
129
|
+
* export function assertPositionOwner(
|
|
130
|
+
* positionData: AccrualPosition,
|
|
131
|
+
* expectedMarketId: MarketId,
|
|
132
|
+
* expectedUser: Address,
|
|
133
|
+
* ): void {
|
|
134
|
+
* validateAccrualPosition({
|
|
135
|
+
* positionData,
|
|
136
|
+
* expectedMarketId,
|
|
137
|
+
* expectedUser,
|
|
138
|
+
* });
|
|
139
|
+
* }
|
|
140
|
+
* ```
|
|
122
141
|
*/
|
|
123
142
|
export declare const validateAccrualPosition: (params: {
|
|
124
143
|
positionData: AccrualPosition;
|
|
125
144
|
expectedMarketId: MarketId;
|
|
126
145
|
expectedUser: Address;
|
|
127
146
|
}) => void;
|
|
147
|
+
/**
|
|
148
|
+
* Computes the total debt supported by post-operation Midnight collateral at LLTV minus
|
|
149
|
+
* `DEFAULT_LLTV_BUFFER`.
|
|
150
|
+
* Mirrors Midnight's `isHealthy` formula in `Midnight.sol`, summing
|
|
151
|
+
* `collateral.mulDivDown(price, ORACLE_PRICE_SCALE).mulDivDown(lltv, WAD)` across indexes with the
|
|
152
|
+
* default buffer subtracted from each LLTV.
|
|
153
|
+
*
|
|
154
|
+
* @param params - Market, collateral amounts, and oracle prices.
|
|
155
|
+
* @param params.market - Hydrated Midnight market containing each collateral's LLTV.
|
|
156
|
+
* @param params.collateral - Post-operation collateral balances by market index.
|
|
157
|
+
* @param params.collateralPrices - Oracle prices by index, scaled by `ORACLE_PRICE_SCALE`.
|
|
158
|
+
* @returns Maximum safe debt in Midnight units.
|
|
159
|
+
* @throws {UnknownCollateralIndexError} when a held collateral index is not configured.
|
|
160
|
+
* @throws {MissingMarketPriceError} when a held collateral index has no supplied price.
|
|
161
|
+
* @example
|
|
162
|
+
* ```ts
|
|
163
|
+
* import { ORACLE_PRICE_SCALE } from "@morpho-org/blue-sdk";
|
|
164
|
+
* import {
|
|
165
|
+
* getMidnightMaxSafeDebt,
|
|
166
|
+
* morphoViemExtension,
|
|
167
|
+
* } from "@morpho-org/morpho-sdk";
|
|
168
|
+
* import { createPublicClient, http, type Hex } from "viem";
|
|
169
|
+
* import { base } from "viem/chains";
|
|
170
|
+
*
|
|
171
|
+
* const client = createPublicClient({ chain: base, transport: http() })
|
|
172
|
+
* .extend(morphoViemExtension());
|
|
173
|
+
* const midnight = client.morpho.midnight(base.id);
|
|
174
|
+
*
|
|
175
|
+
* const getMarketMaxSafeDebt = async (marketId: Hex) => {
|
|
176
|
+
* const market = await midnight.getMarketData(marketId);
|
|
177
|
+
* const maxSafeDebt = getMidnightMaxSafeDebt({
|
|
178
|
+
* market,
|
|
179
|
+
* collateral: [1_000_000n],
|
|
180
|
+
* collateralPrices: [ORACLE_PRICE_SCALE],
|
|
181
|
+
* });
|
|
182
|
+
* // maxSafeDebt: debt units supported at LLTV minus DEFAULT_LLTV_BUFFER
|
|
183
|
+
* return maxSafeDebt;
|
|
184
|
+
* };
|
|
185
|
+
* ```
|
|
186
|
+
*/
|
|
187
|
+
export declare const getMidnightMaxSafeDebt: (params: {
|
|
188
|
+
readonly market: MidnightMarket;
|
|
189
|
+
readonly collateral: readonly bigint[];
|
|
190
|
+
readonly collateralPrices: readonly bigint[];
|
|
191
|
+
}) => bigint;
|
|
128
192
|
/**
|
|
129
193
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
130
194
|
* (LLTV minus buffer) after supplying additional collateral and borrowing.
|
|
@@ -135,6 +199,33 @@ export declare const validateAccrualPosition: (params: {
|
|
|
135
199
|
* @param params.borrowAmount - Amount being borrowed.
|
|
136
200
|
* @param params.marketId - The market identifier (for error messages).
|
|
137
201
|
* @param params.lltv - The market's liquidation LTV.
|
|
202
|
+
* @returns Nothing when the debt after borrowing, including the rounding allowance, is within the
|
|
203
|
+
* safe limit after adding collateral.
|
|
204
|
+
* @throws {MissingMarketPriceError} when `positionData.market.price` is unset or zero.
|
|
205
|
+
* @throws {BorrowExceedsSafeLtvError} when `positionData.borrowAssets + borrowAmount + 1n` exceeds
|
|
206
|
+
* the safe limit after adding collateral at LLTV minus `DEFAULT_LLTV_BUFFER`.
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
210
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
211
|
+
* import { validatePositionHealth } from "@morpho-org/morpho-sdk";
|
|
212
|
+
*
|
|
213
|
+
* export function assertSafeBorrow(
|
|
214
|
+
* positionData: AccrualPosition,
|
|
215
|
+
* additionalCollateral: bigint,
|
|
216
|
+
* borrowAmount: bigint,
|
|
217
|
+
* marketId: MarketId,
|
|
218
|
+
* lltv: bigint,
|
|
219
|
+
* ): void {
|
|
220
|
+
* validatePositionHealth({
|
|
221
|
+
* positionData,
|
|
222
|
+
* additionalCollateral,
|
|
223
|
+
* borrowAmount,
|
|
224
|
+
* marketId,
|
|
225
|
+
* lltv,
|
|
226
|
+
* });
|
|
227
|
+
* }
|
|
228
|
+
* ```
|
|
138
229
|
*/
|
|
139
230
|
export declare const validatePositionHealth: (params: {
|
|
140
231
|
positionData: AccrualPosition;
|
|
@@ -145,10 +236,18 @@ export declare const validatePositionHealth: (params: {
|
|
|
145
236
|
}) => void;
|
|
146
237
|
/**
|
|
147
238
|
* Validates that the viem client chain ID matches the expected chain ID.
|
|
148
|
-
* Throws {@link ChainIdMismatchError} if they differ.
|
|
149
239
|
*
|
|
150
240
|
* @param clientChainId - Chain ID reported by the viem client (may be undefined).
|
|
151
241
|
* @param expectedChainId - Chain ID expected by the entity or action.
|
|
242
|
+
* @returns Nothing when `clientChainId` matches `expectedChainId`.
|
|
243
|
+
* @throws {ChainIdMismatchError} when `clientChainId` is undefined or differs from
|
|
244
|
+
* `expectedChainId`.
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* import { validateChainId } from "@morpho-org/morpho-sdk";
|
|
248
|
+
*
|
|
249
|
+
* validateChainId(8453, 8453);
|
|
250
|
+
* ```
|
|
152
251
|
*/
|
|
153
252
|
export declare const validateChainId: (clientChainId: number | undefined, expectedChainId: number) => void;
|
|
154
253
|
/**
|
|
@@ -158,8 +257,18 @@ export declare const validateChainId: (clientChainId: number | undefined, expect
|
|
|
158
257
|
*
|
|
159
258
|
* @param chainId - The chain to look up wNative on.
|
|
160
259
|
* @param asset - The asset address to check (collateral, loan, vault asset…).
|
|
161
|
-
* @
|
|
162
|
-
* @throws {
|
|
260
|
+
* @returns Nothing when `asset` is the chain's configured wrapped native token.
|
|
261
|
+
* @throws {UnsupportedChainIdError} when `chainId` has no address registry.
|
|
262
|
+
* @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
|
|
263
|
+
* @throws {NativeAmountOnNonWNativeAssetError} when the asset is not wNative.
|
|
264
|
+
* @example
|
|
265
|
+
* ```ts
|
|
266
|
+
* import { getChainAddress } from "@morpho-org/morpho-sdk/addresses";
|
|
267
|
+
* import { validateNativeAsset } from "@morpho-org/morpho-sdk";
|
|
268
|
+
*
|
|
269
|
+
* const wNative = getChainAddress(8453, "wNative");
|
|
270
|
+
* validateNativeAsset(8453, wNative);
|
|
271
|
+
* ```
|
|
163
272
|
*/
|
|
164
273
|
export declare const validateNativeAsset: (chainId: number, asset: Address) => void;
|
|
165
274
|
/**
|
|
@@ -254,6 +363,22 @@ export declare const validatePositionHealthAfterWithdraw: (params: {
|
|
|
254
363
|
* @param params.positionData - The current accrual position.
|
|
255
364
|
* @param params.repayAssets - The amount of assets to repay.
|
|
256
365
|
* @param params.marketId - The market identifier (for error messages).
|
|
366
|
+
* @returns Nothing when `repayAssets` does not exceed the outstanding debt.
|
|
367
|
+
* @throws {RepayExceedsDebtError} when `repayAssets` exceeds the position's borrow assets.
|
|
368
|
+
* @example
|
|
369
|
+
* ```ts
|
|
370
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
371
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
372
|
+
* import { validateRepayAmount } from "@morpho-org/morpho-sdk";
|
|
373
|
+
*
|
|
374
|
+
* export function assertRepayWithinDebt(
|
|
375
|
+
* positionData: AccrualPosition,
|
|
376
|
+
* repayAssets: bigint,
|
|
377
|
+
* marketId: MarketId,
|
|
378
|
+
* ): void {
|
|
379
|
+
* validateRepayAmount({ positionData, repayAssets, marketId });
|
|
380
|
+
* }
|
|
381
|
+
* ```
|
|
257
382
|
*/
|
|
258
383
|
export declare const validateRepayAmount: (params: {
|
|
259
384
|
positionData: AccrualPosition;
|
|
@@ -315,7 +440,22 @@ export declare const validateSlippageTolerance: (slippageTolerance: bigint) => v
|
|
|
315
440
|
* @param params.positionData - The current accrual position.
|
|
316
441
|
* @param params.withdrawAssets - The amount of assets to withdraw.
|
|
317
442
|
* @param params.marketId - The market identifier (for error messages).
|
|
443
|
+
* @returns Nothing when `withdrawAssets` does not exceed the position's supplied assets.
|
|
318
444
|
* @throws {WithdrawExceedsSupplyError} when `withdrawAssets > positionData.supplyAssets`.
|
|
445
|
+
* @example
|
|
446
|
+
* ```ts
|
|
447
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
448
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
449
|
+
* import { validateWithdrawAmount } from "@morpho-org/morpho-sdk";
|
|
450
|
+
*
|
|
451
|
+
* export function assertWithdrawWithinSupply(
|
|
452
|
+
* positionData: AccrualPosition,
|
|
453
|
+
* withdrawAssets: bigint,
|
|
454
|
+
* marketId: MarketId,
|
|
455
|
+
* ): void {
|
|
456
|
+
* validateWithdrawAmount({ positionData, withdrawAssets, marketId });
|
|
457
|
+
* }
|
|
458
|
+
* ```
|
|
319
459
|
*/
|
|
320
460
|
export declare const validateWithdrawAmount: (params: {
|
|
321
461
|
positionData: AccrualPosition;
|
|
@@ -329,7 +469,22 @@ export declare const validateWithdrawAmount: (params: {
|
|
|
329
469
|
* @param params.positionData - The current accrual position.
|
|
330
470
|
* @param params.withdrawShares - The amount of shares to withdraw.
|
|
331
471
|
* @param params.marketId - The market identifier (for error messages).
|
|
472
|
+
* @returns Nothing when `withdrawShares` does not exceed the position's supply shares.
|
|
332
473
|
* @throws {WithdrawSharesExceedSupplyError} when `withdrawShares > positionData.supplyShares`.
|
|
474
|
+
* @example
|
|
475
|
+
* ```ts
|
|
476
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
477
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
478
|
+
* import { validateWithdrawShares } from "@morpho-org/morpho-sdk";
|
|
479
|
+
*
|
|
480
|
+
* export function assertWithdrawSharesWithinSupply(
|
|
481
|
+
* positionData: AccrualPosition,
|
|
482
|
+
* withdrawShares: bigint,
|
|
483
|
+
* marketId: MarketId,
|
|
484
|
+
* ): void {
|
|
485
|
+
* validateWithdrawShares({ positionData, withdrawShares, marketId });
|
|
486
|
+
* }
|
|
487
|
+
* ```
|
|
333
488
|
*/
|
|
334
489
|
export declare const validateWithdrawShares: (params: {
|
|
335
490
|
positionData: AccrualPosition;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getChainAddresses, MarketUtils, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
|
|
2
|
+
import { MarketUtils as MidnightMarketUtils, } from "@morpho-org/midnight-sdk";
|
|
2
3
|
import { isDefined } from "@morpho-org/morpho-ts";
|
|
3
4
|
import { isAddress, isAddressEqual, maxUint128, maxUint256, zeroAddress, } from "viem";
|
|
4
5
|
import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationSourceTypeError, InvalidVaultV2BlueReallocationShapeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NativeAmountOnNonWNativeVaultError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, ReferralFeePctExceededError, ReferralFeeRecipientMissingError, RepayExceedsDebtError, RepaySharesExceedDebtError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
|
|
@@ -152,15 +153,34 @@ export function validateUserAddress(clientAccountAddress, userAddress) {
|
|
|
152
153
|
}
|
|
153
154
|
/**
|
|
154
155
|
* Validates that the accrual position belongs to the expected market and user.
|
|
155
|
-
* Throws {@link MarketIdMismatchError} if the position's market ID
|
|
156
|
-
* does not match the expected market.
|
|
157
|
-
* Throws {@link AccrualPositionUserMismatchError} if the position's user
|
|
158
|
-
* does not match the expected user.
|
|
159
156
|
*
|
|
160
157
|
* @param params - Validation parameters.
|
|
161
158
|
* @param params.positionData - The accrual position to validate.
|
|
162
159
|
* @param params.expectedMarketId - The market ID the position must belong to.
|
|
163
160
|
* @param params.expectedUser - The user address the position must belong to.
|
|
161
|
+
* @returns Nothing when `positionData` belongs to the expected market and user.
|
|
162
|
+
* @throws {MarketIdMismatchError} when the position's market ID differs from `expectedMarketId`.
|
|
163
|
+
* @throws {AccrualPositionUserMismatchError} when the position's user address differs from
|
|
164
|
+
* `expectedUser`.
|
|
165
|
+
* @example
|
|
166
|
+
* ```ts
|
|
167
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
168
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
169
|
+
* import { validateAccrualPosition } from "@morpho-org/morpho-sdk";
|
|
170
|
+
* import type { Address } from "viem";
|
|
171
|
+
*
|
|
172
|
+
* export function assertPositionOwner(
|
|
173
|
+
* positionData: AccrualPosition,
|
|
174
|
+
* expectedMarketId: MarketId,
|
|
175
|
+
* expectedUser: Address,
|
|
176
|
+
* ): void {
|
|
177
|
+
* validateAccrualPosition({
|
|
178
|
+
* positionData,
|
|
179
|
+
* expectedMarketId,
|
|
180
|
+
* expectedUser,
|
|
181
|
+
* });
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
164
184
|
*/
|
|
165
185
|
export const validateAccrualPosition = (params) => {
|
|
166
186
|
const { positionData, expectedMarketId, expectedUser } = params;
|
|
@@ -171,6 +191,65 @@ export const validateAccrualPosition = (params) => {
|
|
|
171
191
|
throw new AccrualPositionUserMismatchError(positionData.user, expectedUser);
|
|
172
192
|
}
|
|
173
193
|
};
|
|
194
|
+
/**
|
|
195
|
+
* Computes the total debt supported by post-operation Midnight collateral at LLTV minus
|
|
196
|
+
* `DEFAULT_LLTV_BUFFER`.
|
|
197
|
+
* Mirrors Midnight's `isHealthy` formula in `Midnight.sol`, summing
|
|
198
|
+
* `collateral.mulDivDown(price, ORACLE_PRICE_SCALE).mulDivDown(lltv, WAD)` across indexes with the
|
|
199
|
+
* default buffer subtracted from each LLTV.
|
|
200
|
+
*
|
|
201
|
+
* @param params - Market, collateral amounts, and oracle prices.
|
|
202
|
+
* @param params.market - Hydrated Midnight market containing each collateral's LLTV.
|
|
203
|
+
* @param params.collateral - Post-operation collateral balances by market index.
|
|
204
|
+
* @param params.collateralPrices - Oracle prices by index, scaled by `ORACLE_PRICE_SCALE`.
|
|
205
|
+
* @returns Maximum safe debt in Midnight units.
|
|
206
|
+
* @throws {UnknownCollateralIndexError} when a held collateral index is not configured.
|
|
207
|
+
* @throws {MissingMarketPriceError} when a held collateral index has no supplied price.
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* import { ORACLE_PRICE_SCALE } from "@morpho-org/blue-sdk";
|
|
211
|
+
* import {
|
|
212
|
+
* getMidnightMaxSafeDebt,
|
|
213
|
+
* morphoViemExtension,
|
|
214
|
+
* } from "@morpho-org/morpho-sdk";
|
|
215
|
+
* import { createPublicClient, http, type Hex } from "viem";
|
|
216
|
+
* import { base } from "viem/chains";
|
|
217
|
+
*
|
|
218
|
+
* const client = createPublicClient({ chain: base, transport: http() })
|
|
219
|
+
* .extend(morphoViemExtension());
|
|
220
|
+
* const midnight = client.morpho.midnight(base.id);
|
|
221
|
+
*
|
|
222
|
+
* const getMarketMaxSafeDebt = async (marketId: Hex) => {
|
|
223
|
+
* const market = await midnight.getMarketData(marketId);
|
|
224
|
+
* const maxSafeDebt = getMidnightMaxSafeDebt({
|
|
225
|
+
* market,
|
|
226
|
+
* collateral: [1_000_000n],
|
|
227
|
+
* collateralPrices: [ORACLE_PRICE_SCALE],
|
|
228
|
+
* });
|
|
229
|
+
* // maxSafeDebt: debt units supported at LLTV minus DEFAULT_LLTV_BUFFER
|
|
230
|
+
* return maxSafeDebt;
|
|
231
|
+
* };
|
|
232
|
+
* ```
|
|
233
|
+
*/
|
|
234
|
+
export const getMidnightMaxSafeDebt = (params) => {
|
|
235
|
+
let maxSafeDebt = 0n;
|
|
236
|
+
for (let index = 0; index < params.collateral.length; index += 1) {
|
|
237
|
+
const amount = params.collateral[index] ?? 0n;
|
|
238
|
+
if (amount === 0n)
|
|
239
|
+
continue;
|
|
240
|
+
const collateral = MidnightMarketUtils.getCollateralByIndex(params.market.params, BigInt(index));
|
|
241
|
+
const price = params.collateralPrices[index];
|
|
242
|
+
if (price === undefined) {
|
|
243
|
+
throw new MissingMarketPriceError(params.market.id);
|
|
244
|
+
}
|
|
245
|
+
const collateralValue = MathLib.mulDivDown(amount, price, ORACLE_PRICE_SCALE);
|
|
246
|
+
const effectiveLltv = collateral.lltv > DEFAULT_LLTV_BUFFER
|
|
247
|
+
? collateral.lltv - DEFAULT_LLTV_BUFFER
|
|
248
|
+
: 0n;
|
|
249
|
+
maxSafeDebt += MathLib.mulDivDown(collateralValue, effectiveLltv, MathLib.WAD);
|
|
250
|
+
}
|
|
251
|
+
return maxSafeDebt;
|
|
252
|
+
};
|
|
174
253
|
/**
|
|
175
254
|
* Validates that the resulting position stays within the safe LTV threshold
|
|
176
255
|
* (LLTV minus buffer) after supplying additional collateral and borrowing.
|
|
@@ -181,6 +260,33 @@ export const validateAccrualPosition = (params) => {
|
|
|
181
260
|
* @param params.borrowAmount - Amount being borrowed.
|
|
182
261
|
* @param params.marketId - The market identifier (for error messages).
|
|
183
262
|
* @param params.lltv - The market's liquidation LTV.
|
|
263
|
+
* @returns Nothing when the debt after borrowing, including the rounding allowance, is within the
|
|
264
|
+
* safe limit after adding collateral.
|
|
265
|
+
* @throws {MissingMarketPriceError} when `positionData.market.price` is unset or zero.
|
|
266
|
+
* @throws {BorrowExceedsSafeLtvError} when `positionData.borrowAssets + borrowAmount + 1n` exceeds
|
|
267
|
+
* the safe limit after adding collateral at LLTV minus `DEFAULT_LLTV_BUFFER`.
|
|
268
|
+
* @example
|
|
269
|
+
* ```ts
|
|
270
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
271
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
272
|
+
* import { validatePositionHealth } from "@morpho-org/morpho-sdk";
|
|
273
|
+
*
|
|
274
|
+
* export function assertSafeBorrow(
|
|
275
|
+
* positionData: AccrualPosition,
|
|
276
|
+
* additionalCollateral: bigint,
|
|
277
|
+
* borrowAmount: bigint,
|
|
278
|
+
* marketId: MarketId,
|
|
279
|
+
* lltv: bigint,
|
|
280
|
+
* ): void {
|
|
281
|
+
* validatePositionHealth({
|
|
282
|
+
* positionData,
|
|
283
|
+
* additionalCollateral,
|
|
284
|
+
* borrowAmount,
|
|
285
|
+
* marketId,
|
|
286
|
+
* lltv,
|
|
287
|
+
* });
|
|
288
|
+
* }
|
|
289
|
+
* ```
|
|
184
290
|
*/
|
|
185
291
|
export const validatePositionHealth = (params) => {
|
|
186
292
|
const { positionData, additionalCollateral, borrowAmount, marketId, lltv } = params;
|
|
@@ -200,10 +306,18 @@ export const validatePositionHealth = (params) => {
|
|
|
200
306
|
};
|
|
201
307
|
/**
|
|
202
308
|
* Validates that the viem client chain ID matches the expected chain ID.
|
|
203
|
-
* Throws {@link ChainIdMismatchError} if they differ.
|
|
204
309
|
*
|
|
205
310
|
* @param clientChainId - Chain ID reported by the viem client (may be undefined).
|
|
206
311
|
* @param expectedChainId - Chain ID expected by the entity or action.
|
|
312
|
+
* @returns Nothing when `clientChainId` matches `expectedChainId`.
|
|
313
|
+
* @throws {ChainIdMismatchError} when `clientChainId` is undefined or differs from
|
|
314
|
+
* `expectedChainId`.
|
|
315
|
+
* @example
|
|
316
|
+
* ```ts
|
|
317
|
+
* import { validateChainId } from "@morpho-org/morpho-sdk";
|
|
318
|
+
*
|
|
319
|
+
* validateChainId(8453, 8453);
|
|
320
|
+
* ```
|
|
207
321
|
*/
|
|
208
322
|
export const validateChainId = (clientChainId, expectedChainId) => {
|
|
209
323
|
if (clientChainId !== expectedChainId) {
|
|
@@ -217,8 +331,18 @@ export const validateChainId = (clientChainId, expectedChainId) => {
|
|
|
217
331
|
*
|
|
218
332
|
* @param chainId - The chain to look up wNative on.
|
|
219
333
|
* @param asset - The asset address to check (collateral, loan, vault asset…).
|
|
220
|
-
* @
|
|
221
|
-
* @throws {
|
|
334
|
+
* @returns Nothing when `asset` is the chain's configured wrapped native token.
|
|
335
|
+
* @throws {UnsupportedChainIdError} when `chainId` has no address registry.
|
|
336
|
+
* @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
|
|
337
|
+
* @throws {NativeAmountOnNonWNativeAssetError} when the asset is not wNative.
|
|
338
|
+
* @example
|
|
339
|
+
* ```ts
|
|
340
|
+
* import { getChainAddress } from "@morpho-org/morpho-sdk/addresses";
|
|
341
|
+
* import { validateNativeAsset } from "@morpho-org/morpho-sdk";
|
|
342
|
+
*
|
|
343
|
+
* const wNative = getChainAddress(8453, "wNative");
|
|
344
|
+
* validateNativeAsset(8453, wNative);
|
|
345
|
+
* ```
|
|
222
346
|
*/
|
|
223
347
|
export const validateNativeAsset = (chainId, asset) => {
|
|
224
348
|
const { wNative } = getChainAddresses(chainId);
|
|
@@ -370,6 +494,22 @@ export const validatePositionHealthAfterWithdraw = (params) => {
|
|
|
370
494
|
* @param params.positionData - The current accrual position.
|
|
371
495
|
* @param params.repayAssets - The amount of assets to repay.
|
|
372
496
|
* @param params.marketId - The market identifier (for error messages).
|
|
497
|
+
* @returns Nothing when `repayAssets` does not exceed the outstanding debt.
|
|
498
|
+
* @throws {RepayExceedsDebtError} when `repayAssets` exceeds the position's borrow assets.
|
|
499
|
+
* @example
|
|
500
|
+
* ```ts
|
|
501
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
502
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
503
|
+
* import { validateRepayAmount } from "@morpho-org/morpho-sdk";
|
|
504
|
+
*
|
|
505
|
+
* export function assertRepayWithinDebt(
|
|
506
|
+
* positionData: AccrualPosition,
|
|
507
|
+
* repayAssets: bigint,
|
|
508
|
+
* marketId: MarketId,
|
|
509
|
+
* ): void {
|
|
510
|
+
* validateRepayAmount({ positionData, repayAssets, marketId });
|
|
511
|
+
* }
|
|
512
|
+
* ```
|
|
373
513
|
*/
|
|
374
514
|
export const validateRepayAmount = (params) => {
|
|
375
515
|
const { positionData, repayAssets, marketId } = params;
|
|
@@ -528,7 +668,22 @@ export const validateSlippageTolerance = (slippageTolerance) => {
|
|
|
528
668
|
* @param params.positionData - The current accrual position.
|
|
529
669
|
* @param params.withdrawAssets - The amount of assets to withdraw.
|
|
530
670
|
* @param params.marketId - The market identifier (for error messages).
|
|
671
|
+
* @returns Nothing when `withdrawAssets` does not exceed the position's supplied assets.
|
|
531
672
|
* @throws {WithdrawExceedsSupplyError} when `withdrawAssets > positionData.supplyAssets`.
|
|
673
|
+
* @example
|
|
674
|
+
* ```ts
|
|
675
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
676
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
677
|
+
* import { validateWithdrawAmount } from "@morpho-org/morpho-sdk";
|
|
678
|
+
*
|
|
679
|
+
* export function assertWithdrawWithinSupply(
|
|
680
|
+
* positionData: AccrualPosition,
|
|
681
|
+
* withdrawAssets: bigint,
|
|
682
|
+
* marketId: MarketId,
|
|
683
|
+
* ): void {
|
|
684
|
+
* validateWithdrawAmount({ positionData, withdrawAssets, marketId });
|
|
685
|
+
* }
|
|
686
|
+
* ```
|
|
532
687
|
*/
|
|
533
688
|
export const validateWithdrawAmount = (params) => {
|
|
534
689
|
const { positionData, withdrawAssets, marketId } = params;
|
|
@@ -547,7 +702,22 @@ export const validateWithdrawAmount = (params) => {
|
|
|
547
702
|
* @param params.positionData - The current accrual position.
|
|
548
703
|
* @param params.withdrawShares - The amount of shares to withdraw.
|
|
549
704
|
* @param params.marketId - The market identifier (for error messages).
|
|
705
|
+
* @returns Nothing when `withdrawShares` does not exceed the position's supply shares.
|
|
550
706
|
* @throws {WithdrawSharesExceedSupplyError} when `withdrawShares > positionData.supplyShares`.
|
|
707
|
+
* @example
|
|
708
|
+
* ```ts
|
|
709
|
+
* import type { AccrualPosition } from "@morpho-org/morpho-sdk/blue/entities";
|
|
710
|
+
* import type { MarketId } from "@morpho-org/morpho-sdk/blue/types";
|
|
711
|
+
* import { validateWithdrawShares } from "@morpho-org/morpho-sdk";
|
|
712
|
+
*
|
|
713
|
+
* export function assertWithdrawSharesWithinSupply(
|
|
714
|
+
* positionData: AccrualPosition,
|
|
715
|
+
* withdrawShares: bigint,
|
|
716
|
+
* marketId: MarketId,
|
|
717
|
+
* ): void {
|
|
718
|
+
* validateWithdrawShares({ positionData, withdrawShares, marketId });
|
|
719
|
+
* }
|
|
720
|
+
* ```
|
|
551
721
|
*/
|
|
552
722
|
export const validateWithdrawShares = (params) => {
|
|
553
723
|
const { positionData, withdrawShares, marketId } = params;
|