@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/cjs/errors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.
|
|
3
|
+
exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
4
|
+
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = 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; } });
|
|
@@ -28,11 +27,12 @@ Object.defineProperty(exports, "InvalidNumberError", { enumerable: true, get: fu
|
|
|
28
27
|
Object.defineProperty(exports, "InvalidPermitDomainChainIdError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainChainIdError; } });
|
|
29
28
|
Object.defineProperty(exports, "InvalidPermitDomainVerifyingContractError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainVerifyingContractError; } });
|
|
30
29
|
Object.defineProperty(exports, "isBlueUnknownOfFactoryError", { enumerable: true, get: function () { return blue_sdk_viem_1.isUnknownOfFactoryError; } });
|
|
30
|
+
Object.defineProperty(exports, "MalformedTokenMetadataError", { enumerable: true, get: function () { return blue_sdk_viem_1.MalformedTokenMetadataError; } });
|
|
31
31
|
Object.defineProperty(exports, "BlueMarketParamsIdMismatchError", { enumerable: true, get: function () { return blue_sdk_viem_1.MarketParamsIdMismatchError; } });
|
|
32
|
+
Object.defineProperty(exports, "MissingPermitDomainNameError", { enumerable: true, get: function () { return blue_sdk_viem_1.MissingPermitDomainNameError; } });
|
|
32
33
|
Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, get: function () { return blue_sdk_viem_1.NonTupleReturnValueError; } });
|
|
33
34
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
34
35
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
35
|
-
Object.defineProperty(exports, "BlueUnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
36
36
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
|
37
37
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
38
38
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
@@ -42,6 +42,9 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
42
42
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
43
43
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
44
44
|
Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
45
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
46
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
47
|
+
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
45
48
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
46
49
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
47
50
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -64,11 +67,5 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
|
|
|
64
67
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
|
|
65
68
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
|
|
66
69
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
67
|
-
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
68
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
69
|
-
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
70
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
71
|
-
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
72
|
-
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
73
70
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
74
71
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
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; } });
|
|
@@ -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. */
|
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = void 0;
|
|
3
|
+
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
/** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
|
|
8
8
|
exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
|
|
9
|
+
/**
|
|
10
|
+
* Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = blue_sdk_1.MathLib.WAD / 10n;
|
|
9
14
|
/** Maximum slippage tolerance: 10% */
|
|
10
15
|
exports.MAX_SLIPPAGE_TOLERANCE = blue_sdk_1.MathLib.WAD / 10n;
|
|
11
16
|
/** 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/cjs/helpers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
|
|
3
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.getMidnightMaxSafeDebt = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
|
|
4
4
|
var callback_js_1 = require("./callback.js");
|
|
5
5
|
Object.defineProperty(exports, "getMidnightBlueBuyCallbackAddress", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackAddress; } });
|
|
6
6
|
Object.defineProperty(exports, "getMidnightBlueBuyCallbackData", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackData; } });
|
|
@@ -32,6 +32,7 @@ Object.defineProperty(exports, "computeMinForceWithdrawSharePrice", { enumerable
|
|
|
32
32
|
Object.defineProperty(exports, "computeVaultMaxShareAllowance", { enumerable: true, get: function () { return slippage_js_1.computeVaultMaxShareAllowance; } });
|
|
33
33
|
Object.defineProperty(exports, "computeVaultMaxSharePrice", { enumerable: true, get: function () { return slippage_js_1.computeVaultMaxSharePrice; } });
|
|
34
34
|
var validate_js_1 = require("./validate.js");
|
|
35
|
+
Object.defineProperty(exports, "getMidnightMaxSafeDebt", { enumerable: true, get: function () { return validate_js_1.getMidnightMaxSafeDebt; } });
|
|
35
36
|
Object.defineProperty(exports, "validateAccrualPosition", { enumerable: true, get: function () { return validate_js_1.validateAccrualPosition; } });
|
|
36
37
|
Object.defineProperty(exports, "validateChainId", { enumerable: true, get: function () { return validate_js_1.validateChainId; } });
|
|
37
38
|
Object.defineProperty(exports, "validateMidnightMarketChainId", { enumerable: true, get: function () { return validate_js_1.validateMidnightMarketChainId; } });
|
|
@@ -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;
|