@morpho-org/morpho-sdk 6.0.0-next.3 → 6.0.0-next.4
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 +5 -3
- package/lib/cjs/abis.d.ts +5 -1
- package/lib/cjs/abis.js +2 -0
- package/lib/cjs/actions/bundles/common.d.ts +2 -2
- package/lib/cjs/actions/bundles/common.js +10 -2
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +2 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +2 -1
- package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +10 -2
- package/lib/cjs/blue/entities.js +2 -0
- package/lib/cjs/blue/errors.d.ts +4 -2
- package/lib/cjs/blue/errors.js +3 -1
- package/lib/cjs/blue/fetch.d.ts +5 -1
- package/lib/cjs/blue/fetch.js +2 -0
- package/lib/cjs/blue/utils.d.ts +5 -1
- package/lib/cjs/blue/utils.js +2 -0
- package/lib/cjs/entities/index.d.ts +10 -2
- package/lib/cjs/entities/index.js +2 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +4 -3
- package/lib/cjs/entities/vaultV1/vaultV1.js +4 -3
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +21 -13
- package/lib/cjs/entities/vaultV2/vaultV2.js +31 -13
- package/lib/cjs/errors.d.ts +5 -3
- package/lib/cjs/errors.js +4 -1
- package/lib/cjs/fetch.d.ts +5 -1
- package/lib/cjs/fetch.js +2 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/cjs/midnight/errors.d.ts +1 -1
- package/lib/cjs/midnight/errors.js +2 -1
- package/lib/cjs/utils.d.ts +5 -1
- package/lib/cjs/utils.js +2 -0
- package/lib/esm/abis.d.ts +5 -1
- package/lib/esm/abis.js +5 -1
- package/lib/esm/actions/bundles/common.d.ts +2 -2
- package/lib/esm/actions/bundles/common.js +10 -2
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +2 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +2 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +2 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +2 -1
- package/lib/esm/augment/AccrualPosition.d.ts +1 -0
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +10 -2
- package/lib/esm/blue/entities.js +5 -1
- package/lib/esm/blue/errors.d.ts +4 -2
- package/lib/esm/blue/errors.js +4 -2
- package/lib/esm/blue/fetch.d.ts +5 -1
- package/lib/esm/blue/fetch.js +5 -1
- package/lib/esm/blue/utils.d.ts +5 -1
- package/lib/esm/blue/utils.js +5 -1
- package/lib/esm/entities/index.d.ts +10 -2
- package/lib/esm/entities/index.js +5 -1
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +4 -3
- package/lib/esm/entities/vaultV1/vaultV1.js +4 -3
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +21 -13
- package/lib/esm/entities/vaultV2/vaultV2.js +31 -13
- package/lib/esm/errors.d.ts +5 -3
- package/lib/esm/errors.js +5 -3
- package/lib/esm/fetch.d.ts +5 -1
- package/lib/esm/fetch.js +5 -1
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/esm/midnight/errors.d.ts +1 -1
- package/lib/esm/midnight/errors.js +1 -1
- package/lib/esm/utils.d.ts +5 -1
- package/lib/esm/utils.js +5 -1
- package/package.json +6 -9
package/MIGRATION-v5-to-v6.md
CHANGED
|
@@ -160,13 +160,15 @@ prerequisite v5 withdrawals did not have. Await `getRequirements()` and satisfy
|
|
|
160
160
|
`buildTx()`, or the withdrawal reverts:
|
|
161
161
|
|
|
162
162
|
- Without signature support, it returns one ERC-20 approval transaction to send first.
|
|
163
|
-
- With `supportSignature: true`, it returns one signable ERC-2612 shares permit
|
|
164
|
-
to `buildTx([sharesPermit])` and it is folded into
|
|
163
|
+
- With `supportSignature: true`, it returns one signable ERC-2612 shares permit when the current
|
|
164
|
+
allowance is below the cap; pass the signature to `buildTx([sharesPermit])` and it is folded into
|
|
165
|
+
the VaultBundlesV1 call. A larger leftover allowance is always reset with an ERC-20 approval
|
|
166
|
+
transaction instead, because VaultBundlesV1 skips a permit whose nonce was already consumed.
|
|
165
167
|
|
|
166
168
|
The allowance is the only cap on the burn, since asset-mode calldata carries no maximum-shares
|
|
167
169
|
argument. `getRequirements()` therefore derives an exact cap from the vault snapshot, the deadline,
|
|
168
170
|
and `slippageTolerance` (default 0.03%), and returns an approval or permit for exactly that amount
|
|
169
|
-
whenever the current allowance differs
|
|
171
|
+
whenever the current allowance differs.
|
|
170
172
|
|
|
171
173
|
`getRequirements()` re-validates the deadline on every call, so a prepared withdrawal reused after
|
|
172
174
|
its deadline throws `ExpiredDeadlineError` rather than returning cached prerequisites.
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
|
+
preLiquidationAbi as bluePreLiquidationAbi,
|
|
5
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
+
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
3
7
|
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesAbi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
4
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
5
9
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
package/lib/cjs/abis.js
CHANGED
|
@@ -19,7 +19,9 @@ Object.defineProperty(exports, "morphoVaultV1AdapterAbi", { enumerable: true, ge
|
|
|
19
19
|
Object.defineProperty(exports, "morphoVaultV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoVaultV1AdapterFactoryAbi; } });
|
|
20
20
|
Object.defineProperty(exports, "permissionedErc20WrapperAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.permissionedErc20WrapperAbi; } });
|
|
21
21
|
Object.defineProperty(exports, "permit2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.permit2Abi; } });
|
|
22
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
22
23
|
Object.defineProperty(exports, "bluePreLiquidationAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.preLiquidationAbi; } });
|
|
24
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
23
25
|
Object.defineProperty(exports, "bluePreLiquidationFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.preLiquidationFactoryAbi; } });
|
|
24
26
|
Object.defineProperty(exports, "vaultV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.vaultV2Abi; } });
|
|
25
27
|
Object.defineProperty(exports, "vaultV2BluePublicAllocatorAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.vaultV2BluePublicAllocatorAbi; } });
|
|
@@ -156,8 +156,8 @@ export declare const normalizeBundlesSignature: (serializedSignature: Hex, onInv
|
|
|
156
156
|
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
157
157
|
* @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
|
|
158
158
|
* @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
|
|
159
|
-
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount
|
|
160
|
-
* deadline, or signature is invalid.
|
|
159
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount,
|
|
160
|
+
* deadline or a supplied action nonce, or signature is invalid.
|
|
161
161
|
* @example
|
|
162
162
|
* ```ts
|
|
163
163
|
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
@@ -235,8 +235,8 @@ exports.normalizeBundlesSignature = normalizeBundlesSignature;
|
|
|
235
235
|
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
236
236
|
* @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
|
|
237
237
|
* @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
|
|
238
|
-
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount
|
|
239
|
-
* deadline, or signature is invalid.
|
|
238
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount,
|
|
239
|
+
* deadline or a supplied action nonce, or signature is invalid.
|
|
240
240
|
* @example
|
|
241
241
|
* ```ts
|
|
242
242
|
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
@@ -323,6 +323,14 @@ const getBundlesSharesPermit = (params) => {
|
|
|
323
323
|
actual: String(requirementSignature.action.args.deadline),
|
|
324
324
|
});
|
|
325
325
|
}
|
|
326
|
+
if (requirementSignature.action.args.nonce != null &&
|
|
327
|
+
requirementSignature.action.args.nonce !== requirementSignature.args.nonce) {
|
|
328
|
+
throw new index_js_2.BundlesPermitMismatchError({
|
|
329
|
+
field: "nonce",
|
|
330
|
+
expected: String(requirementSignature.args.nonce),
|
|
331
|
+
actual: String(requirementSignature.action.args.nonce),
|
|
332
|
+
});
|
|
333
|
+
}
|
|
326
334
|
const signature = (0, exports.normalizeBundlesSignature)(requirementSignature.args.signature);
|
|
327
335
|
return {
|
|
328
336
|
value: requirementSignature.args.amount,
|
|
@@ -41,7 +41,8 @@ export interface VaultV1InKindRedeemParams {
|
|
|
41
41
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
42
42
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
43
43
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
44
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
44
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
45
|
+
* action nonce disagree.
|
|
45
46
|
* @example
|
|
46
47
|
* ```ts
|
|
47
48
|
* import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -33,7 +33,8 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
33
33
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
34
34
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
35
35
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
36
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
36
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
37
|
+
* action nonce disagree.
|
|
37
38
|
* @example
|
|
38
39
|
* ```ts
|
|
39
40
|
* import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -43,7 +43,8 @@ export interface VaultV2InKindRedeemParams {
|
|
|
43
43
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
44
44
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
45
45
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
46
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
46
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
47
|
+
* action nonce disagree.
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -34,7 +34,8 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
34
34
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
35
35
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
36
36
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
37
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
37
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
38
|
+
* action nonce disagree.
|
|
38
39
|
* @example
|
|
39
40
|
* ```ts
|
|
40
41
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -3,6 +3,7 @@ import { fetchAccrualPosition, fetchPreLiquidationPosition } from "@morpho-org/b
|
|
|
3
3
|
declare module "@morpho-org/blue-sdk" {
|
|
4
4
|
namespace AccrualPosition {
|
|
5
5
|
let fetch: typeof fetchAccrualPosition;
|
|
6
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
7
|
let fetchPreLiquidation: typeof fetchPreLiquidationPosition;
|
|
7
8
|
}
|
|
8
9
|
}
|
package/lib/cjs/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,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
|
+
preLiquidationAbi,
|
|
5
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
+
preLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/abis.js
CHANGED
|
@@ -19,7 +19,9 @@ Object.defineProperty(exports, "morphoVaultV1AdapterAbi", { enumerable: true, ge
|
|
|
19
19
|
Object.defineProperty(exports, "morphoVaultV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoVaultV1AdapterFactoryAbi; } });
|
|
20
20
|
Object.defineProperty(exports, "permissionedErc20WrapperAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.permissionedErc20WrapperAbi; } });
|
|
21
21
|
Object.defineProperty(exports, "permit2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.permit2Abi; } });
|
|
22
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
22
23
|
Object.defineProperty(exports, "preLiquidationAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.preLiquidationAbi; } });
|
|
24
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
23
25
|
Object.defineProperty(exports, "preLiquidationFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.preLiquidationFactoryAbi; } });
|
|
24
26
|
Object.defineProperty(exports, "vaultV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.vaultV2Abi; } });
|
|
25
27
|
Object.defineProperty(exports, "vaultV2BluePublicAllocatorAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.vaultV2BluePublicAllocatorAbi; } });
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
|
|
2
|
-
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
IPreLiquidationParams,
|
|
4
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
+
IPreLiquidationPosition, 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, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
|
|
7
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
|
+
PreLiquidationParams,
|
|
9
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
+
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/cjs/blue/entities.js
CHANGED
|
@@ -16,7 +16,9 @@ Object.defineProperty(exports, "Holding", { enumerable: true, get: function () {
|
|
|
16
16
|
Object.defineProperty(exports, "Market", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
|
|
17
17
|
Object.defineProperty(exports, "MarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
|
|
18
18
|
Object.defineProperty(exports, "Position", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
|
|
19
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
19
20
|
Object.defineProperty(exports, "PreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
|
|
21
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
20
22
|
Object.defineProperty(exports, "PreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
|
|
21
23
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
|
|
22
24
|
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return blue_sdk_1.User; } });
|
package/lib/cjs/blue/errors.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
|
-
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedPermitDomainExtensionsError = exports.isUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.getUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownOfFactory = exports.UnknownMarketParamsError = exports.UnknownMarketAllocationError = exports.UnknownFactory = exports.UnknownDataError = exports.UnknownAddressError = exports.RegistryValueAlreadyRegisteredError = exports.InvalidMarketParamsError = exports.InvalidBitLengthError = exports.IncompleteChainRegistryError = exports.DivisionByZeroError = exports.BlueErrors = void 0;
|
|
3
|
+
exports.UnsupportedPermitDomainExtensionsError = exports.isUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownOfFactory = exports.UnknownMarketParamsError = exports.UnknownMarketAllocationError = exports.UnknownFactory = exports.UnknownDataError = exports.UnknownAddressError = exports.RegistryValueAlreadyRegisteredError = exports.InvalidMarketParamsError = exports.InvalidBitLengthError = exports.IncompleteChainRegistryError = exports.DivisionByZeroError = exports.BlueErrors = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
6
6
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return blue_sdk_1.DivisionByZeroError; } });
|
|
@@ -19,11 +19,13 @@ Object.defineProperty(exports, "UnknownTokenPriceError", { enumerable: true, get
|
|
|
19
19
|
Object.defineProperty(exports, "UnknownVaultConfigError", { enumerable: true, get: function () { return blue_sdk_1.UnknownVaultConfigError; } });
|
|
20
20
|
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedChainIdError; } });
|
|
21
21
|
Object.defineProperty(exports, "UnsupportedMarketIrmError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedMarketIrmError; } });
|
|
22
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
22
23
|
Object.defineProperty(exports, "UnsupportedPreLiquidationParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedPreLiquidationParamsError; } });
|
|
23
24
|
Object.defineProperty(exports, "UnsupportedVaultV2AdapterError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedVaultV2AdapterError; } });
|
|
24
25
|
Object.defineProperty(exports, "VaultV2Errors", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Errors; } });
|
|
25
26
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
26
27
|
Object.defineProperty(exports, "getUnsupportedVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.getUnsupportedVaultV2Adapter; } });
|
|
28
|
+
Object.defineProperty(exports, "InvalidNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidNumberError; } });
|
|
27
29
|
Object.defineProperty(exports, "InvalidPermitDomainChainIdError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainChainIdError; } });
|
|
28
30
|
Object.defineProperty(exports, "InvalidPermitDomainVerifyingContractError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainVerifyingContractError; } });
|
|
29
31
|
Object.defineProperty(exports, "isUnknownOfFactoryError", { enumerable: true, get: function () { return blue_sdk_viem_1.isUnknownOfFactoryError; } });
|
package/lib/cjs/blue/fetch.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
fetchPreLiquidationParams,
|
|
4
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
+
fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/fetch.js
CHANGED
|
@@ -13,7 +13,9 @@ Object.defineProperty(exports, "fetchHolding", { enumerable: true, get: function
|
|
|
13
13
|
Object.defineProperty(exports, "fetchMarket", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarket; } });
|
|
14
14
|
Object.defineProperty(exports, "fetchMarketParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarketParams; } });
|
|
15
15
|
Object.defineProperty(exports, "fetchPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPosition; } });
|
|
16
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
16
17
|
Object.defineProperty(exports, "fetchPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationParams; } });
|
|
18
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
17
19
|
Object.defineProperty(exports, "fetchPreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchPreLiquidationPosition; } });
|
|
18
20
|
Object.defineProperty(exports, "fetchToken", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchToken; } });
|
|
19
21
|
Object.defineProperty(exports, "fetchUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchUser; } });
|
package/lib/cjs/blue/utils.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
2
|
+
export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
3
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
|
+
defaultPreLiquidationParamsRegistry,
|
|
5
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
+
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
3
7
|
export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/utils.js
CHANGED
|
@@ -4,7 +4,9 @@ exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = expo
|
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
6
6
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
7
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
7
8
|
Object.defineProperty(exports, "defaultPreLiquidationParamsRegistry", { enumerable: true, get: function () { return blue_sdk_1.defaultPreLiquidationParamsRegistry; } });
|
|
9
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
10
|
Object.defineProperty(exports, "getDefaultPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.getDefaultPreLiquidationParams; } });
|
|
9
11
|
Object.defineProperty(exports, "MarketUtils", { enumerable: true, get: function () { return blue_sdk_1.MarketUtils; } });
|
|
10
12
|
Object.defineProperty(exports, "MathLib", { enumerable: true, get: function () { return blue_sdk_1.MathLib; } });
|
|
@@ -1,5 +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,
|
|
2
|
-
|
|
1
|
+
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
IPreLiquidationParams as IBluePreLiquidationParams,
|
|
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,
|
|
7
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
|
+
PreLiquidationParams as BluePreLiquidationParams,
|
|
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";
|
|
3
11
|
export type { BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, RatifierTreeInput as MidnightRatifierTreeInput, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeDescriptor as MidnightTreeDescriptor, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, } from "@morpho-org/midnight-sdk";
|
|
4
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";
|
|
5
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
@@ -30,7 +30,9 @@ Object.defineProperty(exports, "Holding", { enumerable: true, get: function () {
|
|
|
30
30
|
Object.defineProperty(exports, "BlueMarket", { enumerable: true, get: function () { return blue_sdk_1.Market; } });
|
|
31
31
|
Object.defineProperty(exports, "BlueMarketParams", { enumerable: true, get: function () { return blue_sdk_1.MarketParams; } });
|
|
32
32
|
Object.defineProperty(exports, "BluePosition", { enumerable: true, get: function () { return blue_sdk_1.Position; } });
|
|
33
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
33
34
|
Object.defineProperty(exports, "BluePreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationParams; } });
|
|
35
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
34
36
|
Object.defineProperty(exports, "BluePreLiquidationPosition", { enumerable: true, get: function () { return blue_sdk_1.PreLiquidationPosition; } });
|
|
35
37
|
Object.defineProperty(exports, "Token", { enumerable: true, get: function () { return blue_sdk_1.Token; } });
|
|
36
38
|
Object.defineProperty(exports, "BlueUser", { enumerable: true, get: function () { return blue_sdk_1.User; } });
|
|
@@ -6,14 +6,17 @@ import { type ActionRequirement } from "../../types/index.js";
|
|
|
6
6
|
*
|
|
7
7
|
* The exit burns however many shares the vault prices at execution time, so the share allowance is
|
|
8
8
|
* the only cap on that burn. A leftover allowance above `requiredShareAllowance` therefore does not
|
|
9
|
-
* satisfy the requirement: it is replaced by an approval
|
|
9
|
+
* satisfy the requirement: it is replaced by an onchain approval for exactly the computed cap. Only
|
|
10
|
+
* an insufficient allowance may be raised through an ERC-2612 permit, because VaultBundlesV1 skips a
|
|
11
|
+
* permit whose nonce was already consumed and the leftover allowance would then stay in force.
|
|
10
12
|
*
|
|
11
13
|
* @internal
|
|
12
14
|
*
|
|
13
15
|
* @param viemClient - Client used to read the current share allowance and permit nonce.
|
|
14
16
|
* @param params - Vault snapshot, owner, exact allowance, and deadline values.
|
|
15
17
|
* @returns No requirement when the allowance already equals `requiredShareAllowance`, otherwise one
|
|
16
|
-
*
|
|
18
|
+
* approval that sets it to exactly that cap, or one permit when the allowance is below the cap
|
|
19
|
+
* and signatures are supported.
|
|
17
20
|
* @throws {ExpiredDeadlineError} when the bundles deadline has elapsed.
|
|
18
21
|
* @throws {viem.BaseError} when an allowance or nonce read fails.
|
|
19
22
|
*/
|
|
@@ -13,14 +13,17 @@ const index_js_3 = require("../../types/index.js");
|
|
|
13
13
|
*
|
|
14
14
|
* The exit burns however many shares the vault prices at execution time, so the share allowance is
|
|
15
15
|
* the only cap on that burn. A leftover allowance above `requiredShareAllowance` therefore does not
|
|
16
|
-
* satisfy the requirement: it is replaced by an approval
|
|
16
|
+
* satisfy the requirement: it is replaced by an onchain approval for exactly the computed cap. Only
|
|
17
|
+
* an insufficient allowance may be raised through an ERC-2612 permit, because VaultBundlesV1 skips a
|
|
18
|
+
* permit whose nonce was already consumed and the leftover allowance would then stay in force.
|
|
17
19
|
*
|
|
18
20
|
* @internal
|
|
19
21
|
*
|
|
20
22
|
* @param viemClient - Client used to read the current share allowance and permit nonce.
|
|
21
23
|
* @param params - Vault snapshot, owner, exact allowance, and deadline values.
|
|
22
24
|
* @returns No requirement when the allowance already equals `requiredShareAllowance`, otherwise one
|
|
23
|
-
*
|
|
25
|
+
* approval that sets it to exactly that cap, or one permit when the allowance is below the cap
|
|
26
|
+
* and signatures are supported.
|
|
24
27
|
* @throws {ExpiredDeadlineError} when the bundles deadline has elapsed.
|
|
25
28
|
* @throws {viem.BaseError} when an allowance or nonce read fails.
|
|
26
29
|
*/
|
|
@@ -42,7 +45,9 @@ const getVaultBundlesSharesRequirements = async (viemClient, params) => {
|
|
|
42
45
|
// so only an exact match skips the approval or permit that resets it to the computed cap.
|
|
43
46
|
if (allowance === params.requiredShareAllowance)
|
|
44
47
|
return [];
|
|
45
|
-
|
|
48
|
+
// An oversized allowance is only ever lowered onchain: `TokenLib.submitPermit` skips a permit
|
|
49
|
+
// whose nonce was already consumed, which would silently leave the stale cap in force.
|
|
50
|
+
if (allowance < params.requiredShareAllowance && params.supportSignature) {
|
|
46
51
|
const nonce = await (0, actions_1.readContract)(viemClient, {
|
|
47
52
|
address: params.vaultData.address,
|
|
48
53
|
abi: blue_sdk_viem_1.erc2612Abi,
|
|
@@ -112,9 +112,10 @@ export interface VaultV1Actions {
|
|
|
112
112
|
* defaults to two hours from handle creation.
|
|
113
113
|
* @returns A frozen handle with lazy `getRequirements()` and synchronous `buildTx(signatures?)`,
|
|
114
114
|
* which returns a deep-frozen `Transaction<VaultV1WithdrawAction>`. Requirements are empty
|
|
115
|
-
* when the allowance equals the cap;
|
|
116
|
-
*
|
|
117
|
-
*
|
|
115
|
+
* when the allowance equals the cap; an oversized allowance is always reset with an exact
|
|
116
|
+
* onchain approval, and an insufficient one is raised by an approval or, with signature
|
|
117
|
+
* support, an ERC-2612 request. The cap stays pinned to the first resolution while each call
|
|
118
|
+
* re-reads the allowance. Confirm the approval or pass its signed permit to `buildTx`.
|
|
118
119
|
* @throws {ChainIdMismatchError} when the connected client targets another chain.
|
|
119
120
|
* @throws {NonPositiveInputError} when `amount` or the computed share cap is not positive.
|
|
120
121
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
@@ -187,9 +187,10 @@ class MorphoVaultV1 {
|
|
|
187
187
|
supportSignature: this.client.options.supportSignature,
|
|
188
188
|
});
|
|
189
189
|
const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
expectedRequirement =
|
|
191
|
+
signatureRequirement?.action.type === "permit"
|
|
192
|
+
? signatureRequirement.action
|
|
193
|
+
: undefined;
|
|
193
194
|
return requirements;
|
|
194
195
|
},
|
|
195
196
|
buildTx: (signatures) => {
|
|
@@ -115,9 +115,10 @@ export interface VaultV2Actions {
|
|
|
115
115
|
* defaults to two hours from handle creation.
|
|
116
116
|
* @returns A frozen handle with lazy `getRequirements()` and synchronous `buildTx(signatures?)`,
|
|
117
117
|
* which returns a deep-frozen `Transaction<VaultV2WithdrawAction>`. Requirements are empty
|
|
118
|
-
* when the allowance equals the cap;
|
|
119
|
-
*
|
|
120
|
-
*
|
|
118
|
+
* when the allowance equals the cap; an oversized allowance is always reset with an exact
|
|
119
|
+
* onchain approval, and an insufficient one is raised by an approval or, with signature
|
|
120
|
+
* support, an ERC-2612 request. The cap stays pinned to the first resolution while each call
|
|
121
|
+
* re-reads the allowance. Confirm the approval or pass its signed permit to `buildTx`.
|
|
121
122
|
* @throws {ChainIdMismatchError} when the connected client targets another chain.
|
|
122
123
|
* @throws {NonPositiveInputError} when `amount` or the computed share cap is not positive.
|
|
123
124
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
@@ -320,9 +321,11 @@ export interface VaultV2Actions {
|
|
|
320
321
|
* and permit nonce are read on-chain.
|
|
321
322
|
*
|
|
322
323
|
* The SDK derives a conservative lower bound on the realized exit share price from the snapshot
|
|
323
|
-
* and `slippageTolerance
|
|
324
|
-
*
|
|
325
|
-
*
|
|
324
|
+
* and `slippageTolerance`: the floor is priced off whichever of the raw snapshot or its accrual
|
|
325
|
+
* to `now` burns more shares, so neither pending fee mints nor interest the chain has not yet
|
|
326
|
+
* accrued can lift it above the realized price. A supplied `minSharePriceE27` replaces the
|
|
327
|
+
* tolerance-derived bound (it may be tighter or looser) but must be at least the floor derived
|
|
328
|
+
* at `MAX_SLIPPAGE_TOLERANCE`, so an override can never disable meaningful protection.
|
|
326
329
|
* The bound rejects a share price drop, a penalty increase, and liquidity shifting from the
|
|
327
330
|
* penalty-free leg to the penalised leg. It does **not** cover the referral fee, which the
|
|
328
331
|
* contract deducts afterwards.
|
|
@@ -332,16 +335,21 @@ export interface VaultV2Actions {
|
|
|
332
335
|
* send-shares gate is arbitrary code re-evaluated after each penalty burn. The SDK also does not
|
|
333
336
|
* validate the user's share balance. Per-market penalties and each vault withdrawal round the
|
|
334
337
|
* share burn up independently, so the exit can burn marginally more shares than `exitAssets` alone
|
|
335
|
-
* implies; size `exitAssets` a small buffer below `vault.previewRedeem(sharesHeld)`
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
+
* implies; size `exitAssets` a small buffer below `vault.previewRedeem(sharesHeld)` so a
|
|
339
|
+
* full-balance exit does not revert for insufficient shares. The approved share allowance this
|
|
340
|
+
* handle returns covers a burn at least one `slippageTolerance` step below the price floor
|
|
341
|
+
* whenever the floor exceeds one RAY unit and, in any case, at least one share above the burn
|
|
342
|
+
* at the floor, so a price within that headroom below the floor reverts on the contract's
|
|
343
|
+
* `minSharePriceE27` check rather than on the allowance; a deeper drop can still surface as an
|
|
344
|
+
* ERC-20 allowance underflow.
|
|
338
345
|
*
|
|
339
346
|
* Idle balance, penalty, adapter positions, and market liquidity can drift after the snapshot, so
|
|
340
347
|
* an on-chain revert remains possible if vault state changes between preparation and inclusion.
|
|
341
|
-
* A fee-recipient `userAddress` gets a floor from the
|
|
342
|
-
* and a guard against fee mints reaching the lower burn
|
|
343
|
-
* includes the projected fee shares through that same
|
|
344
|
-
* handle creation are rejected, so the guard and
|
|
348
|
+
* A fee-recipient `userAddress` gets a floor from the larger of the raw snapshot burn and the
|
|
349
|
+
* `now` burn net of its own fee mints, and a guard against fee mints reaching the lower burn
|
|
350
|
+
* bound by the deadline. Its allowance includes the projected fee shares through that same
|
|
351
|
+
* deadline. Deadlines beyond one year after handle creation are rejected, so the guard and
|
|
352
|
+
* allowance cover the whole accepted window.
|
|
345
353
|
*
|
|
346
354
|
* @param params - Force withdrawal parameters.
|
|
347
355
|
* @param params.exitAssets - Penalty-inclusive, asset-denominated amount to exit.
|
|
@@ -190,9 +190,10 @@ class MorphoVaultV2 {
|
|
|
190
190
|
supportSignature: this.client.options.supportSignature,
|
|
191
191
|
});
|
|
192
192
|
const signatureRequirement = requirements.find(index_js_3.isRequirementSignature);
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
expectedRequirement =
|
|
194
|
+
signatureRequirement?.action.type === "permit"
|
|
195
|
+
? signatureRequirement.action
|
|
196
|
+
: undefined;
|
|
196
197
|
return requirements;
|
|
197
198
|
},
|
|
198
199
|
buildTx: (signatures) => {
|
|
@@ -550,10 +551,19 @@ class MorphoVaultV2 {
|
|
|
550
551
|
}
|
|
551
552
|
const projectionTimestamp = deadline;
|
|
552
553
|
// VaultExitBundlesV1 measures shares as `sharesBefore - balanceAfter`; its first withdrawal
|
|
553
|
-
// accrues the vault before burning.
|
|
554
|
-
//
|
|
554
|
+
// accrues the vault before burning. The realized price sits between the raw snapshot price
|
|
555
|
+
// (pending fee mints not yet diluting it) and the `now` projection (interest the chain may not
|
|
556
|
+
// have accrued yet, e.g. when the wall clock runs ahead of the chain). Price the floor off the
|
|
557
|
+
// larger *net* burn of the two endpoints — the raw snapshot mints no fee shares, the `now`
|
|
558
|
+
// accrual mints `feeSharesNow` — so it never exceeds either, and use the projected deadline
|
|
559
|
+
// accrual for the fee-mint guard.
|
|
555
560
|
const { vault: nowVaultData } = vaultData.accrueInterest(blue_sdk_1.MathLib.max(now, vaultData.lastUpdate));
|
|
556
561
|
const { vault: projectedVaultData } = vaultData.accrueInterest(blue_sdk_1.MathLib.max(projectionTimestamp, vaultData.lastUpdate));
|
|
562
|
+
const sharesBurntRaw = (0, index_js_2.computeVaultV2ForceWithdrawSharesBurnt)({
|
|
563
|
+
vaultData,
|
|
564
|
+
deadlineVaultData: vaultData,
|
|
565
|
+
plan,
|
|
566
|
+
});
|
|
557
567
|
const sharesBurntNow = (0, index_js_2.computeVaultV2ForceWithdrawSharesBurnt)({
|
|
558
568
|
vaultData: nowVaultData,
|
|
559
569
|
deadlineVaultData: nowVaultData,
|
|
@@ -584,13 +594,13 @@ class MorphoVaultV2 {
|
|
|
584
594
|
});
|
|
585
595
|
}
|
|
586
596
|
// sharesBurntNow ≥ minSharesBurntNow ≥ minSharesBurntProjected > feeSharesProjected ≥ feeSharesNow
|
|
587
|
-
const
|
|
597
|
+
const sharesBurntForFloor = blue_sdk_1.MathLib.max(sharesBurntRaw, sharesBurntNow - feeSharesNow);
|
|
588
598
|
if (minSharePriceE27Override != null) {
|
|
589
599
|
// The maximum-slippage threshold only bounds the override; unlike the transaction floor it
|
|
590
600
|
// may round to zero, in which case every positive override is acceptable.
|
|
591
601
|
const minAllowedSharePriceE27 = (0, morpho_ts_1._try)(() => (0, index_js_2.computeMinForceWithdrawSharePrice)({
|
|
592
602
|
withdrawnAssets: plan.withdrawnAssets,
|
|
593
|
-
sharesBurnt:
|
|
603
|
+
sharesBurnt: sharesBurntForFloor,
|
|
594
604
|
slippageTolerance: index_js_2.MAX_SLIPPAGE_TOLERANCE,
|
|
595
605
|
}), index_js_3.VaultV2ForceWithdrawZeroSharePriceError) ?? 1n;
|
|
596
606
|
if (minSharePriceE27Override < minAllowedSharePriceE27) {
|
|
@@ -603,7 +613,7 @@ class MorphoVaultV2 {
|
|
|
603
613
|
const minSharePriceE27 = minSharePriceE27Override ??
|
|
604
614
|
(0, index_js_2.computeMinForceWithdrawSharePrice)({
|
|
605
615
|
withdrawnAssets: plan.withdrawnAssets,
|
|
606
|
-
sharesBurnt:
|
|
616
|
+
sharesBurnt: sharesBurntForFloor,
|
|
607
617
|
slippageTolerance,
|
|
608
618
|
});
|
|
609
619
|
// The floor is deliberately *not* capped at `MAX_ABSOLUTE_SHARE_PRICE` (100 assets/share):
|
|
@@ -611,11 +621,19 @@ class MorphoVaultV2 {
|
|
|
611
621
|
// with no real protection. Its two sibling `computeMin*SharePrice` helpers cap nothing either —
|
|
612
622
|
// only the `computeMax*` ones do, where capping relaxes an upper bound and is safe.
|
|
613
623
|
(0, validate_js_1.validateUint256Field)("minSharePriceE27", minSharePriceE27);
|
|
614
|
-
//
|
|
615
|
-
//
|
|
616
|
-
//
|
|
617
|
-
|
|
618
|
-
|
|
624
|
+
// The allowance is only a spend cap, never the price protection: the bundle checks
|
|
625
|
+
// `minSharePriceE27` after its last withdrawal, so an allowance sized exactly to the floor
|
|
626
|
+
// underflows `_spendAllowance` (panic 0x11) on a below-floor price before that check runs. Size
|
|
627
|
+
// it for a price at least one tolerance step below the floor so the miss surfaces as the
|
|
628
|
+
// bundle's own revert instead, and, in any case, for at least one share above the at-floor
|
|
629
|
+
// burn — a burn of `atFloor + 1` shares prices strictly below the floor since
|
|
630
|
+
// `atFloor >= exitAssets * RAY / floor`. The `minSharePriceE27 - 1` branch keeps the
|
|
631
|
+
// denominator strictly below the floor whenever the floor exceeds 1, so even
|
|
632
|
+
// `slippageTolerance: 0n` leaves price-space headroom; a deeper drop still exhausts the
|
|
633
|
+
// allowance first. Add the fee shares the first withdrawal mints since the burn measured
|
|
634
|
+
// on-chain includes them. Saturated at `maxUint256` as an ABI-slot guard.
|
|
635
|
+
const allowanceSharePriceE27 = blue_sdk_1.MathLib.max(blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.mulDivDown(minSharePriceE27, blue_sdk_1.MathLib.WAD - slippageTolerance, blue_sdk_1.MathLib.WAD), minSharePriceE27 - 1n), 1n);
|
|
636
|
+
const requiredShareAllowance = blue_sdk_1.MathLib.min(blue_sdk_1.MathLib.max(blue_sdk_1.MathLib.mulDivUp(exitAssets, blue_sdk_1.MathLib.RAY, allowanceSharePriceE27), blue_sdk_1.MathLib.mulDivUp(exitAssets, blue_sdk_1.MathLib.RAY, minSharePriceE27) + 1n) + feeSharesProjected, viem_1.maxUint256);
|
|
619
637
|
const vaultExitBundlesV1 = (0, morpho_ts_1.getChainAddress)(this.chainId, "bundles.vaultExitBundlesV1");
|
|
620
638
|
return {
|
|
621
639
|
getRequirements: async () => {
|
package/lib/cjs/errors.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
4
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
5
7
|
export { _try, DivisionByZeroError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|