@morpho-org/morpho-sdk 6.0.0-next.4 → 6.1.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 +21 -15
- package/README.md +7 -5
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -1
- package/lib/cjs/actions/bundles/common.d.ts +18 -23
- package/lib/cjs/actions/bundles/common.js +36 -83
- 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/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 +19 -7
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +19 -7
- 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/constants.d.ts +1 -1
- package/lib/cjs/constants.js +4 -1
- package/lib/cjs/entities/blue/blue.d.ts +28 -0
- package/lib/cjs/entities/blue/blue.js +1 -0
- package/lib/cjs/entities/index.d.ts +1 -1
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +38 -22
- package/lib/cjs/entities/vaultV1/vaultV1.js +51 -84
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +68 -35
- package/lib/cjs/entities/vaultV2/vaultV2.js +45 -72
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +8 -1
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -6
- package/lib/cjs/helpers/slippage.d.ts +3 -2
- package/lib/cjs/helpers/slippage.js +3 -2
- package/lib/cjs/helpers/validate.d.ts +40 -0
- package/lib/cjs/helpers/validate.js +40 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +94 -59
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -1
- package/lib/cjs/midnight/constants.d.ts +1 -1
- package/lib/cjs/midnight/constants.js +4 -1
- package/lib/cjs/midnight/entities.d.ts +1 -1
- package/lib/cjs/midnight/errors.d.ts +1 -1
- package/lib/cjs/midnight/errors.js +7 -1
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/midnight/utils.d.ts +11 -1
- package/lib/cjs/midnight/utils.js +13 -1
- package/lib/cjs/types/action.d.ts +35 -0
- package/lib/cjs/types/action.js +10 -0
- package/lib/cjs/types.d.ts +1 -1
- package/lib/cjs/utils.d.ts +11 -1
- package/lib/cjs/utils.js +14 -2
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +18 -23
- package/lib/esm/actions/bundles/common.js +34 -80
- 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/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 +19 -7
- package/lib/esm/actions/vaultV2/forceWithdraw.js +19 -7
- 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/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +28 -0
- package/lib/esm/entities/blue/blue.js +1 -0
- package/lib/esm/entities/index.d.ts +1 -1
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +38 -22
- package/lib/esm/entities/vaultV1/vaultV1.js +53 -86
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +68 -35
- package/lib/esm/entities/vaultV2/vaultV2.js +47 -74
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +10 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -6
- package/lib/esm/helpers/slippage.d.ts +3 -2
- package/lib/esm/helpers/slippage.js +3 -2
- package/lib/esm/helpers/validate.d.ts +40 -0
- package/lib/esm/helpers/validate.js +40 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +94 -59
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +94 -59
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/constants.d.ts +1 -1
- package/lib/esm/midnight/constants.js +1 -1
- package/lib/esm/midnight/entities.d.ts +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -1
- package/lib/esm/midnight/errors.js +1 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/midnight/utils.d.ts +11 -1
- package/lib/esm/midnight/utils.js +11 -1
- package/lib/esm/types/action.d.ts +35 -0
- package/lib/esm/types/action.js +10 -0
- package/lib/esm/types.d.ts +1 -1
- package/lib/esm/utils.d.ts +11 -1
- package/lib/esm/utils.js +11 -1
- package/package.json +5 -5
|
@@ -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,
|
|
@@ -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.
|
|
@@ -66,12 +67,23 @@ export interface VaultV2ForceWithdrawParams {
|
|
|
66
67
|
* @example
|
|
67
68
|
* ```ts
|
|
68
69
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
70
|
+
* import type { Address } from "viem";
|
|
71
|
+
* import { mainnet } from "viem/chains";
|
|
69
72
|
*
|
|
70
|
-
*
|
|
71
|
-
* vault:
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
73
|
+
* export function buildForceWithdraw(
|
|
74
|
+
* vault: Address,
|
|
75
|
+
* adapter: Address,
|
|
76
|
+
* minSharePriceE27: bigint,
|
|
77
|
+
* userAddress: Address,
|
|
78
|
+
* deadline: bigint,
|
|
79
|
+
* ) {
|
|
80
|
+
* const tx = vaultV2ForceWithdraw({
|
|
81
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
82
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
83
|
+
* });
|
|
84
|
+
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
85
|
+
* return tx;
|
|
86
|
+
* }
|
|
75
87
|
* ```
|
|
76
88
|
*/
|
|
77
89
|
export declare const vaultV2ForceWithdraw: ({ vault, args, metadata, }: VaultV2ForceWithdrawParams) => Readonly<Transaction<VaultV2ForceWithdrawAction>>;
|
|
@@ -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.
|
|
@@ -53,12 +54,23 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
53
54
|
* @example
|
|
54
55
|
* ```ts
|
|
55
56
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
57
|
+
* import type { Address } from "viem";
|
|
58
|
+
* import { mainnet } from "viem/chains";
|
|
56
59
|
*
|
|
57
|
-
*
|
|
58
|
-
* vault:
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
60
|
+
* export function buildForceWithdraw(
|
|
61
|
+
* vault: Address,
|
|
62
|
+
* adapter: Address,
|
|
63
|
+
* minSharePriceE27: bigint,
|
|
64
|
+
* userAddress: Address,
|
|
65
|
+
* deadline: bigint,
|
|
66
|
+
* ) {
|
|
67
|
+
* const tx = vaultV2ForceWithdraw({
|
|
68
|
+
* vault: { chainId: mainnet.id, address: vault },
|
|
69
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
70
|
+
* });
|
|
71
|
+
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
72
|
+
* return tx;
|
|
73
|
+
* }
|
|
62
74
|
* ```
|
|
63
75
|
*/
|
|
64
76
|
export const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
|
@@ -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.
|
|
@@ -8,7 +8,7 @@ import { finalizeVaultBundlesV1Transaction, getBundlesReferralFeeAssets, getBund
|
|
|
8
8
|
* Encodes an exact-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
9
9
|
*
|
|
10
10
|
* This low-level builder does not bind `permit.value` to a share cap; use
|
|
11
|
-
* `MorphoVaultV2.withdraw().buildTx()` to validate it against the cap from `
|
|
11
|
+
* `MorphoVaultV2.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 V2 whose shares are burned for the withdrawal.
|
package/lib/esm/constants.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
4
|
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
package/lib/esm/constants.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { DEFAULT_SLIPPAGE_TOLERANCE, EIP_712_FIELDS, ERC20_ALLOWANCE_RECIPIENTS, isMarketId as isBlueMarketId, LIQUIDATION_CURSOR as BLUE_LIQUIDATION_CURSOR, MAX_LIQUIDATION_INCENTIVE_FACTOR as BLUE_MAX_LIQUIDATION_INCENTIVE_FACTOR, ORACLE_PRICE_SCALE, SECONDS_PER_YEAR, TransactionType as BlueTransactionType, } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
2
|
+
export { CBP as MIDNIGHT_CBP, COLLATERAL_PARAMS_TYPEHASH as MIDNIGHT_COLLATERAL_PARAMS_TYPEHASH, DEFAULT_TICK_SPACING as MIDNIGHT_DEFAULT_TICK_SPACING, EIP712_DOMAIN_TYPEHASH as MIDNIGHT_EIP712_DOMAIN_TYPEHASH, MARKET_TYPEHASH as MIDNIGHT_MARKET_TYPEHASH, MAX_COLLATERALS as MIDNIGHT_MAX_COLLATERALS, MAX_COLLATERALS_PER_BORROWER as MIDNIGHT_MAX_COLLATERALS_PER_BORROWER, MAX_CONTINUOUS_FEE as MIDNIGHT_MAX_CONTINUOUS_FEE, MAX_OFFER_CAP as MIDNIGHT_MAX_OFFER_CAP, MAX_SETTLEMENT_FEES as MIDNIGHT_MAX_SETTLEMENT_FEES, MAX_TICK as MIDNIGHT_MAX_TICK, MAX_TREE_HEIGHT as MIDNIGHT_MAX_TREE_HEIGHT, OFFER_TYPEHASH as MIDNIGHT_OFFER_TYPEHASH, PRICE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_PRICE_RATIFIER_V1_OFFER_TYPEHASH, PRICE_ROUNDING_STEP as MIDNIGHT_PRICE_ROUNDING_STEP, RATE_RATIFIER_V1_OFFER_TYPEHASH as MIDNIGHT_RATE_RATIFIER_V1_OFFER_TYPEHASH, SETTLEMENT_FEE_BREAKPOINTS as MIDNIGHT_SETTLEMENT_FEE_BREAKPOINTS, TIME_TO_MAX_LIF as MIDNIGHT_TIME_TO_MAX_LIF, } from "@morpho-org/midnight-sdk";
|
|
3
3
|
export { BLUE_API_BASE_URL, BLUE_API_GRAPHQL_URL, ChainId, ChainUtils, DOCS_BASE_URL, MORPHO_DOMAIN, REWARDS_BASE_URL, ZERO_ADDRESS, } from "@morpho-org/morpho-ts";
|
|
4
4
|
export { APPROVE_ONLY_ONCE_TOKENS, DEFAULT_LLTV_BUFFER, DEFAULT_MAX_REALLOCATION_PENALTY, DEFAULT_SUPPLY_TARGET_UTILIZATION, DEFAULT_WITHDRAWAL_TARGET_UTILIZATION, MAX_ABSOLUTE_SHARE_PRICE, MAX_REALLOCATION_PENALTY, MAX_SLIPPAGE_TOLERANCE, MAX_TOKEN_APPROVALS, } from "./helpers/constant.js";
|
|
@@ -24,12 +24,26 @@ export interface BlueTokenRequirementsParams {
|
|
|
24
24
|
*/
|
|
25
25
|
readonly approvalAmount?: bigint;
|
|
26
26
|
}
|
|
27
|
+
/** Action surface for Morpho Blue reads and writes; writes route through BlueBundlesV1. */
|
|
27
28
|
export interface BlueActions {
|
|
28
29
|
/**
|
|
29
30
|
* Fetches the latest market data with accrued interest.
|
|
30
31
|
*
|
|
31
32
|
* @param parameters - Optional fetch parameters (block number, state overrides).
|
|
32
33
|
* @returns Market state including total supply/borrow assets and shares.
|
|
34
|
+
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
35
|
+
* @example
|
|
36
|
+
* ```ts
|
|
37
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
38
|
+
* import { createPublicClient, http } from "viem";
|
|
39
|
+
* import { mainnet } from "viem/chains";
|
|
40
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
41
|
+
*
|
|
42
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
43
|
+
* .extend(morphoViemExtension());
|
|
44
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
45
|
+
* const marketData = await market.getMarketData();
|
|
46
|
+
* ```
|
|
33
47
|
*/
|
|
34
48
|
getMarketData: (parameters?: FetchParameters) => Promise<Market>;
|
|
35
49
|
/**
|
|
@@ -38,6 +52,19 @@ export interface BlueActions {
|
|
|
38
52
|
* @param userAddress - The user whose position to fetch.
|
|
39
53
|
* @param parameters - Optional fetch parameters (block number, state overrides).
|
|
40
54
|
* @returns Accrual position with health metrics (maxBorrowAssets, ltv, isHealthy).
|
|
55
|
+
* @throws {ChainIdMismatchError} when the connected client targets another chain or has no chain.
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
59
|
+
* import { createPublicClient, http, zeroAddress } from "viem";
|
|
60
|
+
* import { mainnet } from "viem/chains";
|
|
61
|
+
* import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
62
|
+
*
|
|
63
|
+
* const client = createPublicClient({ chain: mainnet, transport: http() })
|
|
64
|
+
* .extend(morphoViemExtension());
|
|
65
|
+
* const market = client.morpho.blue(markets[mainnet.id].usdc_wbtc, mainnet.id);
|
|
66
|
+
* const position = await market.getPositionData(zeroAddress);
|
|
67
|
+
* ```
|
|
41
68
|
*/
|
|
42
69
|
getPositionData: (userAddress: Address, parameters?: FetchParameters) => Promise<AccrualPosition>;
|
|
43
70
|
/**
|
|
@@ -819,6 +846,7 @@ export interface BlueActions {
|
|
|
819
846
|
readonly data: VaultV2BlueReallocationData;
|
|
820
847
|
};
|
|
821
848
|
}
|
|
849
|
+
/** Binds a viem client to a Morpho Blue market's action builders. */
|
|
822
850
|
export declare class MorphoBlue implements BlueActions {
|
|
823
851
|
private readonly client;
|
|
824
852
|
readonly marketParams: MarketParams;
|
|
@@ -8,6 +8,7 @@ import { DEFAULT_LLTV_BUFFER, validateAccrualPosition, validateChainId, validate
|
|
|
8
8
|
import { ExpiredDeadlineError, InputExceedsMaxError, MaxRepayAssetsBelowRepayAssetsError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeInputError, NonPositiveInputError, ReallocationsRequireBorrowError, RefinanceSameMarketError, RefinanceTokenMismatchError, } from "../../types/index.js";
|
|
9
9
|
import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
10
10
|
import { VaultV2BlueReallocationData } from "../vaultV2BlueReallocationData.js";
|
|
11
|
+
/** Binds a viem client to a Morpho Blue market's action builders. */
|
|
11
12
|
export class MorphoBlue {
|
|
12
13
|
client;
|
|
13
14
|
marketParams;
|
|
@@ -8,7 +8,7 @@ export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, A
|
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
10
|
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
|
-
export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
|
|
11
|
+
export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
|
|
12
12
|
export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
|
|
13
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
14
14
|
export { MorphoBlue } from "./blue/index.js";
|