@morpho-org/morpho-sdk 9.4.0 → 9.6.0-next.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 +7 -0
- package/MIGRATION-v7-to-v8.md +7 -0
- package/MIGRATION-v8-to-v9.md +7 -0
- package/README.md +6 -4
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +4 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -1
- package/lib/cjs/entities/blue/blue.d.ts +7 -21
- package/lib/cjs/entities/blue/blue.js +4 -22
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +21 -26
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +42 -80
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
- package/lib/cjs/entities/requirements/getUnusedPermit2Nonce.js +2 -2
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +5 -11
- package/lib/cjs/entities/vaultV1/vaultV1.js +3 -11
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -18
- package/lib/cjs/entities/vaultV2/vaultV2.js +36 -12
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +49 -7
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/deadShares.js +2 -0
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/types/action.d.ts +11 -4
- package/lib/cjs/types/action.js +1 -0
- package/lib/cjs/types/error.d.ts +8 -2
- package/lib/cjs/types/error.js +8 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +4 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +1 -0
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +7 -21
- package/lib/esm/entities/blue/blue.js +4 -22
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +21 -26
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +44 -82
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.d.ts +6 -3
- package/lib/esm/entities/requirements/getUnusedPermit2Nonce.js +2 -2
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +5 -11
- package/lib/esm/entities/vaultV1/vaultV1.js +4 -12
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -18
- package/lib/esm/entities/vaultV2/vaultV2.js +37 -13
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +49 -7
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +3 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/types/action.d.ts +11 -4
- package/lib/esm/types/action.js +1 -0
- package/lib/esm/types/error.d.ts +8 -2
- package/lib/esm/types/error.js +8 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +6 -6
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
1
|
+
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MidnightAdapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams as IBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
-
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
|
|
5
|
+
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MidnightAdapter, IVaultV2MidnightAdapterAccrualMarket, IVaultV2MidnightAdapterCollateralParams, IVaultV2MidnightAdapterMarket, IVaultV2MidnightAdapterMarketData, IVaultV2MidnightAdapterMarketState, IVaultV2MidnightAdapterPosition, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, VaultV2MidnightAdapterAccrualMarket, VaultV2MidnightAdapterMarketData, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MidnightAdapter, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
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";
|
|
10
|
+
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MidnightAdapter, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
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,11 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
|
|
17
|
+
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2MidnightAdapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2MidnightAdapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
|
|
18
18
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
19
19
|
Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
20
20
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
21
21
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
22
|
+
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
22
23
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
23
24
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
24
25
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -46,6 +47,7 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
46
47
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
47
48
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
48
49
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
50
|
+
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
49
51
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
50
52
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
51
53
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
@@ -18,22 +18,19 @@ export interface GetBundlesTokenRequirementsParams {
|
|
|
18
18
|
readonly supportSignature: boolean;
|
|
19
19
|
/** Whether token metadata reads may use deployless aggregation. */
|
|
20
20
|
readonly supportDeployless?: boolean;
|
|
21
|
-
/** Prefer ERC-2612 when the token exposes a compatible nonce. */
|
|
21
|
+
/** Prefer ERC-2612 when the token exposes a compatible nonce; defaults to true when signatures are supported. */
|
|
22
22
|
readonly useSimplePermit?: boolean;
|
|
23
|
-
/**
|
|
23
|
+
/** @deprecated Ignored. The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals. */
|
|
24
24
|
readonly permit2Nonce?: bigint;
|
|
25
25
|
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
26
26
|
readonly now?: bigint;
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* Resolves direct approval
|
|
30
|
-
* a registered fixed bundles contract.
|
|
29
|
+
* Resolves direct approval or ERC-2612 prerequisites for a registered fixed bundles contract.
|
|
31
30
|
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* names the bundles contract as spender. The resolver picks the lowest unused unordered nonce
|
|
36
|
-
* by default; concurrent flows for the same owner should pass explicit nonces.
|
|
31
|
+
* Reads the direct allowance first for nonzero amounts. Only when it is insufficient does
|
|
32
|
+
* the selected signature path try ERC-2612 nonce and metadata reads. A permit is returned only
|
|
33
|
+
* when the token's DOMAIN_SEPARATOR matches the domain to be signed; otherwise use approval.
|
|
37
34
|
*
|
|
38
35
|
* @param viemClient - Connected viem client used for allowance and nonce reads.
|
|
39
36
|
* @param params - Token requirement parameters.
|
|
@@ -44,37 +41,35 @@ export interface GetBundlesTokenRequirementsParams {
|
|
|
44
41
|
* @param params.chainId - Target chain id; must match the client chain.
|
|
45
42
|
* @param params.deadline - Final-call and signature deadline.
|
|
46
43
|
* @param params.now - Timestamp the deadline is validated against; defaults to the current time.
|
|
47
|
-
* @param params.supportSignature - Whether ERC-2612
|
|
44
|
+
* @param params.supportSignature - Whether ERC-2612 signatures may be requested.
|
|
48
45
|
* @param params.supportDeployless - Whether ERC-2612 metadata reads may use deployless calls.
|
|
49
|
-
* @param params.useSimplePermit - Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
50
|
-
*
|
|
51
|
-
*
|
|
46
|
+
* @param params.useSimplePermit - Defaults to true when signatures are supported. Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
47
|
+
* DOMAIN_SEPARATOR matches the signing domain. Missing, mismatched, or unsupported domains,
|
|
48
|
+
* or recognized nonce/separator reverts or undecodable results, fall back to classic approval. A malformed
|
|
52
49
|
* `eip712Domain()` result rejects with `MalformedTokenMetadataError`.
|
|
53
|
-
* @param params.permit2Nonce -
|
|
54
|
-
*
|
|
55
|
-
*
|
|
50
|
+
* @param params.permit2Nonce - Deprecated and ignored.
|
|
51
|
+
* @returns Ordered deep-frozen approval transactions and/or signable token requirements;
|
|
52
|
+
* empty when the direct allowance already covers the amount, without probing permit support.
|
|
56
53
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
57
54
|
* another chain than `params.chainId`.
|
|
58
|
-
* @throws {NegativeInputError} when `amount`
|
|
55
|
+
* @throws {NegativeInputError} when `amount` is negative.
|
|
59
56
|
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
60
57
|
* @throws {ExpiredDeadlineError} when `deadline` is positive but not in the future.
|
|
61
58
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
62
59
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's registered
|
|
63
60
|
* BlueBundlesV1 or VaultBundlesV1 deployment, including for a zero-amount request.
|
|
64
|
-
* @throws {
|
|
65
|
-
* was passed explicitly.
|
|
66
|
-
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} when `permit2Nonce` is already consumed.
|
|
67
|
-
* @throws {InputExceedsMaxError} when `amount`, `deadline`, or `permit2Nonce` exceeds uint256.
|
|
61
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
|
|
68
62
|
* @throws {UnknownTokenError} when the token's `decimals()` reverts, has no code, returns
|
|
69
63
|
* undecodable data, or is out of range.
|
|
70
64
|
* @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
|
|
71
65
|
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
72
66
|
* deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
|
|
73
|
-
* @throws {viem.BaseError} when a required allowance,
|
|
74
|
-
* or `eth_chainId` read fails.
|
|
75
|
-
* only when the token reverts or returns undecodable data; other read failures propagate.
|
|
76
|
-
*
|
|
77
|
-
*
|
|
67
|
+
* @throws {viem.BaseError} when a required allowance, ERC-2612 metadata, DOMAIN_SEPARATOR,
|
|
68
|
+
* or `eth_chainId` read fails. Nonce and separator probes fall back to classic approval
|
|
69
|
+
* only when the token reverts or returns undecodable data; other read failures propagate.
|
|
70
|
+
* `MissingPermitDomainNameError`, `InvalidPermitDomainChainIdError`,
|
|
71
|
+
* `InvalidPermitDomainVerifyingContractError`, and `UnsupportedPermitDomainExtensionsError`
|
|
72
|
+
* are handled internally and fall back to approval.
|
|
78
73
|
* @example
|
|
79
74
|
* ```ts
|
|
80
75
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
@@ -11,16 +11,12 @@ const encodeErc20Permit_js_1 = require("../../actions/requirements/encode/encode
|
|
|
11
11
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
12
12
|
const index_js_2 = require("../../helpers/index.js");
|
|
13
13
|
const index_js_3 = require("../../types/index.js");
|
|
14
|
-
const getUnusedPermit2Nonce_js_1 = require("./getUnusedPermit2Nonce.js");
|
|
15
14
|
/**
|
|
16
|
-
* Resolves direct approval
|
|
17
|
-
* a registered fixed bundles contract.
|
|
15
|
+
* Resolves direct approval or ERC-2612 prerequisites for a registered fixed bundles contract.
|
|
18
16
|
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* names the bundles contract as spender. The resolver picks the lowest unused unordered nonce
|
|
23
|
-
* by default; concurrent flows for the same owner should pass explicit nonces.
|
|
17
|
+
* Reads the direct allowance first for nonzero amounts. Only when it is insufficient does
|
|
18
|
+
* the selected signature path try ERC-2612 nonce and metadata reads. A permit is returned only
|
|
19
|
+
* when the token's DOMAIN_SEPARATOR matches the domain to be signed; otherwise use approval.
|
|
24
20
|
*
|
|
25
21
|
* @param viemClient - Connected viem client used for allowance and nonce reads.
|
|
26
22
|
* @param params - Token requirement parameters.
|
|
@@ -31,37 +27,35 @@ const getUnusedPermit2Nonce_js_1 = require("./getUnusedPermit2Nonce.js");
|
|
|
31
27
|
* @param params.chainId - Target chain id; must match the client chain.
|
|
32
28
|
* @param params.deadline - Final-call and signature deadline.
|
|
33
29
|
* @param params.now - Timestamp the deadline is validated against; defaults to the current time.
|
|
34
|
-
* @param params.supportSignature - Whether ERC-2612
|
|
30
|
+
* @param params.supportSignature - Whether ERC-2612 signatures may be requested.
|
|
35
31
|
* @param params.supportDeployless - Whether ERC-2612 metadata reads may use deployless calls.
|
|
36
|
-
* @param params.useSimplePermit - Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
37
|
-
*
|
|
38
|
-
*
|
|
32
|
+
* @param params.useSimplePermit - Defaults to true when signatures are supported. Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
33
|
+
* DOMAIN_SEPARATOR matches the signing domain. Missing, mismatched, or unsupported domains,
|
|
34
|
+
* or recognized nonce/separator reverts or undecodable results, fall back to classic approval. A malformed
|
|
39
35
|
* `eip712Domain()` result rejects with `MalformedTokenMetadataError`.
|
|
40
|
-
* @param params.permit2Nonce -
|
|
41
|
-
*
|
|
42
|
-
*
|
|
36
|
+
* @param params.permit2Nonce - Deprecated and ignored.
|
|
37
|
+
* @returns Ordered deep-frozen approval transactions and/or signable token requirements;
|
|
38
|
+
* empty when the direct allowance already covers the amount, without probing permit support.
|
|
43
39
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
44
40
|
* another chain than `params.chainId`.
|
|
45
|
-
* @throws {NegativeInputError} when `amount`
|
|
41
|
+
* @throws {NegativeInputError} when `amount` is negative.
|
|
46
42
|
* @throws {NonPositiveInputError} when `deadline` is not positive.
|
|
47
43
|
* @throws {ExpiredDeadlineError} when `deadline` is positive but not in the future.
|
|
48
44
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
49
45
|
* @throws {UnsupportedErc20ApprovalSpenderError} when `spender` is not the chain's registered
|
|
50
46
|
* BlueBundlesV1 or VaultBundlesV1 deployment, including for a zero-amount request.
|
|
51
|
-
* @throws {
|
|
52
|
-
* was passed explicitly.
|
|
53
|
-
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} when `permit2Nonce` is already consumed.
|
|
54
|
-
* @throws {InputExceedsMaxError} when `amount`, `deadline`, or `permit2Nonce` exceeds uint256.
|
|
47
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256.
|
|
55
48
|
* @throws {UnknownTokenError} when the token's `decimals()` reverts, has no code, returns
|
|
56
49
|
* undecodable data, or is out of range.
|
|
57
50
|
* @throws {MalformedTokenMetadataError} when the token's `eip712Domain()` or
|
|
58
51
|
* `bytes32` `name`/`symbol` retry returns non-empty data that does not decode, or when the
|
|
59
52
|
* deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
|
|
60
|
-
* @throws {viem.BaseError} when a required allowance,
|
|
61
|
-
* or `eth_chainId` read fails.
|
|
62
|
-
* only when the token reverts or returns undecodable data; other read failures propagate.
|
|
63
|
-
*
|
|
64
|
-
*
|
|
53
|
+
* @throws {viem.BaseError} when a required allowance, ERC-2612 metadata, DOMAIN_SEPARATOR,
|
|
54
|
+
* or `eth_chainId` read fails. Nonce and separator probes fall back to classic approval
|
|
55
|
+
* only when the token reverts or returns undecodable data; other read failures propagate.
|
|
56
|
+
* `MissingPermitDomainNameError`, `InvalidPermitDomainChainIdError`,
|
|
57
|
+
* `InvalidPermitDomainVerifyingContractError`, and `UnsupportedPermitDomainExtensionsError`
|
|
58
|
+
* are handled internally and fall back to approval.
|
|
65
59
|
* @example
|
|
66
60
|
* ```ts
|
|
67
61
|
* import { addressesRegistry } from "@morpho-org/blue-sdk";
|
|
@@ -131,10 +125,10 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
131
125
|
});
|
|
132
126
|
if (allowance >= params.amount)
|
|
133
127
|
return [];
|
|
134
|
-
const {
|
|
128
|
+
const { dai } = (0, blue_sdk_1.getChainAddresses)(params.chainId);
|
|
135
129
|
if (params.supportSignature) {
|
|
136
130
|
const isDai = (0, morpho_ts_1.isDefined)(dai) && (0, viem_1.isAddressEqual)(params.token, dai);
|
|
137
|
-
if (params.useSimplePermit && !isDai) {
|
|
131
|
+
if ((params.useSimplePermit ?? true) && !isDai) {
|
|
138
132
|
const nonce = await (0, actions_1.readContract)(viemClient, {
|
|
139
133
|
abi: blue_sdk_viem_1.erc2612Abi,
|
|
140
134
|
address: params.token,
|
|
@@ -158,61 +152,29 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
158
152
|
deadline: params.deadline,
|
|
159
153
|
now: timestamp,
|
|
160
154
|
supportDeployless: params.supportDeployless,
|
|
161
|
-
}), blue_sdk_viem_1.MissingPermitDomainNameError);
|
|
162
|
-
if ((0, morpho_ts_1.isDefined)(permit))
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
155
|
+
}), blue_sdk_viem_1.MissingPermitDomainNameError, blue_sdk_viem_1.InvalidPermitDomainChainIdError, blue_sdk_viem_1.InvalidPermitDomainVerifyingContractError, blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError);
|
|
156
|
+
if ((0, morpho_ts_1.isDefined)(permit)) {
|
|
157
|
+
const separator = await (0, actions_1.readContract)(viemClient, {
|
|
158
|
+
abi: blue_sdk_viem_1.erc2612Abi,
|
|
159
|
+
address: params.token,
|
|
160
|
+
functionName: "DOMAIN_SEPARATOR",
|
|
161
|
+
}).catch((error) => {
|
|
162
|
+
if ((0, blue_sdk_viem_1.isTransportError)(error))
|
|
163
|
+
throw error;
|
|
164
|
+
if ((0, blue_sdk_viem_1.isContractRevertError)(error) || (0, blue_sdk_viem_1.isUndecodableResultError)(error))
|
|
165
|
+
return undefined;
|
|
166
|
+
throw error;
|
|
167
|
+
});
|
|
168
|
+
const domain = permit.action.typedData.domain ?? {};
|
|
169
|
+
if (separator?.toLowerCase() ===
|
|
170
|
+
(0, viem_1.hashDomain)({
|
|
171
|
+
domain,
|
|
172
|
+
types: { EIP712Domain: (0, viem_1.getTypesForEIP712Domain)({ domain }) },
|
|
173
|
+
}).toLowerCase())
|
|
174
|
+
return [permit];
|
|
175
|
+
}
|
|
167
176
|
}
|
|
168
177
|
}
|
|
169
|
-
if (permit2 != null) {
|
|
170
|
-
const permit2Nonce = params.permit2Nonce ??
|
|
171
|
-
(await (0, getUnusedPermit2Nonce_js_1.getUnusedPermit2Nonce)(viemClient, {
|
|
172
|
-
owner: params.owner,
|
|
173
|
-
chainId: params.chainId,
|
|
174
|
-
}));
|
|
175
|
-
if (permit2Nonce < 0n) {
|
|
176
|
-
throw new index_js_3.NegativeInputError("permit2Nonce", permit2Nonce);
|
|
177
|
-
}
|
|
178
|
-
if (permit2Nonce > viem_1.maxUint256) {
|
|
179
|
-
throw new index_js_3.InputExceedsMaxError({
|
|
180
|
-
field: "permit2Nonce",
|
|
181
|
-
value: permit2Nonce,
|
|
182
|
-
max: viem_1.maxUint256,
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
const wordPosition = permit2Nonce >> 8n;
|
|
186
|
-
const [permit2Allowance, nonceBitmap] = await Promise.all([
|
|
187
|
-
(0, actions_1.readContract)(viemClient, {
|
|
188
|
-
abi: viem_1.erc20Abi,
|
|
189
|
-
address: params.token,
|
|
190
|
-
functionName: "allowance",
|
|
191
|
-
args: [params.owner, permit2],
|
|
192
|
-
}),
|
|
193
|
-
(0, actions_1.readContract)(viemClient, {
|
|
194
|
-
abi: blue_sdk_viem_1.permit2Abi,
|
|
195
|
-
address: permit2,
|
|
196
|
-
functionName: "nonceBitmap",
|
|
197
|
-
args: [params.owner, wordPosition],
|
|
198
|
-
}),
|
|
199
|
-
]);
|
|
200
|
-
return (0, index_js_1.resolveBundlesTokenRequirements)({
|
|
201
|
-
token: params.token,
|
|
202
|
-
spender: params.spender,
|
|
203
|
-
owner: params.owner,
|
|
204
|
-
chainId: params.chainId,
|
|
205
|
-
amount: params.amount,
|
|
206
|
-
deadline: params.deadline,
|
|
207
|
-
now: timestamp,
|
|
208
|
-
state: {
|
|
209
|
-
type: "permit2SignatureTransfer",
|
|
210
|
-
permit2Allowance,
|
|
211
|
-
permit2Nonce,
|
|
212
|
-
nonceBitmap,
|
|
213
|
-
},
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
178
|
}
|
|
217
179
|
return (0, index_js_1.resolveBundlesTokenRequirements)({
|
|
218
180
|
token: params.token,
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { type Address, type Client } from "viem";
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* Parameters for {@link getUnusedPermit2Nonce}.
|
|
4
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
5
|
+
*/
|
|
3
6
|
export interface GetUnusedPermit2NonceParams {
|
|
4
7
|
/** Account that will sign the Permit2 SignatureTransfer. */
|
|
5
8
|
readonly owner: Address;
|
|
@@ -9,8 +12,7 @@ export interface GetUnusedPermit2NonceParams {
|
|
|
9
12
|
readonly startNonce?: bigint;
|
|
10
13
|
}
|
|
11
14
|
/**
|
|
12
|
-
* Finds the lowest unused Permit2 unordered nonce for
|
|
13
|
-
* {@link getBundlesTokenRequirements} or as `nonce` to {@link encodeErc20Permit2SignatureTransfer}.
|
|
15
|
+
* Finds the lowest unused Permit2 unordered nonce for legacy SignatureTransfer integrations.
|
|
14
16
|
*
|
|
15
17
|
* Permit2 SignatureTransfer consumes an unordered 256-bit nonce; a nonce is free when its bit in
|
|
16
18
|
* `nonceBitmap(owner, word)` is unset. This scans consecutive bitmap words starting at `startNonce`
|
|
@@ -45,5 +47,6 @@ export interface GetUnusedPermit2NonceParams {
|
|
|
45
47
|
* });
|
|
46
48
|
* // permit2Nonce satisfies bigint
|
|
47
49
|
* ```
|
|
50
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
48
51
|
*/
|
|
49
52
|
export declare const getUnusedPermit2Nonce: (viemClient: Client, params: GetUnusedPermit2NonceParams) => Promise<bigint>;
|
|
@@ -12,8 +12,7 @@ const index_js_2 = require("../../types/index.js");
|
|
|
12
12
|
/** Highest Permit2 nonce-bitmap word index; each word covers 256 unordered nonces. */
|
|
13
13
|
const MAX_PERMIT2_NONCE_WORD = viem_1.maxUint256 >> 8n;
|
|
14
14
|
/**
|
|
15
|
-
* Finds the lowest unused Permit2 unordered nonce for
|
|
16
|
-
* {@link getBundlesTokenRequirements} or as `nonce` to {@link encodeErc20Permit2SignatureTransfer}.
|
|
15
|
+
* Finds the lowest unused Permit2 unordered nonce for legacy SignatureTransfer integrations.
|
|
17
16
|
*
|
|
18
17
|
* Permit2 SignatureTransfer consumes an unordered 256-bit nonce; a nonce is free when its bit in
|
|
19
18
|
* `nonceBitmap(owner, word)` is unset. This scans consecutive bitmap words starting at `startNonce`
|
|
@@ -48,6 +47,7 @@ const MAX_PERMIT2_NONCE_WORD = viem_1.maxUint256 >> 8n;
|
|
|
48
47
|
* });
|
|
49
48
|
* // permit2Nonce satisfies bigint
|
|
50
49
|
* ```
|
|
50
|
+
* @deprecated The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals.
|
|
51
51
|
*/
|
|
52
52
|
const getUnusedPermit2Nonce = async (viemClient, params) => {
|
|
53
53
|
(0, index_js_1.validateChainId)(viemClient.chain?.id, params.chainId);
|
|
@@ -27,8 +27,8 @@ export interface VaultV1Actions {
|
|
|
27
27
|
* Prepares a Vault V1 deposit through the registered VaultBundlesV1 contract.
|
|
28
28
|
*
|
|
29
29
|
* Uses the supplied vault snapshot to compute the deadline-accrued `maxSharePrice`.
|
|
30
|
-
* `getRequirements()` reads the asset allowance and, when enabled, the selected ERC-2612
|
|
31
|
-
*
|
|
30
|
+
* `getRequirements()` reads the asset allowance and, when enabled, the selected ERC-2612
|
|
31
|
+
* nonce state. Native funding is exclusive and skips token requirements. Shares are
|
|
32
32
|
* always minted to the transaction sender, which must be `userAddress`.
|
|
33
33
|
* Concurrent requirement reads share the first caller's options; later calls refresh on-chain
|
|
34
34
|
* state using their own options.
|
|
@@ -53,19 +53,14 @@ export interface VaultV1Actions {
|
|
|
53
53
|
* @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
|
|
54
54
|
* @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
|
|
55
55
|
* @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
|
|
56
|
-
* @throws {NegativeInputError} when funding, slippage, the referral fee
|
|
56
|
+
* @throws {NegativeInputError} when funding, slippage, or the referral fee is negative.
|
|
57
57
|
* @throws {NonPositiveInputError} when funding or the previewed vault shares are not positive.
|
|
58
58
|
* @throws {ExcessiveSlippageToleranceError} when slippage tolerance exceeds the SDK maximum.
|
|
59
59
|
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
60
60
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
61
61
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
62
62
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
|
|
63
|
-
* @throws {
|
|
64
|
-
* owner is consumed and none was passed explicitly.
|
|
65
|
-
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the
|
|
66
|
-
* explicit Permit2 nonce is consumed.
|
|
67
|
-
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, or from
|
|
68
|
-
* `getRequirements()` when the Permit2 nonce exceeds uint256.
|
|
63
|
+
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256.
|
|
69
64
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
70
65
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
71
66
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
|
|
@@ -481,8 +476,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
481
476
|
* before any other requirement read. This VaultV1 `inKindRedeem` path validates the client chain
|
|
482
477
|
* before this code check.
|
|
483
478
|
*
|
|
484
|
-
* @param roles - Registry labels to resolve and check
|
|
485
|
-
* chain registers none.
|
|
479
|
+
* @param roles - Registry labels to resolve and check.
|
|
486
480
|
*/
|
|
487
481
|
private assertWriteTargets;
|
|
488
482
|
/** {@inheritDoc VaultV1Actions.deposit} */
|
|
@@ -39,17 +39,12 @@ class MorphoVaultV1 {
|
|
|
39
39
|
* before any other requirement read. This VaultV1 `inKindRedeem` path validates the client chain
|
|
40
40
|
* before this code check.
|
|
41
41
|
*
|
|
42
|
-
* @param roles - Registry labels to resolve and check
|
|
43
|
-
* chain registers none.
|
|
42
|
+
* @param roles - Registry labels to resolve and check.
|
|
44
43
|
*/
|
|
45
44
|
async assertWriteTargets(roles) {
|
|
46
45
|
const targets = [];
|
|
47
46
|
for (const role of roles) {
|
|
48
|
-
const address =
|
|
49
|
-
? (0, morpho_ts_1.getChainAddresses)(this.chainId).permit2
|
|
50
|
-
: (0, morpho_ts_1.getChainAddress)(this.chainId, role);
|
|
51
|
-
if (address == null)
|
|
52
|
-
continue;
|
|
47
|
+
const address = (0, morpho_ts_1.getChainAddress)(this.chainId, role);
|
|
53
48
|
targets.push({ role, address });
|
|
54
49
|
}
|
|
55
50
|
await (0, assertContractCode_js_1.assertRegistryTargetsHaveCode)(this.client.viemClient, this.chainId, targets);
|
|
@@ -97,9 +92,7 @@ class MorphoVaultV1 {
|
|
|
97
92
|
// Memoize the in-flight promise so concurrent callers share one round of
|
|
98
93
|
// allowance/nonce reads.
|
|
99
94
|
const pending = (async () => {
|
|
100
|
-
await this.assertWriteTargets(
|
|
101
|
-
? ["bundles.vaultBundlesV1", "permit2"]
|
|
102
|
-
: ["bundles.vaultBundlesV1"]);
|
|
95
|
+
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
103
96
|
return funding.value > 0n
|
|
104
97
|
? []
|
|
105
98
|
: (0, index_js_4.getBundlesTokenRequirements)(this.client.viemClient, {
|
|
@@ -112,7 +105,6 @@ class MorphoVaultV1 {
|
|
|
112
105
|
supportSignature: this.client.options.supportSignature,
|
|
113
106
|
supportDeployless: this.client.options.supportDeployless,
|
|
114
107
|
useSimplePermit: requirementOptions?.useSimplePermit,
|
|
115
|
-
permit2Nonce: requirementOptions?.permit2Nonce,
|
|
116
108
|
now,
|
|
117
109
|
});
|
|
118
110
|
})();
|
|
@@ -32,8 +32,8 @@ export interface VaultV2Actions {
|
|
|
32
32
|
* Prepares a Vault V2 deposit through the registered VaultBundlesV1 contract.
|
|
33
33
|
*
|
|
34
34
|
* Uses the supplied vault snapshot to compute the deadline-accrued `maxSharePrice`.
|
|
35
|
-
* `getRequirements()` reads the asset allowance and, when enabled, the selected ERC-2612
|
|
36
|
-
*
|
|
35
|
+
* `getRequirements()` reads the asset allowance and, when enabled, the selected ERC-2612
|
|
36
|
+
* nonce state. Native funding is exclusive and skips token requirements. Shares are
|
|
37
37
|
* always minted to the transaction sender, which must be `userAddress`.
|
|
38
38
|
* Concurrent requirement reads share the first caller's options; later calls refresh on-chain
|
|
39
39
|
* state using their own options.
|
|
@@ -58,19 +58,16 @@ export interface VaultV2Actions {
|
|
|
58
58
|
* @throws {VaultAddressMismatchError} when `vaultData` belongs to another vault.
|
|
59
59
|
* @throws {ExpiredDeadlineError} when the deadline is stale at creation or requirement resolution.
|
|
60
60
|
* @throws {MixedBundlesFundingError} when ERC-20 and native funding are both supplied.
|
|
61
|
-
* @throws {NegativeInputError} when funding, slippage, the referral fee
|
|
61
|
+
* @throws {NegativeInputError} when funding, slippage, or the referral fee is negative.
|
|
62
62
|
* @throws {NonPositiveInputError} when funding or the previewed vault shares are not positive.
|
|
63
63
|
* @throws {ExcessiveSlippageToleranceError} when slippage tolerance exceeds the SDK maximum.
|
|
64
64
|
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
65
65
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
66
66
|
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
67
67
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a non-wNative vault.
|
|
68
|
-
* @throws {
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
* explicit Permit2 nonce is consumed.
|
|
72
|
-
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, or from
|
|
73
|
-
* `getRequirements()` when the Permit2 nonce exceeds uint256.
|
|
68
|
+
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, or when the vault's
|
|
69
|
+
* liquidity adapter is a Midnight adapter (it cannot receive vault allocations, so no deposit
|
|
70
|
+
* fits and `max` is `0n`).
|
|
74
71
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
75
72
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
76
73
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
|
|
@@ -152,7 +149,9 @@ export interface VaultV2Actions {
|
|
|
152
149
|
* @throws {NonPositiveInputError} when `amount` or the computed required share amount is not positive.
|
|
153
150
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
154
151
|
* at any `getRequirements()` call.
|
|
155
|
-
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation
|
|
152
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation,
|
|
153
|
+
* or when the vault's liquidity adapter is a Midnight adapter and `amount` exceeds the vault's
|
|
154
|
+
* idle assets.
|
|
156
155
|
* @throws {NegativeInputError} when `referralFeePct` or `slippageTolerance` is negative.
|
|
157
156
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
158
157
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
|
|
@@ -218,7 +217,24 @@ export interface VaultV2Actions {
|
|
|
218
217
|
* @throws {NonPositiveInputError} when `shares` is not positive.
|
|
219
218
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
220
219
|
* requirement resolution.
|
|
221
|
-
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256
|
|
220
|
+
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256, or from
|
|
221
|
+
* `getRequirements()` when the vault's liquidity adapter is a Midnight adapter and `shares`
|
|
222
|
+
* are worth more than the vault's idle assets.
|
|
223
|
+
* @throws {UnknownBlueFactory} from `getRequirements()` when the configured chain has no VaultV2 factory.
|
|
224
|
+
* @throws {UnknownBlueOfFactory} from `getRequirements()` when the vault is not a VaultV2 from the
|
|
225
|
+
* configured factory.
|
|
226
|
+
* @throws {UnsupportedBlueVaultV2AdapterError} from `getRequirements()` when the vault or one of its
|
|
227
|
+
* adapters uses an unsupported adapter class.
|
|
228
|
+
* @throws {UnsupportedBlueMarketIrmError} from `getRequirements()` when the vault's liquidity adapter
|
|
229
|
+
* is a Midnight adapter and accrual projects an underlying market with positive debt that uses an
|
|
230
|
+
* unsupported IRM.
|
|
231
|
+
* @throws {UnknownBlueMarketAllocationError} from `getRequirements()` when the vault's liquidity
|
|
232
|
+
* adapter is a Midnight adapter and accrual meets a nested Vault V1 withdraw queue market without
|
|
233
|
+
* allocation data.
|
|
234
|
+
* @throws {InvalidMidnightPositionLossFactorError} from `getRequirements()` when the vault's liquidity
|
|
235
|
+
* adapter is a Midnight adapter and accrual meets a market loss factor below a position's.
|
|
236
|
+
* @throws {InvalidMidnightPositionAccrualStateError} from `getRequirements()` when the vault's
|
|
237
|
+
* liquidity adapter is a Midnight adapter and accrual meets invalid Midnight position inputs.
|
|
222
238
|
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
223
239
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
224
240
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
|
|
@@ -226,7 +242,7 @@ export interface VaultV2Actions {
|
|
|
226
242
|
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
227
243
|
* @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
|
|
228
244
|
* contract has no code at its registered address.
|
|
229
|
-
* @throws {viem.BaseError} from `getRequirements()` when
|
|
245
|
+
* @throws {viem.BaseError} from `getRequirements()` when a vault-state, allowance, nonce, `eth_chainId`, or
|
|
230
246
|
* `eth_getCode` read fails.
|
|
231
247
|
* @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
|
|
232
248
|
* `getData()` has unusable decimals.
|
|
@@ -304,9 +320,11 @@ export interface VaultV2Actions {
|
|
|
304
320
|
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
305
321
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
306
322
|
* requirement resolution.
|
|
307
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter
|
|
323
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter, including
|
|
324
|
+
* a vault that mixes Blue and Midnight adapters.
|
|
308
325
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
309
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
326
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
|
|
327
|
+
* including a Midnight adapter.
|
|
310
328
|
* @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
|
|
311
329
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
312
330
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
@@ -431,9 +449,11 @@ export interface VaultV2Actions {
|
|
|
431
449
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
432
450
|
* requirement resolution.
|
|
433
451
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
|
|
434
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter
|
|
452
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter,
|
|
453
|
+
* including a vault that mixes Blue and Midnight adapters.
|
|
435
454
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
436
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
455
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
|
|
456
|
+
* including a Midnight adapter.
|
|
437
457
|
* @throws {VaultV2UnsupportedLiquidityAdapterError} when the vault routes liquidity through
|
|
438
458
|
* another adapter.
|
|
439
459
|
* @throws {VaultV2UndecodableLiquidityDataError} when the vault's `liquidityData` does not decode
|
|
@@ -555,8 +575,7 @@ export declare class MorphoVaultV2 implements VaultV2Actions {
|
|
|
555
575
|
* before any other requirement read. The `inKindRedeem` and `forceWithdraw` paths validate the
|
|
556
576
|
* client chain before this code check.
|
|
557
577
|
*
|
|
558
|
-
* @param roles - Registry labels to resolve and check
|
|
559
|
-
* chain registers none.
|
|
578
|
+
* @param roles - Registry labels to resolve and check.
|
|
560
579
|
*/
|
|
561
580
|
private assertWriteTargets;
|
|
562
581
|
/** {@inheritDoc VaultV2Actions.deposit} */
|