@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/lib/cjs/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = exports.BlueErrors = void 0;
|
|
3
|
+
exports.RegistryValueAlreadyRegisteredError = exports.NegativeValueError = exports.InvalidBitLengthError = exports.DivisionByZeroError = exports._try = exports.UnknownMidnightCollateralIndexError = exports.MidnightTickOutOfRangeError = exports.MidnightSettlementFeeExceedsPriceError = exports.MidnightPriceGreaterThanOneError = exports.MidnightPayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidMidnightTypedDataSignatureError = exports.InvalidMidnightTreeHeightError = exports.InvalidMidnightTreeError = exports.InvalidMidnightTickSpacingError = exports.InvalidMidnightPositionLossFactorError = exports.InvalidMidnightPositionAccrualTimestampError = exports.InvalidMidnightPositionAccrualStateError = exports.InvalidMidnightOfferParameterError = exports.InvalidMidnightOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMidnightMarketParameterError = exports.InvalidMidnightEcrecoverSignatureVError = exports.MidnightChainIdMismatchError = exports.UnsupportedPermitDomainExtensionsError = exports.isBlueUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getBlueUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedBlueVaultV2AdapterError = exports.UnsupportedBluePreLiquidationParamsError = exports.UnsupportedBlueMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownBlueVaultConfigError = exports.UnknownBlueTokenPriceError = exports.UnknownBlueTokenError = exports.UnknownBlueOfFactory = exports.UnknownBlueMarketParamsError = exports.UnknownBlueMarketAllocationError = exports.UnknownBlueFactory = exports.UnknownBlueDataError = exports.UnknownAddressError = exports.InvalidBlueMarketParamsError = exports.IncompleteChainRegistryError = 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, "IncompleteChainRegistryError", { enumerable: true, get: function () { return blue_sdk_1.IncompleteChainRegistryError; } });
|
|
@@ -16,11 +16,13 @@ Object.defineProperty(exports, "UnknownBlueTokenPriceError", { enumerable: true,
|
|
|
16
16
|
Object.defineProperty(exports, "UnknownBlueVaultConfigError", { enumerable: true, get: function () { return blue_sdk_1.UnknownVaultConfigError; } });
|
|
17
17
|
Object.defineProperty(exports, "UnsupportedChainIdError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedChainIdError; } });
|
|
18
18
|
Object.defineProperty(exports, "UnsupportedBlueMarketIrmError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedMarketIrmError; } });
|
|
19
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
19
20
|
Object.defineProperty(exports, "UnsupportedBluePreLiquidationParamsError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedPreLiquidationParamsError; } });
|
|
20
21
|
Object.defineProperty(exports, "UnsupportedBlueVaultV2AdapterError", { enumerable: true, get: function () { return blue_sdk_1.UnsupportedVaultV2AdapterError; } });
|
|
21
22
|
Object.defineProperty(exports, "VaultV2Errors", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Errors; } });
|
|
22
23
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
23
24
|
Object.defineProperty(exports, "getBlueUnsupportedVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.getUnsupportedVaultV2Adapter; } });
|
|
25
|
+
Object.defineProperty(exports, "InvalidNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidNumberError; } });
|
|
24
26
|
Object.defineProperty(exports, "InvalidPermitDomainChainIdError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainChainIdError; } });
|
|
25
27
|
Object.defineProperty(exports, "InvalidPermitDomainVerifyingContractError", { enumerable: true, get: function () { return blue_sdk_viem_1.InvalidPermitDomainVerifyingContractError; } });
|
|
26
28
|
Object.defineProperty(exports, "isBlueUnknownOfFactoryError", { enumerable: true, get: function () { return blue_sdk_viem_1.isUnknownOfFactoryError; } });
|
|
@@ -29,6 +31,7 @@ var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
|
29
31
|
Object.defineProperty(exports, "MidnightChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
30
32
|
Object.defineProperty(exports, "InvalidMidnightEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
|
|
31
33
|
Object.defineProperty(exports, "InvalidMidnightMarketParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMarketParameterError; } });
|
|
34
|
+
Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiQuoteTargetError; } });
|
|
32
35
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
33
36
|
Object.defineProperty(exports, "InvalidMidnightOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
34
37
|
Object.defineProperty(exports, "InvalidMidnightOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
package/lib/cjs/fetch.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
1
|
+
export { fetchAccrualPosition as fetchBlueAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
2
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/cjs/fetch.js
CHANGED
|
@@ -13,7 +13,9 @@ Object.defineProperty(exports, "fetchHolding", { enumerable: true, get: function
|
|
|
13
13
|
Object.defineProperty(exports, "fetchBlueMarket", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarket; } });
|
|
14
14
|
Object.defineProperty(exports, "fetchBlueMarketParams", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchMarketParams; } });
|
|
15
15
|
Object.defineProperty(exports, "fetchBluePosition", { 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, "fetchBluePreLiquidationParams", { 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, "fetchBluePreLiquidationPosition", { 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, "fetchBlueUser", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchUser; } });
|
|
@@ -98,15 +98,21 @@ function previewVaultV2ForceWithdraw(vaultData, params) {
|
|
|
98
98
|
// zero (`VaultV2ForceWithdrawZeroSharePriceError`) — a degenerate vault (e.g. `totalSupply`
|
|
99
99
|
// dwarfing `totalAssets`) offers no price protection at all. Screen at the entity's default
|
|
100
100
|
// `DEFAULT_SLIPPAGE_TOLERANCE`, not slippage-free, against the same burn upper bound the entity
|
|
101
|
-
// divides by (
|
|
102
|
-
// realized price is a single RAY-unit, yet
|
|
103
|
-
// to zero — so the entity would reject
|
|
101
|
+
// divides by (the larger of the raw snapshot burn and the net burn accrued to `timestamp` like
|
|
102
|
+
// the plan): a tolerance-free screen clears an exit whose realized price is a single RAY-unit, yet
|
|
103
|
+
// the default tolerance scales that below 1 and rounds it to zero — so the entity would reject
|
|
104
|
+
// with `VaultV2ForceWithdrawZeroSharePriceError` the very
|
|
104
105
|
// `exitAssets` this preview handed back. A caller passing a larger tolerance still relies on the
|
|
105
106
|
// entity's own guard. The entity validates this derived value with
|
|
106
107
|
// `validateUint256Field("minSharePriceE27")`, which throws `InputExceedsMaxError` when it
|
|
107
108
|
// cannot fit uint256.
|
|
108
109
|
const { vault: accruedVaultData } = vaultData.accrueInterest(blue_sdk_1.MathLib.max(timestamp, vaultData.lastUpdate));
|
|
109
|
-
const
|
|
110
|
+
const sharesBurntRaw = (0, vaultV2ForceWithdrawPlan_js_1.computeVaultV2ForceWithdrawSharesBurnt)({
|
|
111
|
+
vaultData,
|
|
112
|
+
deadlineVaultData: vaultData,
|
|
113
|
+
plan,
|
|
114
|
+
});
|
|
115
|
+
const sharesBurntAccrued = (0, vaultV2ForceWithdrawPlan_js_1.computeVaultV2ForceWithdrawSharesBurnt)({
|
|
110
116
|
vaultData: accruedVaultData,
|
|
111
117
|
deadlineVaultData: accruedVaultData,
|
|
112
118
|
plan,
|
|
@@ -135,7 +141,7 @@ function previewVaultV2ForceWithdraw(vaultData, params) {
|
|
|
135
141
|
return undefined;
|
|
136
142
|
}
|
|
137
143
|
}
|
|
138
|
-
const sharesBurntForFloor =
|
|
144
|
+
const sharesBurntForFloor = blue_sdk_1.MathLib.max(sharesBurntRaw, sharesBurntAccrued - feeShares);
|
|
139
145
|
const defaultMinSharePriceE27 = sharesBurntForFloor > 0n
|
|
140
146
|
? blue_sdk_1.MathLib.mulDivDown(plan.withdrawnAssets, blue_sdk_1.MathLib.wToRay(blue_sdk_1.MathLib.WAD - blue_sdk_1.DEFAULT_SLIPPAGE_TOLERANCE), sharesBurntForFloor)
|
|
141
147
|
: 0n;
|
|
@@ -192,23 +192,34 @@ export declare function computeVaultV2ForceWithdrawPlan(params: {
|
|
|
192
192
|
* The result is the **denominator of {@link computeMinForceWithdrawSharePrice}** — the largest share
|
|
193
193
|
* burn the realized exit price is measured against. It takes the max over the two supplied snapshots
|
|
194
194
|
* because interest lowers the burn while management fees raise it, so neither snapshot alone bounds
|
|
195
|
-
* execution. The entity passes
|
|
196
|
-
* underestimates the burn a stale fee-bearing vault realizes —
|
|
197
|
-
* management fees before burning shares —
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
*
|
|
195
|
+
* execution. The entity passes the raw `lastUpdate` snapshot and the same vault accrued to `now`
|
|
196
|
+
* (execution time): the raw snapshot underestimates the burn a stale fee-bearing vault realizes —
|
|
197
|
+
* the first withdrawal accrues pending management fees before burning shares — while the `now`
|
|
198
|
+
* accrual underestimates it when it projects interest the chain has not realized (a wall clock
|
|
199
|
+
* running ahead of the chain, or a capped `maxRate`); either alone would lift the floor above the
|
|
200
|
+
* faithful price and trip `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`,
|
|
201
|
+
* tracks execution without letting a long deadline silently weaken the guard; `slippageTolerance`
|
|
202
|
+
* absorbs the residual drift until inclusion.
|
|
201
203
|
*
|
|
202
|
-
* This is **not** the share allowance to authorize. The
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* `
|
|
206
|
-
*
|
|
204
|
+
* This is **not** the share allowance to authorize. The contract measures the *net* burn, which
|
|
205
|
+
* fee mints to `owner` shrink, and the raw snapshot mints none while the `now` accrual mints
|
|
206
|
+
* `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`; so the
|
|
207
|
+
* entity nets each endpoint before taking the max (`max(burnRaw, burnNow - feeSharesNow)`) rather
|
|
208
|
+
* than subtracting the `now` fee from a gross max. The allowance is
|
|
209
|
+
* `min(max(mulDivUp(exitAssets, RAY, max(min(mulDivDown(minSharePriceE27, WAD - slippageTolerance,
|
|
210
|
+
* WAD), minSharePriceE27 - 1), 1)), mulDivUp(exitAssets, RAY, minSharePriceE27) + 1)
|
|
211
|
+
* + computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: deadline }),
|
|
212
|
+
* maxUint256)`: the permit pays for the *gross* burn, covering a burn at least one tolerance step
|
|
213
|
+
* below the floor whenever the floor exceeds one RAY unit and, in any case, at least one share
|
|
214
|
+
* above the burn at the floor, so a price within that headroom below the floor reverts on the
|
|
215
|
+
* contract's `minSharePriceE27` check rather than on the allowance; a deeper drop can still
|
|
216
|
+
* surface as an ERC-20 allowance underflow.
|
|
207
217
|
*
|
|
208
218
|
* @param params - Share-bound inputs.
|
|
209
219
|
* @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
|
|
210
220
|
* @param params.deadlineVaultData - The same vault accrued to a second timestamp; the max of the two
|
|
211
|
-
* share burns is returned. The entity
|
|
221
|
+
* share burns is returned. The entity calls this twice — the raw snapshot for both parameters,
|
|
222
|
+
* then the `now` accrual for both — and nets each result before taking the max.
|
|
212
223
|
* @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
|
|
213
224
|
* @returns An upper bound, in vault shares, of what the exit burns.
|
|
214
225
|
* @example
|
|
@@ -220,7 +231,12 @@ export declare function computeVaultV2ForceWithdrawPlan(params: {
|
|
|
220
231
|
* } from "@morpho-org/morpho-sdk";
|
|
221
232
|
*
|
|
222
233
|
* const { vault: nowVaultData } = vaultData.accrueInterest(now);
|
|
223
|
-
* const
|
|
234
|
+
* const sharesBurntRaw = computeVaultV2ForceWithdrawSharesBurnt({
|
|
235
|
+
* vaultData,
|
|
236
|
+
* deadlineVaultData: vaultData,
|
|
237
|
+
* plan,
|
|
238
|
+
* });
|
|
239
|
+
* const sharesBurntNow = computeVaultV2ForceWithdrawSharesBurnt({
|
|
224
240
|
* vaultData: nowVaultData,
|
|
225
241
|
* deadlineVaultData: nowVaultData,
|
|
226
242
|
* plan,
|
|
@@ -230,9 +246,26 @@ export declare function computeVaultV2ForceWithdrawPlan(params: {
|
|
|
230
246
|
* owner,
|
|
231
247
|
* timestamp: now,
|
|
232
248
|
* });
|
|
233
|
-
* const sharesBurntForFloor =
|
|
249
|
+
* const sharesBurntForFloor = MathLib.max(
|
|
250
|
+
* sharesBurntRaw,
|
|
251
|
+
* sharesBurntNow - feeSharesNow,
|
|
252
|
+
* );
|
|
253
|
+
* const allowanceSharePriceE27 = MathLib.max(
|
|
254
|
+
* MathLib.min(
|
|
255
|
+
* MathLib.mulDivDown(
|
|
256
|
+
* minSharePriceE27,
|
|
257
|
+
* MathLib.WAD - slippageTolerance,
|
|
258
|
+
* MathLib.WAD,
|
|
259
|
+
* ),
|
|
260
|
+
* minSharePriceE27 - 1n,
|
|
261
|
+
* ),
|
|
262
|
+
* 1n,
|
|
263
|
+
* );
|
|
234
264
|
* const requiredShareAllowance = MathLib.min(
|
|
235
|
-
* MathLib.
|
|
265
|
+
* MathLib.max(
|
|
266
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27),
|
|
267
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n,
|
|
268
|
+
* ) +
|
|
236
269
|
* computeVaultV2ForceWithdrawFeeSharesMinted({
|
|
237
270
|
* vaultData,
|
|
238
271
|
* owner,
|
|
@@ -269,23 +269,34 @@ function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
269
269
|
* The result is the **denominator of {@link computeMinForceWithdrawSharePrice}** — the largest share
|
|
270
270
|
* burn the realized exit price is measured against. It takes the max over the two supplied snapshots
|
|
271
271
|
* because interest lowers the burn while management fees raise it, so neither snapshot alone bounds
|
|
272
|
-
* execution. The entity passes
|
|
273
|
-
* underestimates the burn a stale fee-bearing vault realizes —
|
|
274
|
-
* management fees before burning shares —
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
272
|
+
* execution. The entity passes the raw `lastUpdate` snapshot and the same vault accrued to `now`
|
|
273
|
+
* (execution time): the raw snapshot underestimates the burn a stale fee-bearing vault realizes —
|
|
274
|
+
* the first withdrawal accrues pending management fees before burning shares — while the `now`
|
|
275
|
+
* accrual underestimates it when it projects interest the chain has not realized (a wall clock
|
|
276
|
+
* running ahead of the chain, or a capped `maxRate`); either alone would lift the floor above the
|
|
277
|
+
* faithful price and trip `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`,
|
|
278
|
+
* tracks execution without letting a long deadline silently weaken the guard; `slippageTolerance`
|
|
279
|
+
* absorbs the residual drift until inclusion.
|
|
278
280
|
*
|
|
279
|
-
* This is **not** the share allowance to authorize. The
|
|
280
|
-
*
|
|
281
|
-
*
|
|
282
|
-
* `
|
|
283
|
-
*
|
|
281
|
+
* This is **not** the share allowance to authorize. The contract measures the *net* burn, which
|
|
282
|
+
* fee mints to `owner` shrink, and the raw snapshot mints none while the `now` accrual mints
|
|
283
|
+
* `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`; so the
|
|
284
|
+
* entity nets each endpoint before taking the max (`max(burnRaw, burnNow - feeSharesNow)`) rather
|
|
285
|
+
* than subtracting the `now` fee from a gross max. The allowance is
|
|
286
|
+
* `min(max(mulDivUp(exitAssets, RAY, max(min(mulDivDown(minSharePriceE27, WAD - slippageTolerance,
|
|
287
|
+
* WAD), minSharePriceE27 - 1), 1)), mulDivUp(exitAssets, RAY, minSharePriceE27) + 1)
|
|
288
|
+
* + computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: deadline }),
|
|
289
|
+
* maxUint256)`: the permit pays for the *gross* burn, covering a burn at least one tolerance step
|
|
290
|
+
* below the floor whenever the floor exceeds one RAY unit and, in any case, at least one share
|
|
291
|
+
* above the burn at the floor, so a price within that headroom below the floor reverts on the
|
|
292
|
+
* contract's `minSharePriceE27` check rather than on the allowance; a deeper drop can still
|
|
293
|
+
* surface as an ERC-20 allowance underflow.
|
|
284
294
|
*
|
|
285
295
|
* @param params - Share-bound inputs.
|
|
286
296
|
* @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
|
|
287
297
|
* @param params.deadlineVaultData - The same vault accrued to a second timestamp; the max of the two
|
|
288
|
-
* share burns is returned. The entity
|
|
298
|
+
* share burns is returned. The entity calls this twice — the raw snapshot for both parameters,
|
|
299
|
+
* then the `now` accrual for both — and nets each result before taking the max.
|
|
289
300
|
* @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
|
|
290
301
|
* @returns An upper bound, in vault shares, of what the exit burns.
|
|
291
302
|
* @example
|
|
@@ -297,7 +308,12 @@ function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
297
308
|
* } from "@morpho-org/morpho-sdk";
|
|
298
309
|
*
|
|
299
310
|
* const { vault: nowVaultData } = vaultData.accrueInterest(now);
|
|
300
|
-
* const
|
|
311
|
+
* const sharesBurntRaw = computeVaultV2ForceWithdrawSharesBurnt({
|
|
312
|
+
* vaultData,
|
|
313
|
+
* deadlineVaultData: vaultData,
|
|
314
|
+
* plan,
|
|
315
|
+
* });
|
|
316
|
+
* const sharesBurntNow = computeVaultV2ForceWithdrawSharesBurnt({
|
|
301
317
|
* vaultData: nowVaultData,
|
|
302
318
|
* deadlineVaultData: nowVaultData,
|
|
303
319
|
* plan,
|
|
@@ -307,9 +323,26 @@ function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
307
323
|
* owner,
|
|
308
324
|
* timestamp: now,
|
|
309
325
|
* });
|
|
310
|
-
* const sharesBurntForFloor =
|
|
326
|
+
* const sharesBurntForFloor = MathLib.max(
|
|
327
|
+
* sharesBurntRaw,
|
|
328
|
+
* sharesBurntNow - feeSharesNow,
|
|
329
|
+
* );
|
|
330
|
+
* const allowanceSharePriceE27 = MathLib.max(
|
|
331
|
+
* MathLib.min(
|
|
332
|
+
* MathLib.mulDivDown(
|
|
333
|
+
* minSharePriceE27,
|
|
334
|
+
* MathLib.WAD - slippageTolerance,
|
|
335
|
+
* MathLib.WAD,
|
|
336
|
+
* ),
|
|
337
|
+
* minSharePriceE27 - 1n,
|
|
338
|
+
* ),
|
|
339
|
+
* 1n,
|
|
340
|
+
* );
|
|
311
341
|
* const requiredShareAllowance = MathLib.min(
|
|
312
|
-
* MathLib.
|
|
342
|
+
* MathLib.max(
|
|
343
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27),
|
|
344
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n,
|
|
345
|
+
* ) +
|
|
313
346
|
* computeVaultV2ForceWithdrawFeeSharesMinted({
|
|
314
347
|
* vaultData,
|
|
315
348
|
* owner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
|
|
3
|
+
exports.UnknownCollateralIndexError = exports.TickOutOfRangeError = exports.SettlementFeeExceedsPriceError = exports.PriceGreaterThanOneError = exports.PayloadDecodeError = exports.MidnightMempoolValidationError = exports.MidnightApiError = exports.InvalidTypedDataSignatureError = exports.InvalidTreeHeightError = exports.InvalidTreeError = exports.InvalidTickSpacingError = exports.InvalidPositionLossFactorError = exports.InvalidPositionAccrualTimestampError = exports.InvalidPositionAccrualStateError = exports.InvalidOfferParameterError = exports.InvalidOfferGroupError = exports.InvalidMidnightApiResponseError = exports.InvalidMidnightApiQuoteTargetError = exports.InvalidMarketParameterError = exports.InvalidEcrecoverSignatureVError = exports.ChainIdMismatchError = void 0;
|
|
4
4
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
5
|
Object.defineProperty(exports, "ChainIdMismatchError", { enumerable: true, get: function () { return midnight_sdk_1.ChainIdMismatchError; } });
|
|
6
6
|
Object.defineProperty(exports, "InvalidEcrecoverSignatureVError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidEcrecoverSignatureVError; } });
|
|
7
7
|
Object.defineProperty(exports, "InvalidMarketParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMarketParameterError; } });
|
|
8
|
+
Object.defineProperty(exports, "InvalidMidnightApiQuoteTargetError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiQuoteTargetError; } });
|
|
8
9
|
Object.defineProperty(exports, "InvalidMidnightApiResponseError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidMidnightApiResponseError; } });
|
|
9
10
|
Object.defineProperty(exports, "InvalidOfferGroupError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferGroupError; } });
|
|
10
11
|
Object.defineProperty(exports, "InvalidOfferParameterError", { enumerable: true, get: function () { return midnight_sdk_1.InvalidOfferParameterError; } });
|
package/lib/cjs/utils.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export type { CapacityLimit, RoundingDirection } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
|
|
2
|
+
export { AdaptiveCurveIrmLib as BlueAdaptiveCurveIrmLib, CapacityLimitReason,
|
|
3
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
|
+
defaultPreLiquidationParamsRegistry as blueDefaultPreLiquidationParamsRegistry,
|
|
5
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
+
getDefaultPreLiquidationParams as getBlueDefaultPreLiquidationParams, MarketUtils as BlueMarketUtils, MathLib, SharesMath as BlueSharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
3
7
|
export { decodeBytes32String, getAuthorizationTypedData as getBlueAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction as BlueMetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
|
4
8
|
export { EcrecoverRatifierUtils as MidnightEcrecoverRatifierUtils, eip712Digest, GroupUtils as MidnightGroupUtils, MarketUtils as MidnightMarketUtils, OfferChainUtils as MidnightOfferChainUtils, OfferUtils as MidnightOfferUtils, Payload as MidnightPayload, PositionUtils as MidnightPositionUtils, RatifierUtils as MidnightRatifierUtils, SetterRatifierUtils as MidnightSetterRatifierUtils, TakeAmountsLib as MidnightTakeAmountsLib, TickLib as MidnightTickLib, TreeUtils as MidnightTreeUtils, } from "@morpho-org/midnight-sdk";
|
|
5
9
|
export type { ArrayElementType, DeepPartial, DottedKeys, FieldType, PartialDottedKeys, } from "@morpho-org/morpho-ts";
|
package/lib/cjs/utils.js
CHANGED
|
@@ -5,7 +5,9 @@ exports.resolveVaultV2ForceWithdrawEligibility = exports.computeVaultV2ForceWith
|
|
|
5
5
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
6
6
|
Object.defineProperty(exports, "BlueAdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
7
7
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
8
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
9
|
Object.defineProperty(exports, "blueDefaultPreLiquidationParamsRegistry", { enumerable: true, get: function () { return blue_sdk_1.defaultPreLiquidationParamsRegistry; } });
|
|
10
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
9
11
|
Object.defineProperty(exports, "getBlueDefaultPreLiquidationParams", { enumerable: true, get: function () { return blue_sdk_1.getDefaultPreLiquidationParams; } });
|
|
10
12
|
Object.defineProperty(exports, "BlueMarketUtils", { enumerable: true, get: function () { return blue_sdk_1.MarketUtils; } });
|
|
11
13
|
Object.defineProperty(exports, "MathLib", { enumerable: true, get: function () { return blue_sdk_1.MathLib; } });
|
package/lib/esm/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/esm/abis.js
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 const vaultExitBundlesV1Abi = [
|
|
@@ -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";
|
|
@@ -228,8 +228,8 @@ export const normalizeBundlesSignature = (serializedSignature, onInvalid = (deta
|
|
|
228
228
|
* @returns The signed share permit or the contract's empty-permit sentinel.
|
|
229
229
|
* @throws {NonPositiveInputError} when a bundle or permit deadline is not positive.
|
|
230
230
|
* @throws {InputExceedsMaxError} when a bundle or permit deadline exceeds uint256.
|
|
231
|
-
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount
|
|
232
|
-
* deadline, or signature is invalid.
|
|
231
|
+
* @throws {BundlesPermitMismatchError} when the requirement kind, token, owner, spender, amount,
|
|
232
|
+
* deadline or a supplied action nonce, or signature is invalid.
|
|
233
233
|
* @example
|
|
234
234
|
* ```ts
|
|
235
235
|
* import { getBundlesSharesPermit } from "@morpho-org/morpho-sdk";
|
|
@@ -316,6 +316,14 @@ export const getBundlesSharesPermit = (params) => {
|
|
|
316
316
|
actual: String(requirementSignature.action.args.deadline),
|
|
317
317
|
});
|
|
318
318
|
}
|
|
319
|
+
if (requirementSignature.action.args.nonce != null &&
|
|
320
|
+
requirementSignature.action.args.nonce !== requirementSignature.args.nonce) {
|
|
321
|
+
throw new BundlesPermitMismatchError({
|
|
322
|
+
field: "nonce",
|
|
323
|
+
expected: String(requirementSignature.args.nonce),
|
|
324
|
+
actual: String(requirementSignature.action.args.nonce),
|
|
325
|
+
});
|
|
326
|
+
}
|
|
319
327
|
const signature = normalizeBundlesSignature(requirementSignature.args.signature);
|
|
320
328
|
return {
|
|
321
329
|
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";
|
|
@@ -30,7 +30,8 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
30
30
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
31
31
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
32
32
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
33
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
33
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
34
|
+
* action nonce disagree.
|
|
34
35
|
* @example
|
|
35
36
|
* ```ts
|
|
36
37
|
* import { vaultV1InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -43,7 +43,8 @@ export interface VaultV2InKindRedeemParams {
|
|
|
43
43
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
44
44
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
45
45
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
46
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
46
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
47
|
+
* action nonce disagree.
|
|
47
48
|
* @example
|
|
48
49
|
* ```ts
|
|
49
50
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -31,7 +31,8 @@ import { getBundlesSharesPermit } from "../bundles/common.js";
|
|
|
31
31
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
32
32
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
33
33
|
* @throws {BundlesPermitMismatchError} when the requirement has the wrong permit kind, asset, owner,
|
|
34
|
-
* spender, or signature encoding, or when its signed and action amounts or
|
|
34
|
+
* spender, or signature encoding, or when its signed and action amounts, deadlines, or a supplied
|
|
35
|
+
* action nonce disagree.
|
|
35
36
|
* @example
|
|
36
37
|
* ```ts
|
|
37
38
|
* import { vaultV2InKindRedeem } from "@morpho-org/morpho-sdk";
|
|
@@ -3,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/esm/blue/abis.d.ts
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
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/esm/blue/abis.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
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";
|
|
@@ -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/esm/blue/entities.js
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
|
|
1
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
PreLiquidationParams,
|
|
4
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
+
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/esm/blue/errors.d.ts
CHANGED
|
@@ -1,2 +1,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/esm/blue/errors.js
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/esm/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/esm/blue/fetch.js
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/esm/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/esm/blue/utils.js
CHANGED
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
1
|
+
export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
2
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
|
+
defaultPreLiquidationParamsRegistry,
|
|
4
|
+
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
+
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
2
6
|
export { decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|