@morpho-org/morpho-sdk 6.0.0-next.1 → 6.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +127 -16
- package/README.md +17 -11
- package/lib/cjs/abis.d.ts +17 -2
- package/lib/cjs/abis.js +14 -1
- package/lib/cjs/actions/blue/common.js +5 -26
- package/lib/cjs/actions/blue/supply.js +2 -7
- package/lib/cjs/actions/bundles/common.d.ts +32 -2
- package/lib/cjs/actions/bundles/common.js +68 -30
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +20 -20
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -27
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +6 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +2 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +58 -39
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +8 -2
- package/lib/cjs/blue/entities.js +1 -0
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/blue/fetch.d.ts +3 -1
- package/lib/cjs/blue/fetch.js +1 -0
- package/lib/cjs/entities/blue/blue.d.ts +15 -6
- package/lib/cjs/entities/blue/blue.js +3 -0
- package/lib/cjs/entities/index.d.ts +8 -2
- package/lib/cjs/entities/index.js +1 -0
- package/lib/cjs/entities/midnight/midnight.js +20 -24
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +19 -14
- package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +1 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +10 -5
- package/lib/cjs/entities/vaultV1/vaultV1.js +13 -1
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +140 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +229 -16
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -2
- package/lib/cjs/fetch.d.ts +3 -1
- package/lib/cjs/fetch.js +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/cjs/helpers/index.d.ts +3 -1
- package/lib/cjs/helpers/index.js +10 -1
- package/lib/cjs/helpers/metadata.d.ts +3 -5
- package/lib/cjs/helpers/metadata.js +4 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/cjs/helpers/slippage.d.ts +46 -0
- package/lib/cjs/helpers/slippage.js +65 -0
- package/lib/cjs/helpers/validate.d.ts +65 -8
- package/lib/cjs/helpers/validate.js +83 -9
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
- package/lib/cjs/types/action.d.ts +95 -13
- package/lib/cjs/types/error.d.ts +290 -12
- package/lib/cjs/types/error.js +312 -24
- package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +10 -1
- package/lib/esm/abis.d.ts +17 -2
- package/lib/esm/abis.js +17 -2
- package/lib/esm/actions/blue/common.js +7 -28
- package/lib/esm/actions/blue/supply.js +4 -9
- package/lib/esm/actions/bundles/common.d.ts +32 -2
- package/lib/esm/actions/bundles/common.js +68 -31
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -28
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +14 -9
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +9 -6
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +22 -17
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +6 -0
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +2 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +58 -39
- package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +8 -2
- package/lib/esm/blue/entities.js +3 -1
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/blue/fetch.d.ts +3 -1
- package/lib/esm/blue/fetch.js +3 -1
- package/lib/esm/entities/blue/blue.d.ts +15 -6
- package/lib/esm/entities/blue/blue.js +3 -0
- package/lib/esm/entities/index.d.ts +8 -2
- package/lib/esm/entities/index.js +3 -1
- package/lib/esm/entities/midnight/midnight.js +20 -24
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +7 -6
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +20 -15
- package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +3 -3
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +10 -5
- package/lib/esm/entities/vaultV1/vaultV1.js +14 -2
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +140 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +234 -21
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/fetch.d.ts +3 -1
- package/lib/esm/fetch.js +3 -1
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/esm/helpers/index.d.ts +3 -1
- package/lib/esm/helpers/index.js +3 -1
- package/lib/esm/helpers/metadata.d.ts +3 -5
- package/lib/esm/helpers/metadata.js +4 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/esm/helpers/slippage.d.ts +46 -0
- package/lib/esm/helpers/slippage.js +65 -1
- package/lib/esm/helpers/validate.d.ts +65 -8
- package/lib/esm/helpers/validate.js +82 -10
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
- package/lib/esm/types/action.d.ts +95 -13
- package/lib/esm/types/error.d.ts +290 -12
- package/lib/esm/types/error.js +301 -19
- package/lib/esm/types/sharedLiquidity.d.ts +2 -2
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +3 -1
- package/package.json +7 -7
- /package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
- /package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.d.ts +0 -0
|
@@ -1,58 +1,77 @@
|
|
|
1
1
|
import { type Address } from "viem";
|
|
2
|
-
import { type
|
|
2
|
+
import { type Metadata, type PermitRequirementSignature, type Transaction, type VaultV2ForceWithdrawAction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link vaultV2ForceWithdraw}. */
|
|
4
4
|
export interface VaultV2ForceWithdrawParams {
|
|
5
|
-
vault: {
|
|
6
|
-
|
|
5
|
+
readonly vault: {
|
|
6
|
+
readonly chainId: number;
|
|
7
|
+
readonly address: Address;
|
|
7
8
|
};
|
|
8
|
-
args: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
readonly args: {
|
|
10
|
+
readonly adapter: Address;
|
|
11
|
+
readonly exitAssets: bigint;
|
|
12
|
+
readonly minSharePriceE27: bigint;
|
|
13
|
+
readonly userAddress: Address;
|
|
14
|
+
readonly deadline: bigint;
|
|
15
|
+
readonly referralFeePct?: bigint;
|
|
16
|
+
readonly referralFeeRecipient?: Address;
|
|
17
|
+
readonly requirementSignature?: PermitRequirementSignature;
|
|
15
18
|
};
|
|
16
|
-
metadata?: Metadata;
|
|
19
|
+
readonly metadata?: Metadata;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
|
-
* Prepares a
|
|
22
|
+
* Prepares a Vault V2 force withdrawal through VaultExitBundlesV1.
|
|
20
23
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
+
* The contract first withdraws everything the vault can pay without a penalty — its idle assets
|
|
25
|
+
* plus the liquidity available through its liquidity adapter — then force-deallocates the remainder
|
|
26
|
+
* by looping over the adapter's markets.
|
|
24
27
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
+
* `exitAssets` is **penalty-inclusive**: it is what the contract debits from the user's position,
|
|
29
|
+
* while the assets actually delivered are
|
|
30
|
+
* `assetsToWithdraw + floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty))` minus the
|
|
31
|
+
* referral fee. Use `previewVaultV2ForceWithdraw` to quote the split.
|
|
28
32
|
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @param params
|
|
33
|
-
*
|
|
34
|
-
* @param params.
|
|
35
|
-
* @param params.args.
|
|
36
|
-
*
|
|
37
|
-
* @param params.
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
41
|
-
*
|
|
42
|
-
*
|
|
33
|
+
* Without a signature this embeds the empty-permit sentinel and requires a sufficient vault-share
|
|
34
|
+
* approval to VaultExitBundlesV1.
|
|
35
|
+
*
|
|
36
|
+
* @param params - Force withdrawal parameters.
|
|
37
|
+
* @param params.vault.chainId - Chain containing the target Vault V2 and VaultExitBundlesV1.
|
|
38
|
+
* @param params.vault.address - Target Vault V2 address.
|
|
39
|
+
* @param params.args.adapter - Vault's sole MorphoMarketV1AdapterV2.
|
|
40
|
+
* @param params.args.exitAssets - Penalty-inclusive, asset-denominated amount to exit.
|
|
41
|
+
* @param params.args.minSharePriceE27 - RAY-scaled lower bound on the realized exit share price
|
|
42
|
+
* (withdrawn assets per share burned). `0n` disables the on-chain bound; prefer the value the
|
|
43
|
+
* entity computes.
|
|
44
|
+
* @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
|
|
45
|
+
* VaultExitBundlesV1 burns `msg.sender`'s vault shares and pays out to `msg.sender`, so the
|
|
46
|
+
* submitting account must equal this address.
|
|
47
|
+
* @param params.args.deadline - Permit and bundle deadline.
|
|
48
|
+
* @param params.args.referralFeePct - Optional WAD-scaled share of the withdrawn assets routed to
|
|
49
|
+
* `referralFeeRecipient`. Defaults to `0n`. Deducted *after* the `minSharePriceE27` check, so it
|
|
50
|
+
* is outside that bound's protection.
|
|
51
|
+
* @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
|
|
52
|
+
* address, which is only valid alongside a zero `referralFeePct`.
|
|
53
|
+
* @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
|
|
54
|
+
* @param params.metadata - Optional analytics metadata.
|
|
55
|
+
* @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
|
|
56
|
+
* `data`, and the typed action discriminator.
|
|
57
|
+
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
58
|
+
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
59
|
+
* @throws {InputExceedsMaxError} when `referralFeePct` is not below WAD (the contract rejects it
|
|
60
|
+
* with `PctExceeded`), or when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
61
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
62
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
63
|
+
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
64
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind,
|
|
65
|
+
* asset, owner, spender, or signature encoding.
|
|
43
66
|
* @example
|
|
44
67
|
* ```ts
|
|
45
68
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
46
69
|
*
|
|
47
70
|
* const tx = vaultV2ForceWithdraw({
|
|
48
|
-
* vault: { address:
|
|
49
|
-
* args: {
|
|
50
|
-
* deallocations: [{ adapter, marketParams, amount: 500_000n }],
|
|
51
|
-
* withdraw: { amount: 500_000n, recipient },
|
|
52
|
-
* onBehalf,
|
|
53
|
-
* },
|
|
71
|
+
* vault: { chainId: 1, address: vault },
|
|
72
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
54
73
|
* });
|
|
55
74
|
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
56
75
|
* ```
|
|
57
76
|
*/
|
|
58
|
-
export declare const vaultV2ForceWithdraw: ({ vault
|
|
77
|
+
export declare const vaultV2ForceWithdraw: ({ vault, args, metadata, }: VaultV2ForceWithdrawParams) => Readonly<Transaction<VaultV2ForceWithdrawAction>>;
|
|
@@ -1,90 +1,117 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { deepFreeze } from "@morpho-org/morpho-ts";
|
|
1
|
+
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
2
|
import { encodeFunctionData } from "viem";
|
|
4
|
-
import {
|
|
3
|
+
import { vaultExitBundlesV1Abi } from "../../abis.js";
|
|
5
4
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
6
|
-
import {
|
|
5
|
+
import { validateDeadline, validateReferralFee, validateUint256Field, } from "../../helpers/validate.js";
|
|
6
|
+
import { NonPositiveInputError, } from "../../types/index.js";
|
|
7
|
+
import { getVaultExitBundlesV1PermitStruct } from "../signatures/getVaultExitBundlesV1PermitStruct.js";
|
|
7
8
|
/**
|
|
8
|
-
* Prepares a
|
|
9
|
+
* Prepares a Vault V2 force withdrawal through VaultExitBundlesV1.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
11
|
+
* The contract first withdraws everything the vault can pay without a penalty — its idle assets
|
|
12
|
+
* plus the liquidity available through its liquidity adapter — then force-deallocates the remainder
|
|
13
|
+
* by looping over the adapter's markets.
|
|
13
14
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
15
|
+
* `exitAssets` is **penalty-inclusive**: it is what the contract debits from the user's position,
|
|
16
|
+
* while the assets actually delivered are
|
|
17
|
+
* `assetsToWithdraw + floor((exitAssets - assetsToWithdraw) * WAD / (WAD + penalty))` minus the
|
|
18
|
+
* referral fee. Use `previewVaultV2ForceWithdraw` to quote the split.
|
|
17
19
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param params
|
|
22
|
-
*
|
|
23
|
-
* @param params.
|
|
24
|
-
* @param params.args.
|
|
25
|
-
*
|
|
26
|
-
* @param params.
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* @
|
|
30
|
-
*
|
|
31
|
-
*
|
|
20
|
+
* Without a signature this embeds the empty-permit sentinel and requires a sufficient vault-share
|
|
21
|
+
* approval to VaultExitBundlesV1.
|
|
22
|
+
*
|
|
23
|
+
* @param params - Force withdrawal parameters.
|
|
24
|
+
* @param params.vault.chainId - Chain containing the target Vault V2 and VaultExitBundlesV1.
|
|
25
|
+
* @param params.vault.address - Target Vault V2 address.
|
|
26
|
+
* @param params.args.adapter - Vault's sole MorphoMarketV1AdapterV2.
|
|
27
|
+
* @param params.args.exitAssets - Penalty-inclusive, asset-denominated amount to exit.
|
|
28
|
+
* @param params.args.minSharePriceE27 - RAY-scaled lower bound on the realized exit share price
|
|
29
|
+
* (withdrawn assets per share burned). `0n` disables the on-chain bound; prefer the value the
|
|
30
|
+
* entity computes.
|
|
31
|
+
* @param params.args.userAddress - Expected transaction sender, recorded in action metadata only.
|
|
32
|
+
* VaultExitBundlesV1 burns `msg.sender`'s vault shares and pays out to `msg.sender`, so the
|
|
33
|
+
* submitting account must equal this address.
|
|
34
|
+
* @param params.args.deadline - Permit and bundle deadline.
|
|
35
|
+
* @param params.args.referralFeePct - Optional WAD-scaled share of the withdrawn assets routed to
|
|
36
|
+
* `referralFeeRecipient`. Defaults to `0n`. Deducted *after* the `minSharePriceE27` check, so it
|
|
37
|
+
* is outside that bound's protection.
|
|
38
|
+
* @param params.args.referralFeeRecipient - Optional referral fee recipient. Defaults to the zero
|
|
39
|
+
* address, which is only valid alongside a zero `referralFeePct`.
|
|
40
|
+
* @param params.args.requirementSignature - Optional bounded Vault V2 shares permit.
|
|
41
|
+
* @param params.metadata - Optional analytics metadata.
|
|
42
|
+
* @returns A deep-frozen `Readonly<Transaction<VaultV2ForceWithdrawAction>>` with `to`, `value`,
|
|
43
|
+
* `data`, and the typed action discriminator.
|
|
44
|
+
* @throws {NonPositiveInputError} when `exitAssets` or `deadline` is not positive.
|
|
45
|
+
* @throws {NegativeInputError} when `referralFeePct` or `minSharePriceE27` is negative.
|
|
46
|
+
* @throws {InputExceedsMaxError} when `referralFeePct` is not below WAD (the contract rejects it
|
|
47
|
+
* with `PctExceeded`), or when `exitAssets`, `deadline`, or `minSharePriceE27` exceeds `uint256`.
|
|
48
|
+
* @throws {ReferralFeeRecipientMissingError} when a positive `referralFeePct` has no recipient.
|
|
49
|
+
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
50
|
+
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
51
|
+
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind,
|
|
52
|
+
* asset, owner, spender, or signature encoding.
|
|
32
53
|
* @example
|
|
33
54
|
* ```ts
|
|
34
55
|
* import { vaultV2ForceWithdraw } from "@morpho-org/morpho-sdk";
|
|
35
56
|
*
|
|
36
57
|
* const tx = vaultV2ForceWithdraw({
|
|
37
|
-
* vault: { address:
|
|
38
|
-
* args: {
|
|
39
|
-
* deallocations: [{ adapter, marketParams, amount: 500_000n }],
|
|
40
|
-
* withdraw: { amount: 500_000n, recipient },
|
|
41
|
-
* onBehalf,
|
|
42
|
-
* },
|
|
58
|
+
* vault: { chainId: 1, address: vault },
|
|
59
|
+
* args: { adapter, exitAssets: 1_000_000n, minSharePriceE27, userAddress, deadline },
|
|
43
60
|
* });
|
|
44
61
|
* // tx satisfies Readonly<Transaction<VaultV2ForceWithdrawAction>>
|
|
45
62
|
* ```
|
|
46
63
|
*/
|
|
47
|
-
export const vaultV2ForceWithdraw = ({ vault
|
|
48
|
-
if (
|
|
49
|
-
throw new
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
+
export const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
|
65
|
+
if (args.exitAssets <= 0n)
|
|
66
|
+
throw new NonPositiveInputError("exitAssets", args.exitAssets);
|
|
67
|
+
validateUint256Field("exitAssets", args.exitAssets);
|
|
68
|
+
validateDeadline(args.deadline);
|
|
69
|
+
// `0n` stays valid — it is the intentional "no on-chain bound" opt-out — but a value the uint256
|
|
70
|
+
// slot cannot hold must fail with a dedicated error instead of viem's `IntegerOutOfRangeError`.
|
|
71
|
+
// The entity never emits these (it forbids a non-positive override); this guards direct callers.
|
|
72
|
+
validateUint256Field("minSharePriceE27", args.minSharePriceE27);
|
|
73
|
+
const { referralFeePct, referralFeeRecipient } = validateReferralFee(args);
|
|
74
|
+
const to = getChainAddress(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
75
|
+
const sharesPermit = getVaultExitBundlesV1PermitStruct({
|
|
76
|
+
vault: vault.address,
|
|
77
|
+
deadline: args.deadline,
|
|
78
|
+
owner: args.userAddress,
|
|
79
|
+
spender: to,
|
|
80
|
+
requirementSignature: args.requirementSignature,
|
|
81
|
+
});
|
|
64
82
|
let tx = {
|
|
65
|
-
to
|
|
83
|
+
to,
|
|
84
|
+
value: 0n,
|
|
66
85
|
data: encodeFunctionData({
|
|
67
|
-
abi:
|
|
68
|
-
functionName: "
|
|
69
|
-
args: [
|
|
86
|
+
abi: vaultExitBundlesV1Abi,
|
|
87
|
+
functionName: "vaultExitBundlesV1ForceWithdrawVaultV2",
|
|
88
|
+
args: [
|
|
89
|
+
vault.address,
|
|
90
|
+
args.adapter,
|
|
91
|
+
args.exitAssets,
|
|
92
|
+
args.minSharePriceE27,
|
|
93
|
+
sharesPermit,
|
|
94
|
+
referralFeePct,
|
|
95
|
+
referralFeeRecipient,
|
|
96
|
+
args.deadline,
|
|
97
|
+
],
|
|
70
98
|
}),
|
|
71
|
-
value: 0n,
|
|
72
99
|
};
|
|
73
|
-
if (metadata)
|
|
100
|
+
if (metadata)
|
|
74
101
|
tx = addTransactionMetadata(tx, metadata);
|
|
75
|
-
}
|
|
76
102
|
return deepFreeze({
|
|
77
103
|
...tx,
|
|
78
104
|
action: {
|
|
79
105
|
type: "vaultV2ForceWithdraw",
|
|
80
106
|
args: {
|
|
81
|
-
vault:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
onBehalf,
|
|
107
|
+
vault: vault.address,
|
|
108
|
+
adapter: args.adapter,
|
|
109
|
+
exitAssets: args.exitAssets,
|
|
110
|
+
minSharePriceE27: args.minSharePriceE27,
|
|
111
|
+
referralFeePct,
|
|
112
|
+
referralFeeRecipient,
|
|
113
|
+
onBehalf: args.userAddress,
|
|
114
|
+
deadline: args.deadline,
|
|
88
115
|
},
|
|
89
116
|
},
|
|
90
117
|
});
|
|
@@ -39,6 +39,7 @@ export interface VaultV2InKindRedeemParams {
|
|
|
39
39
|
* @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
|
|
40
40
|
* `data`, and the typed action discriminator.
|
|
41
41
|
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
42
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
42
43
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
43
44
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
44
45
|
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
@@ -2,6 +2,7 @@ import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
|
2
2
|
import { encodeFunctionData } from "viem";
|
|
3
3
|
import { vaultExitBundlesV1Abi } from "../../abis.js";
|
|
4
4
|
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
5
|
+
import { validateDeadline } from "../../helpers/validate.js";
|
|
5
6
|
import { NonPositiveInputError, } from "../../types/index.js";
|
|
6
7
|
import { getVaultExitBundlesV1PermitStruct } from "../signatures/getVaultExitBundlesV1PermitStruct.js";
|
|
7
8
|
/**
|
|
@@ -26,6 +27,7 @@ import { getVaultExitBundlesV1PermitStruct } from "../signatures/getVaultExitBun
|
|
|
26
27
|
* @returns A deep-frozen `Readonly<Transaction<VaultV2InKindRedeemAction>>` with `to`, `value`,
|
|
27
28
|
* `data`, and the typed action discriminator.
|
|
28
29
|
* @throws {NonPositiveInputError} when `amount` or `deadline` is not positive.
|
|
30
|
+
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
29
31
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
30
32
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
31
33
|
* @throws {VaultExitBundlesV1PermitMismatchError} when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
@@ -43,8 +45,7 @@ import { getVaultExitBundlesV1PermitStruct } from "../signatures/getVaultExitBun
|
|
|
43
45
|
export const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
|
|
44
46
|
if (args.amount <= 0n)
|
|
45
47
|
throw new NonPositiveInputError("amount", args.amount);
|
|
46
|
-
|
|
47
|
-
throw new NonPositiveInputError("deadline", args.deadline);
|
|
48
|
+
validateDeadline(args.deadline);
|
|
48
49
|
const to = getChainAddress(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
49
50
|
const marketParamsList = args.marketParamsList.map((marketParams) => ({
|
|
50
51
|
loanToken: marketParams.loanToken,
|
|
@@ -2,7 +2,10 @@ import { VaultMarketPublicAllocatorConfig as BlueVaultMarketPublicAllocatorConfi
|
|
|
2
2
|
import { fetchVaultMarketPublicAllocatorConfig } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
declare module "@morpho-org/blue-sdk" {
|
|
4
4
|
namespace VaultMarketPublicAllocatorConfig {
|
|
5
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/fetch`. */
|
|
5
6
|
let fetch: typeof fetchVaultMarketPublicAllocatorConfig;
|
|
6
7
|
}
|
|
7
8
|
}
|
|
8
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/entities`. */
|
|
11
|
+
BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
|
|
@@ -2,4 +2,6 @@ import { VaultMarketPublicAllocatorConfig as BlueVaultMarketPublicAllocatorConfi
|
|
|
2
2
|
import { fetchVaultMarketPublicAllocatorConfig } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
BlueVaultMarketPublicAllocatorConfig.fetch =
|
|
4
4
|
fetchVaultMarketPublicAllocatorConfig;
|
|
5
|
-
export {
|
|
5
|
+
export {
|
|
6
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig` from `@morpho-org/morpho-sdk/entities`. */
|
|
7
|
+
BlueVaultMarketPublicAllocatorConfig as VaultMarketPublicAllocatorConfig, };
|
package/lib/esm/blue/abis.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
|
|
3
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
|
|
4
|
+
publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi,
|
|
5
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
|
|
6
|
+
vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/blue/abis.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi, preLiquidationAbi, preLiquidationFactoryAbi,
|
|
3
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
|
|
4
|
+
publicAllocatorAbi, vaultV1AdapterAbi, vaultV1AdapterFactoryAbi,
|
|
5
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `vaultV2BluePublicAllocatorAbi`. */
|
|
6
|
+
vaultV1PublicAllocatorAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig,
|
|
2
|
-
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition, IPreLiquidationParams, IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig,
|
|
2
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BlueMarketPublicAllocatorConfig`. */
|
|
3
|
+
IVaultMarketPublicAllocatorConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType,
|
|
4
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `IVaultV2BluePublicAllocatorConfig`. */
|
|
5
|
+
VaultPublicAllocatorConfig, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
|
|
7
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
|
|
8
|
+
VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/esm/blue/entities.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
|
|
1
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position, PreLiquidationParams, PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig,
|
|
2
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `VaultV2BlueMarketPublicAllocatorConfig`. */
|
|
3
|
+
VaultMarketPublicAllocatorConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/esm/blue/errors.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/blue/errors.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError, UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
2
2
|
export { getUnsupportedVaultV2Adapter, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/blue/fetch.d.ts
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
2
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
|
|
3
|
+
fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
package/lib/esm/blue/fetch.js
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition, fetchPreLiquidationParams, fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig,
|
|
2
|
+
/** @deprecated Vault V1 PublicAllocator support will be removed in the next major. Use `fetchVaultV2BlueMarketPublicAllocatorConfig`. */
|
|
3
|
+
fetchVaultMarketPublicAllocatorConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
@@ -30,7 +30,7 @@ type VaultV2BlueReallocationsParams = {
|
|
|
30
30
|
export interface BlueTokenRequirementsParams {
|
|
31
31
|
/** Prefer ERC-2612 when the funded token exposes a compatible nonce. */
|
|
32
32
|
readonly useSimplePermit?: boolean;
|
|
33
|
-
/** Explicit unused Permit2 SignatureTransfer unordered nonce. */
|
|
33
|
+
/** Explicit unused Permit2 SignatureTransfer unordered nonce; defaults to the lowest unused nonce. */
|
|
34
34
|
readonly permit2Nonce?: bigint;
|
|
35
35
|
/**
|
|
36
36
|
* Classic ERC-20 allowance to set when an approval is needed, enabling a reusable approval (for
|
|
@@ -77,7 +77,7 @@ export interface BlueActions {
|
|
|
77
77
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
78
78
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
79
79
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
80
|
-
* @throws {
|
|
80
|
+
* @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
|
|
81
81
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
82
82
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
83
83
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
@@ -141,7 +141,7 @@ export interface BlueActions {
|
|
|
141
141
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
142
142
|
* @throws {InputExceedsMaxError} when `assets` or `deadline` exceeds `uint256`, when the referral fee is at least WAD, or from `getRequirements()` when an explicit `permit2Nonce` exceeds `uint256`.
|
|
143
143
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
144
|
-
* @throws {
|
|
144
|
+
* @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
|
|
145
145
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
146
146
|
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when a classic `approvalAmount` is below the funded `assets`.
|
|
147
147
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
@@ -350,6 +350,7 @@ export interface BlueActions {
|
|
|
350
350
|
* @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
|
|
351
351
|
* @param params.referralFeeRecipient - Recipient required for a positive fee.
|
|
352
352
|
* @returns Lazy token prerequisite resolution and a synchronous deep-frozen transaction.
|
|
353
|
+
* @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
|
|
353
354
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
354
355
|
* @throws {ExpiredDeadlineError} when the deadline is stale.
|
|
355
356
|
* @throws {MissingAccrualPositionError} when no position snapshot is provided.
|
|
@@ -366,7 +367,7 @@ export interface BlueActions {
|
|
|
366
367
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
367
368
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
368
369
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
369
|
-
* @throws {
|
|
370
|
+
* @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
|
|
370
371
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
371
372
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
372
373
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an authorization signature is supplied.
|
|
@@ -508,6 +509,7 @@ export interface BlueActions {
|
|
|
508
509
|
* @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
|
|
509
510
|
* @param params.referralFeeRecipient - Recipient required for a positive fee.
|
|
510
511
|
* @returns Lazy funding/authorization resolution and a synchronous deep-frozen transaction builder.
|
|
512
|
+
* @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
|
|
511
513
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
512
514
|
* @throws {MissingAccrualPositionError} when no position snapshot is provided at runtime.
|
|
513
515
|
* @throws {MarketIdMismatchError} when `positionData` belongs to another market.
|
|
@@ -527,7 +529,7 @@ export interface BlueActions {
|
|
|
527
529
|
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
528
530
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
529
531
|
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
530
|
-
* @throws {
|
|
532
|
+
* @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
|
|
531
533
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
532
534
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
|
|
533
535
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
|
|
@@ -625,7 +627,7 @@ export interface BlueActions {
|
|
|
625
627
|
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
626
628
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
627
629
|
* @throws {ReallocationLoanTokenMismatchError} when a source uses another loan token.
|
|
628
|
-
* @throws {
|
|
630
|
+
* @throws {NoUnusedPermit2NonceError} from `getRequirements()` when every Permit2 nonce for the owner is consumed and none was passed explicitly.
|
|
629
631
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the explicit Permit2 nonce is consumed.
|
|
630
632
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple signatures of one kind are supplied.
|
|
631
633
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an inactive leg cannot consume a supplied signature.
|
|
@@ -692,6 +694,7 @@ export interface BlueActions {
|
|
|
692
694
|
* @param params.referralFeePct - Optional WAD-scaled referral fee below 100%.
|
|
693
695
|
* @param params.referralFeeRecipient - Recipient required for a positive fee.
|
|
694
696
|
* @returns Lazy Blue authorization resolution and a synchronous deep-frozen transaction builder.
|
|
697
|
+
* @throws {UnsupportedBlueMarketIrmError} when required interest projection encounters an unsupported IRM.
|
|
695
698
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
696
699
|
* @throws {MissingAccrualPositionError} when either position snapshot is absent at runtime.
|
|
697
700
|
* @throws {MarketIdMismatchError} when a position snapshot belongs to another market.
|
|
@@ -857,6 +860,7 @@ export interface BlueActions {
|
|
|
857
860
|
* Pass the fetched block timestamp to compute reallocations at the same block.
|
|
858
861
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
859
862
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
863
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
860
864
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market — preventing fee-bearing reallocations from being attached to a call that would still revert onchain.
|
|
861
865
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds the target market supply.
|
|
862
866
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
@@ -883,6 +887,7 @@ export interface BlueActions {
|
|
|
883
887
|
* @param params.options - Optional allocator and utilization options.
|
|
884
888
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
885
889
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
890
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
886
891
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
|
|
887
892
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
888
893
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
|
|
@@ -906,6 +911,7 @@ export interface BlueActions {
|
|
|
906
911
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
907
912
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
908
913
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
914
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
909
915
|
* @throws {NegativeInputError} when a utilization or penalty limit is negative.
|
|
910
916
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
911
917
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
@@ -1181,6 +1187,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1181
1187
|
* @param params.options - Optional allocator and utilization options.
|
|
1182
1188
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
1183
1189
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
1190
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1184
1191
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
|
|
1185
1192
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
|
|
1186
1193
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
@@ -1207,6 +1214,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1207
1214
|
* @param params.options - Optional allocator and utilization options.
|
|
1208
1215
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
1209
1216
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
1217
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1210
1218
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
|
|
1211
1219
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
1212
1220
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
|
|
@@ -1230,6 +1238,7 @@ export declare class MorphoBlue implements BlueActions {
|
|
|
1230
1238
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
1231
1239
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
1232
1240
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
1241
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
1233
1242
|
* @throws {NegativeInputError} when a utilization or penalty limit is negative.
|
|
1234
1243
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
1235
1244
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|
|
@@ -865,6 +865,7 @@ export class MorphoBlue {
|
|
|
865
865
|
* @param params.options - Optional allocator and utilization options.
|
|
866
866
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
867
867
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to a different chain than this market.
|
|
868
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
868
869
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation's absolute shortfall on the target market.
|
|
869
870
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when `operation === "withdraw"` and `amount` exceeds the target market's `totalSupplyAssets`.
|
|
870
871
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault is missing its public allocator config.
|
|
@@ -911,6 +912,7 @@ export class MorphoBlue {
|
|
|
911
912
|
* @param params.options - Optional allocator and utilization options.
|
|
912
913
|
* @returns Vault V1 reallocations for explicit low-level Bundler3 composition.
|
|
913
914
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
915
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
914
916
|
* @throws {InsufficientSharedLiquidityError} when shared liquidity cannot cover the operation.
|
|
915
917
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdrawal exceeds market supply.
|
|
916
918
|
* @throws {MissingPublicAllocatorConfigError} when a selected vault lacks allocator state.
|
|
@@ -936,6 +938,7 @@ export class MorphoBlue {
|
|
|
936
938
|
* @param params.options - Optional allocator discovery controls and operation to support.
|
|
937
939
|
* @returns Action-ready reallocations and their post-simulation state.
|
|
938
940
|
* @throws {ChainIdMismatchError} when `reallocationData` belongs to another chain.
|
|
941
|
+
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
939
942
|
* @throws {NegativeInputError} when a utilization or penalty limit is negative.
|
|
940
943
|
* @throws {InputExceedsMaxError} when a utilization or penalty limit exceeds WAD.
|
|
941
944
|
* @throws {NonPositiveInputError} when an enabled operation amount is not positive.
|