@morpho-org/morpho-sdk 8.3.0 → 9.0.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/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/entities/blue/blue.d.ts +2 -12
- package/lib/cjs/entities/blue/blue.js +0 -4
- package/lib/cjs/entities/midnight/midnight.d.ts +56 -17
- package/lib/cjs/entities/midnight/midnight.js +131 -52
- package/lib/cjs/entities/midnight/types.d.ts +2 -9
- 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 +36 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +8 -34
- 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/types/action.d.ts +3 -1
- package/lib/cjs/types/error.d.ts +56 -5
- package/lib/cjs/types/error.js +139 -10
- 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/entities/blue/blue.d.ts +2 -12
- package/lib/esm/entities/blue/blue.js +0 -4
- package/lib/esm/entities/midnight/midnight.d.ts +56 -17
- package/lib/esm/entities/midnight/midnight.js +132 -53
- package/lib/esm/entities/midnight/types.d.ts +2 -9
- 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 +36 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +8 -34
- 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/types/action.d.ts +3 -1
- package/lib/esm/types/error.d.ts +56 -5
- package/lib/esm/types/error.js +134 -6
- package/package.json +4 -3
|
@@ -114,6 +114,7 @@ export declare class MorphoMidnight {
|
|
|
114
114
|
* @returns Prepared tree, groups, ratifier, and encoded payload used by maker flows.
|
|
115
115
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`, another chain than this entity's.
|
|
116
116
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
117
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
117
118
|
* @throws {MidnightMempoolValidationError} when the Midnight mempool API rejects the offer tree
|
|
118
119
|
* (not thrown when `validation` is `false`).
|
|
119
120
|
* @throws {MidnightOfferMakerMismatchError} when an offer belongs to another maker.
|
|
@@ -123,6 +124,8 @@ export declare class MorphoMidnight {
|
|
|
123
124
|
* @throws {MidnightOfferMarketAddressMismatchError} when an offer targets another Midnight deployment.
|
|
124
125
|
* @throws {UnknownAddressError} when the chain has no deployment for the tree's V1 ratifier.
|
|
125
126
|
* @throws {MidnightOfferRatifierMismatchError} when an offer does not use its tree's ratifier.
|
|
127
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
128
|
+
* @throws {MidnightCalldataEncodingError} when an offer cannot be ABI-encoded, such as an out-of-range integer, or `accountAddress` is not a well-formed address.
|
|
126
129
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
127
130
|
* @throws {MidnightOfferExpiredError} when an offer expiry is not later than the pinned block timestamp.
|
|
128
131
|
* @throws {MidnightOfferExpiryAfterMaturityError} when an offer expiry exceeds its market maturity.
|
|
@@ -171,6 +174,8 @@ export declare class MorphoMidnight {
|
|
|
171
174
|
* @returns Lazy loan-token approval and `MidnightBundlesV2` authorization requirements, and a synchronous transaction builder.
|
|
172
175
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
173
176
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
177
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
178
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
174
179
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
175
180
|
* RPC read fails.
|
|
176
181
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` deployment.
|
|
@@ -204,7 +209,6 @@ export declare class MorphoMidnight {
|
|
|
204
209
|
* offers plus the fallback.
|
|
205
210
|
* @throws {MidnightContractReceiverError} when `referralFeeRecipient` is a Midnight protocol
|
|
206
211
|
* contract or a market token contract with a positive referral fee.
|
|
207
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below the pulled loan assets.
|
|
208
212
|
* @example
|
|
209
213
|
* ```ts
|
|
210
214
|
* const output = midnight.takeLend({
|
|
@@ -245,11 +249,14 @@ export declare class MorphoMidnight {
|
|
|
245
249
|
* Midnight protocol and market token contracts are rejected.
|
|
246
250
|
* @param params.takeableOffers - Lend-side offers returned by the Midnight API.
|
|
247
251
|
* @param params.deadline - Bounded bundle execution deadline timestamp.
|
|
248
|
-
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the
|
|
252
|
+
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the sale
|
|
253
|
+
* proceeds; on an assets target it is added on top of `target.assets`.
|
|
249
254
|
* @param params.referralFeeRecipient - Referral fee recipient; required with a positive fee.
|
|
250
255
|
* @returns Lazy `MidnightBundlesV2` authorization requirement and a synchronous transaction builder.
|
|
251
256
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
252
257
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
258
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
259
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
253
260
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
254
261
|
* RPC read fails.
|
|
255
262
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` deployment.
|
|
@@ -329,11 +336,14 @@ export declare class MorphoMidnight {
|
|
|
329
336
|
* Midnight protocol and market token contracts are rejected.
|
|
330
337
|
* @param params.takeableOffers - Lend-side offers returned by the Midnight API.
|
|
331
338
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
332
|
-
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the
|
|
339
|
+
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the sale
|
|
340
|
+
* proceeds; on an assets target it is added on top of `target.assets`.
|
|
333
341
|
* @param params.referralFeeRecipient - Referral fee recipient; required with a positive fee.
|
|
334
342
|
* @returns Lazy `MidnightBundlesV2` authorization requirement and a synchronous transaction builder.
|
|
335
343
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
336
344
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
345
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
346
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
337
347
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
338
348
|
* RPC read fails.
|
|
339
349
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
@@ -409,11 +419,14 @@ export declare class MorphoMidnight {
|
|
|
409
419
|
* Midnight protocol and market token contracts are rejected.
|
|
410
420
|
* @param params.takeableOffers - Lend-side offers returned by the Midnight API.
|
|
411
421
|
* @param params.deadline - Bounded bundle execution deadline timestamp.
|
|
412
|
-
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the
|
|
422
|
+
* @param params.referralFeePct - Optional WAD-scaled referral fee taken from the sale
|
|
423
|
+
* proceeds; on an assets target it is added on top of `target.assets`.
|
|
413
424
|
* @param params.referralFeeRecipient - Referral fee recipient; required with a positive fee.
|
|
414
425
|
* @returns Lazy collateral approvals and `MidnightBundlesV2` authorization requirements, and a synchronous transaction builder.
|
|
415
426
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
416
427
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
428
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
429
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
417
430
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
418
431
|
* RPC read fails.
|
|
419
432
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` deployment.
|
|
@@ -454,7 +467,6 @@ export declare class MorphoMidnight {
|
|
|
454
467
|
* withdrawal.
|
|
455
468
|
* @throws {MidnightTakeTargetUnreachableError} when the live offers cannot hold the target, or
|
|
456
469
|
* its bounds cannot hold at any fill.
|
|
457
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below a collateral token's pulled assets.
|
|
458
470
|
* @example
|
|
459
471
|
* ```ts
|
|
460
472
|
* const output = midnight.supplyCollateralTakeBorrow({
|
|
@@ -514,6 +526,8 @@ export declare class MorphoMidnight {
|
|
|
514
526
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
515
527
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
516
528
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
529
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
530
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
517
531
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
518
532
|
* RPC read fails.
|
|
519
533
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` deployment.
|
|
@@ -558,7 +572,6 @@ export declare class MorphoMidnight {
|
|
|
558
572
|
* @throws {MidnightContractReceiverError} when `collateralReceiver` is a Midnight protocol
|
|
559
573
|
* contract or a market token contract, or when `referralFeeRecipient` is either with a
|
|
560
574
|
* positive referral fee.
|
|
561
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below the pulled loan assets.
|
|
562
575
|
* @example
|
|
563
576
|
* ```ts
|
|
564
577
|
* const output = midnight.takeRepayWithdrawCollateral({
|
|
@@ -580,23 +593,30 @@ export declare class MorphoMidnight {
|
|
|
580
593
|
* Prepares a direct collateral supply using a caller-provided market snapshot.
|
|
581
594
|
*
|
|
582
595
|
* @param params - Supplier, market snapshot, collateral amount, reserve, and optional collateral index.
|
|
583
|
-
* @param params.accountAddress - Account receiving the supplied collateral position.
|
|
596
|
+
* @param params.accountAddress - Account receiving the supplied collateral position. It must send
|
|
597
|
+
* the transaction: Midnight pulls the collateral from `msg.sender` and only lets the position owner
|
|
598
|
+
* or its operators supply for it, and the approval requirements are resolved for this account.
|
|
584
599
|
* @param params.marketData - Hydrated market snapshot used for validation and transaction construction.
|
|
585
600
|
* @param params.collateralAssets - Collateral assets supplied in this transaction.
|
|
586
601
|
* @param params.reservedCollateralAssets - Existing collateral reserved by other open maker groups.
|
|
587
|
-
*
|
|
602
|
+
* Only raises the approval requirement so those groups keep their allowance; the transaction
|
|
603
|
+
* transfers only `collateralAssets`.
|
|
604
|
+
* @param params.collateralIndex - Optional collateral index; defaults to `0n`. Indexes follow the
|
|
605
|
+
* market's collateral parameters, which Midnight sorts by token address, not the order they were
|
|
606
|
+
* listed in when the market was built; check `marketData.getCollateralByIndex(index).token`.
|
|
588
607
|
* @returns Lazy token-approval requirements and a synchronous transaction builder.
|
|
589
608
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
590
609
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
610
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
591
611
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
592
612
|
* RPC read fails.
|
|
593
613
|
* @throws {MidnightMarketAddressMismatchError} when market data targets another Midnight deployment.
|
|
594
614
|
* @throws {NonPositiveInputError} when `collateralAssets` is non-positive.
|
|
595
615
|
* @throws {InputExceedsMaxError} when `collateralAssets` exceeds `uint128`.
|
|
596
616
|
* @throws {NegativeInputError} when `reservedCollateralAssets` is negative.
|
|
597
|
-
* @throws {MidnightZeroOnBehalfError} from `buildTx()` when `accountAddress`
|
|
617
|
+
* @throws {MidnightZeroOnBehalfError} from `getRequirements()` and `buildTx()` when `accountAddress`
|
|
618
|
+
* is the zero address.
|
|
598
619
|
* @throws {UnknownCollateralIndexError} when the selected collateral is not configured.
|
|
599
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below the pulled collateral assets.
|
|
600
620
|
* @example
|
|
601
621
|
* ```ts
|
|
602
622
|
* const output = midnight.supplyCollateral({
|
|
@@ -627,9 +647,12 @@ export declare class MorphoMidnight {
|
|
|
627
647
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups, excluding groups in `cancellations`.
|
|
628
648
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
629
649
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
650
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
651
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
630
652
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
631
653
|
* RPC read fails.
|
|
632
654
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
655
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
633
656
|
* @throws {MidnightOfferReduceOnlyError} when an offer is reduce-only.
|
|
634
657
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` or V1 ratifier deployment.
|
|
635
658
|
* @throws {NonPositiveInputError} when `loanAssets` is non-positive.
|
|
@@ -660,7 +683,6 @@ export declare class MorphoMidnight {
|
|
|
660
683
|
* @throws {MidnightMarketLiquidationCursorNotEnabledError} when an uncreated market uses a disabled liquidation cursor.
|
|
661
684
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
662
685
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
663
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below `loanAssets + reservedLoanAssets`.
|
|
664
686
|
* @throws {ExpiredDeadlineError} when `params.deadline` is at or before the local clock (`Time.timestamp()`), including zero or negative values.
|
|
665
687
|
* @example
|
|
666
688
|
* ```ts
|
|
@@ -691,9 +713,12 @@ export declare class MorphoMidnight {
|
|
|
691
713
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
692
714
|
* @returns Prepared group metadata, lazy authorization requirements, and a synchronous transaction builder.
|
|
693
715
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
716
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
717
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
694
718
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
695
719
|
* RPC read fails.
|
|
696
720
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
721
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
697
722
|
* @throws {MidnightOfferReduceOnlyError} when an offer is reduce-only.
|
|
698
723
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` or V1 ratifier deployment.
|
|
699
724
|
* @throws {NegativeInputError} when a `maxConsumed` ceiling is negative.
|
|
@@ -777,6 +802,8 @@ export declare class MorphoMidnight {
|
|
|
777
802
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
778
803
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId`,
|
|
779
804
|
* another chain than `this.chainId`.
|
|
805
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
806
|
+
* @throws {MidnightCalldataEncodingError} when the offer tree or `blueMarket` cannot be ABI-encoded.
|
|
780
807
|
* @throws {viem.BaseError} when the `eth_chainId` request, a Blue market RPC read, or a
|
|
781
808
|
* requirement RPC read fails.
|
|
782
809
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2`, `midnightBlueBuyCallbackFactory`, `midnight`, `blue` or V1 ratifier deployment.
|
|
@@ -788,6 +815,7 @@ export declare class MorphoMidnight {
|
|
|
788
815
|
* @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
|
|
789
816
|
* @throws {NativeAmountOnNonWNativeAssetError} when `blueMarket.loanToken` is not wNative.
|
|
790
817
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
818
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
791
819
|
* @throws {MidnightMempoolValidationError} when the Midnight mempool API rejects the offer tree
|
|
792
820
|
* (not thrown when `validation` is `false`).
|
|
793
821
|
* @throws {MidnightOfferMarketChainMismatchError} when an offer targets another chain.
|
|
@@ -817,7 +845,6 @@ export declare class MorphoMidnight {
|
|
|
817
845
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
818
846
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
819
847
|
* @throws {DuplicateMidnightGroupCancellationError} when a cancelled group appears more than once.
|
|
820
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below `assetsToPark`.
|
|
821
848
|
* @throws {ExpiredDeadlineError} when `params.deadline` is at or before the local clock (`Time.timestamp()`), including zero or negative values.
|
|
822
849
|
* @example
|
|
823
850
|
* ```ts
|
|
@@ -859,9 +886,12 @@ export declare class MorphoMidnight {
|
|
|
859
886
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
860
887
|
* @returns Prepared root and groups, lazy requirements, and a synchronous publication builder.
|
|
861
888
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
889
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
890
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
862
891
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
863
892
|
* RPC read fails.
|
|
864
893
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
894
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
865
895
|
* @throws {MidnightOfferSideMismatchError} when an offer is not a sell offer (`buy = false`).
|
|
866
896
|
* @throws {MidnightOfferNotReduceOnlyError} when any offer can increase a position.
|
|
867
897
|
* @throws {MidnightOfferCallbackNotSupportedError} when an offer has a nonzero callback.
|
|
@@ -929,9 +959,12 @@ export declare class MorphoMidnight {
|
|
|
929
959
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups.
|
|
930
960
|
* @returns Prepared root and groups, lazy requirements, and a synchronous publication builder.
|
|
931
961
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
962
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
963
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
932
964
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
933
965
|
* RPC read fails.
|
|
934
966
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
967
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
935
968
|
* @throws {MidnightOfferSideMismatchError} when an offer is not a buy offer (`buy = true`).
|
|
936
969
|
* @throws {MidnightOfferNotReduceOnlyError} when any offer can increase a position.
|
|
937
970
|
* @throws {MidnightOfferCallbackNotSupportedError} when an offer has a nonzero callback.
|
|
@@ -963,7 +996,6 @@ export declare class MorphoMidnight {
|
|
|
963
996
|
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
964
997
|
* @throws {DuplicateMidnightGroupCancellationError} when a cancelled group appears more than once.
|
|
965
998
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
966
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below `loanAssets + reservedLoanAssets`.
|
|
967
999
|
* @throws {ExpiredDeadlineError} when `params.deadline` is at or before the local clock (`Time.timestamp()`), including zero or negative values.
|
|
968
1000
|
* @example
|
|
969
1001
|
* ```ts
|
|
@@ -1004,6 +1036,8 @@ export declare class MorphoMidnight {
|
|
|
1004
1036
|
* required for the full pulled amount.
|
|
1005
1037
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
1006
1038
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
1039
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
1040
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
1007
1041
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
1008
1042
|
* RPC read fails.
|
|
1009
1043
|
* @throws {UnknownAddressError} when the chain has no `midnightBundlesV2` or V1 ratifier deployment.
|
|
@@ -1016,6 +1050,7 @@ export declare class MorphoMidnight {
|
|
|
1016
1050
|
* @throws {ChainWNativeMissingError} when wNative is not configured for the chain.
|
|
1017
1051
|
* @throws {NativeAmountOnNonWNativeAssetError} when no collateral pull uses wNative.
|
|
1018
1052
|
* @throws {InvalidTreeError} when the input does not form a non-empty valid tree.
|
|
1053
|
+
* @throws {InvalidMidnightOfferGroupError} when a priceV1/rateV1 `Tree.create` request has explicit groups that break `OfferUtils.validateOfferGroup` rules.
|
|
1019
1054
|
* @throws {MidnightMempoolValidationError} when the Midnight mempool API rejects the offer tree
|
|
1020
1055
|
* (not thrown when `validation` is `false`).
|
|
1021
1056
|
* @throws {MidnightOfferMarketChainMismatchError} when an offer targets another chain.
|
|
@@ -1044,7 +1079,6 @@ export declare class MorphoMidnight {
|
|
|
1044
1079
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
1045
1080
|
* @throws {InvalidMidnightHexInputError} when a cancellation group is not 32-byte hex.
|
|
1046
1081
|
* @throws {DuplicateMidnightGroupCancellationError} when a cancelled group appears more than once.
|
|
1047
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below a collateral token's pulled assets.
|
|
1048
1082
|
* @throws {ExpiredDeadlineError} when `params.deadline` is at or before the local clock (`Time.timestamp()`), including zero or negative values.
|
|
1049
1083
|
* @example
|
|
1050
1084
|
* ```ts
|
|
@@ -1064,7 +1098,9 @@ export declare class MorphoMidnight {
|
|
|
1064
1098
|
* Prepares redemption of accrued Midnight credit from a position snapshot.
|
|
1065
1099
|
*
|
|
1066
1100
|
* @param params - Position owner, accrued position, optional unit amount, and receiver.
|
|
1067
|
-
* @param params.accountAddress - Position owner whose credit is redeemed.
|
|
1101
|
+
* @param params.accountAddress - Position owner whose credit is redeemed. It must send the
|
|
1102
|
+
* transaction (or authorize the sender): Midnight reverts `Unauthorized()` otherwise, which
|
|
1103
|
+
* `getRequirements()` cannot detect because it does not know the sender.
|
|
1068
1104
|
* @param params.positionData - Owner-bound position snapshot returned by `getPositionData`.
|
|
1069
1105
|
* @param params.receiver - Optional credit receiver; defaults to the position owner.
|
|
1070
1106
|
* Midnight protocol and market token contracts are rejected.
|
|
@@ -1077,6 +1113,7 @@ export declare class MorphoMidnight {
|
|
|
1077
1113
|
* is left. Redeem again after maturity to empty the position.
|
|
1078
1114
|
* @returns No requirements and a synchronous redemption transaction builder.
|
|
1079
1115
|
* @throws {ChainIdMismatchError} when the position market targets another chain.
|
|
1116
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
1080
1117
|
* @throws {MidnightMarketAddressMismatchError} when the position market targets another Midnight deployment.
|
|
1081
1118
|
* @throws {MissingAccrualPositionError} when no position snapshot is supplied.
|
|
1082
1119
|
* @throws {AccrualPositionUserMismatchError} when the position snapshot belongs to another account.
|
|
@@ -1119,7 +1156,7 @@ export declare class MorphoMidnight {
|
|
|
1119
1156
|
* scaled by `ORACLE_PRICE_SCALE`. An empty array is safe only when
|
|
1120
1157
|
* `collateralWithdrawals` is empty or the conservative post-operation debt is zero: a `full`
|
|
1121
1158
|
* repay, or `repay.assets` covering `positionData.debt`.
|
|
1122
|
-
* @param params.repay - `{ type: "assets", assets }` (`0n` to only withdraw) or `{ type: "full", maxBuyerAssets }`; a loan-token approval to `MidnightBundlesV2` is required when the allowance is below the pulled amount
|
|
1159
|
+
* @param params.repay - `{ type: "assets", assets }` (`0n` to only withdraw) or `{ type: "full", maxBuyerAssets }`; a loan-token approval to `MidnightBundlesV2` is required when the allowance is below the pulled amount (unlimited: `maxUint256`, capped per token by `MAX_TOKEN_APPROVALS`), and any unused part is refunded.
|
|
1123
1160
|
* @param params.nativeAmount - Optional native ETH sent as `value`; the bundle wraps it into the
|
|
1124
1161
|
* chain's wNative and transfers it to `msg.sender` before pulling. It may cover part or all of
|
|
1125
1162
|
* the maximum wNative amount this call can pull, but not more. Any wrapped native not pulled
|
|
@@ -1135,6 +1172,8 @@ export declare class MorphoMidnight {
|
|
|
1135
1172
|
* @returns Lazy loan approval/authorization requirements and a synchronous transaction builder.
|
|
1136
1173
|
* @throws {ChainIdMismatchError} when client or market data targets another chain, or from
|
|
1137
1174
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
1175
|
+
* @throws {MidnightZeroAccountError} when `accountAddress` is the zero address.
|
|
1176
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as a malformed `bytes32` or an out-of-range integer.
|
|
1138
1177
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
1139
1178
|
* RPC read fails.
|
|
1140
1179
|
* @throws {MidnightMarketAddressMismatchError} when market data targets another Midnight deployment.
|
|
@@ -1159,7 +1198,6 @@ export declare class MorphoMidnight {
|
|
|
1159
1198
|
* during this method call, before the lazy output is returned.
|
|
1160
1199
|
* @throws {MidnightContractReceiverError} when `collateralReceiver` is a Midnight protocol
|
|
1161
1200
|
* contract or a market token contract.
|
|
1162
|
-
* @throws {ApprovalAmountLessThanSpendAmountError} from `getRequirements()` when `approvalAmount` is below the pulled loan assets.
|
|
1163
1201
|
* @throws {ExpiredDeadlineError} when `params.deadline` is at or before the local clock (`Time.timestamp()`), including zero or negative values.
|
|
1164
1202
|
* @example
|
|
1165
1203
|
* ```ts
|
|
@@ -1197,6 +1235,7 @@ export declare class MorphoMidnight {
|
|
|
1197
1235
|
* @returns Lazy Midnight authorization requirement for `MidnightBundlesV2` and a synchronous transaction builder.
|
|
1198
1236
|
* @throws {ChainIdMismatchError} when the client targets another chain, or from
|
|
1199
1237
|
* `getRequirements()` when the RPC reports another chain via `eth_chainId`.
|
|
1238
|
+
* @throws {MidnightCalldataEncodingError} when an input cannot be ABI-encoded, such as an out-of-range integer.
|
|
1200
1239
|
* @throws {viem.BaseError} from `getRequirements()` when an `eth_chainId` request or requirement
|
|
1201
1240
|
* RPC read fails.
|
|
1202
1241
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|