@morpho-org/morpho-sdk 10.5.0-next.0 → 10.5.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/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +16 -11
- package/lib/cjs/actions/midnight/takeBorrow.js +14 -8
- package/lib/cjs/actions/midnight/takeLend.js +15 -9
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
- package/lib/cjs/actions/midnight/takeWithdraw.js +14 -8
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -2
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +6 -0
- package/lib/cjs/entities/midnight/midnight.js +21 -2
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -39
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +2 -6
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +5 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +7 -0
- package/lib/cjs/helpers/constant.js +8 -1
- package/lib/cjs/helpers/deadShares.js +0 -3
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/validate.d.ts +14 -0
- package/lib/cjs/helpers/validate.js +25 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +4 -0
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +8 -2
- package/lib/cjs/types/error.d.ts +25 -0
- package/lib/cjs/types/error.js +29 -1
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +16 -11
- package/lib/esm/actions/midnight/takeBorrow.js +14 -8
- package/lib/esm/actions/midnight/takeLend.js +15 -9
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +19 -13
- package/lib/esm/actions/midnight/takeWithdraw.js +14 -8
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +6 -0
- package/lib/esm/entities/midnight/midnight.js +21 -2
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +2 -40
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -6
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/constant.d.ts +7 -0
- package/lib/esm/helpers/constant.js +7 -0
- package/lib/esm/helpers/deadShares.js +1 -4
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/validate.d.ts +14 -0
- package/lib/esm/helpers/validate.js +25 -2
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +4 -0
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +9 -3
- package/lib/esm/types/error.d.ts +25 -0
- package/lib/esm/types/error.js +27 -0
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +7 -7
|
@@ -1,2 +1 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
2
|
-
export { InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, } from "@morpho-org/morpho-ts";
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidRateRatifierV1RateError, InvalidRateRatifierV1TickError, InvalidRateRatifierV1TimeError, InvalidRatifierV1AddressError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, RateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.RatifierV1TakerNotAllowedError = exports.RateRatifierV1BoundOverflowError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidRatifierV1AddressError = exports.InvalidRateRatifierV1TimeError = exports.InvalidRateRatifierV1TickError = exports.InvalidRateRatifierV1RateError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.InvalidEcrecoverSignatureError = exports.ChainIdMismatchError = void 0;
|
|
4
4
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
5
|
Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
6
6
|
Object.defineProperty(exports, "InvalidEcrecoverSignatureError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureError; } });
|
|
@@ -10,6 +10,9 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
10
10
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
11
11
|
Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
12
12
|
Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
13
|
+
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
14
|
+
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
15
|
+
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
13
16
|
Object.defineProperty(exports, "InvalidRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
14
17
|
Object.defineProperty(exports, "InvalidRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
15
18
|
Object.defineProperty(exports, "InvalidRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -27,7 +30,3 @@ Object.defineProperty(exports, "RatifierV1TakerNotAllowedError", { enumerable: t
|
|
|
27
30
|
Object.defineProperty(exports, "SettlementFeeExceedsPriceError", { enumerable: true, get: function () { return midnight_sdk_1.SettlementFeeExceedsPriceError; } });
|
|
28
31
|
Object.defineProperty(exports, "TickOutOfRangeError", { enumerable: true, get: function () { return midnight_sdk_1.TickOutOfRangeError; } });
|
|
29
32
|
Object.defineProperty(exports, "UnknownCollateralIndexError", { enumerable: true, get: function () { return midnight_sdk_1.UnknownCollateralIndexError; } });
|
|
30
|
-
var morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
31
|
-
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
32
|
-
Object.defineProperty(exports, "InvalidPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
33
|
-
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
@@ -89,6 +89,8 @@ export interface MidnightTakeBorrowPlanParams extends Omit<IntentParams, "suppor
|
|
|
89
89
|
* @throws {InvalidMidnightPositionAccrualStateError} If the position's credit and fee snapshot cannot be accrued.
|
|
90
90
|
* @throws {MidnightTakeableOffersNotFillableError} If the supplied offers cannot be used.
|
|
91
91
|
* @throws {MidnightTakeTargetUnreachableError} If the supplied target and bounds cannot be met.
|
|
92
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} If `now` is not past maturity and expiry is less than
|
|
93
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the target.
|
|
92
94
|
* @throws {MissingContractCodeError} If either registered Midnight target has no deployed code.
|
|
93
95
|
* @throws {viem.BaseError} If an `eth_chainId` request or the authorization read fails.
|
|
94
96
|
* @example
|
|
@@ -225,6 +227,8 @@ export interface MidnightSupplyCollateralTakeBorrowPlanParams extends MidnightTa
|
|
|
225
227
|
* last loss factor; fetch the market and position at the same block.
|
|
226
228
|
* @throws {InvalidMidnightPositionAccrualStateError} If the position's credit and fee snapshot cannot be accrued.
|
|
227
229
|
* @throws {MidnightTakeableOffersNotFillableError} If the supplied offers cannot be used.
|
|
230
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} If `now` is not past maturity and expiry is less than
|
|
231
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the target.
|
|
228
232
|
* @throws {MissingContractCodeError} If either registered Midnight target has no deployed code.
|
|
229
233
|
* @throws {viem.BaseError} If an `eth_chainId` request, an allowance read or the authorization read fails.
|
|
230
234
|
* @example
|
|
@@ -92,6 +92,8 @@ const validation_js_2 = require("./validation.js");
|
|
|
92
92
|
* @throws {InvalidMidnightPositionAccrualStateError} If the position's credit and fee snapshot cannot be accrued.
|
|
93
93
|
* @throws {MidnightTakeableOffersNotFillableError} If the supplied offers cannot be used.
|
|
94
94
|
* @throws {MidnightTakeTargetUnreachableError} If the supplied target and bounds cannot be met.
|
|
95
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} If `now` is not past maturity and expiry is less than
|
|
96
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the target.
|
|
95
97
|
* @throws {MissingContractCodeError} If either registered Midnight target has no deployed code.
|
|
96
98
|
* @throws {viem.BaseError} If an `eth_chainId` request or the authorization read fails.
|
|
97
99
|
* @example
|
|
@@ -224,6 +226,8 @@ async function prepareMidnightTakeBorrow(client, params) {
|
|
|
224
226
|
* last loss factor; fetch the market and position at the same block.
|
|
225
227
|
* @throws {InvalidMidnightPositionAccrualStateError} If the position's credit and fee snapshot cannot be accrued.
|
|
226
228
|
* @throws {MidnightTakeableOffersNotFillableError} If the supplied offers cannot be used.
|
|
229
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} If `now` is not past maturity and expiry is less than
|
|
230
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the target.
|
|
227
231
|
* @throws {MissingContractCodeError} If either registered Midnight target has no deployed code.
|
|
228
232
|
* @throws {viem.BaseError} If an `eth_chainId` request, an allowance read or the authorization read fails.
|
|
229
233
|
* @example
|
|
@@ -363,7 +367,7 @@ async function prepareBorrow(client, { params, supply, }) {
|
|
|
363
367
|
: parsed.target.maxUnits,
|
|
364
368
|
});
|
|
365
369
|
const { credit } = new midnight_sdk_1.AccrualPosition(positionData, marketData).accrueInterest(blue_sdk_1.MathLib.max(now, positionData.lastAccrual));
|
|
366
|
-
const
|
|
370
|
+
const feasibility = {
|
|
367
371
|
side: "sell",
|
|
368
372
|
takeableOffers: parsed.takeableOffers,
|
|
369
373
|
accountAddress: account,
|
|
@@ -375,7 +379,9 @@ async function prepareBorrow(client, { params, supply, }) {
|
|
|
375
379
|
credit,
|
|
376
380
|
target: parsed.target,
|
|
377
381
|
increasesDebt: true,
|
|
378
|
-
}
|
|
382
|
+
};
|
|
383
|
+
const takeableOffers = (0, validateMidnightTakeFeasibility_js_1.validateMidnightTakeFeasibility)(feasibility);
|
|
384
|
+
(0, validate_js_1.validateMidnightBorrowMaturity)(feasibility);
|
|
379
385
|
const requirement = { chainId, account, bundle, pulls };
|
|
380
386
|
const [approvals, authorization] = await prepareBorrowRequirements(client, requirement);
|
|
381
387
|
const inputs = {
|
package/lib/cjs/types/error.d.ts
CHANGED
|
@@ -1328,6 +1328,31 @@ export declare class MidnightTakeDeadlineTooFarError extends Error {
|
|
|
1328
1328
|
readonly maxDeadline: bigint;
|
|
1329
1329
|
});
|
|
1330
1330
|
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Thrown when a Midnight borrow prepared at or before maturity could execute less than
|
|
1333
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, when unpaid debt becomes liquidatable.
|
|
1334
|
+
* Credit covering the target at preparation does not exempt the borrow, because the sell is not
|
|
1335
|
+
* reduce-only; sell credit only inside the window with `takeWithdraw`.
|
|
1336
|
+
*/
|
|
1337
|
+
export declare class MidnightBorrowTooCloseToMaturityError extends Error {
|
|
1338
|
+
/** Deadline supplied by the caller. */
|
|
1339
|
+
readonly deadline: bigint;
|
|
1340
|
+
/** Market maturity timestamp. */
|
|
1341
|
+
readonly maturity: bigint;
|
|
1342
|
+
/** Latest accepted deadline for this maturity. */
|
|
1343
|
+
readonly latestDeadline: bigint;
|
|
1344
|
+
/**
|
|
1345
|
+
* @param params - Supplied deadline, market maturity and latest accepted deadline.
|
|
1346
|
+
* @param params.deadline - Deadline supplied by the caller.
|
|
1347
|
+
* @param params.maturity - Market maturity timestamp.
|
|
1348
|
+
* @param params.latestDeadline - Latest accepted deadline for this maturity.
|
|
1349
|
+
*/
|
|
1350
|
+
constructor(params: {
|
|
1351
|
+
readonly deadline: bigint;
|
|
1352
|
+
readonly maturity: bigint;
|
|
1353
|
+
readonly latestDeadline: bigint;
|
|
1354
|
+
});
|
|
1355
|
+
}
|
|
1331
1356
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1332
1357
|
export declare class MidnightOfferMarketChainMismatchError extends Error {
|
|
1333
1358
|
constructor(params: {
|
package/lib/cjs/types/error.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DepositAmountMismatchError = exports.EmptyDeallocationsError = exports.ExcessiveSlippageToleranceError = exports.MissingAccrualPositionError = exports.UnsupportedMidnightAuthorizationTargetError = exports.UnsupportedErc20ApprovalSpenderError = exports.MissingClientPropertyError = exports.CryptoUnavailableError = exports.ChainIdMismatchError = exports.AddressMismatchError = exports.UnsupportedRequirementSignatureError = exports.UnexpectedRequirementSignatureError = exports.AmbiguousRequirementSignaturesError = exports.MaxRepayAssetsBelowRepayAssetsError = exports.ReallocationsRequireBorrowError = exports.UnsupportedAuthorizationOperatorError = exports.ReallocationLoanTokenMismatchError = exports.SameVaultMigrationError = exports.AmountAndSharesExclusiveError = exports.MixedBundlesFundingError = exports.MidnightReferralFeePctExceededError = exports.ReferralFeePctExceededError = exports.ReferralFeeRecipientMissingError = exports.NativeFundingAmountMismatchError = exports.NoUnusedPermit2NonceError = exports.Permit2SignatureTransferNonceAlreadyUsedError = exports.BundlesRequirementSignatureMismatchError = exports.BundlesPermitMismatchError = exports.VaultIsBlueFeeRecipientError = exports.VaultMorphoMismatchError = exports.InsufficientBlueBalanceForInKindRedeemError = exports.InKindRedeemCoverageError = exports.InKindRedeemZeroDeallocationError = exports.VaultV2ForceWithdrawFeeSharesExceedBurnError = exports.VaultV2ForceWithdrawSharePriceBelowFloorError = exports.VaultV2ForceWithdrawZeroSharePriceError = exports.VaultV2ForceWithdrawZeroWithdrawalError = exports.VaultV2ForceWithdrawCoverageError = exports.VaultV2UndecodableLiquidityDataError = exports.VaultV2UnsupportedLiquidityAdapterError = exports.VaultV2UnsupportedExitAdapterError = exports.AdapterNotPartOfVaultError = exports.VaultV2SingleAdapterRequiredError = exports.ExpiredDeadlineError = exports.EmptyMarketParamsListError = exports.InputExceedsMaxError = exports.InvalidMidnightNativeAmountTypeError = exports.InvalidBigIntInputError = exports.NonPositiveInputError = exports.NegativeInputError = void 0;
|
|
4
4
|
exports.MidnightZeroReceiverError = exports.MidnightRepayExceedsDebtError = exports.MidnightContinuousFeeAboveMaxError = exports.MidnightTakeTargetUnreachableError = exports.MidnightTakeableOffersNotFillableError = exports.UnboundedMidnightTakeInputError = exports.MidnightOfferSellerReceiverMismatchError = exports.MidnightOfferContinuousFeeCapError = exports.MidnightOfferMakerMismatchError = exports.MidnightOfferReduceOnlyError = exports.MidnightOfferSideMismatchError = exports.EmptyMidnightTakeableOffersError = exports.DuplicateMidnightGroupCancellationError = exports.DuplicateMidnightCollateralIndexError = exports.EmptyMidnightCollateralWithdrawalsError = exports.EmptyMidnightCollateralSuppliesError = exports.EmptyMidnightGroupCancellationsError = exports.ReallocationAdapterSupplySharesUnderflowError = exports.ReallocationAllocationUnderflowError = exports.UnknownReallocationAdapterError = exports.UnknownReallocationMarketPublicAllocatorConfigError = exports.UnknownReallocationActiveAdaptersError = exports.UnknownReallocationPublicAllocatorConfigError = exports.UnknownReallocationAllocationError = exports.UnknownReallocationVaultError = exports.UnknownReallocationMarketError = exports.InsufficientSharedLiquidityError = exports.RepaySharesExceedDebtError = exports.MalformedSignatureError = exports.InvalidSignatureError = exports.RepayExceedsDebtError = exports.WithdrawMakesPositionUnhealthyError = exports.WithdrawExceedsCollateralError = exports.MutuallyExclusiveRepayAmountsError = exports.InconsistentReallocationPenaltyError = exports.InvalidReallocationSourceTypeError = exports.InvalidReallocationAddressError = exports.InvalidVaultV2BlueReallocationShapeError = exports.ReallocationWithdrawalOnTargetMarketError = exports.AccrualPositionUserMismatchError = exports.MarketIdMismatchError = exports.MissingMarketPriceError = exports.BorrowExceedsSafeLtvError = exports.NativeAmountOnNonWNativeAssetError = exports.VaultAddressMismatchError = exports.ChainWNativeMissingError = exports.NativeAmountOnNonWNativeVaultError = exports.DepositSpenderMismatchError = exports.DepositOwnerMismatchError = exports.DepositAssetMismatchError = void 0;
|
|
5
|
-
exports.MidnightCalldataEncodingError = exports.MidnightZeroAccountError = exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.BlueBuyCallbackUnauthorizedError = exports.BlueBuyCallbackOwnerMismatchError = exports.NotBlueBuyCallbackError = exports.InsufficientBlueLiquidityError = exports.EmptyBlueSupplyPositionError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferZeroSellerReceiverError = exports.MidnightTakeableOfferMarketMismatchError = exports.MissingDeadSharesDataError = exports.InsufficientDeadSharesError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightContractReceiverError = exports.MidnightZeroOnBehalfError = void 0;
|
|
5
|
+
exports.MidnightCalldataEncodingError = exports.MidnightZeroAccountError = exports.MissingContractCodeError = exports.MidnightOfferNotReduceOnlyError = exports.RefinanceTokenMismatchError = exports.RefinanceSameMarketError = exports.VaultAssetMismatchError = exports.ReallocationWithdrawExceedsMarketSupplyError = exports.BlueBuyCallbackUnauthorizedError = exports.BlueBuyCallbackOwnerMismatchError = exports.NotBlueBuyCallbackError = exports.InsufficientBlueLiquidityError = exports.EmptyBlueSupplyPositionError = exports.WithdrawSharesExceedSupplyError = exports.WithdrawExceedsSupplyError = exports.MutuallyExclusiveWithdrawAmountsError = exports.MidnightInvalidAccountAddressError = exports.InvalidMidnightHexInputError = exports.InsufficientMidnightWithdrawableLiquidityError = exports.MidnightRedeemExceedsCreditError = exports.NoMidnightCreditToRedeemError = exports.MidnightReplacementGroupCancelledError = exports.MidnightOfferRatifierMismatchError = exports.MidnightTakeableOfferZeroSellerReceiverError = exports.MidnightTakeableOfferMarketMismatchError = exports.MissingDeadSharesDataError = exports.InsufficientDeadSharesError = exports.ZeroBlueParkingSharesError = exports.EmptyBlueParkingMarketError = exports.MidnightOfferCallbackDataMismatchError = exports.MidnightOfferCallbackMismatchError = exports.MidnightOfferMarketLoanTokenMismatchError = exports.MidnightMarketAddressMismatchError = exports.MidnightOfferMarketAddressMismatchError = exports.MidnightOfferMarketChainMismatchError = exports.MidnightBorrowTooCloseToMaturityError = exports.MidnightTakeDeadlineTooFarError = exports.MidnightContractReceiverError = exports.MidnightZeroOnBehalfError = void 0;
|
|
6
6
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
7
7
|
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
8
8
|
const constant_js_1 = require("../helpers/constant.js");
|
|
@@ -1738,6 +1738,34 @@ class MidnightTakeDeadlineTooFarError extends Error {
|
|
|
1738
1738
|
}
|
|
1739
1739
|
}
|
|
1740
1740
|
exports.MidnightTakeDeadlineTooFarError = MidnightTakeDeadlineTooFarError;
|
|
1741
|
+
/**
|
|
1742
|
+
* Thrown when a Midnight borrow prepared at or before maturity could execute less than
|
|
1743
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, when unpaid debt becomes liquidatable.
|
|
1744
|
+
* Credit covering the target at preparation does not exempt the borrow, because the sell is not
|
|
1745
|
+
* reduce-only; sell credit only inside the window with `takeWithdraw`.
|
|
1746
|
+
*/
|
|
1747
|
+
class MidnightBorrowTooCloseToMaturityError extends Error {
|
|
1748
|
+
/** Deadline supplied by the caller. */
|
|
1749
|
+
deadline;
|
|
1750
|
+
/** Market maturity timestamp. */
|
|
1751
|
+
maturity;
|
|
1752
|
+
/** Latest accepted deadline for this maturity. */
|
|
1753
|
+
latestDeadline;
|
|
1754
|
+
/**
|
|
1755
|
+
* @param params - Supplied deadline, market maturity and latest accepted deadline.
|
|
1756
|
+
* @param params.deadline - Deadline supplied by the caller.
|
|
1757
|
+
* @param params.maturity - Market maturity timestamp.
|
|
1758
|
+
* @param params.latestDeadline - Latest accepted deadline for this maturity.
|
|
1759
|
+
*/
|
|
1760
|
+
constructor(params) {
|
|
1761
|
+
super(`Midnight borrow deadline "${params.deadline}" is less than two hours before market maturity "${params.maturity}", when unpaid debt becomes liquidatable. Borrow on a later maturity, sell credit only with takeWithdraw, or, while "${params.latestDeadline}" is still in the future, use a deadline no later than it.`);
|
|
1762
|
+
this.deadline = params.deadline;
|
|
1763
|
+
this.maturity = params.maturity;
|
|
1764
|
+
this.latestDeadline = params.latestDeadline;
|
|
1765
|
+
this.name = "MidnightBorrowTooCloseToMaturityError";
|
|
1766
|
+
}
|
|
1767
|
+
}
|
|
1768
|
+
exports.MidnightBorrowTooCloseToMaturityError = MidnightBorrowTooCloseToMaturityError;
|
|
1741
1769
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1742
1770
|
class MidnightOfferMarketChainMismatchError extends Error {
|
|
1743
1771
|
constructor(params) {
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
|
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
-
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils,
|
|
6
|
+
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
8
8
|
export { EcrecoverRatifier as MidnightEcrecoverRatifier,
|
|
9
9
|
/** @deprecated Use MidnightEcrecoverRatifier with a tagged tree. */
|
|
@@ -17,7 +17,7 @@ RatifierUtils as MidnightRatifierUtils, SetterRatifier as MidnightSetterRatifier
|
|
|
17
17
|
/** @deprecated Use MidnightSetterRatifier with a tagged tree. */
|
|
18
18
|
SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
|
|
19
19
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
|
|
20
|
-
export { bigIntComparator, createGetValue, createHasValue, deepFreeze, entries, filterDefined, fromEntries, getLast, getLastDefined, getSubdomainBaseUrl, getValue, hasValue, isDefined, isNotNull, isNotUndefined, keys,
|
|
20
|
+
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";
|
|
21
21
|
export { validateClientChainId } from "./actions/requirements/validateClientChainId.js";
|
|
22
22
|
export { addTransactionMetadata } from "./helpers/metadata.js";
|
|
23
23
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./helpers/previewVaultV2ForceWithdraw.js";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.
|
|
4
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.
|
|
3
|
+
exports.createHasValue = exports.createGetValue = exports.bigIntComparator = exports.MidnightTreeUtils = exports.MidnightTickLib = exports.MidnightTakeAmountsLib = exports.MidnightSetterRatifierUtils = exports.MidnightSetterRatifier = exports.MidnightRatifierUtils = exports.MidnightRatifier = exports.MidnightRateRatifierV1Utils = exports.MidnightRateRatifierV1 = exports.MidnightPriceRatifierV1Utils = exports.MidnightPriceRatifierV1 = exports.MidnightPositionUtils = exports.MidnightPayload = exports.MidnightOfferUtils = exports.MidnightOfferChainUtils = exports.MidnightMarketUtils = exports.MidnightGroupUtils = exports.eip712Digest = exports.MidnightEcrecoverRatifierUtils = exports.MidnightEcrecoverRatifier = exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.BlueMetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getBlueAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.BlueSharesMath = exports.MathLib = exports.BlueMarketUtils = exports.getBlueDefaultPreLiquidationParams = exports.blueDefaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.BlueAdaptiveCurveIrmLib = void 0;
|
|
4
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateChainId = exports.validateAccrualPosition = exports.computeMinForceWithdrawSharePrice = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateClientChainId = exports.values = exports.transformValue = exports.Time = exports.retryPromiseLinearBackoff = exports.mergeEntries = exports.keys = exports.isNotUndefined = exports.isNotNull = exports.isDefined = exports.hasValue = exports.getValue = exports.getSubdomainBaseUrl = exports.getLastDefined = exports.getLast = exports.fromEntries = exports.filterDefined = exports.entries = exports.deepFreeze = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
7
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "BlueSharesMath", { enumerable: true, get: functi
|
|
|
15
15
|
Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
|
|
16
16
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
|
|
17
17
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
|
|
18
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapterUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapterUtils; } });
|
|
19
18
|
Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
|
|
20
19
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
21
20
|
Object.defineProperty(exports, "catchRevertOnly", { enumerable: true, get: function () { return blue_sdk_viem_1.catchRevertOnly; } });
|
|
@@ -77,7 +76,6 @@ Object.defineProperty(exports, "isDefined", { enumerable: true, get: function ()
|
|
|
77
76
|
Object.defineProperty(exports, "isNotNull", { enumerable: true, get: function () { return morpho_ts_1.isNotNull; } });
|
|
78
77
|
Object.defineProperty(exports, "isNotUndefined", { enumerable: true, get: function () { return morpho_ts_1.isNotUndefined; } });
|
|
79
78
|
Object.defineProperty(exports, "keys", { enumerable: true, get: function () { return morpho_ts_1.keys; } });
|
|
80
|
-
Object.defineProperty(exports, "MidnightPositionLib", { enumerable: true, get: function () { return morpho_ts_1.MidnightPositionLib; } });
|
|
81
79
|
Object.defineProperty(exports, "mergeEntries", { enumerable: true, get: function () { return morpho_ts_1.mergeEntries; } });
|
|
82
80
|
Object.defineProperty(exports, "retryPromiseLinearBackoff", { enumerable: true, get: function () { return morpho_ts_1.retryPromiseLinearBackoff; } });
|
|
83
81
|
Object.defineProperty(exports, "Time", { enumerable: true, get: function () { return morpho_ts_1.Time; } });
|
package/lib/cjs/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Installed @morpho-org/morpho-sdk package version. */
|
|
2
|
-
export declare const version = "10.5.0
|
|
2
|
+
export declare const version = "10.5.0";
|
package/lib/cjs/version.js
CHANGED
package/lib/esm/abis.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const bundlesPermitParameters: {
|
|
|
33
33
|
}];
|
|
34
34
|
};
|
|
35
35
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
36
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
36
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
37
37
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
38
38
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
39
39
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/esm/abis.js
CHANGED
|
@@ -19,7 +19,7 @@ export const bundlesPermitParameters = {
|
|
|
19
19
|
],
|
|
20
20
|
};
|
|
21
21
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
22
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
22
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
23
23
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
24
24
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
25
25
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
@@ -97,31 +97,31 @@ export const midnightSupplyCollateralTakeBorrow = (params) => encodeMidnightSupp
|
|
|
97
97
|
const parsedSupplyCollateralTakeBorrow = Symbol();
|
|
98
98
|
/** Parses the static SupplyCollateralTakeBorrow constraints in the standalone builder's existing order. @internal */
|
|
99
99
|
export const parseMidnightSupplyCollateralTakeBorrow = (params) => {
|
|
100
|
+
const { market, target, takeableOffers } = params;
|
|
100
101
|
// Reject markets from another chain deployment before checking offers against them.
|
|
101
|
-
validateMidnightMarket({ market
|
|
102
|
+
validateMidnightMarket({ market, chainId: params.chainId });
|
|
102
103
|
if (params.collateralSupplies.length === 0) {
|
|
103
104
|
throw new EmptyMidnightCollateralSuppliesError();
|
|
104
105
|
}
|
|
105
106
|
// Validation only; retain main's canonical per-entry and per-index collateral checks.
|
|
106
107
|
validateMidnightCollateralSupplies({
|
|
107
|
-
market
|
|
108
|
+
market,
|
|
108
109
|
field: "collateralSupplies",
|
|
109
110
|
supplies: params.collateralSupplies,
|
|
110
111
|
});
|
|
111
112
|
const marketId = validateTakeableOffers({
|
|
112
|
-
market
|
|
113
|
-
takeableOffers
|
|
113
|
+
market,
|
|
114
|
+
takeableOffers,
|
|
114
115
|
expectedBuy: true,
|
|
115
116
|
});
|
|
116
|
-
validateMidnightTakeableOfferBounds(
|
|
117
|
+
validateMidnightTakeableOfferBounds(takeableOffers);
|
|
117
118
|
// Rejects receivers that would strand the borrowed assets in a contract.
|
|
118
119
|
validateMidnightReceiver({
|
|
119
120
|
chainId: params.chainId,
|
|
120
|
-
market
|
|
121
|
+
market,
|
|
121
122
|
field: "receiver",
|
|
122
123
|
receiver: params.receiver,
|
|
123
124
|
});
|
|
124
|
-
const { target } = params;
|
|
125
125
|
switch (target.type) {
|
|
126
126
|
case "assets": {
|
|
127
127
|
// Validation only; rejects non-positive amounts.
|
|
@@ -161,7 +161,7 @@ export const parseMidnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
161
161
|
// Rejects fee recipients that would strand the fee in a contract.
|
|
162
162
|
validateMidnightReceiver({
|
|
163
163
|
chainId: params.chainId,
|
|
164
|
-
market
|
|
164
|
+
market,
|
|
165
165
|
field: "referralFeeRecipient",
|
|
166
166
|
receiver: referralFeeRecipient,
|
|
167
167
|
});
|
|
@@ -169,15 +169,20 @@ export const parseMidnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
169
169
|
const collateralSupplies = params.collateralSupplies.map(({ collateralIndex, assets }) => ({
|
|
170
170
|
collateralIndex,
|
|
171
171
|
assets,
|
|
172
|
-
token: MarketUtils.getCollateralByIndex(
|
|
173
|
-
.token,
|
|
172
|
+
token: MarketUtils.getCollateralByIndex(market, collateralIndex).token,
|
|
174
173
|
}));
|
|
175
174
|
const nativeFunding = parseMidnightNativeFunding({
|
|
176
175
|
chainId: params.chainId,
|
|
177
176
|
nativeAmount: params.nativeAmount,
|
|
178
177
|
pulls: collateralSupplies,
|
|
179
178
|
});
|
|
180
|
-
const snapshot = snapshotMidnightTakeParams({
|
|
179
|
+
const snapshot = snapshotMidnightTakeParams({
|
|
180
|
+
direction: "sell",
|
|
181
|
+
market,
|
|
182
|
+
target,
|
|
183
|
+
takeableOffers,
|
|
184
|
+
metadata: params.metadata,
|
|
185
|
+
});
|
|
181
186
|
return deepFreeze({
|
|
182
187
|
...snapshot,
|
|
183
188
|
chainId: params.chainId,
|
|
@@ -81,22 +81,22 @@ export const midnightTakeBorrow = (params) => encodeMidnightTakeBorrow(parseMidn
|
|
|
81
81
|
const parsedTakeBorrow = Symbol();
|
|
82
82
|
/** Parses the static TakeBorrow constraints in the standalone builder's existing order. @internal */
|
|
83
83
|
export const parseMidnightTakeBorrow = (params) => {
|
|
84
|
+
const { market, target, takeableOffers } = params;
|
|
84
85
|
// Reject markets from another chain deployment before checking offers against them.
|
|
85
|
-
validateMidnightMarket({ market
|
|
86
|
+
validateMidnightMarket({ market, chainId: params.chainId });
|
|
86
87
|
const marketId = validateTakeableOffers({
|
|
87
|
-
market
|
|
88
|
-
takeableOffers
|
|
88
|
+
market,
|
|
89
|
+
takeableOffers,
|
|
89
90
|
expectedBuy: true,
|
|
90
91
|
});
|
|
91
|
-
validateMidnightTakeableOfferBounds(
|
|
92
|
+
validateMidnightTakeableOfferBounds(takeableOffers);
|
|
92
93
|
// Rejects receivers that would strand the borrowed assets in a contract.
|
|
93
94
|
validateMidnightReceiver({
|
|
94
95
|
chainId: params.chainId,
|
|
95
|
-
market
|
|
96
|
+
market,
|
|
96
97
|
field: "receiver",
|
|
97
98
|
receiver: params.receiver,
|
|
98
99
|
});
|
|
99
|
-
const { target } = params;
|
|
100
100
|
switch (target.type) {
|
|
101
101
|
case "assets": {
|
|
102
102
|
// Validation only; rejects non-positive amounts.
|
|
@@ -136,12 +136,18 @@ export const parseMidnightTakeBorrow = (params) => {
|
|
|
136
136
|
// Rejects fee recipients that would strand the fee in a contract.
|
|
137
137
|
validateMidnightReceiver({
|
|
138
138
|
chainId: params.chainId,
|
|
139
|
-
market
|
|
139
|
+
market,
|
|
140
140
|
field: "referralFeeRecipient",
|
|
141
141
|
receiver: referralFeeRecipient,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
const snapshot = snapshotMidnightTakeParams({
|
|
144
|
+
const snapshot = snapshotMidnightTakeParams({
|
|
145
|
+
direction: "sell",
|
|
146
|
+
market,
|
|
147
|
+
target,
|
|
148
|
+
takeableOffers,
|
|
149
|
+
metadata: params.metadata,
|
|
150
|
+
});
|
|
145
151
|
return deepFreeze({
|
|
146
152
|
...snapshot,
|
|
147
153
|
chainId: params.chainId,
|
|
@@ -81,15 +81,15 @@ export const midnightTakeLend = (params) => encodeMidnightTakeLend(parseMidnight
|
|
|
81
81
|
const parsedTakeLend = Symbol();
|
|
82
82
|
/** Parses the static TakeLend constraints in the standalone builder's existing order. @internal */
|
|
83
83
|
export const parseMidnightTakeLend = (params) => {
|
|
84
|
+
const { market, target, takeableOffers } = params;
|
|
84
85
|
// Reject markets from another chain deployment before checking offers against them.
|
|
85
|
-
validateMidnightMarket({ market
|
|
86
|
+
validateMidnightMarket({ market, chainId: params.chainId });
|
|
86
87
|
const marketId = validateTakeableOffers({
|
|
87
|
-
market
|
|
88
|
-
takeableOffers
|
|
88
|
+
market,
|
|
89
|
+
takeableOffers,
|
|
89
90
|
expectedBuy: false,
|
|
90
91
|
});
|
|
91
|
-
validateMidnightTakeableOfferBounds(
|
|
92
|
-
const { target } = params;
|
|
92
|
+
validateMidnightTakeableOfferBounds(takeableOffers);
|
|
93
93
|
switch (target.type) {
|
|
94
94
|
case "assets": {
|
|
95
95
|
// Validation only; rejects non-positive amounts.
|
|
@@ -129,23 +129,29 @@ export const parseMidnightTakeLend = (params) => {
|
|
|
129
129
|
// Rejects fee recipients that would strand the fee in a contract.
|
|
130
130
|
validateMidnightReceiver({
|
|
131
131
|
chainId: params.chainId,
|
|
132
|
-
market
|
|
132
|
+
market,
|
|
133
133
|
field: "referralFeeRecipient",
|
|
134
134
|
receiver: referralFeeRecipient,
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
|
-
const
|
|
137
|
+
const marketStruct = MarketUtils.toStruct(market);
|
|
138
138
|
const nativeFunding = parseMidnightNativeFunding({
|
|
139
139
|
chainId: params.chainId,
|
|
140
140
|
nativeAmount: params.nativeAmount,
|
|
141
141
|
pulls: [
|
|
142
142
|
{
|
|
143
|
-
token:
|
|
143
|
+
token: marketStruct.loanToken,
|
|
144
144
|
assets: target.type === "assets" ? target.assets : target.maxBuyerAssets,
|
|
145
145
|
},
|
|
146
146
|
],
|
|
147
147
|
});
|
|
148
|
-
const snapshot = snapshotMidnightTakeParams({
|
|
148
|
+
const snapshot = snapshotMidnightTakeParams({
|
|
149
|
+
direction: "buy",
|
|
150
|
+
market,
|
|
151
|
+
target,
|
|
152
|
+
takeableOffers,
|
|
153
|
+
metadata: params.metadata,
|
|
154
|
+
});
|
|
149
155
|
return deepFreeze({
|
|
150
156
|
...snapshot,
|
|
151
157
|
chainId: params.chainId,
|
|
@@ -100,11 +100,12 @@ export const midnightTakeRepayWithdrawCollateral = (params) => encodeMidnightTak
|
|
|
100
100
|
const parsedTakeRepayWithdrawCollateral = Symbol();
|
|
101
101
|
/** Parses the static TakeRepayWithdrawCollateral constraints in the standalone builder's existing order. @internal */
|
|
102
102
|
export const parseMidnightTakeRepayWithdrawCollateral = (params) => {
|
|
103
|
-
|
|
104
|
-
|
|
103
|
+
const { market, target, takeableOffers } = params;
|
|
104
|
+
if (target.type === "assets" && target.assets <= 0n) {
|
|
105
|
+
throw new NonPositiveInputError("target.assets", target.assets);
|
|
105
106
|
}
|
|
106
107
|
// Reject markets from another chain deployment before checking offers against them.
|
|
107
|
-
validateMidnightMarket({ market
|
|
108
|
+
validateMidnightMarket({ market, chainId: params.chainId });
|
|
108
109
|
for (const [index, { collateralIndex, assets },] of params.collateralWithdrawals.entries()) {
|
|
109
110
|
// Validation only; rejects non-positive amounts.
|
|
110
111
|
validatePositiveInput(`collateralWithdrawals[${index}].assets`, assets);
|
|
@@ -112,25 +113,24 @@ export const parseMidnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
112
113
|
validateMidnightUint128Field(`collateralWithdrawals[${index}].assets`, assets);
|
|
113
114
|
}
|
|
114
115
|
// Throws UnknownCollateralIndexError when the index is not configured on the market.
|
|
115
|
-
MarketUtils.getCollateralByIndex(
|
|
116
|
+
MarketUtils.getCollateralByIndex(market, collateralIndex);
|
|
116
117
|
}
|
|
117
118
|
validateMidnightAddress("collateralReceiver", params.collateralReceiver);
|
|
118
119
|
if (params.collateralWithdrawals.length > 0) {
|
|
119
120
|
// Rejects receivers that would strand the withdrawn collateral in a contract.
|
|
120
121
|
validateMidnightReceiver({
|
|
121
122
|
chainId: params.chainId,
|
|
122
|
-
market
|
|
123
|
+
market,
|
|
123
124
|
field: "collateralReceiver",
|
|
124
125
|
receiver: params.collateralReceiver,
|
|
125
126
|
});
|
|
126
127
|
}
|
|
127
128
|
const marketId = validateTakeableOffers({
|
|
128
|
-
market
|
|
129
|
-
takeableOffers
|
|
129
|
+
market,
|
|
130
|
+
takeableOffers,
|
|
130
131
|
expectedBuy: false,
|
|
131
132
|
});
|
|
132
|
-
validateMidnightTakeableOfferBounds(
|
|
133
|
-
const { target } = params;
|
|
133
|
+
validateMidnightTakeableOfferBounds(takeableOffers);
|
|
134
134
|
switch (target.type) {
|
|
135
135
|
case "assets": {
|
|
136
136
|
// Validation only; rejects non-positive amounts.
|
|
@@ -164,23 +164,29 @@ export const parseMidnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
164
164
|
// Rejects fee recipients that would strand the fee in a contract.
|
|
165
165
|
validateMidnightReceiver({
|
|
166
166
|
chainId: params.chainId,
|
|
167
|
-
market
|
|
167
|
+
market,
|
|
168
168
|
field: "referralFeeRecipient",
|
|
169
169
|
receiver: referralFeeRecipient,
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
|
-
const
|
|
172
|
+
const marketStruct = MarketUtils.toStruct(market);
|
|
173
173
|
const nativeFunding = parseMidnightNativeFunding({
|
|
174
174
|
chainId: params.chainId,
|
|
175
175
|
nativeAmount: params.nativeAmount,
|
|
176
176
|
pulls: [
|
|
177
177
|
{
|
|
178
|
-
token:
|
|
178
|
+
token: marketStruct.loanToken,
|
|
179
179
|
assets: target.type === "assets" ? target.assets : target.maxBuyerAssets,
|
|
180
180
|
},
|
|
181
181
|
],
|
|
182
182
|
});
|
|
183
|
-
const snapshot = snapshotMidnightTakeParams({
|
|
183
|
+
const snapshot = snapshotMidnightTakeParams({
|
|
184
|
+
direction: "buy",
|
|
185
|
+
market,
|
|
186
|
+
target,
|
|
187
|
+
takeableOffers,
|
|
188
|
+
metadata: params.metadata,
|
|
189
|
+
});
|
|
184
190
|
return deepFreeze({
|
|
185
191
|
...snapshot,
|
|
186
192
|
chainId: params.chainId,
|
|
@@ -77,23 +77,23 @@ export const midnightTakeWithdraw = (params) => encodeMidnightTakeWithdraw(parse
|
|
|
77
77
|
const parsedTakeWithdraw = Symbol();
|
|
78
78
|
/** Parses the static TakeWithdraw constraints in the standalone builder's existing order. @internal */
|
|
79
79
|
export const parseMidnightTakeWithdraw = (params) => {
|
|
80
|
+
const { market, target, takeableOffers } = params;
|
|
80
81
|
// Reject markets from another chain deployment before checking offers against them.
|
|
81
|
-
validateMidnightMarket({ market
|
|
82
|
+
validateMidnightMarket({ market, chainId: params.chainId });
|
|
82
83
|
const marketId = validateTakeableOffers({
|
|
83
|
-
market
|
|
84
|
-
takeableOffers
|
|
84
|
+
market,
|
|
85
|
+
takeableOffers,
|
|
85
86
|
expectedBuy: true,
|
|
86
87
|
});
|
|
87
88
|
validateMidnightAddress("receiver", params.receiver);
|
|
88
|
-
validateMidnightTakeableOfferBounds(
|
|
89
|
+
validateMidnightTakeableOfferBounds(takeableOffers);
|
|
89
90
|
// Rejects receivers that would strand the withdrawn assets in a contract.
|
|
90
91
|
validateMidnightReceiver({
|
|
91
92
|
chainId: params.chainId,
|
|
92
|
-
market
|
|
93
|
+
market,
|
|
93
94
|
field: "receiver",
|
|
94
95
|
receiver: params.receiver,
|
|
95
96
|
});
|
|
96
|
-
const { target } = params;
|
|
97
97
|
switch (target.type) {
|
|
98
98
|
case "assets": {
|
|
99
99
|
// Validation only; preserve main's positive-target and finite-cap order.
|
|
@@ -131,12 +131,18 @@ export const parseMidnightTakeWithdraw = (params) => {
|
|
|
131
131
|
// Rejects fee recipients that would strand the fee in a contract.
|
|
132
132
|
validateMidnightReceiver({
|
|
133
133
|
chainId: params.chainId,
|
|
134
|
-
market
|
|
134
|
+
market,
|
|
135
135
|
field: "referralFeeRecipient",
|
|
136
136
|
receiver: referralFeeRecipient,
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
const snapshot = snapshotMidnightTakeParams({
|
|
139
|
+
const snapshot = snapshotMidnightTakeParams({
|
|
140
|
+
direction: "sell",
|
|
141
|
+
market,
|
|
142
|
+
target,
|
|
143
|
+
takeableOffers,
|
|
144
|
+
metadata: params.metadata,
|
|
145
|
+
});
|
|
140
146
|
return deepFreeze({
|
|
141
147
|
...snapshot,
|
|
142
148
|
chainId: params.chainId,
|
package/lib/esm/blue/abis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/esm/blue/abis.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|