@morpho-org/morpho-sdk 5.5.0 → 5.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -7
- package/lib/cjs/abis.d.ts +15 -3
- package/lib/cjs/abis.js +15 -1
- package/lib/cjs/actions/blue/borrow.d.ts +21 -15
- package/lib/cjs/actions/blue/borrow.js +25 -18
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/cjs/actions/blue/buildReallocationActions.js +123 -27
- package/lib/cjs/actions/blue/refinance.d.ts +14 -7
- package/lib/cjs/actions/blue/refinance.js +18 -10
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +39 -23
- package/lib/cjs/actions/blue/withdraw.d.ts +20 -13
- package/lib/cjs/actions/blue/withdraw.js +23 -18
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/cjs/blue/abis.d.ts +2 -0
- package/lib/cjs/blue/abis.js +33 -0
- package/lib/cjs/blue/addresses.d.ts +2 -0
- package/lib/cjs/blue/addresses.js +19 -0
- package/lib/cjs/blue/constants.d.ts +1 -0
- package/lib/cjs/blue/constants.js +13 -0
- package/lib/cjs/blue/entities.d.ts +2 -0
- package/lib/cjs/blue/entities.js +37 -0
- package/lib/cjs/blue/errors.d.ts +2 -0
- package/lib/cjs/blue/errors.js +29 -0
- package/lib/cjs/blue/fetch.d.ts +1 -0
- package/lib/cjs/blue/fetch.js +33 -0
- package/lib/cjs/blue/types.d.ts +2 -0
- package/lib/cjs/blue/types.js +2 -0
- package/lib/cjs/blue/utils.d.ts +3 -0
- package/lib/cjs/blue/utils.js +29 -0
- package/lib/cjs/bundler/actions.d.ts +122 -3
- package/lib/cjs/bundler/actions.js +216 -7
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +37 -3
- package/lib/cjs/constants.js +41 -1
- package/lib/cjs/entities/blue/blue.d.ts +362 -71
- package/lib/cjs/entities/blue/blue.js +286 -52
- package/lib/cjs/entities/index.d.ts +64 -4
- package/lib/cjs/entities/index.js +37 -22
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +29 -16
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1300 -0
- package/lib/cjs/errors.d.ts +48 -3
- package/lib/cjs/errors.js +62 -1
- package/lib/cjs/fetch.d.ts +16 -1
- package/lib/cjs/fetch.js +24 -1
- package/lib/{esm/helpers/computeReallocations.d.ts → cjs/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/cjs/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +27 -13
- package/lib/cjs/helpers/constant.d.ts +5 -3
- package/lib/cjs/helpers/constant.js +6 -4
- package/lib/cjs/helpers/index.d.ts +2 -2
- package/lib/cjs/helpers/index.js +6 -3
- package/lib/cjs/helpers/validate.d.ts +32 -16
- package/lib/cjs/helpers/validate.js +142 -29
- package/lib/cjs/midnight/abis.d.ts +1 -0
- package/lib/cjs/midnight/abis.js +8 -0
- package/lib/cjs/midnight/constants.d.ts +1 -0
- package/lib/cjs/midnight/constants.js +19 -0
- package/lib/cjs/midnight/entities.d.ts +2 -0
- package/lib/cjs/midnight/entities.js +11 -0
- package/lib/cjs/midnight/errors.d.ts +1 -0
- package/lib/cjs/midnight/errors.js +24 -0
- package/lib/cjs/midnight/fetch.d.ts +1 -0
- package/lib/cjs/midnight/fetch.js +9 -0
- package/lib/cjs/midnight/types.d.ts +1 -0
- package/lib/cjs/midnight/types.js +2 -0
- package/lib/cjs/midnight/utils.d.ts +1 -0
- package/lib/cjs/midnight/utils.js +17 -0
- package/lib/cjs/types/action.d.ts +12 -0
- package/lib/cjs/types/error.d.ts +224 -5
- package/lib/cjs/types/error.js +269 -7
- package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
- package/lib/cjs/types.d.ts +17 -2
- package/lib/cjs/utils.d.ts +31 -4
- package/lib/cjs/utils.js +44 -4
- package/lib/esm/abis.d.ts +15 -3
- package/lib/esm/abis.js +15 -3
- package/lib/esm/actions/blue/borrow.d.ts +21 -15
- package/lib/esm/actions/blue/borrow.js +26 -19
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +1 -1
- package/lib/esm/actions/blue/buildAssetFundingActions.js +1 -1
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +62 -19
- package/lib/esm/actions/blue/buildReallocationActions.js +119 -25
- package/lib/esm/actions/blue/refinance.d.ts +14 -7
- package/lib/esm/actions/blue/refinance.js +19 -11
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +28 -19
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +40 -24
- package/lib/esm/actions/blue/withdraw.d.ts +20 -13
- package/lib/esm/actions/blue/withdraw.js +24 -19
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +2 -2
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +2 -2
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +1 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -1
- package/lib/esm/blue/abis.d.ts +2 -0
- package/lib/esm/blue/abis.js +2 -0
- package/lib/esm/blue/addresses.d.ts +2 -0
- package/lib/esm/blue/addresses.js +1 -0
- package/lib/esm/blue/constants.d.ts +1 -0
- package/lib/esm/blue/constants.js +1 -0
- package/lib/esm/blue/entities.d.ts +2 -0
- package/lib/esm/blue/entities.js +1 -0
- package/lib/esm/blue/errors.d.ts +2 -0
- package/lib/esm/blue/errors.js +2 -0
- package/lib/esm/blue/fetch.d.ts +1 -0
- package/lib/esm/blue/fetch.js +1 -0
- package/lib/esm/blue/types.d.ts +2 -0
- package/lib/esm/blue/types.js +1 -0
- package/lib/esm/blue/utils.d.ts +3 -0
- package/lib/esm/blue/utils.js +2 -0
- package/lib/esm/bundler/actions.d.ts +122 -3
- package/lib/esm/bundler/actions.js +219 -10
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +37 -3
- package/lib/esm/constants.js +37 -3
- package/lib/esm/entities/blue/blue.d.ts +362 -71
- package/lib/esm/entities/blue/blue.js +289 -55
- package/lib/esm/entities/index.d.ts +64 -4
- package/lib/esm/entities/index.js +19 -3
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +40 -15
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +32 -14
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +1 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1296 -0
- package/lib/esm/errors.d.ts +48 -3
- package/lib/esm/errors.js +48 -3
- package/lib/esm/fetch.d.ts +16 -1
- package/lib/esm/fetch.js +16 -1
- package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts} +14 -8
- package/lib/esm/helpers/{computeReallocations.js → computeVaultV1Reallocations.js} +25 -11
- package/lib/esm/helpers/constant.d.ts +5 -3
- package/lib/esm/helpers/constant.js +5 -3
- package/lib/esm/helpers/index.d.ts +2 -2
- package/lib/esm/helpers/index.js +2 -2
- package/lib/esm/helpers/validate.d.ts +32 -16
- package/lib/esm/helpers/validate.js +143 -32
- package/lib/esm/midnight/abis.d.ts +1 -0
- package/lib/esm/midnight/abis.js +1 -0
- package/lib/esm/midnight/constants.d.ts +1 -0
- package/lib/esm/midnight/constants.js +1 -0
- package/lib/esm/midnight/entities.d.ts +2 -0
- package/lib/esm/midnight/entities.js +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -0
- package/lib/esm/midnight/errors.js +1 -0
- package/lib/esm/midnight/fetch.d.ts +1 -0
- package/lib/esm/midnight/fetch.js +1 -0
- package/lib/esm/midnight/types.d.ts +1 -0
- package/lib/esm/midnight/types.js +1 -0
- package/lib/esm/midnight/utils.d.ts +1 -0
- package/lib/esm/midnight/utils.js +1 -0
- package/lib/esm/types/action.d.ts +12 -0
- package/lib/esm/types/error.d.ts +224 -5
- package/lib/esm/types/error.js +253 -4
- package/lib/esm/types/sharedLiquidity.d.ts +72 -8
- package/lib/esm/types.d.ts +17 -2
- package/lib/esm/utils.d.ts +31 -4
- package/lib/esm/utils.js +31 -4
- package/package.json +23 -7
package/lib/esm/errors.d.ts
CHANGED
|
@@ -1,4 +1,49 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError
|
|
2
|
-
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
2
|
+
/** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
|
|
3
|
+
InvalidMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError,
|
|
4
|
+
/** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
|
|
5
|
+
UnknownDataError, UnknownFactory as UnknownBlueFactory,
|
|
6
|
+
/** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
|
|
7
|
+
UnknownFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError,
|
|
8
|
+
/** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
|
|
9
|
+
UnknownMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory,
|
|
10
|
+
/** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
|
|
11
|
+
UnknownOfFactory, UnknownTokenError as UnknownBlueTokenError,
|
|
12
|
+
/** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
|
|
13
|
+
UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
|
|
14
|
+
/** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
|
|
15
|
+
UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
|
|
16
|
+
/** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
|
|
17
|
+
UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
|
|
18
|
+
/** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
|
|
19
|
+
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
|
|
20
|
+
/** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
|
|
21
|
+
UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
22
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
23
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError,
|
|
24
|
+
/** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
|
|
25
|
+
InvalidOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
26
|
+
/** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
|
|
27
|
+
InvalidOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError,
|
|
28
|
+
/** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
|
|
29
|
+
InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError,
|
|
30
|
+
/** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
|
|
31
|
+
InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError,
|
|
32
|
+
/** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
|
|
33
|
+
InvalidPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError,
|
|
34
|
+
/** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
|
|
35
|
+
InvalidTickSpacingError, InvalidTreeError as InvalidMidnightTreeError,
|
|
36
|
+
/** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
|
|
37
|
+
InvalidTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError,
|
|
38
|
+
/** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
|
|
39
|
+
InvalidTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError,
|
|
40
|
+
/** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
|
|
41
|
+
PriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError,
|
|
42
|
+
/** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
|
|
43
|
+
SettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError,
|
|
44
|
+
/** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
|
|
45
|
+
TickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError,
|
|
46
|
+
/** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
|
|
47
|
+
UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
3
48
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
4
|
-
export { _try } from "@morpho-org/morpho-ts";
|
|
49
|
+
export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/errors.js
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
2
|
+
/** @deprecated Use InvalidBlueMarketParamsError or the raw protocol subpath. */
|
|
3
|
+
InvalidMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError,
|
|
4
|
+
/** @deprecated Use UnknownBlueDataError or the raw protocol subpath. */
|
|
5
|
+
UnknownDataError, UnknownFactory as UnknownBlueFactory,
|
|
6
|
+
/** @deprecated Use UnknownBlueFactory or the raw protocol subpath. */
|
|
7
|
+
UnknownFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError,
|
|
8
|
+
/** @deprecated Use UnknownBlueMarketParamsError or the raw protocol subpath. */
|
|
9
|
+
UnknownMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory,
|
|
10
|
+
/** @deprecated Use UnknownBlueOfFactory or the raw protocol subpath. */
|
|
11
|
+
UnknownOfFactory, UnknownTokenError as UnknownBlueTokenError,
|
|
12
|
+
/** @deprecated Use UnknownBlueTokenError or the raw protocol subpath. */
|
|
13
|
+
UnknownTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError,
|
|
14
|
+
/** @deprecated Use UnknownBlueTokenPriceError or the raw protocol subpath. */
|
|
15
|
+
UnknownTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError,
|
|
16
|
+
/** @deprecated Use UnknownBlueVaultConfigError or the raw protocol subpath. */
|
|
17
|
+
UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError,
|
|
18
|
+
/** @deprecated Use UnsupportedBluePreLiquidationParamsError or the raw protocol subpath. */
|
|
19
|
+
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError,
|
|
20
|
+
/** @deprecated Use UnsupportedBlueVaultV2AdapterError or the raw protocol subpath. */
|
|
21
|
+
UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
22
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
23
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError,
|
|
24
|
+
/** @deprecated Use InvalidMidnightOfferGroupError or the raw protocol subpath. */
|
|
25
|
+
InvalidOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
26
|
+
/** @deprecated Use InvalidMidnightOfferParameterError or the raw protocol subpath. */
|
|
27
|
+
InvalidOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError,
|
|
28
|
+
/** @deprecated Use InvalidMidnightPositionAccrualStateError or the raw protocol subpath. */
|
|
29
|
+
InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError,
|
|
30
|
+
/** @deprecated Use InvalidMidnightPositionAccrualTimestampError or the raw protocol subpath. */
|
|
31
|
+
InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError,
|
|
32
|
+
/** @deprecated Use InvalidMidnightPositionLossFactorError or the raw protocol subpath. */
|
|
33
|
+
InvalidPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError,
|
|
34
|
+
/** @deprecated Use InvalidMidnightTickSpacingError or the raw protocol subpath. */
|
|
35
|
+
InvalidTickSpacingError, InvalidTreeError as InvalidMidnightTreeError,
|
|
36
|
+
/** @deprecated Use InvalidMidnightTreeError or the raw protocol subpath. */
|
|
37
|
+
InvalidTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError,
|
|
38
|
+
/** @deprecated Use InvalidMidnightTreeHeightError or the raw protocol subpath. */
|
|
39
|
+
InvalidTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError,
|
|
40
|
+
/** @deprecated Use MidnightPriceGreaterThanOneError or the raw protocol subpath. */
|
|
41
|
+
PriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError,
|
|
42
|
+
/** @deprecated Use MidnightSettlementFeeExceedsPriceError or the raw protocol subpath. */
|
|
43
|
+
SettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError,
|
|
44
|
+
/** @deprecated Use MidnightTickOutOfRangeError or the raw protocol subpath. */
|
|
45
|
+
TickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError,
|
|
46
|
+
/** @deprecated Use UnknownMidnightCollateralIndexError or the raw protocol subpath. */
|
|
47
|
+
UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
48
|
+
export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/fetch.d.ts
CHANGED
|
@@ -1 +1,16 @@
|
|
|
1
|
-
export { fetchAccrualPosition
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition,
|
|
2
|
+
/** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
|
|
3
|
+
fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket,
|
|
4
|
+
/** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
|
|
5
|
+
fetchMarket, fetchMarketParams as fetchBlueMarketParams,
|
|
6
|
+
/** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
|
|
7
|
+
fetchMarketParams, fetchPosition as fetchBluePosition,
|
|
8
|
+
/** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
|
|
9
|
+
fetchPosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
10
|
+
/** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
|
|
11
|
+
fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition,
|
|
12
|
+
/** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
|
|
13
|
+
fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
|
|
14
|
+
/** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
|
|
15
|
+
fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
16
|
+
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 +1,16 @@
|
|
|
1
|
-
export { fetchAccrualPosition
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition,
|
|
2
|
+
/** @deprecated Use `fetchBlueAccrualPosition` or the raw `/blue/fetch` subpath. */
|
|
3
|
+
fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket,
|
|
4
|
+
/** @deprecated Use `fetchBlueMarket` or the raw `/blue/fetch` subpath. */
|
|
5
|
+
fetchMarket, fetchMarketParams as fetchBlueMarketParams,
|
|
6
|
+
/** @deprecated Use `fetchBlueMarketParams` or the raw `/blue/fetch` subpath. */
|
|
7
|
+
fetchMarketParams, fetchPosition as fetchBluePosition,
|
|
8
|
+
/** @deprecated Use `fetchBluePosition` or the raw `/blue/fetch` subpath. */
|
|
9
|
+
fetchPosition, fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
10
|
+
/** @deprecated Use `fetchBluePreLiquidationParams` or the raw `/blue/fetch` subpath. */
|
|
11
|
+
fetchPreLiquidationParams, fetchPreLiquidationPosition as fetchBluePreLiquidationPosition,
|
|
12
|
+
/** @deprecated Use `fetchBluePreLiquidationPosition` or the raw `/blue/fetch` subpath. */
|
|
13
|
+
fetchPreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser,
|
|
14
|
+
/** @deprecated Use `fetchBlueUser` or the raw `/blue/fetch` subpath. */
|
|
15
|
+
fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
16
|
+
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/{cjs/helpers/computeReallocations.d.ts → esm/helpers/computeVaultV1Reallocations.d.ts}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MarketId } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type {
|
|
3
|
-
import { type ReallocationComputeOptions, type
|
|
2
|
+
import type { VaultV1ReallocationData } from "../entities/vaultV1ReallocationData.js";
|
|
3
|
+
import { type ReallocationComputeOptions, type VaultV1Reallocation } from "../types/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Computes vault reallocations for a `borrow` or `withdraw` on a target market.
|
|
6
6
|
*
|
|
@@ -31,7 +31,7 @@ import { type ReallocationComputeOptions, type VaultReallocation } from "../type
|
|
|
31
31
|
* import { mainnet } from "viem/chains";
|
|
32
32
|
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
33
33
|
* import {
|
|
34
|
-
*
|
|
34
|
+
* computeVaultV1Reallocations,
|
|
35
35
|
* morphoViemExtension,
|
|
36
36
|
* } from "@morpho-org/morpho-sdk";
|
|
37
37
|
*
|
|
@@ -44,12 +44,12 @@ import { type ReallocationComputeOptions, type VaultReallocation } from "../type
|
|
|
44
44
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
45
45
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
46
46
|
* const block = await client.getBlock();
|
|
47
|
-
* const reallocationData = await market.
|
|
47
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
48
48
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
49
49
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
50
50
|
* });
|
|
51
51
|
* const borrowAmount = parseUnits("1000", 6);
|
|
52
|
-
* const reallocations =
|
|
52
|
+
* const reallocations = computeVaultV1Reallocations({
|
|
53
53
|
* reallocationData,
|
|
54
54
|
* marketId: marketParams.id,
|
|
55
55
|
* operation: "borrow",
|
|
@@ -66,10 +66,16 @@ import { type ReallocationComputeOptions, type VaultReallocation } from "../type
|
|
|
66
66
|
* // borrow.buildTx() includes any required PublicAllocator reallocations.
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
export declare const
|
|
70
|
-
readonly reallocationData:
|
|
69
|
+
export declare const computeVaultV1Reallocations: ({ reallocationData: data, marketId, operation, amount, options, }: {
|
|
70
|
+
readonly reallocationData: VaultV1ReallocationData;
|
|
71
71
|
readonly marketId: MarketId;
|
|
72
72
|
readonly operation: "borrow" | "withdraw";
|
|
73
73
|
readonly amount: bigint;
|
|
74
74
|
readonly options?: ReallocationComputeOptions;
|
|
75
|
-
}) => readonly
|
|
75
|
+
}) => readonly VaultV1Reallocation[];
|
|
76
|
+
/**
|
|
77
|
+
* Deprecated name for the Vault V1 amount-aware reallocation planner.
|
|
78
|
+
*
|
|
79
|
+
* @deprecated Use {@link computeVaultV1Reallocations} instead.
|
|
80
|
+
*/
|
|
81
|
+
export declare const computeReallocations: typeof computeVaultV1Reallocations;
|
|
@@ -84,7 +84,7 @@ const capVaultWithdrawals = (withdrawals, assets) => {
|
|
|
84
84
|
* import { mainnet } from "viem/chains";
|
|
85
85
|
* import { markets, vaults } from "@morpho-org/morpho-test";
|
|
86
86
|
* import {
|
|
87
|
-
*
|
|
87
|
+
* computeVaultV1Reallocations,
|
|
88
88
|
* morphoViemExtension,
|
|
89
89
|
* } from "@morpho-org/morpho-sdk";
|
|
90
90
|
*
|
|
@@ -97,12 +97,12 @@ const capVaultWithdrawals = (withdrawals, assets) => {
|
|
|
97
97
|
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
98
98
|
* const market = client.morpho.blue(marketParams, mainnet.id);
|
|
99
99
|
* const block = await client.getBlock();
|
|
100
|
-
* const reallocationData = await market.
|
|
100
|
+
* const reallocationData = await market.getVaultV1ReallocationData({
|
|
101
101
|
* vaultAddresses: [vaults[mainnet.id].steakUsdc.address],
|
|
102
102
|
* block: { number: block.number, timestamp: block.timestamp },
|
|
103
103
|
* });
|
|
104
104
|
* const borrowAmount = parseUnits("1000", 6);
|
|
105
|
-
* const reallocations =
|
|
105
|
+
* const reallocations = computeVaultV1Reallocations({
|
|
106
106
|
* reallocationData,
|
|
107
107
|
* marketId: marketParams.id,
|
|
108
108
|
* operation: "borrow",
|
|
@@ -119,12 +119,20 @@ const capVaultWithdrawals = (withdrawals, assets) => {
|
|
|
119
119
|
* // borrow.buildTx() includes any required PublicAllocator reallocations.
|
|
120
120
|
* ```
|
|
121
121
|
*/
|
|
122
|
-
export const
|
|
122
|
+
export const computeVaultV1Reallocations = ({ reallocationData: data, marketId, operation, amount, options, }) => {
|
|
123
123
|
if (options?.enabled === false)
|
|
124
124
|
return [];
|
|
125
|
-
|
|
125
|
+
const normalizedOptions = {
|
|
126
|
+
...options,
|
|
127
|
+
reallocatableVaults: options?.reallocatableVaults == null
|
|
128
|
+
? undefined
|
|
129
|
+
: [...options.reallocatableVaults],
|
|
130
|
+
};
|
|
131
|
+
// VaultV1ReallocationData does not retain the fetch block; pass that block timestamp
|
|
126
132
|
// to compute against the same accrued state, otherwise Market defaults to lastUpdate.
|
|
127
|
-
const market = data
|
|
133
|
+
const market = data
|
|
134
|
+
.getMarket(marketId)
|
|
135
|
+
.accrueInterest(normalizedOptions.timestamp);
|
|
128
136
|
// Reject unreachable withdraws before any utilization math: a negative
|
|
129
137
|
// post-supply yields a negative utilization that short-circuits the
|
|
130
138
|
// utilization gate below and silently returns `[]` — masking a sure revert.
|
|
@@ -142,7 +150,7 @@ export const computeReallocations = ({ reallocationData: data, marketId, operati
|
|
|
142
150
|
const newTotalSupplyAssets = operation === "withdraw"
|
|
143
151
|
? market.totalSupplyAssets - amount
|
|
144
152
|
: market.totalSupplyAssets;
|
|
145
|
-
const supplyTargetUtilization = getSupplyTargetUtilization(market.params.id,
|
|
153
|
+
const supplyTargetUtilization = getSupplyTargetUtilization(market.params.id, normalizedOptions);
|
|
146
154
|
if (MarketUtils.getUtilization({
|
|
147
155
|
totalSupplyAssets: newTotalSupplyAssets,
|
|
148
156
|
totalBorrowAssets: newTotalBorrowAssets,
|
|
@@ -154,7 +162,7 @@ export const computeReallocations = ({ reallocationData: data, marketId, operati
|
|
|
154
162
|
: MathLib.wDivDown(newTotalBorrowAssets, supplyTargetUtilization) -
|
|
155
163
|
newTotalSupplyAssets;
|
|
156
164
|
// Phase 1: "friendly" reallocations respecting withdrawal utilization targets.
|
|
157
|
-
const { withdrawals: friendlyWithdrawals, data: friendlyReallocationData } = data.
|
|
165
|
+
const { withdrawals: friendlyWithdrawals, data: friendlyReallocationData } = data.computeVaultV1Reallocations(market.id, normalizedOptions);
|
|
158
166
|
const withdrawals = [...friendlyWithdrawals];
|
|
159
167
|
const friendlyReallocationMarket = friendlyReallocationData.getMarket(market.id);
|
|
160
168
|
// Operation-specific post-friendly check: would the on-chain call still revert?
|
|
@@ -167,8 +175,8 @@ export const computeReallocations = ({ reallocationData: data, marketId, operati
|
|
|
167
175
|
if (friendlyBorrow > friendlySupply) {
|
|
168
176
|
// Phase 2: "aggressive" — fully withdraw from every market (100% utilization).
|
|
169
177
|
requiredAssets = newTotalBorrowAssets - newTotalSupplyAssets;
|
|
170
|
-
withdrawals.push(...friendlyReallocationData.
|
|
171
|
-
...
|
|
178
|
+
withdrawals.push(...friendlyReallocationData.computeVaultV1Reallocations(market.id, {
|
|
179
|
+
...normalizedOptions,
|
|
172
180
|
defaultMaxWithdrawalUtilization: MathLib.WAD,
|
|
173
181
|
maxWithdrawalUtilization: {},
|
|
174
182
|
}).withdrawals);
|
|
@@ -204,7 +212,7 @@ export const computeReallocations = ({ reallocationData: data, marketId, operati
|
|
|
204
212
|
available: totalReallocated,
|
|
205
213
|
});
|
|
206
214
|
}
|
|
207
|
-
// Transform into
|
|
215
|
+
// Transform into VaultV1Reallocation[] format.
|
|
208
216
|
return reallocations
|
|
209
217
|
.filter(({ withdrawals: vaultWithdrawals }) => vaultWithdrawals.length > 0)
|
|
210
218
|
.map(({ vault, withdrawals: vaultWithdrawals }) => ({
|
|
@@ -226,3 +234,9 @@ export const computeReallocations = ({ reallocationData: data, marketId, operati
|
|
|
226
234
|
})),
|
|
227
235
|
}));
|
|
228
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* Deprecated name for the Vault V1 amount-aware reallocation planner.
|
|
239
|
+
*
|
|
240
|
+
* @deprecated Use {@link computeVaultV1Reallocations} instead.
|
|
241
|
+
*/
|
|
242
|
+
export const computeReallocations = computeVaultV1Reallocations;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
2
|
/** Maximum slippage tolerance: 10% */
|
|
3
3
|
export declare const MAX_SLIPPAGE_TOLERANCE: bigint;
|
|
4
|
+
/** Default maximum Vault V2 reallocation penalty: zero. */
|
|
5
|
+
export declare const DEFAULT_MAX_REALLOCATION_PENALTY = 0n;
|
|
6
|
+
/** Maximum Vault V2 reallocation penalty: 100%. */
|
|
7
|
+
export declare const MAX_REALLOCATION_PENALTY = 1000000000000000000n;
|
|
4
8
|
/** Default LLTV buffer: 0.5% below LLTV. Prevents instant liquidation on new positions. */
|
|
5
9
|
export declare const DEFAULT_LLTV_BUFFER: bigint;
|
|
6
10
|
/** Maximum absolute share price cap (100 RAY). Prevents absurd maxSharePrice values in repay. */
|
|
7
11
|
export declare const MAX_ABSOLUTE_SHARE_PRICE: bigint;
|
|
8
12
|
/**
|
|
9
13
|
* The default maximum utilization a source market may reach when withdrawing
|
|
10
|
-
* shared liquidity, scaled by WAD.
|
|
11
|
-
* `maxWithdrawalUtilization` / `defaultMaxWithdrawalUtilization` options until
|
|
12
|
-
* the next major.
|
|
14
|
+
* shared liquidity, scaled by WAD.
|
|
13
15
|
*/
|
|
14
16
|
export declare const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n;
|
|
15
17
|
/**
|
|
@@ -2,15 +2,17 @@ import { ChainId, MathLib } from "@morpho-org/blue-sdk";
|
|
|
2
2
|
import { maxUint96 } from "viem";
|
|
3
3
|
/** Maximum slippage tolerance: 10% */
|
|
4
4
|
export const MAX_SLIPPAGE_TOLERANCE = MathLib.WAD / 10n;
|
|
5
|
+
/** Default maximum Vault V2 reallocation penalty: zero. */
|
|
6
|
+
export const DEFAULT_MAX_REALLOCATION_PENALTY = 0n;
|
|
7
|
+
/** Maximum Vault V2 reallocation penalty: 100%. */
|
|
8
|
+
export const MAX_REALLOCATION_PENALTY = MathLib.WAD;
|
|
5
9
|
/** Default LLTV buffer: 0.5% below LLTV. Prevents instant liquidation on new positions. */
|
|
6
10
|
export const DEFAULT_LLTV_BUFFER = MathLib.WAD / 200n;
|
|
7
11
|
/** Maximum absolute share price cap (100 RAY). Prevents absurd maxSharePrice values in repay. */
|
|
8
12
|
export const MAX_ABSOLUTE_SHARE_PRICE = 100n * MathLib.RAY;
|
|
9
13
|
/**
|
|
10
14
|
* The default maximum utilization a source market may reach when withdrawing
|
|
11
|
-
* shared liquidity, scaled by WAD.
|
|
12
|
-
* `maxWithdrawalUtilization` / `defaultMaxWithdrawalUtilization` options until
|
|
13
|
-
* the next major.
|
|
15
|
+
* shared liquidity, scaled by WAD.
|
|
14
16
|
*/
|
|
15
17
|
export const DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = 900000000000000000n;
|
|
16
18
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { computeReallocations } from "./
|
|
2
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
1
|
+
export { computeReallocations, computeVaultV1Reallocations, } from "./computeVaultV1Reallocations.js";
|
|
2
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
3
3
|
export { addTransactionMetadata } from "./metadata.js";
|
|
4
4
|
export { type PreviewVaultV2InKindRedeemParams, previewVaultV2InKindRedeem, type VaultV2InKindRedeemMarketPreview, } from "./previewVaultV2InKindRedeem.js";
|
|
5
5
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
package/lib/esm/helpers/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { computeReallocations } from "./
|
|
2
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
1
|
+
export { computeReallocations, computeVaultV1Reallocations, } from "./computeVaultV1Reallocations.js";
|
|
2
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./constant.js";
|
|
3
3
|
export { addTransactionMetadata } from "./metadata.js";
|
|
4
4
|
export { previewVaultV2InKindRedeem, } from "./previewVaultV2InKindRedeem.js";
|
|
5
5
|
export { signAndVerifyTypedData } from "./signAndVerifyTypedData.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type AccrualPosition, type MarketId } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { MarketInput as MidnightMarketInput } from "@morpho-org/midnight-sdk";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
|
-
import { type
|
|
4
|
+
import { type BlueReallocationPlan, type VaultV1Reallocation, type VaultV2BlueReallocation } from "../types/index.js";
|
|
5
5
|
/** @internal */
|
|
6
6
|
export declare const compareMarketIds: (idA: MarketId, idB: MarketId) => -1 | 0 | 1;
|
|
7
7
|
/**
|
|
@@ -138,18 +138,10 @@ export declare const validateRepayShares: (params: {
|
|
|
138
138
|
marketId: MarketId;
|
|
139
139
|
}) => void;
|
|
140
140
|
/**
|
|
141
|
-
* Validates that
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* -
|
|
145
|
-
* - `withdrawals` must be non-empty.
|
|
146
|
-
* - Every withdrawal `amount` must be strictly positive.
|
|
147
|
-
* - No withdrawal may target `targetMarketId` (the operation's target market — the market being
|
|
148
|
-
* borrowed from for `borrow`, or being withdrawn from for `withdraw`).
|
|
149
|
-
* - Withdrawal market IDs must be strictly ascending (required by `PublicAllocator.reallocateTo`).
|
|
150
|
-
*
|
|
151
|
-
* @param reallocations - The reallocations to validate.
|
|
152
|
-
* @param targetMarketId - The ID of the operation's target market. No withdrawal may reference this market.
|
|
141
|
+
* Validates that Vault V1 PublicAllocator reallocations are well-formed.
|
|
142
|
+
*
|
|
143
|
+
* @param reallocations - Vault V1 reallocations to validate.
|
|
144
|
+
* @param targetMarketId - The operation's target market ID.
|
|
153
145
|
* @returns Nothing when every reallocation is valid.
|
|
154
146
|
* @throws {NegativeInputError} when a reallocation fee is negative.
|
|
155
147
|
* @throws {EmptyReallocationWithdrawalsError} when a reallocation has no withdrawals.
|
|
@@ -158,14 +150,38 @@ export declare const validateRepayShares: (params: {
|
|
|
158
150
|
* @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
|
|
159
151
|
* @example
|
|
160
152
|
* ```ts
|
|
161
|
-
* import type {
|
|
153
|
+
* import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
|
|
162
154
|
* import { validateReallocations } from "@morpho-org/morpho-sdk";
|
|
163
155
|
* import { zeroHash } from "viem";
|
|
164
156
|
*
|
|
165
|
-
* const result: void = validateReallocations([], zeroHash as
|
|
157
|
+
* const result: void = validateReallocations([], zeroHash as BlueMarketId);
|
|
166
158
|
* ```
|
|
167
159
|
*/
|
|
168
|
-
export declare const validateReallocations: (reallocations:
|
|
160
|
+
export declare const validateReallocations: (reallocations: Iterable<VaultV1Reallocation>, targetMarketId: MarketId) => void;
|
|
161
|
+
/** @internal */
|
|
162
|
+
export declare const validateVaultV2BlueReallocations: (reallocations: Iterable<VaultV2BlueReallocation>, targetMarketId: MarketId) => void;
|
|
163
|
+
/**
|
|
164
|
+
* Validates and normalizes a homogeneous Blue reallocation plan.
|
|
165
|
+
*
|
|
166
|
+
* @param params - Validation parameters.
|
|
167
|
+
* @param params.reallocations - Optional Vault V1 or Vault V2 reallocation plan.
|
|
168
|
+
* @param params.targetMarketId - Morpho Blue market receiving the liquidity.
|
|
169
|
+
* @param params.chainId - Chain whose allocator deployment is required for a V2 plan.
|
|
170
|
+
* @returns The validated plan tagged with its allocator version.
|
|
171
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
172
|
+
* @internal
|
|
173
|
+
*/
|
|
174
|
+
export declare const validateAndNormalizeReallocations: ({ reallocations, targetMarketId, chainId, }: {
|
|
175
|
+
readonly reallocations: BlueReallocationPlan | undefined;
|
|
176
|
+
readonly targetMarketId: MarketId;
|
|
177
|
+
readonly chainId: number;
|
|
178
|
+
}) => {
|
|
179
|
+
type: "vaultV2Blue";
|
|
180
|
+
reallocations: VaultV2BlueReallocation[];
|
|
181
|
+
} | {
|
|
182
|
+
type: "vaultV1";
|
|
183
|
+
reallocations: VaultV1Reallocation[];
|
|
184
|
+
};
|
|
169
185
|
/**
|
|
170
186
|
* Validates that a slippage tolerance is within an acceptable range.
|
|
171
187
|
*
|