@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +404 -0
- package/README.md +127 -69
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +62 -61
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +86 -0
- package/lib/cjs/actions/blue/common.js +205 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -112
- package/lib/cjs/actions/blue/refinance.js +97 -199
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- package/lib/cjs/actions/bundles/common.d.ts +200 -0
- package/lib/cjs/actions/bundles/common.js +469 -0
- package/lib/cjs/actions/bundles/index.d.ts +3 -0
- package/lib/cjs/actions/bundles/index.js +23 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
- package/lib/cjs/actions/index.d.ts +2 -1
- 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 +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/index.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +8 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +123 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
- package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/cjs/actions/vaultV1/deposit.js +110 -109
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
- package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/cjs/actions/vaultV1/redeem.js +56 -33
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
- package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/cjs/actions/vaultV2/deposit.js +111 -109
- package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/cjs/actions/vaultV2/redeem.js +56 -34
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
- package/lib/cjs/bundler/actions.d.ts +4 -4
- package/lib/cjs/bundler/actions.js +4 -4
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +806 -374
- package/lib/cjs/entities/blue/blue.js +449 -696
- package/lib/cjs/entities/index.d.ts +2 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +203 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +17 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +5 -1
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +90 -1
- package/lib/cjs/helpers/slippage.js +123 -0
- package/lib/cjs/helpers/validate.d.ts +16 -23
- package/lib/cjs/helpers/validate.js +41 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +3 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +303 -210
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +193 -18
- package/lib/cjs/types/error.js +267 -24
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +62 -61
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +86 -0
- package/lib/esm/actions/blue/common.js +193 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -112
- package/lib/esm/actions/blue/refinance.js +98 -200
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
- package/lib/esm/actions/blue/withdraw.d.ts +68 -79
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- package/lib/esm/actions/bundles/common.d.ts +200 -0
- package/lib/esm/actions/bundles/common.js +457 -0
- package/lib/esm/actions/bundles/index.d.ts +3 -0
- package/lib/esm/actions/bundles/index.js +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
- package/lib/esm/actions/index.d.ts +2 -1
- 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 +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/index.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +119 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
- package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/esm/actions/vaultV1/deposit.js +112 -111
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
- package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/esm/actions/vaultV1/redeem.js +56 -33
- package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/esm/actions/vaultV1/withdraw.js +86 -34
- package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/esm/actions/vaultV2/deposit.js +113 -111
- package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/esm/actions/vaultV2/redeem.js +56 -34
- package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/esm/actions/vaultV2/withdraw.js +86 -35
- package/lib/esm/bundler/actions.d.ts +4 -4
- package/lib/esm/bundler/actions.js +4 -4
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +806 -374
- package/lib/esm/entities/blue/blue.js +455 -702
- package/lib/esm/entities/index.d.ts +2 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +199 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +90 -1
- package/lib/esm/helpers/slippage.js +122 -2
- package/lib/esm/helpers/validate.d.ts +16 -23
- package/lib/esm/helpers/validate.js +40 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +3 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +303 -210
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +193 -18
- package/lib/esm/types/error.js +252 -21
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +6 -5
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
|
@@ -1,134 +1,136 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vaultV2Deposit = void 0;
|
|
4
|
-
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
5
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
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");
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
11
|
+
* Encodes a Vault V2 deposit through the registered VaultBundlesV1 contract.
|
|
13
12
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* the
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* asset
|
|
21
|
-
*
|
|
22
|
-
* @param params.
|
|
23
|
-
* @param params.
|
|
24
|
-
* @param params.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
* @param params.args.
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
* @param params.metadata -
|
|
34
|
-
* @
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* @throws {
|
|
38
|
-
*
|
|
39
|
-
* @throws {
|
|
40
|
-
*
|
|
41
|
-
* @throws {NativeAmountOnNonWNativeVaultError} when
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
* @throws {
|
|
49
|
-
*
|
|
13
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
14
|
+
* @param params.vault.address - Vault V2 contract receiving the net deposit.
|
|
15
|
+
* @param params.vault.asset - Underlying ERC-20 asset; must be the chain's wNative for native funding.
|
|
16
|
+
* @param params.args.amount - Positive gross ERC-20 amount in asset base units, exclusive with `nativeAmount`.
|
|
17
|
+
* @param params.args.nativeAmount - Positive gross native amount in wei, exclusive with `amount` and
|
|
18
|
+
* `requirementSignature`; sent as `tx.value` and wrapped by VaultBundlesV1.
|
|
19
|
+
* @param params.args.maxSharePrice - Positive maximum asset base units per share base unit, scaled
|
|
20
|
+
* by RAY (1e27). Compute it for the net deposit after referral fees to bound slippage.
|
|
21
|
+
* @param params.args.userAddress - Permit owner and transaction sender; VaultBundlesV1 mints shares to this account.
|
|
22
|
+
* @param params.args.recipient - Unsupported; shares are always minted to the transaction sender.
|
|
23
|
+
* @param params.args.requirementSignature - Optional ERC-2612 or Permit2 SignatureTransfer signature
|
|
24
|
+
* for the gross amount, vault asset, `userAddress`, and VaultBundlesV1 spender.
|
|
25
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
26
|
+
* The fee is rounded down and deducted from gross assets before depositing.
|
|
27
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
28
|
+
* when `referralFeePct > 0n`.
|
|
29
|
+
* @param params.args.deadline - Positive uint256 Unix timestamp in seconds after which execution
|
|
30
|
+
* reverts. The caller must supply it; the builder chooses no default.
|
|
31
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
32
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
33
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
34
|
+
* @returns A deep-frozen `Transaction<VaultV2DepositAction>` targeting VaultBundlesV1, with
|
|
35
|
+
* `to`, `value`, `data`, and gross/fee/net deposit action metadata.
|
|
36
|
+
* @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
|
|
37
|
+
* @throws {NegativeInputError} when the selected funding amount or `referralFeePct` is negative.
|
|
38
|
+
* @throws {NonPositiveInputError} when funding, `maxSharePrice`, or `deadline` is not positive.
|
|
39
|
+
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
40
|
+
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
|
|
41
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD; it extends
|
|
42
|
+
* {@link InputExceedsMaxError}, so either class catches it.
|
|
43
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
44
|
+
* @throws {UnexpectedRequirementSignatureError} when native funding carries a token permit or a
|
|
45
|
+
* Permit2 AllowanceTransfer signature is supplied.
|
|
46
|
+
* @throws {InputExceedsMaxError} when funding, `maxSharePrice`, or `deadline` exceeds uint256.
|
|
47
|
+
* @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
|
|
48
|
+
* @throws {DepositAssetMismatchError} when the signed asset differs from the vault asset.
|
|
49
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from the gross funding amount.
|
|
50
|
+
* @throws {DepositSpenderMismatchError} when the signed spender is not VaultBundlesV1.
|
|
51
|
+
* @throws {BundlesRequirementSignatureMismatchError} when the signature deadline, nonce, or encoding is invalid.
|
|
52
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
53
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
50
54
|
* @example
|
|
51
55
|
* ```ts
|
|
52
56
|
* import { vaultV2Deposit } from "@morpho-org/morpho-sdk";
|
|
57
|
+
* import { getChainAddresses } from "@morpho-org/morpho-sdk/addresses";
|
|
58
|
+
* import type { Address } from "viem";
|
|
59
|
+
* import { mainnet } from "viem/chains";
|
|
53
60
|
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* }
|
|
61
|
-
*
|
|
62
|
-
*
|
|
61
|
+
* export function buildKeyrockUsdcDeposit(
|
|
62
|
+
* userAddress: Address,
|
|
63
|
+
* maxSharePrice: bigint,
|
|
64
|
+
* deadline: bigint,
|
|
65
|
+
* ) {
|
|
66
|
+
* const keyrockUsdcVaultV2 = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
|
|
67
|
+
* const { usdc } = getChainAddresses(mainnet.id);
|
|
68
|
+
* const tx = vaultV2Deposit({
|
|
69
|
+
* vault: { chainId: mainnet.id, address: keyrockUsdcVaultV2, asset: usdc! },
|
|
70
|
+
* args: { amount: 1_000_000n, maxSharePrice, userAddress, deadline },
|
|
71
|
+
* });
|
|
72
|
+
* // tx satisfies Readonly<Transaction<VaultV2DepositAction>>
|
|
73
|
+
* return tx;
|
|
74
|
+
* }
|
|
63
75
|
* ```
|
|
64
76
|
*/
|
|
65
|
-
const vaultV2Deposit = (
|
|
66
|
-
|
|
67
|
-
|
|
77
|
+
const vaultV2Deposit = (params) => {
|
|
78
|
+
const funding = (0, common_js_1.resolveBundlesFunding)(params.args);
|
|
79
|
+
if (params.args.maxSharePrice <= 0n) {
|
|
80
|
+
throw new index_js_1.NonPositiveInputError("maxSharePrice", params.args.maxSharePrice);
|
|
68
81
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (
|
|
76
|
-
throw new
|
|
77
|
-
}
|
|
78
|
-
if (!(0, morpho_ts_1.isDefined)(wNative)) {
|
|
79
|
-
throw new index_js_3.ChainWNativeMissingError(chainId);
|
|
82
|
+
// Reject ABI overflow with SDK errors before calldata encoding.
|
|
83
|
+
(0, validate_js_1.validateUint256Field)(funding.value > 0n ? "nativeAmount" : "amount", funding.assets);
|
|
84
|
+
(0, validate_js_1.validateUint256Field)("maxSharePrice", params.args.maxSharePrice);
|
|
85
|
+
if (funding.value > 0n) {
|
|
86
|
+
// Reject native funding unless the vault accepts the chain's wrapped-native asset.
|
|
87
|
+
(0, validate_js_1.validateNativeVaultAsset)(params.vault.chainId, params.vault.asset);
|
|
88
|
+
if (params.args.requirementSignature != null) {
|
|
89
|
+
throw new index_js_1.UnexpectedRequirementSignatureError(params.args.requirementSignature.action.type);
|
|
80
90
|
}
|
|
81
|
-
if (!(0, viem_1.isAddressEqual)(asset, wNative)) {
|
|
82
|
-
throw new index_js_3.NativeAmountOnNonWNativeVaultError(asset, wNative);
|
|
83
|
-
}
|
|
84
|
-
actions.push(
|
|
85
|
-
// Transfers native token from Bundler3 to GeneralAdapter1 for wrapping.
|
|
86
|
-
{
|
|
87
|
-
type: "nativeTransfer",
|
|
88
|
-
args: [bundler3, generalAdapter1, nativeAmount, false /* skipRevert */],
|
|
89
|
-
}, {
|
|
90
|
-
type: "wrapNative",
|
|
91
|
-
args: [nativeAmount, generalAdapter1, false /* skipRevert */],
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
if (amount > 0n) {
|
|
95
|
-
actions.push(...(0, getTokenRequirementActions_js_1.getTokenRequirementActions)({
|
|
96
|
-
asset,
|
|
97
|
-
amount,
|
|
98
|
-
recipient: generalAdapter1,
|
|
99
|
-
requirementSignature,
|
|
100
|
-
}));
|
|
101
91
|
}
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
recipient,
|
|
113
|
-
false /* skipRevert */,
|
|
114
|
-
],
|
|
92
|
+
const common = (0, common_js_1.normalizeBundlesCommonParams)(params.args);
|
|
93
|
+
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(funding.assets, common.referralFeePct);
|
|
94
|
+
const netAssets = funding.assets - referralFeeAssets;
|
|
95
|
+
const spender = (0, morpho_ts_1.getChainAddress)(params.vault.chainId, "bundles.vaultBundlesV1");
|
|
96
|
+
const tokenPermit = (0, common_js_1.getBundlesTokenPermit)({
|
|
97
|
+
userAddress: params.args.userAddress,
|
|
98
|
+
token: params.vault.asset,
|
|
99
|
+
spender,
|
|
100
|
+
amount: funding.assets,
|
|
101
|
+
requirementSignature: params.args.requirementSignature,
|
|
115
102
|
});
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
103
|
+
return (0, common_js_1.finalizeVaultBundlesV1Transaction)({
|
|
104
|
+
chainId: params.vault.chainId,
|
|
105
|
+
value: funding.value,
|
|
106
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
107
|
+
abi: abis_js_1.vaultBundlesV1Abi,
|
|
108
|
+
functionName: "vaultBundlesV1Deposit",
|
|
109
|
+
args: [
|
|
110
|
+
params.vault.address,
|
|
111
|
+
funding.assets,
|
|
112
|
+
params.args.maxSharePrice,
|
|
113
|
+
tokenPermit,
|
|
114
|
+
common.referralFeePct,
|
|
115
|
+
common.referralFeeRecipient,
|
|
116
|
+
common.deadline,
|
|
117
|
+
],
|
|
118
|
+
}),
|
|
122
119
|
action: {
|
|
123
120
|
type: "vaultV2Deposit",
|
|
124
121
|
args: {
|
|
125
|
-
vault:
|
|
126
|
-
amount,
|
|
127
|
-
maxSharePrice,
|
|
128
|
-
|
|
129
|
-
|
|
122
|
+
vault: params.vault.address,
|
|
123
|
+
amount: funding.assets,
|
|
124
|
+
maxSharePrice: params.args.maxSharePrice,
|
|
125
|
+
nativeAmount: funding.value || undefined,
|
|
126
|
+
referralFeePct: common.referralFeePct,
|
|
127
|
+
referralFeeRecipient: common.referralFeeRecipient,
|
|
128
|
+
referralFeeAssets,
|
|
129
|
+
netAssets,
|
|
130
|
+
deadline: common.deadline,
|
|
130
131
|
},
|
|
131
132
|
},
|
|
133
|
+
metadata: params.metadata,
|
|
132
134
|
});
|
|
133
135
|
};
|
|
134
136
|
exports.vaultV2Deposit = vaultV2Deposit;
|
|
@@ -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;
|
|
@@ -1,40 +1,73 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type Metadata, type Transaction, type VaultV2WithdrawAction } from "../../types/index.js";
|
|
2
|
+
import { type Erc2612RequirementSignature, type Metadata, type Transaction, type VaultV2WithdrawAction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link vaultV2Withdraw}. */
|
|
4
4
|
export interface VaultV2WithdrawParams {
|
|
5
|
-
vault: {
|
|
6
|
-
|
|
5
|
+
readonly vault: {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly address: Address;
|
|
7
8
|
};
|
|
8
|
-
args: {
|
|
9
|
-
amount: bigint;
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
readonly args: {
|
|
10
|
+
readonly amount: 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-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
17
23
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
24
|
+
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
25
|
+
* `MorphoVaultV2.withdraw().buildTx()` to validate it against the cap from `getRequirements()`.
|
|
20
26
|
*
|
|
21
|
-
* @param params.vault.
|
|
22
|
-
* @param params.
|
|
23
|
-
* @param params.args.
|
|
24
|
-
* @param params.args.
|
|
25
|
-
* @param params.
|
|
26
|
-
* @
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
28
|
+
* @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
|
|
29
|
+
* @param params.args.amount - Positive gross withdrawal in underlying asset base units, before fees.
|
|
30
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net withdrawn assets.
|
|
31
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
32
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
33
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
34
|
+
* and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
|
|
35
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
36
|
+
* The fee is rounded down and deducted from the gross withdrawn assets.
|
|
37
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
38
|
+
* when `referralFeePct > 0n`.
|
|
39
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
40
|
+
* execution reverts. This pure builder does not check the current time.
|
|
41
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
42
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
43
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
44
|
+
* @returns A deep-frozen `Transaction<VaultV2WithdrawAction>` targeting VaultBundlesV1, with
|
|
45
|
+
* `to`, `value: 0n`, `data`, and gross/fee/net withdrawal action metadata.
|
|
46
|
+
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
47
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
|
|
48
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
49
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
50
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
|
|
51
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
52
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
53
|
+
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
54
|
+
* @throws {viem.BaseError} when transaction encoding fails.
|
|
29
55
|
* @example
|
|
30
56
|
* ```ts
|
|
31
57
|
* import { vaultV2Withdraw } from "@morpho-org/morpho-sdk";
|
|
58
|
+
* import type { Address } from "viem";
|
|
59
|
+
* import { mainnet } from "viem/chains";
|
|
32
60
|
*
|
|
33
|
-
*
|
|
34
|
-
* vault
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
61
|
+
* export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
|
|
62
|
+
* const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
|
|
63
|
+
* // Set the exact vault-share allowance before submitting; the entity API derives that cap.
|
|
64
|
+
* const tx = vaultV2Withdraw({
|
|
65
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
66
|
+
* args: { amount: 1_000_000n, userAddress, deadline },
|
|
67
|
+
* });
|
|
68
|
+
* // tx satisfies Readonly<Transaction<VaultV2WithdrawAction>>
|
|
69
|
+
* return tx;
|
|
70
|
+
* }
|
|
38
71
|
* ```
|
|
39
72
|
*/
|
|
40
|
-
export declare const vaultV2Withdraw: (
|
|
73
|
+
export declare const vaultV2Withdraw: (params: VaultV2WithdrawParams) => Readonly<Transaction<VaultV2WithdrawAction>>;
|