@morpho-org/morpho-sdk 6.6.0 → 7.1.0-next.1
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-v6-to-v7.md +297 -0
- package/README.md +26 -12
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +7 -2
- package/lib/cjs/actions/bundles/common.d.ts +9 -5
- package/lib/cjs/actions/bundles/common.js +22 -13
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
- package/lib/cjs/actions/midnight/authorization.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
- package/lib/cjs/actions/midnight/index.d.ts +3 -3
- package/lib/cjs/actions/midnight/index.js +3 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
- package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
- package/lib/cjs/actions/midnight/takeLend.js +111 -54
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
- package/lib/cjs/actions/midnight/types.d.ts +7 -26
- package/lib/cjs/actions/midnight/types.js +0 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/midnight/index.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/entities/index.d.ts +6 -6
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +585 -108
- package/lib/cjs/entities/midnight/midnight.js +984 -509
- package/lib/cjs/entities/midnight/types.d.ts +142 -60
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +32 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/cjs/entities/vaultV2/vaultV2.js +68 -41
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +10 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/callback.d.ts +54 -0
- package/lib/cjs/helpers/callback.js +73 -0
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +6 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/cjs/helpers/validate.d.ts +43 -2
- package/lib/cjs/helpers/validate.js +60 -3
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -2
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/types/action.d.ts +219 -90
- package/lib/cjs/types/action.js +103 -20
- package/lib/cjs/types/error.d.ts +126 -40
- package/lib/cjs/types/error.js +154 -49
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +9 -5
- package/lib/esm/actions/bundles/common.js +22 -13
- package/lib/esm/actions/midnight/authorization.d.ts +3 -2
- package/lib/esm/actions/midnight/authorization.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
- package/lib/esm/actions/midnight/index.d.ts +3 -3
- package/lib/esm/actions/midnight/index.js +3 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
- package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/esm/actions/midnight/takeBorrow.js +98 -57
- package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
- package/lib/esm/actions/midnight/takeLend.js +114 -57
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
- package/lib/esm/actions/midnight/types.d.ts +7 -26
- package/lib/esm/actions/midnight/types.js +1 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/esm/actions/requirements/midnight/index.js +0 -1
- 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 +6 -6
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +585 -108
- package/lib/esm/entities/midnight/midnight.js +990 -515
- package/lib/esm/entities/midnight/types.d.ts +142 -60
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +33 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/esm/entities/vaultV2/vaultV2.js +69 -42
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
- 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/callback.d.ts +54 -0
- package/lib/esm/helpers/callback.js +68 -0
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/esm/helpers/validate.d.ts +43 -2
- package/lib/esm/helpers/validate.js +58 -2
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/esm/helpers/validateRequirementSpender.js +4 -5
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/types/action.d.ts +219 -90
- package/lib/esm/types/action.js +103 -19
- package/lib/esm/types/error.d.ts +126 -40
- package/lib/esm/types/error.js +135 -38
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +10 -10
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
- package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/esm/actions/midnight/cancelOffer.js +0 -69
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
package/lib/esm/types/action.js
CHANGED
|
@@ -1,4 +1,48 @@
|
|
|
1
1
|
import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "./error.js";
|
|
2
|
+
/**
|
|
3
|
+
* Narrows an action requirement to an ERC-20 approval transaction.
|
|
4
|
+
*
|
|
5
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
6
|
+
* @returns `true` when `requirement.action.type` is `"erc20Approval"`.
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
10
|
+
* import {
|
|
11
|
+
* isRequirementApproval,
|
|
12
|
+
* morphoViemExtension,
|
|
13
|
+
* } from "@morpho-org/morpho-sdk";
|
|
14
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
15
|
+
* import { mainnet } from "viem/chains";
|
|
16
|
+
*
|
|
17
|
+
* const client = createWalletClient({
|
|
18
|
+
* chain: mainnet,
|
|
19
|
+
* transport: http(),
|
|
20
|
+
* account: zeroAddress,
|
|
21
|
+
* })
|
|
22
|
+
* .extend(publicActions)
|
|
23
|
+
* .extend(morphoViemExtension());
|
|
24
|
+
*
|
|
25
|
+
* const vault = client.morpho.vaultV1(
|
|
26
|
+
* vaults[mainnet.id].steakUsdc.address,
|
|
27
|
+
* mainnet.id,
|
|
28
|
+
* );
|
|
29
|
+
* const vaultData = await vault.getData();
|
|
30
|
+
* const handle = vault.deposit({
|
|
31
|
+
* amount: 1_000_000n,
|
|
32
|
+
* userAddress: zeroAddress,
|
|
33
|
+
* vaultData,
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
37
|
+
* if (!isRequirementApproval(requirement)) continue;
|
|
38
|
+
*
|
|
39
|
+
* const { amount, spender } = requirement.action.args;
|
|
40
|
+
* const hash = await client.sendTransaction(requirement);
|
|
41
|
+
* console.log({ amount, spender, hash });
|
|
42
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
43
|
+
* }
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
2
46
|
export function isRequirementApproval(requirement) {
|
|
3
47
|
return (typeof requirement === "object" &&
|
|
4
48
|
requirement !== null &&
|
|
@@ -11,7 +55,54 @@ export function isRequirementApproval(requirement) {
|
|
|
11
55
|
"type" in requirement.action &&
|
|
12
56
|
requirement.action.type === "erc20Approval");
|
|
13
57
|
}
|
|
14
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* Narrows an action requirement to a Blue authorization call.
|
|
60
|
+
*
|
|
61
|
+
* @param requirement - The requirement returned by `getRequirements()` to test.
|
|
62
|
+
* @returns `true` when the requirement is a call whose `action.type` is `"blueAuthorization"`.
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* import { AccrualPosition } from "@morpho-org/blue-sdk";
|
|
66
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
67
|
+
* import { Time } from "@morpho-org/morpho-ts";
|
|
68
|
+
* import { createWalletClient, http, publicActions, zeroAddress } from "viem";
|
|
69
|
+
* import { mainnet } from "viem/chains";
|
|
70
|
+
* import {
|
|
71
|
+
* isRequirementBlueAuthorization,
|
|
72
|
+
* morphoViemExtension,
|
|
73
|
+
* } from "@morpho-org/morpho-sdk";
|
|
74
|
+
*
|
|
75
|
+
* const client = createWalletClient({
|
|
76
|
+
* chain: mainnet,
|
|
77
|
+
* transport: http(),
|
|
78
|
+
* account: zeroAddress,
|
|
79
|
+
* })
|
|
80
|
+
* .extend(publicActions)
|
|
81
|
+
* .extend(morphoViemExtension());
|
|
82
|
+
*
|
|
83
|
+
* const blue = client.morpho.blue(
|
|
84
|
+
* markets[mainnet.id].usdc_wbtc,
|
|
85
|
+
* mainnet.id,
|
|
86
|
+
* );
|
|
87
|
+
* const positionData = new AccrualPosition(
|
|
88
|
+
* { user: zeroAddress, supplyShares: 0n, borrowShares: 0n, collateral: 10n ** 8n },
|
|
89
|
+
* await blue.getMarketData(),
|
|
90
|
+
* );
|
|
91
|
+
* const handle = blue.borrow({
|
|
92
|
+
* userAddress: zeroAddress,
|
|
93
|
+
* borrowAssets: 1_000_000n,
|
|
94
|
+
* positionData,
|
|
95
|
+
* deadline: Time.timestamp() + 600n,
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* for (const requirement of await handle.getRequirements()) {
|
|
99
|
+
* if (!isRequirementBlueAuthorization(requirement)) continue;
|
|
100
|
+
*
|
|
101
|
+
* const hash = await client.sendTransaction(requirement);
|
|
102
|
+
* await client.waitForTransactionReceipt({ hash });
|
|
103
|
+
* }
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
15
106
|
export function isRequirementBlueAuthorization(requirement) {
|
|
16
107
|
return (typeof requirement === "object" &&
|
|
17
108
|
requirement !== null &&
|
|
@@ -74,19 +165,20 @@ export function isPermit2SignatureTransferSignature(signature) {
|
|
|
74
165
|
*
|
|
75
166
|
* @param signature - The signed requirement to test.
|
|
76
167
|
* @returns `true` when `signature.action.type` is `"authorization"`.
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* import {
|
|
171
|
+
* isAuthorizationSignature,
|
|
172
|
+
* type RequirementSignature,
|
|
173
|
+
* } from "@morpho-org/morpho-sdk";
|
|
174
|
+
*
|
|
175
|
+
* const getAuthorizationNonce = (signature: RequirementSignature): bigint | undefined =>
|
|
176
|
+
* isAuthorizationSignature(signature) ? signature.args.nonce : undefined;
|
|
177
|
+
* ```
|
|
77
178
|
*/
|
|
78
179
|
export function isAuthorizationSignature(signature) {
|
|
79
180
|
return signature.action.type === "authorization";
|
|
80
181
|
}
|
|
81
|
-
/**
|
|
82
|
-
* Narrows a {@link RequirementSignature} to a Midnight offer-root signature.
|
|
83
|
-
*
|
|
84
|
-
* @param signature - The signed requirement to test.
|
|
85
|
-
* @returns `true` when `signature.action.type` is `"midnightOfferRootSignature"`.
|
|
86
|
-
*/
|
|
87
|
-
export function isMidnightOfferRootSignature(signature) {
|
|
88
|
-
return signature.action.type === "midnightOfferRootSignature";
|
|
89
|
-
}
|
|
90
182
|
/**
|
|
91
183
|
* Splits a `buildTx` signature array into its typed requirement-signature slots, rejecting
|
|
92
184
|
* ambiguous or unexpected input so a path never silently consumes the wrong signature.
|
|
@@ -101,7 +193,6 @@ export function isMidnightOfferRootSignature(signature) {
|
|
|
101
193
|
* @param accepts.permit - Whether an ERC-2612 signature is consumed.
|
|
102
194
|
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
103
195
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
104
|
-
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
105
196
|
* @returns The accepted signature in each typed slot, when present.
|
|
106
197
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
107
198
|
* @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
|
|
@@ -122,11 +213,9 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
122
213
|
const permits = signatures.filter(isPermitSignature);
|
|
123
214
|
const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
|
|
124
215
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
125
|
-
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
126
216
|
const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
|
|
127
217
|
!isPermit2SignatureTransferSignature(signature) &&
|
|
128
|
-
!isAuthorizationSignature(signature)
|
|
129
|
-
!isMidnightOfferRootSignature(signature));
|
|
218
|
+
!isAuthorizationSignature(signature));
|
|
130
219
|
if (unsupported != null)
|
|
131
220
|
throw new UnsupportedRequirementSignatureError(unsupported.action.type);
|
|
132
221
|
if (!accepts.permit && permits.length > 0)
|
|
@@ -135,20 +224,15 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
135
224
|
throw new UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
136
225
|
if (!accepts.authorization && authorizations.length > 0)
|
|
137
226
|
throw new UnexpectedRequirementSignatureError("authorization");
|
|
138
|
-
if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
|
|
139
|
-
throw new UnexpectedRequirementSignatureError("midnightOfferRootSignature");
|
|
140
227
|
if (permits.length > 1)
|
|
141
228
|
throw new AmbiguousRequirementSignaturesError("permit", permits.length);
|
|
142
229
|
if (permit2Transfers.length > 1)
|
|
143
230
|
throw new AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
|
|
144
231
|
if (authorizations.length > 1)
|
|
145
232
|
throw new AmbiguousRequirementSignaturesError("authorization", authorizations.length);
|
|
146
|
-
if (midnightOfferRoots.length > 1)
|
|
147
|
-
throw new AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
|
|
148
233
|
return {
|
|
149
234
|
permit: permits[0],
|
|
150
235
|
permit2SignatureTransfer: permit2Transfers[0],
|
|
151
236
|
authorization: authorizations[0],
|
|
152
|
-
midnightOfferRoot: midnightOfferRoots[0],
|
|
153
237
|
};
|
|
154
238
|
}
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -500,7 +500,8 @@ export declare class BundlesPermitMismatchError extends Error {
|
|
|
500
500
|
/**
|
|
501
501
|
* @param params - Permit mismatch values used to explain the rejection.
|
|
502
502
|
* @param params.field - Permit field that does not match the exit.
|
|
503
|
-
* @param params.expected - Value required by the exit.
|
|
503
|
+
* @param params.expected - Value required by the exit. For `field: "amount"` on an
|
|
504
|
+
* operation that accepts a range of permit amounts, an inclusive `"[min, max]"` range.
|
|
504
505
|
* @param params.actual - Value supplied by the signature.
|
|
505
506
|
* @param params.cause - Original parser failure when signature decoding is wrapped.
|
|
506
507
|
*/
|
|
@@ -632,7 +633,7 @@ export declare class MaxRepayAssetsBelowRepayAssetsError extends Error {
|
|
|
632
633
|
constructor(maxRepayAssets: bigint, repayAssets: bigint);
|
|
633
634
|
}
|
|
634
635
|
/** Requirement signature kind accepted by action-output transaction builders. */
|
|
635
|
-
export type RequirementSignatureKind = "permit" | "permit2SignatureTransfer" | "authorization"
|
|
636
|
+
export type RequirementSignatureKind = "permit" | "permit2SignatureTransfer" | "authorization";
|
|
636
637
|
/**
|
|
637
638
|
* Thrown when `buildTx` receives more than one requirement signature of the same kind.
|
|
638
639
|
*
|
|
@@ -709,11 +710,10 @@ export declare class UnsupportedErc20ApprovalSpenderError extends Error {
|
|
|
709
710
|
readonly chainId: number;
|
|
710
711
|
readonly permit2?: Address;
|
|
711
712
|
readonly midnight?: Address;
|
|
712
|
-
readonly midnightBundles?: Address;
|
|
713
713
|
readonly supportedSpenders?: readonly (Address | undefined)[];
|
|
714
714
|
});
|
|
715
715
|
}
|
|
716
|
-
/** Thrown when a Midnight authorization requirement
|
|
716
|
+
/** Thrown when a Midnight authorization target (a requirement operator, or the ratifier that `midnightCancelAndMake` activates and MidnightBundlesV2 authorizes) is not registered for the chain. */
|
|
717
717
|
export declare class UnsupportedMidnightAuthorizationTargetError extends Error {
|
|
718
718
|
constructor(params: {
|
|
719
719
|
readonly authorized: Address;
|
|
@@ -1027,12 +1027,19 @@ export declare class ReallocationAdapterSupplySharesUnderflowError extends Error
|
|
|
1027
1027
|
readonly withdrawnShares: bigint;
|
|
1028
1028
|
});
|
|
1029
1029
|
}
|
|
1030
|
-
/** Thrown when a Midnight
|
|
1031
|
-
export declare class
|
|
1030
|
+
/** Thrown when a Midnight batch cancellation has no offer groups. */
|
|
1031
|
+
export declare class EmptyMidnightGroupCancellationsError extends Error {
|
|
1032
|
+
constructor();
|
|
1033
|
+
}
|
|
1034
|
+
/** Thrown when a Midnight flow passes a collateral market with no collateral supplies. */
|
|
1035
|
+
export declare class EmptyMidnightCollateralSuppliesError extends Error {
|
|
1036
|
+
constructor();
|
|
1037
|
+
}
|
|
1038
|
+
/** Thrown when a Midnight batch cancellation lists the same offer group twice. */
|
|
1039
|
+
export declare class DuplicateMidnightGroupCancellationError extends Error {
|
|
1032
1040
|
constructor(params: {
|
|
1033
|
-
readonly
|
|
1034
|
-
readonly
|
|
1035
|
-
readonly maxOfferCap: bigint;
|
|
1041
|
+
readonly index: number;
|
|
1042
|
+
readonly group: Hex;
|
|
1036
1043
|
});
|
|
1037
1044
|
}
|
|
1038
1045
|
/** Thrown when a Midnight flow needs at least one takeable offer. */
|
|
@@ -1047,6 +1054,12 @@ export declare class MidnightOfferSideMismatchError extends Error {
|
|
|
1047
1054
|
actualBuy: boolean;
|
|
1048
1055
|
});
|
|
1049
1056
|
}
|
|
1057
|
+
/** Thrown when a Midnight maker method that is not a limit exit receives a reduce-only offer. */
|
|
1058
|
+
export declare class MidnightOfferReduceOnlyError extends Error {
|
|
1059
|
+
constructor(params: {
|
|
1060
|
+
readonly index: number;
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1050
1063
|
/** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
|
|
1051
1064
|
export declare class MidnightOfferMakerMismatchError extends Error {
|
|
1052
1065
|
constructor(params: {
|
|
@@ -1055,6 +1068,74 @@ export declare class MidnightOfferMakerMismatchError extends Error {
|
|
|
1055
1068
|
readonly actualMaker: Address;
|
|
1056
1069
|
});
|
|
1057
1070
|
}
|
|
1071
|
+
/** Thrown when a Midnight maker offer sets a nonzero continuous fee cap. */
|
|
1072
|
+
export declare class MidnightOfferContinuousFeeCapError extends Error {
|
|
1073
|
+
/** Offer index in the maker tree. */
|
|
1074
|
+
readonly index: number;
|
|
1075
|
+
/** Continuous fee cap supplied on the offer. */
|
|
1076
|
+
readonly continuousFeeCap: bigint;
|
|
1077
|
+
/**
|
|
1078
|
+
* @param params - Offer index and rejected fee cap.
|
|
1079
|
+
* @param params.index - Offer index in the maker tree.
|
|
1080
|
+
* @param params.continuousFeeCap - Continuous fee cap supplied on the offer.
|
|
1081
|
+
*/
|
|
1082
|
+
constructor(params: {
|
|
1083
|
+
readonly index: number;
|
|
1084
|
+
readonly continuousFeeCap: bigint;
|
|
1085
|
+
});
|
|
1086
|
+
}
|
|
1087
|
+
/** Thrown when a Midnight sell offer routes its seller proceeds to another address. */
|
|
1088
|
+
export declare class MidnightOfferSellerReceiverMismatchError extends Error {
|
|
1089
|
+
/** Offer index in the maker tree. */
|
|
1090
|
+
readonly index: number;
|
|
1091
|
+
/** Offer maker, which must receive seller proceeds. */
|
|
1092
|
+
readonly expectedReceiver: Address;
|
|
1093
|
+
/** Seller receiver supplied on the offer. */
|
|
1094
|
+
readonly actualReceiver: Address;
|
|
1095
|
+
/**
|
|
1096
|
+
* @param params - Offer index and expected and actual seller receivers.
|
|
1097
|
+
* @param params.index - Offer index in the maker tree.
|
|
1098
|
+
* @param params.expectedReceiver - Offer maker, which must receive seller proceeds.
|
|
1099
|
+
* @param params.actualReceiver - Seller receiver supplied on the offer.
|
|
1100
|
+
*/
|
|
1101
|
+
constructor(params: {
|
|
1102
|
+
readonly index: number;
|
|
1103
|
+
readonly expectedReceiver: Address;
|
|
1104
|
+
readonly actualReceiver: Address;
|
|
1105
|
+
});
|
|
1106
|
+
}
|
|
1107
|
+
/** Thrown when a Midnight taker flow uses an unbounded target or deadline. */
|
|
1108
|
+
export declare class UnboundedMidnightTakeInputError extends Error {
|
|
1109
|
+
readonly field: "target.units" | "target.maxBuyerAssets" | "target.maxUnits" | "deadline";
|
|
1110
|
+
/**
|
|
1111
|
+
* @param field - Target or deadline input set to `maxUint256`.
|
|
1112
|
+
*/
|
|
1113
|
+
constructor(field: "target.units" | "target.maxBuyerAssets" | "target.maxUnits" | "deadline");
|
|
1114
|
+
}
|
|
1115
|
+
/** Thrown when a Midnight taker flow uses a zero address as its receiver. */
|
|
1116
|
+
export declare class MidnightZeroReceiverError extends Error {
|
|
1117
|
+
readonly field: "receiver";
|
|
1118
|
+
/**
|
|
1119
|
+
* @param field - Receiver field containing the zero address.
|
|
1120
|
+
*/
|
|
1121
|
+
constructor(field: "receiver");
|
|
1122
|
+
}
|
|
1123
|
+
/** Thrown when a Midnight take deadline is more than one hour from the current time. */
|
|
1124
|
+
export declare class MidnightTakeDeadlineTooFarError extends Error {
|
|
1125
|
+
/** Deadline supplied by the caller. */
|
|
1126
|
+
readonly deadline: bigint;
|
|
1127
|
+
/** Accepted maximum deadline. */
|
|
1128
|
+
readonly maxDeadline: bigint;
|
|
1129
|
+
/**
|
|
1130
|
+
* @param params - Supplied deadline and accepted maximum.
|
|
1131
|
+
* @param params.deadline - Deadline supplied by the caller.
|
|
1132
|
+
* @param params.maxDeadline - Latest accepted deadline.
|
|
1133
|
+
*/
|
|
1134
|
+
constructor(params: {
|
|
1135
|
+
readonly deadline: bigint;
|
|
1136
|
+
readonly maxDeadline: bigint;
|
|
1137
|
+
});
|
|
1138
|
+
}
|
|
1058
1139
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1059
1140
|
export declare class MidnightOfferMarketChainMismatchError extends Error {
|
|
1060
1141
|
constructor(params: {
|
|
@@ -1086,58 +1167,57 @@ export declare class MidnightOfferMarketLoanTokenMismatchError extends Error {
|
|
|
1086
1167
|
readonly actualLoanToken: Address;
|
|
1087
1168
|
});
|
|
1088
1169
|
}
|
|
1089
|
-
/** Thrown when a
|
|
1090
|
-
export declare class
|
|
1170
|
+
/** Thrown when a Blue-funded Midnight lend offer does not use the maker's derived `BlueBuyCallback`. */
|
|
1171
|
+
export declare class MidnightOfferCallbackMismatchError extends Error {
|
|
1091
1172
|
constructor(params: {
|
|
1092
|
-
index: number;
|
|
1093
|
-
|
|
1094
|
-
|
|
1173
|
+
readonly index: number;
|
|
1174
|
+
readonly expectedCallback: Address;
|
|
1175
|
+
readonly actualCallback: Address;
|
|
1095
1176
|
});
|
|
1096
1177
|
}
|
|
1097
|
-
/** Thrown when a Midnight offer
|
|
1098
|
-
export declare class
|
|
1178
|
+
/** Thrown when a Blue-funded Midnight lend offer's callback data is not the ABI-encoded Blue market. */
|
|
1179
|
+
export declare class MidnightOfferCallbackDataMismatchError extends Error {
|
|
1099
1180
|
constructor(params: {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1181
|
+
readonly index: number;
|
|
1182
|
+
readonly expectedCallbackData: Hex;
|
|
1183
|
+
readonly actualCallbackData: Hex;
|
|
1103
1184
|
});
|
|
1104
1185
|
}
|
|
1105
|
-
/** Thrown when
|
|
1106
|
-
export declare class
|
|
1107
|
-
constructor(
|
|
1186
|
+
/** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
|
|
1187
|
+
export declare class EmptyBlueParkingMarketError extends Error {
|
|
1188
|
+
constructor(params: {
|
|
1189
|
+
readonly marketId: MarketId;
|
|
1190
|
+
});
|
|
1108
1191
|
}
|
|
1109
|
-
/** Thrown when
|
|
1110
|
-
export declare class
|
|
1192
|
+
/** Thrown when parked assets would mint no Morpho Blue supply shares. */
|
|
1193
|
+
export declare class ZeroBlueParkingSharesError extends Error {
|
|
1111
1194
|
constructor(params: {
|
|
1112
|
-
|
|
1113
|
-
|
|
1195
|
+
readonly marketId: MarketId;
|
|
1196
|
+
readonly assets: bigint;
|
|
1114
1197
|
});
|
|
1115
1198
|
}
|
|
1116
|
-
/** Thrown when a Midnight offer
|
|
1117
|
-
export declare class
|
|
1199
|
+
/** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
|
|
1200
|
+
export declare class MidnightTakeableOfferMarketMismatchError extends Error {
|
|
1118
1201
|
constructor(params: {
|
|
1119
|
-
|
|
1120
|
-
|
|
1202
|
+
index: number;
|
|
1203
|
+
expectedMarket: string;
|
|
1204
|
+
actualMarket: string;
|
|
1121
1205
|
});
|
|
1122
1206
|
}
|
|
1123
|
-
/** Thrown when a Midnight offer
|
|
1124
|
-
export declare class
|
|
1207
|
+
/** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
|
|
1208
|
+
export declare class MidnightOfferRatifierMismatchError extends Error {
|
|
1125
1209
|
constructor(params: {
|
|
1210
|
+
index: number;
|
|
1126
1211
|
expectedRatifier: Address;
|
|
1127
1212
|
actualRatifier: Address;
|
|
1128
1213
|
});
|
|
1129
1214
|
}
|
|
1130
|
-
/** Thrown when a Midnight
|
|
1131
|
-
export declare class
|
|
1215
|
+
/** Thrown when a Midnight repost cancels a group it also publishes. */
|
|
1216
|
+
export declare class MidnightReplacementGroupCancelledError extends Error {
|
|
1132
1217
|
constructor(params: {
|
|
1133
|
-
|
|
1134
|
-
actualOffers: number;
|
|
1218
|
+
readonly group: Hex;
|
|
1135
1219
|
});
|
|
1136
1220
|
}
|
|
1137
|
-
/** Thrown when a Midnight offer-root signature carries no encoded payload. */
|
|
1138
|
-
export declare class UnpreparedMidnightOfferRootSignatureError extends Error {
|
|
1139
|
-
constructor();
|
|
1140
|
-
}
|
|
1141
1221
|
/** Thrown when a Midnight redeem flow finds no credit units for the user. */
|
|
1142
1222
|
export declare class NoMidnightCreditToRedeemError extends Error {
|
|
1143
1223
|
constructor(market: string);
|
|
@@ -1209,3 +1289,9 @@ export declare class RefinanceSameMarketError extends Error {
|
|
|
1209
1289
|
export declare class RefinanceTokenMismatchError extends Error {
|
|
1210
1290
|
constructor(sourceMarket: string, targetMarket: string);
|
|
1211
1291
|
}
|
|
1292
|
+
/** Thrown when a maker limit-exit offer can increase or open a position. */
|
|
1293
|
+
export declare class MidnightOfferNotReduceOnlyError extends Error {
|
|
1294
|
+
constructor(params: {
|
|
1295
|
+
readonly index: number;
|
|
1296
|
+
});
|
|
1297
|
+
}
|