@morpho-org/morpho-sdk 7.1.0-next.1 → 8.1.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/MIGRATION-v7-to-v8.md +290 -0
- package/README.md +11 -6
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +17 -71
- package/lib/cjs/actions/midnight/cancelAndMake.js +41 -29
- package/lib/cjs/actions/midnight/redeem.d.ts +8 -1
- package/lib/cjs/actions/midnight/redeem.js +18 -1
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +24 -2
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/supplyCollateral.js +3 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +49 -14
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +18 -5
- package/lib/cjs/actions/midnight/takeBorrow.js +44 -12
- package/lib/cjs/actions/midnight/takeLend.d.ts +10 -5
- package/lib/cjs/actions/midnight/takeLend.js +27 -9
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +51 -27
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +14 -5
- package/lib/cjs/actions/midnight/takeWithdraw.js +40 -9
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +17 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
- package/lib/cjs/actions/requirements/validateClientChainId.d.ts +26 -0
- package/lib/cjs/actions/requirements/validateClientChainId.js +34 -0
- 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 +3 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/types.d.ts +1 -1
- package/lib/cjs/blue/utils.d.ts +2 -2
- package/lib/cjs/blue/utils.js +5 -2
- package/lib/cjs/entities/blue/blue.d.ts +109 -27
- package/lib/cjs/entities/blue/blue.js +103 -28
- package/lib/cjs/entities/index.d.ts +5 -5
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/deadline.d.ts +15 -0
- package/lib/cjs/entities/midnight/deadline.js +24 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +427 -72
- package/lib/cjs/entities/midnight/midnight.js +864 -186
- package/lib/cjs/entities/midnight/publication.d.ts +134 -0
- package/lib/cjs/entities/midnight/publication.js +404 -0
- package/lib/cjs/entities/midnight/types.d.ts +26 -5
- package/lib/cjs/entities/requirements/assertContractCode.d.ts +49 -0
- package/lib/cjs/entities/requirements/assertContractCode.js +79 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +45 -18
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +5 -2
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +63 -11
- package/lib/cjs/entities/vaultV1/vaultV1.js +52 -15
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +62 -44
- package/lib/cjs/entities/vaultV2/vaultV2.js +53 -48
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +3 -9
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -10
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/constant.d.ts +5 -0
- package/lib/cjs/helpers/constant.js +6 -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 +163 -8
- package/lib/cjs/helpers/validate.js +179 -8
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +47 -0
- package/lib/cjs/helpers/validateMidnightBounds.js +79 -0
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +12 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +144 -0
- package/lib/cjs/helpers/validateMidnightReceiver.d.ts +29 -0
- package/lib/cjs/helpers/validateMidnightReceiver.js +84 -0
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +231 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +3 -0
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/types/error.d.ts +197 -4
- package/lib/cjs/types/error.js +265 -5
- package/lib/cjs/types/index.d.ts +1 -0
- package/lib/cjs/types/index.js +1 -0
- package/lib/cjs/types/midnightCancelAndMake.d.ts +70 -0
- package/lib/cjs/types/midnightCancelAndMake.js +2 -0
- package/lib/cjs/types/midnightPublicationError.d.ts +332 -0
- package/lib/cjs/types/midnightPublicationError.js +376 -0
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/utils.d.ts +4 -3
- package/lib/cjs/utils.js +8 -4
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -0
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +17 -71
- package/lib/esm/actions/midnight/cancelAndMake.js +42 -30
- package/lib/esm/actions/midnight/redeem.d.ts +8 -1
- package/lib/esm/actions/midnight/redeem.js +18 -1
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +19 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +24 -2
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/supplyCollateral.js +3 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +21 -6
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +52 -17
- package/lib/esm/actions/midnight/takeBorrow.d.ts +18 -5
- package/lib/esm/actions/midnight/takeBorrow.js +47 -15
- package/lib/esm/actions/midnight/takeLend.d.ts +10 -5
- package/lib/esm/actions/midnight/takeLend.js +27 -9
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +22 -7
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +52 -28
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +14 -5
- package/lib/esm/actions/midnight/takeWithdraw.js +41 -10
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +13 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +3 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +13 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +17 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +3 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +5 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +4 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +3 -1
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +5 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +3 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -1
- package/lib/esm/actions/requirements/validateClientChainId.d.ts +26 -0
- package/lib/esm/actions/requirements/validateClientChainId.js +30 -0
- 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/types.d.ts +1 -1
- package/lib/esm/blue/utils.d.ts +2 -2
- package/lib/esm/blue/utils.js +2 -2
- package/lib/esm/entities/blue/blue.d.ts +109 -27
- package/lib/esm/entities/blue/blue.js +104 -29
- package/lib/esm/entities/index.d.ts +5 -5
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/deadline.d.ts +15 -0
- package/lib/esm/entities/midnight/deadline.js +20 -0
- package/lib/esm/entities/midnight/midnight.d.ts +427 -72
- package/lib/esm/entities/midnight/midnight.js +865 -187
- package/lib/esm/entities/midnight/publication.d.ts +134 -0
- package/lib/esm/entities/midnight/publication.js +397 -0
- package/lib/esm/entities/midnight/types.d.ts +26 -5
- package/lib/esm/entities/requirements/assertContractCode.d.ts +49 -0
- package/lib/esm/entities/requirements/assertContractCode.js +74 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +19 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +47 -20
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +3 -2
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +5 -2
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -1
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +63 -11
- package/lib/esm/entities/vaultV1/vaultV1.js +53 -16
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +62 -44
- package/lib/esm/entities/vaultV2/vaultV2.js +54 -49
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +3 -5
- package/lib/esm/entities/vaultV2BlueReallocationData.js +3 -9
- 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 +5 -0
- package/lib/esm/helpers/constant.js +5 -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 +163 -8
- package/lib/esm/helpers/validate.js +177 -7
- package/lib/esm/helpers/validateMidnightBounds.d.ts +47 -0
- package/lib/esm/helpers/validateMidnightBounds.js +72 -0
- package/lib/esm/helpers/validateMidnightPublication.d.ts +12 -0
- package/lib/esm/helpers/validateMidnightPublication.js +139 -0
- package/lib/esm/helpers/validateMidnightReceiver.d.ts +29 -0
- package/lib/esm/helpers/validateMidnightReceiver.js +80 -0
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +102 -0
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +226 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/types/error.d.ts +197 -4
- package/lib/esm/types/error.js +253 -2
- package/lib/esm/types/index.d.ts +1 -0
- package/lib/esm/types/index.js +1 -0
- package/lib/esm/types/midnightCancelAndMake.d.ts +70 -0
- package/lib/esm/types/midnightCancelAndMake.js +1 -0
- package/lib/esm/types/midnightPublicationError.d.ts +332 -0
- package/lib/esm/types/midnightPublicationError.js +359 -0
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/utils.d.ts +4 -3
- package/lib/esm/utils.js +4 -3
- package/package.json +9 -8
|
@@ -7,8 +7,10 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
7
7
|
const viem_1 = require("viem");
|
|
8
8
|
const common_js_1 = require("../../actions/blue/common.js");
|
|
9
9
|
const index_js_1 = require("../../actions/index.js");
|
|
10
|
+
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
10
11
|
const index_js_2 = require("../../helpers/index.js");
|
|
11
12
|
const index_js_3 = require("../../types/index.js");
|
|
13
|
+
const assertContractCode_js_1 = require("../requirements/assertContractCode.js");
|
|
12
14
|
const index_js_4 = require("../requirements/index.js");
|
|
13
15
|
const vaultV2BlueReallocationData_js_1 = require("../vaultV2BlueReallocationData.js");
|
|
14
16
|
/** Binds a viem client to a Morpho Blue market's action builders. */
|
|
@@ -22,10 +24,9 @@ class MorphoBlue {
|
|
|
22
24
|
this.marketParams = marketParams;
|
|
23
25
|
this.chainId = chainId;
|
|
24
26
|
}
|
|
25
|
-
validateDeadline(deadline) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw new index_js_3.ExpiredDeadlineError(deadline, timestamp);
|
|
27
|
+
validateDeadline(deadline, now = morpho_ts_1.Time.timestamp()) {
|
|
28
|
+
if (deadline <= now) {
|
|
29
|
+
throw new index_js_3.ExpiredDeadlineError(deadline, now);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
validateWriteCommon(params) {
|
|
@@ -43,6 +44,30 @@ class MorphoBlue {
|
|
|
43
44
|
referralFeeRecipient: params.referralFeeRecipient,
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Asserts that every registry contract this flow's transaction targets or names as
|
|
49
|
+
* spender/authorized operator holds code, with one `eth_getCode` per distinct address
|
|
50
|
+
* before any other requirement read. Blue write flows probe `eth_chainId` only after a target
|
|
51
|
+
* has no code and report a chain mismatch when the RPC serves another chain.
|
|
52
|
+
*
|
|
53
|
+
* @param params.erc20Funding - Whether the flow resolves an ERC-20 funding leg, which
|
|
54
|
+
* may name canonical Permit2 when signatures are supported.
|
|
55
|
+
*/
|
|
56
|
+
async assertWriteTargets(params) {
|
|
57
|
+
const targets = [
|
|
58
|
+
{
|
|
59
|
+
role: "bundles.blueBundlesV1",
|
|
60
|
+
address: (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.blueBundlesV1"),
|
|
61
|
+
},
|
|
62
|
+
{ role: "blue", address: (0, morpho_ts_1.getChainAddress)(this.chainId, "blue") },
|
|
63
|
+
];
|
|
64
|
+
if (params?.erc20Funding && this.client.options.supportSignature) {
|
|
65
|
+
const permit2 = (0, morpho_ts_1.getChainAddresses)(this.chainId).permit2;
|
|
66
|
+
if (permit2 != null)
|
|
67
|
+
targets.push({ role: "permit2", address: permit2 });
|
|
68
|
+
}
|
|
69
|
+
await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
|
|
70
|
+
}
|
|
46
71
|
getMaxLtv(marketParams = this.marketParams) {
|
|
47
72
|
return blue_sdk_1.MathLib.zeroFloorSub(marketParams.lltv, index_js_2.DEFAULT_LLTV_BUFFER);
|
|
48
73
|
}
|
|
@@ -50,7 +75,7 @@ class MorphoBlue {
|
|
|
50
75
|
return blue_sdk_1.MathLib.max(morpho_ts_1.Time.timestamp(), lastUpdate) + morpho_ts_1.Time.s.from.h(2n);
|
|
51
76
|
}
|
|
52
77
|
async getTokenRequirements(params) {
|
|
53
|
-
this.validateDeadline(params.deadline);
|
|
78
|
+
this.validateDeadline(params.deadline, params.now);
|
|
54
79
|
return (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
|
|
55
80
|
token: params.token,
|
|
56
81
|
spender: (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.blueBundlesV1"),
|
|
@@ -63,10 +88,11 @@ class MorphoBlue {
|
|
|
63
88
|
useSimplePermit: params.useSimplePermit,
|
|
64
89
|
permit2Nonce: params.permit2Nonce,
|
|
65
90
|
approvalAmount: params.approvalAmount,
|
|
91
|
+
now: params.now,
|
|
66
92
|
});
|
|
67
93
|
}
|
|
68
94
|
async getAuthorizationRequirements(params) {
|
|
69
|
-
this.validateDeadline(params.deadline);
|
|
95
|
+
this.validateDeadline(params.deadline, params.now);
|
|
70
96
|
const requirement = await (0, index_js_1.getBlueAuthorizationRequirement)({
|
|
71
97
|
viemClient: this.client.viemClient,
|
|
72
98
|
chainId: this.chainId,
|
|
@@ -74,18 +100,19 @@ class MorphoBlue {
|
|
|
74
100
|
supportSignature: this.client.options.supportSignature,
|
|
75
101
|
authorized: (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.blueBundlesV1"),
|
|
76
102
|
deadline: params.deadline,
|
|
103
|
+
now: params.now,
|
|
77
104
|
});
|
|
78
105
|
return requirement == null ? [] : [requirement];
|
|
79
106
|
}
|
|
80
107
|
async getMarketData(parameters) {
|
|
81
|
-
(0,
|
|
108
|
+
await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
|
|
82
109
|
return (0, blue_sdk_viem_1.fetchMarket)(this.marketParams.id, this.client.viemClient, {
|
|
83
110
|
...parameters,
|
|
84
111
|
deployless: this.client.options.supportDeployless,
|
|
85
112
|
});
|
|
86
113
|
}
|
|
87
114
|
async getPositionData(userAddress, parameters) {
|
|
88
|
-
(0,
|
|
115
|
+
await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
|
|
89
116
|
return (0, blue_sdk_viem_1.fetchAccrualPosition)(userAddress, this.marketParams.id, this.client.viemClient, {
|
|
90
117
|
...parameters,
|
|
91
118
|
deployless: this.client.options.supportDeployless,
|
|
@@ -105,17 +132,23 @@ class MorphoBlue {
|
|
|
105
132
|
});
|
|
106
133
|
return {
|
|
107
134
|
getRequirements: (requirementsParams) => {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
135
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
136
|
+
this.validateDeadline(deadline, now);
|
|
137
|
+
return this.assertWriteTargets({
|
|
138
|
+
erc20Funding: nativeValue === 0n,
|
|
139
|
+
}).then(() => {
|
|
140
|
+
if (nativeValue > 0n)
|
|
141
|
+
return [];
|
|
142
|
+
return this.getTokenRequirements({
|
|
143
|
+
token: this.marketParams.loanToken,
|
|
144
|
+
amount: assets,
|
|
145
|
+
userAddress,
|
|
146
|
+
deadline,
|
|
147
|
+
now,
|
|
148
|
+
useSimplePermit: requirementsParams?.useSimplePermit,
|
|
149
|
+
permit2Nonce: requirementsParams?.permit2Nonce,
|
|
150
|
+
approvalAmount: requirementsParams?.approvalAmount,
|
|
151
|
+
});
|
|
119
152
|
});
|
|
120
153
|
},
|
|
121
154
|
buildTx: (signatures) => {
|
|
@@ -189,7 +222,16 @@ class MorphoBlue {
|
|
|
189
222
|
});
|
|
190
223
|
}
|
|
191
224
|
return {
|
|
192
|
-
getRequirements: () =>
|
|
225
|
+
getRequirements: async () => {
|
|
226
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
227
|
+
this.validateDeadline(deadline, now);
|
|
228
|
+
await this.assertWriteTargets();
|
|
229
|
+
return this.getAuthorizationRequirements({
|
|
230
|
+
userAddress,
|
|
231
|
+
deadline,
|
|
232
|
+
now,
|
|
233
|
+
});
|
|
234
|
+
},
|
|
193
235
|
buildTx: (signatures) => {
|
|
194
236
|
const { authorization } = (0, common_js_1.selectBlueBundlesV1RequirementSignatures)(signatures, {
|
|
195
237
|
authorization: true,
|
|
@@ -433,7 +475,11 @@ class MorphoBlue {
|
|
|
433
475
|
}
|
|
434
476
|
return {
|
|
435
477
|
getRequirements: async (requirementsParams) => {
|
|
436
|
-
|
|
478
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
479
|
+
this.validateDeadline(deadline, now);
|
|
480
|
+
await this.assertWriteTargets({
|
|
481
|
+
erc20Funding: hasRepay && nativeValue === 0n,
|
|
482
|
+
});
|
|
437
483
|
const [tokenRequirements, authorizationRequirements] = await Promise.all([
|
|
438
484
|
hasRepay && nativeValue === 0n
|
|
439
485
|
? this.getTokenRequirements({
|
|
@@ -442,12 +488,17 @@ class MorphoBlue {
|
|
|
442
488
|
approvalAmount: requirementsParams?.approvalAmount,
|
|
443
489
|
userAddress,
|
|
444
490
|
deadline,
|
|
491
|
+
now,
|
|
445
492
|
useSimplePermit: requirementsParams?.useSimplePermit,
|
|
446
493
|
permit2Nonce: requirementsParams?.permit2Nonce,
|
|
447
494
|
})
|
|
448
495
|
: Promise.resolve([]),
|
|
449
496
|
collateralAssets > 0n
|
|
450
|
-
? this.getAuthorizationRequirements({
|
|
497
|
+
? this.getAuthorizationRequirements({
|
|
498
|
+
userAddress,
|
|
499
|
+
deadline,
|
|
500
|
+
now,
|
|
501
|
+
})
|
|
451
502
|
: Promise.resolve([]),
|
|
452
503
|
]);
|
|
453
504
|
return [...tokenRequirements, ...authorizationRequirements];
|
|
@@ -536,7 +587,11 @@ class MorphoBlue {
|
|
|
536
587
|
});
|
|
537
588
|
return {
|
|
538
589
|
getRequirements: async (requirementsParams) => {
|
|
539
|
-
|
|
590
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
591
|
+
this.validateDeadline(deadline, now);
|
|
592
|
+
await this.assertWriteTargets({
|
|
593
|
+
erc20Funding: collateralAssets > 0n && nativeValue === 0n,
|
|
594
|
+
});
|
|
540
595
|
const [tokenRequirements, authorizationRequirements] = await Promise.all([
|
|
541
596
|
collateralAssets > 0n && nativeValue === 0n
|
|
542
597
|
? this.getTokenRequirements({
|
|
@@ -545,12 +600,17 @@ class MorphoBlue {
|
|
|
545
600
|
approvalAmount: requirementsParams?.approvalAmount,
|
|
546
601
|
userAddress,
|
|
547
602
|
deadline,
|
|
603
|
+
now,
|
|
548
604
|
useSimplePermit: requirementsParams?.useSimplePermit,
|
|
549
605
|
permit2Nonce: requirementsParams?.permit2Nonce,
|
|
550
606
|
})
|
|
551
607
|
: Promise.resolve([]),
|
|
552
608
|
borrowAssets > 0n
|
|
553
|
-
? this.getAuthorizationRequirements({
|
|
609
|
+
? this.getAuthorizationRequirements({
|
|
610
|
+
userAddress,
|
|
611
|
+
deadline,
|
|
612
|
+
now,
|
|
613
|
+
})
|
|
554
614
|
: Promise.resolve([]),
|
|
555
615
|
]);
|
|
556
616
|
return [...tokenRequirements, ...authorizationRequirements];
|
|
@@ -628,7 +688,16 @@ class MorphoBlue {
|
|
|
628
688
|
lltv: destination.marketParams.lltv,
|
|
629
689
|
});
|
|
630
690
|
return {
|
|
631
|
-
getRequirements: () =>
|
|
691
|
+
getRequirements: async () => {
|
|
692
|
+
const now = morpho_ts_1.Time.timestamp();
|
|
693
|
+
this.validateDeadline(deadline, now);
|
|
694
|
+
await this.assertWriteTargets();
|
|
695
|
+
return this.getAuthorizationRequirements({
|
|
696
|
+
userAddress,
|
|
697
|
+
deadline,
|
|
698
|
+
now,
|
|
699
|
+
});
|
|
700
|
+
},
|
|
632
701
|
buildTx: (signatures) => {
|
|
633
702
|
const { authorization } = (0, common_js_1.selectBlueBundlesV1RequirementSignatures)(signatures, {
|
|
634
703
|
authorization: true,
|
|
@@ -663,13 +732,19 @@ class MorphoBlue {
|
|
|
663
732
|
* @param params.block.number - Block number used for every RPC read.
|
|
664
733
|
* @param params.block.timestamp - Timestamp corresponding to the fetched block.
|
|
665
734
|
* @returns A `VaultV2BlueReallocationData` snapshot ready for {@link getVaultV2BlueReallocations}.
|
|
666
|
-
* @throws {ChainIdMismatchError} when the client chain
|
|
735
|
+
* @throws {ChainIdMismatchError} when the client declares another chain or its RPC reports another
|
|
736
|
+
* chain via `eth_chainId`.
|
|
667
737
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
668
738
|
* @throws {UnknownAddressError} when the chain has no BluePublicAllocator deployment.
|
|
669
739
|
* @throws {UnknownBlueFactory} when the chain has no Vault V2 factory.
|
|
670
740
|
* @throws {UnknownBlueOfFactory} when a requested address is not a Vault V2 from that factory.
|
|
671
741
|
* @throws {UnsupportedBlueVaultV2AdapterError} when a vault contains an unsupported adapter.
|
|
672
|
-
* @throws {
|
|
742
|
+
* @throws {UnknownTokenError} when a vault's share token has unusable decimals.
|
|
743
|
+
* @throws {MalformedTokenMetadataError} when the share token's `eip712Domain()` or
|
|
744
|
+
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
745
|
+
* deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
|
|
746
|
+
* @throws {viem.BaseError} when the `eth_chainId` request fails or a later RPC or contract read
|
|
747
|
+
* fails with no fallback left.
|
|
673
748
|
* @example
|
|
674
749
|
* ```ts
|
|
675
750
|
* import { markets } from "@morpho-org/morpho-test";
|
|
@@ -691,7 +766,7 @@ class MorphoBlue {
|
|
|
691
766
|
* ```
|
|
692
767
|
*/
|
|
693
768
|
async getVaultV2BlueReallocationData({ vaultAddresses, block, }) {
|
|
694
|
-
(0,
|
|
769
|
+
await (0, validateClientChainId_js_1.validateClientChainId)(this.client.viemClient, this.chainId);
|
|
695
770
|
const client = this.client.viemClient;
|
|
696
771
|
const fetchParams = {
|
|
697
772
|
blockNumber: block.number,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter,
|
|
1
|
+
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams as IBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig,
|
|
6
|
-
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2,
|
|
5
|
+
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
-
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig,
|
|
10
|
+
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
11
|
export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
|
|
12
12
|
export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
|
|
13
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
14
14
|
export { MorphoBlue } from "./blue/index.js";
|
|
15
|
-
export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, MidnightMakerTreeInput, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyBlueMakeLendParams as MidnightSupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, TakeRepayWithdrawCollateralParams as MidnightTakeRepayWithdrawCollateralParams, TakeWithdrawParams as MidnightTakeWithdrawParams, } from "./midnight/index.js";
|
|
15
|
+
export type { GetOffersDataParams as MidnightGetOffersDataParams, GetPositionDataParams as MidnightGetPositionDataParams, MakeLendParams as MidnightMakeLendParams, MakeOffersOutput as MidnightMakeOffersOutput, MakeOffersParams as MidnightMakeOffersParams, MarketActionParams as MidnightMarketActionParams, MidnightMakerTreeInput, MidnightPositionHealthParams, OffersData as MidnightOffersData, OfferValidationParams as MidnightOfferValidationParams, RedeemParams as MidnightRedeemParams, RepayWithdrawCollateralParams as MidnightRepayWithdrawCollateralParams, SupplyBlueMakeLendParams as MidnightSupplyBlueMakeLendParams, SupplyCollateralMakeBorrowParams as MidnightSupplyCollateralMakeBorrowParams, SupplyCollateralParams as MidnightSupplyCollateralParams, SupplyCollateralTakeBorrowParams as MidnightSupplyCollateralTakeBorrowParams, TakeBorrowParams as MidnightTakeBorrowParams, TakeLendParams as MidnightTakeLendParams, TakeRepayWithdrawCollateralParams as MidnightTakeRepayWithdrawCollateralParams, TakeWithdrawParams as MidnightTakeWithdrawParams, } from "./midnight/index.js";
|
|
16
16
|
export { type MidnightActionOutput, type MidnightActions, type MidnightRequirementsParams, MorphoMidnight, } from "./midnight/index.js";
|
|
17
17
|
export * from "./requirements/index.js";
|
|
18
18
|
export { MorphoVaultV1 } from "./vaultV1/index.js";
|
|
@@ -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; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rejects a Midnight bundle deadline that is not strictly after `now`.
|
|
3
|
+
*
|
|
4
|
+
* Midnight bundles revert with `DeadlinePassed()` once the deadline has passed, so a deadline at
|
|
5
|
+
* or before `now` builds a transaction that cannot succeed. `maxUint256` still means
|
|
6
|
+
* "no expiry". The check uses the local clock (`Time.timestamp()`), not chain time. Transaction
|
|
7
|
+
* builders stay clock-free and only check the deadline's `uint256` shape.
|
|
8
|
+
*
|
|
9
|
+
* @param deadline - Bundle execution deadline timestamp, in seconds.
|
|
10
|
+
* @param now - Reference timestamp, in seconds. Defaults to `Time.timestamp()`.
|
|
11
|
+
* @returns Nothing when `deadline` is after `now`.
|
|
12
|
+
* @throws {ExpiredDeadlineError} when `deadline` is at or before `now`.
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare const validateMidnightDeadline: (deadline: bigint, now?: bigint) => void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateMidnightDeadline = void 0;
|
|
4
|
+
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
+
const index_js_1 = require("../../types/index.js");
|
|
6
|
+
/**
|
|
7
|
+
* Rejects a Midnight bundle deadline that is not strictly after `now`.
|
|
8
|
+
*
|
|
9
|
+
* Midnight bundles revert with `DeadlinePassed()` once the deadline has passed, so a deadline at
|
|
10
|
+
* or before `now` builds a transaction that cannot succeed. `maxUint256` still means
|
|
11
|
+
* "no expiry". The check uses the local clock (`Time.timestamp()`), not chain time. Transaction
|
|
12
|
+
* builders stay clock-free and only check the deadline's `uint256` shape.
|
|
13
|
+
*
|
|
14
|
+
* @param deadline - Bundle execution deadline timestamp, in seconds.
|
|
15
|
+
* @param now - Reference timestamp, in seconds. Defaults to `Time.timestamp()`.
|
|
16
|
+
* @returns Nothing when `deadline` is after `now`.
|
|
17
|
+
* @throws {ExpiredDeadlineError} when `deadline` is at or before `now`.
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
const validateMidnightDeadline = (deadline, now = morpho_ts_1.Time.timestamp()) => {
|
|
21
|
+
if (deadline <= now)
|
|
22
|
+
throw new index_js_1.ExpiredDeadlineError(deadline, now);
|
|
23
|
+
};
|
|
24
|
+
exports.validateMidnightDeadline = validateMidnightDeadline;
|