@morpho-org/morpho-sdk 6.0.0-next.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 +206 -3
- package/README.md +81 -41
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +1 -1
- package/lib/cjs/actions/blue/borrow.js +1 -1
- package/lib/cjs/actions/blue/common.d.ts +6 -19
- package/lib/cjs/actions/blue/common.js +25 -138
- package/lib/cjs/actions/blue/refinance.d.ts +1 -1
- package/lib/cjs/actions/blue/refinance.js +1 -1
- package/lib/cjs/actions/blue/repay.d.ts +3 -3
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/actions/blue/supply.d.ts +3 -3
- package/lib/cjs/actions/blue/supply.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
- package/lib/cjs/actions/blue/withdraw.js +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
- 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 +1 -0
- 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/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +13 -13
- 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 -1
- package/lib/cjs/actions/requirements/encode/index.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
- 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/entities/blue/blue.d.ts +19 -19
- package/lib/cjs/entities/blue/blue.js +3 -1
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +61 -65
- 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/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 +2 -0
- package/lib/cjs/helpers/validate.js +12 -1
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +179 -70
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +62 -14
- package/lib/cjs/types/error.js +88 -22
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +1 -1
- package/lib/esm/actions/blue/borrow.js +1 -1
- package/lib/esm/actions/blue/common.d.ts +6 -19
- package/lib/esm/actions/blue/common.js +27 -140
- package/lib/esm/actions/blue/refinance.d.ts +1 -1
- package/lib/esm/actions/blue/refinance.js +1 -1
- package/lib/esm/actions/blue/repay.d.ts +3 -3
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/esm/actions/blue/supply.d.ts +3 -3
- package/lib/esm/actions/blue/supply.js +1 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateral.js +1 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -1
- package/lib/esm/actions/blue/withdraw.js +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
- 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 +1 -0
- 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/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +11 -11
- 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 -1
- package/lib/esm/actions/requirements/encode/index.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
- 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/entities/blue/blue.d.ts +19 -19
- package/lib/esm/entities/blue/blue.js +4 -2
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +51 -55
- 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/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 +2 -0
- package/lib/esm/helpers/validate.js +11 -1
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +179 -70
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +62 -14
- package/lib/esm/types/error.js +80 -16
- package/package.json +3 -3
|
@@ -16,15 +16,15 @@ const validateRequirementSpender_js_1 = require("../../../helpers/validateRequir
|
|
|
16
16
|
*
|
|
17
17
|
* @param params.vault - Vault share token, including V1 permit-domain metadata when available.
|
|
18
18
|
* @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
|
|
19
|
-
* @param params.spender - Registered VaultExitBundlesV1 spender.
|
|
19
|
+
* @param params.spender - Registered VaultBundlesV1 or VaultExitBundlesV1 spender.
|
|
20
20
|
* @param params.owner - Account that owns and authorizes spending of the vault shares.
|
|
21
21
|
* @param params.chainId - Chain on which the vault and spender are deployed.
|
|
22
22
|
* @param params.nonce - Current vault permit nonce for the owner.
|
|
23
23
|
* @param params.amount - Vault-share allowance to authorize.
|
|
24
24
|
* @param params.deadline - Shared permit and bundle deadline.
|
|
25
|
-
* @returns A requirement whose `sign()` result can be embedded in
|
|
25
|
+
* @returns A requirement whose `sign()` result can be embedded in fixed vault-bundles calldata.
|
|
26
26
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
27
|
-
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not
|
|
27
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
|
|
28
28
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
|
|
29
29
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
|
|
30
30
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
|
|
@@ -79,11 +79,11 @@ const encodeVaultSharesPermit = (params) => {
|
|
|
79
79
|
extensions: [...inputDomain.extensions],
|
|
80
80
|
}),
|
|
81
81
|
});
|
|
82
|
-
// Bind the permit to the
|
|
82
|
+
// Bind the permit to one of the registered fixed vault bundles deployments.
|
|
83
83
|
(0, validateRequirementSpender_js_1.validateRequirementSpender)({
|
|
84
84
|
chainId,
|
|
85
85
|
spender,
|
|
86
|
-
allowed: ["vaultExitBundlesV1"],
|
|
86
|
+
allowed: ["vaultExitBundlesV1", "vaultBundlesV1"],
|
|
87
87
|
});
|
|
88
88
|
const action = {
|
|
89
89
|
type: "permit",
|
|
@@ -91,6 +91,7 @@ const encodeVaultSharesPermit = (params) => {
|
|
|
91
91
|
spender,
|
|
92
92
|
amount,
|
|
93
93
|
deadline,
|
|
94
|
+
nonce,
|
|
94
95
|
},
|
|
95
96
|
};
|
|
96
97
|
return {
|
|
@@ -2,5 +2,5 @@ export * from "./encodeBlueSignatureAuthorization.js";
|
|
|
2
2
|
export * from "./encodeErc20Approval.js";
|
|
3
3
|
export * from "./encodeErc20Permit.js";
|
|
4
4
|
export * from "./encodeErc20Permit2Approve.js";
|
|
5
|
-
export * from "./
|
|
5
|
+
export * from "./encodeErc20Permit2SignatureTransfer.js";
|
|
6
6
|
export * from "./encodeVaultSharesPermit.js";
|
|
@@ -18,5 +18,5 @@ __exportStar(require("./encodeBlueSignatureAuthorization.js"), exports);
|
|
|
18
18
|
__exportStar(require("./encodeErc20Approval.js"), exports);
|
|
19
19
|
__exportStar(require("./encodeErc20Permit.js"), exports);
|
|
20
20
|
__exportStar(require("./encodeErc20Permit2Approve.js"), exports);
|
|
21
|
-
__exportStar(require("./
|
|
21
|
+
__exportStar(require("./encodeErc20Permit2SignatureTransfer.js"), exports);
|
|
22
22
|
__exportStar(require("./encodeVaultSharesPermit.js"), exports);
|
|
@@ -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, VaultExitBundlesV1, and
|
|
9
|
-
* addresses when configured.
|
|
8
|
+
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and
|
|
9
|
+
* BlueBundlesV1 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
|
|
@@ -20,7 +20,8 @@ import { type ERC20ApprovalAction, type Transaction } from "../../types/index.js
|
|
|
20
20
|
* @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
|
|
21
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, VaultExitBundlesV1, or BlueBundlesV1 for
|
|
23
|
+
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
|
|
24
|
+
* `chainId`.
|
|
24
25
|
* @param params.allowances - The user's current allowance of `address` for `spender`.
|
|
25
26
|
* @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
|
|
26
27
|
* followed by the new approval. Empty when no approval is needed.
|
|
@@ -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, VaultExitBundlesV1, and
|
|
14
|
-
* addresses when configured.
|
|
13
|
+
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and
|
|
14
|
+
* BlueBundlesV1 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
|
|
@@ -25,7 +25,8 @@ const encodeErc20Approval_js_1 = require("./encode/encodeErc20Approval.js");
|
|
|
25
25
|
* @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
|
|
26
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, VaultExitBundlesV1, or BlueBundlesV1 for
|
|
28
|
+
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
|
|
29
|
+
* `chainId`.
|
|
29
30
|
* @param params.allowances - The user's current allowance of `address` for `spender`.
|
|
30
31
|
* @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
|
|
31
32
|
* followed by the new approval. Empty when no approval is needed.
|
|
@@ -59,8 +59,8 @@ const getTokenRequirementActions = ({ asset, amount, recipient, requirementSigna
|
|
|
59
59
|
},
|
|
60
60
|
];
|
|
61
61
|
}
|
|
62
|
-
if ((0, index_js_1.
|
|
63
|
-
throw new index_js_1.UnexpectedRequirementSignatureError("
|
|
62
|
+
if ((0, index_js_1.isPermit2SignatureTransferSignature)(requirementSignature)) {
|
|
63
|
+
throw new index_js_1.UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
64
64
|
}
|
|
65
65
|
if (!(0, viem_1.isAddressEqual)(requirementSignature.args.asset, asset)) {
|
|
66
66
|
throw new index_js_1.DepositAssetMismatchError(asset, requirementSignature.args.asset);
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Address } from "viem";
|
|
2
2
|
import { type PermitRequirementSignature } from "../../types/index.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/** ECDSA signature `s`, or zero for the empty-permit sentinel. */
|
|
16
|
-
readonly s: Hex;
|
|
17
|
-
}
|
|
18
|
-
/** Parameters for {@link getVaultExitBundlesV1PermitStruct}. */
|
|
3
|
+
import { type BundleSharesPermit } from "../bundles/common.js";
|
|
4
|
+
/**
|
|
5
|
+
* Compatibility alias for the canonical {@link BundleSharesPermit} tuple consumed by VaultExitBundlesV1.
|
|
6
|
+
*
|
|
7
|
+
* @deprecated Use {@link BundleSharesPermit}.
|
|
8
|
+
*/
|
|
9
|
+
export type VaultExitBundlesV1PermitStruct = BundleSharesPermit;
|
|
10
|
+
/**
|
|
11
|
+
* Parameters for {@link getVaultExitBundlesV1PermitStruct}.
|
|
12
|
+
*
|
|
13
|
+
* @deprecated Use the parameters of `getBundlesSharesPermit`.
|
|
14
|
+
*/
|
|
19
15
|
export interface GetVaultExitBundlesV1PermitStructParams {
|
|
20
16
|
/** Vault share token authorized by the permit. */
|
|
21
17
|
readonly vault: Address;
|
|
@@ -25,28 +21,24 @@ export interface GetVaultExitBundlesV1PermitStructParams {
|
|
|
25
21
|
readonly requirementSignature?: PermitRequirementSignature;
|
|
26
22
|
}
|
|
27
23
|
/**
|
|
28
|
-
*
|
|
29
|
-
* requirement signature.
|
|
30
|
-
*
|
|
31
|
-
* Without a signature, returns the contract's empty-permit sentinel. With a signature, validates
|
|
32
|
-
* the ERC-2612 kind and vault asset before splitting the serialized signature.
|
|
33
|
-
* Owner, spender, deadline, nonce, and cryptographic validity are verified onchain by the vault.
|
|
24
|
+
* Compatibility wrapper for the former VaultExitBundlesV1-specific permit reshaper.
|
|
34
25
|
*
|
|
35
26
|
* @param params.vault - Vault share token authorized by the permit.
|
|
36
27
|
* @param params.deadline - Bundle deadline used by the empty-permit sentinel.
|
|
37
|
-
* @param params.requirementSignature - Optional signed
|
|
38
|
-
* @returns The
|
|
39
|
-
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement
|
|
28
|
+
* @param params.requirementSignature - Optional signed ERC-2612 vault-share requirement.
|
|
29
|
+
* @returns The shared bundles share-permit tuple.
|
|
30
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement is incompatible.
|
|
31
|
+
* @deprecated Use `getBundlesSharesPermit`; this wrapper preserves the legacy error identity.
|
|
40
32
|
* @example
|
|
41
33
|
* ```ts
|
|
42
34
|
* import { getVaultExitBundlesV1PermitStruct } from "@morpho-org/morpho-sdk";
|
|
35
|
+
* import { zeroAddress } from "viem";
|
|
43
36
|
*
|
|
44
37
|
* const permit = getVaultExitBundlesV1PermitStruct({
|
|
45
|
-
* vault,
|
|
46
|
-
* deadline,
|
|
47
|
-
* requirementSignature,
|
|
38
|
+
* vault: zeroAddress,
|
|
39
|
+
* deadline: 1_900_000_000n,
|
|
48
40
|
* });
|
|
49
|
-
* // permit
|
|
41
|
+
* // permit.value === 0n
|
|
50
42
|
* ```
|
|
51
43
|
*/
|
|
52
44
|
export declare const getVaultExitBundlesV1PermitStruct: (params: GetVaultExitBundlesV1PermitStructParams) => VaultExitBundlesV1PermitStruct;
|
|
@@ -1,91 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getVaultExitBundlesV1PermitStruct = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
4
|
const index_js_1 = require("../../types/index.js");
|
|
5
|
+
const common_js_1 = require("../bundles/common.js");
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
8
|
-
* requirement signature.
|
|
9
|
-
*
|
|
10
|
-
* Without a signature, returns the contract's empty-permit sentinel. With a signature, validates
|
|
11
|
-
* the ERC-2612 kind and vault asset before splitting the serialized signature.
|
|
12
|
-
* Owner, spender, deadline, nonce, and cryptographic validity are verified onchain by the vault.
|
|
7
|
+
* Compatibility wrapper for the former VaultExitBundlesV1-specific permit reshaper.
|
|
13
8
|
*
|
|
14
9
|
* @param params.vault - Vault share token authorized by the permit.
|
|
15
10
|
* @param params.deadline - Bundle deadline used by the empty-permit sentinel.
|
|
16
|
-
* @param params.requirementSignature - Optional signed
|
|
17
|
-
* @returns The
|
|
18
|
-
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement
|
|
11
|
+
* @param params.requirementSignature - Optional signed ERC-2612 vault-share requirement.
|
|
12
|
+
* @returns The shared bundles share-permit tuple.
|
|
13
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement is incompatible.
|
|
14
|
+
* @deprecated Use `getBundlesSharesPermit`; this wrapper preserves the legacy error identity.
|
|
19
15
|
* @example
|
|
20
16
|
* ```ts
|
|
21
17
|
* import { getVaultExitBundlesV1PermitStruct } from "@morpho-org/morpho-sdk";
|
|
18
|
+
* import { zeroAddress } from "viem";
|
|
22
19
|
*
|
|
23
20
|
* const permit = getVaultExitBundlesV1PermitStruct({
|
|
24
|
-
* vault,
|
|
25
|
-
* deadline,
|
|
26
|
-
* requirementSignature,
|
|
21
|
+
* vault: zeroAddress,
|
|
22
|
+
* deadline: 1_900_000_000n,
|
|
27
23
|
* });
|
|
28
|
-
* // permit
|
|
24
|
+
* // permit.value === 0n
|
|
29
25
|
* ```
|
|
30
26
|
*/
|
|
31
27
|
const getVaultExitBundlesV1PermitStruct = (params) => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return {
|
|
35
|
-
value: 0n,
|
|
36
|
-
nonce: 0n,
|
|
37
|
-
deadline: params.deadline,
|
|
38
|
-
v: 0,
|
|
39
|
-
r: viem_1.zeroHash,
|
|
40
|
-
s: viem_1.zeroHash,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
if (requirementSignature.action.type !== "permit") {
|
|
44
|
-
throw new index_js_1.VaultExitBundlesV1PermitMismatchError({
|
|
45
|
-
field: "type",
|
|
46
|
-
expected: "permit",
|
|
47
|
-
actual: requirementSignature.action.type,
|
|
48
|
-
});
|
|
28
|
+
try {
|
|
29
|
+
return (0, common_js_1.getBundlesSharesPermit)(params);
|
|
49
30
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
field: "asset",
|
|
53
|
-
expected: params.vault,
|
|
54
|
-
actual: requirementSignature.args.asset,
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
const signature = (() => {
|
|
58
|
-
try {
|
|
59
|
-
const serializedSignature = requirementSignature.args.signature;
|
|
60
|
-
return (0, viem_1.size)(serializedSignature) === 64
|
|
61
|
-
? (0, viem_1.compactSignatureToSignature)((0, viem_1.parseCompactSignature)(serializedSignature))
|
|
62
|
-
: (0, viem_1.parseSignature)(serializedSignature);
|
|
63
|
-
}
|
|
64
|
-
catch (cause) {
|
|
31
|
+
catch (cause) {
|
|
32
|
+
if (cause instanceof index_js_1.BundlesPermitMismatchError) {
|
|
65
33
|
throw new index_js_1.VaultExitBundlesV1PermitMismatchError({
|
|
66
|
-
field:
|
|
67
|
-
expected:
|
|
68
|
-
actual:
|
|
34
|
+
field: cause.field,
|
|
35
|
+
expected: cause.expected,
|
|
36
|
+
actual: cause.actual,
|
|
69
37
|
cause,
|
|
70
38
|
});
|
|
71
39
|
}
|
|
72
|
-
|
|
73
|
-
const { r, s, v, yParity } = signature;
|
|
74
|
-
const normalizedV = v ?? (yParity == null ? undefined : BigInt(yParity + 27));
|
|
75
|
-
if (normalizedV == null) {
|
|
76
|
-
throw new index_js_1.VaultExitBundlesV1PermitMismatchError({
|
|
77
|
-
field: "signature",
|
|
78
|
-
expected: "a signature containing v or yParity",
|
|
79
|
-
actual: requirementSignature.args.signature,
|
|
80
|
-
});
|
|
40
|
+
throw cause;
|
|
81
41
|
}
|
|
82
|
-
return {
|
|
83
|
-
value: requirementSignature.args.amount,
|
|
84
|
-
nonce: requirementSignature.args.nonce,
|
|
85
|
-
deadline: requirementSignature.args.deadline,
|
|
86
|
-
v: Number(normalizedV),
|
|
87
|
-
r,
|
|
88
|
-
s,
|
|
89
|
-
};
|
|
90
42
|
};
|
|
91
43
|
exports.getVaultExitBundlesV1PermitStruct = getVaultExitBundlesV1PermitStruct;
|
|
@@ -1,71 +1,87 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type
|
|
2
|
+
import { type BundlesFundingArgs, type BundlesTokenRequirementSignature, type Metadata, type Transaction, type VaultV1DepositAction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link vaultV1Deposit}. */
|
|
4
4
|
export interface VaultV1DepositParams {
|
|
5
|
-
vault: {
|
|
6
|
-
chainId: number;
|
|
7
|
-
address: Address;
|
|
8
|
-
asset: Address;
|
|
5
|
+
readonly vault: {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly address: Address;
|
|
8
|
+
readonly asset: Address;
|
|
9
9
|
};
|
|
10
|
-
args:
|
|
11
|
-
maxSharePrice: bigint;
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
readonly args: BundlesFundingArgs & {
|
|
11
|
+
readonly maxSharePrice: bigint;
|
|
12
|
+
readonly userAddress: Address;
|
|
13
|
+
readonly recipient?: never;
|
|
14
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
15
|
+
readonly referralFeePct?: bigint;
|
|
16
|
+
readonly referralFeeRecipient?: Address;
|
|
17
|
+
readonly deadline: bigint;
|
|
14
18
|
};
|
|
15
|
-
metadata?: Metadata;
|
|
19
|
+
readonly metadata?: Metadata;
|
|
16
20
|
}
|
|
17
21
|
/**
|
|
18
|
-
*
|
|
22
|
+
* Encodes a Vault V1 deposit through the registered VaultBundlesV1 contract.
|
|
19
23
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* the
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* asset
|
|
27
|
-
*
|
|
28
|
-
* @param params.
|
|
29
|
-
* @param params.
|
|
30
|
-
* @param params.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @param params.args.
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @param params.metadata -
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @throws {
|
|
44
|
-
*
|
|
45
|
-
* @throws {
|
|
46
|
-
*
|
|
47
|
-
* @throws {NativeAmountOnNonWNativeVaultError} when
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* @throws {
|
|
55
|
-
*
|
|
24
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
25
|
+
* @param params.vault.address - Vault V1 contract receiving the net deposit.
|
|
26
|
+
* @param params.vault.asset - Underlying ERC-20 asset; must be the chain's wNative for native funding.
|
|
27
|
+
* @param params.args.amount - Positive gross ERC-20 amount in asset base units, exclusive with `nativeAmount`.
|
|
28
|
+
* @param params.args.nativeAmount - Positive gross native amount in wei, exclusive with `amount` and
|
|
29
|
+
* `requirementSignature`; sent as `tx.value` and wrapped by VaultBundlesV1.
|
|
30
|
+
* @param params.args.maxSharePrice - Positive maximum asset base units per share base unit, scaled
|
|
31
|
+
* by RAY (1e27). Compute it for the net deposit after referral fees to bound slippage.
|
|
32
|
+
* @param params.args.userAddress - Permit owner and transaction sender; VaultBundlesV1 mints shares to this account.
|
|
33
|
+
* @param params.args.recipient - Unsupported; shares are always minted to the transaction sender.
|
|
34
|
+
* @param params.args.requirementSignature - Optional ERC-2612 or Permit2 SignatureTransfer signature
|
|
35
|
+
* for the gross amount, vault asset, `userAddress`, and VaultBundlesV1 spender.
|
|
36
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
37
|
+
* The fee is rounded down and deducted from gross assets before depositing.
|
|
38
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
39
|
+
* when `referralFeePct > 0n`.
|
|
40
|
+
* @param params.args.deadline - Positive uint256 Unix timestamp in seconds after which execution
|
|
41
|
+
* reverts. The caller must supply it; the builder chooses no default.
|
|
42
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
43
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
44
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
45
|
+
* @returns A deep-frozen `Transaction<VaultV1DepositAction>` targeting VaultBundlesV1, with
|
|
46
|
+
* `to`, `value`, `data`, and gross/fee/net deposit action metadata.
|
|
47
|
+
* @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
|
|
48
|
+
* @throws {NegativeInputError} when the selected funding amount or `referralFeePct` is negative.
|
|
49
|
+
* @throws {NonPositiveInputError} when funding, `maxSharePrice`, or `deadline` is not positive.
|
|
50
|
+
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
51
|
+
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
|
|
52
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD; it extends
|
|
53
|
+
* {@link InputExceedsMaxError}, so either class catches it.
|
|
54
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
55
|
+
* @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit or a
|
|
56
|
+
* Permit2 AllowanceTransfer signature is supplied.
|
|
57
|
+
* @throws {InputExceedsMaxError} when funding, `maxSharePrice`, or `deadline` exceeds uint256.
|
|
58
|
+
* @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
|
|
59
|
+
* @throws {DepositAssetMismatchError} when the signed asset differs from the vault asset.
|
|
60
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from the gross funding amount.
|
|
61
|
+
* @throws {DepositSpenderMismatchError} when the signed spender is not VaultBundlesV1.
|
|
62
|
+
* @throws {BundlesRequirementSignatureMismatchError} when the signature deadline, nonce, or encoding is invalid.
|
|
63
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
64
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
56
65
|
* @example
|
|
57
66
|
* ```ts
|
|
67
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
58
68
|
* import { vaultV1Deposit } from "@morpho-org/morpho-sdk";
|
|
69
|
+
* import type { Address } from "viem";
|
|
70
|
+
* import { mainnet } from "viem/chains";
|
|
59
71
|
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* }
|
|
68
|
-
*
|
|
72
|
+
* export function buildSteakUsdcDeposit(
|
|
73
|
+
* userAddress: Address,
|
|
74
|
+
* maxSharePrice: bigint,
|
|
75
|
+
* deadline: bigint,
|
|
76
|
+
* ) {
|
|
77
|
+
* const vault = vaults[mainnet.id].steakUsdc;
|
|
78
|
+
* const tx = vaultV1Deposit({
|
|
79
|
+
* vault: { chainId: mainnet.id, address: vault.address, asset: vault.asset },
|
|
80
|
+
* args: { amount: 1_000_000n, maxSharePrice, userAddress, deadline },
|
|
81
|
+
* });
|
|
82
|
+
* // tx satisfies Readonly<Transaction<VaultV1DepositAction>>
|
|
83
|
+
* return tx;
|
|
84
|
+
* }
|
|
69
85
|
* ```
|
|
70
86
|
*/
|
|
71
|
-
export declare const vaultV1Deposit: (
|
|
87
|
+
export declare const vaultV1Deposit: (params: VaultV1DepositParams) => Readonly<Transaction<VaultV1DepositAction>>;
|