@morpho-org/morpho-sdk 8.3.0 → 9.1.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-v8-to-v9.md +54 -0
- package/README.md +13 -7
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +5 -1
- package/lib/cjs/actions/bundles/common.d.ts +4 -7
- package/lib/cjs/actions/bundles/common.js +8 -14
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +1 -8
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -1
- package/lib/cjs/actions/midnight/authorization.js +11 -1
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +2 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +10 -2
- package/lib/cjs/actions/midnight/redeem.d.ts +3 -1
- package/lib/cjs/actions/midnight/redeem.js +9 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +7 -3
- package/lib/cjs/actions/midnight/supplyCollateral.d.ts +4 -1
- package/lib/cjs/actions/midnight/supplyCollateral.js +10 -3
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +9 -3
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +3 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +9 -3
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeLend.js +7 -2
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +8 -2
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +3 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +10 -3
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +5 -7
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +7 -11
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +8 -15
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +11 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +1 -1
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +4 -4
- package/lib/cjs/actions/vaultV1/withdraw.js +4 -4
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +1 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +1 -1
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +4 -4
- package/lib/cjs/actions/vaultV2/withdraw.js +4 -4
- 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 +2 -12
- package/lib/cjs/entities/blue/blue.js +0 -4
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +63 -18
- package/lib/cjs/entities/midnight/midnight.js +138 -53
- package/lib/cjs/entities/midnight/types.d.ts +3 -10
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +0 -7
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -20
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +40 -37
- package/lib/cjs/entities/vaultV1/vaultV1.js +5 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +69 -43
- package/lib/cjs/entities/vaultV2/vaultV2.js +41 -35
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +10 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/encodeMidnightCalldata.d.ts +48 -0
- package/lib/cjs/helpers/encodeMidnightCalldata.js +74 -0
- package/lib/cjs/helpers/slippage.d.ts +9 -25
- package/lib/cjs/helpers/slippage.js +10 -27
- package/lib/cjs/helpers/validate.d.ts +1 -0
- package/lib/cjs/helpers/validate.js +5 -0
- package/lib/cjs/helpers/validateMidnightAccount.d.ts +34 -0
- package/lib/cjs/helpers/validateMidnightAccount.js +47 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +4 -0
- package/lib/cjs/helpers/validateMidnightMarket.d.ts +2 -0
- package/lib/cjs/helpers/validateMidnightMarket.js +5 -0
- package/lib/cjs/helpers/validateMidnightPublication.d.ts +11 -0
- package/lib/cjs/helpers/validateMidnightPublication.js +12 -1
- package/lib/cjs/helpers/validateMidnightReceiver.d.ts +1 -0
- package/lib/cjs/helpers/validateMidnightReceiver.js +8 -0
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +2 -1
- package/lib/cjs/helpers/validateTakeableOffers.js +4 -3
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/types/action.d.ts +3 -1
- package/lib/cjs/types/error.d.ts +60 -6
- package/lib/cjs/types/error.js +143 -11
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +4 -7
- package/lib/esm/actions/bundles/common.js +8 -14
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +1 -5
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -9
- package/lib/esm/actions/midnight/authorization.d.ts +3 -1
- package/lib/esm/actions/midnight/authorization.js +12 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +2 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +11 -3
- package/lib/esm/actions/midnight/redeem.d.ts +3 -1
- package/lib/esm/actions/midnight/redeem.js +10 -4
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +8 -4
- package/lib/esm/actions/midnight/supplyCollateral.d.ts +4 -1
- package/lib/esm/actions/midnight/supplyCollateral.js +11 -4
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +3 -1
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +10 -4
- package/lib/esm/actions/midnight/takeBorrow.d.ts +3 -1
- package/lib/esm/actions/midnight/takeBorrow.js +10 -4
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
- package/lib/esm/actions/midnight/takeLend.js +8 -3
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +9 -3
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +3 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +11 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +1 -5
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -8
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +7 -11
- package/lib/esm/actions/requirements/getRequirementsApproval.js +9 -16
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +5 -10
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +12 -9
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +2 -0
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +5 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +1 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +1 -1
- package/lib/esm/actions/vaultV1/withdraw.d.ts +4 -4
- package/lib/esm/actions/vaultV1/withdraw.js +4 -4
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +1 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -1
- package/lib/esm/actions/vaultV2/inKindRedeem.js +1 -1
- package/lib/esm/actions/vaultV2/withdraw.d.ts +4 -4
- package/lib/esm/actions/vaultV2/withdraw.js +4 -4
- 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 +2 -12
- package/lib/esm/entities/blue/blue.js +0 -4
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +63 -18
- package/lib/esm/entities/midnight/midnight.js +139 -54
- package/lib/esm/entities/midnight/types.d.ts +3 -10
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +0 -4
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +1 -8
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -14
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +9 -21
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +40 -37
- package/lib/esm/entities/vaultV1/vaultV1.js +6 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +69 -43
- package/lib/esm/entities/vaultV2/vaultV2.js +41 -35
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
- 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/encodeMidnightCalldata.d.ts +48 -0
- package/lib/esm/helpers/encodeMidnightCalldata.js +69 -0
- package/lib/esm/helpers/slippage.d.ts +9 -25
- package/lib/esm/helpers/slippage.js +9 -25
- package/lib/esm/helpers/validate.d.ts +1 -0
- package/lib/esm/helpers/validate.js +5 -0
- package/lib/esm/helpers/validateMidnightAccount.d.ts +34 -0
- package/lib/esm/helpers/validateMidnightAccount.js +43 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -0
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +4 -0
- package/lib/esm/helpers/validateMidnightMarket.d.ts +2 -0
- package/lib/esm/helpers/validateMidnightMarket.js +5 -0
- package/lib/esm/helpers/validateMidnightPublication.d.ts +11 -0
- package/lib/esm/helpers/validateMidnightPublication.js +10 -0
- package/lib/esm/helpers/validateMidnightReceiver.d.ts +1 -0
- package/lib/esm/helpers/validateMidnightReceiver.js +8 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +2 -1
- package/lib/esm/helpers/validateTakeableOffers.js +4 -3
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/types/action.d.ts +3 -1
- package/lib/esm/types/error.d.ts +60 -6
- package/lib/esm/types/error.js +138 -7
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +8 -7
|
@@ -69,8 +69,9 @@ export interface VaultV2Actions {
|
|
|
69
69
|
* owner is consumed and none was passed explicitly.
|
|
70
70
|
* @throws {Permit2SignatureTransferNonceAlreadyUsedError} from `getRequirements()` when the
|
|
71
71
|
* explicit Permit2 nonce is consumed.
|
|
72
|
-
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256,
|
|
73
|
-
*
|
|
72
|
+
* @throws {InputExceedsMaxError} when funding or the deadline exceeds uint256, when the vault's
|
|
73
|
+
* liquidity adapter is a Midnight adapter (it cannot receive vault allocations, so no deposit
|
|
74
|
+
* fits and `max` is `0n`), or from `getRequirements()` when the Permit2 nonce exceeds uint256.
|
|
74
75
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple token signatures are supplied.
|
|
75
76
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
76
77
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender, amount or
|
|
@@ -122,16 +123,16 @@ export interface VaultV2Actions {
|
|
|
122
123
|
/**
|
|
123
124
|
* Prepares an exact-assets Vault V2 withdrawal through VaultBundlesV1.
|
|
124
125
|
*
|
|
125
|
-
* Derives the share
|
|
126
|
-
* reads the live vault-share allowance and, when a signature is needed, the permit
|
|
127
|
-
* each `getRequirements()` call. Captures the requested amount and owner at creation, so
|
|
128
|
-
* changes to `params` do not change this handle's requirements or transaction.
|
|
126
|
+
* Derives the minimum required share allowance from the supplied `vaultData` snapshot at handle
|
|
127
|
+
* creation, then reads the live vault-share allowance and, when a signature is needed, the permit
|
|
128
|
+
* nonce on each `getRequirements()` call. Captures the requested amount and owner at creation, so
|
|
129
|
+
* later changes to `params` do not change this handle's requirements or transaction.
|
|
129
130
|
*
|
|
130
131
|
* @param params.amount - Positive gross withdrawal in underlying asset base units, before fees.
|
|
131
132
|
* @param params.userAddress - Share owner that must sign and submit; receives the net assets.
|
|
132
|
-
* @param params.vaultData - Pre-fetched Vault V2 snapshot used to derive the share
|
|
133
|
-
* @param params.slippageTolerance - Optional WAD-scaled
|
|
134
|
-
*
|
|
133
|
+
* @param params.vaultData - Pre-fetched Vault V2 snapshot used to derive the minimum share allowance.
|
|
134
|
+
* @param params.slippageTolerance - Optional WAD-scaled tolerance used only to size the minimum
|
|
135
|
+
* share allowance. It does not impose an on-chain share-burn bound.
|
|
135
136
|
* Defaults to 0.03% and cannot exceed 10%.
|
|
136
137
|
* @param params.referralFeePct - Optional WAD-scaled fee in [0, 1e18), defaulting to zero;
|
|
137
138
|
* rounded down and deducted from the gross withdrawn assets.
|
|
@@ -140,20 +141,21 @@ export interface VaultV2Actions {
|
|
|
140
141
|
* defaults to two hours from handle creation.
|
|
141
142
|
* @returns A frozen handle with lazy `getRequirements()` and synchronous `buildTx(signatures?)`,
|
|
142
143
|
* which returns a deep-frozen `Transaction<VaultV2WithdrawAction>`. Requirements are empty
|
|
143
|
-
* when the allowance
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
* the allowance. Confirm the approval or pass its signed permit to `buildTx`.
|
|
144
|
+
* when the allowance meets or exceeds the required share amount. An insufficient allowance is
|
|
145
|
+
* raised by an unlimited approval or, with signature support, an ERC-2612 request. The minimum
|
|
146
|
+
* is fixed at handle creation while each call re-reads the allowance. Confirm the approval or
|
|
147
|
+
* pass its signed permit to `buildTx`.
|
|
148
148
|
* @remarks VaultBundlesV1 skips a share permit whose nonce was already consumed and proceeds
|
|
149
149
|
* under the live allowance, so execute every requirement returned by the latest
|
|
150
|
-
* `getRequirements()`
|
|
150
|
+
* `getRequirements()` before submitting.
|
|
151
151
|
* @throws {ChainIdMismatchError} when the connected client targets another chain, or from
|
|
152
152
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
153
|
-
* @throws {NonPositiveInputError} when `amount` or the computed share
|
|
153
|
+
* @throws {NonPositiveInputError} when `amount` or the computed required share amount is not positive.
|
|
154
154
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
155
155
|
* at any `getRequirements()` call.
|
|
156
|
-
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation
|
|
156
|
+
* @throws {InputExceedsMaxError} when `amount` or `deadline` exceeds uint256 at handle creation,
|
|
157
|
+
* or when the vault's liquidity adapter is a Midnight adapter and `amount` exceeds the vault's
|
|
158
|
+
* idle assets.
|
|
157
159
|
* @throws {NegativeInputError} when `referralFeePct` or `slippageTolerance` is negative.
|
|
158
160
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
159
161
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no nonzero recipient.
|
|
@@ -164,8 +166,8 @@ export interface VaultV2Actions {
|
|
|
164
166
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when an unsupported signature is supplied.
|
|
165
167
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when multiple permits are supplied.
|
|
166
168
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the share permit is malformed or
|
|
167
|
-
* its spender or deadline differ from this operation's, or its amount is
|
|
168
|
-
*
|
|
169
|
+
* its spender or deadline differ from this operation's, or its amount is below the required
|
|
170
|
+
* share allowance.
|
|
169
171
|
* @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
|
|
170
172
|
* contract has no code at its registered address.
|
|
171
173
|
* @throws {viem.BaseError} from `getRequirements()` when an allowance, nonce, or `eth_chainId`
|
|
@@ -203,8 +205,9 @@ export interface VaultV2Actions {
|
|
|
203
205
|
* Prepares an exact-shares Vault V2 redemption through VaultBundlesV1.
|
|
204
206
|
*
|
|
205
207
|
* Captures `shares` and `userAddress` at handle creation for both requirements and `buildTx()`.
|
|
206
|
-
* The caller must satisfy the
|
|
207
|
-
* `buildTx()`;
|
|
208
|
+
* The caller must satisfy the minimum share allowance returned by `getRequirements()` before
|
|
209
|
+
* `buildTx()`; larger allowances also suffice, and each requirement resolution re-reads the live
|
|
210
|
+
* allowance and checks the deadline.
|
|
208
211
|
*
|
|
209
212
|
* @param params - The redeem parameters.
|
|
210
213
|
* @param params.shares - Exact vault shares to burn.
|
|
@@ -212,13 +215,30 @@ export interface VaultV2Actions {
|
|
|
212
215
|
* @param [params.referralFeePct=0n] - WAD-scaled referral fee deducted from the redeemed assets; must be below WAD.
|
|
213
216
|
* @param [params.referralFeeRecipient] - Non-zero recipient required when `referralFeePct` is positive.
|
|
214
217
|
* @param [params.deadline] - VaultBundlesV1 execution deadline; defaults to two hours from now.
|
|
215
|
-
* @returns Lazy
|
|
218
|
+
* @returns Lazy share-allowance requirements and a synchronous transaction builder.
|
|
216
219
|
* @throws {ChainIdMismatchError} when the client and entity target different chains, or from
|
|
217
220
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
218
221
|
* @throws {NonPositiveInputError} when `shares` is not positive.
|
|
219
222
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
220
223
|
* requirement resolution.
|
|
221
|
-
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256
|
|
224
|
+
* @throws {InputExceedsMaxError} when `shares` or `deadline` exceeds uint256, or from
|
|
225
|
+
* `getRequirements()` when the vault's liquidity adapter is a Midnight adapter and `shares`
|
|
226
|
+
* are worth more than the vault's idle assets.
|
|
227
|
+
* @throws {UnknownBlueFactory} from `getRequirements()` when the configured chain has no VaultV2 factory.
|
|
228
|
+
* @throws {UnknownBlueOfFactory} from `getRequirements()` when the vault is not a VaultV2 from the
|
|
229
|
+
* configured factory.
|
|
230
|
+
* @throws {UnsupportedBlueVaultV2AdapterError} from `getRequirements()` when the vault or one of its
|
|
231
|
+
* adapters uses an unsupported adapter class.
|
|
232
|
+
* @throws {UnsupportedBlueMarketIrmError} from `getRequirements()` when the vault's liquidity adapter
|
|
233
|
+
* is a Midnight adapter and accrual projects an underlying market with positive debt that uses an
|
|
234
|
+
* unsupported IRM.
|
|
235
|
+
* @throws {UnknownBlueMarketAllocationError} from `getRequirements()` when the vault's liquidity
|
|
236
|
+
* adapter is a Midnight adapter and accrual meets a nested Vault V1 withdraw queue market without
|
|
237
|
+
* allocation data.
|
|
238
|
+
* @throws {InvalidMidnightPositionLossFactorError} from `getRequirements()` when the vault's liquidity
|
|
239
|
+
* adapter is a Midnight adapter and accrual meets a market loss factor below a position's.
|
|
240
|
+
* @throws {InvalidMidnightPositionAccrualStateError} from `getRequirements()` when the vault's
|
|
241
|
+
* liquidity adapter is a Midnight adapter and accrual meets invalid Midnight position inputs.
|
|
222
242
|
* @throws {NegativeInputError} when `referralFeePct` is negative.
|
|
223
243
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
224
244
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no non-zero recipient.
|
|
@@ -226,7 +246,7 @@ export interface VaultV2Actions {
|
|
|
226
246
|
* @throws {UnknownAddressError} when VaultBundlesV1 is not registered on the target chain.
|
|
227
247
|
* @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol
|
|
228
248
|
* contract has no code at its registered address.
|
|
229
|
-
* @throws {viem.BaseError} from `getRequirements()` when
|
|
249
|
+
* @throws {viem.BaseError} from `getRequirements()` when a vault-state, allowance, nonce, `eth_chainId`, or
|
|
230
250
|
* `eth_getCode` read fails.
|
|
231
251
|
* @throws {UnknownTokenError} from `getRequirements()` when the share token fetched by
|
|
232
252
|
* `getData()` has unusable decimals.
|
|
@@ -235,8 +255,8 @@ export interface VaultV2Actions {
|
|
|
235
255
|
* deployless query reports malformed `name()`/`symbol()`/`eip712Domain()` returndata (no fallback).
|
|
236
256
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
|
|
237
257
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
|
|
238
|
-
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender
|
|
239
|
-
* deadline
|
|
258
|
+
* @throws {BundlesPermitMismatchError} from `buildTx()` when the signature's spender or
|
|
259
|
+
* deadline differs from this operation's, or its amount is below the required share allowance.
|
|
240
260
|
* @example
|
|
241
261
|
* ```ts
|
|
242
262
|
* import { isRequirementSignature } from "@morpho-org/morpho-sdk";
|
|
@@ -279,9 +299,10 @@ export interface VaultV2Actions {
|
|
|
279
299
|
* Idle balance, penalty, and adapter positions can drift after the snapshot, so an on-chain
|
|
280
300
|
* under-coverage panic remains possible if vault state changes between preparation and inclusion.
|
|
281
301
|
*
|
|
282
|
-
* In-kind exits
|
|
283
|
-
*
|
|
284
|
-
*
|
|
302
|
+
* In-kind exits have no on-chain share-price or max-shares bound. A share-price drop before
|
|
303
|
+
* inclusion can burn more shares than quoted when the allowance is unlimited. The SDK requires
|
|
304
|
+
* the computed minimum allowance, and an insufficient allowance is raised by an unlimited
|
|
305
|
+
* approval or ERC-2612 permit.
|
|
285
306
|
*
|
|
286
307
|
* @param params - In-kind redemption parameters.
|
|
287
308
|
* @param params.amount - Penalty-inclusive, asset-denominated amount to exit.
|
|
@@ -303,9 +324,11 @@ export interface VaultV2Actions {
|
|
|
303
324
|
* @throws {InputExceedsMaxError} when `deadline` exceeds `uint256`.
|
|
304
325
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
305
326
|
* requirement resolution.
|
|
306
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter
|
|
327
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have one adapter, including
|
|
328
|
+
* a vault that mixes Blue and Midnight adapters.
|
|
307
329
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
308
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
330
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
|
|
331
|
+
* including a Midnight adapter.
|
|
309
332
|
* @throws {InKindRedeemCoverageError} when the deduplicated list cannot cover the exit.
|
|
310
333
|
* @throws {UnsupportedChainIdError} when no address registry exists for the target chain.
|
|
311
334
|
* @throws {UnknownAddressError} when VaultExitBundlesV1 is not registered on the target chain.
|
|
@@ -316,8 +339,8 @@ export interface VaultV2Actions {
|
|
|
316
339
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
|
|
317
340
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
|
|
318
341
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the supplied permit is not ERC-2612, has
|
|
319
|
-
* the wrong asset, owner, or signature encoding,
|
|
320
|
-
*
|
|
342
|
+
* the wrong asset, owner, or signature encoding, names another spender or deadline, or
|
|
343
|
+
* signs an amount below the required share allowance.
|
|
321
344
|
* @example
|
|
322
345
|
* ```ts
|
|
323
346
|
* import { isRequirementSignature } from "@morpho-org/morpho-sdk";
|
|
@@ -384,12 +407,13 @@ export interface VaultV2Actions {
|
|
|
384
407
|
* validate the user's share balance. Per-market penalties and each vault withdrawal round the
|
|
385
408
|
* share burn up independently, so the exit can burn marginally more shares than `exitAssets` alone
|
|
386
409
|
* implies; size `exitAssets` a small buffer below `vault.previewRedeem(sharesHeld)` so a
|
|
387
|
-
* full-balance exit does not revert for insufficient shares.
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
391
|
-
*
|
|
392
|
-
* ERC-20 allowance underflow
|
|
410
|
+
* full-balance exit does not revert for insufficient shares. Any approval or permit this handle
|
|
411
|
+
* returns is unlimited. The computed share amount is only the smallest existing allowance the
|
|
412
|
+
* SDK accepts without a new requirement: it covers a burn at least one `slippageTolerance` step
|
|
413
|
+
* below the price floor whenever the floor exceeds one RAY unit and, in any case, at least one
|
|
414
|
+
* share above the burn at the floor. A reused allowance just above that minimum can still
|
|
415
|
+
* surface a deeper price drop as an ERC-20 allowance underflow rather than the contract's
|
|
416
|
+
* `minSharePriceE27` check.
|
|
393
417
|
*
|
|
394
418
|
* Idle balance, penalty, adapter positions, and market liquidity can drift after the snapshot, so
|
|
395
419
|
* an on-chain revert remains possible if vault state changes between preparation and inclusion.
|
|
@@ -429,9 +453,11 @@ export interface VaultV2Actions {
|
|
|
429
453
|
* @throws {ExpiredDeadlineError} when `deadline` is not in the future at handle creation or
|
|
430
454
|
* requirement resolution.
|
|
431
455
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds the SDK maximum.
|
|
432
|
-
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter
|
|
456
|
+
* @throws {VaultV2SingleAdapterRequiredError} when the vault does not have exactly one adapter,
|
|
457
|
+
* including a vault that mixes Blue and Midnight adapters.
|
|
433
458
|
* @throws {AdapterNotPartOfVaultError} when `adapter` is not the vault's adapter.
|
|
434
|
-
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2
|
|
459
|
+
* @throws {VaultV2UnsupportedExitAdapterError} when the adapter is not a MorphoMarketV1AdapterV2,
|
|
460
|
+
* including a Midnight adapter.
|
|
435
461
|
* @throws {VaultV2UnsupportedLiquidityAdapterError} when the vault routes liquidity through
|
|
436
462
|
* another adapter.
|
|
437
463
|
* @throws {VaultV2UndecodableLiquidityDataError} when the vault's `liquidityData` does not decode
|
|
@@ -453,8 +479,8 @@ export interface VaultV2Actions {
|
|
|
453
479
|
* @throws {MissingContractCodeError} from `getRequirements()` when a fixed bundles or protocol contract has no code at its registered address.
|
|
454
480
|
* @throws {AmbiguousRequirementSignaturesError} from `buildTx()` when more than one permit signature is supplied.
|
|
455
481
|
* @throws {UnexpectedRequirementSignatureError} from `buildTx()` when a non-permit signature is supplied.
|
|
456
|
-
* @throws {BundlesPermitMismatchError} from `buildTx()` when the permit's spender
|
|
457
|
-
*
|
|
482
|
+
* @throws {BundlesPermitMismatchError} from `buildTx()` when the permit's spender or deadline
|
|
483
|
+
* differs from this operation, or its amount is below the required share allowance. Any handle built from the same inputs accepts the
|
|
458
484
|
* permit; a permit whose nonce was consumed is skipped onchain and the live allowance applies.
|
|
459
485
|
* @throws {BundlesPermitMismatchError} from `buildTx()` when the requirement has the wrong permit kind, asset, or signature encoding.
|
|
460
486
|
* @example
|
|
@@ -7,7 +7,6 @@ import { getBundlesReferralFeeAssets, normalizeBundlesCommonParams, resolveBundl
|
|
|
7
7
|
import { encodeErc20Approval, encodeVaultSharesPermit, vaultV2Deposit, vaultV2ForceRedeem, vaultV2ForceWithdraw, vaultV2InKindRedeem, vaultV2Redeem, vaultV2Withdraw, } from "../../actions/index.js";
|
|
8
8
|
import { validateClientChainId } from "../../actions/requirements/validateClientChainId.js";
|
|
9
9
|
import { computeMinForceWithdrawSharePrice, computeVaultMaxShareAllowance, computeVaultMaxSharePrice, computeVaultV2ForceWithdrawFeeSharesMinted, computeVaultV2ForceWithdrawMinSharesBurnt, computeVaultV2ForceWithdrawPlan, computeVaultV2ForceWithdrawSharesBurnt, MAX_SLIPPAGE_TOLERANCE, resolveVaultV2ForceWithdrawEligibility, validateChainId, validateSlippageTolerance, } from "../../helpers/index.js";
|
|
10
|
-
import { computeVaultShareAllowanceCeiling } from "../../helpers/slippage.js";
|
|
11
10
|
import { validateDeadline, validateNativeVaultAsset, validateReferralFee, validateUint256Field, } from "../../helpers/validate.js";
|
|
12
11
|
import { AdapterNotPartOfVaultError, EmptyMarketParamsListError, ExpiredDeadlineError, InKindRedeemCoverageError, InKindRedeemZeroDeallocationError, InputExceedsMaxError, InsufficientBlueBalanceForInKindRedeemError, NonPositiveInputError, VaultAddressMismatchError, VaultV2ForceWithdrawCoverageError, VaultV2ForceWithdrawFeeSharesExceedBurnError, VaultV2ForceWithdrawSharePriceBelowFloorError, VaultV2ForceWithdrawZeroSharePriceError, VaultV2ForceWithdrawZeroWithdrawalError, VaultV2SingleAdapterRequiredError, VaultV2UndecodableLiquidityDataError, VaultV2UnsupportedExitAdapterError, VaultV2UnsupportedLiquidityAdapterError, } from "../../types/index.js";
|
|
13
12
|
import { assertRegistryTargetsHaveCode } from "../requirements/assertContractCode.js";
|
|
@@ -16,6 +15,11 @@ import { getBundlesTokenRequirements } from "../requirements/index.js";
|
|
|
16
15
|
// Maximum accepted deadline horizon; the on-chain management fee is capped at 5%/yr so the
|
|
17
16
|
// accrual model stays well-defined inside it.
|
|
18
17
|
const VAULT_V2_FEE_PROJECTION_HORIZON = Time.s.from.y(1n);
|
|
18
|
+
/**
|
|
19
|
+
* Midnight adapters revert vault-initiated `allocate` and `deallocate` (`SelfAllocationOnly`), so a
|
|
20
|
+
* vault routing liquidity through one accepts no deposit and serves exits from idle assets only.
|
|
21
|
+
*/
|
|
22
|
+
const isMidnightLiquidityAdapter = (vaultData) => vaultData.accrualLiquidityAdapter?.type === "VaultV2MidnightAdapter";
|
|
19
23
|
/** Binds a viem client to a Vault V2 vault's action builders. */
|
|
20
24
|
export class MorphoVaultV2 {
|
|
21
25
|
client;
|
|
@@ -79,6 +83,13 @@ export class MorphoVaultV2 {
|
|
|
79
83
|
// The native path must target the chain's registered wrapped-native asset.
|
|
80
84
|
validateNativeVaultAsset(this.chainId, vaultAsset);
|
|
81
85
|
}
|
|
86
|
+
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
87
|
+
throw new InputExceedsMaxError({
|
|
88
|
+
field: funding.value > 0n ? "nativeAmount" : "amount",
|
|
89
|
+
value: funding.assets,
|
|
90
|
+
max: 0n,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
82
93
|
const referralFeeAssets = getBundlesReferralFeeAssets(funding.assets, common.referralFeePct);
|
|
83
94
|
const maxSharePrice = computeVaultMaxSharePrice({
|
|
84
95
|
vaultData,
|
|
@@ -162,6 +173,14 @@ export class MorphoVaultV2 {
|
|
|
162
173
|
throw new NonPositiveInputError("amount", amount);
|
|
163
174
|
// Reject values outside the ABI range before resolving any requirements.
|
|
164
175
|
validateUint256Field("amount", amount);
|
|
176
|
+
if (isMidnightLiquidityAdapter(vaultData) &&
|
|
177
|
+
amount > vaultData.assetBalance) {
|
|
178
|
+
throw new InputExceedsMaxError({
|
|
179
|
+
field: "amount",
|
|
180
|
+
value: amount,
|
|
181
|
+
max: vaultData.assetBalance,
|
|
182
|
+
});
|
|
183
|
+
}
|
|
165
184
|
const createdAt = Time.timestamp();
|
|
166
185
|
const deadline = params.deadline ?? createdAt + Time.s.from.h(2n);
|
|
167
186
|
if (deadline <= createdAt)
|
|
@@ -181,28 +200,19 @@ export class MorphoVaultV2 {
|
|
|
181
200
|
assets: amount,
|
|
182
201
|
slippageTolerance,
|
|
183
202
|
});
|
|
184
|
-
const maxShareAllowance = computeVaultShareAllowanceCeiling({
|
|
185
|
-
requiredShareAllowance,
|
|
186
|
-
slippageTolerance,
|
|
187
|
-
});
|
|
188
203
|
return Object.freeze({
|
|
189
204
|
getRequirements: async () => {
|
|
190
205
|
const now = Time.timestamp();
|
|
191
206
|
if (deadline <= now)
|
|
192
207
|
throw new ExpiredDeadlineError(deadline, now);
|
|
193
208
|
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
194
|
-
// Re-read the live share allowance on every call instead of caching the resolved
|
|
195
|
-
// requirements: the allowance is the sole cap on the burn, so a caller that executed the
|
|
196
|
-
// returned approval must see it satisfied on the next call, and an allowance revoked or
|
|
197
|
-
// raised afterwards must resurface as an outstanding requirement. The cap derived from
|
|
198
|
-
// `vaultData` is pinned at handle creation, so re-reading cannot move it.
|
|
209
|
+
// Re-read the live share allowance on every call instead of caching the resolved requirements.
|
|
199
210
|
return getVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
200
211
|
vaultData,
|
|
201
212
|
version: "vaultV2",
|
|
202
213
|
owner: userAddress,
|
|
203
214
|
chainId: this.chainId,
|
|
204
215
|
requiredShareAllowance,
|
|
205
|
-
maxShareAllowance,
|
|
206
216
|
deadline,
|
|
207
217
|
supportSignature: this.client.options.supportSignature,
|
|
208
218
|
now,
|
|
@@ -212,7 +222,6 @@ export class MorphoVaultV2 {
|
|
|
212
222
|
const permit = selectBundlesSharesPermitSignature(signatures, {
|
|
213
223
|
spender,
|
|
214
224
|
amount: requiredShareAllowance,
|
|
215
|
-
maxAmount: maxShareAllowance,
|
|
216
225
|
deadline,
|
|
217
226
|
});
|
|
218
227
|
return vaultV2Withdraw({
|
|
@@ -252,8 +261,20 @@ export class MorphoVaultV2 {
|
|
|
252
261
|
if (deadline <= now)
|
|
253
262
|
throw new ExpiredDeadlineError(deadline, now);
|
|
254
263
|
await this.assertWriteTargets(["bundles.vaultBundlesV1"]);
|
|
264
|
+
const vaultData = await this.getData();
|
|
265
|
+
if (isMidnightLiquidityAdapter(vaultData)) {
|
|
266
|
+
// Onchain redeem accrues interest before converting shares to assets.
|
|
267
|
+
const { vault: accrued } = vaultData.accrueInterest(now);
|
|
268
|
+
if (accrued.toAssets(shares) > accrued.assetBalance) {
|
|
269
|
+
throw new InputExceedsMaxError({
|
|
270
|
+
field: "shares",
|
|
271
|
+
value: shares,
|
|
272
|
+
max: accrued.toShares(accrued.assetBalance),
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
255
276
|
return getVaultBundlesSharesRequirements(this.client.viemClient, {
|
|
256
|
-
vaultData
|
|
277
|
+
vaultData,
|
|
257
278
|
version: "vaultV2",
|
|
258
279
|
owner: userAddress,
|
|
259
280
|
chainId: this.chainId,
|
|
@@ -421,14 +442,9 @@ export class MorphoVaultV2 {
|
|
|
421
442
|
required: peak,
|
|
422
443
|
});
|
|
423
444
|
}
|
|
424
|
-
|
|
425
|
-
// larger leftover allowance would let a share-price loss burn past `requiredShareAllowance`.
|
|
426
|
-
if (allowance === requiredShareAllowance)
|
|
445
|
+
if (allowance >= requiredShareAllowance)
|
|
427
446
|
return [];
|
|
428
|
-
|
|
429
|
-
// must be reset with an onchain approval.
|
|
430
|
-
if (allowance < requiredShareAllowance &&
|
|
431
|
-
this.client.options.supportSignature) {
|
|
447
|
+
if (this.client.options.supportSignature) {
|
|
432
448
|
return [
|
|
433
449
|
encodeVaultSharesPermit({
|
|
434
450
|
vault: vaultData,
|
|
@@ -437,7 +453,6 @@ export class MorphoVaultV2 {
|
|
|
437
453
|
owner: userAddress,
|
|
438
454
|
chainId: this.chainId,
|
|
439
455
|
nonce,
|
|
440
|
-
amount: requiredShareAllowance,
|
|
441
456
|
deadline,
|
|
442
457
|
}),
|
|
443
458
|
];
|
|
@@ -446,7 +461,7 @@ export class MorphoVaultV2 {
|
|
|
446
461
|
encodeErc20Approval({
|
|
447
462
|
token: this.vault,
|
|
448
463
|
spender: vaultExitBundlesV1,
|
|
449
|
-
amount:
|
|
464
|
+
amount: maxUint256,
|
|
450
465
|
chainId: this.chainId,
|
|
451
466
|
}),
|
|
452
467
|
];
|
|
@@ -630,17 +645,9 @@ export class MorphoVaultV2 {
|
|
|
630
645
|
// with no real protection. Its two sibling `computeMin*SharePrice` helpers cap nothing either —
|
|
631
646
|
// only the `computeMax*` ones do, where capping relaxes an upper bound and is safe.
|
|
632
647
|
validateUint256Field("minSharePriceE27", minSharePriceE27);
|
|
633
|
-
//
|
|
634
|
-
//
|
|
635
|
-
//
|
|
636
|
-
// it for a price at least one tolerance step below the floor so the miss surfaces as the
|
|
637
|
-
// bundle's own revert instead, and, in any case, for at least one share above the at-floor
|
|
638
|
-
// burn — a burn of `atFloor + 1` shares prices strictly below the floor since
|
|
639
|
-
// `atFloor >= exitAssets * RAY / floor`. The `minSharePriceE27 - 1` branch keeps the
|
|
640
|
-
// denominator strictly below the floor whenever the floor exceeds 1, so even
|
|
641
|
-
// `slippageTolerance: 0n` leaves price-space headroom; a deeper drop still exhausts the
|
|
642
|
-
// allowance first. Add the fee shares the first withdrawal mints since the burn measured
|
|
643
|
-
// on-chain includes them. Saturated at `maxUint256` as an ABI-slot guard.
|
|
648
|
+
// This is the minimum allowance needed for successful execution, not an exit cap: the bundle
|
|
649
|
+
// independently rejects a realized share price below `minSharePriceE27`. Include the fee
|
|
650
|
+
// shares minted by the first withdrawal and enough headroom for the configured tolerance.
|
|
644
651
|
const allowanceSharePriceE27 = MathLib.max(MathLib.min(MathLib.mulDivDown(minSharePriceE27, MathLib.WAD - slippageTolerance, MathLib.WAD), minSharePriceE27 - 1n), 1n);
|
|
645
652
|
const requiredShareAllowance = MathLib.min(MathLib.max(MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27), MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n) + feeSharesProjected, maxUint256);
|
|
646
653
|
const vaultExitBundlesV1 = getChainAddress(this.chainId, "bundles.vaultExitBundlesV1");
|
|
@@ -681,7 +688,6 @@ export class MorphoVaultV2 {
|
|
|
681
688
|
owner: userAddress,
|
|
682
689
|
chainId: this.chainId,
|
|
683
690
|
nonce,
|
|
684
|
-
amount: requiredShareAllowance,
|
|
685
691
|
deadline,
|
|
686
692
|
});
|
|
687
693
|
return [requirement];
|
|
@@ -690,7 +696,7 @@ export class MorphoVaultV2 {
|
|
|
690
696
|
encodeErc20Approval({
|
|
691
697
|
token: this.vault,
|
|
692
698
|
spender: vaultExitBundlesV1,
|
|
693
|
-
amount:
|
|
699
|
+
amount: maxUint256,
|
|
694
700
|
chainId: this.chainId,
|
|
695
701
|
}),
|
|
696
702
|
];
|
|
@@ -39,8 +39,9 @@ export interface InputVaultV2BlueReallocationData {
|
|
|
39
39
|
/**
|
|
40
40
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
41
41
|
*
|
|
42
|
-
* Constructor inputs are cloned
|
|
43
|
-
*
|
|
42
|
+
* Constructor inputs are cloned, except Midnight adapter snapshots: those are
|
|
43
|
+
* shared by reference and must be treated as read-only. Every simulated
|
|
44
|
+
* reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
44
45
|
* denominator outside the durable snapshot while applying reallocations in
|
|
45
46
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
46
47
|
* excluded from same-plan idle liquidity so round-up dust cannot create
|
|
@@ -100,7 +101,8 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
100
101
|
/**
|
|
101
102
|
* Clones the complete simulation snapshot.
|
|
102
103
|
*
|
|
103
|
-
* @returns A deep clone of this simulation state.
|
|
104
|
+
* @returns A deep clone of this simulation state. Midnight adapter snapshots are
|
|
105
|
+
* shared by reference and must be treated as read-only.
|
|
104
106
|
* @example
|
|
105
107
|
* ```ts
|
|
106
108
|
* import { markets } from "@morpho-org/morpho-test";
|
|
@@ -75,6 +75,10 @@ const cloneAccrualVault = (vault, markets) => new AccrualVault({
|
|
|
75
75
|
position: clonePosition(position, markets),
|
|
76
76
|
})));
|
|
77
77
|
const cloneAdapter = (adapter, markets) => {
|
|
78
|
+
// BluePublicAllocator never moves Midnight liquidity, and reallocation never mutates a Midnight
|
|
79
|
+
// adapter, so its read-only snapshot is shared as-is.
|
|
80
|
+
if (adapter.type === "VaultV2MidnightAdapter")
|
|
81
|
+
return adapter;
|
|
78
82
|
const base = {
|
|
79
83
|
address: adapter.address,
|
|
80
84
|
parentVault: adapter.parentVault,
|
|
@@ -122,8 +126,9 @@ const cloneVault = (vault, { markets, adapterKeysToClone, }) => {
|
|
|
122
126
|
/**
|
|
123
127
|
* Immutable-by-convention state container for Vault V2 BluePublicAllocator simulations.
|
|
124
128
|
*
|
|
125
|
-
* Constructor inputs are cloned
|
|
126
|
-
*
|
|
129
|
+
* Constructor inputs are cloned, except Midnight adapter snapshots: those are
|
|
130
|
+
* shared by reference and must be treated as read-only. Every simulated
|
|
131
|
+
* reallocation returns a new instance. Planning keeps the transaction-scoped `firstTotalAssets`
|
|
127
132
|
* denominator outside the durable snapshot while applying reallocations in
|
|
128
133
|
* contract order. Penalty donations update simulated vault accounting but are
|
|
129
134
|
* excluded from same-plan idle liquidity so round-up dust cannot create
|
|
@@ -245,7 +250,8 @@ export class VaultV2BlueReallocationData {
|
|
|
245
250
|
/**
|
|
246
251
|
* Clones the complete simulation snapshot.
|
|
247
252
|
*
|
|
248
|
-
* @returns A deep clone of this simulation state.
|
|
253
|
+
* @returns A deep clone of this simulation state. Midnight adapter snapshots are
|
|
254
|
+
* shared by reference and must be treated as read-only.
|
|
249
255
|
* @example
|
|
250
256
|
* ```ts
|
|
251
257
|
* import { markets } from "@morpho-org/morpho-test";
|
package/lib/esm/errors.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, InvalidVaultV2MidnightAdapterMarketsError as InvalidBlueVaultV2MidnightAdapterMarketsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError as BlueUnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
6
|
export type { ErrorClass } from "@morpho-org/morpho-ts";
|
|
7
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
|
7
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, InvalidPositionAccrualStateError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
1
|
+
export { BlueErrors, IncompleteChainRegistryError, InvalidMarketParamsError as InvalidBlueMarketParamsError, InvalidVaultV2MidnightAdapterMarketsError as InvalidBlueVaultV2MidnightAdapterMarketsError, UnknownAddressError, UnknownDataError as UnknownBlueDataError, UnknownFactory as UnknownBlueFactory, UnknownMarketAllocationError as UnknownBlueMarketAllocationError, UnknownMarketParamsError as UnknownBlueMarketParamsError, UnknownOfFactory as UnknownBlueOfFactory, UnknownTokenError as UnknownBlueTokenError, UnknownTokenPriceError as UnknownBlueTokenPriceError, UnknownVaultConfigError as UnknownBlueVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError as UnsupportedBlueMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError as UnsupportedBluePreLiquidationParamsError, UnsupportedVaultV2AdapterError as UnsupportedBlueVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
-
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError,
|
|
6
|
-
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
|
4
|
+
export { getUnsupportedVaultV2Adapter as getBlueUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError as isBlueUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError as BlueMarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnresolvedBlockNumberError as BlueUnresolvedBlockNumberError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
|
5
|
+
export { ChainIdMismatchError as MidnightChainIdMismatchError, InvalidEcrecoverSignatureVError as InvalidMidnightEcrecoverSignatureVError, InvalidMarketParameterError as InvalidMidnightMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError as InvalidMidnightOfferGroupError, InvalidOfferParameterError as InvalidMidnightOfferParameterError, InvalidRateRatifierV1RateError as InvalidMidnightRateRatifierV1RateError, InvalidRateRatifierV1TickError as InvalidMidnightRateRatifierV1TickError, InvalidRateRatifierV1TimeError as InvalidMidnightRateRatifierV1TimeError, InvalidRatifierV1AddressError as InvalidMidnightRatifierV1AddressError, InvalidTickSpacingError as InvalidMidnightTickSpacingError, InvalidTreeError as InvalidMidnightTreeError, InvalidTreeHeightError as InvalidMidnightTreeHeightError, InvalidTypedDataSignatureError as InvalidMidnightTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError as MidnightPayloadDecodeError, PriceGreaterThanOneError as MidnightPriceGreaterThanOneError, RateRatifierV1BoundOverflowError as MidnightRateRatifierV1BoundOverflowError, RatifierV1TakerNotAllowedError as MidnightRatifierV1TakerNotAllowedError, SettlementFeeExceedsPriceError as MidnightSettlementFeeExceedsPriceError, TickOutOfRangeError as MidnightTickOutOfRangeError, UnknownCollateralIndexError as UnknownMidnightCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
6
|
+
export { _try, DivisionByZeroError, InvalidAddressError, InvalidBitLengthError, InvalidPositionAccrualStateError, InvalidPositionAccrualStateError as InvalidMidnightPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionAccrualTimestampError as InvalidMidnightPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidPositionLossFactorError as InvalidMidnightPositionLossFactorError, NegativeValueError, RegistryValueAlreadyRegisteredError, } from "@morpho-org/morpho-ts";
|
package/lib/esm/fetch.d.ts
CHANGED
|
@@ -1,6 +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, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
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";
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
6
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
package/lib/esm/fetch.js
CHANGED
|
@@ -1,6 +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, fetchAccrualVaultV2MidnightAdapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket as fetchBlueMarket, fetchMarketParams as fetchBlueMarketParams, fetchPosition as fetchBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams as fetchBluePreLiquidationParams,
|
|
4
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";
|
|
5
|
+
fetchPreLiquidationPosition as fetchBluePreLiquidationPosition, fetchToken, fetchUser as fetchBlueUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MidnightAdapter, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
|
6
6
|
export { fetchAccrualPosition as fetchMidnightAccrualPosition, fetchMarket as fetchMidnightMarket, fetchMarketParams as fetchMidnightMarketParams, fetchPosition as fetchMidnightPosition, fetchRatifierInfo as fetchMidnightRatifierInfo, } from "@morpho-org/midnight-sdk";
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type MarketInput } from "@morpho-org/midnight-sdk";
|
|
2
|
+
import { type Abi, type ContractFunctionName, type EncodeFunctionDataParameters, type EncodeFunctionDataReturnType } from "viem";
|
|
3
|
+
/**
|
|
4
|
+
* `encodeFunctionData` for Midnight builders that reports invalid inputs as a typed SDK error.
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
* @param parameters - viem `encodeFunctionData` parameters.
|
|
8
|
+
* @returns The encoded calldata.
|
|
9
|
+
* @throws {MidnightCalldataEncodingError} when viem cannot encode an argument.
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { midnightAbi } from "@morpho-org/midnight-sdk";
|
|
13
|
+
*
|
|
14
|
+
* const data = encodeMidnightCalldata({
|
|
15
|
+
* abi: midnightAbi,
|
|
16
|
+
* functionName: "setIsAuthorized",
|
|
17
|
+
* args: [operator, true, owner],
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function encodeMidnightCalldata<const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi> | undefined = undefined>(parameters: EncodeFunctionDataParameters<abi, functionName>): EncodeFunctionDataReturnType;
|
|
22
|
+
/**
|
|
23
|
+
* Runs a Midnight ABI encoding step and reports a viem encoding failure as a typed SDK error.
|
|
24
|
+
*
|
|
25
|
+
* @internal
|
|
26
|
+
* @param name - Name of the encoded value, reported as the error's `input`.
|
|
27
|
+
* @param encode - Encoding step, such as hashing a market or an offer tree.
|
|
28
|
+
* @returns The encoding step's result.
|
|
29
|
+
* @throws {MidnightCalldataEncodingError} when `encode` throws a viem error.
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const tree = wrapMidnightEncoding("offers", () => Tree.from(offers));
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export declare function wrapMidnightEncoding<T>(name: string, encode: () => T): T;
|
|
36
|
+
/**
|
|
37
|
+
* `MarketUtils.toId` for Midnight builders that reports an unencodable market as a typed SDK error.
|
|
38
|
+
*
|
|
39
|
+
* @internal
|
|
40
|
+
* @param market - Midnight market whose struct is ABI-encoded and hashed.
|
|
41
|
+
* @returns The market id.
|
|
42
|
+
* @throws {MidnightCalldataEncodingError} when viem cannot encode a market field.
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* const marketId = encodeMidnightMarketId(market);
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function encodeMidnightMarketId(market: MarketInput): `0x${string}`;
|