@morpho-org/morpho-sdk 9.7.0 → 10.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v9-to-v10.md +114 -0
- package/README.md +5 -1
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -1
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -1
- package/lib/cjs/actions/midnight/cancelAndMake.js +2 -1
- package/lib/cjs/actions/midnight/cancelOffers.d.ts +54 -0
- package/lib/cjs/actions/midnight/cancelOffers.js +107 -0
- package/lib/cjs/actions/midnight/index.d.ts +1 -0
- package/lib/cjs/actions/midnight/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +1 -1
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +1 -1
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeLend.js +1 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +1 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +1 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +34 -28
- package/lib/cjs/entities/blue/blue.js +99 -73
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/deadline.d.ts +2 -2
- package/lib/cjs/entities/midnight/deadline.js +2 -2
- package/lib/cjs/entities/midnight/midnight.d.ts +49 -51
- package/lib/cjs/entities/midnight/midnight.js +144 -131
- package/lib/cjs/entities/midnight/publication.d.ts +2 -0
- package/lib/cjs/entities/midnight/publication.js +126 -100
- package/lib/cjs/entities/midnight/types.d.ts +4 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +17 -17
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +3 -4
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +1 -1
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -12
- package/lib/cjs/entities/vaultV1/vaultV1.js +83 -57
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +50 -24
- package/lib/cjs/entities/vaultV2/vaultV2.js +166 -90
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +17 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +1410 -806
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +7 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/deadShares.js +55 -34
- package/lib/cjs/helpers/metadata.d.ts +14 -2
- package/lib/cjs/helpers/metadata.js +39 -4
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +34 -22
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +7 -1
- package/lib/cjs/helpers/validate.js +76 -61
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +154 -103
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +31 -20
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +3 -1
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/transactionPlan/plan.js +6 -3
- package/lib/cjs/transactionPlan/serde.js +7 -7
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +6 -4
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +5 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +6 -4
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +5 -3
- package/lib/cjs/types/action.d.ts +26 -2
- package/lib/cjs/types/action.js +1 -1
- package/lib/cjs/types/error.js +11 -5
- package/lib/cjs/types/metadata.d.ts +12 -2
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/cjs/version.d.ts +2 -0
- package/lib/cjs/version.js +6 -0
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +3 -4
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +1 -1
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -1
- package/lib/esm/actions/midnight/cancelAndMake.js +2 -1
- package/lib/esm/actions/midnight/cancelOffers.d.ts +54 -0
- package/lib/esm/actions/midnight/cancelOffers.js +103 -0
- package/lib/esm/actions/midnight/index.d.ts +1 -0
- package/lib/esm/actions/midnight/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +1 -1
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +1 -1
- package/lib/esm/actions/midnight/takeBorrow.d.ts +1 -1
- package/lib/esm/actions/midnight/takeBorrow.js +1 -1
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -1
- package/lib/esm/actions/midnight/takeLend.js +1 -1
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -1
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +1 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +1 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +3 -4
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +4 -6
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +5 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +3 -5
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +26 -23
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +34 -28
- package/lib/esm/entities/blue/blue.js +99 -73
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/deadline.d.ts +2 -2
- package/lib/esm/entities/midnight/deadline.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +49 -51
- package/lib/esm/entities/midnight/midnight.js +145 -132
- package/lib/esm/entities/midnight/publication.d.ts +2 -0
- package/lib/esm/entities/midnight/publication.js +126 -100
- package/lib/esm/entities/midnight/types.d.ts +4 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +3 -5
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +17 -17
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +3 -4
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +1 -1
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -12
- package/lib/esm/entities/vaultV1/vaultV1.js +83 -57
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +50 -24
- package/lib/esm/entities/vaultV2/vaultV2.js +166 -90
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +17 -2
- package/lib/esm/entities/vaultV2BlueReallocationData.js +1410 -806
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +56 -35
- package/lib/esm/helpers/metadata.d.ts +14 -2
- package/lib/esm/helpers/metadata.js +38 -4
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +34 -22
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +7 -1
- package/lib/esm/helpers/validate.js +76 -61
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +153 -102
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +31 -20
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/transactionPlan/plan.js +6 -3
- package/lib/esm/transactionPlan/serde.js +7 -7
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +6 -4
- package/lib/esm/transactionPlan/vaultv2/deposit.js +5 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +6 -4
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +5 -3
- package/lib/esm/types/action.d.ts +26 -2
- package/lib/esm/types/action.js +1 -1
- package/lib/esm/types/error.js +11 -5
- package/lib/esm/types/metadata.d.ts +12 -2
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +2 -0
- package/lib/esm/version.js +3 -0
- package/package.json +8 -7
|
@@ -60,6 +60,7 @@ export interface MidnightMakerOfferState {
|
|
|
60
60
|
* @returns Nothing when every offer can be published.
|
|
61
61
|
* @throws {MidnightOfferExpiredError} when expiry is not later than `now`.
|
|
62
62
|
* @throws {MidnightOfferExpiryAfterMaturityError} when expiry exceeds market maturity.
|
|
63
|
+
* @throws {UnknownDataError} when an offer's state or rate entry is missing.
|
|
63
64
|
* @throws {MidnightOfferGroupConsumedError} when the group's remaining cap is zero.
|
|
64
65
|
* @throws {MidnightOfferTickSpacingError} when the tick is inaccessible.
|
|
65
66
|
* @throws {MidnightOfferContinuousFeeCapBelowMarketFeeError} when the market fee exceeds the offer cap.
|
|
@@ -98,6 +99,7 @@ export declare function validateMidnightMakerOfferStates(params: {
|
|
|
98
99
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
99
100
|
* another chain than `params.chainId`.
|
|
100
101
|
* @throws {viem.BaseError} when block, contract, or oracle-code reads fail.
|
|
102
|
+
* @throws {UnknownDataError} when required publication state is missing.
|
|
101
103
|
* @example
|
|
102
104
|
* ```ts
|
|
103
105
|
* const { states, now } = await fetchMidnightMakerOfferStates({
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { UnknownDataError } from "@morpho-org/blue-sdk";
|
|
1
2
|
import { DEFAULT_TICK_SPACING, Market, MarketParams, MarketUtils, midnightAbi, RateRatifierV1, } from "@morpho-org/midnight-sdk";
|
|
2
3
|
import { getChainAddress, MathLib } from "@morpho-org/morpho-ts";
|
|
3
4
|
import { maxUint256, zeroAddress } from "viem";
|
|
@@ -6,8 +7,101 @@ import { validateClientChainId } from "../../actions/requirements/validateClient
|
|
|
6
7
|
import { MidnightMarketLiquidationCursorNotEnabledError, MidnightMarketLltvNotEnabledError, MidnightMarketMaturityTooFarError, MidnightMarketOracleWithoutCodeError, MidnightOfferCallbackNotSupportedError, MidnightOfferContinuousFeeCapBelowMarketFeeError, MidnightOfferExpiredError, MidnightOfferExpiryAfterMaturityError, MidnightOfferGroupConsumedError, MidnightOfferNoCreditError, MidnightOfferNoDebtError, MidnightOfferRateBoundUnreachableError, MidnightOfferTickSpacingError, MidnightOfferZeroPriceSellError, } from "../../types/midnightPublicationError.js";
|
|
7
8
|
// Midnight.sol `touchMarket` rejects markets maturing more than 100 years after creation.
|
|
8
9
|
const MAX_TIME_TO_MATURITY = 100n * 365n * 86400n;
|
|
10
|
+
function requirePublicationState(value) {
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
throw new UnknownDataError("Missing Midnight publication state.");
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
9
15
|
/** @internal */
|
|
10
16
|
export const offerMarketParams = (offer) => "params" in offer.market ? offer.market.params : offer.market;
|
|
17
|
+
function validateOfferTerms({ offer, state, index, marketId, }) {
|
|
18
|
+
const capacity = BigInt(offer.maxAssets) > 0n
|
|
19
|
+
? BigInt(offer.maxAssets)
|
|
20
|
+
: BigInt(offer.maxUnits);
|
|
21
|
+
if (state.consumed >= capacity) {
|
|
22
|
+
throw new MidnightOfferGroupConsumedError({
|
|
23
|
+
index,
|
|
24
|
+
group: offer.group,
|
|
25
|
+
consumed: state.consumed,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
const tickSpacing = state.tickSpacing || Number(DEFAULT_TICK_SPACING);
|
|
29
|
+
if (BigInt(offer.tick) % BigInt(tickSpacing) !== 0n) {
|
|
30
|
+
throw new MidnightOfferTickSpacingError({
|
|
31
|
+
index,
|
|
32
|
+
tick: BigInt(offer.tick),
|
|
33
|
+
tickSpacing,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (BigInt(offer.continuousFeeCap) < state.continuousFee) {
|
|
37
|
+
throw new MidnightOfferContinuousFeeCapBelowMarketFeeError({
|
|
38
|
+
index,
|
|
39
|
+
marketId,
|
|
40
|
+
continuousFeeCap: BigInt(offer.continuousFeeCap),
|
|
41
|
+
continuousFee: state.continuousFee,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (!offer.buy && BigInt(offer.tick) === 0n) {
|
|
45
|
+
throw new MidnightOfferZeroPriceSellError({ index });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function validateOfferRate({ offer, state, index, rate, now, expiry, }) {
|
|
49
|
+
let timestamp = offer.buy ? expiry : MathLib.max(now, BigInt(offer.start));
|
|
50
|
+
if (!offer.buy && rate > 0n) {
|
|
51
|
+
const maxTimeToMaturity = (maxUint256 - MathLib.WAD * MathLib.WAD - MathLib.WAD + 1n) / rate;
|
|
52
|
+
const marketMaturity = state.market.params.maturity;
|
|
53
|
+
timestamp = MathLib.max(timestamp, marketMaturity - maxTimeToMaturity);
|
|
54
|
+
if (timestamp > expiry || timestamp > marketMaturity) {
|
|
55
|
+
throw new MidnightOfferRateBoundUnreachableError({
|
|
56
|
+
index,
|
|
57
|
+
rate,
|
|
58
|
+
tick: BigInt(offer.tick),
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (!RateRatifierV1.isPriceAcceptable({
|
|
63
|
+
offer: { ...offer, market: state.market },
|
|
64
|
+
rate,
|
|
65
|
+
timestamp,
|
|
66
|
+
})) {
|
|
67
|
+
throw new MidnightOfferRateBoundUnreachableError({
|
|
68
|
+
index,
|
|
69
|
+
rate,
|
|
70
|
+
tick: BigInt(offer.tick),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function validateUncreatedMarket({ state, index, offerMarket, maturity, expiry, now, marketCreationTime, }) {
|
|
75
|
+
const marketCreationTimestamp = marketCreationTime === "now" ? now : expiry;
|
|
76
|
+
const maxMaturity = marketCreationTimestamp + MAX_TIME_TO_MATURITY;
|
|
77
|
+
if (maturity > maxMaturity) {
|
|
78
|
+
throw new MidnightMarketMaturityTooFarError({
|
|
79
|
+
index,
|
|
80
|
+
maturity,
|
|
81
|
+
maxMaturity,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
for (const [collateralIndex, collateral,] of offerMarket.collateralParams.entries()) {
|
|
85
|
+
if (!state.lltvEnabled[collateralIndex]) {
|
|
86
|
+
throw new MidnightMarketLltvNotEnabledError({
|
|
87
|
+
index,
|
|
88
|
+
lltv: BigInt(collateral.lltv),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (!state.liquidationCursorEnabled[collateralIndex]) {
|
|
92
|
+
throw new MidnightMarketLiquidationCursorNotEnabledError({
|
|
93
|
+
index,
|
|
94
|
+
liquidationCursor: BigInt(collateral.liquidationCursor),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (!state.oracleHasCode[collateralIndex]) {
|
|
98
|
+
throw new MidnightMarketOracleWithoutCodeError({
|
|
99
|
+
index,
|
|
100
|
+
oracle: collateral.oracle,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
11
105
|
/**
|
|
12
106
|
* Rejects the first maker offer that cannot be filled at or after publication.
|
|
13
107
|
*
|
|
@@ -24,6 +118,7 @@ export const offerMarketParams = (offer) => "params" in offer.market ? offer.mar
|
|
|
24
118
|
* @returns Nothing when every offer can be published.
|
|
25
119
|
* @throws {MidnightOfferExpiredError} when expiry is not later than `now`.
|
|
26
120
|
* @throws {MidnightOfferExpiryAfterMaturityError} when expiry exceeds market maturity.
|
|
121
|
+
* @throws {UnknownDataError} when an offer's state or rate entry is missing.
|
|
27
122
|
* @throws {MidnightOfferGroupConsumedError} when the group's remaining cap is zero.
|
|
28
123
|
* @throws {MidnightOfferTickSpacingError} when the tick is inaccessible.
|
|
29
124
|
* @throws {MidnightOfferContinuousFeeCapBelowMarketFeeError} when the market fee exceeds the offer cap.
|
|
@@ -43,7 +138,7 @@ export const offerMarketParams = (offer) => "params" in offer.market ? offer.mar
|
|
|
43
138
|
export function validateMidnightMakerOfferStates(params) {
|
|
44
139
|
const rateEntries = params.tree.type === "rateV1" ? params.tree.entries : [];
|
|
45
140
|
params.tree.offers.forEach((offer, index) => {
|
|
46
|
-
const state = params.states[index];
|
|
141
|
+
const state = requirePublicationState(params.states[index]);
|
|
47
142
|
const expiry = BigInt(offer.expiry);
|
|
48
143
|
const offerMarket = offerMarketParams(offer);
|
|
49
144
|
const maturity = BigInt(offerMarket.maturity);
|
|
@@ -62,63 +157,12 @@ export function validateMidnightMakerOfferStates(params) {
|
|
|
62
157
|
maturity,
|
|
63
158
|
});
|
|
64
159
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
: BigInt(offer.maxUnits);
|
|
68
|
-
if (state.consumed >= capacity) {
|
|
69
|
-
throw new MidnightOfferGroupConsumedError({
|
|
70
|
-
index,
|
|
71
|
-
group: offer.group,
|
|
72
|
-
consumed: state.consumed,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
const tickSpacing = state.tickSpacing || Number(DEFAULT_TICK_SPACING);
|
|
76
|
-
if (BigInt(offer.tick) % BigInt(tickSpacing) !== 0n) {
|
|
77
|
-
throw new MidnightOfferTickSpacingError({
|
|
78
|
-
index,
|
|
79
|
-
tick: BigInt(offer.tick),
|
|
80
|
-
tickSpacing,
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
if (BigInt(offer.continuousFeeCap) < state.continuousFee) {
|
|
84
|
-
throw new MidnightOfferContinuousFeeCapBelowMarketFeeError({
|
|
85
|
-
index,
|
|
86
|
-
marketId,
|
|
87
|
-
continuousFeeCap: BigInt(offer.continuousFeeCap),
|
|
88
|
-
continuousFee: state.continuousFee,
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (!offer.buy && BigInt(offer.tick) === 0n) {
|
|
92
|
-
throw new MidnightOfferZeroPriceSellError({ index });
|
|
93
|
-
}
|
|
160
|
+
// Reject inaccessible terms before evaluating rate reachability.
|
|
161
|
+
validateOfferTerms({ offer, state, index, marketId });
|
|
94
162
|
if (params.tree.type === "rateV1") {
|
|
95
|
-
const rate = BigInt(rateEntries[index].rate);
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
: MathLib.max(params.now, BigInt(offer.start));
|
|
99
|
-
if (!offer.buy && rate > 0n) {
|
|
100
|
-
const maxTimeToMaturity = (maxUint256 - MathLib.WAD * MathLib.WAD - MathLib.WAD + 1n) / rate;
|
|
101
|
-
const marketMaturity = state.market.params.maturity;
|
|
102
|
-
timestamp = MathLib.max(timestamp, marketMaturity - maxTimeToMaturity);
|
|
103
|
-
if (timestamp > expiry || timestamp > marketMaturity) {
|
|
104
|
-
throw new MidnightOfferRateBoundUnreachableError({
|
|
105
|
-
index,
|
|
106
|
-
rate,
|
|
107
|
-
tick: BigInt(offer.tick),
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
if (!RateRatifierV1.isPriceAcceptable({
|
|
112
|
-
offer: { ...offer, market: state.market },
|
|
113
|
-
rate,
|
|
114
|
-
timestamp,
|
|
115
|
-
})) {
|
|
116
|
-
throw new MidnightOfferRateBoundUnreachableError({
|
|
117
|
-
index,
|
|
118
|
-
rate,
|
|
119
|
-
tick: BigInt(offer.tick),
|
|
120
|
-
});
|
|
121
|
-
}
|
|
163
|
+
const rate = BigInt(requirePublicationState(rateEntries[index]).rate);
|
|
164
|
+
// Reject rate bounds that cannot become fillable.
|
|
165
|
+
validateOfferRate({ offer, state, index, rate, now: params.now, expiry });
|
|
122
166
|
}
|
|
123
167
|
if (offer.reduceOnly && offer.buy && state.debt === 0n) {
|
|
124
168
|
throw new MidnightOfferNoDebtError({ index, marketId });
|
|
@@ -127,35 +171,16 @@ export function validateMidnightMakerOfferStates(params) {
|
|
|
127
171
|
throw new MidnightOfferNoCreditError({ index, marketId });
|
|
128
172
|
}
|
|
129
173
|
if (state.tickSpacing === 0) {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (!state.lltvEnabled[collateralIndex]) {
|
|
141
|
-
throw new MidnightMarketLltvNotEnabledError({
|
|
142
|
-
index,
|
|
143
|
-
lltv: BigInt(collateral.lltv),
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
if (!state.liquidationCursorEnabled[collateralIndex]) {
|
|
147
|
-
throw new MidnightMarketLiquidationCursorNotEnabledError({
|
|
148
|
-
index,
|
|
149
|
-
liquidationCursor: BigInt(collateral.liquidationCursor),
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
if (!state.oracleHasCode[collateralIndex]) {
|
|
153
|
-
throw new MidnightMarketOracleWithoutCodeError({
|
|
154
|
-
index,
|
|
155
|
-
oracle: collateral.oracle,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
}
|
|
174
|
+
// Reject market parameters that cannot be created.
|
|
175
|
+
validateUncreatedMarket({
|
|
176
|
+
state,
|
|
177
|
+
index,
|
|
178
|
+
offerMarket,
|
|
179
|
+
maturity,
|
|
180
|
+
expiry,
|
|
181
|
+
now: params.now,
|
|
182
|
+
marketCreationTime: params.marketCreationTime,
|
|
183
|
+
});
|
|
159
184
|
}
|
|
160
185
|
});
|
|
161
186
|
}
|
|
@@ -175,6 +200,7 @@ export function validateMidnightMakerOfferStates(params) {
|
|
|
175
200
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
176
201
|
* another chain than `params.chainId`.
|
|
177
202
|
* @throws {viem.BaseError} when block, contract, or oracle-code reads fail.
|
|
203
|
+
* @throws {UnknownDataError} when required publication state is missing.
|
|
178
204
|
* @example
|
|
179
205
|
* ```ts
|
|
180
206
|
* const { states, now } = await fetchMidnightMakerOfferStates({
|
|
@@ -275,12 +301,12 @@ export async function fetchMidnightMakerOfferStates(params) {
|
|
|
275
301
|
]);
|
|
276
302
|
const defaultFeeByLoanToken = new Map(defaultFeeTokens.map((loanToken, index) => [
|
|
277
303
|
loanToken.toLowerCase(),
|
|
278
|
-
defaultFees[index],
|
|
304
|
+
requirePublicationState(defaultFees[index]),
|
|
279
305
|
]));
|
|
280
306
|
const marketById = new Map(markets.map(({ id, market: marketParams }, index) => {
|
|
281
|
-
const [totalUnits, lossFactor, withdrawable, continuousFeeCredit, fee0, fee1, fee2, fee3, fee4, fee5, fee6, continuousFee, tickSpacing,] = marketStates[index];
|
|
307
|
+
const [totalUnits, lossFactor, withdrawable, continuousFeeCredit, fee0, fee1, fee2, fee3, fee4, fee5, fee6, continuousFee, tickSpacing,] = requirePublicationState(marketStates[index]);
|
|
282
308
|
const effectiveContinuousFee = tickSpacing === 0
|
|
283
|
-
? defaultFeeByLoanToken.get(marketParams.loanToken.toLowerCase())
|
|
309
|
+
? requirePublicationState(defaultFeeByLoanToken.get(marketParams.loanToken.toLowerCase()))
|
|
284
310
|
: continuousFee;
|
|
285
311
|
return [
|
|
286
312
|
id.toLowerCase(),
|
|
@@ -298,44 +324,44 @@ export async function fetchMidnightMakerOfferStates(params) {
|
|
|
298
324
|
}));
|
|
299
325
|
const consumedByGroup = new Map(groups.map(({ maker, group }, index) => [
|
|
300
326
|
`${maker.toLowerCase()}:${group.toLowerCase()}`,
|
|
301
|
-
consumedValues[index],
|
|
327
|
+
requirePublicationState(consumedValues[index]),
|
|
302
328
|
]));
|
|
303
329
|
const positionByOwner = new Map(owners.map(({ id, maker }, index) => [
|
|
304
330
|
`${id.toLowerCase()}:${maker.toLowerCase()}`,
|
|
305
331
|
{
|
|
306
|
-
credit: creditValues[index],
|
|
307
|
-
debt: debtValues[index],
|
|
332
|
+
credit: requirePublicationState(creditValues[index]),
|
|
333
|
+
debt: requirePublicationState(debtValues[index]),
|
|
308
334
|
},
|
|
309
335
|
]));
|
|
310
336
|
const collateralStateByKey = new Map(collaterals.map(({ key }, index) => [
|
|
311
337
|
key,
|
|
312
338
|
{
|
|
313
|
-
lltvEnabled: lltvEnabledByCollateral[index],
|
|
314
|
-
liquidationCursorEnabled: liquidationCursorEnabledByCollateral[index],
|
|
339
|
+
lltvEnabled: requirePublicationState(lltvEnabledByCollateral[index]),
|
|
340
|
+
liquidationCursorEnabled: requirePublicationState(liquidationCursorEnabledByCollateral[index]),
|
|
315
341
|
},
|
|
316
342
|
]));
|
|
317
343
|
const collateralStateByMarket = new Map(markets.map(({ id, market }) => [
|
|
318
344
|
id.toLowerCase(),
|
|
319
|
-
market.collateralParams.map((_, index) => collateralStateByKey.get(`${id.toLowerCase()}:${index}`)),
|
|
345
|
+
market.collateralParams.map((_, index) => requirePublicationState(collateralStateByKey.get(`${id.toLowerCase()}:${index}`))),
|
|
320
346
|
]));
|
|
321
347
|
const codeByOracle = new Map(await Promise.all([...new Set(collaterals.map(({ oracleKey }) => oracleKey))].map(async (oracleKey) => [
|
|
322
348
|
oracleKey,
|
|
323
349
|
await getCode(params.client, {
|
|
324
|
-
address: collaterals.find(({ oracleKey: key }) => key === oracleKey).collateral.oracle,
|
|
350
|
+
address: requirePublicationState(collaterals.find(({ oracleKey: key }) => key === oracleKey)).collateral.oracle,
|
|
325
351
|
blockNumber,
|
|
326
352
|
}),
|
|
327
353
|
])));
|
|
328
354
|
const states = params.tree.offers.map((offer) => {
|
|
329
355
|
const id = MarketUtils.toId(offer.market);
|
|
330
|
-
const market = marketById.get(id.toLowerCase());
|
|
356
|
+
const market = requirePublicationState(marketById.get(id.toLowerCase()));
|
|
331
357
|
const groupKey = `${offer.maker.toLowerCase()}:${offer.group.toLowerCase()}`;
|
|
332
|
-
const owner = positionByOwner.get(`${id.toLowerCase()}:${offer.maker.toLowerCase()}`);
|
|
358
|
+
const owner = requirePublicationState(positionByOwner.get(`${id.toLowerCase()}:${offer.maker.toLowerCase()}`));
|
|
333
359
|
const uncreated = market.tickSpacing === 0;
|
|
334
360
|
const collateralStates = uncreated
|
|
335
|
-
? collateralStateByMarket.get(id.toLowerCase())
|
|
361
|
+
? requirePublicationState(collateralStateByMarket.get(id.toLowerCase()))
|
|
336
362
|
: [];
|
|
337
363
|
return {
|
|
338
|
-
consumed: consumedByGroup.get(groupKey),
|
|
364
|
+
consumed: requirePublicationState(consumedByGroup.get(groupKey)),
|
|
339
365
|
tickSpacing: market.tickSpacing,
|
|
340
366
|
continuousFee: BigInt(market.continuousFee),
|
|
341
367
|
credit: owner.credit,
|
|
@@ -3,7 +3,7 @@ import type { AccrualPosition, Market, MidnightFetchParams, PriceRatifierV1TreeC
|
|
|
3
3
|
import type { Address, Hex } from "viem";
|
|
4
4
|
import type { MidnightMakeBorrowCollateral } from "../../actions/midnight/cancelAndMake.js";
|
|
5
5
|
import type { MidnightReferralFeeParams, MidnightTakeableOffer } from "../../actions/midnight/types.js";
|
|
6
|
-
import type { ActionOutput, BaseAction, MidnightBuyTarget, MidnightCancelAndMakeAction, MidnightCollateralTransfer, MidnightGroupCancellation, MidnightRepay, MidnightSellTarget } from "../../types/action.js";
|
|
6
|
+
import type { ActionOutput, BaseAction, MidnightBuyTarget, MidnightCancelAndMakeAction, MidnightCollateralTransfer, MidnightGroupCancellation, MidnightRepay, MidnightSellTarget, ReferenceTimestampParams } from "../../types/action.js";
|
|
7
7
|
/** Optional Midnight API validation controls for make-offer flows. */
|
|
8
8
|
export type OfferValidationParams = Omit<TreeMempoolValidateParams, "chainId" | "ratification">;
|
|
9
9
|
/**
|
|
@@ -33,7 +33,7 @@ export interface OffersData {
|
|
|
33
33
|
readonly payload: Hex;
|
|
34
34
|
}
|
|
35
35
|
/** Parameters shared by Midnight maker flows. */
|
|
36
|
-
export interface MakeOffersParams {
|
|
36
|
+
export interface MakeOffersParams extends ReferenceTimestampParams {
|
|
37
37
|
/** Maker expected on every offer. Must send the transaction: V2 acts on `msg.sender`. */
|
|
38
38
|
readonly accountAddress: Address;
|
|
39
39
|
readonly offers: MidnightMakerTreeInput;
|
|
@@ -146,7 +146,7 @@ export interface MakeOffersOutput extends MidnightActionOutput<MidnightCancelAnd
|
|
|
146
146
|
readonly ratifierType: "priceV1" | "rateV1";
|
|
147
147
|
}
|
|
148
148
|
/** Parameters shared by Midnight market action flows. */
|
|
149
|
-
export interface MarketActionParams {
|
|
149
|
+
export interface MarketActionParams extends ReferenceTimestampParams {
|
|
150
150
|
readonly accountAddress: Address;
|
|
151
151
|
readonly marketData: Market;
|
|
152
152
|
}
|
|
@@ -260,7 +260,7 @@ export interface WithdrawCollateralBatchParams extends MarketActionParams, Midni
|
|
|
260
260
|
readonly receiver?: Address;
|
|
261
261
|
}
|
|
262
262
|
/** Parameters for the Midnight redeem flow. */
|
|
263
|
-
export interface RedeemParams {
|
|
263
|
+
export interface RedeemParams extends ReferenceTimestampParams {
|
|
264
264
|
readonly accountAddress: Address;
|
|
265
265
|
/** Owner-bound snapshot returned by `getPositionData`; manually constructed ownerless snapshots are rejected. */
|
|
266
266
|
readonly positionData: AccrualPosition;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Address, type Client } from "viem";
|
|
2
|
-
import { type BundlesTokenSignatureRequirement, type ERC20ApprovalAction, type Transaction } from "../../types/index.js";
|
|
2
|
+
import { type BundlesTokenSignatureRequirement, type ERC20ApprovalAction, type ReferenceTimestampParams, type Transaction } from "../../types/index.js";
|
|
3
3
|
/** Parameters for {@link getBundlesTokenRequirements}. */
|
|
4
|
-
export interface GetBundlesTokenRequirementsParams {
|
|
4
|
+
export interface GetBundlesTokenRequirementsParams extends ReferenceTimestampParams {
|
|
5
5
|
/** ERC-20 token funded by the operation. */
|
|
6
6
|
readonly token: Address;
|
|
7
7
|
/** Registered fixed bundles contract that pulls the token. */
|
|
@@ -22,8 +22,6 @@ export interface GetBundlesTokenRequirementsParams {
|
|
|
22
22
|
readonly useSimplePermit?: boolean;
|
|
23
23
|
/** @deprecated Ignored. The SDK no longer requests Permit2 funding; use ERC-2612 permits or ERC-20 approvals. */
|
|
24
24
|
readonly permit2Nonce?: bigint;
|
|
25
|
-
/** Timestamp the deadline is validated against; defaults to the current time. */
|
|
26
|
-
readonly now?: bigint;
|
|
27
25
|
}
|
|
28
26
|
/**
|
|
29
27
|
* Resolves direct approval or ERC-2612 prerequisites for a registered fixed bundles contract.
|
|
@@ -40,7 +38,7 @@ export interface GetBundlesTokenRequirementsParams {
|
|
|
40
38
|
* @param params.owner - Account funding the operation.
|
|
41
39
|
* @param params.chainId - Target chain id; must match the client chain.
|
|
42
40
|
* @param params.deadline - Final-call and signature deadline.
|
|
43
|
-
* @param params.now -
|
|
41
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
44
42
|
* @param params.supportSignature - Whether ERC-2612 signatures may be requested.
|
|
45
43
|
* @param params.supportDeployless - Whether ERC-2612 metadata reads may use deployless calls.
|
|
46
44
|
* @param params.useSimplePermit - Defaults to true when signatures are supported. Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
@@ -22,7 +22,7 @@ import { getErc2612Permit } from "./getErc2612Permit.js";
|
|
|
22
22
|
* @param params.owner - Account funding the operation.
|
|
23
23
|
* @param params.chainId - Target chain id; must match the client chain.
|
|
24
24
|
* @param params.deadline - Final-call and signature deadline.
|
|
25
|
-
* @param params.now -
|
|
25
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
26
26
|
* @param params.supportSignature - Whether ERC-2612 signatures may be requested.
|
|
27
27
|
* @param params.supportDeployless - Whether ERC-2612 metadata reads may use deployless calls.
|
|
28
28
|
* @param params.useSimplePermit - Defaults to true when signatures are supported. Prefer ERC-2612 when `nonces()` succeeds and the token's
|
|
@@ -122,22 +122,22 @@ export const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
122
122
|
if (allowance >= params.amount)
|
|
123
123
|
return [];
|
|
124
124
|
const { dai } = getChainAddresses(params.chainId);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
const isDai = params.supportSignature &&
|
|
126
|
+
isDefined(dai) &&
|
|
127
|
+
isAddressEqual(params.token, dai);
|
|
128
|
+
if (params.supportSignature && (params.useSimplePermit ?? true) && !isDai) {
|
|
129
|
+
const permit = await getErc2612Permit(viemClient, {
|
|
130
|
+
token: params.token,
|
|
131
|
+
owner: params.owner,
|
|
132
|
+
spender: params.spender,
|
|
133
|
+
amount: params.amount,
|
|
134
|
+
chainId: params.chainId,
|
|
135
|
+
deadline: params.deadline,
|
|
136
|
+
now: timestamp,
|
|
137
|
+
supportDeployless: params.supportDeployless,
|
|
138
|
+
});
|
|
139
|
+
if (isDefined(permit))
|
|
140
|
+
return [permit];
|
|
141
141
|
}
|
|
142
142
|
return resolveBundlesTokenRequirements({
|
|
143
143
|
token: params.token,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Token } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address, Client } from "viem";
|
|
3
|
-
import { type ERC20ApprovalAction, type PermitRequirementSignature, type Requirement, type Transaction } from "../../types/index.js";
|
|
3
|
+
import { type ERC20ApprovalAction, type PermitRequirementSignature, type ReferenceTimestampParams, type Requirement, type Transaction } from "../../types/index.js";
|
|
4
4
|
/**
|
|
5
5
|
* Resolves the vault-share approval or ERC-2612 requirement for a VaultBundlesV1 exit.
|
|
6
6
|
*
|
|
@@ -11,7 +11,7 @@ import { type ERC20ApprovalAction, type PermitRequirementSignature, type Require
|
|
|
11
11
|
*
|
|
12
12
|
* @param viemClient - Client used to read the current share allowance and permit nonce.
|
|
13
13
|
* @param params - Vault snapshot, owner, minimum allowance, and deadline values.
|
|
14
|
-
* @param params.now -
|
|
14
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
15
15
|
* @returns No requirement when the allowance is sufficient, otherwise one approval or permit.
|
|
16
16
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
17
17
|
* another chain than `params.chainId`.
|
|
@@ -26,5 +26,4 @@ export declare const getVaultBundlesSharesRequirements: (viemClient: Client, par
|
|
|
26
26
|
readonly requiredShareAllowance: bigint;
|
|
27
27
|
readonly deadline: bigint;
|
|
28
28
|
readonly supportSignature: boolean;
|
|
29
|
-
|
|
30
|
-
}) => Promise<readonly (Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
|
|
29
|
+
} & ReferenceTimestampParams) => Promise<readonly (Readonly<Transaction<ERC20ApprovalAction>> | Requirement<PermitRequirementSignature>)[]>;
|
|
@@ -16,7 +16,7 @@ import { ExpiredDeadlineError, } from "../../types/index.js";
|
|
|
16
16
|
*
|
|
17
17
|
* @param viemClient - Client used to read the current share allowance and permit nonce.
|
|
18
18
|
* @param params - Vault snapshot, owner, minimum allowance, and deadline values.
|
|
19
|
-
* @param params.now -
|
|
19
|
+
* @param params.now - See {@link ReferenceTimestampParams.now}.
|
|
20
20
|
* @returns No requirement when the allowance is sufficient, otherwise one approval or permit.
|
|
21
21
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
22
22
|
* another chain than `params.chainId`.
|
|
@@ -2,7 +2,7 @@ import { type AccrualVault, type AccrualVaultV2, type MarketParams } from "@morp
|
|
|
2
2
|
import { fetchAccrualVault } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import type { FetchParameters } from "../../types/data.js";
|
|
5
|
-
import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type MorphoClientType, type RequirementSignature, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1MigrateToV2AmountArgs, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
|
|
5
|
+
import { type ActionOutput, type ActionRequirement, type BundlesFundingArgs, type BundlesTokenRequirementsOptions, type MorphoClientType, type ReferenceTimestampParams, type RequirementSignature, type VaultV1DepositAction, type VaultV1InKindRedeemAction, type VaultV1MigrateToV2Action, type VaultV1MigrateToV2AmountArgs, type VaultV1RedeemAction, type VaultV1WithdrawAction } from "../../types/index.js";
|
|
6
6
|
/** Action surface for Vault V1 reads and writes; writes route through VaultBundlesV1 and VaultExitBundlesV1. */
|
|
7
7
|
export interface VaultV1Actions {
|
|
8
8
|
/**
|
|
@@ -107,7 +107,7 @@ export interface VaultV1Actions {
|
|
|
107
107
|
readonly referralFeePct?: bigint;
|
|
108
108
|
readonly referralFeeRecipient?: Address;
|
|
109
109
|
readonly deadline?: bigint;
|
|
110
|
-
} & BundlesFundingArgs) => ActionOutput<VaultV1DepositAction, readonly RequirementSignature[], BundlesTokenRequirementsOptions>;
|
|
110
|
+
} & ReferenceTimestampParams & BundlesFundingArgs) => ActionOutput<VaultV1DepositAction, readonly RequirementSignature[], BundlesTokenRequirementsOptions>;
|
|
111
111
|
/**
|
|
112
112
|
* Prepares an exact-assets Vault V1 withdrawal through VaultBundlesV1.
|
|
113
113
|
*
|
|
@@ -189,7 +189,7 @@ export interface VaultV1Actions {
|
|
|
189
189
|
readonly referralFeePct?: bigint;
|
|
190
190
|
readonly referralFeeRecipient?: Address;
|
|
191
191
|
readonly deadline?: bigint;
|
|
192
|
-
}) => ActionOutput<VaultV1WithdrawAction, readonly RequirementSignature[], undefined>;
|
|
192
|
+
} & ReferenceTimestampParams) => ActionOutput<VaultV1WithdrawAction, readonly RequirementSignature[], undefined>;
|
|
193
193
|
/**
|
|
194
194
|
* Prepares an exact-shares Vault V1 redemption through VaultBundlesV1.
|
|
195
195
|
*
|
|
@@ -270,7 +270,7 @@ export interface VaultV1Actions {
|
|
|
270
270
|
readonly referralFeePct?: bigint;
|
|
271
271
|
readonly referralFeeRecipient?: Address;
|
|
272
272
|
readonly deadline?: bigint;
|
|
273
|
-
}) => ActionOutput<VaultV1RedeemAction, readonly RequirementSignature[], undefined>;
|
|
273
|
+
} & ReferenceTimestampParams) => ActionOutput<VaultV1RedeemAction, readonly RequirementSignature[], undefined>;
|
|
274
274
|
/**
|
|
275
275
|
* Prepares an illiquid Vault V1 exit into the vault's Morpho Blue supply positions.
|
|
276
276
|
*
|
|
@@ -355,7 +355,7 @@ export interface VaultV1Actions {
|
|
|
355
355
|
readonly vaultData: AccrualVault;
|
|
356
356
|
readonly userAddress: Address;
|
|
357
357
|
readonly deadline?: bigint;
|
|
358
|
-
}) => ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
358
|
+
} & ReferenceTimestampParams) => ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
359
359
|
/**
|
|
360
360
|
* Prepares a Vault V1-to-Vault V2 migration through VaultBundlesV1.
|
|
361
361
|
*
|
|
@@ -461,7 +461,7 @@ export interface VaultV1Actions {
|
|
|
461
461
|
readonly referralFeePct?: bigint;
|
|
462
462
|
readonly referralFeeRecipient?: Address;
|
|
463
463
|
readonly deadline?: bigint;
|
|
464
|
-
} & VaultV1MigrateToV2AmountArgs) => ActionOutput<VaultV1MigrateToV2Action, readonly RequirementSignature[], undefined>;
|
|
464
|
+
} & ReferenceTimestampParams & VaultV1MigrateToV2AmountArgs) => ActionOutput<VaultV1MigrateToV2Action, readonly RequirementSignature[], undefined>;
|
|
465
465
|
}
|
|
466
466
|
/** Binds a viem client to a Vault V1 (MetaMorpho) vault's action builders. */
|
|
467
467
|
export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
@@ -487,7 +487,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
487
487
|
readonly referralFeePct?: bigint;
|
|
488
488
|
readonly referralFeeRecipient?: Address;
|
|
489
489
|
readonly deadline?: bigint;
|
|
490
|
-
} & BundlesFundingArgs): Readonly<{
|
|
490
|
+
} & ReferenceTimestampParams & BundlesFundingArgs): Readonly<{
|
|
491
491
|
getRequirements: (requirementOptions?: BundlesTokenRequirementsOptions) => Promise<readonly ActionRequirement[]>;
|
|
492
492
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1DepositAction>>;
|
|
493
493
|
}>;
|
|
@@ -499,7 +499,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
499
499
|
readonly referralFeePct?: bigint;
|
|
500
500
|
readonly referralFeeRecipient?: Address;
|
|
501
501
|
readonly deadline?: bigint;
|
|
502
|
-
}): Readonly<{
|
|
502
|
+
} & ReferenceTimestampParams): Readonly<{
|
|
503
503
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
504
504
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1WithdrawAction>>;
|
|
505
505
|
}>;
|
|
@@ -510,18 +510,18 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
510
510
|
readonly referralFeePct?: bigint;
|
|
511
511
|
readonly referralFeeRecipient?: Address;
|
|
512
512
|
readonly deadline?: bigint;
|
|
513
|
-
}): Readonly<{
|
|
513
|
+
} & ReferenceTimestampParams): Readonly<{
|
|
514
514
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
515
515
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1RedeemAction>>;
|
|
516
516
|
}>;
|
|
517
517
|
/** {@inheritDoc VaultV1Actions.inKindRedeem} */
|
|
518
|
-
inKindRedeem(
|
|
518
|
+
inKindRedeem(params: {
|
|
519
519
|
readonly amount: bigint;
|
|
520
520
|
readonly marketParamsList: readonly MarketParams[];
|
|
521
521
|
readonly vaultData: AccrualVault;
|
|
522
522
|
readonly userAddress: Address;
|
|
523
523
|
readonly deadline?: bigint;
|
|
524
|
-
}): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
524
|
+
} & ReferenceTimestampParams): ActionOutput<VaultV1InKindRedeemAction, readonly RequirementSignature[], undefined>;
|
|
525
525
|
/** {@inheritDoc VaultV1Actions.migrateToV2} */
|
|
526
526
|
migrateToV2(params: {
|
|
527
527
|
readonly userAddress: Address;
|
|
@@ -531,7 +531,7 @@ export declare class MorphoVaultV1 implements VaultV1Actions {
|
|
|
531
531
|
readonly referralFeePct?: bigint;
|
|
532
532
|
readonly referralFeeRecipient?: Address;
|
|
533
533
|
readonly deadline?: bigint;
|
|
534
|
-
} & VaultV1MigrateToV2AmountArgs): Readonly<{
|
|
534
|
+
} & ReferenceTimestampParams & VaultV1MigrateToV2AmountArgs): Readonly<{
|
|
535
535
|
getRequirements: () => Promise<readonly (Readonly<import("../../types/action.js").Transaction<import("../../types/action.js").ERC20ApprovalAction>> | import("../../types/action.js").Requirement<import("../../types/action.js").Erc2612RequirementSignature, undefined>)[]>;
|
|
536
536
|
buildTx: (signatures?: readonly RequirementSignature[]) => Readonly<import("../../types/action.js").Transaction<VaultV1MigrateToV2Action>>;
|
|
537
537
|
}>;
|