@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.0-next.2
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 +329 -15
- package/README.md +93 -47
- package/lib/cjs/abis.d.ts +227 -2
- package/lib/cjs/abis.js +156 -3
- 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 +28 -162
- 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 +3 -8
- 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 +230 -0
- package/lib/cjs/actions/bundles/common.js +507 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -2
- package/lib/cjs/actions/requirements/blue/index.js +0 -2
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
- 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 +19 -10
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +43 -31
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +27 -22
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +20 -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/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +8 -2
- package/lib/cjs/blue/entities.js +1 -0
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/blue/fetch.d.ts +3 -1
- package/lib/cjs/blue/fetch.js +1 -0
- package/lib/cjs/entities/blue/blue.d.ts +29 -20
- package/lib/cjs/entities/blue/blue.js +6 -1
- package/lib/cjs/entities/index.d.ts +9 -2
- package/lib/cjs/entities/index.js +16 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/midnight/midnight.js +20 -24
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +76 -75
- package/lib/{esm/actions/requirements/blue → cjs/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/cjs/entities/requirements/index.js +18 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/cjs/entities/vaultV1/vaultV1.js +334 -120
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/cjs/entities/vaultV2/vaultV2.js +448 -93
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -2
- package/lib/cjs/fetch.d.ts +3 -1
- package/lib/cjs/fetch.js +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/cjs/helpers/index.d.ts +4 -1
- package/lib/cjs/helpers/index.js +14 -1
- package/lib/cjs/helpers/metadata.d.ts +3 -5
- package/lib/cjs/helpers/metadata.js +4 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +136 -1
- package/lib/cjs/helpers/slippage.js +188 -0
- package/lib/cjs/helpers/validate.d.ts +67 -8
- package/lib/cjs/helpers/validate.js +94 -9
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +273 -82
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +349 -23
- package/lib/cjs/types/error.js +393 -39
- package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +10 -1
- package/lib/esm/abis.d.ts +227 -2
- package/lib/esm/abis.js +157 -2
- 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 +30 -164
- 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 +5 -10
- 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 +230 -0
- package/lib/esm/actions/bundles/common.js +494 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -2
- package/lib/esm/actions/requirements/blue/index.js +0 -2
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +22 -22
- 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 +19 -10
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +44 -32
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +25 -20
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +21 -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/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +8 -2
- package/lib/esm/blue/entities.js +3 -1
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/blue/fetch.d.ts +3 -1
- package/lib/esm/blue/fetch.js +3 -1
- package/lib/esm/entities/blue/blue.d.ts +29 -20
- package/lib/esm/entities/blue/blue.js +7 -2
- package/lib/esm/entities/index.d.ts +9 -2
- package/lib/esm/entities/index.js +4 -1
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/midnight/midnight.js +20 -24
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +67 -66
- package/lib/{cjs/actions/requirements/blue → esm/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/esm/entities/requirements/index.js +2 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/esm/entities/vaultV1/vaultV1.js +338 -124
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/esm/entities/vaultV2/vaultV2.js +452 -97
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/fetch.d.ts +3 -1
- package/lib/esm/fetch.js +3 -1
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/esm/helpers/index.d.ts +4 -1
- package/lib/esm/helpers/index.js +4 -1
- package/lib/esm/helpers/metadata.d.ts +3 -5
- package/lib/esm/helpers/metadata.js +4 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +136 -1
- package/lib/esm/helpers/slippage.js +186 -2
- package/lib/esm/helpers/validate.d.ts +67 -8
- package/lib/esm/helpers/validate.js +92 -10
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +273 -82
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +349 -23
- package/lib/esm/types/error.js +377 -31
- package/lib/esm/types/sharedLiquidity.d.ts +2 -2
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +3 -1
- package/package.json +7 -7
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import type { InputMarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type { Address, Hex, WalletClient } from "viem";
|
|
2
|
+
import type { Address, Hex, TypedDataDefinition, WalletClient } from "viem";
|
|
3
3
|
import type { Deallocation } from "./deallocation.js";
|
|
4
|
+
/**
|
|
5
|
+
* Serves as the common discriminated action-metadata base shared by both
|
|
6
|
+
* {@link TransactionAction} (actions that carry encoded calldata) and
|
|
7
|
+
* {@link SignatureRequirementAction} (signature requirements whose metadata is
|
|
8
|
+
* exposed before any calldata exists). Each concrete action narrows
|
|
9
|
+
* {@link BaseAction} on its literal `type` tag and carries an
|
|
10
|
+
* operation-specific `args` record surfaced for tracing.
|
|
11
|
+
*
|
|
12
|
+
* @typeParam TType - Literal discriminator identifying the action.
|
|
13
|
+
* @typeParam TArgs - The action's argument record.
|
|
14
|
+
*/
|
|
4
15
|
export interface BaseAction<TType extends string = string, TArgs extends Record<string, unknown> = Record<string, unknown>> {
|
|
5
16
|
readonly type: TType;
|
|
6
17
|
readonly args: TArgs;
|
|
@@ -13,24 +24,58 @@ export interface ERC20ApprovalAction extends BaseAction<"erc20Approval", {
|
|
|
13
24
|
export interface ERC20PermitAction {
|
|
14
25
|
sign: (client: WalletClient, userAddress: Address) => Promise<Hex>;
|
|
15
26
|
}
|
|
27
|
+
/** Metadata for a direct Vault V2 deposit through VaultBundlesV1. */
|
|
16
28
|
export interface VaultV2DepositAction extends BaseAction<"vaultV2Deposit", {
|
|
17
|
-
vault
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
29
|
+
/** Destination vault receiving net assets; shares are minted to the transaction sender. */
|
|
30
|
+
readonly vault: Address;
|
|
31
|
+
/** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
|
|
32
|
+
readonly amount: bigint;
|
|
33
|
+
/** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
|
|
34
|
+
readonly maxSharePrice: bigint;
|
|
35
|
+
/** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
|
|
36
|
+
readonly nativeAmount?: bigint;
|
|
37
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
38
|
+
readonly referralFeePct: bigint;
|
|
39
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
40
|
+
readonly referralFeeRecipient: Address;
|
|
41
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
42
|
+
readonly referralFeeAssets: bigint;
|
|
43
|
+
/** Assets deposited into the vault: amount minus referralFeeAssets. */
|
|
44
|
+
readonly netAssets: bigint;
|
|
45
|
+
/** Execution and token-permit expiration as a Unix timestamp in seconds. */
|
|
46
|
+
readonly deadline: bigint;
|
|
22
47
|
}> {
|
|
23
48
|
}
|
|
49
|
+
/** Metadata for an exact-assets Vault V2 withdrawal through VaultBundlesV1. */
|
|
24
50
|
export interface VaultV2WithdrawAction extends BaseAction<"vaultV2Withdraw", {
|
|
25
|
-
vault
|
|
26
|
-
|
|
27
|
-
|
|
51
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
52
|
+
readonly vault: Address;
|
|
53
|
+
/** Gross withdrawal in asset base units, before the referral fee is deducted. */
|
|
54
|
+
readonly amount: bigint;
|
|
55
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
56
|
+
readonly referralFeePct: bigint;
|
|
57
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
58
|
+
readonly referralFeeRecipient: Address;
|
|
59
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
60
|
+
readonly referralFeeAssets: bigint;
|
|
61
|
+
/** Assets received by the transaction sender: amount minus referralFeeAssets. */
|
|
62
|
+
readonly netAssets: bigint;
|
|
63
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
64
|
+
readonly deadline: bigint;
|
|
28
65
|
}> {
|
|
29
66
|
}
|
|
67
|
+
/** Metadata for an exact-shares Vault V2 redemption through VaultBundlesV1. */
|
|
30
68
|
export interface VaultV2RedeemAction extends BaseAction<"vaultV2Redeem", {
|
|
31
|
-
vault
|
|
32
|
-
|
|
33
|
-
|
|
69
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
70
|
+
readonly vault: Address;
|
|
71
|
+
/** Exact shares to burn, in vault-share base units. */
|
|
72
|
+
readonly shares: bigint;
|
|
73
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
|
|
74
|
+
readonly referralFeePct: bigint;
|
|
75
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
76
|
+
readonly referralFeeRecipient: Address;
|
|
77
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
78
|
+
readonly deadline: bigint;
|
|
34
79
|
}> {
|
|
35
80
|
}
|
|
36
81
|
/** Metadata for a Vault V2 in-kind redemption into Morpho Blue supply positions. */
|
|
@@ -43,14 +88,22 @@ export interface VaultV2InKindRedeemAction extends BaseAction<"vaultV2InKindRede
|
|
|
43
88
|
readonly deadline: bigint;
|
|
44
89
|
}> {
|
|
45
90
|
}
|
|
91
|
+
/**
|
|
92
|
+
* Metadata for a Vault V2 force withdrawal through VaultExitBundlesV1.
|
|
93
|
+
*
|
|
94
|
+
* `exitAssets` is penalty-inclusive: the assets actually delivered are
|
|
95
|
+
* `assetsToWithdraw + floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty))`, minus the
|
|
96
|
+
* referral fee.
|
|
97
|
+
*/
|
|
46
98
|
export interface VaultV2ForceWithdrawAction extends BaseAction<"vaultV2ForceWithdraw", {
|
|
47
|
-
vault: Address;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
onBehalf: Address;
|
|
99
|
+
readonly vault: Address;
|
|
100
|
+
readonly adapter: Address;
|
|
101
|
+
readonly exitAssets: bigint;
|
|
102
|
+
readonly minSharePriceE27: bigint;
|
|
103
|
+
readonly referralFeePct: bigint;
|
|
104
|
+
readonly referralFeeRecipient: Address;
|
|
105
|
+
readonly onBehalf: Address;
|
|
106
|
+
readonly deadline: bigint;
|
|
54
107
|
}> {
|
|
55
108
|
}
|
|
56
109
|
export interface VaultV2ForceRedeemAction extends BaseAction<"vaultV2ForceRedeem", {
|
|
@@ -63,24 +116,58 @@ export interface VaultV2ForceRedeemAction extends BaseAction<"vaultV2ForceRedeem
|
|
|
63
116
|
onBehalf: Address;
|
|
64
117
|
}> {
|
|
65
118
|
}
|
|
119
|
+
/** Metadata for a direct Vault V1 deposit through VaultBundlesV1. */
|
|
66
120
|
export interface VaultV1DepositAction extends BaseAction<"vaultV1Deposit", {
|
|
67
|
-
vault
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
121
|
+
/** Destination vault receiving net assets; shares are minted to the transaction sender. */
|
|
122
|
+
readonly vault: Address;
|
|
123
|
+
/** Gross funding in asset base units, for either ERC-20 or native funding, before fees. */
|
|
124
|
+
readonly amount: bigint;
|
|
125
|
+
/** Maximum asset/share ratio scaled by 1e27, computed from net assets through the deadline. */
|
|
126
|
+
readonly maxSharePrice: bigint;
|
|
127
|
+
/** Native funding marker: equals `amount` and transaction `value` on native deposits; otherwise undefined. */
|
|
128
|
+
readonly nativeAmount?: bigint;
|
|
129
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
130
|
+
readonly referralFeePct: bigint;
|
|
131
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
132
|
+
readonly referralFeeRecipient: Address;
|
|
133
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
134
|
+
readonly referralFeeAssets: bigint;
|
|
135
|
+
/** Assets deposited into the vault: amount minus referralFeeAssets. */
|
|
136
|
+
readonly netAssets: bigint;
|
|
137
|
+
/** Execution and token-permit expiration as a Unix timestamp in seconds. */
|
|
138
|
+
readonly deadline: bigint;
|
|
72
139
|
}> {
|
|
73
140
|
}
|
|
141
|
+
/** Metadata for an exact-assets Vault V1 withdrawal through VaultBundlesV1. */
|
|
74
142
|
export interface VaultV1WithdrawAction extends BaseAction<"vaultV1Withdraw", {
|
|
75
|
-
vault
|
|
76
|
-
|
|
77
|
-
|
|
143
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
144
|
+
readonly vault: Address;
|
|
145
|
+
/** Gross withdrawal in asset base units, before the referral fee is deducted. */
|
|
146
|
+
readonly amount: bigint;
|
|
147
|
+
/** Referral fee fraction scaled by WAD (1e18); zero disables the fee. */
|
|
148
|
+
readonly referralFeePct: bigint;
|
|
149
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
150
|
+
readonly referralFeeRecipient: Address;
|
|
151
|
+
/** Fee in asset base units: floor(amount * referralFeePct / WAD). */
|
|
152
|
+
readonly referralFeeAssets: bigint;
|
|
153
|
+
/** Assets received by the transaction sender: amount minus referralFeeAssets. */
|
|
154
|
+
readonly netAssets: bigint;
|
|
155
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
156
|
+
readonly deadline: bigint;
|
|
78
157
|
}> {
|
|
79
158
|
}
|
|
159
|
+
/** Metadata for an exact-shares Vault V1 redemption through VaultBundlesV1. */
|
|
80
160
|
export interface VaultV1RedeemAction extends BaseAction<"vaultV1Redeem", {
|
|
81
|
-
vault
|
|
82
|
-
|
|
83
|
-
|
|
161
|
+
/** Source vault whose shares are burned from the transaction sender. */
|
|
162
|
+
readonly vault: Address;
|
|
163
|
+
/** Exact shares to burn, in vault-share base units. */
|
|
164
|
+
readonly shares: bigint;
|
|
165
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted from redeemed assets; zero disables it. */
|
|
166
|
+
readonly referralFeePct: bigint;
|
|
167
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
168
|
+
readonly referralFeeRecipient: Address;
|
|
169
|
+
/** Execution and share-permit expiration as a Unix timestamp in seconds. */
|
|
170
|
+
readonly deadline: bigint;
|
|
84
171
|
}> {
|
|
85
172
|
}
|
|
86
173
|
/** Metadata for a Vault V1 in-kind redemption into Morpho Blue supply positions. */
|
|
@@ -92,13 +179,28 @@ export interface VaultV1InKindRedeemAction extends BaseAction<"vaultV1InKindRede
|
|
|
92
179
|
readonly deadline: bigint;
|
|
93
180
|
}> {
|
|
94
181
|
}
|
|
182
|
+
/** Metadata for an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1. */
|
|
95
183
|
export interface VaultV1MigrateToV2Action extends BaseAction<"vaultV1MigrateToV2", {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
shares
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
184
|
+
/** Source Vault V1 whose shares are burned from the transaction sender. */
|
|
185
|
+
readonly sourceVault: Address;
|
|
186
|
+
/** Destination Vault V2 receiving net assets; shares are minted to the transaction sender. */
|
|
187
|
+
readonly targetVault: Address;
|
|
188
|
+
/** Gross assets to withdraw in asset base units; zero in exact-shares mode. */
|
|
189
|
+
readonly assets: bigint;
|
|
190
|
+
/** Source shares to burn in vault-share base units; zero in exact-assets mode. */
|
|
191
|
+
readonly shares: bigint;
|
|
192
|
+
/** Maximum destination asset base units per share base unit, scaled by RAY (1e27). */
|
|
193
|
+
readonly maxSharePriceVaultV2: bigint;
|
|
194
|
+
/** Referral fee fraction scaled by WAD (1e18), deducted before depositing; zero disables it. */
|
|
195
|
+
readonly referralFeePct: bigint;
|
|
196
|
+
/** Recipient of the referral fee; zero address when the fee is disabled by default. */
|
|
197
|
+
readonly referralFeeRecipient: Address;
|
|
198
|
+
/** Fee in asset base units: floor(assets * referralFeePct / WAD); omitted in exact-shares mode. */
|
|
199
|
+
readonly referralFeeAssets?: bigint;
|
|
200
|
+
/** Assets deposited: assets minus referralFeeAssets; omitted in exact-shares mode. */
|
|
201
|
+
readonly netAssets?: bigint;
|
|
202
|
+
/** Execution and source share-permit expiration as a Unix timestamp in seconds. */
|
|
203
|
+
readonly deadline: bigint;
|
|
102
204
|
}> {
|
|
103
205
|
}
|
|
104
206
|
/** Metadata for a direct BlueBundlesV1 loan-asset supply. */
|
|
@@ -296,8 +398,19 @@ export interface MidnightCancelOfferAction extends BaseAction<"midnightCancelOff
|
|
|
296
398
|
readonly onBehalf: Address;
|
|
297
399
|
}> {
|
|
298
400
|
}
|
|
299
|
-
/**
|
|
300
|
-
|
|
401
|
+
/**
|
|
402
|
+
* Enumerates every action a {@link Transaction} can describe across the VaultV1,
|
|
403
|
+
* VaultV2, Blue, and Midnight flows. The `type` tag discriminates the union so
|
|
404
|
+
* consumers can `switch` exhaustively on it.
|
|
405
|
+
*/
|
|
406
|
+
export type TransactionAction = ERC20ApprovalAction | VaultV2DepositAction | VaultV2WithdrawAction | VaultV2RedeemAction | VaultV2InKindRedeemAction | VaultV2ForceWithdrawAction | VaultV2ForceRedeemAction | VaultV1DepositAction | VaultV1WithdrawAction | VaultV1RedeemAction | VaultV1InKindRedeemAction | VaultV1MigrateToV2Action | BlueSupplyAction | BlueSupplyCollateralAction | BlueBorrowAction | BlueSupplyCollateralBorrowAction | BlueRepayAction | BlueWithdrawCollateralAction | BlueRepayWithdrawCollateralAction | BlueWithdrawAction | BlueRefinanceAction | BlueAuthorizationAction | MidnightAuthorizationAction | SetterRatifierRatifyRootAction | MidnightTakeLendAction | MidnightTakeBorrowAction | MidnightSupplyCollateralTakeBorrowAction | MidnightSupplyCollateralAction | MempoolSubmitOffersAction | MidnightRedeemAction | MidnightRepayWithdrawCollateralAction | MidnightCancelOfferAction;
|
|
407
|
+
/**
|
|
408
|
+
* Describes a single, immutable, deep-frozen transaction to submit on-chain:
|
|
409
|
+
* the target `to`, native `value`, encoded call `data`, and the originating
|
|
410
|
+
* {@link BaseAction} for tracing. Every action builder returns one.
|
|
411
|
+
*
|
|
412
|
+
* @typeParam TAction - The action that produced this transaction.
|
|
413
|
+
*/
|
|
301
414
|
export interface Transaction<TAction extends BaseAction = TransactionAction> {
|
|
302
415
|
readonly to: Address;
|
|
303
416
|
readonly value: bigint;
|
|
@@ -318,22 +431,58 @@ export type DepositAmountArgs = {
|
|
|
318
431
|
nativeAmount: bigint;
|
|
319
432
|
amount?: bigint;
|
|
320
433
|
};
|
|
434
|
+
/** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
|
|
435
|
+
export type BundlesFundingArgs = {
|
|
436
|
+
readonly amount: bigint;
|
|
437
|
+
readonly nativeAmount?: never;
|
|
438
|
+
} | {
|
|
439
|
+
readonly nativeAmount: bigint;
|
|
440
|
+
readonly amount?: never;
|
|
441
|
+
};
|
|
442
|
+
/** Controls token requirements generated for a bundles-funded action. */
|
|
443
|
+
export interface BundlesTokenRequirementsOptions {
|
|
444
|
+
/** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
|
|
445
|
+
readonly useSimplePermit?: boolean;
|
|
446
|
+
/** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
|
|
447
|
+
readonly permit2Nonce?: bigint;
|
|
448
|
+
}
|
|
449
|
+
/** Mutually exclusive source amount accepted by a Vault V1 to Vault V2 migration. */
|
|
450
|
+
export type VaultV1MigrateToV2AmountArgs = {
|
|
451
|
+
readonly shares: bigint;
|
|
452
|
+
readonly assets?: never;
|
|
453
|
+
} | {
|
|
454
|
+
readonly assets: bigint;
|
|
455
|
+
readonly shares?: never;
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Holds the pre-resolved arguments for an ERC-2612 `permit`: the signed approval
|
|
459
|
+
* of `amount` of `asset` from `owner` to the permitted spender, bounded by the
|
|
460
|
+
* `deadline` timestamp and consuming the given `nonce`. The associated
|
|
461
|
+
* {@link PermitAction} identifies the permitted spender, including fixed-bundle
|
|
462
|
+
* contracts and the GeneralAdapter1 periphery.
|
|
463
|
+
*/
|
|
321
464
|
export interface PermitArgs {
|
|
322
|
-
owner: Address;
|
|
323
|
-
nonce: bigint;
|
|
324
|
-
asset: Address;
|
|
325
|
-
signature: Hex;
|
|
326
|
-
amount: bigint;
|
|
327
|
-
deadline: bigint;
|
|
465
|
+
readonly owner: Address;
|
|
466
|
+
readonly nonce: bigint;
|
|
467
|
+
readonly asset: Address;
|
|
468
|
+
readonly signature: Hex;
|
|
469
|
+
readonly amount: bigint;
|
|
470
|
+
readonly deadline: bigint;
|
|
328
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Holds the pre-resolved arguments for a Permit2 `permit` bundler call. It
|
|
474
|
+
* mirrors {@link PermitArgs} but adds the Permit2 allowance `expiration` (when
|
|
475
|
+
* the on-chain allowance lapses) alongside the signature `deadline` (by when the
|
|
476
|
+
* signature must be submitted).
|
|
477
|
+
*/
|
|
329
478
|
export interface Permit2Args {
|
|
330
|
-
owner: Address;
|
|
331
|
-
nonce: bigint;
|
|
332
|
-
asset: Address;
|
|
333
|
-
signature: Hex;
|
|
334
|
-
amount: bigint;
|
|
335
|
-
deadline: bigint;
|
|
336
|
-
expiration: bigint;
|
|
479
|
+
readonly owner: Address;
|
|
480
|
+
readonly nonce: bigint;
|
|
481
|
+
readonly asset: Address;
|
|
482
|
+
readonly signature: Hex;
|
|
483
|
+
readonly amount: bigint;
|
|
484
|
+
readonly deadline: bigint;
|
|
485
|
+
readonly expiration: bigint;
|
|
337
486
|
}
|
|
338
487
|
/**
|
|
339
488
|
* Signed Morpho Blue authorization payload produced when an integrator opts into offchain
|
|
@@ -361,11 +510,22 @@ export interface MidnightOfferRootSignatureArgs {
|
|
|
361
510
|
readonly signature: Hex;
|
|
362
511
|
readonly payload: Hex;
|
|
363
512
|
}
|
|
513
|
+
/** EIP-712 payload carried by a signable requirement action. */
|
|
514
|
+
export type RequirementTypedData = TypedDataDefinition<Record<string, unknown>, string>;
|
|
364
515
|
export interface PermitAction extends BaseAction<"permit", {
|
|
365
|
-
spender: Address;
|
|
366
|
-
amount: bigint;
|
|
367
|
-
deadline: bigint;
|
|
516
|
+
readonly spender: Address;
|
|
517
|
+
readonly amount: bigint;
|
|
518
|
+
readonly deadline: bigint;
|
|
519
|
+
/** Permit nonce captured by a prepared requirement, when available. */
|
|
520
|
+
readonly nonce?: bigint;
|
|
368
521
|
}> {
|
|
522
|
+
/**
|
|
523
|
+
* EIP-712 payload `sign()` signs for this permit, exposed so it can be inspected or displayed
|
|
524
|
+
* before signing. Required on {@link Requirement.action}; optional here only so hand-built action
|
|
525
|
+
* metadata (e.g. test fixtures) need not supply it. The payload is deep-frozen and `sign()` signs
|
|
526
|
+
* this exact payload.
|
|
527
|
+
*/
|
|
528
|
+
readonly typedData?: RequirementTypedData;
|
|
369
529
|
}
|
|
370
530
|
export interface Permit2Action extends BaseAction<"permit2", {
|
|
371
531
|
spender: Address;
|
|
@@ -373,13 +533,18 @@ export interface Permit2Action extends BaseAction<"permit2", {
|
|
|
373
533
|
deadline: bigint;
|
|
374
534
|
expiration: bigint;
|
|
375
535
|
}> {
|
|
536
|
+
/** EIP-712 payload to sign for this Permit2 AllowanceTransfer. See {@link PermitAction.typedData}. */
|
|
537
|
+
readonly typedData?: RequirementTypedData;
|
|
376
538
|
}
|
|
377
|
-
/** Signable Permit2 SignatureTransfer requirement for a
|
|
378
|
-
export interface
|
|
539
|
+
/** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
|
|
540
|
+
export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
|
|
379
541
|
readonly spender: Address;
|
|
380
542
|
readonly amount: bigint;
|
|
543
|
+
readonly nonce: bigint;
|
|
381
544
|
readonly deadline: bigint;
|
|
382
545
|
}> {
|
|
546
|
+
/** EIP-712 payload to sign for this Permit2 SignatureTransfer. See {@link PermitAction.typedData}. */
|
|
547
|
+
readonly typedData?: RequirementTypedData;
|
|
383
548
|
}
|
|
384
549
|
/**
|
|
385
550
|
* Signable Morpho authorization requirement. Its `authorized` operator is route-specific:
|
|
@@ -390,6 +555,8 @@ export interface AuthorizationAction extends BaseAction<"authorization", {
|
|
|
390
555
|
isAuthorized: boolean;
|
|
391
556
|
deadline: bigint;
|
|
392
557
|
}> {
|
|
558
|
+
/** EIP-712 payload to sign for this Morpho authorization. See {@link PermitAction.typedData}. */
|
|
559
|
+
readonly typedData?: RequirementTypedData;
|
|
393
560
|
}
|
|
394
561
|
/** Metadata for a Midnight offer-root signature request. */
|
|
395
562
|
export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOfferRootSignature", {
|
|
@@ -397,9 +564,18 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
|
|
|
397
564
|
readonly ratifier: Address;
|
|
398
565
|
readonly offers: number;
|
|
399
566
|
}> {
|
|
567
|
+
/**
|
|
568
|
+
* EIP-712 offer-tree payload `sign()` signs for this Midnight ratification, exposed so it can be
|
|
569
|
+
* inspected or displayed before signing. See {@link PermitAction.typedData}.
|
|
570
|
+
*
|
|
571
|
+
* A bare signature over this payload is not enough to build the submit-offers transaction:
|
|
572
|
+
* `sign()` also derives the ratification payload (`MidnightOfferRootSignature.args.payload`) that
|
|
573
|
+
* `buildTx()` submits to the mempool.
|
|
574
|
+
*/
|
|
575
|
+
readonly typedData?: RequirementTypedData;
|
|
400
576
|
}
|
|
401
577
|
/** Action metadata supported by signature requirements. */
|
|
402
|
-
export type SignatureRequirementAction = PermitAction | Permit2Action |
|
|
578
|
+
export type SignatureRequirementAction = PermitAction | Permit2Action | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
|
|
403
579
|
/** Argument payloads returned by signature requirements. */
|
|
404
580
|
export type RequirementSignatureArgs = PermitArgs | Permit2Args | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
|
|
405
581
|
/** A signed ERC-2612 permit requirement. */
|
|
@@ -414,10 +590,10 @@ export interface Permit2AllowanceRequirementSignature {
|
|
|
414
590
|
}
|
|
415
591
|
/** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
|
|
416
592
|
export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
|
|
417
|
-
/** A signed Permit2 SignatureTransfer requirement used by
|
|
418
|
-
export interface
|
|
593
|
+
/** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
|
|
594
|
+
export interface Permit2SignatureTransferRequirementSignature {
|
|
419
595
|
readonly args: Readonly<PermitArgs>;
|
|
420
|
-
readonly action:
|
|
596
|
+
readonly action: Permit2SignatureTransferAction;
|
|
421
597
|
}
|
|
422
598
|
/** A signed Morpho authorization consumed by Bundler3 or a direct BlueBundlesV1 call. */
|
|
423
599
|
export interface AuthorizationRequirementSignature {
|
|
@@ -431,42 +607,57 @@ export interface MidnightOfferRootSignature {
|
|
|
431
607
|
}
|
|
432
608
|
/**
|
|
433
609
|
* The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
|
|
434
|
-
* `"permit"` / `"permit2"` carry token-approval args, `"
|
|
435
|
-
*
|
|
610
|
+
* `"permit"` / `"permit2"` carry token-approval args, `"permit2SignatureTransfer"` carries a
|
|
611
|
+
* bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
|
|
436
612
|
* and Midnight adds `"midnightOfferRootSignature"`.
|
|
437
613
|
*/
|
|
438
614
|
export type RequirementSignature<TAction extends SignatureRequirementAction | undefined = undefined, TArgs extends RequirementSignatureArgs | undefined = undefined> = TAction extends SignatureRequirementAction ? TArgs extends RequirementSignatureArgs ? {
|
|
439
615
|
args: TArgs;
|
|
440
616
|
action: TAction;
|
|
441
|
-
} : never : PermitRequirementSignature |
|
|
617
|
+
} : never : PermitRequirementSignature | Permit2SignatureTransferRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
442
618
|
type RequirementResult<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction, TArgs extends RequirementSignatureArgs | undefined> = TSignatureOrAction extends SignatureRequirementAction ? RequirementSignature<TSignatureOrAction, Extract<TArgs, RequirementSignatureArgs>> : Extract<TSignatureOrAction, RequirementSignature>;
|
|
443
619
|
/**
|
|
444
620
|
* A signable approval / authorization requirement. `sign()` returns the matching
|
|
445
|
-
* {@link RequirementSignature}; `action` describes the requirement without signing
|
|
621
|
+
* {@link RequirementSignature}; `action` describes the requirement without signing and carries the
|
|
622
|
+
* EIP-712 `typedData` payload so an integrator can inspect or display it before signing.
|
|
446
623
|
*
|
|
447
624
|
* Generic over the signature it produces so permit encoders narrow to
|
|
448
625
|
* {@link PermitRequirementSignature} and the authorization encoder to
|
|
449
626
|
* {@link AuthorizationRequirementSignature}; the two-parameter form is kept for
|
|
450
627
|
* Midnight action requirements that are parameterized by action and args.
|
|
628
|
+
*
|
|
629
|
+
* @example
|
|
630
|
+
* ```ts
|
|
631
|
+
* const requirement = (await output.getRequirements()).find(isRequirementSignature);
|
|
632
|
+
* if (requirement == null) return; // nothing to sign (only on-chain approvals, or none)
|
|
633
|
+
*
|
|
634
|
+
* const typedData = requirement.action.typedData; // exact EIP-712 payload `sign()` will sign
|
|
635
|
+
* const signed = await requirement.sign(walletClient, owner);
|
|
636
|
+
* const tx = output.buildTx([signed]); // Midnight outputs take the single signature instead
|
|
637
|
+
* ```
|
|
451
638
|
*/
|
|
452
639
|
export interface Requirement<TSignatureOrAction extends RequirementSignature | SignatureRequirementAction = RequirementSignature, TArgs extends RequirementSignatureArgs | undefined = undefined> {
|
|
453
|
-
|
|
454
|
-
|
|
640
|
+
/** Signs `action.typedData` with `client`, verifies the signature recovers `userAddress`, and returns the signed requirement. */
|
|
641
|
+
readonly sign: (client: WalletClient, userAddress: Address) => Promise<RequirementResult<TSignatureOrAction, TArgs>>;
|
|
642
|
+
/** Requirement metadata; `typedData` is always populated on SDK-built requirements. */
|
|
643
|
+
readonly action: RequirementResult<TSignatureOrAction, TArgs>["action"] & {
|
|
644
|
+
readonly typedData: RequirementTypedData;
|
|
645
|
+
};
|
|
455
646
|
}
|
|
456
647
|
/** Bundler3 token signature requirement. */
|
|
457
648
|
export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
|
|
458
|
-
/**
|
|
459
|
-
export type
|
|
649
|
+
/** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
|
|
650
|
+
export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
|
|
460
651
|
/** Midnight Ecrecover offer-root signature requirement. */
|
|
461
652
|
export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
|
|
462
653
|
/** Any token signature requirement supported by an SDK transaction route. */
|
|
463
|
-
export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement |
|
|
654
|
+
export type TokenSignatureRequirement = Bundler3TokenSignatureRequirement | BundlesTokenSignatureRequirement;
|
|
464
655
|
/** Bundler3 token signature result. */
|
|
465
656
|
export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
|
|
466
|
-
/**
|
|
467
|
-
export type
|
|
657
|
+
/** Token signature result consumed by a fixed bundles contract. */
|
|
658
|
+
export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
|
|
468
659
|
/** Any token signature result supported by an SDK transaction route. */
|
|
469
|
-
export type TokenRequirementSignature = Bundler3TokenRequirementSignature |
|
|
660
|
+
export type TokenRequirementSignature = Bundler3TokenRequirementSignature | BundlesTokenRequirementSignature;
|
|
470
661
|
/** Any signature result returned by an action-output signature requirement. */
|
|
471
662
|
export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
472
663
|
/** Any signature requirement returned by an entity action output. */
|
|
@@ -508,19 +699,19 @@ export declare function isPermitSignature(signature: RequirementSignature): sign
|
|
|
508
699
|
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
509
700
|
*
|
|
510
701
|
* @param signature - The signed requirement to test.
|
|
511
|
-
* @returns `true` when `signature.action.type` is `"
|
|
702
|
+
* @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
|
|
512
703
|
* @example
|
|
513
704
|
* ```ts
|
|
514
705
|
* import {
|
|
515
|
-
*
|
|
706
|
+
* isPermit2SignatureTransferSignature,
|
|
516
707
|
* type RequirementSignature,
|
|
517
708
|
* } from "@morpho-org/morpho-sdk";
|
|
518
709
|
*
|
|
519
710
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
520
|
-
*
|
|
711
|
+
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
521
712
|
* ```
|
|
522
713
|
*/
|
|
523
|
-
export declare function
|
|
714
|
+
export declare function isPermit2SignatureTransferSignature(signature: RequirementSignature): signature is Permit2SignatureTransferRequirementSignature;
|
|
524
715
|
/**
|
|
525
716
|
* Narrows a {@link RequirementSignature} to a signed Morpho authorization.
|
|
526
717
|
*
|
|
@@ -540,7 +731,7 @@ export interface SelectedRequirementSignatures {
|
|
|
540
731
|
/** The single ERC-2612 or Permit2 AllowanceTransfer signature, when present. */
|
|
541
732
|
readonly permit?: PermitRequirementSignature;
|
|
542
733
|
/** The single Permit2 SignatureTransfer signature, when present. */
|
|
543
|
-
readonly
|
|
734
|
+
readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
|
|
544
735
|
/** The single Morpho authorization signature, when present. */
|
|
545
736
|
readonly authorization?: AuthorizationRequirementSignature;
|
|
546
737
|
/** The single Midnight offer-root signature, when present. */
|
|
@@ -558,7 +749,7 @@ export interface SelectedRequirementSignatures {
|
|
|
558
749
|
* @param signatures - The signatures passed to `buildTx`.
|
|
559
750
|
* @param accepts - Which signature kinds this operation consumes.
|
|
560
751
|
* @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
|
|
561
|
-
* @param accepts.
|
|
752
|
+
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
562
753
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
563
754
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
564
755
|
* @returns The accepted signature in each typed slot, when present.
|
|
@@ -575,9 +766,9 @@ export interface SelectedRequirementSignatures {
|
|
|
575
766
|
* ```
|
|
576
767
|
*/
|
|
577
768
|
export declare function selectRequirementSignatures(signatures: readonly RequirementSignature[] | undefined, accepts: {
|
|
578
|
-
permit?: boolean;
|
|
579
|
-
|
|
580
|
-
authorization?: boolean;
|
|
581
|
-
midnightOfferRoot?: boolean;
|
|
769
|
+
readonly permit?: boolean;
|
|
770
|
+
readonly permit2SignatureTransfer?: boolean;
|
|
771
|
+
readonly authorization?: boolean;
|
|
772
|
+
readonly midnightOfferRoot?: boolean;
|
|
582
773
|
}): SelectedRequirementSignatures;
|
|
583
774
|
export {};
|
package/lib/cjs/types/action.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.isRequirementApproval = isRequirementApproval;
|
|
|
4
4
|
exports.isRequirementBlueAuthorization = isRequirementBlueAuthorization;
|
|
5
5
|
exports.isRequirementSignature = isRequirementSignature;
|
|
6
6
|
exports.isPermitSignature = isPermitSignature;
|
|
7
|
-
exports.
|
|
7
|
+
exports.isPermit2SignatureTransferSignature = isPermit2SignatureTransferSignature;
|
|
8
8
|
exports.isAuthorizationSignature = isAuthorizationSignature;
|
|
9
9
|
exports.isMidnightOfferRootSignature = isMidnightOfferRootSignature;
|
|
10
10
|
exports.selectRequirementSignatures = selectRequirementSignatures;
|
|
@@ -54,20 +54,20 @@ function isPermitSignature(signature) {
|
|
|
54
54
|
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
55
55
|
*
|
|
56
56
|
* @param signature - The signed requirement to test.
|
|
57
|
-
* @returns `true` when `signature.action.type` is `"
|
|
57
|
+
* @returns `true` when `signature.action.type` is `"permit2SignatureTransfer"`.
|
|
58
58
|
* @example
|
|
59
59
|
* ```ts
|
|
60
60
|
* import {
|
|
61
|
-
*
|
|
61
|
+
* isPermit2SignatureTransferSignature,
|
|
62
62
|
* type RequirementSignature,
|
|
63
63
|
* } from "@morpho-org/morpho-sdk";
|
|
64
64
|
*
|
|
65
65
|
* const getPermit2Nonce = (signature: RequirementSignature): bigint | undefined =>
|
|
66
|
-
*
|
|
66
|
+
* isPermit2SignatureTransferSignature(signature) ? signature.args.nonce : undefined;
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
-
function
|
|
70
|
-
return signature.action.type === "
|
|
69
|
+
function isPermit2SignatureTransferSignature(signature) {
|
|
70
|
+
return signature.action.type === "permit2SignatureTransfer";
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Narrows a {@link RequirementSignature} to a signed Morpho authorization.
|
|
@@ -99,7 +99,7 @@ function isMidnightOfferRootSignature(signature) {
|
|
|
99
99
|
* @param signatures - The signatures passed to `buildTx`.
|
|
100
100
|
* @param accepts - Which signature kinds this operation consumes.
|
|
101
101
|
* @param accepts.permit - Whether an ERC-2612 or Permit2 AllowanceTransfer signature is consumed.
|
|
102
|
-
* @param accepts.
|
|
102
|
+
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
103
103
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
104
104
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
105
105
|
* @returns The accepted signature in each typed slot, when present.
|
|
@@ -119,13 +119,13 @@ function selectRequirementSignatures(signatures, accepts) {
|
|
|
119
119
|
if (signatures == null)
|
|
120
120
|
return {};
|
|
121
121
|
const permits = signatures.filter(isPermitSignature);
|
|
122
|
-
const permit2Transfers = signatures.filter(
|
|
122
|
+
const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
|
|
123
123
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
124
124
|
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
125
125
|
if (!accepts.permit && permits.length > 0)
|
|
126
126
|
throw new error_js_1.UnexpectedRequirementSignatureError("permit");
|
|
127
|
-
if (!accepts.
|
|
128
|
-
throw new error_js_1.UnexpectedRequirementSignatureError("
|
|
127
|
+
if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)
|
|
128
|
+
throw new error_js_1.UnexpectedRequirementSignatureError("permit2SignatureTransfer");
|
|
129
129
|
if (!accepts.authorization && authorizations.length > 0)
|
|
130
130
|
throw new error_js_1.UnexpectedRequirementSignatureError("authorization");
|
|
131
131
|
if (!accepts.midnightOfferRoot && midnightOfferRoots.length > 0)
|
|
@@ -133,14 +133,14 @@ function selectRequirementSignatures(signatures, accepts) {
|
|
|
133
133
|
if (permits.length > 1)
|
|
134
134
|
throw new error_js_1.AmbiguousRequirementSignaturesError("permit", permits.length);
|
|
135
135
|
if (permit2Transfers.length > 1)
|
|
136
|
-
throw new error_js_1.AmbiguousRequirementSignaturesError("
|
|
136
|
+
throw new error_js_1.AmbiguousRequirementSignaturesError("permit2SignatureTransfer", permit2Transfers.length);
|
|
137
137
|
if (authorizations.length > 1)
|
|
138
138
|
throw new error_js_1.AmbiguousRequirementSignaturesError("authorization", authorizations.length);
|
|
139
139
|
if (midnightOfferRoots.length > 1)
|
|
140
140
|
throw new error_js_1.AmbiguousRequirementSignaturesError("midnightOfferRootSignature", midnightOfferRoots.length);
|
|
141
141
|
return {
|
|
142
142
|
permit: permits[0],
|
|
143
|
-
|
|
143
|
+
permit2SignatureTransfer: permit2Transfers[0],
|
|
144
144
|
authorization: authorizations[0],
|
|
145
145
|
midnightOfferRoot: midnightOfferRoots[0],
|
|
146
146
|
};
|