@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
|
@@ -14,12 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.
|
|
17
|
+
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
|
|
18
18
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
19
19
|
Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
20
20
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
21
21
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
22
|
-
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
23
22
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
24
23
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
25
24
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -47,7 +46,6 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
47
46
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
48
47
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
49
48
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
50
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
51
49
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
52
50
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
53
51
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
@@ -293,6 +293,9 @@ export declare class MorphoMidnight {
|
|
|
293
293
|
* withdrawal.
|
|
294
294
|
* @throws {MidnightTakeTargetUnreachableError} when the live offers cannot hold the target, or
|
|
295
295
|
* its bounds cannot hold at any fill.
|
|
296
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} when `now` is not past maturity and `deadline` is less
|
|
297
|
+
* than `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the
|
|
298
|
+
* target; use `takeWithdraw` to sell credit only.
|
|
296
299
|
* @example
|
|
297
300
|
* ```ts
|
|
298
301
|
* import { blueOracleAbi } from "@morpho-org/morpho-sdk/abis";
|
|
@@ -471,6 +474,9 @@ export declare class MorphoMidnight {
|
|
|
471
474
|
* withdrawal.
|
|
472
475
|
* @throws {MidnightTakeTargetUnreachableError} when the live offers cannot hold the target, or
|
|
473
476
|
* its bounds cannot hold at any fill.
|
|
477
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} when `now` is not past maturity and `deadline` is less
|
|
478
|
+
* than `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the
|
|
479
|
+
* target; use `takeWithdraw` to sell credit only.
|
|
474
480
|
* @example
|
|
475
481
|
* ```ts
|
|
476
482
|
* const output = midnight.supplyCollateralTakeBorrow({
|
|
@@ -15,6 +15,7 @@ const getMidnightAuthorizationRequirement_js_1 = require("../../actions/requirem
|
|
|
15
15
|
const index_js_1 = require("../../helpers/index.js");
|
|
16
16
|
const metadata_js_1 = require("../../helpers/metadata.js");
|
|
17
17
|
const parseMidnight_js_1 = require("../../helpers/parseMidnight.js");
|
|
18
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
18
19
|
const validateMidnightAccount_js_1 = require("../../helpers/validateMidnightAccount.js");
|
|
19
20
|
const validateMidnightMarket_js_1 = require("../../helpers/validateMidnightMarket.js");
|
|
20
21
|
const validateMidnightTakeFeasibility_js_1 = require("../../helpers/validateMidnightTakeFeasibility.js");
|
|
@@ -349,6 +350,9 @@ class MorphoMidnight {
|
|
|
349
350
|
* withdrawal.
|
|
350
351
|
* @throws {MidnightTakeTargetUnreachableError} when the live offers cannot hold the target, or
|
|
351
352
|
* its bounds cannot hold at any fill.
|
|
353
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} when `now` is not past maturity and `deadline` is less
|
|
354
|
+
* than `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the
|
|
355
|
+
* target; use `takeWithdraw` to sell credit only.
|
|
352
356
|
* @example
|
|
353
357
|
* ```ts
|
|
354
358
|
* import { blueOracleAbi } from "@morpho-org/morpho-sdk/abis";
|
|
@@ -401,12 +405,13 @@ class MorphoMidnight {
|
|
|
401
405
|
throw new index_js_2.BorrowExceedsSafeLtvError(requestedUnits, blue_sdk_1.MathLib.zeroFloorSub(maxSafeDebt, params.positionData.debt));
|
|
402
406
|
}
|
|
403
407
|
}
|
|
408
|
+
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
404
409
|
const takeableOffers = (0, validateMidnightTakeFeasibility_js_1.validateMidnightTakeFeasibility)({
|
|
405
410
|
side: "sell",
|
|
406
411
|
takeableOffers: parsed.takeableOffers,
|
|
407
412
|
accountAddress: accountAddress,
|
|
408
413
|
marketData: params.marketData,
|
|
409
|
-
now
|
|
414
|
+
now,
|
|
410
415
|
deadline: parsed.deadline,
|
|
411
416
|
referralFeePct: parsed.referralFeePct,
|
|
412
417
|
// Credit is withdrawn first, up to the market's withdrawable liquidity.
|
|
@@ -415,6 +420,11 @@ class MorphoMidnight {
|
|
|
415
420
|
target: parsed.target,
|
|
416
421
|
increasesDebt: true,
|
|
417
422
|
});
|
|
423
|
+
(0, validate_js_1.validateMidnightBorrowMaturity)({
|
|
424
|
+
marketData: params.marketData,
|
|
425
|
+
now,
|
|
426
|
+
deadline: parsed.deadline,
|
|
427
|
+
});
|
|
418
428
|
if (takeableOffers !== parsed.takeableOffers) {
|
|
419
429
|
tx = (0, encode_js_1.encodeMidnightTakeBorrow)(parsed, takeableOffers.map((offer) => parsed.takeableOffers.indexOf(offer)));
|
|
420
430
|
}
|
|
@@ -603,6 +613,9 @@ class MorphoMidnight {
|
|
|
603
613
|
* withdrawal.
|
|
604
614
|
* @throws {MidnightTakeTargetUnreachableError} when the live offers cannot hold the target, or
|
|
605
615
|
* its bounds cannot hold at any fill.
|
|
616
|
+
* @throws {MidnightBorrowTooCloseToMaturityError} when `now` is not past maturity and `deadline` is less
|
|
617
|
+
* than `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, even when credit covers the
|
|
618
|
+
* target; use `takeWithdraw` to sell credit only.
|
|
606
619
|
* @example
|
|
607
620
|
* ```ts
|
|
608
621
|
* const output = midnight.supplyCollateralTakeBorrow({
|
|
@@ -651,12 +664,13 @@ class MorphoMidnight {
|
|
|
651
664
|
throw new index_js_2.BorrowExceedsSafeLtvError(requestedUnits, blue_sdk_1.MathLib.zeroFloorSub(maxSafeDebt, params.positionData.debt));
|
|
652
665
|
}
|
|
653
666
|
}
|
|
667
|
+
const now = params.now ?? morpho_ts_1.Time.timestamp();
|
|
654
668
|
const takeableOffers = (0, validateMidnightTakeFeasibility_js_1.validateMidnightTakeFeasibility)({
|
|
655
669
|
side: "sell",
|
|
656
670
|
takeableOffers: parsed.takeableOffers,
|
|
657
671
|
accountAddress: accountAddress,
|
|
658
672
|
marketData: params.marketData,
|
|
659
|
-
now
|
|
673
|
+
now,
|
|
660
674
|
deadline: parsed.deadline,
|
|
661
675
|
referralFeePct: parsed.referralFeePct,
|
|
662
676
|
// Credit is withdrawn first, up to the market's withdrawable liquidity.
|
|
@@ -665,6 +679,11 @@ class MorphoMidnight {
|
|
|
665
679
|
target: parsed.target,
|
|
666
680
|
increasesDebt: true,
|
|
667
681
|
});
|
|
682
|
+
(0, validate_js_1.validateMidnightBorrowMaturity)({
|
|
683
|
+
marketData: params.marketData,
|
|
684
|
+
now,
|
|
685
|
+
deadline: parsed.deadline,
|
|
686
|
+
});
|
|
668
687
|
if (takeableOffers !== parsed.takeableOffers) {
|
|
669
688
|
tx = (0, encode_js_1.encodeMidnightSupplyCollateralTakeBorrow)(parsed, takeableOffers.map((offer) => parsed.takeableOffers.indexOf(offer)));
|
|
670
689
|
}
|
|
@@ -67,9 +67,7 @@ export interface VaultV2Actions {
|
|
|
67
67
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
68
68
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
69
69
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
|
|
70
|
-
* @throws {InputExceedsMaxError} when the deadline exceeds seven days after creation or funding or
|
|
71
|
-
* the deadline exceeds uint256, or when the vault's liquidity adapter is a Midnight adapter (it
|
|
72
|
-
* cannot receive vault allocations, so no deposit fits and `max` is `0n`).
|
|
70
|
+
* @throws {InputExceedsMaxError} when the deadline exceeds seven days after creation or funding or the deadline exceeds uint256.
|
|
73
71
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
74
72
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
75
73
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
|
|
@@ -151,9 +149,7 @@ export interface VaultV2Actions {
|
|
|
151
149
|
* @throws {NonPositiveInputError} when `amount` or the computed required share amount is not positive.
|
|
152
150
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
153
151
|
* at any `getRequirements()` call.
|
|
154
|
-
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation
|
|
155
|
-
* or when the vault's liquidity adapter is a Midnight adapter and `amount` exceeds the vault's
|
|
156
|
-
* idle assets plus what the adapter can withdraw from the liquidity market.
|
|
152
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation.
|
|
157
153
|
* @throws {NegativeInputError} when `referralFeePct` or `slippageTolerance` is negative.
|
|
158
154
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
159
155
|
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
@@ -220,25 +216,7 @@ export interface VaultV2Actions {
|
|
|
220
216
|
* @throws {NonPositiveInputError} when `shares` is not positive.
|
|
221
217
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
222
218
|
* requirement resolution.
|
|
223
|
-
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256
|
|
224
|
-
* `getRequirements()` when the vault's liquidity adapter is a Midnight adapter and `shares`
|
|
225
|
-
* are worth more than the vault's idle assets plus what the adapter can withdraw from the
|
|
226
|
-
* liquidity market.
|
|
227
|
-
* @throws {UnknownBlueFactory} from `getRequirements()` when the configured chain has no VaultV2 factory.
|
|
228
|
-
* @throws {UnknownBlueOfFactory} from `getRequirements()` when the vault is not a VaultV2 from the
|
|
229
|
-
* configured factory.
|
|
230
|
-
* @throws {UnsupportedBlueVaultV2AdapterError} from `getRequirements()` when the vault or one of its
|
|
231
|
-
* adapters uses an unsupported adapter class.
|
|
232
|
-
* @throws {UnsupportedBlueMarketIrmError} from `getRequirements()` when the vault's liquidity adapter
|
|
233
|
-
* is a Midnight adapter and accrual projects an underlying market with positive debt that uses an
|
|
234
|
-
* unsupported IRM.
|
|
235
|
-
* @throws {UnknownBlueMarketAllocationError} from `getRequirements()` when the vault's liquidity
|
|
236
|
-
* adapter is a Midnight adapter and accrual meets a nested Vault V1 withdraw queue market without
|
|
237
|
-
* allocation data.
|
|
238
|
-
* @throws {InvalidMidnightPositionLossFactorError} from `getRequirements()` when the vault's liquidity
|
|
239
|
-
* adapter is a Midnight adapter and accrual meets a market loss factor below a position's.
|
|
240
|
-
* @throws {InvalidMidnightPositionAccrualStateError} from `getRequirements()` when the vault's
|
|
241
|
-
* liquidity adapter is a Midnight adapter and accrual meets invalid Midnight position inputs.
|
|
219
|
+
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
242
220
|
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
243
221
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
244
222
|
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
@@ -247,7 +225,7 @@ export interface VaultV2Actions {
|
|
|
247
225
|
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
248
226
|
* @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
|
|
249
227
|
* contract has no code at its registered address.
|
|
250
|
-
* @throws {viem.BaseError} from `getRequirements()` when
|
|
228
|
+
* @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, `eth_chainId`, or
|
|
251
229
|
* `eth_getCode` read fails.
|
|
252
230
|
* @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
|
|
253
231
|
* `getData()` has unusable decimals.
|
|
@@ -325,11 +303,9 @@ export interface VaultV2Actions {
|
|
|
325
303
|
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
326
304
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
327
305
|
* requirement resolution.
|
|
328
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter
|
|
329
|
-
* a vault that mixes Blue and Midnight adapters.
|
|
306
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter.
|
|
330
307
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
331
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
332
|
-
* including a Midnight adapter.
|
|
308
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
|
|
333
309
|
* @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
|
|
334
310
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
335
311
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
@@ -455,11 +431,9 @@ export interface VaultV2Actions {
|
|
|
455
431
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
456
432
|
* requirement resolution.
|
|
457
433
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
|
|
458
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter
|
|
459
|
-
* including a vault that mixes Blue and Midnight adapters.
|
|
434
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter.
|
|
460
435
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
461
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
462
|
-
* including a Midnight adapter.
|
|
436
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2.
|
|
463
437
|
* @throws {VaultV2UnsupportedLiquidityAdapterError} when the vault routes liquidity through
|
|
464
438
|
* another adapter.
|
|
465
439
|
* @throws {VaultV2UndecodableLiquidityDataError} when the vault's `liquidityData` does not decode
|
|
@@ -26,16 +26,6 @@ const getVaultV2InKindRedeemRequirements_js_1 = require("../requirements/getVaul
|
|
|
26
26
|
const validateNativeRequirements_js_1 = require("../requirements/validateNativeRequirements.js");
|
|
27
27
|
const forceWithdrawQuote_js_1 = require("./forceWithdrawQuote.js");
|
|
28
28
|
const inKindRedeemQuote_js_1 = require("./inKindRedeemQuote.js");
|
|
29
|
-
/**
|
|
30
|
-
* Midnight adapters revert vault-initiated `allocate` (`SelfAllocationOnly`), so a vault routing
|
|
31
|
-
* liquidity through one accepts no deposit. Exits are served from idle assets plus what the adapter's
|
|
32
|
-
* `withdrawToVault` path can withdraw from the liquidity market.
|
|
33
|
-
*/
|
|
34
|
-
const isMidnightLiquidityAdapter = (vaultData) => vaultData.accrualLiquidityAdapter?.type === "VaultV2MidnightAdapter";
|
|
35
|
-
/** Idle assets plus what the Midnight liquidity adapter can withdraw to the vault onchain. */
|
|
36
|
-
const midnightWithdrawLiquidity = (vaultData) => vaultData.assetBalance +
|
|
37
|
-
(vaultData.accrualLiquidityAdapter?.maxWithdraw(vaultData.liquidityData)
|
|
38
|
-
.value ?? 0n);
|
|
39
29
|
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
40
30
|
class MorphoVaultV2 {
|
|
41
31
|
client;
|
|
@@ -104,13 +94,6 @@ class MorphoVaultV2 {
|
|
|
104
94
|
if (funding.value > 0n) {
|
|
105
95
|
(0, validate_js_1.validateNativeVaultAsset)(this.chainId, vaultAsset);
|
|
106
96
|
}
|
|
107
|
-
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
108
|
-
throw new index_js_2.InputExceedsMaxError({
|
|
109
|
-
field: funding.value > 0n ? "nativeAmount" : "amount",
|
|
110
|
-
value: funding.assets,
|
|
111
|
-
max: 0n,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
97
|
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
115
98
|
// Bound forward accrual before deriving the deposit price protection.
|
|
116
99
|
(0, validate_js_1.validateVaultDepositDeadline)(deadline, { now: createdAt });
|
|
@@ -217,14 +200,6 @@ class MorphoVaultV2 {
|
|
|
217
200
|
throw new index_js_2.NonPositiveInputError("amount", amount);
|
|
218
201
|
}
|
|
219
202
|
const parsedAmount = (0, parse_js_1.parseUint256)("amount", amount);
|
|
220
|
-
if (isMidnightLiquidityAdapter(vaultData) &&
|
|
221
|
-
amount > midnightWithdrawLiquidity(vaultData)) {
|
|
222
|
-
throw new index_js_2.InputExceedsMaxError({
|
|
223
|
-
field: "amount",
|
|
224
|
-
value: amount,
|
|
225
|
-
max: midnightWithdrawLiquidity(vaultData),
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
203
|
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
229
204
|
const deadline = params.deadline ?? createdAt + morpho_ts_1.Time.s.from.h(2n);
|
|
230
205
|
if (deadline <= createdAt) {
|
|
@@ -334,21 +309,8 @@ class MorphoVaultV2 {
|
|
|
334
309
|
}
|
|
335
310
|
const chainCheck = (0, chainCheck_js_1.createChainCheck)(this.client.viemClient, this.chainId);
|
|
336
311
|
await this.assertWriteTargets(["bundles.vaultBundlesV1"], chainCheck);
|
|
337
|
-
const vaultData = await this.getDataWithChainCheck(chainCheck);
|
|
338
|
-
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
339
|
-
// Onchain redeem accrues interest before converting shares to assets.
|
|
340
|
-
const { vault: accrued } = vaultData.accrueInterest(now);
|
|
341
|
-
const liquidity = midnightWithdrawLiquidity(accrued);
|
|
342
|
-
if (accrued.toAssets(shares) > liquidity) {
|
|
343
|
-
throw new index_js_2.InputExceedsMaxError({
|
|
344
|
-
field: "shares",
|
|
345
|
-
value: shares,
|
|
346
|
-
max: accrued.toShares(liquidity),
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
312
|
return (0, getVaultBundlesSharesRequirements_js_1.getParsedVaultBundlesSharesRequirements)({ viemClient: this.client.viemClient, chainCheck }, (0, getVaultBundlesSharesRequirements_js_1.parseVaultBundlesSharesRequirements)(this.client.viemClient, {
|
|
351
|
-
vaultData,
|
|
313
|
+
vaultData: await this.getDataWithChainCheck(chainCheck),
|
|
352
314
|
version: "vaultV2",
|
|
353
315
|
owner: userAddress,
|
|
354
316
|
chainId: this.chainId,
|
|
@@ -56,8 +56,7 @@ export interface InputVaultV2BlueReallocationData {
|
|
|
56
56
|
/**
|
|
57
57
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
58
58
|
*
|
|
59
|
-
* Constructor inputs are cloned
|
|
60
|
-
* shared by reference. Every simulated reallocation returns a new
|
|
59
|
+
* Constructor inputs are cloned. Every simulated reallocation returns a new
|
|
61
60
|
* instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
62
61
|
* denominator outside the durable snapshot while applying reallocations in
|
|
63
62
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
@@ -134,7 +133,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
134
133
|
/**
|
|
135
134
|
* Clones the complete simulation snapshot.
|
|
136
135
|
*
|
|
137
|
-
* @returns A deep clone of this simulation state
|
|
136
|
+
* @returns A deep clone of this simulation state.
|
|
138
137
|
* @example
|
|
139
138
|
* ```ts
|
|
140
139
|
* import { markets } from "@morpho-org/morpho-test";
|
|
@@ -83,9 +83,6 @@ const cloneAccrualVault = (vault, markets) => new blue_sdk_1.AccrualVault({
|
|
|
83
83
|
position: clonePosition(position, markets),
|
|
84
84
|
})));
|
|
85
85
|
const cloneAdapter = (adapter, markets) => {
|
|
86
|
-
if (adapter.type === "VaultV2MidnightAdapter") {
|
|
87
|
-
return adapter;
|
|
88
|
-
}
|
|
89
86
|
const base = {
|
|
90
87
|
address: adapter.address,
|
|
91
88
|
parentVault: adapter.parentVault,
|
|
@@ -137,8 +134,7 @@ const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
|
|
|
137
134
|
/**
|
|
138
135
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
139
136
|
*
|
|
140
|
-
* Constructor inputs are cloned
|
|
141
|
-
* shared by reference. Every simulated reallocation returns a new
|
|
137
|
+
* Constructor inputs are cloned. Every simulated reallocation returns a new
|
|
142
138
|
* instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
143
139
|
* denominator outside the durable snapshot while applying reallocations in
|
|
144
140
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
@@ -269,7 +265,7 @@ class VaultV2BlueReallocationData {
|
|
|
269
265
|
/**
|
|
270
266
|
* Clones the complete simulation snapshot.
|
|
271
267
|
*
|
|
272
|
-
* @returns A deep clone of this simulation state
|
|
268
|
+
* @returns A deep clone of this simulation state.
|
|
273
269
|
* @example
|
|
274
270
|
* ```ts
|
|
275
271
|
* import { markets } from "@morpho-org/morpho-test";
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError,
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError,
|
|
5
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureError as InvalidMidnightEcrecoverSignatureError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureError as InvalidMidnightEcrecoverSignatureError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError,
|
|
7
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, MissingLocalePartError, NegativeValueError, RegistryValueAlreadyRegisteredError, RetriesExhaustedError, RetryStoppedError, } from "@morpho-org/morpho-ts";
|
package/lib/cjs/errors.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.
|
|
3
|
+
exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightRatifierV1AddressError = exports.InvalidMidnightRateRatifierV1TimeError = exports.InvalidMidnightRateRatifierV1TickError = exports.InvalidMidnightRateRatifierV1RateError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.InvalidMidnightEcrecoverSignatureError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.BlueMarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
4
|
+
exports.RetryStoppedError = exports.RetriesExhaustedError = exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.MissingLocalePartError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightRatifierV1TakerNotAllowedError = exports.MidnightRateRatifierV1BoundOverflowError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = void 0;
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
7
7
|
Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
|
|
8
8
|
Object.defineProperty(exports, "InvalidBlueMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
|
|
9
|
-
Object.defineProperty(exports, "InvalidBlueVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
|
|
10
9
|
Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
|
|
11
10
|
Object.defineProperty(exports, "UnknownBlueDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
|
|
12
11
|
Object.defineProperty(exports, "UnknownBlueFactory", { enumerable: true, get: function () { return blue_sdk_1.UnknownFactory; } });
|
|
@@ -35,7 +34,6 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
|
|
|
35
34
|
Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
|
|
36
35
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
37
36
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
38
|
-
Object.defineProperty(exports, "UnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
39
37
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
|
40
38
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
41
39
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
@@ -46,6 +44,9 @@ Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerabl
|
|
|
46
44
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
47
45
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
48
46
|
Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
|
47
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualStateError; } });
|
|
48
|
+
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionAccrualTimestampError; } });
|
|
49
|
+
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidPositionLossFactorError; } });
|
|
49
50
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1RateError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1RateError; } });
|
|
50
51
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TickError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TickError; } });
|
|
51
52
|
Object.defineProperty(exports, "InvalidMidnightRateRatifierV1TimeError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidRateRatifierV1TimeError; } });
|
|
@@ -68,9 +69,6 @@ Object.defineProperty(exports, "_try", { enumerable: true, get: function () { re
|
|
|
68
69
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return morpho_ts_1.DivisionByZeroError; } });
|
|
69
70
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return morpho_ts_1.InvalidAddressError; } });
|
|
70
71
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return morpho_ts_1.InvalidBitLengthError; } });
|
|
71
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualStateError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualStateError; } });
|
|
72
|
-
Object.defineProperty(exports, "InvalidMidnightPositionAccrualTimestampError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionAccrualTimestampError; } });
|
|
73
|
-
Object.defineProperty(exports, "InvalidMidnightPositionLossFactorError", { enumerable: true, get: function () { return morpho_ts_1.InvalidPositionLossFactorError; } });
|
|
74
72
|
Object.defineProperty(exports, "MissingLocalePartError", { enumerable: true, get: function () { return morpho_ts_1.MissingLocalePartError; } });
|
|
75
73
|
Object.defineProperty(exports, "NegativeValueError", { enumerable: true, get: function () { return morpho_ts_1.NegativeValueError; } });
|
|
76
74
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return morpho_ts_1.RegistryValueAlreadyRegisteredError; } });
|
package/lib/cjs/fetch.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter,
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData,
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
6
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/cjs/fetch.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.
|
|
3
|
+
exports.fetchMidnightRatifierInfo = exports.fetchMidnightPosition = exports.fetchMidnightMarketParams = exports.fetchMidnightMarket = exports.fetchMidnightAccrualPosition = exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchBlueUser = exports.fetchToken = exports.fetchBluePreLiquidationPosition = exports.fetchBluePreLiquidationParams = exports.fetchBluePosition = exports.fetchBlueMarketParams = exports.fetchBlueMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchBlueAccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
Object.defineProperty(exports, "fetchBlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
|
|
8
8
|
Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
|
|
9
|
-
Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
|
|
10
9
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
|
|
11
10
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
12
11
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -30,7 +29,6 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
|
|
|
30
29
|
Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
|
|
31
30
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
|
|
32
31
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
|
|
33
|
-
Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
|
|
34
32
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
|
|
35
33
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
|
|
36
34
|
Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -3,6 +3,13 @@ import { type Address } from "viem";
|
|
|
3
3
|
export declare const VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = 604800n;
|
|
4
4
|
/** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
|
|
5
5
|
export declare const MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
|
|
6
|
+
/**
|
|
7
|
+
* Minimum time between a Midnight borrow's deadline and its market maturity, in seconds (2 hours).
|
|
8
|
+
* Debt still open at maturity becomes liquidatable, so entity and TransactionPlan borrows prepared at
|
|
9
|
+
* or before maturity that could execute closer to it are rejected. Credit covering the target at
|
|
10
|
+
* preparation does not exempt a borrow; sell credit only inside the window with `takeWithdraw`.
|
|
11
|
+
*/
|
|
12
|
+
export declare const MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY: bigint;
|
|
6
13
|
/**
|
|
7
14
|
* Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
|
|
8
15
|
* @internal
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = void 0;
|
|
3
|
+
exports.MAX_TOKEN_APPROVALS = exports.APPROVE_ONLY_ONCE_TOKENS = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_LLTV_BUFFER = exports.MAX_REALLOCATION_PENALTY = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.MAX_SLIPPAGE_TOLERANCE = exports.MIDNIGHT_MAX_REFERRAL_FEE_PCT = exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = void 0;
|
|
4
4
|
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
6
|
const viem_1 = require("viem");
|
|
@@ -8,6 +8,13 @@ const viem_1 = require("viem");
|
|
|
8
8
|
exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = 604800n;
|
|
9
9
|
/** Maximum time between now and a Midnight taker-flow deadline, in seconds. */
|
|
10
10
|
exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = 3600n;
|
|
11
|
+
/**
|
|
12
|
+
* Minimum time between a Midnight borrow's deadline and its market maturity, in seconds (2 hours).
|
|
13
|
+
* Debt still open at maturity becomes liquidatable, so entity and TransactionPlan borrows prepared at
|
|
14
|
+
* or before maturity that could execute closer to it are rejected. Credit covering the target at
|
|
15
|
+
* preparation does not exempt a borrow; sell credit only inside the window with `takeWithdraw`.
|
|
16
|
+
*/
|
|
17
|
+
exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = morpho_ts_1.Time.s.from.h(2n);
|
|
11
18
|
/**
|
|
12
19
|
* Matches MAX_SLIPPAGE_TOLERANCE, the SDK's other ceiling on a WAD share of user funds; higher fees are rejected as likely unit mistakes.
|
|
13
20
|
* @internal
|
|
@@ -193,9 +193,6 @@ function getDeadSharesAbsoluteCap(id, { absoluteCaps, entity, adapter, }) {
|
|
|
193
193
|
}
|
|
194
194
|
/** Checks the currently allocated positions of one supported adapter. @internal */
|
|
195
195
|
function assertAdapterDeadShares(adapter, { absoluteCaps, entity, }) {
|
|
196
|
-
if (adapter instanceof blue_sdk_1.AccrualVaultV2MidnightAdapter) {
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
196
|
if (adapter instanceof blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter) {
|
|
200
197
|
const id = blue_sdk_1.VaultV2MorphoVaultV1Adapter.adapterCapId(adapter.address);
|
|
201
198
|
if (getDeadSharesAbsoluteCap(id, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { getMidnightBlueBuyCallbackAddress, getMidnightBlueBuyCallbackData, } from "./callback.js";
|
|
2
|
-
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./constant.js";
|
|
2
|
+
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_ALLOCATOR_CAP_HEADROOM, DEFAULT_CAP_ACCRUAL_BUFFER, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY, MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS, MIN_DEAD_SHARES, MIN_VAULT_V2_DEAD_ASSETS, VAULT_DEPOSIT_MAX_DEADLINE_SECONDS, } from "./constant.js";
|
|
3
3
|
export { validateBlueMarketDeadShares, validateVaultV1DeadShares, validateVaultV2DeadShares, } from "./deadShares.js";
|
|
4
4
|
export { addTransactionMetadata } from "./metadata.js";
|
|
5
5
|
export { type PreviewVaultV2ForceWithdrawParams, previewVaultV2ForceWithdraw, type VaultV2ForceWithdrawPreview, } from "./previewVaultV2ForceWithdraw.js";
|
package/lib/cjs/helpers/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.getMidnightMaxSafeDebt = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateVaultV2DeadShares = exports.validateVaultV1DeadShares = exports.validateBlueMarketDeadShares = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
|
|
3
|
+
exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWithdrawSharesBurnt = exports.computeVaultV2ForceWithdrawPlan = exports.computeVaultV2ForceWithdrawMinSharesBurnt = exports.computeVaultV2ForceWithdrawFeeSharesMinted = exports.validateRequirementSpender = exports.validateOfferSides = exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateUserAddress = exports.validateSlippageTolerance = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validatePositionHealth = exports.validateNativeAsset = exports.validateMidnightNativeAmount = exports.validateMidnightMarketChainId = exports.validateChainId = exports.validateAccrualPosition = exports.getMidnightMaxSafeDebt = exports.computeVaultMaxSharePrice = exports.computeVaultMaxShareAllowance = exports.computeMinForceWithdrawSharePrice = exports.signAndVerifyTypedData = exports.grossFromNetAssets = exports.previewVaultV2InKindRedeem = exports.previewVaultV2ForceWithdraw = exports.addTransactionMetadata = exports.validateVaultV2DeadShares = exports.validateVaultV1DeadShares = exports.validateBlueMarketDeadShares = exports.VAULT_DEPOSIT_MAX_DEADLINE_SECONDS = exports.MIN_VAULT_V2_DEAD_ASSETS = exports.MIN_DEAD_SHARES = exports.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS = exports.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY = exports.MAX_TOKEN_APPROVALS = exports.MAX_SLIPPAGE_TOLERANCE = exports.MAX_REALLOCATION_PENALTY = exports.MAX_ABSOLUTE_SHARE_PRICE = exports.DEFAULT_WITHDRAWAL_TARGET_UTILIZATION = exports.DEFAULT_SUPPLY_TARGET_UTILIZATION = exports.DEFAULT_MAX_REALLOCATION_PENALTY = exports.DEFAULT_LLTV_BUFFER = exports.DEFAULT_CAP_ACCRUAL_BUFFER = exports.DEFAULT_ALLOCATOR_CAP_HEADROOM = exports.APPROVE_ONLY_ONCE_TOKENS = exports.getMidnightBlueBuyCallbackData = exports.getMidnightBlueBuyCallbackAddress = void 0;
|
|
4
4
|
var callback_js_1 = require("./callback.js");
|
|
5
5
|
Object.defineProperty(exports, "getMidnightBlueBuyCallbackAddress", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackAddress; } });
|
|
6
6
|
Object.defineProperty(exports, "getMidnightBlueBuyCallbackData", { enumerable: true, get: function () { return callback_js_1.getMidnightBlueBuyCallbackData; } });
|
|
@@ -16,6 +16,7 @@ Object.defineProperty(exports, "MAX_ABSOLUTE_SHARE_PRICE", { enumerable: true, g
|
|
|
16
16
|
Object.defineProperty(exports, "MAX_REALLOCATION_PENALTY", { enumerable: true, get: function () { return constant_js_1.MAX_REALLOCATION_PENALTY; } });
|
|
17
17
|
Object.defineProperty(exports, "MAX_SLIPPAGE_TOLERANCE", { enumerable: true, get: function () { return constant_js_1.MAX_SLIPPAGE_TOLERANCE; } });
|
|
18
18
|
Object.defineProperty(exports, "MAX_TOKEN_APPROVALS", { enumerable: true, get: function () { return constant_js_1.MAX_TOKEN_APPROVALS; } });
|
|
19
|
+
Object.defineProperty(exports, "MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY", { enumerable: true, get: function () { return constant_js_1.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY; } });
|
|
19
20
|
Object.defineProperty(exports, "MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS", { enumerable: true, get: function () { return constant_js_1.MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS; } });
|
|
20
21
|
Object.defineProperty(exports, "MIN_DEAD_SHARES", { enumerable: true, get: function () { return constant_js_1.MIN_DEAD_SHARES; } });
|
|
21
22
|
Object.defineProperty(exports, "MIN_VAULT_V2_DEAD_ASSETS", { enumerable: true, get: function () { return constant_js_1.MIN_VAULT_V2_DEAD_ASSETS; } });
|
|
@@ -235,6 +235,20 @@ export declare const validateMidnightBorrowHealth: (params: {
|
|
|
235
235
|
readonly debt: bigint;
|
|
236
236
|
readonly borrowUnits: bigint;
|
|
237
237
|
}) => void;
|
|
238
|
+
/**
|
|
239
|
+
* @internal Rejects a Midnight borrow that could execute less than
|
|
240
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` before the market's maturity, when unpaid debt becomes
|
|
241
|
+
* liquidatable. The sell is not reduce-only, so any units beyond the credit left at execution open
|
|
242
|
+
* debt; credit covering the target when the borrow is prepared does not exempt it. Once `now` is
|
|
243
|
+
* past maturity the protocol rejects new debt, so the check does not apply, matching the
|
|
244
|
+
* post-maturity credit cap in `validateMidnightTakeFeasibility`.
|
|
245
|
+
* Used by the entity and TransactionPlan borrow flows.
|
|
246
|
+
*/
|
|
247
|
+
export declare const validateMidnightBorrowMaturity: (params: {
|
|
248
|
+
readonly marketData: MidnightMarket;
|
|
249
|
+
readonly now: bigint;
|
|
250
|
+
readonly deadline: bigint;
|
|
251
|
+
}) => void;
|
|
238
252
|
/**
|
|
239
253
|
* @internal Rejects a Midnight collateral withdrawal whose post-operation debt exceeds the remaining
|
|
240
254
|
* collateral's capacity at LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateMidnightRepayWithdrawCollateralPosition = exports.validateMidnightWithdrawHealth = exports.validateMidnightBorrowHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateMarketParamsId = exports.validateUint256Field = void 0;
|
|
3
|
+
exports.validateWithdrawShares = exports.validateWithdrawAmount = exports.validateSlippageTolerance = exports.validateVaultV2BlueReallocations = exports.validateRepayShares = exports.validateRepayAmount = exports.validatePositionHealthAfterWithdraw = exports.validateNativeVaultAsset = exports.validateMidnightNativeAmount = exports.validateNativeAsset = exports.validateChainId = exports.validatePositionHealth = exports.validateMidnightRepayWithdrawCollateralPosition = exports.validateMidnightWithdrawHealth = exports.validateMidnightBorrowMaturity = exports.validateMidnightBorrowHealth = exports.getMidnightMaxSafeDebt = exports.validateAccrualPosition = exports.validateMidnightMarketChainId = exports.validateReferralFee = exports.validateDeadline = exports.validateMarketParamsId = exports.validateUint256Field = void 0;
|
|
4
4
|
exports.validateReferenceTime = validateReferenceTime;
|
|
5
5
|
exports.validateVaultDepositDeadline = validateVaultDepositDeadline;
|
|
6
6
|
exports.validateUserAddress = validateUserAddress;
|
|
@@ -337,6 +337,30 @@ const validateMidnightBorrowHealth = (params) => {
|
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
339
|
exports.validateMidnightBorrowHealth = validateMidnightBorrowHealth;
|
|
340
|
+
/**
|
|
341
|
+
* @internal Rejects a Midnight borrow that could execute less than
|
|
342
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` before the market's maturity, when unpaid debt becomes
|
|
343
|
+
* liquidatable. The sell is not reduce-only, so any units beyond the credit left at execution open
|
|
344
|
+
* debt; credit covering the target when the borrow is prepared does not exempt it. Once `now` is
|
|
345
|
+
* past maturity the protocol rejects new debt, so the check does not apply, matching the
|
|
346
|
+
* post-maturity credit cap in `validateMidnightTakeFeasibility`.
|
|
347
|
+
* Used by the entity and TransactionPlan borrow flows.
|
|
348
|
+
*/
|
|
349
|
+
const validateMidnightBorrowMaturity = (params) => {
|
|
350
|
+
const { maturity } = params.marketData.params;
|
|
351
|
+
if (params.now > maturity) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
const latestDeadline = maturity - constant_js_1.MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY;
|
|
355
|
+
if (params.deadline > latestDeadline) {
|
|
356
|
+
throw new index_js_1.MidnightBorrowTooCloseToMaturityError({
|
|
357
|
+
deadline: params.deadline,
|
|
358
|
+
maturity,
|
|
359
|
+
latestDeadline,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
exports.validateMidnightBorrowMaturity = validateMidnightBorrowMaturity;
|
|
340
364
|
/**
|
|
341
365
|
* @internal Rejects a Midnight collateral withdrawal whose post-operation debt exceeds the remaining
|
|
342
366
|
* collateral's capacity at LLTV minus `DEFAULT_LLTV_BUFFER`, with the same check and error as the
|