@morpho-org/morpho-sdk 10.4.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/actions/blue/common.js +12 -3
- 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/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -2
- package/lib/cjs/entities/midnight/midnight.d.ts +106 -103
- package/lib/cjs/entities/midnight/midnight.js +120 -101
- package/lib/cjs/entities/vaultV1/vaultV1.js +0 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +0 -1
- package/lib/cjs/helpers/constant.d.ts +7 -0
- package/lib/cjs/helpers/constant.js +8 -1
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/validate.d.ts +25 -1
- package/lib/cjs/helpers/validate.js +25 -1
- package/lib/cjs/transactionPlan/assemble.d.ts +24 -0
- package/lib/cjs/transactionPlan/assemble.js +25 -0
- package/lib/cjs/transactionPlan/blue/borrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/refinance.js +9 -11
- package/lib/cjs/transactionPlan/blue/repay.js +10 -24
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +49 -45
- package/lib/cjs/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/cjs/transactionPlan/blue/stored.js +87 -0
- package/lib/cjs/transactionPlan/blue/supply.js +7 -22
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +14 -64
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdraw.js +67 -79
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +31 -30
- package/lib/cjs/transactionPlan/deposit.js +4 -7
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeBorrow.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeBorrow.js +1 -1
- package/lib/cjs/transactionPlan/midnight/makeLend.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeLend.js +1 -1
- package/lib/cjs/transactionPlan/midnight/makeRepay.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/makeRepay.js +1 -1
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
- package/lib/cjs/transactionPlan/midnight/takeBorrow.d.ts +6 -2
- package/lib/cjs/transactionPlan/midnight/takeBorrow.js +10 -4
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/midnight/takeWithdraw.js +1 -1
- package/lib/cjs/transactionPlan/permit.d.ts +15 -2
- package/lib/cjs/transactionPlan/permit.js +26 -68
- package/lib/cjs/transactionPlan/plan.d.ts +51 -1
- package/lib/cjs/transactionPlan/plan.js +56 -13
- package/lib/cjs/transactionPlan/redeem.js +4 -7
- package/lib/cjs/transactionPlan/types.d.ts +4 -3
- package/lib/cjs/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/cjs/transactionPlan/vaultBinding.js +69 -0
- package/lib/cjs/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/cjs/transactionPlan/vaultRequirements.js +37 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +6 -18
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -12
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +4 -7
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +12 -42
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +10 -41
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -13
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -13
- package/lib/cjs/transactionPlan/withdraw.js +4 -7
- package/lib/cjs/types/error.d.ts +27 -1
- package/lib/cjs/types/error.js +32 -3
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/actions/blue/common.js +13 -4
- 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/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/midnight/midnight.d.ts +106 -103
- package/lib/esm/entities/midnight/midnight.js +120 -101
- package/lib/esm/entities/vaultV1/vaultV1.js +0 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +0 -1
- package/lib/esm/helpers/constant.d.ts +7 -0
- package/lib/esm/helpers/constant.js +7 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/validate.d.ts +25 -1
- package/lib/esm/helpers/validate.js +25 -2
- package/lib/esm/transactionPlan/assemble.d.ts +24 -0
- package/lib/esm/transactionPlan/assemble.js +21 -0
- package/lib/esm/transactionPlan/blue/borrow.js +15 -65
- package/lib/esm/transactionPlan/blue/refinance.js +10 -12
- package/lib/esm/transactionPlan/blue/repay.js +11 -25
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +50 -46
- package/lib/esm/transactionPlan/blue/stored.d.ts +26 -0
- package/lib/esm/transactionPlan/blue/stored.js +80 -0
- package/lib/esm/transactionPlan/blue/supply.js +7 -22
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +10 -15
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +15 -65
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdraw.js +70 -82
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +32 -31
- package/lib/esm/transactionPlan/deposit.js +5 -8
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeBorrow.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeBorrow.js +1 -1
- package/lib/esm/transactionPlan/midnight/makeLend.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeLend.js +1 -1
- package/lib/esm/transactionPlan/midnight/makeRepay.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/makeRepay.js +1 -1
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/repayWithdrawCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyBlueMakeLend.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralBatch.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralMakeBorrow.js +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/supplyCollateralWithNative.js +1 -1
- package/lib/esm/transactionPlan/midnight/takeBorrow.d.ts +6 -2
- package/lib/esm/transactionPlan/midnight/takeBorrow.js +11 -5
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/esm/transactionPlan/midnight/takeWithdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/midnight/takeWithdraw.js +1 -1
- package/lib/esm/transactionPlan/permit.d.ts +15 -2
- package/lib/esm/transactionPlan/permit.js +25 -68
- package/lib/esm/transactionPlan/plan.d.ts +51 -1
- package/lib/esm/transactionPlan/plan.js +55 -13
- package/lib/esm/transactionPlan/redeem.js +5 -8
- package/lib/esm/transactionPlan/types.d.ts +4 -3
- package/lib/esm/transactionPlan/vaultBinding.d.ts +29 -0
- package/lib/esm/transactionPlan/vaultBinding.js +65 -0
- package/lib/esm/transactionPlan/vaultRequirements.d.ts +20 -0
- package/lib/esm/transactionPlan/vaultRequirements.js +34 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +9 -21
- package/lib/esm/transactionPlan/vaultv1/redeem.js +2 -13
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +5 -8
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +15 -45
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +2 -2
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +12 -43
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/redeem.js +3 -14
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +1 -1
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +3 -14
- package/lib/esm/transactionPlan/withdraw.js +5 -8
- package/lib/esm/types/error.d.ts +27 -1
- package/lib/esm/types/error.js +30 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
2
|
-
import { selectBundlesSharesPermitSignature } from "../../actions/bundles/common.js";
|
|
3
1
|
import { vaultV2Withdraw } from "../../actions/vaultV2/withdraw.js";
|
|
4
|
-
import {
|
|
2
|
+
import { selectVaultPermit } from "../permit.js";
|
|
5
3
|
import { prepareVaultWithdraw } from "../withdraw.js";
|
|
6
4
|
/**
|
|
7
5
|
* @experimental TransactionPlan is in beta; breaking changes may ship in minor releases.
|
|
@@ -22,7 +20,7 @@ import { prepareVaultWithdraw } from "../withdraw.js";
|
|
|
22
20
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
23
21
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
24
22
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h` (device clock when `now` is omitted).
|
|
25
|
-
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to
|
|
23
|
+
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to the action transaction's calldata; approval and authorization steps carry none.
|
|
26
24
|
* @returns A plan with the withdrawal step and any required share approval or signature request.
|
|
27
25
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
28
26
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
@@ -59,16 +57,7 @@ export async function prepareVaultV2Withdraw(client, params) {
|
|
|
59
57
|
/** @internal Encodes the withdrawal from its self-contained inputs and resolved signature requests. */
|
|
60
58
|
export function buildVaultV2Withdraw(action, requests) {
|
|
61
59
|
const { requiredShareAllowance, chainId, account, assets, ...args } = action.inputs;
|
|
62
|
-
const
|
|
63
|
-
id: action.signatureRequestIds.tokenPermit,
|
|
64
|
-
asset: action.inputs.vault,
|
|
65
|
-
owner: account,
|
|
66
|
-
});
|
|
67
|
-
const permit = selectBundlesSharesPermitSignature(signature ? [signature] : [], {
|
|
68
|
-
spender: getChainAddress(chainId, "bundles.vaultBundlesV1"),
|
|
69
|
-
amount: requiredShareAllowance,
|
|
70
|
-
deadline: action.inputs.deadline,
|
|
71
|
-
});
|
|
60
|
+
const permit = selectVaultPermit(action, requests);
|
|
72
61
|
return vaultV2Withdraw({
|
|
73
62
|
vault: { chainId, address: action.inputs.vault },
|
|
74
63
|
args: {
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DEFAULT_SLIPPAGE_TOLERANCE, Token, } from "@morpho-org/blue-sdk";
|
|
2
|
-
import {
|
|
2
|
+
import { Time } from "@morpho-org/morpho-ts";
|
|
3
3
|
import { normalizeBundlesCommonParams } from "../actions/bundles/common.js";
|
|
4
4
|
import { computeVaultMaxShareAllowance } from "../helpers/index.js";
|
|
5
5
|
import { validateUint256Field } from "../helpers/validate.js";
|
|
6
6
|
import { NonPositiveInputError, } from "../types/index.js";
|
|
7
|
+
import { freezePlan, planHeader } from "./assemble.js";
|
|
7
8
|
import { resolveIntent } from "./intent.js";
|
|
8
9
|
import { getVaultShareSpendingRequirements } from "./shareSpending.js";
|
|
9
10
|
import { validatePlanFields, validateVaultPlanAction } from "./validation.js";
|
|
@@ -58,12 +59,8 @@ export async function prepareVaultWithdraw(client, params) {
|
|
|
58
59
|
supportSignature: intent.supportSignature,
|
|
59
60
|
now,
|
|
60
61
|
});
|
|
61
|
-
return
|
|
62
|
-
|
|
63
|
-
account,
|
|
64
|
-
chainId,
|
|
65
|
-
expiresAt: intent.expiresAt,
|
|
66
|
-
...(intent.calldataOrigin && { calldataOrigin: intent.calldataOrigin }),
|
|
62
|
+
return freezePlan({
|
|
63
|
+
...planHeader({ chainId, account }, intent),
|
|
67
64
|
steps: [
|
|
68
65
|
...approvals,
|
|
69
66
|
{
|
|
@@ -86,5 +83,5 @@ export async function prepareVaultWithdraw(client, params) {
|
|
|
86
83
|
},
|
|
87
84
|
],
|
|
88
85
|
signatureRequests,
|
|
89
|
-
})
|
|
86
|
+
}, { detach: true });
|
|
90
87
|
}
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -840,7 +840,8 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
840
840
|
* ```
|
|
841
841
|
*/
|
|
842
842
|
export declare class InvalidVaultV2BlueReallocationShapeError extends Error {
|
|
843
|
-
|
|
843
|
+
/** @param options - Optional underlying failure, kept as `cause`. */
|
|
844
|
+
constructor(options?: ErrorOptions);
|
|
844
845
|
}
|
|
845
846
|
/**
|
|
846
847
|
* Thrown when a Blue Public Allocator reallocation contains a malformed vault
|
|
@@ -1327,6 +1328,31 @@ export declare class MidnightTakeDeadlineTooFarError extends Error {
|
|
|
1327
1328
|
readonly maxDeadline: bigint;
|
|
1328
1329
|
});
|
|
1329
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
|
+
}
|
|
1330
1356
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1331
1357
|
export declare class MidnightOfferMarketChainMismatchError extends Error {
|
|
1332
1358
|
constructor(params: {
|
package/lib/esm/types/error.js
CHANGED
|
@@ -1046,8 +1046,9 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
1046
1046
|
* ```
|
|
1047
1047
|
*/
|
|
1048
1048
|
export class InvalidVaultV2BlueReallocationShapeError extends Error {
|
|
1049
|
-
|
|
1050
|
-
|
|
1049
|
+
/** @param options - Optional underlying failure, kept as `cause`. */
|
|
1050
|
+
constructor(options) {
|
|
1051
|
+
super("Reallocation entry is not a valid Vault V2 reallocation. High-level Blue writes accept only VaultV2BlueReallocation entries (e.g. from getVaultV2BlueReallocations()). Use morpho-sdk v5 if Vault V1 reallocations are required.", options);
|
|
1051
1052
|
this.name = "InvalidVaultV2BlueReallocationShapeError";
|
|
1052
1053
|
}
|
|
1053
1054
|
}
|
|
@@ -1629,6 +1630,33 @@ export class MidnightTakeDeadlineTooFarError extends Error {
|
|
|
1629
1630
|
this.name = "MidnightTakeDeadlineTooFarError";
|
|
1630
1631
|
}
|
|
1631
1632
|
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Thrown when a Midnight borrow prepared at or before maturity could execute less than
|
|
1635
|
+
* `MIDNIGHT_MIN_BORROW_TIME_TO_MATURITY` (2 hours) before it, when unpaid debt becomes liquidatable.
|
|
1636
|
+
* Credit covering the target at preparation does not exempt the borrow, because the sell is not
|
|
1637
|
+
* reduce-only; sell credit only inside the window with `takeWithdraw`.
|
|
1638
|
+
*/
|
|
1639
|
+
export class MidnightBorrowTooCloseToMaturityError extends Error {
|
|
1640
|
+
/** Deadline supplied by the caller. */
|
|
1641
|
+
deadline;
|
|
1642
|
+
/** Market maturity timestamp. */
|
|
1643
|
+
maturity;
|
|
1644
|
+
/** Latest accepted deadline for this maturity. */
|
|
1645
|
+
latestDeadline;
|
|
1646
|
+
/**
|
|
1647
|
+
* @param params - Supplied deadline, market maturity and latest accepted deadline.
|
|
1648
|
+
* @param params.deadline - Deadline supplied by the caller.
|
|
1649
|
+
* @param params.maturity - Market maturity timestamp.
|
|
1650
|
+
* @param params.latestDeadline - Latest accepted deadline for this maturity.
|
|
1651
|
+
*/
|
|
1652
|
+
constructor(params) {
|
|
1653
|
+
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.`);
|
|
1654
|
+
this.deadline = params.deadline;
|
|
1655
|
+
this.maturity = params.maturity;
|
|
1656
|
+
this.latestDeadline = params.latestDeadline;
|
|
1657
|
+
this.name = "MidnightBorrowTooCloseToMaturityError";
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1632
1660
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1633
1661
|
export class MidnightOfferMarketChainMismatchError extends Error {
|
|
1634
1662
|
constructor(params) {
|
package/lib/esm/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Installed @morpho-org/morpho-sdk package version. */
|
|
2
|
-
export declare const version = "10.
|
|
2
|
+
export declare const version = "10.5.0";
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "10.
|
|
4
|
+
"version": "10.5.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -162,7 +162,7 @@
|
|
|
162
162
|
"test": "vitest --root ../.. --project morpho-sdk --project morpho-sdk-fork"
|
|
163
163
|
},
|
|
164
164
|
"dependencies": {
|
|
165
|
-
"@morpho-org/blue-sdk": "^8.4.
|
|
165
|
+
"@morpho-org/blue-sdk": "^8.4.2",
|
|
166
166
|
"@morpho-org/blue-sdk-viem": "^7.6.0",
|
|
167
167
|
"@morpho-org/midnight-sdk": "^2.10.0",
|
|
168
168
|
"@morpho-org/morpho-ts": "^4.5.1",
|
|
@@ -173,7 +173,7 @@
|
|
|
173
173
|
},
|
|
174
174
|
"devDependencies": {
|
|
175
175
|
"@morpho-org/morpho-test": "^4.4.0",
|
|
176
|
-
"@morpho-org/test": "^2.15.
|
|
176
|
+
"@morpho-org/test": "^2.15.1",
|
|
177
177
|
"fast-check": "^4.9.0",
|
|
178
178
|
"typescript": "7.0.2",
|
|
179
179
|
"viem": "^2.55.10",
|