@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.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-v5-to-v6.md +201 -0
- package/README.md +58 -40
- 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 +99 -0
- package/lib/cjs/actions/blue/common.js +318 -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/index.d.ts +1 -1
- 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/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +207 -0
- 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 +2 -0
- package/lib/cjs/actions/requirements/blue/index.js +2 -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 +7 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +123 -0
- 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 +5 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- 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 +447 -696
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/validate.d.ts +14 -23
- package/lib/cjs/helpers/validate.js +30 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -0
- package/lib/cjs/types/action.d.ts +146 -162
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +141 -14
- package/lib/cjs/types/error.js +198 -21
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- 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 +99 -0
- package/lib/esm/actions/blue/common.js +306 -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/index.d.ts +1 -1
- 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/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +203 -0
- 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 +2 -0
- package/lib/esm/actions/requirements/blue/index.js +2 -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 +8 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +119 -0
- 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 +5 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- 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 +453 -702
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/validate.d.ts +14 -23
- package/lib/esm/helpers/validate.js +30 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -0
- package/lib/esm/types/action.d.ts +146 -162
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +141 -14
- package/lib/esm/types/error.js +184 -17
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +4 -3
- 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
|
@@ -5,8 +5,8 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
|
|
|
5
5
|
* allowance.
|
|
6
6
|
*
|
|
7
7
|
* The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
|
|
8
|
-
* GeneralAdapter1, Permit2, Midnight, MidnightBundles,
|
|
9
|
-
* configured.
|
|
8
|
+
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, and BlueBundlesV1
|
|
9
|
+
* addresses when configured.
|
|
10
10
|
*
|
|
11
11
|
* Returns an empty array when the allowance already covers `spendAmount`. When the token is in
|
|
12
12
|
* `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
|
|
@@ -18,13 +18,14 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
|
|
|
18
18
|
* and token approval caps.
|
|
19
19
|
* @param params.args.spendAmount - The amount the bundle will actually pull.
|
|
20
20
|
* @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
|
|
21
|
-
* may be `
|
|
21
|
+
* may be `maxUint256` for reusable Permit2 or saturated-share-repay approvals).
|
|
22
22
|
* @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
|
|
23
|
-
* Permit2, Midnight, MidnightBundles, or
|
|
23
|
+
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, or BlueBundlesV1 for `chainId`.
|
|
24
24
|
* @param params.allowances - The user's current allowance of `address` for `spender`.
|
|
25
25
|
* @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
|
|
26
26
|
* followed by the new approval. Empty when no approval is needed.
|
|
27
27
|
* @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount < spendAmount`.
|
|
28
|
+
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
28
29
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a supported SDK spender for `chainId`.
|
|
29
30
|
* @example
|
|
30
31
|
* ```ts
|
|
@@ -10,8 +10,8 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
|
|
|
10
10
|
* allowance.
|
|
11
11
|
*
|
|
12
12
|
* The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
|
|
13
|
-
* GeneralAdapter1, Permit2, Midnight, MidnightBundles,
|
|
14
|
-
* configured.
|
|
13
|
+
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, and BlueBundlesV1
|
|
14
|
+
* addresses when configured.
|
|
15
15
|
*
|
|
16
16
|
* Returns an empty array when the allowance already covers `spendAmount`. When the token is in
|
|
17
17
|
* `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
|
|
@@ -23,13 +23,14 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
|
|
|
23
23
|
* and token approval caps.
|
|
24
24
|
* @param params.args.spendAmount - The amount the bundle will actually pull.
|
|
25
25
|
* @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
|
|
26
|
-
* may be `
|
|
26
|
+
* may be `maxUint256` for reusable Permit2 or saturated-share-repay approvals).
|
|
27
27
|
* @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
|
|
28
|
-
* Permit2, Midnight, MidnightBundles, or
|
|
28
|
+
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, or BlueBundlesV1 for `chainId`.
|
|
29
29
|
* @param params.allowances - The user's current allowance of `address` for `spender`.
|
|
30
30
|
* @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
|
|
31
31
|
* followed by the new approval. Empty when no approval is needed.
|
|
32
32
|
* @throws {ApprovalAmountLessThanSpendAmountError} when `approvalAmount < spendAmount`.
|
|
33
|
+
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
33
34
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a supported SDK spender for `chainId`.
|
|
34
35
|
* @example
|
|
35
36
|
* ```ts
|
|
@@ -25,6 +25,7 @@ interface GetTokenRequirementActionsParams {
|
|
|
25
25
|
* @returns Bundler `Action`s needed to pull the token.
|
|
26
26
|
* @throws {DepositAssetMismatchError} when the signed asset differs from `asset`.
|
|
27
27
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
|
|
28
|
+
* @throws {UnexpectedRequirementSignatureError} when passed a BlueBundlesV1-only SignatureTransfer result.
|
|
28
29
|
* @throws {Permit2ExpirationMissingError} when `action.type === "permit2"` but `args.expiration` is missing.
|
|
29
30
|
* @example
|
|
30
31
|
* ```ts
|
|
@@ -21,6 +21,7 @@ const index_js_1 = require("../../types/index.js");
|
|
|
21
21
|
* @returns Bundler `Action`s needed to pull the token.
|
|
22
22
|
* @throws {DepositAssetMismatchError} when the signed asset differs from `asset`.
|
|
23
23
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `amount`.
|
|
24
|
+
* @throws {UnexpectedRequirementSignatureError} when passed a BlueBundlesV1-only SignatureTransfer result.
|
|
24
25
|
* @throws {Permit2ExpirationMissingError} when `action.type === "permit2"` but `args.expiration` is missing.
|
|
25
26
|
* @example
|
|
26
27
|
* ```ts
|
|
@@ -58,6 +59,9 @@ const getTokenRequirementActions = ({ asset, amount, recipient, requirementSigna
|
|
|
58
59
|
},
|
|
59
60
|
];
|
|
60
61
|
}
|
|
62
|
+
if ((0, index_js_1.isPermit2TransferFromSignature)(requirementSignature)) {
|
|
63
|
+
throw new index_js_1.UnexpectedRequirementSignatureError("permit2TransferFrom");
|
|
64
|
+
}
|
|
61
65
|
if (!(0, viem_1.isAddressEqual)(requirementSignature.args.asset, asset)) {
|
|
62
66
|
throw new index_js_1.DepositAssetMismatchError(asset, requirementSignature.args.asset);
|
|
63
67
|
}
|
|
@@ -655,8 +655,8 @@ export declare namespace BundlerAction {
|
|
|
655
655
|
/**
|
|
656
656
|
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
657
657
|
*
|
|
658
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
659
|
-
*
|
|
658
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
659
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
660
660
|
*
|
|
661
661
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
662
662
|
* @param vault - Vault whose liquidity is reallocated.
|
|
@@ -720,8 +720,8 @@ export declare namespace BundlerAction {
|
|
|
720
720
|
/**
|
|
721
721
|
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
722
722
|
*
|
|
723
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
724
|
-
*
|
|
723
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
724
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
725
725
|
*
|
|
726
726
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
727
727
|
* @param vault - Vault whose idle liquidity is allocated.
|
|
@@ -1128,8 +1128,8 @@ var BundlerAction;
|
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
1130
1130
|
*
|
|
1131
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
1132
|
-
*
|
|
1131
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
1132
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
1133
1133
|
*
|
|
1134
1134
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1135
1135
|
* @param vault - Vault whose liquidity is reallocated.
|
|
@@ -1239,8 +1239,8 @@ var BundlerAction;
|
|
|
1239
1239
|
/**
|
|
1240
1240
|
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
1241
1241
|
*
|
|
1242
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
1243
|
-
*
|
|
1242
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
1243
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
1244
1244
|
*
|
|
1245
1245
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1246
1246
|
* @param vault - Vault whose idle liquidity is allocated.
|
|
@@ -12,7 +12,8 @@ import { type Metadata, type MorphoClientType } from "../types/index.js";
|
|
|
12
12
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
13
13
|
* `morpho` namespace builds.
|
|
14
14
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
15
|
-
*
|
|
15
|
+
* ERC-2612, Permit2 AllowanceTransfer or SignatureTransfer, and Morpho authorization.
|
|
16
|
+
* Defaults to `false` (standalone approvals and authorization calls only).
|
|
16
17
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
17
18
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
18
19
|
* `client.morpho`.
|
|
@@ -55,7 +55,8 @@ function createMorphoNamespace(viemClient, options) {
|
|
|
55
55
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
56
56
|
* `morpho` namespace builds.
|
|
57
57
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
58
|
-
*
|
|
58
|
+
* ERC-2612, Permit2 AllowanceTransfer or SignatureTransfer, and Morpho authorization.
|
|
59
|
+
* Defaults to `false` (standalone approvals and authorization calls only).
|
|
59
60
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
60
61
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
61
62
|
* `client.morpho`.
|