@morpho-org/morpho-sdk 6.0.0-next.3 → 6.0.0
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 +24 -16
- package/README.md +6 -4
- package/lib/cjs/abis.d.ts +5 -1
- package/lib/cjs/abis.js +2 -0
- package/lib/cjs/actions/bundles/common.d.ts +20 -25
- package/lib/cjs/actions/bundles/common.js +46 -85
- package/lib/cjs/actions/bundles/index.d.ts +1 -1
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +6 -2
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +6 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +11 -3
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +19 -1
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -1
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +12 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +2 -1
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +62 -17
- package/lib/cjs/actions/vaultV1/migrateToV2.js +48 -17
- package/lib/cjs/actions/vaultV1/redeem.d.ts +28 -1
- package/lib/cjs/actions/vaultV1/redeem.js +17 -1
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +3 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -2
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +2 -1
- package/lib/cjs/actions/vaultV2/redeem.d.ts +28 -1
- package/lib/cjs/actions/vaultV2/redeem.js +17 -1
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +1 -1
- package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +10 -2
- package/lib/cjs/blue/entities.js +2 -0
- package/lib/cjs/blue/errors.d.ts +4 -2
- package/lib/cjs/blue/errors.js +3 -1
- package/lib/cjs/blue/fetch.d.ts +5 -1
- package/lib/cjs/blue/fetch.js +2 -0
- package/lib/cjs/blue/utils.d.ts +5 -1
- package/lib/cjs/blue/utils.js +2 -0
- package/lib/cjs/entities/index.d.ts +10 -2
- package/lib/cjs/entities/index.js +2 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +31 -21
- package/lib/cjs/entities/vaultV1/vaultV1.js +50 -83
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +52 -35
- package/lib/cjs/entities/vaultV2/vaultV2.js +71 -81
- package/lib/cjs/errors.d.ts +5 -3
- package/lib/cjs/errors.js +4 -1
- package/lib/cjs/fetch.d.ts +5 -1
- package/lib/cjs/fetch.js +2 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/cjs/midnight/errors.d.ts +1 -1
- package/lib/cjs/midnight/errors.js +2 -1
- package/lib/cjs/types/action.d.ts +1 -0
- package/lib/cjs/utils.d.ts +5 -1
- package/lib/cjs/utils.js +2 -0
- package/lib/esm/abis.d.ts +5 -1
- package/lib/esm/abis.js +5 -1
- package/lib/esm/actions/bundles/common.d.ts +20 -25
- package/lib/esm/actions/bundles/common.js +44 -82
- package/lib/esm/actions/bundles/index.d.ts +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +6 -2
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +6 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +11 -3
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -3
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -1
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +14 -2
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +2 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +2 -1
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +62 -17
- package/lib/esm/actions/vaultV1/migrateToV2.js +48 -17
- package/lib/esm/actions/vaultV1/redeem.d.ts +28 -1
- package/lib/esm/actions/vaultV1/redeem.js +17 -1
- package/lib/esm/actions/vaultV1/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV1/withdraw.js +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +3 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -2
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +2 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +2 -1
- package/lib/esm/actions/vaultV2/redeem.d.ts +28 -1
- package/lib/esm/actions/vaultV2/redeem.js +17 -1
- package/lib/esm/actions/vaultV2/withdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/withdraw.js +1 -1
- package/lib/esm/augment/AccrualPosition.d.ts +1 -0
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +10 -2
- package/lib/esm/blue/entities.js +5 -1
- package/lib/esm/blue/errors.d.ts +4 -2
- package/lib/esm/blue/errors.js +4 -2
- package/lib/esm/blue/fetch.d.ts +5 -1
- package/lib/esm/blue/fetch.js +5 -1
- package/lib/esm/blue/utils.d.ts +5 -1
- package/lib/esm/blue/utils.js +5 -1
- package/lib/esm/entities/index.d.ts +10 -2
- package/lib/esm/entities/index.js +5 -1
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +31 -21
- package/lib/esm/entities/vaultV1/vaultV1.js +52 -85
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +52 -35
- package/lib/esm/entities/vaultV2/vaultV2.js +73 -83
- package/lib/esm/errors.d.ts +5 -3
- package/lib/esm/errors.js +5 -3
- package/lib/esm/fetch.d.ts +5 -1
- package/lib/esm/fetch.js +5 -1
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/esm/midnight/errors.d.ts +1 -1
- package/lib/esm/midnight/errors.js +1 -1
- package/lib/esm/types/action.d.ts +1 -0
- package/lib/esm/utils.d.ts +5 -1
- package/lib/esm/utils.js +5 -1
- package/package.json +6 -9
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Address } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type Client } from "viem";
|
|
3
3
|
import { type AuthorizationRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
4
4
|
/** Parameters for {@link encodeBlueSignatureAuthorization}. */
|
|
5
5
|
interface EncodeBlueSignatureAuthorizationParams {
|
|
6
6
|
/** Account granting the authorization and signing it (the Morpho `authorizer`). */
|
|
7
7
|
owner: Address;
|
|
8
|
-
/** BlueBundlesV1 operator to authorize on Morpho. */
|
|
8
|
+
/** BlueBundlesV1 operator to authorize on Morpho; must be the chain's registered deployment. */
|
|
9
9
|
authorized: Address;
|
|
10
10
|
/** Target chain id; must match `viemClient.chain.id`. */
|
|
11
11
|
chainId: number;
|
|
@@ -25,11 +25,15 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
25
25
|
* `RequirementSignature` the selected transaction route consumes. The requirement's
|
|
26
26
|
* `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
|
|
27
27
|
* Deadline defaults to two hours from `Time.timestamp()`.
|
|
28
|
+
* The operator pin applies to grants and revocations alike: revoking a previously registered
|
|
29
|
+
* operator is outside this helper's scope.
|
|
28
30
|
*
|
|
29
31
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
30
32
|
* @param params - Authorization encoding parameters.
|
|
31
33
|
* @param params.owner - Account granting the authorization and signing it (the Morpho `authorizer`).
|
|
32
|
-
* @param params.authorized - BlueBundlesV1 operator to authorize
|
|
34
|
+
* @param params.authorized - BlueBundlesV1 operator to authorize; must be the chain's
|
|
35
|
+
* registered BlueBundlesV1 deployment, so a misconfigured `authorized` cannot grant an
|
|
36
|
+
* arbitrary address control over the signer's Morpho positions.
|
|
33
37
|
* @param params.chainId - Target chain id.
|
|
34
38
|
* @param params.nonce - The owner's current Morpho authorization nonce.
|
|
35
39
|
* @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
|
|
@@ -37,6 +41,10 @@ interface EncodeBlueSignatureAuthorizationParams {
|
|
|
37
41
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
38
42
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
39
43
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
44
|
+
* @throws {UnsupportedChainIdError} when `params.chainId` is absent from the address registry.
|
|
45
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered on `params.chainId`.
|
|
46
|
+
* @throws {UnsupportedAuthorizationOperatorError} when `params.authorized` is not the chain's
|
|
47
|
+
* registered BlueBundlesV1 deployment.
|
|
40
48
|
* @throws {NonPositiveInputError} when a provided `deadline` is not positive.
|
|
41
49
|
* @throws {InputExceedsMaxError} when a provided `deadline` exceeds `uint256`.
|
|
42
50
|
* @throws {ExpiredDeadlineError} when a provided `deadline` is positive but not in the future.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { getAuthorizationTypedData } from "@morpho-org/blue-sdk-viem";
|
|
2
|
-
import { deepFreeze, Time } from "@morpho-org/morpho-ts";
|
|
2
|
+
import { deepFreeze, getChainAddress, Time } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { isAddressEqual } from "viem";
|
|
3
4
|
import { signAndVerifyTypedData } from "../../../helpers/signAndVerifyTypedData.js";
|
|
4
5
|
import { validateDeadline, validateUserAddress, } from "../../../helpers/validate.js";
|
|
5
|
-
import { ChainIdMismatchError, ExpiredDeadlineError, } from "../../../types/index.js";
|
|
6
|
+
import { ChainIdMismatchError, ExpiredDeadlineError, UnsupportedAuthorizationOperatorError, } from "../../../types/index.js";
|
|
6
7
|
/**
|
|
7
8
|
* Builds a Morpho authorization `Requirement` that, once signed, lets BlueBundlesV1 operate on
|
|
8
9
|
* Morpho on the signer's behalf.
|
|
@@ -12,11 +13,15 @@ import { ChainIdMismatchError, ExpiredDeadlineError, } from "../../../types/inde
|
|
|
12
13
|
* `RequirementSignature` the selected transaction route consumes. The requirement's
|
|
13
14
|
* `action.typedData` holds that EIP-712 payload so it can be inspected or displayed before signing.
|
|
14
15
|
* Deadline defaults to two hours from `Time.timestamp()`.
|
|
16
|
+
* The operator pin applies to grants and revocations alike: revoking a previously registered
|
|
17
|
+
* operator is outside this helper's scope.
|
|
15
18
|
*
|
|
16
19
|
* @param viemClient - Connected viem `Client` whose `chain.id` matches `params.chainId`.
|
|
17
20
|
* @param params - Authorization encoding parameters.
|
|
18
21
|
* @param params.owner - Account granting the authorization and signing it (the Morpho `authorizer`).
|
|
19
|
-
* @param params.authorized - BlueBundlesV1 operator to authorize
|
|
22
|
+
* @param params.authorized - BlueBundlesV1 operator to authorize; must be the chain's
|
|
23
|
+
* registered BlueBundlesV1 deployment, so a misconfigured `authorized` cannot grant an
|
|
24
|
+
* arbitrary address control over the signer's Morpho positions.
|
|
20
25
|
* @param params.chainId - Target chain id.
|
|
21
26
|
* @param params.nonce - The owner's current Morpho authorization nonce.
|
|
22
27
|
* @param params.isAuthorized - Grant (`true`, default) or revoke (`false`).
|
|
@@ -24,6 +29,10 @@ import { ChainIdMismatchError, ExpiredDeadlineError, } from "../../../types/inde
|
|
|
24
29
|
* @returns A `Requirement` whose `action.typedData` is the EIP-712 payload and whose
|
|
25
30
|
* `sign(client, userAddress)` produces the deep-frozen signature.
|
|
26
31
|
* @throws {ChainIdMismatchError} when `viemClient.chain?.id !== params.chainId`.
|
|
32
|
+
* @throws {UnsupportedChainIdError} when `params.chainId` is absent from the address registry.
|
|
33
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered on `params.chainId`.
|
|
34
|
+
* @throws {UnsupportedAuthorizationOperatorError} when `params.authorized` is not the chain's
|
|
35
|
+
* registered BlueBundlesV1 deployment.
|
|
27
36
|
* @throws {NonPositiveInputError} when a provided `deadline` is not positive.
|
|
28
37
|
* @throws {InputExceedsMaxError} when a provided `deadline` exceeds `uint256`.
|
|
29
38
|
* @throws {ExpiredDeadlineError} when a provided `deadline` is positive but not in the future.
|
|
@@ -52,6 +61,15 @@ export const encodeBlueSignatureAuthorization = async (viemClient, params) => {
|
|
|
52
61
|
if (viemClient.chain?.id !== chainId) {
|
|
53
62
|
throw new ChainIdMismatchError(viemClient.chain?.id, chainId);
|
|
54
63
|
}
|
|
64
|
+
// Pin the authorized operator to the chain's registered BlueBundlesV1 so a direct caller
|
|
65
|
+
// cannot sign an authorization granting an arbitrary address control over the signer's Morpho
|
|
66
|
+
// positions. Mirrors the `getBlueAuthorizationRequirement` resolver guard and applies to grant
|
|
67
|
+
// and revoke payloads alike: the registry is pinned per release, so revoking a rotated-out
|
|
68
|
+
// operator is outside this helper's scope.
|
|
69
|
+
const blueBundlesV1 = getChainAddress(chainId, "bundles.blueBundlesV1");
|
|
70
|
+
if (!isAddressEqual(blueBundlesV1, authorized)) {
|
|
71
|
+
throw new UnsupportedAuthorizationOperatorError(authorized, chainId);
|
|
72
|
+
}
|
|
55
73
|
// Reject an invalid or already-expired caller-supplied deadline before signing, so a direct caller
|
|
56
74
|
// is never walked through a wallet EIP-712 prompt for an authorization Morpho would reject with
|
|
57
75
|
// `SIGNATURE_EXPIRED`. Mirrors the sibling `encodeErc20Permit2SignatureTransfer` and the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Address, Token } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type PermitRequirementSignature, type Requirement } from "../../../types/index.js";
|
|
3
3
|
/** Parameters for {@link encodeVaultSharesPermit}. */
|
|
4
4
|
export interface EncodeVaultSharesPermitParams {
|
|
5
5
|
/** Vault share token, including V1 permit-domain metadata when available. */
|
|
@@ -38,6 +38,9 @@ export interface EncodeVaultSharesPermitParams {
|
|
|
38
38
|
* can be embedded in fixed vault-bundles calldata.
|
|
39
39
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
40
40
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
|
|
41
|
+
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
42
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds uint256.
|
|
43
|
+
* @throws {ExpiredDeadlineError} when `deadline` is not in the future.
|
|
41
44
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
|
|
42
45
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
43
46
|
* wallet account differs from `userAddress`.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Eip5267Domain, Token } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { getPermitTypedData } from "@morpho-org/blue-sdk-viem";
|
|
3
|
-
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
3
|
+
import { deepFreeze, Time } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { zeroHash } from "viem";
|
|
5
5
|
import { signAndVerifyTypedData } from "../../../helpers/signAndVerifyTypedData.js";
|
|
6
|
-
import { validateUserAddress } from "../../../helpers/validate.js";
|
|
6
|
+
import { validateDeadline, validateUserAddress, } from "../../../helpers/validate.js";
|
|
7
7
|
import { validateRequirementSpender } from "../../../helpers/validateRequirementSpender.js";
|
|
8
|
+
import { ExpiredDeadlineError, } from "../../../types/index.js";
|
|
8
9
|
/**
|
|
9
10
|
* Builds the bounded ERC-2612 shares-permit requirement used by an in-kind vault exit.
|
|
10
11
|
*
|
|
@@ -24,6 +25,9 @@ import { validateRequirementSpender } from "../../../helpers/validateRequirement
|
|
|
24
25
|
* can be embedded in fixed vault-bundles calldata.
|
|
25
26
|
* @throws {UnsupportedChainIdError} when no address registry exists for `chainId`.
|
|
26
27
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not a registered fixed vault-bundles contract.
|
|
28
|
+
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
29
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds uint256.
|
|
30
|
+
* @throws {ExpiredDeadlineError} when `deadline` is not in the future.
|
|
27
31
|
* @throws {MissingClientPropertyError} from `sign()` when the wallet has no account.
|
|
28
32
|
* @throws {AddressMismatchError} from `sign()` when `userAddress` differs from `owner`, or when the
|
|
29
33
|
* wallet account differs from `userAddress`.
|
|
@@ -85,6 +89,14 @@ export const encodeVaultSharesPermit = (params) => {
|
|
|
85
89
|
spender,
|
|
86
90
|
allowed: ["vaultExitBundlesV1", "vaultBundlesV1"],
|
|
87
91
|
});
|
|
92
|
+
const now = Time.timestamp();
|
|
93
|
+
// Validate the explicit deadline: this exported encoder can be called independently of the
|
|
94
|
+
// guarded resolvers, and an out-of-range or already-expired deadline otherwise surfaces only as
|
|
95
|
+
// a downstream wallet typed-data error or an on-chain revert.
|
|
96
|
+
validateDeadline(deadline);
|
|
97
|
+
if (deadline <= now) {
|
|
98
|
+
throw new ExpiredDeadlineError(deadline, now);
|
|
99
|
+
}
|
|
88
100
|
const permitTypedData = getPermitTypedData({
|
|
89
101
|
owner,
|
|
90
102
|
spender,
|
|
@@ -41,7 +41,8 @@ export interface VaultV1InKindRedeemParams {
|
|
|
41
41
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
42
42
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
43
43
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
44
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
44
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
45
|
+
* action nonce disagree.
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -30,7 +30,8 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
30
30
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
31
31
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
32
32
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
33
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
33
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
34
|
+
* action nonce disagree.
|
|
34
35
|
* @example
|
|
35
36
|
* ```ts
|
|
36
37
|
* import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -3,28 +3,65 @@ import { type Erc2612RequirementSignature, type Metadata, type Transaction, type
|
|
|
3
3
|
/** Parameters for {@link vaultV1MigrateToV2}. */
|
|
4
4
|
export interface VaultV1MigrateToV2Params {
|
|
5
5
|
readonly vault: {
|
|
6
|
+
/** Chain containing the vaults and their registered VaultBundlesV1 contract. */
|
|
6
7
|
readonly chainId: number;
|
|
8
|
+
/** Source Vault V1 address whose shares are burned. */
|
|
7
9
|
readonly address: Address;
|
|
10
|
+
/** Source vault's underlying ERC-20 asset; must equal `args.targetAsset`. */
|
|
8
11
|
readonly asset: Address;
|
|
9
12
|
};
|
|
10
13
|
readonly args: VaultV1MigrateToV2AmountArgs & {
|
|
14
|
+
/** Destination Vault V2 contract receiving the net migrated assets. */
|
|
11
15
|
readonly targetVault: Address;
|
|
16
|
+
/** Destination vault's underlying ERC-20 asset; must equal `vault.asset`. */
|
|
12
17
|
readonly targetAsset: Address;
|
|
18
|
+
/** Maximum accepted destination share price, scaled by RAY (1e27). */
|
|
13
19
|
readonly maxSharePriceVaultV2: bigint;
|
|
20
|
+
/** Share owner and transaction sender; VaultBundlesV1 mints shares to this account. */
|
|
14
21
|
readonly userAddress: Address;
|
|
22
|
+
/** Unsupported; shares are always minted to the transaction sender. */
|
|
15
23
|
readonly recipient?: never;
|
|
24
|
+
/** Unsupported; the source Vault V1 withdrawal carries no share-price bound. */
|
|
16
25
|
readonly minSharePriceVaultV1?: never;
|
|
26
|
+
/** Optional ERC-2612 vault-share permit for the migrated source shares. */
|
|
17
27
|
readonly requirementSignature?: Erc2612RequirementSignature;
|
|
28
|
+
/** Optional WAD-scaled fee in [0, 1e18), defaulting to zero. */
|
|
18
29
|
readonly referralFeePct?: bigint;
|
|
30
|
+
/** Optional fee recipient; a nonzero address is required when `referralFeePct > 0n`. */
|
|
19
31
|
readonly referralFeeRecipient?: Address;
|
|
32
|
+
/** Positive uint256 Unix timestamp in seconds after which execution reverts. */
|
|
20
33
|
readonly deadline: bigint;
|
|
21
34
|
};
|
|
35
|
+
/** Optional analytics metadata appended to the transaction calldata. */
|
|
22
36
|
readonly metadata?: Metadata;
|
|
23
37
|
}
|
|
24
38
|
/**
|
|
25
39
|
* Encodes an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1.
|
|
26
40
|
*
|
|
27
|
-
* @param params -
|
|
41
|
+
* @param params.vault.chainId - Chain containing the vaults and their registered VaultBundlesV1 contract.
|
|
42
|
+
* @param params.vault.address - Source Vault V1 address whose shares are burned.
|
|
43
|
+
* @param params.vault.asset - Source vault's underlying ERC-20 asset; must equal `args.targetAsset`.
|
|
44
|
+
* @param params.args.assets - Gross migrated amount in asset base units, exclusive with `shares`.
|
|
45
|
+
* @param params.args.shares - Source vault shares to burn for the migration, exclusive with `assets`.
|
|
46
|
+
* @param params.args.targetVault - Destination Vault V2 contract receiving the net migrated assets.
|
|
47
|
+
* @param params.args.targetAsset - Destination vault's underlying ERC-20 asset; must equal `vault.asset`.
|
|
48
|
+
* @param params.args.maxSharePriceVaultV2 - Positive maximum asset base units per share base unit
|
|
49
|
+
* on the destination Vault V2 deposit, scaled by RAY (1e27).
|
|
50
|
+
* @param params.args.userAddress - Share owner and transaction sender; VaultBundlesV1 mints shares to this account.
|
|
51
|
+
* @param params.args.recipient - Unsupported; shares are always minted to the transaction sender.
|
|
52
|
+
* @param params.args.minSharePriceVaultV1 - Unsupported; the source Vault V1 withdrawal carries no
|
|
53
|
+
* share-price bound.
|
|
54
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
55
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
56
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
57
|
+
* The fee is rounded down and deducted from gross assets before depositing.
|
|
58
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
59
|
+
* when `referralFeePct > 0n`.
|
|
60
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
61
|
+
* execution reverts. This pure builder does not check the current time.
|
|
62
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
63
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
64
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
28
65
|
* @returns A deep-frozen VaultBundlesV1 migration transaction.
|
|
29
66
|
* @throws {VaultAssetMismatchError} when source and destination assets differ.
|
|
30
67
|
* @throws {SameVaultMigrationError} when source and destination vaults are identical.
|
|
@@ -39,24 +76,32 @@ export interface VaultV1MigrateToV2Params {
|
|
|
39
76
|
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
40
77
|
* @example
|
|
41
78
|
* ```ts
|
|
79
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
42
80
|
* import { vaultV1MigrateToV2 } from "@morpho-org/morpho-sdk";
|
|
81
|
+
* import type { Address } from "viem";
|
|
82
|
+
* import { mainnet } from "viem/chains";
|
|
43
83
|
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
84
|
+
* export function buildSteakUsdcMigration(
|
|
85
|
+
* targetVault: Address,
|
|
86
|
+
* userAddress: Address,
|
|
87
|
+
* maxSharePriceVaultV2: bigint,
|
|
88
|
+
* deadline: bigint,
|
|
89
|
+
* ) {
|
|
90
|
+
* const vault = vaults[mainnet.id].steakUsdc;
|
|
91
|
+
* const tx = vaultV1MigrateToV2({
|
|
92
|
+
* vault: { chainId: mainnet.id, address: vault.address, asset: vault.asset },
|
|
93
|
+
* args: {
|
|
94
|
+
* shares: 1_000_000n,
|
|
95
|
+
* targetVault,
|
|
96
|
+
* targetAsset: vault.asset,
|
|
97
|
+
* maxSharePriceVaultV2,
|
|
98
|
+
* userAddress,
|
|
99
|
+
* deadline,
|
|
100
|
+
* },
|
|
101
|
+
* });
|
|
102
|
+
* // tx satisfies Readonly<Transaction<VaultV1MigrateToV2Action>>
|
|
103
|
+
* return tx;
|
|
104
|
+
* }
|
|
60
105
|
* ```
|
|
61
106
|
*/
|
|
62
107
|
export declare const vaultV1MigrateToV2: (params: VaultV1MigrateToV2Params) => Readonly<Transaction<VaultV1MigrateToV2Action>>;
|
|
@@ -7,7 +7,30 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBund
|
|
|
7
7
|
/**
|
|
8
8
|
* Encodes an assets-or-shares Vault V1 to Vault V2 migration through VaultBundlesV1.
|
|
9
9
|
*
|
|
10
|
-
* @param params -
|
|
10
|
+
* @param params.vault.chainId - Chain containing the vaults and their registered VaultBundlesV1 contract.
|
|
11
|
+
* @param params.vault.address - Source Vault V1 address whose shares are burned.
|
|
12
|
+
* @param params.vault.asset - Source vault's underlying ERC-20 asset; must equal `args.targetAsset`.
|
|
13
|
+
* @param params.args.assets - Gross migrated amount in asset base units, exclusive with `shares`.
|
|
14
|
+
* @param params.args.shares - Source vault shares to burn for the migration, exclusive with `assets`.
|
|
15
|
+
* @param params.args.targetVault - Destination Vault V2 contract receiving the net migrated assets.
|
|
16
|
+
* @param params.args.targetAsset - Destination vault's underlying ERC-20 asset; must equal `vault.asset`.
|
|
17
|
+
* @param params.args.maxSharePriceVaultV2 - Positive maximum asset base units per share base unit
|
|
18
|
+
* on the destination Vault V2 deposit, scaled by RAY (1e27).
|
|
19
|
+
* @param params.args.userAddress - Share owner and transaction sender; VaultBundlesV1 mints shares to this account.
|
|
20
|
+
* @param params.args.recipient - Unsupported; shares are always minted to the transaction sender.
|
|
21
|
+
* @param params.args.minSharePriceVaultV1 - Unsupported; the source Vault V1 withdrawal carries no
|
|
22
|
+
* share-price bound.
|
|
23
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
24
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
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 - Required positive uint256 Unix timestamp in seconds after which
|
|
30
|
+
* execution reverts. This pure builder does not check the current time.
|
|
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.
|
|
11
34
|
* @returns A deep-frozen VaultBundlesV1 migration transaction.
|
|
12
35
|
* @throws {VaultAssetMismatchError} when source and destination assets differ.
|
|
13
36
|
* @throws {SameVaultMigrationError} when source and destination vaults are identical.
|
|
@@ -22,24 +45,32 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBund
|
|
|
22
45
|
* @throws {BundlesPermitMismatchError} when the optional share permit is incompatible.
|
|
23
46
|
* @example
|
|
24
47
|
* ```ts
|
|
48
|
+
* import { vaults } from "@morpho-org/morpho-test";
|
|
25
49
|
* import { vaultV1MigrateToV2 } from "@morpho-org/morpho-sdk";
|
|
50
|
+
* import type { Address } from "viem";
|
|
51
|
+
* import { mainnet } from "viem/chains";
|
|
26
52
|
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
53
|
+
* export function buildSteakUsdcMigration(
|
|
54
|
+
* targetVault: Address,
|
|
55
|
+
* userAddress: Address,
|
|
56
|
+
* maxSharePriceVaultV2: bigint,
|
|
57
|
+
* deadline: bigint,
|
|
58
|
+
* ) {
|
|
59
|
+
* const vault = vaults[mainnet.id].steakUsdc;
|
|
60
|
+
* const tx = vaultV1MigrateToV2({
|
|
61
|
+
* vault: { chainId: mainnet.id, address: vault.address, asset: vault.asset },
|
|
62
|
+
* args: {
|
|
63
|
+
* shares: 1_000_000n,
|
|
64
|
+
* targetVault,
|
|
65
|
+
* targetAsset: vault.asset,
|
|
66
|
+
* maxSharePriceVaultV2,
|
|
67
|
+
* userAddress,
|
|
68
|
+
* deadline,
|
|
69
|
+
* },
|
|
70
|
+
* });
|
|
71
|
+
* // tx satisfies Readonly<Transaction<VaultV1MigrateToV2Action>>
|
|
72
|
+
* return tx;
|
|
73
|
+
* }
|
|
43
74
|
* ```
|
|
44
75
|
*/
|
|
45
76
|
export const vaultV1MigrateToV2 = (params) => {
|
|
@@ -3,25 +3,52 @@ import { type Erc2612RequirementSignature, type Metadata, type Transaction, type
|
|
|
3
3
|
/** Parameters for {@link vaultV1Redeem}. */
|
|
4
4
|
export interface VaultV1RedeemParams {
|
|
5
5
|
readonly vault: {
|
|
6
|
+
/** Chain containing the vault and its registered VaultBundlesV1 contract. */
|
|
6
7
|
readonly chainId: number;
|
|
8
|
+
/** Vault V1 whose shares are burned for the redemption. */
|
|
7
9
|
readonly address: Address;
|
|
8
10
|
};
|
|
9
11
|
readonly args: {
|
|
12
|
+
/** Vault shares to redeem, in share base units. */
|
|
10
13
|
readonly shares: bigint;
|
|
14
|
+
/** Share owner and transaction sender; receives the net redeemed assets. */
|
|
11
15
|
readonly userAddress: Address;
|
|
16
|
+
/** Unsupported; net assets are always paid to the transaction sender. */
|
|
12
17
|
readonly recipient?: never;
|
|
18
|
+
/** Unsupported; VaultBundlesV1 always burns the transaction sender's shares. */
|
|
13
19
|
readonly onBehalf?: never;
|
|
20
|
+
/** Optional ERC-2612 vault-share permit for the redeemed shares. */
|
|
14
21
|
readonly requirementSignature?: Erc2612RequirementSignature;
|
|
22
|
+
/** Optional WAD-scaled fee in [0, 1e18), defaulting to zero. */
|
|
15
23
|
readonly referralFeePct?: bigint;
|
|
24
|
+
/** Optional fee recipient; a nonzero address is required when `referralFeePct > 0n`. */
|
|
16
25
|
readonly referralFeeRecipient?: Address;
|
|
26
|
+
/** Positive uint256 Unix timestamp in seconds after which execution reverts. */
|
|
17
27
|
readonly deadline: bigint;
|
|
18
28
|
};
|
|
29
|
+
/** Optional analytics metadata appended to the transaction calldata. */
|
|
19
30
|
readonly metadata?: Metadata;
|
|
20
31
|
}
|
|
21
32
|
/**
|
|
22
33
|
* Encodes an exact-shares Vault V1 redemption through VaultBundlesV1.
|
|
23
34
|
*
|
|
24
|
-
* @param params -
|
|
35
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
36
|
+
* @param params.vault.address - Vault V1 whose shares are burned for the redemption.
|
|
37
|
+
* @param params.args.shares - Positive vault shares to redeem, in share base units.
|
|
38
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net redeemed assets.
|
|
39
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
40
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
41
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
42
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
43
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
44
|
+
* The fee is rounded down and deducted from the gross redeemed assets.
|
|
45
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
46
|
+
* when `referralFeePct > 0n`.
|
|
47
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
48
|
+
* execution reverts. This pure builder does not check the current time.
|
|
49
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
50
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
51
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
25
52
|
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
26
53
|
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
27
54
|
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
@@ -7,7 +7,23 @@ import { finalizeVaultBundlesV1Transaction, getBundlesSharesPermit, normalizeBun
|
|
|
7
7
|
/**
|
|
8
8
|
* Encodes an exact-shares Vault V1 redemption through VaultBundlesV1.
|
|
9
9
|
*
|
|
10
|
-
* @param params -
|
|
10
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
11
|
+
* @param params.vault.address - Vault V1 whose shares are burned for the redemption.
|
|
12
|
+
* @param params.args.shares - Positive vault shares to redeem, in share base units.
|
|
13
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net redeemed assets.
|
|
14
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
15
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
16
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
17
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
18
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
19
|
+
* The fee is rounded down and deducted from the gross redeemed assets.
|
|
20
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
21
|
+
* when `referralFeePct > 0n`.
|
|
22
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
23
|
+
* execution reverts. This pure builder does not check the current time.
|
|
24
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
25
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
26
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
11
27
|
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
12
28
|
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
13
29
|
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
@@ -22,7 +22,7 @@ export interface VaultV1WithdrawParams {
|
|
|
22
22
|
* Encodes an exact-assets Vault V1 withdrawal through VaultBundlesV1.
|
|
23
23
|
*
|
|
24
24
|
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
25
|
-
* `MorphoVaultV1.withdraw().buildTx()` to validate it against the cap from `
|
|
25
|
+
* `MorphoVaultV1.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
|
|
26
26
|
*
|
|
27
27
|
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
28
28
|
* @param params.vault.address - Vault V1 whose shares are burned for the withdrawal.
|
|
@@ -8,7 +8,7 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBund
|
|
|
8
8
|
* Encodes an exact-assets Vault V1 withdrawal through VaultBundlesV1.
|
|
9
9
|
*
|
|
10
10
|
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
11
|
-
* `MorphoVaultV1.withdraw().buildTx()` to validate it against the cap from `
|
|
11
|
+
* `MorphoVaultV1.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
|
|
12
12
|
*
|
|
13
13
|
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
14
14
|
* @param params.vault.address - Vault V1 whose shares are burned for the withdrawal.
|
|
@@ -56,8 +56,9 @@ export interface VaultV2ForceWithdrawParams {
|
|
|
56
56
|
* `data`, and the typed action discriminator.
|
|
57
57
|
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
58
58
|
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
59
|
-
* @throws {
|
|
60
|
-
* with `PctExceeded`)
|
|
59
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD (the contract
|
|
60
|
+
* rejects it with `PctExceeded`); it extends {@link InputExceedsMaxError}.
|
|
61
|
+
* @throws {InputExceedsMaxError} when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
61
62
|
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
62
63
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
63
64
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
@@ -43,8 +43,9 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
43
43
|
* `data`, and the typed action discriminator.
|
|
44
44
|
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
45
45
|
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
46
|
-
* @throws {
|
|
47
|
-
* with `PctExceeded`)
|
|
46
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD (the contract
|
|
47
|
+
* rejects it with `PctExceeded`); it extends {@link InputExceedsMaxError}.
|
|
48
|
+
* @throws {InputExceedsMaxError} when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
48
49
|
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
49
50
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
50
51
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
@@ -43,7 +43,8 @@ export interface VaultV2InKindRedeemParams {
|
|
|
43
43
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
44
44
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
45
45
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
46
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
46
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
47
|
+
* action nonce disagree.
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -31,7 +31,8 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
31
31
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
32
32
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
33
33
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
34
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
34
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
35
|
+
* action nonce disagree.
|
|
35
36
|
* @example
|
|
36
37
|
* ```ts
|
|
37
38
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -3,25 +3,52 @@ import { type Erc2612RequirementSignature, type Metadata, type Transaction, type
|
|
|
3
3
|
/** Parameters for {@link vaultV2Redeem}. */
|
|
4
4
|
export interface VaultV2RedeemParams {
|
|
5
5
|
readonly vault: {
|
|
6
|
+
/** Chain containing the vault and its registered VaultBundlesV1 contract. */
|
|
6
7
|
readonly chainId: number;
|
|
8
|
+
/** Vault V2 whose shares are burned for the redemption. */
|
|
7
9
|
readonly address: Address;
|
|
8
10
|
};
|
|
9
11
|
readonly args: {
|
|
12
|
+
/** Vault shares to redeem, in share base units. */
|
|
10
13
|
readonly shares: bigint;
|
|
14
|
+
/** Share owner and transaction sender; receives the net redeemed assets. */
|
|
11
15
|
readonly userAddress: Address;
|
|
16
|
+
/** Unsupported; net assets are always paid to the transaction sender. */
|
|
12
17
|
readonly recipient?: never;
|
|
18
|
+
/** Unsupported; VaultBundlesV1 always burns the transaction sender's shares. */
|
|
13
19
|
readonly onBehalf?: never;
|
|
20
|
+
/** Optional ERC-2612 vault-share permit for the redeemed shares. */
|
|
14
21
|
readonly requirementSignature?: Erc2612RequirementSignature;
|
|
22
|
+
/** Optional WAD-scaled fee in [0, 1e18), defaulting to zero. */
|
|
15
23
|
readonly referralFeePct?: bigint;
|
|
24
|
+
/** Optional fee recipient; a nonzero address is required when `referralFeePct > 0n`. */
|
|
16
25
|
readonly referralFeeRecipient?: Address;
|
|
26
|
+
/** Positive uint256 Unix timestamp in seconds after which execution reverts. */
|
|
17
27
|
readonly deadline: bigint;
|
|
18
28
|
};
|
|
29
|
+
/** Optional analytics metadata appended to the transaction calldata. */
|
|
19
30
|
readonly metadata?: Metadata;
|
|
20
31
|
}
|
|
21
32
|
/**
|
|
22
33
|
* Encodes an exact-shares Vault V2 redemption through VaultBundlesV1.
|
|
23
34
|
*
|
|
24
|
-
* @param params -
|
|
35
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
36
|
+
* @param params.vault.address - Vault V2 whose shares are burned for the redemption.
|
|
37
|
+
* @param params.args.shares - Positive vault shares to redeem, in share base units.
|
|
38
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net redeemed assets.
|
|
39
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
40
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
41
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
42
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
43
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
44
|
+
* The fee is rounded down and deducted from the gross redeemed assets.
|
|
45
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
46
|
+
* when `referralFeePct > 0n`.
|
|
47
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
48
|
+
* execution reverts. This pure builder does not check the current time.
|
|
49
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
50
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
51
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
25
52
|
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
26
53
|
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
27
54
|
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
@@ -7,7 +7,23 @@ import { finalizeVaultBundlesV1Transaction, getBundlesSharesPermit, normalizeBun
|
|
|
7
7
|
/**
|
|
8
8
|
* Encodes an exact-shares Vault V2 redemption through VaultBundlesV1.
|
|
9
9
|
*
|
|
10
|
-
* @param params -
|
|
10
|
+
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
11
|
+
* @param params.vault.address - Vault V2 whose shares are burned for the redemption.
|
|
12
|
+
* @param params.args.shares - Positive vault shares to redeem, in share base units.
|
|
13
|
+
* @param params.args.userAddress - Share owner and transaction sender; receives the net redeemed assets.
|
|
14
|
+
* @param params.args.recipient - Unsupported; net assets are always paid to the transaction sender.
|
|
15
|
+
* @param params.args.onBehalf - Unsupported; VaultBundlesV1 always burns the transaction sender's shares.
|
|
16
|
+
* @param params.args.requirementSignature - Optional ERC-2612 vault-share permit for `userAddress`
|
|
17
|
+
* and the registered VaultBundlesV1 spender. Omit when the share allowance is already set.
|
|
18
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero.
|
|
19
|
+
* The fee is rounded down and deducted from the gross redeemed assets.
|
|
20
|
+
* @param params.args.referralFeeRecipient - Optional fee recipient; a nonzero address is required
|
|
21
|
+
* when `referralFeePct > 0n`.
|
|
22
|
+
* @param params.args.deadline - Required positive uint256 Unix timestamp in seconds after which
|
|
23
|
+
* execution reverts. This pure builder does not check the current time.
|
|
24
|
+
* @param params.metadata - Optional analytics metadata appended to the transaction calldata.
|
|
25
|
+
* @param params.metadata.origin - Hex origin identifier of at most four bytes, with an optional `0x` prefix.
|
|
26
|
+
* @param params.metadata.timestamp - Optional flag to append the current timestamp; defaults to false.
|
|
11
27
|
* @returns A deep-frozen VaultBundlesV1 redemption transaction.
|
|
12
28
|
* @throws {NonPositiveInputError} when `shares` or `deadline` is not positive.
|
|
13
29
|
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256.
|
|
@@ -22,7 +22,7 @@ export interface VaultV2WithdrawParams {
|
|
|
22
22
|
* Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
23
23
|
*
|
|
24
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 `
|
|
25
|
+
* `MorphoVaultV2.withdraw().buildTx()` to validate it against the share cap derived from the handle's `vaultData`.
|
|
26
26
|
*
|
|
27
27
|
* @param params.vault.chainId - Chain containing the vault and its registered VaultBundlesV1 contract.
|
|
28
28
|
* @param params.vault.address - Vault V2 whose shares are burned for the withdrawal.
|