@morpho-org/morpho-sdk 5.4.1 → 5.6.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 +23 -7
- package/lib/cjs/abis.d.ts +314 -1
- package/lib/cjs/abis.js +169 -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/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +131 -0
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +91 -0
- package/lib/cjs/actions/signatures/index.d.ts +1 -0
- package/lib/cjs/actions/signatures/index.js +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +96 -0
- package/lib/cjs/actions/vaultV1/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/index.js +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +97 -0
- package/lib/cjs/actions/vaultV2/index.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/index.js +1 -0
- package/lib/cjs/bundler/actions.d.ts +118 -2
- package/lib/cjs/bundler/actions.js +212 -6
- package/lib/cjs/bundler/types.d.ts +20 -0
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -1
- package/lib/cjs/entities/blue/blue.d.ts +365 -76
- package/lib/cjs/entities/blue/blue.js +285 -52
- package/lib/cjs/entities/index.d.ts +2 -1
- package/lib/cjs/entities/index.js +6 -3
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +82 -4
- package/lib/cjs/entities/vaultV1/vaultV1.js +164 -0
- package/lib/cjs/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/cjs/entities/{reallocationData.js → vaultV1ReallocationData.js} +30 -18
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +89 -3
- package/lib/cjs/entities/vaultV2/vaultV2.js +181 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1311 -0
- 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 +3 -2
- package/lib/cjs/helpers/index.js +8 -3
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +73 -0
- package/lib/cjs/helpers/validate.d.ts +31 -15
- package/lib/cjs/helpers/validate.js +140 -27
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -1
- package/lib/cjs/types/action.d.ts +33 -1
- package/lib/cjs/types/error.d.ts +363 -5
- package/lib/cjs/types/error.js +455 -6
- package/lib/cjs/types/sharedLiquidity.d.ts +72 -8
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +6 -4
- package/lib/esm/abis.d.ts +314 -1
- package/lib/esm/abis.js +167 -1
- 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/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -2
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +64 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +127 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -3
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +52 -0
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +87 -0
- package/lib/esm/actions/signatures/index.d.ts +1 -0
- package/lib/esm/actions/signatures/index.js +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +54 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +92 -0
- package/lib/esm/actions/vaultV1/index.d.ts +1 -0
- package/lib/esm/actions/vaultV1/index.js +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +56 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +93 -0
- package/lib/esm/actions/vaultV2/index.d.ts +1 -0
- package/lib/esm/actions/vaultV2/index.js +1 -0
- package/lib/esm/bundler/actions.d.ts +118 -2
- package/lib/esm/bundler/actions.js +215 -9
- package/lib/esm/bundler/types.d.ts +20 -0
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +362 -73
- package/lib/esm/entities/blue/blue.js +288 -55
- package/lib/esm/entities/index.d.ts +2 -1
- package/lib/esm/entities/index.js +2 -1
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +80 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +170 -6
- package/lib/esm/entities/{reallocationData.d.ts → vaultV1ReallocationData.d.ts} +41 -17
- package/lib/esm/entities/{reallocationData.js → vaultV1ReallocationData.js} +33 -16
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +88 -2
- package/lib/esm/entities/vaultV2/vaultV2.js +187 -6
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +511 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1307 -0
- 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 +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +49 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +70 -0
- package/lib/esm/helpers/validate.d.ts +31 -15
- package/lib/esm/helpers/validate.js +141 -30
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -1
- package/lib/esm/types/action.d.ts +33 -1
- package/lib/esm/types/error.d.ts +363 -5
- package/lib/esm/types/error.js +428 -4
- package/lib/esm/types/sharedLiquidity.d.ts +72 -8
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +9 -11
package/lib/cjs/types/error.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.ApprovalAmountLessThanSpendAmountError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.BundlerErrors = exports.NegativeMaxRepaySharePriceError = exports.NegativeBorrowSharesError = exports.NegativeMinSharePriceError = exports.NegativeWithdrawMinSharePriceError = exports.NegativeSupplyMaxSharePriceError = exports.NegativeSupplyAmountError = exports.NonPositiveMinBorrowSharePriceError = exports.NegativeReallocationFeeError = exports.NegativeNativeAmountError = exports.NegativeSlippageToleranceError = exports.NonPositiveWithdrawAmountError = exports.ZeroSupplyAmountError = exports.NonPositiveWithdrawCollateralAmountError = exports.NonPositiveRepayMaxSharePriceError = exports.NonPositiveRepayAmountError = exports.NonPositiveReallocationAmountError = exports.ZeroCollateralAmountError = exports.NonPositiveBorrowAmountError = exports.ZeroDepositAmountError = exports.NonPositiveMaxSharePriceError = exports.NonPositiveSharesAmountError = exports.NonPositiveAssetAmountError = exports.VaultExitBundlesV1PermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.UnsupportedInKindAdapterError = exports.AdapterNotPartOfVaultError = exports.InKindRedeemRequiresSingleAdapterError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
|
|
4
|
+
exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.MidnightAmountExceedsMaxOfferCapError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationPositionError = exports.UnknownReallocationVaultMarketConfigError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.DisabledReallocationMarketError = exports.MissingPublicAllocatorConfigError = exports.RepaySharesExceedDebtError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.ShareDivideByZeroError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.TransferAmountNotEqualToAssetsError = exports.UnsortedReallocationWithdrawalsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.MixedReallocationVersionsError = exports.InvalidReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.EmptyReallocationWithdrawalsError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeCollateralError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.Permit2ExpirationMissingError = exports.DepositSpenderMismatchError = exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = void 0;
|
|
5
|
+
exports.RefinanceSharesMissingBorrowAssetsError = exports.RefinanceExceedsBorrowAssetsError = exports.RefinanceExceedsBorrowSharesError = exports.RefinanceExceedsCollateralError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.BorrowAmountAndSharesExclusiveError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.UnpreparedMidnightOfferRootSignatureError = exports.MidnightOfferRootOfferCountMismatchError = exports.MidnightOfferRootRatifierMismatchError = exports.MidnightOfferRootOwnerMismatchError = exports.MidnightOfferRootMismatchError = exports.MissingMidnightOfferRootSignatureError = exports.UnknownMidnightRatifierError = exports.MidnightTakeableOfferMarketMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = void 0;
|
|
5
6
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
7
|
/**
|
|
7
8
|
* Thrown when a morpho-sdk input that must be non-negative is negative.
|
|
@@ -59,6 +60,215 @@ class NonPositiveInputError extends Error {
|
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
exports.NonPositiveInputError = NonPositiveInputError;
|
|
63
|
+
/** Thrown when an integer input exceeds its protocol-defined maximum. */
|
|
64
|
+
class InputExceedsMaxError extends Error {
|
|
65
|
+
/**
|
|
66
|
+
* @param params - Maximum-bound validation details.
|
|
67
|
+
* @param params.field - Public input field whose value is invalid.
|
|
68
|
+
* @param params.value - Supplied value.
|
|
69
|
+
* @param params.max - Largest accepted value.
|
|
70
|
+
*/
|
|
71
|
+
constructor(params) {
|
|
72
|
+
super(`Input "${params.field}" must be at most "${params.max}", got "${params.value}".`);
|
|
73
|
+
this.field = params.field;
|
|
74
|
+
this.value = params.value;
|
|
75
|
+
this.max = params.max;
|
|
76
|
+
this.name = "InputExceedsMaxError";
|
|
77
|
+
}
|
|
78
|
+
/** Public input field whose value is invalid. */
|
|
79
|
+
field;
|
|
80
|
+
/** Supplied value. */
|
|
81
|
+
value;
|
|
82
|
+
/** Largest accepted value. */
|
|
83
|
+
max;
|
|
84
|
+
}
|
|
85
|
+
exports.InputExceedsMaxError = InputExceedsMaxError;
|
|
86
|
+
/** Thrown when an in-kind redemption does not include any Morpho Blue market parameters. */
|
|
87
|
+
class EmptyMarketParamsListError extends Error {
|
|
88
|
+
constructor() {
|
|
89
|
+
super("Market parameters list cannot be empty. Include enough ordered vault markets to cover the in-kind redemption.");
|
|
90
|
+
this.name = "EmptyMarketParamsListError";
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.EmptyMarketParamsListError = EmptyMarketParamsListError;
|
|
94
|
+
/** Thrown when an in-kind redemption deadline has already passed. */
|
|
95
|
+
class ExpiredDeadlineError extends Error {
|
|
96
|
+
deadline;
|
|
97
|
+
timestamp;
|
|
98
|
+
/**
|
|
99
|
+
* @param deadline - Expired deadline supplied by the caller.
|
|
100
|
+
* @param timestamp - Current timestamp used for validation.
|
|
101
|
+
*/
|
|
102
|
+
constructor(deadline, timestamp) {
|
|
103
|
+
super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the exit.`);
|
|
104
|
+
this.deadline = deadline;
|
|
105
|
+
this.timestamp = timestamp;
|
|
106
|
+
this.name = "ExpiredDeadlineError";
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
exports.ExpiredDeadlineError = ExpiredDeadlineError;
|
|
110
|
+
/** Thrown when Vault V2 in-kind redemption is attempted with anything other than one adapter. */
|
|
111
|
+
class InKindRedeemRequiresSingleAdapterError extends Error {
|
|
112
|
+
vault;
|
|
113
|
+
adapters;
|
|
114
|
+
/**
|
|
115
|
+
* @param vault - Vault V2 address.
|
|
116
|
+
* @param adapters - Number of adapters in the supplied vault snapshot.
|
|
117
|
+
*/
|
|
118
|
+
constructor(vault, adapters) {
|
|
119
|
+
super(`Vault "${vault}" has "${adapters}" adapters. In-kind redemption requires exactly one MorphoMarketV1AdapterV2.`);
|
|
120
|
+
this.vault = vault;
|
|
121
|
+
this.adapters = adapters;
|
|
122
|
+
this.name = "InKindRedeemRequiresSingleAdapterError";
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.InKindRedeemRequiresSingleAdapterError = InKindRedeemRequiresSingleAdapterError;
|
|
126
|
+
/** Thrown when a requested in-kind redemption adapter is not part of the Vault V2 snapshot. */
|
|
127
|
+
class AdapterNotPartOfVaultError extends Error {
|
|
128
|
+
vault;
|
|
129
|
+
adapter;
|
|
130
|
+
/**
|
|
131
|
+
* @param vault - Vault V2 address.
|
|
132
|
+
* @param adapter - Adapter rejected by the vault snapshot.
|
|
133
|
+
*/
|
|
134
|
+
constructor(vault, adapter) {
|
|
135
|
+
super(`Adapter "${adapter}" is not part of vault "${vault}". Use the vault's sole configured adapter.`);
|
|
136
|
+
this.vault = vault;
|
|
137
|
+
this.adapter = adapter;
|
|
138
|
+
this.name = "AdapterNotPartOfVaultError";
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
exports.AdapterNotPartOfVaultError = AdapterNotPartOfVaultError;
|
|
142
|
+
/** Thrown when the Vault V2 adapter cannot expose MorphoMarketV1AdapterV2 market shares. */
|
|
143
|
+
class UnsupportedInKindAdapterError extends Error {
|
|
144
|
+
adapter;
|
|
145
|
+
/**
|
|
146
|
+
* @param adapter - Unsupported Vault V2 adapter address.
|
|
147
|
+
*/
|
|
148
|
+
constructor(adapter) {
|
|
149
|
+
super(`Adapter "${adapter}" does not support Vault V2 in-kind redemption. Use a MorphoMarketV1AdapterV2-backed vault.`);
|
|
150
|
+
this.adapter = adapter;
|
|
151
|
+
this.name = "UnsupportedInKindAdapterError";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
exports.UnsupportedInKindAdapterError = UnsupportedInKindAdapterError;
|
|
155
|
+
/** Thrown when a Vault V2 in-kind redemption rounds to no deallocated assets. */
|
|
156
|
+
class InKindRedeemZeroDeallocationError extends Error {
|
|
157
|
+
/**
|
|
158
|
+
* @param params - Values that caused the exit to round to zero deallocated assets.
|
|
159
|
+
* @param params.vault - Vault V2 address with no idle assets available for the exit.
|
|
160
|
+
* @param params.amount - Positive penalty-inclusive amount requested by the caller.
|
|
161
|
+
* @param params.penalty - WAD-scaled force-deallocation penalty applied by the adapter.
|
|
162
|
+
*/
|
|
163
|
+
vault;
|
|
164
|
+
amount;
|
|
165
|
+
penalty;
|
|
166
|
+
constructor(params) {
|
|
167
|
+
super(`Vault "${params.vault}" has no idle assets, and in-kind redemption amount "${params.amount}" rounds to zero deallocated assets after applying penalty "${params.penalty}". Increase the amount or use another exit path.`);
|
|
168
|
+
this.vault = params.vault;
|
|
169
|
+
this.amount = params.amount;
|
|
170
|
+
this.penalty = params.penalty;
|
|
171
|
+
this.name = "InKindRedeemZeroDeallocationError";
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.InKindRedeemZeroDeallocationError = InKindRedeemZeroDeallocationError;
|
|
175
|
+
/** Thrown when the ordered market list cannot cover the requested in-kind redemption. */
|
|
176
|
+
class InKindRedeemCoverageError extends Error {
|
|
177
|
+
/**
|
|
178
|
+
* @param params - Coverage values used to explain the rejected exit.
|
|
179
|
+
* @param params.required - Assets that must be deallocated from listed markets.
|
|
180
|
+
* @param params.covered - Assets covered by the supplied market list.
|
|
181
|
+
* @param params.maxExitAssets - Largest penalty-inclusive exit supported by the list.
|
|
182
|
+
*/
|
|
183
|
+
required;
|
|
184
|
+
covered;
|
|
185
|
+
maxExitAssets;
|
|
186
|
+
constructor(params) {
|
|
187
|
+
super(`In-kind redemption requires "${params.required}" assets but the market list covers "${params.covered}". Reduce the amount to at most "${params.maxExitAssets}" or include more vault markets.`);
|
|
188
|
+
this.required = params.required;
|
|
189
|
+
this.covered = params.covered;
|
|
190
|
+
this.maxExitAssets = params.maxExitAssets;
|
|
191
|
+
this.name = "InKindRedeemCoverageError";
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
exports.InKindRedeemCoverageError = InKindRedeemCoverageError;
|
|
195
|
+
/** Thrown when Morpho Blue lacks the physical loan-token balance needed during an exit callback. */
|
|
196
|
+
class InsufficientBlueBalanceForInKindRedeemError extends Error {
|
|
197
|
+
/**
|
|
198
|
+
* @param params - Morpho Blue balance values used to explain the rejected exit.
|
|
199
|
+
* @param params.asset - Loan token required by the exit.
|
|
200
|
+
* @param params.available - Current token balance held by Morpho Blue.
|
|
201
|
+
* @param params.required - Peak token balance required by the exit.
|
|
202
|
+
*/
|
|
203
|
+
asset;
|
|
204
|
+
available;
|
|
205
|
+
required;
|
|
206
|
+
constructor(params) {
|
|
207
|
+
super(`Morpho Blue holds "${params.available}" of asset "${params.asset}", but this in-kind redemption requires "${params.required}" during its callback. Reduce the amount or wait for Blue liquidity.`);
|
|
208
|
+
this.asset = params.asset;
|
|
209
|
+
this.available = params.available;
|
|
210
|
+
this.required = params.required;
|
|
211
|
+
this.name = "InsufficientBlueBalanceForInKindRedeemError";
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
exports.InsufficientBlueBalanceForInKindRedeemError = InsufficientBlueBalanceForInKindRedeemError;
|
|
215
|
+
/** Thrown when a MetaMorpho vault is connected to a different Morpho deployment. */
|
|
216
|
+
class VaultMorphoMismatchError extends Error {
|
|
217
|
+
/**
|
|
218
|
+
* @param params - Vault and Morpho addresses used to explain the mismatch.
|
|
219
|
+
* @param params.vault - MetaMorpho vault address.
|
|
220
|
+
* @param params.expected - Morpho Blue address expected for the target chain.
|
|
221
|
+
* @param params.actual - Morpho address returned by the vault.
|
|
222
|
+
*/
|
|
223
|
+
vault;
|
|
224
|
+
expected;
|
|
225
|
+
actual;
|
|
226
|
+
constructor(params) {
|
|
227
|
+
super(`Vault "${params.vault}" uses Morpho "${params.actual}", expected "${params.expected}". Use vault data from the selected chain.`);
|
|
228
|
+
this.vault = params.vault;
|
|
229
|
+
this.expected = params.expected;
|
|
230
|
+
this.actual = params.actual;
|
|
231
|
+
this.name = "VaultMorphoMismatchError";
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.VaultMorphoMismatchError = VaultMorphoMismatchError;
|
|
235
|
+
/** Thrown when a Vault V1 is Morpho Blue's fee recipient and cannot safely redeem in kind. */
|
|
236
|
+
class VaultIsBlueFeeRecipientError extends Error {
|
|
237
|
+
vault;
|
|
238
|
+
blue;
|
|
239
|
+
/**
|
|
240
|
+
* @param vault - Unsupported Vault V1 address.
|
|
241
|
+
* @param blue - Morpho Blue deployment whose fees accrue to the vault.
|
|
242
|
+
*/
|
|
243
|
+
constructor(vault, blue) {
|
|
244
|
+
super(`Vault "${vault}" is Morpho Blue "${blue}"'s fee recipient. Use another exit path because VaultExitBundlesV1 cannot safely account for the vault's accrued fee shares.`);
|
|
245
|
+
this.vault = vault;
|
|
246
|
+
this.blue = blue;
|
|
247
|
+
this.name = "VaultIsBlueFeeRecipientError";
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
exports.VaultIsBlueFeeRecipientError = VaultIsBlueFeeRecipientError;
|
|
251
|
+
/** Thrown when a vault-shares requirement cannot be safely encoded as an ERC-2612 permit. */
|
|
252
|
+
class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
253
|
+
/**
|
|
254
|
+
* @param params - Permit mismatch values used to explain the rejection.
|
|
255
|
+
* @param params.field - Permit field that does not match the exit.
|
|
256
|
+
* @param params.expected - Value required by the exit.
|
|
257
|
+
* @param params.actual - Value supplied by the signature.
|
|
258
|
+
* @param params.cause - Original parser failure when signature decoding is wrapped.
|
|
259
|
+
*/
|
|
260
|
+
field;
|
|
261
|
+
expected;
|
|
262
|
+
actual;
|
|
263
|
+
constructor(params) {
|
|
264
|
+
super(`VaultExitBundlesV1 permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Rebuild and sign the vault-exit permit.`, { cause: params.cause });
|
|
265
|
+
this.field = params.field;
|
|
266
|
+
this.expected = params.expected;
|
|
267
|
+
this.actual = params.actual;
|
|
268
|
+
this.name = "VaultExitBundlesV1PermitMismatchError";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
exports.VaultExitBundlesV1PermitMismatchError = VaultExitBundlesV1PermitMismatchError;
|
|
62
272
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
63
273
|
exports.NonPositiveAssetAmountError = NonPositiveInputError;
|
|
64
274
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
@@ -175,6 +385,31 @@ var BundlerErrors;
|
|
|
175
385
|
}
|
|
176
386
|
}
|
|
177
387
|
BundlerErrors.UnexpectedSignature = UnexpectedSignature;
|
|
388
|
+
/**
|
|
389
|
+
* Thrown when a skippable Blue Public Allocator call would leave a usable
|
|
390
|
+
* token allowance behind after the allocator call reverts.
|
|
391
|
+
*
|
|
392
|
+
* @example
|
|
393
|
+
* ```ts
|
|
394
|
+
* import { BundlerErrors } from "@morpho-org/morpho-sdk";
|
|
395
|
+
*
|
|
396
|
+
* if (error instanceof BundlerErrors.SkippableAllocatorPenalty) {
|
|
397
|
+
* // Rebuild the allocator call with skipRevert set to false.
|
|
398
|
+
* }
|
|
399
|
+
* ```
|
|
400
|
+
*/
|
|
401
|
+
class SkippableAllocatorPenalty extends Error {
|
|
402
|
+
penaltyAssets;
|
|
403
|
+
/**
|
|
404
|
+
* @param penaltyAssets - Exact token amount approved to the allocator.
|
|
405
|
+
*/
|
|
406
|
+
constructor(penaltyAssets) {
|
|
407
|
+
super(`Blue Public Allocator calls with penalty assets cannot skip reverts. Rebuild with skipRevert false for penalty amount "${penaltyAssets}".`);
|
|
408
|
+
this.penaltyAssets = penaltyAssets;
|
|
409
|
+
this.name = "SkippableAllocatorPenalty";
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
BundlerErrors.SkippableAllocatorPenalty = SkippableAllocatorPenalty;
|
|
178
413
|
})(BundlerErrors || (exports.BundlerErrors = BundlerErrors = {}));
|
|
179
414
|
/**
|
|
180
415
|
* Thrown when `buildTx` receives more than one requirement signature of the same kind.
|
|
@@ -403,13 +638,144 @@ class EmptyReallocationWithdrawalsError extends Error {
|
|
|
403
638
|
}
|
|
404
639
|
}
|
|
405
640
|
exports.EmptyReallocationWithdrawalsError = EmptyReallocationWithdrawalsError;
|
|
406
|
-
/** Thrown when a
|
|
641
|
+
/** Thrown when a Public Allocator source references the target Blue market. */
|
|
407
642
|
class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
408
643
|
constructor(vault, marketId) {
|
|
409
644
|
super(`Reallocation withdrawal cannot include the target market ${marketId} for vault ${vault}.`);
|
|
410
645
|
}
|
|
411
646
|
}
|
|
412
647
|
exports.ReallocationWithdrawalOnTargetMarketError = ReallocationWithdrawalOnTargetMarketError;
|
|
648
|
+
/**
|
|
649
|
+
* Thrown when a Public Allocator reallocation does not match exactly one V1 or
|
|
650
|
+
* V2 input shape.
|
|
651
|
+
*
|
|
652
|
+
* @example
|
|
653
|
+
* ```ts
|
|
654
|
+
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
655
|
+
*
|
|
656
|
+
* const error = new InvalidReallocationShapeError();
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
class InvalidReallocationShapeError extends Error {
|
|
660
|
+
constructor() {
|
|
661
|
+
super('Reallocation must contain either V1 "withdrawals" or V2 "from", but not both.');
|
|
662
|
+
this.name = "InvalidReallocationShapeError";
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
exports.InvalidReallocationShapeError = InvalidReallocationShapeError;
|
|
666
|
+
/**
|
|
667
|
+
* Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```ts
|
|
671
|
+
* import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
|
|
672
|
+
*
|
|
673
|
+
* const error = new MixedReallocationVersionsError();
|
|
674
|
+
* ```
|
|
675
|
+
*/
|
|
676
|
+
class MixedReallocationVersionsError extends Error {
|
|
677
|
+
constructor() {
|
|
678
|
+
super("Reallocation plans cannot mix Vault V1 and Vault V2 entries. Submit one version per transaction.");
|
|
679
|
+
this.name = "MixedReallocationVersionsError";
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
exports.MixedReallocationVersionsError = MixedReallocationVersionsError;
|
|
683
|
+
/**
|
|
684
|
+
* Thrown when a Blue Public Allocator reallocation contains a malformed vault
|
|
685
|
+
* or adapter address.
|
|
686
|
+
*
|
|
687
|
+
* @example
|
|
688
|
+
* ```ts
|
|
689
|
+
* import { InvalidReallocationAddressError } from "@morpho-org/morpho-sdk";
|
|
690
|
+
*
|
|
691
|
+
* const error = new InvalidReallocationAddressError("to.adapter");
|
|
692
|
+
* if (error instanceof InvalidReallocationAddressError) {
|
|
693
|
+
* console.error(error.field);
|
|
694
|
+
* }
|
|
695
|
+
* ```
|
|
696
|
+
*/
|
|
697
|
+
class InvalidReallocationAddressError extends Error {
|
|
698
|
+
field;
|
|
699
|
+
/**
|
|
700
|
+
* @param field - Reallocation address field that is absent or malformed.
|
|
701
|
+
*/
|
|
702
|
+
constructor(field) {
|
|
703
|
+
super(`Reallocation "${field}" must be a valid address.`);
|
|
704
|
+
this.field = field;
|
|
705
|
+
this.name = "InvalidReallocationAddressError";
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
exports.InvalidReallocationAddressError = InvalidReallocationAddressError;
|
|
709
|
+
/**
|
|
710
|
+
* Thrown when a Blue Public Allocator source is absent, incomplete, or has an
|
|
711
|
+
* unknown discriminator.
|
|
712
|
+
*
|
|
713
|
+
* @example
|
|
714
|
+
* ```ts
|
|
715
|
+
* import { InvalidReallocationSourceTypeError } from "@morpho-org/morpho-sdk";
|
|
716
|
+
*
|
|
717
|
+
* const error = new InvalidReallocationSourceTypeError("marketTypo");
|
|
718
|
+
* ```
|
|
719
|
+
*/
|
|
720
|
+
class InvalidReallocationSourceTypeError extends Error {
|
|
721
|
+
sourceType;
|
|
722
|
+
missingField;
|
|
723
|
+
/**
|
|
724
|
+
* @param sourceType - Invalid runtime value received for `reallocation.from.type`,
|
|
725
|
+
* or `undefined` when the source or discriminator is absent.
|
|
726
|
+
* @param missingField - Required market-source field that is absent or malformed.
|
|
727
|
+
*/
|
|
728
|
+
constructor(sourceType, missingField) {
|
|
729
|
+
super(missingField == null
|
|
730
|
+
? sourceType === undefined
|
|
731
|
+
? 'Reallocation source must specify type "market" or "idle".'
|
|
732
|
+
: `Reallocation source type must be "market" or "idle", got "${sourceType}".`
|
|
733
|
+
: `Reallocation market source must include a valid "${missingField}".`);
|
|
734
|
+
this.sourceType = sourceType;
|
|
735
|
+
this.missingField = missingField;
|
|
736
|
+
this.name = "InvalidReallocationSourceTypeError";
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
exports.InvalidReallocationSourceTypeError = InvalidReallocationSourceTypeError;
|
|
740
|
+
/**
|
|
741
|
+
* Thrown when one bundle assigns different penalty rates to the same Vault V2.
|
|
742
|
+
*
|
|
743
|
+
* @example
|
|
744
|
+
* ```ts
|
|
745
|
+
* import { InconsistentReallocationPenaltyError } from "@morpho-org/morpho-sdk";
|
|
746
|
+
* import type { Address } from "viem";
|
|
747
|
+
*
|
|
748
|
+
* const vaultFixture =
|
|
749
|
+
* "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address;
|
|
750
|
+
* const error = new InconsistentReallocationPenaltyError({
|
|
751
|
+
* vault: vaultFixture,
|
|
752
|
+
* expected: 5n,
|
|
753
|
+
* actual: 11n,
|
|
754
|
+
* });
|
|
755
|
+
* ```
|
|
756
|
+
*/
|
|
757
|
+
class InconsistentReallocationPenaltyError extends Error {
|
|
758
|
+
/** Vault whose configured penalty must be reused. */
|
|
759
|
+
vault;
|
|
760
|
+
/** Penalty rate established by the first matching bundle entry. */
|
|
761
|
+
expected;
|
|
762
|
+
/** Conflicting penalty rate supplied by a later bundle entry. */
|
|
763
|
+
actual;
|
|
764
|
+
/**
|
|
765
|
+
* @param params - Conflicting vault penalty details.
|
|
766
|
+
* @param params.vault - Vault whose configured penalty applies.
|
|
767
|
+
* @param params.expected - Penalty rate established by the first matching entry.
|
|
768
|
+
* @param params.actual - Conflicting penalty rate supplied by a later entry.
|
|
769
|
+
*/
|
|
770
|
+
constructor(params) {
|
|
771
|
+
super(`Penalty for vault "${params.vault}" must remain "${params.expected}" across the bundle, got "${params.actual}". Use the vault's configured penalty for every call.`);
|
|
772
|
+
this.vault = params.vault;
|
|
773
|
+
this.expected = params.expected;
|
|
774
|
+
this.actual = params.actual;
|
|
775
|
+
this.name = "InconsistentReallocationPenaltyError";
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
exports.InconsistentReallocationPenaltyError = InconsistentReallocationPenaltyError;
|
|
413
779
|
/** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
|
|
414
780
|
class UnsortedReallocationWithdrawalsError extends Error {
|
|
415
781
|
constructor(vault, marketId) {
|
|
@@ -496,8 +862,8 @@ class DisabledReallocationMarketError extends Error {
|
|
|
496
862
|
}
|
|
497
863
|
exports.DisabledReallocationMarketError = DisabledReallocationMarketError;
|
|
498
864
|
/**
|
|
499
|
-
* Thrown when shared liquidity selected by
|
|
500
|
-
* the operation's absolute shortfall on the target market — the resulting
|
|
865
|
+
* Thrown when shared liquidity selected by a Vault V1 or Vault V2 reallocation planner cannot
|
|
866
|
+
* cover the operation's absolute shortfall on the target market — the resulting
|
|
501
867
|
* `morphoBorrow` or `morphoWithdraw` would still revert onchain.
|
|
502
868
|
*
|
|
503
869
|
* Pattern-match on the class and inspect `params` to surface the gap to users.
|
|
@@ -564,6 +930,89 @@ class UnknownReallocationPositionError extends blue_sdk_1.UnknownDataError {
|
|
|
564
930
|
}
|
|
565
931
|
}
|
|
566
932
|
exports.UnknownReallocationPositionError = UnknownReallocationPositionError;
|
|
933
|
+
/** Thrown when Vault V2 reallocation state does not contain a requested allocation id. */
|
|
934
|
+
class UnknownReallocationAllocationError extends blue_sdk_1.UnknownDataError {
|
|
935
|
+
vault;
|
|
936
|
+
id;
|
|
937
|
+
/**
|
|
938
|
+
* @param vault - Vault V2 address for the missing allocation.
|
|
939
|
+
* @param id - Missing Vault V2 allocation id.
|
|
940
|
+
*/
|
|
941
|
+
constructor(vault, id) {
|
|
942
|
+
super(`unknown reallocation allocation "${id}" for vault "${vault}"`);
|
|
943
|
+
this.vault = vault;
|
|
944
|
+
this.id = id;
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
exports.UnknownReallocationAllocationError = UnknownReallocationAllocationError;
|
|
948
|
+
/** Thrown when Vault V2 reallocation state lacks the vault-wide allocator configuration. */
|
|
949
|
+
class UnknownReallocationPublicAllocatorConfigError extends blue_sdk_1.UnknownDataError {
|
|
950
|
+
vault;
|
|
951
|
+
/** @param vault - Vault V2 address with missing allocator configuration. */
|
|
952
|
+
constructor(vault) {
|
|
953
|
+
super(`unknown public allocator configuration for vault "${vault}"`);
|
|
954
|
+
this.vault = vault;
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
exports.UnknownReallocationPublicAllocatorConfigError = UnknownReallocationPublicAllocatorConfigError;
|
|
958
|
+
/** Thrown when Vault V2 reallocation state lacks the fetched active-adapter set. */
|
|
959
|
+
class UnknownReallocationActiveAdaptersError extends blue_sdk_1.UnknownDataError {
|
|
960
|
+
vault;
|
|
961
|
+
/** @param vault - Vault V2 address with missing active-adapter state. */
|
|
962
|
+
constructor(vault) {
|
|
963
|
+
super(`unknown active adapters for reallocation vault "${vault}"`);
|
|
964
|
+
this.vault = vault;
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
exports.UnknownReallocationActiveAdaptersError = UnknownReallocationActiveAdaptersError;
|
|
968
|
+
/** Thrown when Vault V2 reallocation state lacks an adapter-market allocator configuration. */
|
|
969
|
+
class UnknownReallocationMarketPublicAllocatorConfigError extends blue_sdk_1.UnknownDataError {
|
|
970
|
+
vault;
|
|
971
|
+
adapterMarketCapId;
|
|
972
|
+
/**
|
|
973
|
+
* @param vault - Vault V2 address for the missing configuration.
|
|
974
|
+
* @param adapterMarketCapId - Missing adapter-scoped market cap id.
|
|
975
|
+
*/
|
|
976
|
+
constructor(vault, adapterMarketCapId) {
|
|
977
|
+
super(`unknown public allocator configuration "${adapterMarketCapId}" for vault "${vault}"`);
|
|
978
|
+
this.vault = vault;
|
|
979
|
+
this.adapterMarketCapId = adapterMarketCapId;
|
|
980
|
+
}
|
|
981
|
+
}
|
|
982
|
+
exports.UnknownReallocationMarketPublicAllocatorConfigError = UnknownReallocationMarketPublicAllocatorConfigError;
|
|
983
|
+
/** Thrown when Vault V2 reallocation state does not contain a requested adapter. */
|
|
984
|
+
class UnknownReallocationAdapterError extends blue_sdk_1.UnknownDataError {
|
|
985
|
+
vault;
|
|
986
|
+
adapter;
|
|
987
|
+
/**
|
|
988
|
+
* @param vault - Vault V2 address expected to own the adapter.
|
|
989
|
+
* @param adapter - Missing adapter address.
|
|
990
|
+
*/
|
|
991
|
+
constructor(vault, adapter) {
|
|
992
|
+
super(`unknown reallocation adapter "${adapter}" for vault "${vault}"`);
|
|
993
|
+
this.vault = vault;
|
|
994
|
+
this.adapter = adapter;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
exports.UnknownReallocationAdapterError = UnknownReallocationAdapterError;
|
|
998
|
+
/** Thrown when a simulated Vault V2 allocation transition would underflow. */
|
|
999
|
+
class ReallocationAllocationUnderflowError extends Error {
|
|
1000
|
+
params;
|
|
1001
|
+
constructor(params) {
|
|
1002
|
+
super(`Reallocation change "${params.change}" exceeds allocation "${params.allocation}" for id "${params.id}" on vault "${params.vault}". Refresh the reallocation data and recompute the plan.`);
|
|
1003
|
+
this.params = params;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
exports.ReallocationAllocationUnderflowError = ReallocationAllocationUnderflowError;
|
|
1007
|
+
/** Thrown when a simulated Vault V2 market withdrawal exceeds the adapter's supply shares. */
|
|
1008
|
+
class ReallocationAdapterSupplySharesUnderflowError extends Error {
|
|
1009
|
+
params;
|
|
1010
|
+
constructor(params) {
|
|
1011
|
+
super(`Reallocation withdraw shares "${params.withdrawnShares}" exceed adapter supply shares "${params.supplyShares}" on market "${params.marketId}" for adapter "${params.adapter}". Refresh the reallocation data and recompute the plan.`);
|
|
1012
|
+
this.params = params;
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
exports.ReallocationAdapterSupplySharesUnderflowError = ReallocationAdapterSupplySharesUnderflowError;
|
|
567
1016
|
/** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
|
|
568
1017
|
class MidnightAmountExceedsMaxOfferCapError extends Error {
|
|
569
1018
|
constructor(params) {
|
|
@@ -719,7 +1168,7 @@ class WithdrawSharesExceedSupplyError extends Error {
|
|
|
719
1168
|
}
|
|
720
1169
|
exports.WithdrawSharesExceedSupplyError = WithdrawSharesExceedSupplyError;
|
|
721
1170
|
/**
|
|
722
|
-
* Thrown when
|
|
1171
|
+
* Thrown when a Vault V1 or Vault V2 reallocation planner receives a withdraw `amount` greater
|
|
723
1172
|
* than the target market's current `totalSupplyAssets` — the post-withdraw
|
|
724
1173
|
* supply would be negative, making the on-chain `morphoWithdraw` revert
|
|
725
1174
|
* regardless of any reallocation. Caught here so callers do not pay
|
|
@@ -13,16 +13,16 @@ export interface PublicAllocatorOptions {
|
|
|
13
13
|
readonly timestamp?: BigIntish;
|
|
14
14
|
/**
|
|
15
15
|
* Vaults to consider for reallocation. They must have enabled the PublicAllocator.
|
|
16
|
+
* Arrays, readonly arrays, sets, and other iterables are accepted.
|
|
16
17
|
* Defaults to all vaults present in the reallocation data.
|
|
17
18
|
*/
|
|
18
|
-
readonly reallocatableVaults?:
|
|
19
|
+
readonly reallocatableVaults?: Iterable<Address>;
|
|
19
20
|
/**
|
|
20
21
|
* The maximum utilization each source market may reach when withdrawing
|
|
21
22
|
* shared liquidity, scaled by WAD.
|
|
22
23
|
*
|
|
23
|
-
* @deprecated
|
|
24
|
-
*
|
|
25
|
-
* configurable in the next major. Per-market overrides are still honored for now.
|
|
24
|
+
* @deprecated Per-market source ceilings will be removed in the next major.
|
|
25
|
+
* Use `defaultMaxWithdrawalUtilization` to configure one ceiling for every source.
|
|
26
26
|
*/
|
|
27
27
|
readonly maxWithdrawalUtilization?: Readonly<Record<MarketId, bigint | undefined>>;
|
|
28
28
|
/**
|
|
@@ -30,12 +30,37 @@ export interface PublicAllocatorOptions {
|
|
|
30
30
|
* shared liquidity, scaled by WAD.
|
|
31
31
|
*
|
|
32
32
|
* @default 90% (900000000000000000n)
|
|
33
|
-
* @deprecated The source-market withdrawal ceiling is fixed at 90%
|
|
34
|
-
* ({@link DEFAULT_WITHDRAWAL_TARGET_UTILIZATION}) and will stop being
|
|
35
|
-
* configurable in the next major. Overrides are still honored for now.
|
|
36
33
|
*/
|
|
37
34
|
readonly defaultMaxWithdrawalUtilization?: bigint;
|
|
38
35
|
}
|
|
36
|
+
/** Options controlling Vault V2 BluePublicAllocator reallocation discovery. */
|
|
37
|
+
export interface VaultV2BluePublicAllocatorOptions {
|
|
38
|
+
/** Whether Vault V2 public allocator discovery is enabled. */
|
|
39
|
+
readonly enabled?: boolean;
|
|
40
|
+
/** Timestamp at which market and Vault V2 interest is evaluated. */
|
|
41
|
+
readonly timestamp?: BigIntish;
|
|
42
|
+
/**
|
|
43
|
+
* Vault V2 addresses to consider. Arrays, readonly arrays, sets, and other
|
|
44
|
+
* iterables are accepted. Defaults to every vault in the reallocation data.
|
|
45
|
+
*/
|
|
46
|
+
readonly reallocatableVaults?: Iterable<Address>;
|
|
47
|
+
/**
|
|
48
|
+
* Maximum utilization source markets may reach during friendly discovery,
|
|
49
|
+
* scaled by WAD. The amount-aware planner falls back to 100% only when the
|
|
50
|
+
* friendly phase cannot cover the operation's absolute shortfall.
|
|
51
|
+
*
|
|
52
|
+
* @default 90% (900000000000000000n)
|
|
53
|
+
*/
|
|
54
|
+
readonly maxWithdrawalUtilization?: bigint;
|
|
55
|
+
/**
|
|
56
|
+
* Maximum proportional vault-asset penalty accepted for each
|
|
57
|
+
* BluePublicAllocator call, scaled by WAD. Vaults with a higher configured
|
|
58
|
+
* penalty are ignored. Must not exceed WAD (100%).
|
|
59
|
+
*
|
|
60
|
+
* @default 0n
|
|
61
|
+
*/
|
|
62
|
+
readonly maxPenalty?: bigint;
|
|
63
|
+
}
|
|
39
64
|
/**
|
|
40
65
|
* A computed source-market withdrawal before it is grouped by vault.
|
|
41
66
|
*/
|
|
@@ -60,13 +85,52 @@ export interface ReallocationWithdrawal {
|
|
|
60
85
|
* Maps 1:1 to a `PublicAllocator.reallocateTo()` call.
|
|
61
86
|
* Withdraws from source markets and supplies to the target market.
|
|
62
87
|
*/
|
|
63
|
-
export interface
|
|
88
|
+
export interface VaultV1Reallocation {
|
|
64
89
|
readonly vault: Address;
|
|
65
90
|
/** Fee in native token (ETH) paid to the PublicAllocator for this vault. */
|
|
66
91
|
readonly fee: bigint;
|
|
67
92
|
/** Source markets to withdraw from before supplying to the target market. */
|
|
68
93
|
readonly withdrawals: readonly ReallocationWithdrawal[];
|
|
69
94
|
}
|
|
95
|
+
/** Source of a Vault V2 BluePublicAllocator reallocation. */
|
|
96
|
+
export type VaultV2BlueReallocationSource = {
|
|
97
|
+
/** Reallocate from a Morpho Blue market. */
|
|
98
|
+
readonly type: "market";
|
|
99
|
+
/** Vault V2 adapter supplying the source market. */
|
|
100
|
+
readonly adapter: Address;
|
|
101
|
+
/** Source market parameters. */
|
|
102
|
+
readonly marketParams: MarketParams;
|
|
103
|
+
} | {
|
|
104
|
+
/** Allocate from vault idle liquidity without a synthetic market. */
|
|
105
|
+
readonly type: "idle";
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* One Blue Public Allocator contract call performed before a Blue action.
|
|
109
|
+
*
|
|
110
|
+
* The target market parameters are derived from the enclosing Blue action.
|
|
111
|
+
*/
|
|
112
|
+
export interface VaultV2BlueReallocation {
|
|
113
|
+
/** Vault whose liquidity is moved. */
|
|
114
|
+
readonly vault: Address;
|
|
115
|
+
/** Liquidity source. */
|
|
116
|
+
readonly from: VaultV2BlueReallocationSource;
|
|
117
|
+
/** Target Vault V2 adapter; the target market comes from the enclosing action. */
|
|
118
|
+
readonly to: {
|
|
119
|
+
readonly adapter: Address;
|
|
120
|
+
};
|
|
121
|
+
/** Asset amount, which must fit in `uint128`. */
|
|
122
|
+
readonly assets: bigint;
|
|
123
|
+
/** Vault-configured WAD-scaled penalty rate passed to the allocator. */
|
|
124
|
+
readonly penalty: bigint;
|
|
125
|
+
}
|
|
126
|
+
/** A homogeneous Blue action plan containing only Vault V1 or only Vault V2 reallocations. */
|
|
127
|
+
export type BlueReallocationPlan = Iterable<VaultV1Reallocation> | Iterable<VaultV2BlueReallocation>;
|
|
128
|
+
/**
|
|
129
|
+
* Deprecated name for a Vault V1 reallocation.
|
|
130
|
+
*
|
|
131
|
+
* @deprecated Use {@link VaultV1Reallocation} instead.
|
|
132
|
+
*/
|
|
133
|
+
export type VaultReallocation = VaultV1Reallocation;
|
|
70
134
|
/**
|
|
71
135
|
* Options for computing vault reallocations via the public allocator.
|
|
72
136
|
*
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, } from "@morpho-org/blue-sdk";
|
|
2
|
+
export { AdaptiveCurveIrmLib, CapacityLimitReason, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
3
3
|
export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
4
4
|
export { EcrecoverRatifierUtils, GroupUtils, OfferUtils, Payload, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
5
5
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, WithId, WithIndex, } from "@morpho-org/morpho-ts";
|
|
6
6
|
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys, mergeEntries, retryPromiseLinearBackoff, Time, transformValue, values, } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { computeReallocations } from "./helpers/
|
|
7
|
+
export { computeReallocations, computeVaultV1Reallocations, } from "./helpers/computeVaultV1Reallocations.js";
|
|
8
8
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
9
9
|
export { computeMaxRepaySharePrice, computeMinBorrowSharePrice, } from "./helpers/slippage.js";
|
|
10
10
|
export { validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateReallocations, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateUserAddress, } from "./helpers/validate.js";
|