@morpho-org/morpho-sdk 9.0.0 → 9.1.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/README.md +3 -1
- package/lib/cjs/actions/blue/borrow.d.ts +1 -0
- package/lib/cjs/actions/blue/borrow.js +1 -0
- package/lib/cjs/actions/blue/refinance.d.ts +1 -0
- package/lib/cjs/actions/blue/refinance.js +3 -0
- package/lib/cjs/actions/blue/repay.d.ts +1 -0
- package/lib/cjs/actions/blue/repay.js +1 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -0
- package/lib/cjs/actions/blue/supply.d.ts +1 -0
- package/lib/cjs/actions/blue/supply.js +2 -0
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +1 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +2 -0
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -0
- package/lib/cjs/actions/blue/withdraw.js +2 -0
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -0
- package/lib/cjs/actions/midnight/takeLend.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeLend.js +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -7
- package/lib/cjs/entities/blue/blue.d.ts +43 -7
- package/lib/cjs/entities/blue/blue.js +27 -3
- package/lib/cjs/entities/midnight/midnight.d.ts +14 -6
- package/lib/cjs/entities/midnight/midnight.js +14 -6
- package/lib/cjs/entities/midnight/types.d.ts +9 -2
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +3 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +8 -5
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +40 -13
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +207 -70
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -2
- package/lib/cjs/helpers/validate.d.ts +11 -1
- package/lib/cjs/helpers/validate.js +17 -1
- package/lib/cjs/helpers/validateTakeableOffers.d.ts +4 -2
- package/lib/cjs/helpers/validateTakeableOffers.js +12 -1
- package/lib/cjs/types/error.d.ts +10 -1
- package/lib/cjs/types/error.js +13 -2
- package/lib/cjs/types/sharedLiquidity.d.ts +27 -11
- package/lib/esm/actions/blue/borrow.d.ts +1 -0
- package/lib/esm/actions/blue/borrow.js +1 -0
- package/lib/esm/actions/blue/refinance.d.ts +1 -0
- package/lib/esm/actions/blue/refinance.js +4 -1
- package/lib/esm/actions/blue/repay.d.ts +1 -0
- package/lib/esm/actions/blue/repay.js +1 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -1
- package/lib/esm/actions/blue/supply.d.ts +1 -0
- package/lib/esm/actions/blue/supply.js +3 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/supplyCollateral.js +1 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +1 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -0
- package/lib/esm/actions/blue/withdraw.js +3 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -0
- package/lib/esm/actions/midnight/takeLend.d.ts +1 -0
- package/lib/esm/actions/midnight/takeLend.js +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +1 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -0
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -7
- package/lib/esm/entities/blue/blue.d.ts +43 -7
- package/lib/esm/entities/blue/blue.js +27 -3
- package/lib/esm/entities/midnight/midnight.d.ts +14 -6
- package/lib/esm/entities/midnight/midnight.js +14 -6
- package/lib/esm/entities/midnight/types.d.ts +9 -2
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +3 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +9 -6
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +40 -13
- package/lib/esm/entities/vaultV2BlueReallocationData.js +208 -71
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/helpers/validate.d.ts +11 -1
- package/lib/esm/helpers/validate.js +15 -0
- package/lib/esm/helpers/validateTakeableOffers.d.ts +4 -2
- package/lib/esm/helpers/validateTakeableOffers.js +13 -2
- package/lib/esm/types/error.d.ts +10 -1
- package/lib/esm/types/error.js +11 -1
- package/lib/esm/types/sharedLiquidity.d.ts +27 -11
- package/package.json +4 -4
|
@@ -197,6 +197,7 @@ export declare class MorphoMidnight {
|
|
|
197
197
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
198
198
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
199
199
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
200
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
200
201
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
201
202
|
* @throws {MidnightReferralFeePctExceededError} when `referralFeePct` exceeds 10% (`WAD / 10n`).
|
|
202
203
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
@@ -552,6 +553,7 @@ export declare class MorphoMidnight {
|
|
|
552
553
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
553
554
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
554
555
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
556
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
555
557
|
* @throws {ExpiredDeadlineError} when `deadline` has expired.
|
|
556
558
|
* @throws {MidnightTakeDeadlineTooFarError} when `deadline` is more than one hour from now.
|
|
557
559
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
@@ -636,14 +638,14 @@ export declare class MorphoMidnight {
|
|
|
636
638
|
* for a new publication. Calls the Midnight mempool validation API while preparing the tree;
|
|
637
639
|
* `validation: false` skips that call.
|
|
638
640
|
*
|
|
639
|
-
* @param params - Maker, lend-side offers,
|
|
641
|
+
* @param params - Maker, lend-side offers, `loanAssets` and `reservedLoanAssets` allowance thresholds, cancellations, and deadline.
|
|
640
642
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
641
643
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
642
644
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
643
645
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
644
646
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
645
647
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
646
|
-
* @param params.loanAssets -
|
|
648
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
647
649
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups, excluding groups in `cancellations`.
|
|
648
650
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
649
651
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
@@ -781,6 +783,12 @@ export declare class MorphoMidnight {
|
|
|
781
783
|
* `midnightBlueBuyCallbackFactory`, `accountAddress` and `callbackSalt`, and fetches the Morpho Blue market,
|
|
782
784
|
* accruing interest to the current time before previewing parked shares (markets whose
|
|
783
785
|
* IRM the SDK cannot accrue are previewed on their last-updated state).
|
|
786
|
+
* The share check runs once, before signing: the bundle supplies `assetsToPark` with no
|
|
787
|
+
* minimum-shares bound, so interest accrued before inclusion can still round the supply down
|
|
788
|
+
* to zero shares if `assetsToPark` is worth less than one share at inclusion. A preview above
|
|
789
|
+
* one share does not rule this out: interest accrued while the transaction waits, or not
|
|
790
|
+
* accrued by the SDK for an IRM it cannot accrue, raises the share price. Choosing a market
|
|
791
|
+
* whose share price makes that impossible is the caller's responsibility.
|
|
784
792
|
* The caller is responsible for trusting the Blue market's oracle and IRM. If Blue liquidity is
|
|
785
793
|
* drained, callback offers cannot fill until liquidity returns. `assetsToPark` may underfund the
|
|
786
794
|
* offers; top-ups are allowed.
|
|
@@ -841,7 +849,7 @@ export declare class MorphoMidnight {
|
|
|
841
849
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
842
850
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
843
851
|
* @throws {EmptyBlueParkingMarketError} when `blueMarket` has no supply shares.
|
|
844
|
-
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price.
|
|
852
|
+
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price (checked at preparation time only).
|
|
845
853
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
846
854
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
847
855
|
* @throws {DuplicateMidnightGroupCancellationError} when a cancelled group appears more than once.
|
|
@@ -940,7 +948,7 @@ export declare class MorphoMidnight {
|
|
|
940
948
|
*
|
|
941
949
|
* Shares the lend-side publication and requirement handling of {@link MorphoMidnight.makeLend}.
|
|
942
950
|
* Loan assets are pulled by Midnight when the offers fill, not during publication.
|
|
943
|
-
*
|
|
951
|
+
* `loanAssets` is only the allowance threshold `getRequirements()` checks, as in `makeLend`; the signed offer caps bound fills.
|
|
944
952
|
* A partially consumed offer group remains publishable with its shared remaining cap reduced.
|
|
945
953
|
* No repay offer can be live after market maturity; late borrowers should repay directly with
|
|
946
954
|
* {@link MorphoMidnight.repayWithdrawCollateral}.
|
|
@@ -948,14 +956,14 @@ export declare class MorphoMidnight {
|
|
|
948
956
|
* Every offer must already have `buy = true` and `reduceOnly = true`.
|
|
949
957
|
* The supplied tree, group caps and prices are preserved; no separate root signature is needed.
|
|
950
958
|
*
|
|
951
|
-
* @param params - Maker, reduce-only offers, optional cancellations,
|
|
959
|
+
* @param params - Maker, reduce-only offers, optional cancellations, `loanAssets` and `reservedLoanAssets` allowance thresholds, and deadline.
|
|
952
960
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
953
961
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
954
962
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
955
963
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
956
964
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
957
965
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
958
|
-
* @param params.loanAssets -
|
|
966
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
959
967
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups.
|
|
960
968
|
* @returns Prepared root and groups, lazy requirements, and a synchronous publication builder.
|
|
961
969
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
@@ -342,6 +342,7 @@ class MorphoMidnight {
|
|
|
342
342
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
343
343
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
344
344
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
345
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
345
346
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
346
347
|
* @throws {MidnightReferralFeePctExceededError} when `referralFeePct` exceeds 10% (`WAD / 10n`).
|
|
347
348
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient.
|
|
@@ -930,6 +931,7 @@ class MorphoMidnight {
|
|
|
930
931
|
* @throws {EmptyMidnightTakeableOffersError} when no offers are supplied.
|
|
931
932
|
* @throws {MidnightOfferSideMismatchError} when an offer has the wrong maker side.
|
|
932
933
|
* @throws {MidnightTakeableOfferMarketMismatchError} when an offer targets another market.
|
|
934
|
+
* @throws {MidnightTakeableOfferZeroSellerReceiverError} when a sell offer routes seller proceeds to the zero address.
|
|
933
935
|
* @throws {ExpiredDeadlineError} when `deadline` has expired.
|
|
934
936
|
* @throws {MidnightTakeDeadlineTooFarError} when `deadline` is more than one hour from now.
|
|
935
937
|
* @throws {ReferralFeePctExceededError} when `referralFeePct` is not below WAD.
|
|
@@ -1154,14 +1156,14 @@ class MorphoMidnight {
|
|
|
1154
1156
|
* for a new publication. Calls the Midnight mempool validation API while preparing the tree;
|
|
1155
1157
|
* `validation: false` skips that call.
|
|
1156
1158
|
*
|
|
1157
|
-
* @param params - Maker, lend-side offers,
|
|
1159
|
+
* @param params - Maker, lend-side offers, `loanAssets` and `reservedLoanAssets` allowance thresholds, cancellations, and deadline.
|
|
1158
1160
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
1159
1161
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
1160
1162
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
1161
1163
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
1162
1164
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
1163
1165
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
1164
|
-
* @param params.loanAssets -
|
|
1166
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
1165
1167
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups, excluding groups in `cancellations`.
|
|
1166
1168
|
* @returns Prepared group metadata, lazy approval/authorization requirements, and a synchronous transaction builder.
|
|
1167
1169
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
@@ -1371,6 +1373,12 @@ class MorphoMidnight {
|
|
|
1371
1373
|
* `midnightBlueBuyCallbackFactory`, `accountAddress` and `callbackSalt`, and fetches the Morpho Blue market,
|
|
1372
1374
|
* accruing interest to the current time before previewing parked shares (markets whose
|
|
1373
1375
|
* IRM the SDK cannot accrue are previewed on their last-updated state).
|
|
1376
|
+
* The share check runs once, before signing: the bundle supplies `assetsToPark` with no
|
|
1377
|
+
* minimum-shares bound, so interest accrued before inclusion can still round the supply down
|
|
1378
|
+
* to zero shares if `assetsToPark` is worth less than one share at inclusion. A preview above
|
|
1379
|
+
* one share does not rule this out: interest accrued while the transaction waits, or not
|
|
1380
|
+
* accrued by the SDK for an IRM it cannot accrue, raises the share price. Choosing a market
|
|
1381
|
+
* whose share price makes that impossible is the caller's responsibility.
|
|
1374
1382
|
* The caller is responsible for trusting the Blue market's oracle and IRM. If Blue liquidity is
|
|
1375
1383
|
* drained, callback offers cannot fill until liquidity returns. `assetsToPark` may underfund the
|
|
1376
1384
|
* offers; top-ups are allowed.
|
|
@@ -1431,7 +1439,7 @@ class MorphoMidnight {
|
|
|
1431
1439
|
* @throws {MidnightMarketOracleWithoutCodeError} when an uncreated market's oracle has no code.
|
|
1432
1440
|
* @throws {viem.BaseError} when a pinned block, multicall, or oracle-code read fails.
|
|
1433
1441
|
* @throws {EmptyBlueParkingMarketError} when `blueMarket` has no supply shares.
|
|
1434
|
-
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price.
|
|
1442
|
+
* @throws {ZeroBlueParkingSharesError} when `assetsToPark` would mint no supply shares at the current share price (checked at preparation time only).
|
|
1435
1443
|
* @throws {MidnightReplacementGroupCancelledError} when a published group is also cancelled.
|
|
1436
1444
|
* @throws {InvalidMidnightHexInputError} when a cancellation group or `callbackSalt` is not 32-byte hex.
|
|
1437
1445
|
* @throws {DuplicateMidnightGroupCancellationError} when a cancelled group appears more than once.
|
|
@@ -1674,7 +1682,7 @@ class MorphoMidnight {
|
|
|
1674
1682
|
*
|
|
1675
1683
|
* Shares the lend-side publication and requirement handling of {@link MorphoMidnight.makeLend}.
|
|
1676
1684
|
* Loan assets are pulled by Midnight when the offers fill, not during publication.
|
|
1677
|
-
*
|
|
1685
|
+
* `loanAssets` is only the allowance threshold `getRequirements()` checks, as in `makeLend`; the signed offer caps bound fills.
|
|
1678
1686
|
* A partially consumed offer group remains publishable with its shared remaining cap reduced.
|
|
1679
1687
|
* No repay offer can be live after market maturity; late borrowers should repay directly with
|
|
1680
1688
|
* {@link MorphoMidnight.repayWithdrawCollateral}.
|
|
@@ -1682,14 +1690,14 @@ class MorphoMidnight {
|
|
|
1682
1690
|
* Every offer must already have `buy = true` and `reduceOnly = true`.
|
|
1683
1691
|
* The supplied tree, group caps and prices are preserved; no separate root signature is needed.
|
|
1684
1692
|
*
|
|
1685
|
-
* @param params - Maker, reduce-only offers, optional cancellations,
|
|
1693
|
+
* @param params - Maker, reduce-only offers, optional cancellations, `loanAssets` and `reservedLoanAssets` allowance thresholds, and deadline.
|
|
1686
1694
|
* @param params.accountAddress - Maker expected on every offer; must send the transaction.
|
|
1687
1695
|
* @param params.offers - PriceRatifierV1 or RateRatifierV1 tree, or its `Tree.create` request.
|
|
1688
1696
|
* @param params.cancellations - Previous groups to cancel with their consumption ceilings.
|
|
1689
1697
|
* @param params.deadline - Bundle execution deadline timestamp.
|
|
1690
1698
|
* @param params.validation - Midnight mempool API request controls, or `false` to skip the API call.
|
|
1691
1699
|
* @param params.loanToken - Loan token shared by every offer market.
|
|
1692
|
-
* @param params.loanAssets -
|
|
1700
|
+
* @param params.loanAssets - Minimum Midnight allowance (with `reservedLoanAssets`) that `getRequirements()` checks; the approval it returns is unlimited. The signed offer caps bound fills.
|
|
1693
1701
|
* @param params.reservedLoanAssets - Existing loan assets reserved by other open groups.
|
|
1694
1702
|
* @returns Prepared root and groups, lazy requirements, and a synchronous publication builder.
|
|
1695
1703
|
* @throws {ChainIdMismatchError} when the client declares, or its RPC reports via `eth_chainId` during `getOffersData()` or `getRequirements`, another chain than this entity's.
|
|
@@ -51,7 +51,14 @@ export interface MakeOffersParams {
|
|
|
51
51
|
/** Parameters for a Midnight lend maker flow. */
|
|
52
52
|
export interface MakeLendParams extends MakeOffersParams {
|
|
53
53
|
readonly loanToken: Address;
|
|
54
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* Minimum Midnight loan-token allowance, together with `reservedLoanAssets`, that `getRequirements()` checks.
|
|
56
|
+
* When the allowance is lower, it returns an unlimited approval (`maxUint256`, capped per token by `MAX_TOKEN_APPROVALS`).
|
|
57
|
+
* Not checked against the offers: their signed `maxAssets`/`maxUnits` caps, the maker's balance and the
|
|
58
|
+
* allowance bound what takers can fill, so size those caps to what you mean to lend
|
|
59
|
+
* (`maxAssets` counts loan assets, `maxUnits` counts position units).
|
|
60
|
+
* For grouped OCA offers, pass the group amount once instead of summing every leg.
|
|
61
|
+
*/
|
|
55
62
|
readonly loanAssets: bigint;
|
|
56
63
|
/** Existing loan assets reserved across the maker's other open groups, including consumed amounts when available. Leave out groups listed in `cancellations`; this transaction cancels them. */
|
|
57
64
|
readonly reservedLoanAssets?: bigint;
|
|
@@ -62,7 +69,7 @@ export interface SupplyBlueMakeLendParams extends MakeOffersParams {
|
|
|
62
69
|
* Morpho Blue market the parked assets are supplied to; its loan token must match every offer.
|
|
63
70
|
* The contract does not check supply share-price slippage: use only markets protected against
|
|
64
71
|
* supply-share-price inflation. Markets with no supply shares or parked amounts that mint zero
|
|
65
|
-
* shares are rejected.
|
|
72
|
+
* shares are rejected (checked at preparation time; see `supplyBlueMakeLend`).
|
|
66
73
|
*/
|
|
67
74
|
readonly blueMarket: BlueMarketParams;
|
|
68
75
|
/** Loan assets pulled from the maker and supplied to `blueMarket` for the maker's callback. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AccrualVaultV2,
|
|
1
|
+
import { type AccrualVaultV2, MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { fetchAccrualVaultV2 } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { type Address } from "viem";
|
|
4
4
|
import type { FetchParameters } from "../../types/data.js";
|
|
@@ -504,6 +504,8 @@ export interface VaultV2Actions {
|
|
|
504
504
|
* This is the share-based counterpart to forceWithdraw, useful for maximum withdrawal scenarios
|
|
505
505
|
* where specifying an exact asset amount is impractical.
|
|
506
506
|
*
|
|
507
|
+
* Inputs are copied when the handle is created, so later changes to them are not encoded.
|
|
508
|
+
*
|
|
507
509
|
* The total assets passed to forceDeallocate calls must be greater than or equal to the
|
|
508
510
|
* asset-equivalent of the redeemed shares. The caller should apply a buffer on the deallocated
|
|
509
511
|
* amounts to account for share-price drift between submission and execution.
|
|
@@ -697,15 +697,18 @@ class MorphoVaultV2 {
|
|
|
697
697
|
}
|
|
698
698
|
forceRedeem({ deallocations, redeem, userAddress, }) {
|
|
699
699
|
(0, index_js_2.validateChainId)(this.client.viemClient.chain?.id, this.chainId);
|
|
700
|
+
const shares = redeem.shares;
|
|
701
|
+
const deallocationsSnapshot = deallocations.map(({ adapter, marketParams, amount }) => ({
|
|
702
|
+
adapter,
|
|
703
|
+
amount,
|
|
704
|
+
...(marketParams && { marketParams: new blue_sdk_1.MarketParams(marketParams) }),
|
|
705
|
+
}));
|
|
700
706
|
return {
|
|
701
707
|
buildTx: () => (0, index_js_1.vaultV2ForceRedeem)({
|
|
702
708
|
vault: { address: this.vault },
|
|
703
709
|
args: {
|
|
704
|
-
deallocations,
|
|
705
|
-
redeem: {
|
|
706
|
-
shares: redeem.shares,
|
|
707
|
-
recipient: userAddress,
|
|
708
|
-
},
|
|
710
|
+
deallocations: deallocationsSnapshot,
|
|
711
|
+
redeem: { shares, recipient: userAddress },
|
|
709
712
|
onBehalf: userAddress,
|
|
710
713
|
},
|
|
711
714
|
metadata: this.client.options.metadata,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccrualVaultV2, AccrualVaultV2MorphoMarketV1AdapterV2, type IAccrualVaultV2Adapter, type IVaultV2Allocation, type IVaultV2BlueMarketPublicAllocatorConfig, type IVaultV2BluePublicAllocatorConfig, Market, type MarketId, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig } from "@morpho-org/blue-sdk";
|
|
1
|
+
import { AccrualVaultV2, AccrualVaultV2MorphoMarketV1AdapterV2, type BigIntish, type IAccrualVaultV2Adapter, type IVaultV2Allocation, type IVaultV2BlueMarketPublicAllocatorConfig, type IVaultV2BluePublicAllocatorConfig, Market, type MarketId, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address, type Hash } from "viem";
|
|
3
3
|
import type { VaultV2BluePublicAllocatorOptions, VaultV2BlueReallocation } from "../types/index.js";
|
|
4
4
|
type ReadonlyMarketSnapshot = Readonly<Market>;
|
|
@@ -19,6 +19,13 @@ type ReadonlyVaultSnapshot = Readonly<Omit<AccrualVaultV2, "adapters" | "liquidi
|
|
|
19
19
|
export interface InputVaultV2BlueReallocationData {
|
|
20
20
|
/** Chain id associated with the fetched state. */
|
|
21
21
|
readonly chainId: number;
|
|
22
|
+
/**
|
|
23
|
+
* Timestamp of the block the state was fetched at. When present, this is the
|
|
24
|
+
* default planning timestamp when `options.timestamp` is omitted, never
|
|
25
|
+
* earlier than the latest market/vault `lastUpdate`; when absent, planning
|
|
26
|
+
* defaults to the latest market/vault `lastUpdate`.
|
|
27
|
+
*/
|
|
28
|
+
readonly timestamp?: BigIntish;
|
|
22
29
|
/** Markets indexed by market id. */
|
|
23
30
|
readonly markets?: Readonly<Record<MarketId, ReadonlyMarketSnapshot | undefined>>;
|
|
24
31
|
/** Accrued Vault V2 entities indexed by vault address. */
|
|
@@ -78,6 +85,8 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
78
85
|
private readonly mutableAllocations;
|
|
79
86
|
/** Chain id associated with this snapshot. */
|
|
80
87
|
readonly chainId: number;
|
|
88
|
+
/** Timestamp of the block the state was fetched at. */
|
|
89
|
+
readonly timestamp?: bigint;
|
|
81
90
|
/** Markets indexed by market id. */
|
|
82
91
|
readonly markets: Readonly<Record<MarketId, ReadonlyMarketSnapshot | undefined>>;
|
|
83
92
|
/** Vault V2 entities indexed by address. */
|
|
@@ -356,16 +365,29 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
356
365
|
* Computes Vault V2 BluePublicAllocator calls available for a target market.
|
|
357
366
|
*
|
|
358
367
|
* Without `options.operation`, discovers every friendly call. With an
|
|
359
|
-
* operation,
|
|
360
|
-
*
|
|
361
|
-
*
|
|
362
|
-
*
|
|
363
|
-
*
|
|
364
|
-
* `
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
368
|
+
* operation, penalty tiers are considered ascending, starting with free
|
|
369
|
+
* vaults. The free tier aims to bring the target market back to 90%
|
|
370
|
+
* utilization; positive tiers cover only the remaining absolute shortfall
|
|
371
|
+
* (borrows minus supply). Within each tier, source markets go to the
|
|
372
|
+
* friendly source utilization (90% by default) before 100%. Free capacity
|
|
373
|
+
* inside `allocatorCapHeadroom` is kept unused, so a penalized leg can cover
|
|
374
|
+
* it instead. Discovery and liquidity getters still count every vault up to
|
|
375
|
+
* `options.maxPenalty`. A shared relative-cap lower bound may require one call
|
|
376
|
+
* to exceed the targeted amount. For `refinance`, compute the plan on the
|
|
377
|
+
* destination-market handle (for example,
|
|
378
|
+
* `client.morpho.blue(destination.marketParams, chainId)`), not the source
|
|
379
|
+
* handle. Pass the source position's `borrowAssets` accrued to
|
|
380
|
+
* `max(now, source.lastUpdate, destination.lastUpdate) + 2h` as
|
|
381
|
+
* `operation.amount`; the optional `operation.referralFeePct` is WAD-scaled.
|
|
382
|
+
* The planner includes the referral fee and its allocator-leg penalties in
|
|
383
|
+
* destination debt, so penalized legs also cover their own penalty.
|
|
384
|
+
* Refinance never uses vaults with a 100% penalty.
|
|
385
|
+
* Friendly source utilization defaults to 90% and is configurable through
|
|
386
|
+
* `options.maxWithdrawalUtilization`. Market/vault state and the returned
|
|
387
|
+
* post-state stay at `timestamp`. An enabled operation that needs no
|
|
388
|
+
* reallocation still returns a clone accrued to `timestamp`. Only
|
|
389
|
+
* target-market cap checks reserve interest the vault's existing allocation
|
|
390
|
+
* would accrue through `timestamp + capAccrualBuffer`
|
|
369
391
|
* (two hours by default; `0n` disables it). When an operation's plan would
|
|
370
392
|
* come within `allocatorCapHeadroom` (1% of the cap by default) of a target
|
|
371
393
|
* BluePublicAllocator cap, the plan is reduced to the larger of the
|
|
@@ -406,8 +428,9 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
406
428
|
* every leg of a plan.
|
|
407
429
|
* @returns Flat action-ready reallocations and their post-simulation state.
|
|
408
430
|
* @throws {UnsupportedBlueMarketIrmError} when a market with positive debt uses an unsupported IRM.
|
|
409
|
-
* @throws {NegativeInputError} when `capAccrualBuffer`, `allocatorCapHeadroom`, `maxWithdrawalUtilization`, or `
|
|
431
|
+
* @throws {NegativeInputError} when `capAccrualBuffer`, `allocatorCapHeadroom`, `maxWithdrawalUtilization`, `maxPenalty`, or `referralFeePct` is negative.
|
|
410
432
|
* @throws {InputExceedsMaxError} when `allocatorCapHeadroom`, `maxWithdrawalUtilization`, or `maxPenalty` exceeds WAD.
|
|
433
|
+
* @throws {ReferralFeePctExceededError} when `referralFeePct` is at least WAD.
|
|
411
434
|
* @throws {NonPositiveInputError} when the operation amount is not positive and planning is enabled.
|
|
412
435
|
* @throws {UnknownReallocationMarketError} when a required market is absent.
|
|
413
436
|
* @throws {UnknownReallocationVaultError} when configured vault state is absent.
|
|
@@ -415,7 +438,7 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
415
438
|
* @throws {UnknownReallocationActiveAdaptersError} when active-adapter state is absent for a vault.
|
|
416
439
|
* @throws {UnknownReallocationMarketPublicAllocatorConfigError} when an adapter-market allocator configuration is absent.
|
|
417
440
|
* @throws {UnknownReallocationAllocationError} when required allocation state is absent.
|
|
418
|
-
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the absolute shortfall.
|
|
441
|
+
* @throws {InsufficientSharedLiquidityError} when selected liquidity cannot cover the absolute shortfall and, for refinance, its planned allocator penalties.
|
|
419
442
|
* @throws {ReallocationWithdrawExceedsMarketSupplyError} when a withdraw exceeds market supply.
|
|
420
443
|
* @example
|
|
421
444
|
* ```ts
|
|
@@ -450,6 +473,10 @@ export declare class VaultV2BlueReallocationData implements InputVaultV2BlueReal
|
|
|
450
473
|
readonly operation?: {
|
|
451
474
|
readonly type: "borrow" | "withdraw";
|
|
452
475
|
readonly amount: bigint;
|
|
476
|
+
} | {
|
|
477
|
+
readonly type: "refinance";
|
|
478
|
+
readonly amount: bigint;
|
|
479
|
+
readonly referralFeePct?: bigint;
|
|
453
480
|
};
|
|
454
481
|
}): {
|
|
455
482
|
readonly reallocations: readonly VaultV2BlueReallocation[];
|