@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,58 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.vaultV2Withdraw = 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-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
14
|
+
* `MorphoVaultV2.withdraw().buildTx()` to validate it against the cap from `getRequirements()`.
|
|
14
15
|
*
|
|
15
|
-
* @param params.vault.
|
|
16
|
-
* @param params.
|
|
17
|
-
* @param params.args.
|
|
18
|
-
* @param params.args.
|
|
19
|
-
* @param params.
|
|
20
|
-
* @
|
|
21
|
-
*
|
|
22
|
-
*
|
|
16
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
17
|
+
* @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
|
|
18
|
+
* @param params.args.amount - Positive gross withdrawal in underlying asset base units, before fees.
|
|
19
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net withdrawn assets.
|
|
20
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
21
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
22
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
23
|
+
* and the registered VaultBundlesV1 spender. Omit when the exact share allowance is already set.
|
|
24
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
25
|
+
* The fee is rounded down and deducted from the gross withdrawn assets.
|
|
26
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
27
|
+
* when `referralFeePct > 0n`.
|
|
28
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
29
|
+
* execution reverts. This pure builder does not check the current time.
|
|
30
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
31
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
32
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
33
|
+
* @returns A deep-frozen `Transaction<VaultV2WithdrawAction>` targeting VaultBundlesV1, with
|
|
34
|
+
* `to`, `value: 0n`, `data`, and gross/fee/net withdrawal action metadata.
|
|
35
|
+
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
36
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
|
|
37
|
+
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
38
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
39
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
|
|
40
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
41
|
+
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
42
|
+
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
43
|
+
* @throws {viem.BaseError} when transaction encoding fails.
|
|
23
44
|
* @example
|
|
24
45
|
* ```ts
|
|
25
46
|
* import { vaultV2Withdraw } from "@morpho-org/morpho-sdk";
|
|
47
|
+
* import type { Address } from "viem";
|
|
48
|
+
* import { mainnet } from "viem/chains";
|
|
26
49
|
*
|
|
27
|
-
*
|
|
28
|
-
* vault
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
50
|
+
* export function buildUsdcWithdrawal(userAddress: Address, deadline: bigint) {
|
|
51
|
+
* const vault = "0x04422053aDDbc9bB2759b248B574e3FCA76Bc145";
|
|
52
|
+
* // Set the exact vault-share allowance before submitting; the entity API derives that cap.
|
|
53
|
+
* const tx = vaultV2Withdraw({
|
|
54
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
55
|
+
* args: { amount: 1_000_000n, userAddress, deadline },
|
|
56
|
+
* });
|
|
57
|
+
* // tx satisfies Readonly<Transaction<VaultV2WithdrawAction>>
|
|
58
|
+
* return tx;
|
|
59
|
+
* }
|
|
32
60
|
* ```
|
|
33
61
|
*/
|
|
34
|
-
const vaultV2Withdraw = (
|
|
35
|
-
if (amount <= 0n) {
|
|
36
|
-
throw new
|
|
62
|
+
const vaultV2Withdraw = (params) => {
|
|
63
|
+
if (params.args.amount <= 0n) {
|
|
64
|
+
throw new index_js_1.NonPositiveInputError("amount", params.args.amount);
|
|
37
65
|
}
|
|
38
|
-
|
|
39
|
-
|
|
66
|
+
// Validate the ABI bound before encoding to preserve the SDK's typed errors.
|
|
67
|
+
(0, validate_js_1.validateUint256Field)("amount", params.args.amount);
|
|
68
|
+
const common = (0, common_js_1.normalizeBundlesCommonParams)(params.args);
|
|
69
|
+
const spender = (0, morpho_ts_1.getChainAddress)(params.vault.chainId, "bundles.vaultBundlesV1");
|
|
70
|
+
const sharesPermit = (0, common_js_1.getBundlesSharesPermit)({
|
|
71
|
+
vault: params.vault.address,
|
|
72
|
+
deadline: common.deadline,
|
|
73
|
+
owner: params.args.userAddress,
|
|
74
|
+
spender,
|
|
75
|
+
requirementSignature: params.args.requirementSignature,
|
|
76
|
+
});
|
|
77
|
+
const referralFeeAssets = (0, common_js_1.getBundlesReferralFeeAssets)(params.args.amount, common.referralFeePct);
|
|
78
|
+
return (0, common_js_1.finalizeVaultBundlesV1Transaction)({
|
|
79
|
+
chainId: params.vault.chainId,
|
|
80
|
+
value: 0n,
|
|
40
81
|
data: (0, viem_1.encodeFunctionData)({
|
|
41
|
-
abi:
|
|
42
|
-
functionName: "
|
|
43
|
-
args: [
|
|
82
|
+
abi: abis_js_1.vaultBundlesV1Abi,
|
|
83
|
+
functionName: "vaultBundlesV1Withdraw",
|
|
84
|
+
args: [
|
|
85
|
+
params.vault.address,
|
|
86
|
+
params.args.amount,
|
|
87
|
+
0n,
|
|
88
|
+
sharesPermit,
|
|
89
|
+
common.referralFeePct,
|
|
90
|
+
common.referralFeeRecipient,
|
|
91
|
+
common.deadline,
|
|
92
|
+
],
|
|
44
93
|
}),
|
|
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
94
|
action: {
|
|
53
95
|
type: "vaultV2Withdraw",
|
|
54
|
-
args: {
|
|
96
|
+
args: {
|
|
97
|
+
vault: params.vault.address,
|
|
98
|
+
amount: params.args.amount,
|
|
99
|
+
referralFeePct: common.referralFeePct,
|
|
100
|
+
referralFeeRecipient: common.referralFeeRecipient,
|
|
101
|
+
referralFeeAssets,
|
|
102
|
+
netAssets: params.args.amount - referralFeeAssets,
|
|
103
|
+
deadline: common.deadline,
|
|
104
|
+
},
|
|
55
105
|
},
|
|
106
|
+
metadata: params.metadata,
|
|
56
107
|
});
|
|
57
108
|
};
|
|
58
109
|
exports.vaultV2Withdraw = vaultV2Withdraw;
|
|
@@ -655,8 +655,8 @@ export declare namespace BundlerAction {
|
|
|
655
655
|
/**
|
|
656
656
|
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
657
657
|
*
|
|
658
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
659
|
-
*
|
|
658
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
659
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
660
660
|
*
|
|
661
661
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
662
662
|
* @param vault - Vault whose liquidity is reallocated.
|
|
@@ -720,8 +720,8 @@ export declare namespace BundlerAction {
|
|
|
720
720
|
/**
|
|
721
721
|
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
722
722
|
*
|
|
723
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
724
|
-
*
|
|
723
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
724
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
725
725
|
*
|
|
726
726
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
727
727
|
* @param vault - Vault whose idle liquidity is allocated.
|
|
@@ -1128,8 +1128,8 @@ var BundlerAction;
|
|
|
1128
1128
|
/**
|
|
1129
1129
|
* Encodes a Vault V2 Blue Public Allocator market-to-market reallocation.
|
|
1130
1130
|
*
|
|
1131
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
1132
|
-
*
|
|
1131
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
1132
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
1133
1133
|
*
|
|
1134
1134
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1135
1135
|
* @param vault - Vault whose liquidity is reallocated.
|
|
@@ -1239,8 +1239,8 @@ var BundlerAction;
|
|
|
1239
1239
|
/**
|
|
1240
1240
|
* Encodes a Vault V2 Blue Public Allocator allocation from vault idle liquidity.
|
|
1241
1241
|
*
|
|
1242
|
-
* @remarks Bundler3 must already hold the computed penalty assets.
|
|
1243
|
-
*
|
|
1242
|
+
* @remarks Bundler3 must already hold the computed penalty assets. Explicit low-level
|
|
1243
|
+
* composition must add the corresponding GeneralAdapter1 transfer.
|
|
1244
1244
|
*
|
|
1245
1245
|
* @param chainId - Chain whose canonical Blue Public Allocator is called.
|
|
1246
1246
|
* @param vault - Vault whose idle liquidity is allocated.
|
|
@@ -12,7 +12,8 @@ import { type Metadata, type MorphoClientType } from "../types/index.js";
|
|
|
12
12
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
13
13
|
* `morpho` namespace builds.
|
|
14
14
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
15
|
-
*
|
|
15
|
+
* ERC-2612, Permit2 AllowanceTransfer or SignatureTransfer, and Morpho authorization.
|
|
16
|
+
* Defaults to `false` (standalone approvals and authorization calls only).
|
|
16
17
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
17
18
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
18
19
|
* `client.morpho`.
|
|
@@ -55,7 +55,8 @@ function createMorphoNamespace(viemClient, options) {
|
|
|
55
55
|
* @param _options.metadata - Optional analytics metadata applied to every transaction the
|
|
56
56
|
* `morpho` namespace builds.
|
|
57
57
|
* @param _options.supportSignature - Whether the integrator can collect EIP-712 signatures for
|
|
58
|
-
*
|
|
58
|
+
* ERC-2612, Permit2 AllowanceTransfer or SignatureTransfer, and Morpho authorization.
|
|
59
|
+
* Defaults to `false` (standalone approvals and authorization calls only).
|
|
59
60
|
* @param _options.supportDeployless - Whether entity fetchers may use deployless multicall.
|
|
60
61
|
* @returns A viem extension function — `client.extend(morphoViemExtension(...))` adds
|
|
61
62
|
* `client.morpho`.
|