@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
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { getChainAddresses, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
|
|
1
|
+
import { getChainAddresses, MarketUtils, MathLib, ORACLE_PRICE_SCALE, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { isDefined } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { isAddressEqual } from "viem";
|
|
4
|
-
import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, NativeAmountOnNonWNativeAssetError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
|
|
5
|
-
import { DEFAULT_LLTV_BUFFER, MAX_SLIPPAGE_TOLERANCE } from "./constant.js";
|
|
3
|
+
import { isAddress, isAddressEqual, maxUint128 } from "viem";
|
|
4
|
+
import { AccrualPositionUserMismatchError, AddressMismatchError, BorrowExceedsSafeLtvError, BundlerErrors, ChainIdMismatchError, ChainWNativeMissingError, EmptyReallocationWithdrawalsError, ExcessiveSlippageToleranceError, InconsistentReallocationPenaltyError, InputExceedsMaxError, InvalidReallocationAddressError, InvalidReallocationShapeError, InvalidReallocationSourceTypeError, MarketIdMismatchError, MissingClientPropertyError, MissingMarketPriceError, MixedReallocationVersionsError, NativeAmountOnNonWNativeAssetError, NegativeInputError, NonPositiveInputError, ReallocationWithdrawalOnTargetMarketError, RepayExceedsDebtError, RepaySharesExceedDebtError, UnsortedReallocationWithdrawalsError, WithdrawExceedsCollateralError, WithdrawExceedsSupplyError, WithdrawMakesPositionUnhealthyError, WithdrawSharesExceedSupplyError, } from "../types/index.js";
|
|
5
|
+
import { DEFAULT_LLTV_BUFFER, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, } from "./constant.js";
|
|
6
6
|
/** @internal */
|
|
7
7
|
export const compareMarketIds = (idA, idB) => {
|
|
8
8
|
const normalizedIdA = idA.toLowerCase();
|
|
@@ -218,18 +218,10 @@ export const validateRepayShares = (params) => {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
/**
|
|
221
|
-
* Validates that
|
|
221
|
+
* Validates that Vault V1 PublicAllocator reallocations are well-formed.
|
|
222
222
|
*
|
|
223
|
-
*
|
|
224
|
-
* -
|
|
225
|
-
* - `withdrawals` must be non-empty.
|
|
226
|
-
* - Every withdrawal `amount` must be strictly positive.
|
|
227
|
-
* - No withdrawal may target `targetMarketId` (the operation's target market — the market being
|
|
228
|
-
* borrowed from for `borrow`, or being withdrawn from for `withdraw`).
|
|
229
|
-
* - Withdrawal market IDs must be strictly ascending (required by `PublicAllocator.reallocateTo`).
|
|
230
|
-
*
|
|
231
|
-
* @param reallocations - The reallocations to validate.
|
|
232
|
-
* @param targetMarketId - The ID of the operation's target market. No withdrawal may reference this market.
|
|
223
|
+
* @param reallocations - Vault V1 reallocations to validate.
|
|
224
|
+
* @param targetMarketId - The operation's target market ID.
|
|
233
225
|
* @returns Nothing when every reallocation is valid.
|
|
234
226
|
* @throws {NegativeInputError} when a reallocation fee is negative.
|
|
235
227
|
* @throws {EmptyReallocationWithdrawalsError} when a reallocation has no withdrawals.
|
|
@@ -238,36 +230,155 @@ export const validateRepayShares = (params) => {
|
|
|
238
230
|
* @throws {UnsortedReallocationWithdrawalsError} when withdrawals are not strictly market-id sorted.
|
|
239
231
|
* @example
|
|
240
232
|
* ```ts
|
|
241
|
-
* import type {
|
|
233
|
+
* import type { BlueMarketId } from "@morpho-org/morpho-sdk/types";
|
|
242
234
|
* import { validateReallocations } from "@morpho-org/morpho-sdk";
|
|
243
235
|
* import { zeroHash } from "viem";
|
|
244
236
|
*
|
|
245
|
-
* const result: void = validateReallocations([], zeroHash as
|
|
237
|
+
* const result: void = validateReallocations([], zeroHash as BlueMarketId);
|
|
246
238
|
* ```
|
|
247
239
|
*/
|
|
248
240
|
export const validateReallocations = (reallocations, targetMarketId) => {
|
|
249
|
-
for (const
|
|
250
|
-
if (
|
|
251
|
-
throw new NegativeInputError("reallocation.fee",
|
|
241
|
+
for (const reallocation of reallocations) {
|
|
242
|
+
if (reallocation.fee < 0n) {
|
|
243
|
+
throw new NegativeInputError("reallocation.fee", reallocation.fee);
|
|
252
244
|
}
|
|
253
|
-
if (
|
|
254
|
-
throw new EmptyReallocationWithdrawalsError(
|
|
245
|
+
if (reallocation.withdrawals.length === 0) {
|
|
246
|
+
throw new EmptyReallocationWithdrawalsError(reallocation.vault);
|
|
255
247
|
}
|
|
256
|
-
let
|
|
257
|
-
for (const
|
|
258
|
-
if (
|
|
259
|
-
throw new NonPositiveInputError(`reallocation.withdrawals[${
|
|
248
|
+
let previousMarketId;
|
|
249
|
+
for (const withdrawal of reallocation.withdrawals) {
|
|
250
|
+
if (withdrawal.amount <= 0n) {
|
|
251
|
+
throw new NonPositiveInputError(`reallocation.withdrawals[${withdrawal.marketParams.id}].amount`, withdrawal.amount);
|
|
260
252
|
}
|
|
261
|
-
if (
|
|
262
|
-
throw new ReallocationWithdrawalOnTargetMarketError(
|
|
253
|
+
if (withdrawal.marketParams.id === targetMarketId) {
|
|
254
|
+
throw new ReallocationWithdrawalOnTargetMarketError(reallocation.vault, withdrawal.marketParams.id);
|
|
263
255
|
}
|
|
264
|
-
if (
|
|
265
|
-
compareMarketIds(
|
|
266
|
-
throw new UnsortedReallocationWithdrawalsError(
|
|
256
|
+
if (previousMarketId !== undefined &&
|
|
257
|
+
compareMarketIds(withdrawal.marketParams.id, previousMarketId) <= 0) {
|
|
258
|
+
throw new UnsortedReallocationWithdrawalsError(reallocation.vault, withdrawal.marketParams.id);
|
|
267
259
|
}
|
|
268
|
-
|
|
260
|
+
previousMarketId = withdrawal.marketParams.id;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
/** @internal */
|
|
265
|
+
export const validateVaultV2BlueReallocations = (reallocations, targetMarketId) => {
|
|
266
|
+
const penaltyByVault = new Map();
|
|
267
|
+
for (const reallocation of reallocations) {
|
|
268
|
+
if (typeof reallocation.vault !== "string" ||
|
|
269
|
+
!isAddress(reallocation.vault)) {
|
|
270
|
+
throw new InvalidReallocationAddressError("vault");
|
|
271
|
+
}
|
|
272
|
+
if (reallocation.to == null ||
|
|
273
|
+
typeof reallocation.to.adapter !== "string" ||
|
|
274
|
+
!isAddress(reallocation.to.adapter)) {
|
|
275
|
+
throw new InvalidReallocationAddressError("to.adapter");
|
|
276
|
+
}
|
|
277
|
+
const source = reallocation.from;
|
|
278
|
+
if (source == null) {
|
|
279
|
+
throw new InvalidReallocationSourceTypeError(undefined);
|
|
280
|
+
}
|
|
281
|
+
const sourceType = source.type;
|
|
282
|
+
if (sourceType !== "market" && sourceType !== "idle") {
|
|
283
|
+
throw new InvalidReallocationSourceTypeError(sourceType);
|
|
284
|
+
}
|
|
285
|
+
let sourceMarketId;
|
|
286
|
+
if (source.type === "market") {
|
|
287
|
+
if (typeof source.adapter !== "string" || !isAddress(source.adapter)) {
|
|
288
|
+
throw new InvalidReallocationAddressError("from.adapter");
|
|
289
|
+
}
|
|
290
|
+
if (source.marketParams == null ||
|
|
291
|
+
!isAddress(source.marketParams.loanToken) ||
|
|
292
|
+
!isAddress(source.marketParams.collateralToken) ||
|
|
293
|
+
!isAddress(source.marketParams.oracle) ||
|
|
294
|
+
!isAddress(source.marketParams.irm) ||
|
|
295
|
+
typeof source.marketParams.lltv !== "bigint") {
|
|
296
|
+
throw new InvalidReallocationSourceTypeError("market", "marketParams");
|
|
297
|
+
}
|
|
298
|
+
sourceMarketId = MarketUtils.getMarketId(source.marketParams);
|
|
299
|
+
}
|
|
300
|
+
if (reallocation.penalty < 0n) {
|
|
301
|
+
throw new NegativeInputError("reallocation.penalty", reallocation.penalty);
|
|
302
|
+
}
|
|
303
|
+
if (reallocation.penalty > MAX_REALLOCATION_PENALTY) {
|
|
304
|
+
throw new InputExceedsMaxError({
|
|
305
|
+
field: "reallocation.penalty",
|
|
306
|
+
value: reallocation.penalty,
|
|
307
|
+
max: MAX_REALLOCATION_PENALTY,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
if (reallocation.assets <= 0n) {
|
|
311
|
+
throw new NonPositiveInputError("reallocation.assets", reallocation.assets);
|
|
312
|
+
}
|
|
313
|
+
if (reallocation.assets > maxUint128) {
|
|
314
|
+
throw new InputExceedsMaxError({
|
|
315
|
+
field: "reallocation.assets",
|
|
316
|
+
value: reallocation.assets,
|
|
317
|
+
max: maxUint128,
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
const penaltyKey = reallocation.vault.toLowerCase();
|
|
321
|
+
const expectedPenalty = penaltyByVault.get(penaltyKey);
|
|
322
|
+
if (expectedPenalty !== undefined &&
|
|
323
|
+
expectedPenalty !== reallocation.penalty) {
|
|
324
|
+
throw new InconsistentReallocationPenaltyError({
|
|
325
|
+
vault: reallocation.vault,
|
|
326
|
+
expected: expectedPenalty,
|
|
327
|
+
actual: reallocation.penalty,
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
penaltyByVault.set(penaltyKey, reallocation.penalty);
|
|
331
|
+
if (sourceMarketId !== undefined &&
|
|
332
|
+
compareMarketIds(sourceMarketId, targetMarketId) === 0) {
|
|
333
|
+
throw new ReallocationWithdrawalOnTargetMarketError(reallocation.vault, sourceMarketId);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
/**
|
|
338
|
+
* Validates and normalizes a homogeneous Blue reallocation plan.
|
|
339
|
+
*
|
|
340
|
+
* @param params - Validation parameters.
|
|
341
|
+
* @param params.reallocations - Optional Vault V1 or Vault V2 reallocation plan.
|
|
342
|
+
* @param params.targetMarketId - Morpho Blue market receiving the liquidity.
|
|
343
|
+
* @param params.chainId - Chain whose allocator deployment is required for a V2 plan.
|
|
344
|
+
* @returns The validated plan tagged with its allocator version.
|
|
345
|
+
* @throws {BundlerErrors.UnexpectedAction} when a V2 plan is unsupported on the chain.
|
|
346
|
+
* @internal
|
|
347
|
+
*/
|
|
348
|
+
export const validateAndNormalizeReallocations = ({ reallocations, targetMarketId, chainId, }) => {
|
|
349
|
+
const vaultV1Reallocations = [];
|
|
350
|
+
const vaultV2Reallocations = [];
|
|
351
|
+
for (const reallocation of reallocations ?? []) {
|
|
352
|
+
if (typeof reallocation !== "object" || reallocation === null) {
|
|
353
|
+
throw new InvalidReallocationShapeError();
|
|
354
|
+
}
|
|
355
|
+
if ("from" in reallocation === "withdrawals" in reallocation) {
|
|
356
|
+
throw new InvalidReallocationShapeError();
|
|
357
|
+
}
|
|
358
|
+
if ("withdrawals" in reallocation) {
|
|
359
|
+
vaultV1Reallocations.push(reallocation);
|
|
360
|
+
}
|
|
361
|
+
else {
|
|
362
|
+
vaultV2Reallocations.push(reallocation);
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
if (vaultV1Reallocations.length > 0 && vaultV2Reallocations.length > 0) {
|
|
366
|
+
throw new MixedReallocationVersionsError();
|
|
367
|
+
}
|
|
368
|
+
if (vaultV2Reallocations.length > 0) {
|
|
369
|
+
validateVaultV2BlueReallocations(vaultV2Reallocations, targetMarketId);
|
|
370
|
+
if (getChainAddresses(chainId).vaultV2BluePublicAllocator == null) {
|
|
371
|
+
throw new BundlerErrors.UnexpectedAction(vaultV2Reallocations[0]?.from.type === "market"
|
|
372
|
+
? "vaultV2BluePublicAllocatorReallocate"
|
|
373
|
+
: "vaultV2BluePublicAllocatorAllocateFromIdle", chainId);
|
|
269
374
|
}
|
|
375
|
+
return {
|
|
376
|
+
type: "vaultV2Blue",
|
|
377
|
+
reallocations: vaultV2Reallocations,
|
|
378
|
+
};
|
|
270
379
|
}
|
|
380
|
+
validateReallocations(vaultV1Reallocations, targetMarketId);
|
|
381
|
+
return { type: "vaultV1", reallocations: vaultV1Reallocations };
|
|
271
382
|
};
|
|
272
383
|
/**
|
|
273
384
|
* Validates that a slippage tolerance is within an acceptable range.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ecrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CBP, COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH, MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE, MAX_OFFER_CAP, MAX_SETTLEMENT_FEES, MAX_TICK, OFFER_TYPEHASH, PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CBP, COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH, MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE, MAX_OFFER_CAP, MAX_SETTLEMENT_FEES, MAX_TICK, OFFER_TYPEHASH, PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export type { BuildOfferParams, CollateralParams, GroupInput, IAccrualPosition, ICollateralParams, IGroup, IMarket, IMarketParams, IOffer, IPosition, MarketInput, OfferStruct, RatifierTreeInput, SettlementFeeCbps, TreeCreateParams, TreeDescriptor, TreeInput, TreeLike, TreeMempoolValidateParams, TreeMempoolValidateRatification, TreeProof, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { AccrualPosition, Group, Market, MarketParams, Offer, Position, Tree, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { AccrualPosition, Group, Market, MarketParams, Offer, Position, Tree, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fetchAccrualPosition, fetchMarket, fetchMarketParams, fetchPosition, fetchRatifierInfo, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { fetchAccrualPosition, fetchMarket, fetchMarketParams, fetchPosition, fetchRatifierInfo, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { BuildFixedRateOfferChainParams, DecodedEcrecoverRatifierData, DecodedSetterRatifierData, DeploylessFetchParameters, EcrecoverRatificationTypedData, EcrecoverRatifierDataDigestParams, EcrecoverRatifierDataParams, EcrecoverRatifierDataVerificationParams, EcrecoverRatifierRatifyParams, EcrecoverRatifierRootDigestParams, EcrecoverRatifierTypedDataParams, EcrecoverSignatureInput, FixedRateOfferChainLeg, GetRatifierInfoParams, MidnightCallParameters, MidnightFetchParams, RatifierInfo, SetterRatifierDataParams, SetterRatifierDataVerificationParams, VerifiedEcrecoverRatifierData, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { EcrecoverRatifierUtils, eip712Digest, GroupUtils, MarketUtils, OfferChainUtils, OfferUtils, Payload, PositionUtils, RatifierUtils, SetterRatifierUtils, TakeAmountsLib, TickLib, TreeUtils, } from "@morpho-org/midnight-sdk";
|
|
@@ -115,7 +115,10 @@ export interface BlueWithdrawAction extends BaseAction<"blueWithdraw", {
|
|
|
115
115
|
shares: bigint;
|
|
116
116
|
receiver: Address;
|
|
117
117
|
minSharePrice: bigint;
|
|
118
|
+
/** Native-token fees paid to PublicAllocator V1. */
|
|
118
119
|
reallocationFee: bigint;
|
|
120
|
+
/** Loan-token assets donated as BluePublicAllocator V2 penalties. */
|
|
121
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
119
122
|
}> {
|
|
120
123
|
}
|
|
121
124
|
export interface BlueSupplyCollateralAction extends BaseAction<"blueSupplyCollateral", {
|
|
@@ -130,7 +133,10 @@ export interface BlueBorrowAction extends BaseAction<"blueBorrow", {
|
|
|
130
133
|
amount: bigint;
|
|
131
134
|
receiver: Address;
|
|
132
135
|
minSharePrice: bigint;
|
|
136
|
+
/** Native-token fees paid to PublicAllocator V1. */
|
|
133
137
|
reallocationFee: bigint;
|
|
138
|
+
/** Loan-token assets donated as BluePublicAllocator V2 penalties. */
|
|
139
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
134
140
|
}> {
|
|
135
141
|
}
|
|
136
142
|
export interface BlueSupplyCollateralBorrowAction extends BaseAction<"blueSupplyCollateralBorrow", {
|
|
@@ -141,7 +147,10 @@ export interface BlueSupplyCollateralBorrowAction extends BaseAction<"blueSupply
|
|
|
141
147
|
onBehalf: Address;
|
|
142
148
|
receiver: Address;
|
|
143
149
|
nativeAmount?: bigint;
|
|
150
|
+
/** Native-token fees paid to PublicAllocator V1. */
|
|
144
151
|
reallocationFee: bigint;
|
|
152
|
+
/** Loan-token assets donated as BluePublicAllocator V2 penalties. */
|
|
153
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
145
154
|
}> {
|
|
146
155
|
}
|
|
147
156
|
export interface BlueRepayAction extends BaseAction<"blueRepay", {
|
|
@@ -185,7 +194,10 @@ export interface BlueRefinanceAction extends BaseAction<"blueRefinance", {
|
|
|
185
194
|
readonly minBorrowSharePrice: bigint;
|
|
186
195
|
readonly maxRepaySharePrice: bigint;
|
|
187
196
|
readonly user: Address;
|
|
197
|
+
/** Native-token fees paid to PublicAllocator V1. */
|
|
188
198
|
readonly reallocationFee: bigint;
|
|
199
|
+
/** Loan-token assets donated as BluePublicAllocator V2 penalties. */
|
|
200
|
+
readonly reallocationPenaltyAssets: bigint;
|
|
189
201
|
}> {
|
|
190
202
|
}
|
|
191
203
|
/**
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MarketId, UnknownDataError } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type { Address } from "viem";
|
|
2
|
+
import type { Address, Hash } from "viem";
|
|
3
3
|
/**
|
|
4
4
|
* Thrown when a morpho-sdk input that must be non-negative is negative.
|
|
5
5
|
*
|
|
@@ -44,6 +44,26 @@ export declare class NonPositiveInputError extends Error {
|
|
|
44
44
|
*/
|
|
45
45
|
constructor(field: string, value: bigint);
|
|
46
46
|
}
|
|
47
|
+
/** Thrown when an integer input exceeds its protocol-defined maximum. */
|
|
48
|
+
export declare class InputExceedsMaxError extends Error {
|
|
49
|
+
/**
|
|
50
|
+
* @param params - Maximum-bound validation details.
|
|
51
|
+
* @param params.field - Public input field whose value is invalid.
|
|
52
|
+
* @param params.value - Supplied value.
|
|
53
|
+
* @param params.max - Largest accepted value.
|
|
54
|
+
*/
|
|
55
|
+
constructor(params: {
|
|
56
|
+
readonly field: string;
|
|
57
|
+
readonly value: bigint;
|
|
58
|
+
readonly max: bigint;
|
|
59
|
+
});
|
|
60
|
+
/** Public input field whose value is invalid. */
|
|
61
|
+
readonly field: string;
|
|
62
|
+
/** Supplied value. */
|
|
63
|
+
readonly value: bigint;
|
|
64
|
+
/** Largest accepted value. */
|
|
65
|
+
readonly max: bigint;
|
|
66
|
+
}
|
|
47
67
|
/** Thrown when an in-kind redemption does not include any Morpho Blue market parameters. */
|
|
48
68
|
export declare class EmptyMarketParamsListError extends Error {
|
|
49
69
|
constructor();
|
|
@@ -333,6 +353,26 @@ export declare namespace BundlerErrors {
|
|
|
333
353
|
*/
|
|
334
354
|
constructor(authorized: Address);
|
|
335
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Thrown when a skippable Blue Public Allocator call would leave a usable
|
|
358
|
+
* token allowance behind after the allocator call reverts.
|
|
359
|
+
*
|
|
360
|
+
* @example
|
|
361
|
+
* ```ts
|
|
362
|
+
* import { BundlerErrors } from "@morpho-org/morpho-sdk";
|
|
363
|
+
*
|
|
364
|
+
* if (error instanceof BundlerErrors.SkippableAllocatorPenalty) {
|
|
365
|
+
* // Rebuild the allocator call with skipRevert set to false.
|
|
366
|
+
* }
|
|
367
|
+
* ```
|
|
368
|
+
*/
|
|
369
|
+
class SkippableAllocatorPenalty extends Error {
|
|
370
|
+
readonly penaltyAssets: bigint;
|
|
371
|
+
/**
|
|
372
|
+
* @param penaltyAssets - Exact token amount approved to the allocator.
|
|
373
|
+
*/
|
|
374
|
+
constructor(penaltyAssets: bigint);
|
|
375
|
+
}
|
|
336
376
|
}
|
|
337
377
|
/** Requirement signature kind accepted by action-output transaction builders. */
|
|
338
378
|
export type RequirementSignatureKind = "permit" | "authorization" | "midnightOfferRootSignature";
|
|
@@ -488,10 +528,115 @@ export declare class AccrualPositionUserMismatchError extends Error {
|
|
|
488
528
|
export declare class EmptyReallocationWithdrawalsError extends Error {
|
|
489
529
|
constructor(vault: string);
|
|
490
530
|
}
|
|
491
|
-
/** Thrown when a
|
|
531
|
+
/** Thrown when a Public Allocator source references the target Blue market. */
|
|
492
532
|
export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
493
533
|
constructor(vault: string, marketId: string);
|
|
494
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Thrown when a Public Allocator reallocation does not match exactly one V1 or
|
|
537
|
+
* V2 input shape.
|
|
538
|
+
*
|
|
539
|
+
* @example
|
|
540
|
+
* ```ts
|
|
541
|
+
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
542
|
+
*
|
|
543
|
+
* const error = new InvalidReallocationShapeError();
|
|
544
|
+
* ```
|
|
545
|
+
*/
|
|
546
|
+
export declare class InvalidReallocationShapeError extends Error {
|
|
547
|
+
constructor();
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Thrown when one reallocation plan contains both Vault V1 and Vault V2 entries.
|
|
551
|
+
*
|
|
552
|
+
* @example
|
|
553
|
+
* ```ts
|
|
554
|
+
* import { MixedReallocationVersionsError } from "@morpho-org/morpho-sdk";
|
|
555
|
+
*
|
|
556
|
+
* const error = new MixedReallocationVersionsError();
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
export declare class MixedReallocationVersionsError extends Error {
|
|
560
|
+
constructor();
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* Thrown when a Blue Public Allocator reallocation contains a malformed vault
|
|
564
|
+
* or adapter address.
|
|
565
|
+
*
|
|
566
|
+
* @example
|
|
567
|
+
* ```ts
|
|
568
|
+
* import { InvalidReallocationAddressError } from "@morpho-org/morpho-sdk";
|
|
569
|
+
*
|
|
570
|
+
* const error = new InvalidReallocationAddressError("to.adapter");
|
|
571
|
+
* if (error instanceof InvalidReallocationAddressError) {
|
|
572
|
+
* console.error(error.field);
|
|
573
|
+
* }
|
|
574
|
+
* ```
|
|
575
|
+
*/
|
|
576
|
+
export declare class InvalidReallocationAddressError extends Error {
|
|
577
|
+
readonly field: "vault" | "from.adapter" | "to.adapter";
|
|
578
|
+
/**
|
|
579
|
+
* @param field - Reallocation address field that is absent or malformed.
|
|
580
|
+
*/
|
|
581
|
+
constructor(field: "vault" | "from.adapter" | "to.adapter");
|
|
582
|
+
}
|
|
583
|
+
/**
|
|
584
|
+
* Thrown when a Blue Public Allocator source is absent, incomplete, or has an
|
|
585
|
+
* unknown discriminator.
|
|
586
|
+
*
|
|
587
|
+
* @example
|
|
588
|
+
* ```ts
|
|
589
|
+
* import { InvalidReallocationSourceTypeError } from "@morpho-org/morpho-sdk";
|
|
590
|
+
*
|
|
591
|
+
* const error = new InvalidReallocationSourceTypeError("marketTypo");
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
594
|
+
export declare class InvalidReallocationSourceTypeError extends Error {
|
|
595
|
+
readonly sourceType: string | undefined;
|
|
596
|
+
readonly missingField?: "adapter" | "marketParams" | undefined;
|
|
597
|
+
/**
|
|
598
|
+
* @param sourceType - Invalid runtime value received for `reallocation.from.type`,
|
|
599
|
+
* or `undefined` when the source or discriminator is absent.
|
|
600
|
+
* @param missingField - Required market-source field that is absent or malformed.
|
|
601
|
+
*/
|
|
602
|
+
constructor(sourceType: string | undefined, missingField?: "adapter" | "marketParams" | undefined);
|
|
603
|
+
}
|
|
604
|
+
/**
|
|
605
|
+
* Thrown when one bundle assigns different penalty rates to the same Vault V2.
|
|
606
|
+
*
|
|
607
|
+
* @example
|
|
608
|
+
* ```ts
|
|
609
|
+
* import { InconsistentReallocationPenaltyError } from "@morpho-org/morpho-sdk";
|
|
610
|
+
* import type { Address } from "viem";
|
|
611
|
+
*
|
|
612
|
+
* const vaultFixture =
|
|
613
|
+
* "0x70997970C51812dc3A010C7d01b50e0d17dc79C8" satisfies Address;
|
|
614
|
+
* const error = new InconsistentReallocationPenaltyError({
|
|
615
|
+
* vault: vaultFixture,
|
|
616
|
+
* expected: 5n,
|
|
617
|
+
* actual: 11n,
|
|
618
|
+
* });
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
621
|
+
export declare class InconsistentReallocationPenaltyError extends Error {
|
|
622
|
+
/** Vault whose configured penalty must be reused. */
|
|
623
|
+
readonly vault: Address;
|
|
624
|
+
/** Penalty rate established by the first matching bundle entry. */
|
|
625
|
+
readonly expected: bigint;
|
|
626
|
+
/** Conflicting penalty rate supplied by a later bundle entry. */
|
|
627
|
+
readonly actual: bigint;
|
|
628
|
+
/**
|
|
629
|
+
* @param params - Conflicting vault penalty details.
|
|
630
|
+
* @param params.vault - Vault whose configured penalty applies.
|
|
631
|
+
* @param params.expected - Penalty rate established by the first matching entry.
|
|
632
|
+
* @param params.actual - Conflicting penalty rate supplied by a later entry.
|
|
633
|
+
*/
|
|
634
|
+
constructor(params: {
|
|
635
|
+
readonly vault: Address;
|
|
636
|
+
readonly expected: bigint;
|
|
637
|
+
readonly actual: bigint;
|
|
638
|
+
});
|
|
639
|
+
}
|
|
495
640
|
/** Thrown when reallocation withdrawals within a vault are not strictly sorted by market id. */
|
|
496
641
|
export declare class UnsortedReallocationWithdrawalsError extends Error {
|
|
497
642
|
constructor(vault: string, marketId: string);
|
|
@@ -563,8 +708,8 @@ export declare class DisabledReallocationMarketError extends Error {
|
|
|
563
708
|
constructor(vault: Address, marketId: MarketId);
|
|
564
709
|
}
|
|
565
710
|
/**
|
|
566
|
-
* Thrown when shared liquidity selected by
|
|
567
|
-
* the operation's absolute shortfall on the target market — the resulting
|
|
711
|
+
* Thrown when shared liquidity selected by a Vault V1 or Vault V2 reallocation planner cannot
|
|
712
|
+
* cover the operation's absolute shortfall on the target market — the resulting
|
|
568
713
|
* `morphoBorrow` or `morphoWithdraw` would still revert onchain.
|
|
569
714
|
*
|
|
570
715
|
* Pattern-match on the class and inspect `params` to surface the gap to users.
|
|
@@ -617,6 +762,80 @@ export declare class UnknownReallocationPositionError extends UnknownDataError {
|
|
|
617
762
|
*/
|
|
618
763
|
constructor(user: Address, marketId: MarketId);
|
|
619
764
|
}
|
|
765
|
+
/** Thrown when Vault V2 reallocation state does not contain a requested allocation id. */
|
|
766
|
+
export declare class UnknownReallocationAllocationError extends UnknownDataError {
|
|
767
|
+
readonly vault: Address;
|
|
768
|
+
readonly id: Hash;
|
|
769
|
+
/**
|
|
770
|
+
* @param vault - Vault V2 address for the missing allocation.
|
|
771
|
+
* @param id - Missing Vault V2 allocation id.
|
|
772
|
+
*/
|
|
773
|
+
constructor(vault: Address, id: Hash);
|
|
774
|
+
}
|
|
775
|
+
/** Thrown when Vault V2 reallocation state lacks the vault-wide allocator configuration. */
|
|
776
|
+
export declare class UnknownReallocationPublicAllocatorConfigError extends UnknownDataError {
|
|
777
|
+
readonly vault: Address;
|
|
778
|
+
/** @param vault - Vault V2 address with missing allocator configuration. */
|
|
779
|
+
constructor(vault: Address);
|
|
780
|
+
}
|
|
781
|
+
/** Thrown when Vault V2 reallocation state lacks the fetched active-adapter set. */
|
|
782
|
+
export declare class UnknownReallocationActiveAdaptersError extends UnknownDataError {
|
|
783
|
+
readonly vault: Address;
|
|
784
|
+
/** @param vault - Vault V2 address with missing active-adapter state. */
|
|
785
|
+
constructor(vault: Address);
|
|
786
|
+
}
|
|
787
|
+
/** Thrown when Vault V2 reallocation state lacks an adapter-market allocator configuration. */
|
|
788
|
+
export declare class UnknownReallocationMarketPublicAllocatorConfigError extends UnknownDataError {
|
|
789
|
+
readonly vault: Address;
|
|
790
|
+
readonly adapterMarketCapId: Hash;
|
|
791
|
+
/**
|
|
792
|
+
* @param vault - Vault V2 address for the missing configuration.
|
|
793
|
+
* @param adapterMarketCapId - Missing adapter-scoped market cap id.
|
|
794
|
+
*/
|
|
795
|
+
constructor(vault: Address, adapterMarketCapId: Hash);
|
|
796
|
+
}
|
|
797
|
+
/** Thrown when Vault V2 reallocation state does not contain a requested adapter. */
|
|
798
|
+
export declare class UnknownReallocationAdapterError extends UnknownDataError {
|
|
799
|
+
readonly vault: Address;
|
|
800
|
+
readonly adapter: Address;
|
|
801
|
+
/**
|
|
802
|
+
* @param vault - Vault V2 address expected to own the adapter.
|
|
803
|
+
* @param adapter - Missing adapter address.
|
|
804
|
+
*/
|
|
805
|
+
constructor(vault: Address, adapter: Address);
|
|
806
|
+
}
|
|
807
|
+
/** Thrown when a simulated Vault V2 allocation transition would underflow. */
|
|
808
|
+
export declare class ReallocationAllocationUnderflowError extends Error {
|
|
809
|
+
readonly params: {
|
|
810
|
+
readonly vault: Address;
|
|
811
|
+
readonly id: Hash;
|
|
812
|
+
readonly allocation: bigint;
|
|
813
|
+
readonly change: bigint;
|
|
814
|
+
};
|
|
815
|
+
constructor(params: {
|
|
816
|
+
readonly vault: Address;
|
|
817
|
+
readonly id: Hash;
|
|
818
|
+
readonly allocation: bigint;
|
|
819
|
+
readonly change: bigint;
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
/** Thrown when a simulated Vault V2 market withdrawal exceeds the adapter's supply shares. */
|
|
823
|
+
export declare class ReallocationAdapterSupplySharesUnderflowError extends Error {
|
|
824
|
+
readonly params: {
|
|
825
|
+
readonly vault: Address;
|
|
826
|
+
readonly adapter: Address;
|
|
827
|
+
readonly marketId: MarketId;
|
|
828
|
+
readonly supplyShares: bigint;
|
|
829
|
+
readonly withdrawnShares: bigint;
|
|
830
|
+
};
|
|
831
|
+
constructor(params: {
|
|
832
|
+
readonly vault: Address;
|
|
833
|
+
readonly adapter: Address;
|
|
834
|
+
readonly marketId: MarketId;
|
|
835
|
+
readonly supplyShares: bigint;
|
|
836
|
+
readonly withdrawnShares: bigint;
|
|
837
|
+
});
|
|
838
|
+
}
|
|
620
839
|
/** Thrown when a Midnight amount exceeds the maximum offer-cap value accepted onchain. */
|
|
621
840
|
export declare class MidnightAmountExceedsMaxOfferCapError extends Error {
|
|
622
841
|
constructor(params: {
|
|
@@ -769,7 +988,7 @@ export declare class WithdrawSharesExceedSupplyError extends Error {
|
|
|
769
988
|
});
|
|
770
989
|
}
|
|
771
990
|
/**
|
|
772
|
-
* Thrown when
|
|
991
|
+
* Thrown when a Vault V1 or Vault V2 reallocation planner receives a withdraw `amount` greater
|
|
773
992
|
* than the target market's current `totalSupplyAssets` — the post-withdraw
|
|
774
993
|
* supply would be negative, making the on-chain `morphoWithdraw` revert
|
|
775
994
|
* regardless of any reallocation. Caught here so callers do not pay
|