@morpho-org/morpho-sdk 5.9.0 → 6.0.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-v5-to-v6.md +404 -0
- package/README.md +127 -69
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +62 -61
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +86 -0
- package/lib/cjs/actions/blue/common.js +205 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -112
- package/lib/cjs/actions/blue/refinance.js +97 -199
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- package/lib/cjs/actions/bundles/common.d.ts +200 -0
- package/lib/cjs/actions/bundles/common.js +469 -0
- package/lib/cjs/actions/bundles/index.d.ts +3 -0
- package/lib/cjs/actions/bundles/index.js +23 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
- package/lib/cjs/actions/index.d.ts +2 -1
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeLend.js +2 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/index.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +8 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +123 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
- package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/cjs/actions/vaultV1/deposit.js +110 -109
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
- package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/cjs/actions/vaultV1/redeem.js +56 -33
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
- package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/cjs/actions/vaultV2/deposit.js +111 -109
- package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/cjs/actions/vaultV2/redeem.js +56 -34
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
- package/lib/cjs/bundler/actions.d.ts +4 -4
- package/lib/cjs/bundler/actions.js +4 -4
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +806 -374
- package/lib/cjs/entities/blue/blue.js +449 -696
- package/lib/cjs/entities/index.d.ts +2 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +203 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +17 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +5 -1
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +90 -1
- package/lib/cjs/helpers/slippage.js +123 -0
- package/lib/cjs/helpers/validate.d.ts +16 -23
- package/lib/cjs/helpers/validate.js +41 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +3 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +303 -210
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +193 -18
- package/lib/cjs/types/error.js +267 -24
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +62 -61
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +86 -0
- package/lib/esm/actions/blue/common.js +193 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -112
- package/lib/esm/actions/blue/refinance.js +98 -200
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
- package/lib/esm/actions/blue/withdraw.d.ts +68 -79
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- package/lib/esm/actions/bundles/common.d.ts +200 -0
- package/lib/esm/actions/bundles/common.js +457 -0
- package/lib/esm/actions/bundles/index.d.ts +3 -0
- package/lib/esm/actions/bundles/index.js +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
- package/lib/esm/actions/index.d.ts +2 -1
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/takeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
- package/lib/esm/actions/midnight/takeLend.js +2 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/index.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +119 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
- package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/esm/actions/vaultV1/deposit.js +112 -111
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
- package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/esm/actions/vaultV1/redeem.js +56 -33
- package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/esm/actions/vaultV1/withdraw.js +86 -34
- package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/esm/actions/vaultV2/deposit.js +113 -111
- package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/esm/actions/vaultV2/redeem.js +56 -34
- package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/esm/actions/vaultV2/withdraw.js +86 -35
- package/lib/esm/bundler/actions.d.ts +4 -4
- package/lib/esm/bundler/actions.js +4 -4
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +806 -374
- package/lib/esm/entities/blue/blue.js +455 -702
- package/lib/esm/entities/index.d.ts +2 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +199 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +90 -1
- package/lib/esm/helpers/slippage.js +122 -2
- package/lib/esm/helpers/validate.d.ts +16 -23
- package/lib/esm/helpers/validate.js +40 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +3 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +303 -210
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +193 -18
- package/lib/esm/types/error.js +252 -21
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +6 -5
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
package/lib/esm/types/action.js
CHANGED
|
@@ -40,6 +40,25 @@ export function isRequirementSignature(requirement) {
|
|
|
40
40
|
export function isPermitSignature(signature) {
|
|
41
41
|
return (signature.action.type === "permit" || signature.action.type === "permit2");
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
45
|
+
*
|
|
46
|
+
* @param signature - The signed requirement to test.
|
|
47
|
+
* @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import {
|
|
51
|
+
* isPermit2SignatureTransferSignature,
|
|
52
|
+
* type RequirementSignature,
|
|
53
|
+
* } from "@morpho-org/morpho-sdk";
|
|
54
|
+
*
|
|
55
|
+
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
56
|
+
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export function isPermit2SignatureTransferSignature(signature) {
|
|
60
|
+
return signature.action.type === "permit2SignatureTransfer";
|
|
61
|
+
}
|
|
43
62
|
/**
|
|
44
63
|
* Narrows a {@link RequirementSignature} to a signed Morpho authorization.
|
|
45
64
|
*
|
|
@@ -69,10 +88,11 @@ export function isMidnightOfferRootSignature(signature) {
|
|
|
69
88
|
*
|
|
70
89
|
* @param signatures - The signatures passed to `buildTx`.
|
|
71
90
|
* @param accepts - Which signature kinds this operation consumes.
|
|
72
|
-
* @param accepts.permit - Whether
|
|
91
|
+
* @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
|
|
92
|
+
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
73
93
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
74
94
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
75
|
-
* @returns The
|
|
95
|
+
* @returns The accepted signature in each typed slot, when present.
|
|
76
96
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
77
97
|
* @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
|
|
78
98
|
* @example
|
|
@@ -89,22 +109,28 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
89
109
|
if (signatures == null)
|
|
90
110
|
return {};
|
|
91
111
|
const permits = signatures.filter(isPermitSignature);
|
|
112
|
+
const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
|
|
92
113
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
93
114
|
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
94
115
|
if (!accepts.permit && permits.length > 0)
|
|
95
116
|
throw new UnexpectedRequirementSignatureError("permit");
|
|
117
|
+
if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)
|
|
118
|
+
throw new UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
96
119
|
if (!accepts.authorization && authorizations.length > 0)
|
|
97
120
|
throw new UnexpectedRequirementSignatureError("authorization");
|
|
98
121
|
if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
|
|
99
122
|
throw new UnexpectedRequirementSignatureError("midnightOfferRootSignature");
|
|
100
123
|
if (permits.length > 1)
|
|
101
124
|
throw new AmbiguousRequirementSignaturesError("permit", permits.length);
|
|
125
|
+
if (permit2Transfers.length > 1)
|
|
126
|
+
throw new AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
|
|
102
127
|
if (authorizations.length > 1)
|
|
103
128
|
throw new AmbiguousRequirementSignaturesError("authorization", authorizations.length);
|
|
104
129
|
if (midnightOfferRoots.length > 1)
|
|
105
130
|
throw new AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
|
|
106
131
|
return {
|
|
107
132
|
permit: permits[0],
|
|
133
|
+
permit2SignatureTransfer: permit2Transfers[0],
|
|
108
134
|
authorization: authorizations[0],
|
|
109
135
|
midnightOfferRoot: midnightOfferRoots[0],
|
|
110
136
|
};
|
|
@@ -8,14 +8,23 @@ import type { Metadata } from "./index.js";
|
|
|
8
8
|
* resolved options bag, and the four entity-factory methods the SDK exposes.
|
|
9
9
|
*/
|
|
10
10
|
export interface MorphoClientType {
|
|
11
|
+
/** Viem client shared by every entity factory and onchain read. */
|
|
11
12
|
readonly viemClient: Client;
|
|
13
|
+
/** Resolved immutable SDK options shared by every entity. */
|
|
12
14
|
readonly options: {
|
|
15
|
+
/** Whether entity prerequisites may be returned as signable EIP-712 requirements. */
|
|
13
16
|
readonly supportSignature: boolean;
|
|
17
|
+
/** Whether supported entity fetchers may use deployless reads. */
|
|
14
18
|
readonly supportDeployless?: boolean;
|
|
19
|
+
/** Optional analytics metadata appended to built transactions. */
|
|
15
20
|
readonly metadata?: Metadata;
|
|
16
21
|
};
|
|
22
|
+
/** Creates a Vault V1 entity bound to `vault` on `chainId`. */
|
|
17
23
|
vaultV1: (vault: Address, chainId: number) => VaultV1Actions;
|
|
24
|
+
/** Creates a Vault V2 entity bound to `vault` on `chainId`. */
|
|
18
25
|
vaultV2: (vault: Address, chainId: number) => VaultV2Actions;
|
|
26
|
+
/** Creates a Morpho Blue market entity whose high-level writes use BlueBundlesV1. */
|
|
19
27
|
blue: (marketParams: MarketParams, chainId: number) => BlueActions;
|
|
28
|
+
/** Creates a Midnight entity bound to `chainId`. */
|
|
20
29
|
midnight: (chainId: number) => MidnightActions;
|
|
21
30
|
}
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class InputExceedsMaxError extends Error {
|
|
|
68
68
|
export declare class EmptyMarketParamsListError extends Error {
|
|
69
69
|
constructor();
|
|
70
70
|
}
|
|
71
|
-
/** Thrown when an
|
|
71
|
+
/** Thrown when an SDK operation deadline has already passed. */
|
|
72
72
|
export declare class ExpiredDeadlineError extends Error {
|
|
73
73
|
readonly deadline: bigint;
|
|
74
74
|
readonly timestamp: bigint;
|
|
@@ -184,8 +184,8 @@ export declare class VaultIsBlueFeeRecipientError extends Error {
|
|
|
184
184
|
*/
|
|
185
185
|
constructor(vault: Address, blue: Address);
|
|
186
186
|
}
|
|
187
|
-
/** Thrown when a vault-shares requirement cannot be safely encoded as
|
|
188
|
-
export declare class
|
|
187
|
+
/** Thrown when a vault-shares requirement cannot be safely encoded as a bundles permit. */
|
|
188
|
+
export declare class BundlesPermitMismatchError extends Error {
|
|
189
189
|
/**
|
|
190
190
|
* @param params - Permit mismatch values used to explain the rejection.
|
|
191
191
|
* @param params.field - Permit field that does not match the exit.
|
|
@@ -193,16 +193,162 @@ export declare class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
|
193
193
|
* @param params.actual - Value supplied by the signature.
|
|
194
194
|
* @param params.cause - Original parser failure when signature decoding is wrapped.
|
|
195
195
|
*/
|
|
196
|
-
readonly field: "type" | "asset" | "signature";
|
|
196
|
+
readonly field: "type" | "asset" | "owner" | "spender" | "amount" | "nonce" | "deadline" | "signature";
|
|
197
197
|
readonly expected: string;
|
|
198
198
|
readonly actual: string;
|
|
199
199
|
constructor(params: {
|
|
200
|
-
readonly field: "type" | "asset" | "signature";
|
|
200
|
+
readonly field: "type" | "asset" | "owner" | "spender" | "amount" | "nonce" | "deadline" | "signature";
|
|
201
201
|
readonly expected: string;
|
|
202
202
|
readonly actual: string;
|
|
203
203
|
readonly cause?: unknown;
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
+
/**
|
|
207
|
+
* Thrown by the deprecated VaultExitBundlesV1 permit compatibility helper.
|
|
208
|
+
*
|
|
209
|
+
* @deprecated Use {@link BundlesPermitMismatchError} with `getBundlesSharesPermit`.
|
|
210
|
+
*/
|
|
211
|
+
export declare class VaultExitBundlesV1PermitMismatchError extends BundlesPermitMismatchError {
|
|
212
|
+
constructor(params: {
|
|
213
|
+
readonly field: "type" | "asset" | "owner" | "spender" | "amount" | "nonce" | "deadline" | "signature";
|
|
214
|
+
readonly expected: string;
|
|
215
|
+
readonly actual: string;
|
|
216
|
+
readonly cause?: unknown;
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
/** Thrown when a signed requirement cannot be safely encoded for a fixed bundles call. */
|
|
220
|
+
export declare class BundlesRequirementSignatureMismatchError extends Error {
|
|
221
|
+
/** Field whose signed value or encoding is invalid for the fixed bundles call. */
|
|
222
|
+
readonly field: "type" | "authorized" | "isAuthorized" | "nonce" | "deadline" | "signature";
|
|
223
|
+
/** Value required by the fixed bundles call. */
|
|
224
|
+
readonly expected: string;
|
|
225
|
+
/** Value supplied by the signed requirement. */
|
|
226
|
+
readonly actual: string;
|
|
227
|
+
/**
|
|
228
|
+
* @param params - Signature mismatch details.
|
|
229
|
+
* @param params.field - Field rejected by the converter.
|
|
230
|
+
* @param params.expected - Value required by the direct route.
|
|
231
|
+
* @param params.actual - Value supplied by the requirement.
|
|
232
|
+
* @param params.cause - Original signature parser failure, when applicable.
|
|
233
|
+
*/
|
|
234
|
+
constructor(params: {
|
|
235
|
+
field: "type" | "authorized" | "isAuthorized" | "nonce" | "deadline" | "signature";
|
|
236
|
+
expected: string;
|
|
237
|
+
actual: string;
|
|
238
|
+
cause?: unknown;
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
/** @deprecated Use {@link BundlesRequirementSignatureMismatchError}. */
|
|
242
|
+
export { BundlesRequirementSignatureMismatchError as BlueBundlesV1RequirementSignatureMismatchError, };
|
|
243
|
+
/** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
|
|
244
|
+
export declare class MissingPermit2SignatureTransferNonceError extends Error {
|
|
245
|
+
constructor();
|
|
246
|
+
}
|
|
247
|
+
/** @deprecated Use {@link MissingPermit2SignatureTransferNonceError}. */
|
|
248
|
+
export { MissingPermit2SignatureTransferNonceError as MissingPermit2TransferFromNonceError, };
|
|
249
|
+
/** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
|
|
250
|
+
export declare class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
251
|
+
readonly owner: Address;
|
|
252
|
+
readonly nonce: bigint;
|
|
253
|
+
/**
|
|
254
|
+
* @param owner - Permit2 token owner whose nonce is unavailable.
|
|
255
|
+
* @param nonce - Explicit unordered nonce that has already been consumed.
|
|
256
|
+
*/
|
|
257
|
+
constructor(owner: Address, nonce: bigint);
|
|
258
|
+
}
|
|
259
|
+
/** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
|
|
260
|
+
export declare class NoUnusedPermit2NonceError extends Error {
|
|
261
|
+
readonly owner: Address;
|
|
262
|
+
readonly startNonce: bigint;
|
|
263
|
+
/**
|
|
264
|
+
* @param owner - Permit2 token owner scanned for a free nonce.
|
|
265
|
+
* @param startNonce - Lowest nonce that was considered.
|
|
266
|
+
*/
|
|
267
|
+
constructor(owner: Address, startNonce: bigint);
|
|
268
|
+
}
|
|
269
|
+
/** @deprecated Use {@link Permit2SignatureTransferNonceAlreadyUsedError}. */
|
|
270
|
+
export { Permit2SignatureTransferNonceAlreadyUsedError as Permit2TransferFromNonceAlreadyUsedError, };
|
|
271
|
+
/** Thrown when native funding does not exactly match the contract's gross token pull. */
|
|
272
|
+
export declare class NativeFundingAmountMismatchError extends Error {
|
|
273
|
+
readonly nativeAmount: bigint;
|
|
274
|
+
readonly requiredAmount: bigint;
|
|
275
|
+
/**
|
|
276
|
+
* @param nativeAmount - Native value supplied with the transaction.
|
|
277
|
+
* @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
|
|
278
|
+
*/
|
|
279
|
+
constructor(nativeAmount: bigint, requiredAmount: bigint);
|
|
280
|
+
}
|
|
281
|
+
/** Thrown when a positive referral fee has no recipient. */
|
|
282
|
+
export declare class ReferralFeeRecipientMissingError extends Error {
|
|
283
|
+
constructor();
|
|
284
|
+
}
|
|
285
|
+
/** @deprecated Use {@link ReferralFeeRecipientMissingError}. */
|
|
286
|
+
export declare const MissingReferralFeeRecipientError: typeof ReferralFeeRecipientMissingError;
|
|
287
|
+
/** @deprecated Use {@link ReferralFeeRecipientMissingError}. */
|
|
288
|
+
export type MissingReferralFeeRecipientError = ReferralFeeRecipientMissingError;
|
|
289
|
+
/**
|
|
290
|
+
* Thrown when a referral fee percentage is outside the contract's `[0, WAD)` range.
|
|
291
|
+
*
|
|
292
|
+
* Extends {@link InputExceedsMaxError} — and reports the same `field`, `value`, and `max` the
|
|
293
|
+
* generic bound error used to carry for this input — so integrators already pattern-matching
|
|
294
|
+
* `InputExceedsMaxError` keep catching this failure.
|
|
295
|
+
*/
|
|
296
|
+
export declare class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
297
|
+
readonly referralFeePct: bigint;
|
|
298
|
+
/** @param referralFeePct - WAD-scaled referral fee percentage supplied by the caller. */
|
|
299
|
+
constructor(referralFeePct: bigint);
|
|
300
|
+
}
|
|
301
|
+
/** Thrown when a fixed bundles call mixes ERC-20 and native funding. */
|
|
302
|
+
export declare class MixedBundlesFundingError extends Error {
|
|
303
|
+
constructor();
|
|
304
|
+
}
|
|
305
|
+
/** Thrown when a vault migration specifies both assets and shares, or neither. */
|
|
306
|
+
export declare class AmountAndSharesExclusiveError extends Error {
|
|
307
|
+
constructor();
|
|
308
|
+
}
|
|
309
|
+
/** Thrown when a vault migration selects the same source and destination vault. */
|
|
310
|
+
export declare class SameVaultMigrationError extends Error {
|
|
311
|
+
readonly vault: Address;
|
|
312
|
+
constructor(vault: Address);
|
|
313
|
+
}
|
|
314
|
+
/** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
|
|
315
|
+
export declare class ReallocationLoanTokenMismatchError extends Error {
|
|
316
|
+
readonly expected: Address;
|
|
317
|
+
readonly actual: Address;
|
|
318
|
+
/**
|
|
319
|
+
* @param expected - Loan token of the operation's target market.
|
|
320
|
+
* @param actual - Loan token found in the reallocation source market.
|
|
321
|
+
*/
|
|
322
|
+
constructor(expected: Address, actual: Address);
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
|
|
326
|
+
* (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
|
|
327
|
+
* `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
|
|
328
|
+
*/
|
|
329
|
+
export declare class UnsupportedAuthorizationOperatorError extends Error {
|
|
330
|
+
readonly authorized: Address;
|
|
331
|
+
readonly chainId: number;
|
|
332
|
+
/**
|
|
333
|
+
* @param authorized - The operator address rejected as unsupported.
|
|
334
|
+
* @param chainId - Chain whose registry was consulted for the supported operators.
|
|
335
|
+
*/
|
|
336
|
+
constructor(authorized: Address, chainId: number);
|
|
337
|
+
}
|
|
338
|
+
/** Thrown when reallocations are attached to a combined call with no borrow leg. */
|
|
339
|
+
export declare class ReallocationsRequireBorrowError extends Error {
|
|
340
|
+
constructor();
|
|
341
|
+
}
|
|
342
|
+
/** Thrown when repay funding cannot cover the requested assets and referral fee. */
|
|
343
|
+
export declare class MaxRepayAssetsBelowRepayAssetsError extends Error {
|
|
344
|
+
readonly maxRepayAssets: bigint;
|
|
345
|
+
readonly repayAssets: bigint;
|
|
346
|
+
/**
|
|
347
|
+
* @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
|
|
348
|
+
* @param repayAssets - Minimum funding required for the repayment and referral fee.
|
|
349
|
+
*/
|
|
350
|
+
constructor(maxRepayAssets: bigint, repayAssets: bigint);
|
|
351
|
+
}
|
|
206
352
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
207
353
|
export declare const NonPositiveAssetAmountError: typeof NonPositiveInputError;
|
|
208
354
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
@@ -375,7 +521,7 @@ export declare namespace BundlerErrors {
|
|
|
375
521
|
}
|
|
376
522
|
}
|
|
377
523
|
/** Requirement signature kind accepted by action-output transaction builders. */
|
|
378
|
-
export type RequirementSignatureKind = "permit" | "authorization" | "midnightOfferRootSignature";
|
|
524
|
+
export type RequirementSignatureKind = "permit" | "permit2SignatureTransfer" | "authorization" | "midnightOfferRootSignature";
|
|
379
525
|
/**
|
|
380
526
|
* Thrown when `buildTx` receives more than one requirement signature of the same kind.
|
|
381
527
|
*
|
|
@@ -537,11 +683,10 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
537
683
|
constructor(vault: string, marketId: string);
|
|
538
684
|
}
|
|
539
685
|
/**
|
|
540
|
-
* Thrown when a
|
|
541
|
-
*
|
|
686
|
+
* Thrown when a reallocation entry passed to a high-level Blue write is not a valid
|
|
687
|
+
* {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
|
|
688
|
+
* `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
|
|
542
689
|
*
|
|
543
|
-
* @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
|
|
544
|
-
* V2 reallocations.
|
|
545
690
|
* @example
|
|
546
691
|
* ```ts
|
|
547
692
|
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
@@ -1038,10 +1183,6 @@ export declare class ReallocationWithdrawExceedsMarketSupplyError extends Error
|
|
|
1038
1183
|
export declare class VaultAssetMismatchError extends Error {
|
|
1039
1184
|
constructor(sourceAsset: Address, targetAsset: Address);
|
|
1040
1185
|
}
|
|
1041
|
-
/** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
|
|
1042
|
-
export declare class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1043
|
-
constructor(market: string);
|
|
1044
|
-
}
|
|
1045
1186
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
1046
1187
|
export declare class RefinanceSameMarketError extends Error {
|
|
1047
1188
|
constructor(market: string);
|
|
@@ -1050,7 +1191,23 @@ export declare class RefinanceSameMarketError extends Error {
|
|
|
1050
1191
|
export declare class RefinanceTokenMismatchError extends Error {
|
|
1051
1192
|
constructor(sourceMarket: string, targetMarket: string);
|
|
1052
1193
|
}
|
|
1053
|
-
/**
|
|
1194
|
+
/**
|
|
1195
|
+
* Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
|
|
1196
|
+
*
|
|
1197
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1198
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1199
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1200
|
+
*/
|
|
1201
|
+
export declare class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1202
|
+
constructor(market: string);
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
|
|
1206
|
+
*
|
|
1207
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1208
|
+
* partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1209
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1210
|
+
*/
|
|
1054
1211
|
export declare class RefinanceExceedsCollateralError extends Error {
|
|
1055
1212
|
readonly market: string;
|
|
1056
1213
|
readonly requested: bigint;
|
|
@@ -1061,7 +1218,13 @@ export declare class RefinanceExceedsCollateralError extends Error {
|
|
|
1061
1218
|
available: bigint;
|
|
1062
1219
|
});
|
|
1063
1220
|
}
|
|
1064
|
-
/**
|
|
1221
|
+
/**
|
|
1222
|
+
* Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
|
|
1223
|
+
*
|
|
1224
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1225
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1226
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1227
|
+
*/
|
|
1065
1228
|
export declare class RefinanceExceedsBorrowSharesError extends Error {
|
|
1066
1229
|
readonly market: string;
|
|
1067
1230
|
readonly requested: bigint;
|
|
@@ -1072,7 +1235,13 @@ export declare class RefinanceExceedsBorrowSharesError extends Error {
|
|
|
1072
1235
|
available: bigint;
|
|
1073
1236
|
});
|
|
1074
1237
|
}
|
|
1075
|
-
/**
|
|
1238
|
+
/**
|
|
1239
|
+
* Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
|
|
1240
|
+
*
|
|
1241
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1242
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1243
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1244
|
+
*/
|
|
1076
1245
|
export declare class RefinanceExceedsBorrowAssetsError extends Error {
|
|
1077
1246
|
readonly market: string;
|
|
1078
1247
|
readonly requested: bigint;
|
|
@@ -1083,7 +1252,13 @@ export declare class RefinanceExceedsBorrowAssetsError extends Error {
|
|
|
1083
1252
|
available: bigint;
|
|
1084
1253
|
});
|
|
1085
1254
|
}
|
|
1086
|
-
/**
|
|
1255
|
+
/**
|
|
1256
|
+
* Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
|
|
1257
|
+
*
|
|
1258
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1259
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1260
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1261
|
+
*/
|
|
1087
1262
|
export declare class RefinanceSharesMissingBorrowAssetsError extends Error {
|
|
1088
1263
|
constructor(market: string);
|
|
1089
1264
|
}
|