@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
|
@@ -40,8 +40,8 @@ export interface MidnightSupplyCollateralTakeBorrowParams extends MidnightTakeBo
|
|
|
40
40
|
* chainId: 8453,
|
|
41
41
|
* market: marketData.params,
|
|
42
42
|
* collateralAssets: 2_000_000n,
|
|
43
|
-
* loanAssets:
|
|
44
|
-
* maxUnits:
|
|
43
|
+
* loanAssets: 1_000_000n,
|
|
44
|
+
* maxUnits: 1_100_000n,
|
|
45
45
|
* taker: borrower,
|
|
46
46
|
* takeableOffers: quote.data.takeableOffers,
|
|
47
47
|
* deadline: maxUint256,
|
|
@@ -41,8 +41,8 @@ import { PermitKind } from "./types.js";
|
|
|
41
41
|
* chainId: 8453,
|
|
42
42
|
* market: marketData.params,
|
|
43
43
|
* collateralAssets: 2_000_000n,
|
|
44
|
-
* loanAssets:
|
|
45
|
-
* maxUnits:
|
|
44
|
+
* loanAssets: 1_000_000n,
|
|
45
|
+
* maxUnits: 1_100_000n,
|
|
46
46
|
* taker: borrower,
|
|
47
47
|
* takeableOffers: quote.data.takeableOffers,
|
|
48
48
|
* deadline: maxUint256,
|
|
@@ -46,8 +46,8 @@ export interface MidnightTakeBorrowParams {
|
|
|
46
46
|
* const tx = midnightTakeBorrow({
|
|
47
47
|
* chainId: 8453,
|
|
48
48
|
* market: marketData.params,
|
|
49
|
-
* loanAssets:
|
|
50
|
-
* maxUnits:
|
|
49
|
+
* loanAssets: 1_000_000n,
|
|
50
|
+
* maxUnits: 1_100_000n,
|
|
51
51
|
* taker: borrower,
|
|
52
52
|
* takeableOffers: quote.data.takeableOffers,
|
|
53
53
|
* deadline: maxUint256,
|
|
@@ -37,8 +37,8 @@ import { NegativeInputError, NonPositiveInputError, } from "../../types/index.js
|
|
|
37
37
|
* const tx = midnightTakeBorrow({
|
|
38
38
|
* chainId: 8453,
|
|
39
39
|
* market: marketData.params,
|
|
40
|
-
* loanAssets:
|
|
41
|
-
* maxUnits:
|
|
40
|
+
* loanAssets: 1_000_000n,
|
|
41
|
+
* maxUnits: 1_100_000n,
|
|
42
42
|
* taker: borrower,
|
|
43
43
|
* takeableOffers: quote.data.takeableOffers,
|
|
44
44
|
* deadline: maxUint256,
|
|
@@ -46,8 +46,8 @@ export interface MidnightTakeLendParams {
|
|
|
46
46
|
* const tx = midnightTakeLend({
|
|
47
47
|
* chainId: 8453,
|
|
48
48
|
* market: marketData.params,
|
|
49
|
-
* assets:
|
|
50
|
-
* minUnits:
|
|
49
|
+
* assets: 1_000_000n,
|
|
50
|
+
* minUnits: 900_000n,
|
|
51
51
|
* taker: lender,
|
|
52
52
|
* takeableOffers: quote.data.takeableOffers,
|
|
53
53
|
* deadline: maxUint256,
|
|
@@ -38,8 +38,8 @@ import { PermitKind } from "./types.js";
|
|
|
38
38
|
* const tx = midnightTakeLend({
|
|
39
39
|
* chainId: 8453,
|
|
40
40
|
* market: marketData.params,
|
|
41
|
-
* assets:
|
|
42
|
-
* minUnits:
|
|
41
|
+
* assets: 1_000_000n,
|
|
42
|
+
* minUnits: 900_000n,
|
|
43
43
|
* taker: lender,
|
|
44
44
|
* takeableOffers: quote.data.takeableOffers,
|
|
45
45
|
* deadline: maxUint256,
|
|
@@ -10,7 +10,7 @@ export interface GetUnusedPermit2NonceParams {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Finds the lowest unused Permit2 unordered nonce for `owner`, ready to pass as `permit2Nonce` to
|
|
13
|
-
* {@link
|
|
13
|
+
* {@link getBundlesTokenRequirements} or as `nonce` to {@link encodeErc20Permit2SignatureTransfer}.
|
|
14
14
|
*
|
|
15
15
|
* Permit2 SignatureTransfer consumes an unordered 256-bit nonce; a nonce is free when its bit in
|
|
16
16
|
* `nonceBitmap(owner, word)` is unset. This scans consecutive bitmap words starting at `startNonce`
|
|
@@ -9,7 +9,7 @@ import { NoUnusedPermit2NonceError } from "../../../types/index.js";
|
|
|
9
9
|
const MAX_PERMIT2_NONCE_WORD = maxUint256 >> 8n;
|
|
10
10
|
/**
|
|
11
11
|
* Finds the lowest unused Permit2 unordered nonce for `owner`, ready to pass as `permit2Nonce` to
|
|
12
|
-
* {@link
|
|
12
|
+
* {@link getBundlesTokenRequirements} or as `nonce` to {@link encodeErc20Permit2SignatureTransfer}.
|
|
13
13
|
*
|
|
14
14
|
* Permit2 SignatureTransfer consumes an unordered 256-bit nonce; a nonce is free when its bit in
|
|
15
15
|
* `nonceBitmap(owner, word)` is unset. This scans consecutive bitmap words starting at `startNonce`
|
|
@@ -50,7 +50,7 @@ export const encodeBlueSignatureAuthorization = async (viemClient, params) => {
|
|
|
50
50
|
}
|
|
51
51
|
// Reject an invalid or already-expired caller-supplied deadline before signing, so a direct caller
|
|
52
52
|
// is never walked through a wallet EIP-712 prompt for an authorization Morpho would reject with
|
|
53
|
-
// `SIGNATURE_EXPIRED`. Mirrors the sibling `
|
|
53
|
+
// `SIGNATURE_EXPIRED`. Mirrors the sibling `encodeErc20Permit2SignatureTransfer` and the
|
|
54
54
|
// `getBlueAuthorizationRequirement` resolver guards. An omitted deadline defaults to two hours
|
|
55
55
|
// from now and is always valid.
|
|
56
56
|
if (params.deadline != null) {
|
|
@@ -16,7 +16,7 @@ interface EncodeErc20ApprovalParams {
|
|
|
16
16
|
* @param params - Encoding parameters.
|
|
17
17
|
* @param params.token - ERC-20 token address to approve.
|
|
18
18
|
* @param params.spender - Address granted the allowance. Must be GeneralAdapter1, Permit2,
|
|
19
|
-
* Midnight, MidnightBundles, VaultExitBundlesV1, or BlueBundlesV1 for the chain.
|
|
19
|
+
* Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for the chain.
|
|
20
20
|
* @param params.amount - Allowance amount before per-token cap.
|
|
21
21
|
* @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
|
|
22
22
|
* @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
|
|
@@ -12,7 +12,7 @@ import { validateRequirementSpender } from "../../../helpers/validateRequirement
|
|
|
12
12
|
* @param params - Encoding parameters.
|
|
13
13
|
* @param params.token - ERC-20 token address to approve.
|
|
14
14
|
* @param params.spender - Address granted the allowance. Must be GeneralAdapter1, Permit2,
|
|
15
|
-
* Midnight, MidnightBundles, VaultExitBundlesV1, or BlueBundlesV1 for the chain.
|
|
15
|
+
* Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for the chain.
|
|
16
16
|
* @param params.amount - Allowance amount before per-token cap.
|
|
17
17
|
* @param params.chainId - The chain the transaction targets (used to resolve supported spenders and the per-token cap).
|
|
18
18
|
* @returns A deep-frozen `Transaction<ERC20ApprovalAction>` with the capped approval amount.
|
|
@@ -43,6 +43,7 @@ export const encodeErc20Approval = (params) => {
|
|
|
43
43
|
"midnight",
|
|
44
44
|
"midnightBundles",
|
|
45
45
|
"vaultExitBundlesV1",
|
|
46
|
+
"vaultBundlesV1",
|
|
46
47
|
"blueBundlesV1",
|
|
47
48
|
],
|
|
48
49
|
});
|
|
@@ -23,8 +23,8 @@ interface EncodeErc20PermitParams {
|
|
|
23
23
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
24
24
|
* @param params - Permit encoding parameters.
|
|
25
25
|
* @param params.token - ERC-20 token address (must support EIP-2612).
|
|
26
|
-
* @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
|
|
27
|
-
* BlueBundlesV1 for the chain.
|
|
26
|
+
* @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
|
|
27
|
+
* VaultBundlesV1, or BlueBundlesV1 for the chain.
|
|
28
28
|
* @param params.amount - Permit allowance amount.
|
|
29
29
|
* @param params.chainId - Target chain id.
|
|
30
30
|
* @param params.nonce - The user's current EIP-2612 nonce on `token`.
|
|
@@ -34,7 +34,7 @@ interface EncodeErc20PermitParams {
|
|
|
34
34
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
35
35
|
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
36
36
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not GeneralAdapter1,
|
|
37
|
-
* MidnightBundles, or BlueBundlesV1 for `chainId`.
|
|
37
|
+
* MidnightBundles, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
|
|
38
38
|
* @throws {NonPositiveInputError} when an explicit `deadline` is not positive.
|
|
39
39
|
* @throws {InputExceedsMaxError} when an explicit `deadline` exceeds `uint256`.
|
|
40
40
|
* @throws {ExpiredDeadlineError} when an explicit `deadline` is positive but not in the future.
|
|
@@ -16,8 +16,8 @@ import { ChainIdMismatchError, ExpiredDeadlineError, InputExceedsMaxError, NonPo
|
|
|
16
16
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
17
17
|
* @param params - Permit encoding parameters.
|
|
18
18
|
* @param params.token - ERC-20 token address (must support EIP-2612).
|
|
19
|
-
* @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
|
|
20
|
-
* BlueBundlesV1 for the chain.
|
|
19
|
+
* @param params.spender - Permit spender. Must be GeneralAdapter1, MidnightBundles,
|
|
20
|
+
* VaultBundlesV1, or BlueBundlesV1 for the chain.
|
|
21
21
|
* @param params.amount - Permit allowance amount.
|
|
22
22
|
* @param params.chainId - Target chain id.
|
|
23
23
|
* @param params.nonce - The user's current EIP-2612 nonce on `token`.
|
|
@@ -27,7 +27,7 @@ import { ChainIdMismatchError, ExpiredDeadlineError, InputExceedsMaxError, NonPo
|
|
|
27
27
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
28
28
|
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
29
29
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not GeneralAdapter1,
|
|
30
|
-
* MidnightBundles, or BlueBundlesV1 for `chainId`.
|
|
30
|
+
* MidnightBundles, VaultBundlesV1, or BlueBundlesV1 for `chainId`.
|
|
31
31
|
* @throws {NonPositiveInputError} when an explicit `deadline` is not positive.
|
|
32
32
|
* @throws {InputExceedsMaxError} when an explicit `deadline` exceeds `uint256`.
|
|
33
33
|
* @throws {ExpiredDeadlineError} when an explicit `deadline` is positive but not in the future.
|
|
@@ -60,7 +60,12 @@ export const encodeErc20Permit = async (viemClient, params) => {
|
|
|
60
60
|
validateRequirementSpender({
|
|
61
61
|
chainId,
|
|
62
62
|
spender,
|
|
63
|
-
allowed: [
|
|
63
|
+
allowed: [
|
|
64
|
+
"generalAdapter1",
|
|
65
|
+
"midnightBundles",
|
|
66
|
+
"vaultBundlesV1",
|
|
67
|
+
"blueBundlesV1",
|
|
68
|
+
],
|
|
64
69
|
});
|
|
65
70
|
const now = Time.timestamp();
|
|
66
71
|
// Validate an explicit deadline before the token-metadata read: this exported encoder can be
|
|
@@ -91,6 +96,7 @@ export const encodeErc20Permit = async (viemClient, params) => {
|
|
|
91
96
|
spender,
|
|
92
97
|
amount,
|
|
93
98
|
deadline,
|
|
99
|
+
nonce,
|
|
94
100
|
},
|
|
95
101
|
};
|
|
96
102
|
return {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Address } from "@morpho-org/blue-sdk";
|
|
2
|
-
import { type
|
|
3
|
-
/** Parameters for {@link
|
|
4
|
-
export interface
|
|
2
|
+
import { type Permit2SignatureTransferRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
3
|
+
/** Parameters for {@link encodeErc20Permit2SignatureTransfer}. */
|
|
4
|
+
export interface EncodeErc20Permit2SignatureTransferParams {
|
|
5
5
|
/** ERC-20 token pulled through Permit2. */
|
|
6
6
|
readonly token: Address;
|
|
7
|
-
/**
|
|
7
|
+
/** Registered fixed bundles deployment receiving permission to pull the token. */
|
|
8
8
|
readonly spender: Address;
|
|
9
9
|
/** Exact token amount authorized by the one-time transfer. */
|
|
10
10
|
readonly amount: bigint;
|
|
@@ -16,14 +16,14 @@ export interface EncodeErc20Permit2TransferFromParams {
|
|
|
16
16
|
readonly deadline: bigint;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* Builds a Permit2 SignatureTransfer requirement for a direct
|
|
19
|
+
* Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
|
|
20
20
|
*
|
|
21
21
|
* Unlike Permit2 AllowanceTransfer, this signs a one-time `uint256` amount and unordered nonce;
|
|
22
22
|
* it has no managed allowance expiration.
|
|
23
23
|
*
|
|
24
24
|
* @param params - SignatureTransfer parameters.
|
|
25
25
|
* @param params.token - ERC-20 token pulled through Permit2.
|
|
26
|
-
* @param params.spender - Registered BlueBundlesV1 deployment that performs the pull.
|
|
26
|
+
* @param params.spender - Registered BlueBundlesV1 or VaultBundlesV1 deployment that performs the pull.
|
|
27
27
|
* @param params.amount - Exact `uint256` token amount authorized.
|
|
28
28
|
* @param params.chainId - Target chain id.
|
|
29
29
|
* @param params.nonce - Unused Permit2 unordered nonce.
|
|
@@ -35,7 +35,7 @@ export interface EncodeErc20Permit2TransferFromParams {
|
|
|
35
35
|
* @throws {ExpiredDeadlineError} when `deadline` is positive but not in the future.
|
|
36
36
|
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
37
37
|
* @throws {UnknownAddressError} when the chain has no registered canonical Permit2 deployment.
|
|
38
|
-
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not
|
|
38
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed bundles deployment for `chainId`.
|
|
39
39
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet client has no account.
|
|
40
40
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `userAddress`.
|
|
41
41
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet chain differs from `chainId`.
|
|
@@ -43,19 +43,19 @@ export interface EncodeErc20Permit2TransferFromParams {
|
|
|
43
43
|
* @example
|
|
44
44
|
* ```ts
|
|
45
45
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
46
|
-
* import {
|
|
46
|
+
* import { encodeErc20Permit2SignatureTransfer } from "@morpho-org/morpho-sdk";
|
|
47
47
|
* import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
48
48
|
* import { mainnet } from "viem/chains";
|
|
49
49
|
*
|
|
50
|
-
* const requirement =
|
|
50
|
+
* const requirement = encodeErc20Permit2SignatureTransfer({
|
|
51
51
|
* token: addressesRegistry[mainnet.id].usdc,
|
|
52
|
-
* spender: getChainAddress(mainnet.id, "bundles.
|
|
52
|
+
* spender: getChainAddress(mainnet.id, "bundles.vaultBundlesV1"),
|
|
53
53
|
* amount: 1_000_000n,
|
|
54
54
|
* chainId: mainnet.id,
|
|
55
55
|
* nonce: 0n,
|
|
56
56
|
* deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
|
|
57
57
|
* });
|
|
58
|
-
* // requirement satisfies Requirement<
|
|
58
|
+
* // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export declare const
|
|
61
|
+
export declare const encodeErc20Permit2SignatureTransfer: (params: EncodeErc20Permit2SignatureTransferParams) => Requirement<Permit2SignatureTransferRequirementSignature>;
|
|
@@ -6,14 +6,14 @@ import { validateUint256Field } from "../../../helpers/validate.js";
|
|
|
6
6
|
import { validateRequirementSpender } from "../../../helpers/validateRequirementSpender.js";
|
|
7
7
|
import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } from "../../../types/index.js";
|
|
8
8
|
/**
|
|
9
|
-
* Builds a Permit2 SignatureTransfer requirement for a direct
|
|
9
|
+
* Builds a Permit2 SignatureTransfer requirement for a direct fixed-bundles token pull.
|
|
10
10
|
*
|
|
11
11
|
* Unlike Permit2 AllowanceTransfer, this signs a one-time `uint256` amount and unordered nonce;
|
|
12
12
|
* it has no managed allowance expiration.
|
|
13
13
|
*
|
|
14
14
|
* @param params - SignatureTransfer parameters.
|
|
15
15
|
* @param params.token - ERC-20 token pulled through Permit2.
|
|
16
|
-
* @param params.spender - Registered BlueBundlesV1 deployment that performs the pull.
|
|
16
|
+
* @param params.spender - Registered BlueBundlesV1 or VaultBundlesV1 deployment that performs the pull.
|
|
17
17
|
* @param params.amount - Exact `uint256` token amount authorized.
|
|
18
18
|
* @param params.chainId - Target chain id.
|
|
19
19
|
* @param params.nonce - Unused Permit2 unordered nonce.
|
|
@@ -25,7 +25,7 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
|
|
|
25
25
|
* @throws {ExpiredDeadlineError} when `deadline` is positive but not in the future.
|
|
26
26
|
* @throws {UnsupportedChainIdError} when `chainId` is absent from the address registry.
|
|
27
27
|
* @throws {UnknownAddressError} when the chain has no registered canonical Permit2 deployment.
|
|
28
|
-
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not
|
|
28
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed bundles deployment for `chainId`.
|
|
29
29
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet client has no account.
|
|
30
30
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `userAddress`.
|
|
31
31
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet chain differs from `chainId`.
|
|
@@ -33,22 +33,22 @@ import { ExpiredDeadlineError, InputExceedsMaxError, NonPositiveInputError, } fr
|
|
|
33
33
|
* @example
|
|
34
34
|
* ```ts
|
|
35
35
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
36
|
-
* import {
|
|
36
|
+
* import { encodeErc20Permit2SignatureTransfer } from "@morpho-org/morpho-sdk";
|
|
37
37
|
* import { getChainAddress } from "@morpho-org/morpho-ts";
|
|
38
38
|
* import { mainnet } from "viem/chains";
|
|
39
39
|
*
|
|
40
|
-
* const requirement =
|
|
40
|
+
* const requirement = encodeErc20Permit2SignatureTransfer({
|
|
41
41
|
* token: addressesRegistry[mainnet.id].usdc,
|
|
42
|
-
* spender: getChainAddress(mainnet.id, "bundles.
|
|
42
|
+
* spender: getChainAddress(mainnet.id, "bundles.vaultBundlesV1"),
|
|
43
43
|
* amount: 1_000_000n,
|
|
44
44
|
* chainId: mainnet.id,
|
|
45
45
|
* nonce: 0n,
|
|
46
46
|
* deadline: BigInt(Math.floor(Date.now() / 1_000) + 3_600),
|
|
47
47
|
* });
|
|
48
|
-
* // requirement satisfies Requirement<
|
|
48
|
+
* // requirement satisfies Requirement<Permit2SignatureTransferRequirementSignature>
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
export const
|
|
51
|
+
export const encodeErc20Permit2SignatureTransfer = (params) => {
|
|
52
52
|
const { token, spender, amount, chainId, nonce, deadline } = params;
|
|
53
53
|
// Bound every uint256 field before signing: getPermit2TransferFromTypedData silently clamps an
|
|
54
54
|
// oversized allowance to maxUint256, which would desync the signed value from the requirement
|
|
@@ -76,7 +76,7 @@ export const encodeErc20Permit2TransferFrom = (params) => {
|
|
|
76
76
|
validateRequirementSpender({
|
|
77
77
|
chainId,
|
|
78
78
|
spender,
|
|
79
|
-
allowed: ["blueBundlesV1"],
|
|
79
|
+
allowed: ["vaultBundlesV1", "blueBundlesV1"],
|
|
80
80
|
});
|
|
81
81
|
// getPermit2TransferFromTypedData derives its EIP-712 domain's verifyingContract from
|
|
82
82
|
// getChainAddresses(chainId).permit2. A chain that registers BlueBundlesV1 but no canonical Permit2
|
|
@@ -85,8 +85,8 @@ export const encodeErc20Permit2TransferFrom = (params) => {
|
|
|
85
85
|
// this exported encoder is reachable directly, so it must reject the same unsupported chain itself.
|
|
86
86
|
getChainAddress(chainId, "permit2"); // throws UnknownAddressError when Permit2 is unregistered
|
|
87
87
|
const action = {
|
|
88
|
-
type: "
|
|
89
|
-
args: { spender, amount, deadline },
|
|
88
|
+
type: "permit2SignatureTransfer",
|
|
89
|
+
args: { spender, amount, nonce, deadline },
|
|
90
90
|
};
|
|
91
91
|
return {
|
|
92
92
|
action,
|
|
@@ -6,7 +6,7 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
6
6
|
readonly vault: Token;
|
|
7
7
|
/** Vault generation, which selects the standard V1 or two-field V2 domain. */
|
|
8
8
|
readonly version: "vaultV1" | "vaultV2";
|
|
9
|
-
/**
|
|
9
|
+
/** Registered fixed vault bundles spender. */
|
|
10
10
|
readonly spender: Address;
|
|
11
11
|
/** Account that owns the vault shares. */
|
|
12
12
|
readonly owner: Address;
|
|
@@ -27,15 +27,15 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
27
27
|
*
|
|
28
28
|
* @param params.vault - Vault share token, including V1 permit-domain metadata when available.
|
|
29
29
|
* @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
|
|
30
|
-
* @param params.spender - Registered VaultExitBundlesV1 spender.
|
|
30
|
+
* @param params.spender - Registered VaultBundlesV1 or VaultExitBundlesV1 spender.
|
|
31
31
|
* @param params.owner - Account that owns and authorizes spending of the vault shares.
|
|
32
32
|
* @param params.chainId - Chain on which the vault and spender are deployed.
|
|
33
33
|
* @param params.nonce - Current vault permit nonce for the owner.
|
|
34
34
|
* @param params.amount - Vault-share allowance to authorize.
|
|
35
35
|
* @param params.deadline - Shared permit and bundle deadline.
|
|
36
|
-
* @returns A requirement whose `sign()` result can be embedded in
|
|
36
|
+
* @returns A requirement whose `sign()` result can be embedded in fixed vault-bundles calldata.
|
|
37
37
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
38
|
-
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not
|
|
38
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
|
|
39
39
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
|
|
40
40
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
|
|
41
41
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
|
|
@@ -13,15 +13,15 @@ import { validateRequirementSpender } from "../../../helpers/validateRequirement
|
|
|
13
13
|
*
|
|
14
14
|
* @param params.vault - Vault share token, including V1 permit-domain metadata when available.
|
|
15
15
|
* @param params.version - Vault generation selecting the standard V1 or two-field V2 domain.
|
|
16
|
-
* @param params.spender - Registered VaultExitBundlesV1 spender.
|
|
16
|
+
* @param params.spender - Registered VaultBundlesV1 or VaultExitBundlesV1 spender.
|
|
17
17
|
* @param params.owner - Account that owns and authorizes spending of the vault shares.
|
|
18
18
|
* @param params.chainId - Chain on which the vault and spender are deployed.
|
|
19
19
|
* @param params.nonce - Current vault permit nonce for the owner.
|
|
20
20
|
* @param params.amount - Vault-share allowance to authorize.
|
|
21
21
|
* @param params.deadline - Shared permit and bundle deadline.
|
|
22
|
-
* @returns A requirement whose `sign()` result can be embedded in
|
|
22
|
+
* @returns A requirement whose `sign()` result can be embedded in fixed vault-bundles calldata.
|
|
23
23
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
24
|
-
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not
|
|
24
|
+
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
|
|
25
25
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
|
|
26
26
|
* @throws {AddressMismatchError} from `sign()` when the wallet account differs from `owner`.
|
|
27
27
|
* @throws {ChainIdMismatchError} from `sign()` when the wallet targets another chain.
|
|
@@ -76,11 +76,11 @@ export const encodeVaultSharesPermit = (params) => {
|
|
|
76
76
|
extensions: [...inputDomain.extensions],
|
|
77
77
|
}),
|
|
78
78
|
});
|
|
79
|
-
// Bind the permit to the
|
|
79
|
+
// Bind the permit to one of the registered fixed vault bundles deployments.
|
|
80
80
|
validateRequirementSpender({
|
|
81
81
|
chainId,
|
|
82
82
|
spender,
|
|
83
|
-
allowed: ["vaultExitBundlesV1"],
|
|
83
|
+
allowed: ["vaultExitBundlesV1", "vaultBundlesV1"],
|
|
84
84
|
});
|
|
85
85
|
const action = {
|
|
86
86
|
type: "permit",
|
|
@@ -88,6 +88,7 @@ export const encodeVaultSharesPermit = (params) => {
|
|
|
88
88
|
spender,
|
|
89
89
|
amount,
|
|
90
90
|
deadline,
|
|
91
|
+
nonce,
|
|
91
92
|
},
|
|
92
93
|
};
|
|
93
94
|
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";
|
|
@@ -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";
|
|
@@ -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.
|
|
@@ -7,8 +7,8 @@ import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
|
|
|
7
7
|
* allowance.
|
|
8
8
|
*
|
|
9
9
|
* The spender is validated by {@link encodeErc20Approval}. Supported spenders are the chain's
|
|
10
|
-
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, and
|
|
11
|
-
* addresses when configured.
|
|
10
|
+
* GeneralAdapter1, Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, and
|
|
11
|
+
* BlueBundlesV1 addresses when configured.
|
|
12
12
|
*
|
|
13
13
|
* Returns an empty array when the allowance already covers `spendAmount`. When the token is in
|
|
14
14
|
* `APPROVE_ONLY_ONCE_TOKENS` (e.g. USDT) and the existing allowance is non-zero, prepends a
|
|
@@ -22,7 +22,8 @@ import { encodeErc20Approval } from "./encode/encodeErc20Approval.js";
|
|
|
22
22
|
* @param params.args.approvalAmount - The amount to approve (often equal to `spendAmount`, but
|
|
23
23
|
* may be `maxUint256` for reusable Permit2 or saturated-share-repay approvals).
|
|
24
24
|
* @param params.args.spender - Address that will be granted the approval. Must be GeneralAdapter1,
|
|
25
|
-
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, or BlueBundlesV1 for
|
|
25
|
+
* Permit2, Midnight, MidnightBundles, VaultExitBundlesV1, VaultBundlesV1, or BlueBundlesV1 for
|
|
26
|
+
* `chainId`.
|
|
26
27
|
* @param params.allowances - The user's current allowance of `address` for `spender`.
|
|
27
28
|
* @returns Up to two deep-frozen `Transaction<ERC20ApprovalAction>` entries: an optional reset
|
|
28
29
|
* followed by the new approval. Empty when no approval is needed.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isAddressEqual } from "viem";
|
|
2
|
-
import { DepositAmountMismatchError, DepositAssetMismatchError,
|
|
2
|
+
import { DepositAmountMismatchError, DepositAssetMismatchError, isPermit2SignatureTransferSignature, Permit2ExpirationMissingError, UnexpectedRequirementSignatureError, } from "../../types/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Encodes the bundler actions that pull the asset to `recipient`, optionally consuming a
|
|
5
5
|
* pre-signed permit / permit2 requirement first.
|
|
@@ -56,8 +56,8 @@ export const getTokenRequirementActions = ({ asset, amount, recipient, requireme
|
|
|
56
56
|
},
|
|
57
57
|
];
|
|
58
58
|
}
|
|
59
|
-
if (
|
|
60
|
-
throw new UnexpectedRequirementSignatureError("
|
|
59
|
+
if (isPermit2SignatureTransferSignature(requirementSignature)) {
|
|
60
|
+
throw new UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
61
61
|
}
|
|
62
62
|
if (!isAddressEqual(requirementSignature.args.asset, asset)) {
|
|
63
63
|
throw new 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;
|