@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,58 +1,77 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Metadata, type PermitRequirementSignature, type Transaction, type VaultV2ForceWithdrawAction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link vaultV2ForceWithdraw}. */
|
|
4
4
|
export interface VaultV2ForceWithdrawParams {
|
|
5
|
-
vault: {
|
|
6
|
-
|
|
5
|
+
readonly vault: {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly address: Address;
|
|
7
8
|
};
|
|
8
|
-
args: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
readonly args: {
|
|
10
|
+
readonly adapter: Address;
|
|
11
|
+
readonly exitAssets: bigint;
|
|
12
|
+
readonly minSharePriceE27: bigint;
|
|
13
|
+
readonly userAddress: Address;
|
|
14
|
+
readonly deadline: bigint;
|
|
15
|
+
readonly referralFeePct?: bigint;
|
|
16
|
+
readonly referralFeeRecipient?: Address;
|
|
17
|
+
readonly requirementSignature?: PermitRequirementSignature;
|
|
15
18
|
};
|
|
16
|
-
metadata?: Metadata;
|
|
19
|
+
readonly metadata?: Metadata;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
* Prepares a
|
|
22
|
+
* Prepares a Vault V2 force withdrawal through VaultExitBundlesV1.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* The contract first withdraws everything the vault can pay without a penalty — its idle assets
|
|
25
|
+
* plus the liquidity available through its liquidity adapter — then force-deallocates the remainder
|
|
26
|
+
* by looping over the adapter's markets.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
+
* `exitAssets` is **penalty-inclusive**: it is what the contract debits from the user's position,
|
|
29
|
+
* while the assets actually delivered are
|
|
30
|
+
* `assetsToWithdraw + floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty))` minus the
|
|
31
|
+
* referral fee. Use `previewVaultV2ForceWithdraw` to quote the split.
|
|
28
32
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param params
|
|
33
|
-
*
|
|
34
|
-
* @param params.
|
|
35
|
-
* @param params.args.
|
|
36
|
-
*
|
|
37
|
-
* @param params.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
*
|
|
33
|
+
* Without a signature this embeds the empty-permit sentinel and requires a sufficient vault-share
|
|
34
|
+
* approval to VaultExitBundlesV1.
|
|
35
|
+
*
|
|
36
|
+
* @param params - Force withdrawal parameters.
|
|
37
|
+
* @param params.vault.chainId - Chain containing the target Vault V2 and VaultExitBundlesV1.
|
|
38
|
+
* @param params.vault.address - Target Vault V2 address.
|
|
39
|
+
* @param params.args.adapter - Vault's sole MorphoMarketV1AdapterV2.
|
|
40
|
+
* @param params.args.exitAssets - Penalty-inclusive, asset-denominated amount to exit.
|
|
41
|
+
* @param params.args.minSharePriceE27 - RAY-scaled lower bound on the realized exit share price
|
|
42
|
+
* (withdrawn assets per share burned). `0n` disables the on-chain bound; prefer the value the
|
|
43
|
+
* entity computes.
|
|
44
|
+
* @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
|
|
45
|
+
* VaultExitBundlesV1 burns `msg.sender`'s vault shares and pays out to `msg.sender`, so the
|
|
46
|
+
* submitting account must equal this address.
|
|
47
|
+
* @param params.args.deadline - Permit and bundle deadline.
|
|
48
|
+
* @param params.args.referralFeePct - Optional WAD-scaled share of the withdrawn assets routed to
|
|
49
|
+
* `referralFeeRecipient`. Defaults to `0n`. Deducted *after* the `minSharePriceE27` check, so it
|
|
50
|
+
* is outside that bound's protection.
|
|
51
|
+
* @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
|
|
52
|
+
* address, which is only valid alongside a zero `referralFeePct`.
|
|
53
|
+
* @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
|
|
54
|
+
* @param params.metadata - Optional analytics metadata.
|
|
55
|
+
* @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
|
|
56
|
+
* `data`, and the typed action discriminator.
|
|
57
|
+
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
58
|
+
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
59
|
+
* @throws {InputExceedsMaxError} when `referralFeePct` is not below WAD (the contract rejects it
|
|
60
|
+
* with `PctExceeded`), or when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
61
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
62
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
63
|
+
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
64
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind,
|
|
65
|
+
* asset, owner, spender, or signature encoding.
|
|
43
66
|
* @example
|
|
44
67
|
* ```ts
|
|
45
68
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
46
69
|
*
|
|
47
70
|
* const tx = vaultV2ForceWithdraw({
|
|
48
|
-
* vault: { address:
|
|
49
|
-
* args: {
|
|
50
|
-
* deallocations: [{ adapter, marketParams, amount: 500_000n }],
|
|
51
|
-
* withdraw: { amount: 500_000n, recipient },
|
|
52
|
-
* onBehalf,
|
|
53
|
-
* },
|
|
71
|
+
* vault: { chainId: 1, address: vault },
|
|
72
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
54
73
|
* });
|
|
55
74
|
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
56
75
|
* ```
|
|
57
76
|
*/
|
|
58
|
-
export declare const vaultV2ForceWithdraw: ({ vault
|
|
77
|
+
export declare const vaultV2ForceWithdraw: ({ vault, args, metadata, }: VaultV2ForceWithdrawParams) => Readonly<Transaction<VaultV2ForceWithdrawAction>>;
|
|
@@ -1,93 +1,120 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vaultV2ForceWithdraw = void 0;
|
|
4
|
-
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
5
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
6
|
+
const abis_js_1 = require("../../abis.js");
|
|
8
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
9
9
|
const index_js_2 = require("../../types/index.js");
|
|
10
|
+
const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultExitBundlesV1PermitStruct.js");
|
|
10
11
|
/**
|
|
11
|
-
* Prepares a
|
|
12
|
+
* Prepares a Vault V2 force withdrawal through VaultExitBundlesV1.
|
|
12
13
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* The contract first withdraws everything the vault can pay without a penalty — its idle assets
|
|
15
|
+
* plus the liquidity available through its liquidity adapter — then force-deallocates the remainder
|
|
16
|
+
* by looping over the adapter's markets.
|
|
16
17
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
18
|
+
* `exitAssets` is **penalty-inclusive**: it is what the contract debits from the user's position,
|
|
19
|
+
* while the assets actually delivered are
|
|
20
|
+
* `assetsToWithdraw + floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty))` minus the
|
|
21
|
+
* referral fee. Use `previewVaultV2ForceWithdraw` to quote the split.
|
|
20
22
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @param params
|
|
25
|
-
*
|
|
26
|
-
* @param params.
|
|
27
|
-
* @param params.args.
|
|
28
|
-
*
|
|
29
|
-
* @param params.
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
*
|
|
23
|
+
* Without a signature this embeds the empty-permit sentinel and requires a sufficient vault-share
|
|
24
|
+
* approval to VaultExitBundlesV1.
|
|
25
|
+
*
|
|
26
|
+
* @param params - Force withdrawal parameters.
|
|
27
|
+
* @param params.vault.chainId - Chain containing the target Vault V2 and VaultExitBundlesV1.
|
|
28
|
+
* @param params.vault.address - Target Vault V2 address.
|
|
29
|
+
* @param params.args.adapter - Vault's sole MorphoMarketV1AdapterV2.
|
|
30
|
+
* @param params.args.exitAssets - Penalty-inclusive, asset-denominated amount to exit.
|
|
31
|
+
* @param params.args.minSharePriceE27 - RAY-scaled lower bound on the realized exit share price
|
|
32
|
+
* (withdrawn assets per share burned). `0n` disables the on-chain bound; prefer the value the
|
|
33
|
+
* entity computes.
|
|
34
|
+
* @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
|
|
35
|
+
* VaultExitBundlesV1 burns `msg.sender`'s vault shares and pays out to `msg.sender`, so the
|
|
36
|
+
* submitting account must equal this address.
|
|
37
|
+
* @param params.args.deadline - Permit and bundle deadline.
|
|
38
|
+
* @param params.args.referralFeePct - Optional WAD-scaled share of the withdrawn assets routed to
|
|
39
|
+
* `referralFeeRecipient`. Defaults to `0n`. Deducted *after* the `minSharePriceE27` check, so it
|
|
40
|
+
* is outside that bound's protection.
|
|
41
|
+
* @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
|
|
42
|
+
* address, which is only valid alongside a zero `referralFeePct`.
|
|
43
|
+
* @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
|
|
44
|
+
* @param params.metadata - Optional analytics metadata.
|
|
45
|
+
* @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
|
|
46
|
+
* `data`, and the typed action discriminator.
|
|
47
|
+
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
48
|
+
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
49
|
+
* @throws {InputExceedsMaxError} when `referralFeePct` is not below WAD (the contract rejects it
|
|
50
|
+
* with `PctExceeded`), or when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
51
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
52
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
53
|
+
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
54
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind,
|
|
55
|
+
* asset, owner, spender, or signature encoding.
|
|
35
56
|
* @example
|
|
36
57
|
* ```ts
|
|
37
58
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
38
59
|
*
|
|
39
60
|
* const tx = vaultV2ForceWithdraw({
|
|
40
|
-
* vault: { address:
|
|
41
|
-
* args: {
|
|
42
|
-
* deallocations: [{ adapter, marketParams, amount: 500_000n }],
|
|
43
|
-
* withdraw: { amount: 500_000n, recipient },
|
|
44
|
-
* onBehalf,
|
|
45
|
-
* },
|
|
61
|
+
* vault: { chainId: 1, address: vault },
|
|
62
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
46
63
|
* });
|
|
47
64
|
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
48
65
|
* ```
|
|
49
66
|
*/
|
|
50
|
-
const vaultV2ForceWithdraw = ({ vault
|
|
51
|
-
if (
|
|
52
|
-
throw new index_js_2.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
|
68
|
+
if (args.exitAssets <= 0n)
|
|
69
|
+
throw new index_js_2.NonPositiveInputError("exitAssets", args.exitAssets);
|
|
70
|
+
(0, validate_js_1.validateUint256Field)("exitAssets", args.exitAssets);
|
|
71
|
+
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
72
|
+
// `0n` stays valid — it is the intentional "no on-chain bound" opt-out — but a value the uint256
|
|
73
|
+
// slot cannot hold must fail with a dedicated error instead of viem's `IntegerOutOfRangeError`.
|
|
74
|
+
// The entity never emits these (it forbids a non-positive override); this guards direct callers.
|
|
75
|
+
(0, validate_js_1.validateUint256Field)("minSharePriceE27", args.minSharePriceE27);
|
|
76
|
+
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(args);
|
|
77
|
+
const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
78
|
+
const sharesPermit = (0, getVaultExitBundlesV1PermitStruct_js_1.getVaultExitBundlesV1PermitStruct)({
|
|
79
|
+
vault: vault.address,
|
|
80
|
+
deadline: args.deadline,
|
|
81
|
+
owner: args.userAddress,
|
|
82
|
+
spender: to,
|
|
83
|
+
requirementSignature: args.requirementSignature,
|
|
84
|
+
});
|
|
67
85
|
let tx = {
|
|
68
|
-
to
|
|
86
|
+
to,
|
|
87
|
+
value: 0n,
|
|
69
88
|
data: (0, viem_1.encodeFunctionData)({
|
|
70
|
-
abi:
|
|
71
|
-
functionName: "
|
|
72
|
-
args: [
|
|
89
|
+
abi: abis_js_1.vaultExitBundlesV1Abi,
|
|
90
|
+
functionName: "vaultExitBundlesV1ForceWithdrawVaultV2",
|
|
91
|
+
args: [
|
|
92
|
+
vault.address,
|
|
93
|
+
args.adapter,
|
|
94
|
+
args.exitAssets,
|
|
95
|
+
args.minSharePriceE27,
|
|
96
|
+
sharesPermit,
|
|
97
|
+
referralFeePct,
|
|
98
|
+
referralFeeRecipient,
|
|
99
|
+
args.deadline,
|
|
100
|
+
],
|
|
73
101
|
}),
|
|
74
|
-
value: 0n,
|
|
75
102
|
};
|
|
76
|
-
if (metadata)
|
|
103
|
+
if (metadata)
|
|
77
104
|
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
78
|
-
}
|
|
79
105
|
return (0, morpho_ts_1.deepFreeze)({
|
|
80
106
|
...tx,
|
|
81
107
|
action: {
|
|
82
108
|
type: "vaultV2ForceWithdraw",
|
|
83
109
|
args: {
|
|
84
|
-
vault:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
onBehalf,
|
|
110
|
+
vault: vault.address,
|
|
111
|
+
adapter: args.adapter,
|
|
112
|
+
exitAssets: args.exitAssets,
|
|
113
|
+
minSharePriceE27: args.minSharePriceE27,
|
|
114
|
+
referralFeePct,
|
|
115
|
+
referralFeeRecipient,
|
|
116
|
+
onBehalf: args.userAddress,
|
|
117
|
+
deadline: args.deadline,
|
|
91
118
|
},
|
|
92
119
|
},
|
|
93
120
|
});
|
|
@@ -39,6 +39,7 @@ export interface VaultV2InKindRedeemParams {
|
|
|
39
39
|
* @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
|
|
40
40
|
* `data`, and the typed action discriminator.
|
|
41
41
|
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
42
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
42
43
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
43
44
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
44
45
|
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
@@ -5,6 +5,7 @@ const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
|
5
5
|
const viem_1 = require("viem");
|
|
6
6
|
const abis_js_1 = require("../../abis.js");
|
|
7
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
8
9
|
const index_js_2 = require("../../types/index.js");
|
|
9
10
|
const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultExitBundlesV1PermitStruct.js");
|
|
10
11
|
/**
|
|
@@ -29,6 +30,7 @@ const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultEx
|
|
|
29
30
|
* @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
|
|
30
31
|
* `data`, and the typed action discriminator.
|
|
31
32
|
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
33
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
32
34
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
33
35
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
34
36
|
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
@@ -46,8 +48,7 @@ const getVaultExitBundlesV1PermitStruct_js_1 = require("../signatures/getVaultEx
|
|
|
46
48
|
const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
|
|
47
49
|
if (args.amount <= 0n)
|
|
48
50
|
throw new index_js_2.NonPositiveInputError("amount", args.amount);
|
|
49
|
-
|
|
50
|
-
throw new index_js_2.NonPositiveInputError("deadline", args.deadline);
|
|
51
|
+
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
51
52
|
const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
52
53
|
const marketParamsList = args.marketParamsList.map((marketParams) => ({
|
|
53
54
|
loanToken: marketParams.loanToken,
|
|
@@ -1,40 +1,46 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type Metadata, type Transaction, type VaultV2RedeemAction } from "../../types/index.js";
|
|
2
|
+
import { type Erc2612RequirementSignature, type Metadata, type Transaction, type VaultV2RedeemAction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link vaultV2Redeem}. */
|
|
4
4
|
export interface VaultV2RedeemParams {
|
|
5
|
-
vault: {
|
|
6
|
-
|
|
5
|
+
readonly vault: {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly address: Address;
|
|
7
8
|
};
|
|
8
|
-
args: {
|
|
9
|
-
shares: bigint;
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
readonly args: {
|
|
10
|
+
readonly shares: bigint;
|
|
11
|
+
readonly userAddress: Address;
|
|
12
|
+
readonly recipient?: never;
|
|
13
|
+
readonly onBehalf?: never;
|
|
14
|
+
readonly requirementSignature?: Erc2612RequirementSignature;
|
|
15
|
+
readonly referralFeePct?: bigint;
|
|
16
|
+
readonly referralFeeRecipient?: Address;
|
|
17
|
+
readonly deadline: bigint;
|
|
12
18
|
};
|
|
13
|
-
metadata?: Metadata;
|
|
19
|
+
readonly metadata?: Metadata;
|
|
14
20
|
}
|
|
15
21
|
/**
|
|
16
|
-
*
|
|
22
|
+
* Encodes an exact-shares Vault V2 redemption through VaultBundlesV1.
|
|
17
23
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @
|
|
22
|
-
* @
|
|
23
|
-
* @
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
28
|
-
* @throws {NonPositiveInputError} when `shares <= 0n`.
|
|
24
|
+
* @param params - Vault, shares, share permit, fee, and deadline values.
|
|
25
|
+
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
26
|
+
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
27
|
+
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
28
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
29
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
30
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
31
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
32
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
33
|
+
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
29
34
|
* @example
|
|
30
35
|
* ```ts
|
|
31
36
|
* import { vaultV2Redeem } from "@morpho-org/morpho-sdk";
|
|
37
|
+
* import { zeroAddress } from "viem";
|
|
32
38
|
*
|
|
33
39
|
* const tx = vaultV2Redeem({
|
|
34
|
-
* vault: { address:
|
|
35
|
-
* args: { shares: 1_000_000n,
|
|
40
|
+
* vault: { chainId: 1, address: zeroAddress },
|
|
41
|
+
* args: { shares: 1_000_000n, userAddress: zeroAddress, deadline: 1_900_000_000n },
|
|
36
42
|
* });
|
|
37
|
-
* // tx
|
|
43
|
+
* // tx.action.type === "vaultV2Redeem"
|
|
38
44
|
* ```
|
|
39
45
|
*/
|
|
40
|
-
export declare const vaultV2Redeem: (
|
|
46
|
+
export declare const vaultV2Redeem: (params: VaultV2RedeemParams) => Readonly<Transaction<VaultV2RedeemAction>>;
|
|
@@ -1,58 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vaultV2Redeem = void 0;
|
|
4
|
-
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
5
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
6
|
+
const abis_js_1 = require("../../abis.js");
|
|
7
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
8
|
+
const index_js_1 = require("../../types/index.js");
|
|
9
|
+
const common_js_1 = require("../bundles/common.js");
|
|
9
10
|
/**
|
|
10
|
-
*
|
|
11
|
+
* Encodes an exact-shares Vault V2 redemption through VaultBundlesV1.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
16
|
-
* @
|
|
17
|
-
* @
|
|
18
|
-
* @
|
|
19
|
-
* @
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
* @throws {NonPositiveInputError} when `shares <= 0n`.
|
|
13
|
+
* @param params - Vault, shares, share permit, fee, and deadline values.
|
|
14
|
+
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
15
|
+
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
16
|
+
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
17
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
18
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
19
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
20
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
21
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
22
|
+
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
23
23
|
* @example
|
|
24
24
|
* ```ts
|
|
25
25
|
* import { vaultV2Redeem } from "@morpho-org/morpho-sdk";
|
|
26
|
+
* import { zeroAddress } from "viem";
|
|
26
27
|
*
|
|
27
28
|
* const tx = vaultV2Redeem({
|
|
28
|
-
* vault: { address:
|
|
29
|
-
* args: { shares: 1_000_000n,
|
|
29
|
+
* vault: { chainId: 1, address: zeroAddress },
|
|
30
|
+
* args: { shares: 1_000_000n, userAddress: zeroAddress, deadline: 1_900_000_000n },
|
|
30
31
|
* });
|
|
31
|
-
* // tx
|
|
32
|
+
* // tx.action.type === "vaultV2Redeem"
|
|
32
33
|
* ```
|
|
33
34
|
*/
|
|
34
|
-
const vaultV2Redeem = (
|
|
35
|
-
if (shares <= 0n) {
|
|
36
|
-
throw new
|
|
35
|
+
const vaultV2Redeem = (params) => {
|
|
36
|
+
if (params.args.shares <= 0n) {
|
|
37
|
+
throw new index_js_1.NonPositiveInputError("shares", params.args.shares);
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
// Reject ABI overflow with SDK errors before calldata encoding.
|
|
40
|
+
(0, validate_js_1.validateUint256Field)("shares", params.args.shares);
|
|
41
|
+
const common = (0, common_js_1.normalizeBundlesCommonParams)(params.args);
|
|
42
|
+
const spender = (0, morpho_ts_1.getChainAddress)(params.vault.chainId, "bundles.vaultBundlesV1");
|
|
43
|
+
const sharesPermit = (0, common_js_1.getBundlesSharesPermit)({
|
|
44
|
+
vault: params.vault.address,
|
|
45
|
+
deadline: common.deadline,
|
|
46
|
+
owner: params.args.userAddress,
|
|
47
|
+
spender,
|
|
48
|
+
amount: params.args.shares,
|
|
49
|
+
requirementSignature: params.args.requirementSignature,
|
|
50
|
+
});
|
|
51
|
+
return (0, common_js_1.finalizeVaultBundlesV1Transaction)({
|
|
52
|
+
chainId: params.vault.chainId,
|
|
53
|
+
value: 0n,
|
|
40
54
|
data: (0, viem_1.encodeFunctionData)({
|
|
41
|
-
abi:
|
|
42
|
-
functionName: "
|
|
43
|
-
args: [
|
|
55
|
+
abi: abis_js_1.vaultBundlesV1Abi,
|
|
56
|
+
functionName: "vaultBundlesV1Withdraw",
|
|
57
|
+
args: [
|
|
58
|
+
params.vault.address,
|
|
59
|
+
0n,
|
|
60
|
+
params.args.shares,
|
|
61
|
+
sharesPermit,
|
|
62
|
+
common.referralFeePct,
|
|
63
|
+
common.referralFeeRecipient,
|
|
64
|
+
common.deadline,
|
|
65
|
+
],
|
|
44
66
|
}),
|
|
45
|
-
value: 0n,
|
|
46
|
-
};
|
|
47
|
-
if (metadata) {
|
|
48
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
49
|
-
}
|
|
50
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
51
|
-
...tx,
|
|
52
67
|
action: {
|
|
53
68
|
type: "vaultV2Redeem",
|
|
54
|
-
args: {
|
|
69
|
+
args: {
|
|
70
|
+
vault: params.vault.address,
|
|
71
|
+
shares: params.args.shares,
|
|
72
|
+
referralFeePct: common.referralFeePct,
|
|
73
|
+
referralFeeRecipient: common.referralFeeRecipient,
|
|
74
|
+
deadline: common.deadline,
|
|
75
|
+
},
|
|
55
76
|
},
|
|
77
|
+
metadata: params.metadata,
|
|
56
78
|
});
|
|
57
79
|
};
|
|
58
80
|
exports.vaultV2Redeem = vaultV2Redeem;
|