@morpho-org/morpho-sdk 10.0.0-next.0 → 10.0.1
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 +104 -12
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/common.js +4 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/cjs/actions/bundles/common.js +20 -14
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
- package/lib/cjs/actions/midnight/cancelOffers.js +2 -1
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -1
- package/lib/cjs/actions/midnight/takeLend.js +2 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +2 -1
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -11
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/blue/blue.js +8 -4
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/deadline.js +2 -1
- package/lib/cjs/entities/midnight/midnight.js +14 -7
- package/lib/cjs/entities/midnight/publication.js +73 -44
- package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +9 -13
- package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +51 -181
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +62 -429
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +346 -234
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +6 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.js +34 -19
- package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/cjs/helpers/metadata.js +12 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -5
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +6 -3
- package/lib/cjs/helpers/utilization.js +10 -5
- package/lib/cjs/helpers/validate.js +12 -6
- package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
- package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +44 -22
- package/lib/cjs/helpers/validatePositiveInput.js +2 -1
- package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +14 -7
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +10 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/approval.js +12 -1
- package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
- package/lib/cjs/transactionPlan/deposit.js +139 -0
- package/lib/cjs/transactionPlan/error.d.ts +10 -8
- package/lib/cjs/transactionPlan/error.js +10 -8
- package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
- package/lib/cjs/transactionPlan/index.d.ts +18 -0
- package/lib/cjs/transactionPlan/index.js +23 -5
- package/lib/cjs/transactionPlan/intent.d.ts +3 -3
- package/lib/cjs/transactionPlan/intent.js +14 -7
- package/lib/cjs/transactionPlan/permit.d.ts +1 -1
- package/lib/cjs/transactionPlan/permit.js +86 -20
- package/lib/cjs/transactionPlan/plan.d.ts +16 -6
- package/lib/cjs/transactionPlan/plan.js +72 -22
- package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
- package/lib/cjs/transactionPlan/redeem.js +63 -0
- package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
- package/lib/cjs/transactionPlan/requirements.js +12 -6
- package/lib/cjs/transactionPlan/serde.d.ts +2 -2
- package/lib/cjs/transactionPlan/serde.js +41 -15
- package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/cjs/transactionPlan/shareSpending.js +50 -0
- package/lib/cjs/transactionPlan/types.d.ts +117 -11
- package/lib/cjs/transactionPlan/validateActions.js +11 -1
- package/lib/cjs/transactionPlan/validation.js +6 -3
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +14 -31
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +15 -141
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +14 -27
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +17 -124
- package/lib/cjs/transactionPlan/version.js +2 -1
- package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
- package/lib/cjs/transactionPlan/withdraw.js +94 -0
- package/lib/cjs/types/action.js +16 -8
- package/lib/cjs/types/error.d.ts +8 -1
- package/lib/cjs/types/error.js +10 -1
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/common.js +4 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/esm/actions/bundles/common.js +20 -14
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
- package/lib/esm/actions/midnight/cancelOffers.js +2 -1
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
- package/lib/esm/actions/midnight/takeBorrow.js +2 -1
- package/lib/esm/actions/midnight/takeLend.js +2 -1
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +2 -1
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +4 -13
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
- 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.js +8 -4
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/deadline.js +2 -1
- package/lib/esm/entities/midnight/midnight.js +14 -7
- package/lib/esm/entities/midnight/publication.js +73 -44
- package/lib/esm/entities/requirements/assertContractCode.js +4 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +10 -14
- package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +57 -187
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +70 -437
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +346 -234
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +35 -20
- package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/esm/helpers/metadata.js +12 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -5
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +6 -3
- package/lib/esm/helpers/utilization.js +10 -5
- package/lib/esm/helpers/validate.js +12 -6
- package/lib/esm/helpers/validateMidnightBounds.js +2 -1
- package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/esm/helpers/validateMidnightPublication.js +4 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +44 -22
- package/lib/esm/helpers/validatePositiveInput.js +2 -1
- package/lib/esm/helpers/validateTakeableOffers.js +2 -1
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +14 -7
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/approval.js +13 -2
- package/lib/esm/transactionPlan/deposit.d.ts +22 -0
- package/lib/esm/transactionPlan/deposit.js +135 -0
- package/lib/esm/transactionPlan/error.d.ts +10 -8
- package/lib/esm/transactionPlan/error.js +10 -8
- package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
- package/lib/esm/transactionPlan/index.d.ts +18 -0
- package/lib/esm/transactionPlan/index.js +9 -0
- package/lib/esm/transactionPlan/intent.d.ts +3 -3
- package/lib/esm/transactionPlan/intent.js +14 -7
- package/lib/esm/transactionPlan/permit.d.ts +1 -1
- package/lib/esm/transactionPlan/permit.js +86 -20
- package/lib/esm/transactionPlan/plan.d.ts +16 -6
- package/lib/esm/transactionPlan/plan.js +68 -18
- package/lib/esm/transactionPlan/redeem.d.ts +18 -0
- package/lib/esm/transactionPlan/redeem.js +59 -0
- package/lib/esm/transactionPlan/requirements.d.ts +4 -3
- package/lib/esm/transactionPlan/requirements.js +12 -6
- package/lib/esm/transactionPlan/serde.d.ts +2 -2
- package/lib/esm/transactionPlan/serde.js +41 -15
- package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/esm/transactionPlan/shareSpending.js +47 -0
- package/lib/esm/transactionPlan/types.d.ts +117 -11
- package/lib/esm/transactionPlan/validateActions.js +11 -1
- package/lib/esm/transactionPlan/validation.js +6 -3
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +14 -31
- package/lib/esm/transactionPlan/vaultv2/deposit.js +17 -142
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +14 -27
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +19 -125
- package/lib/esm/transactionPlan/version.js +2 -1
- package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
- package/lib/esm/transactionPlan/withdraw.js +90 -0
- package/lib/esm/types/action.js +16 -8
- package/lib/esm/types/error.d.ts +8 -1
- package/lib/esm/types/error.js +10 -1
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +15 -15
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ General Vault V1 operations remain supported.
|
|
|
21
21
|
## Installation
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
|
|
24
|
+
npm install @morpho-org/morpho-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
Read [Dead-share validators](./DEAD-SHARE-PROTECTION.md) for the exported checks. Builders do not
|
|
@@ -77,7 +77,9 @@ then call `buildTx()` without a separate root signature.
|
|
|
77
77
|
|
|
78
78
|
`VaultExitBundlesV1`, `VaultBundlesV1`, and `BlueBundlesV1` are registered on Ethereum, Base,
|
|
79
79
|
Arbitrum, Optimism, Polygon, World Chain, Unichain, HyperEVM, Katana, Monad, Stable, Tempo,
|
|
80
|
-
Robinhood Chain, Arc,
|
|
80
|
+
Robinhood Chain, Arc, X Layer, and Alpen. Alpen has no registered Vault V1 factory, wrapped-native
|
|
81
|
+
token, or Permit2; native-token funding is not enabled there. Custom deployments can still be
|
|
82
|
+
configured with `registerCustomAddresses`.
|
|
81
83
|
|
|
82
84
|
## How it works
|
|
83
85
|
|
|
@@ -277,7 +279,38 @@ instant liquidation. Blue writes do not accept `slippageTolerance`, `minSharePri
|
|
|
277
279
|
> **Beta:** TransactionPlan is experimental; breaking changes may ship in minor releases.
|
|
278
280
|
> Existing entity flows remain the recommended stable path during the shadow-mode rollout.
|
|
279
281
|
|
|
280
|
-
|
|
282
|
+
Preparers emit stored format `version: 2`. Version 1 (including SDK 9.7.0 plans) is rejected with
|
|
283
|
+
`UnsupportedTransactionPlanVersionError`; migrate trusted saved plans' fields and version before
|
|
284
|
+
restoring them. There is no legacy parser.
|
|
285
|
+
|
|
286
|
+
Prepare a Vault V2 deposit, withdrawal, force-withdraw or exact-share redemption plan, or a Vault V1 deposit or withdrawal plan with
|
|
287
|
+
`prepareVaultV1Deposit` or `prepareVaultV1Withdraw` and a `fetchAccrualVault` snapshot, then sign its pending requests with your wallet.
|
|
288
|
+
Deposit and withdrawal preparers take `assets`; redemption takes `shares`. Stored operation inputs
|
|
289
|
+
use the same names, except native-funded deposits store `nativeAssets` instead of `assets`.
|
|
290
|
+
Stored ERC-20 approval inputs likewise use `assets` for underlying-token approvals or `shares`
|
|
291
|
+
for vault-share approvals. See the [TransactionPlan format and migration notes](./src/transactionPlan/README.md).
|
|
292
|
+
Pass the caller-fetched `AccrualVault` (V1) or `AccrualVaultV2` (V2) once as `vault` for deposits,
|
|
293
|
+
and the matching snapshot as `vault` for withdrawals;
|
|
294
|
+
the contract address comes from `vault.address`. Only deposit preparation accepts `deployless`.
|
|
295
|
+
|
|
296
|
+
V1 and V2 deposits share preparation and validation; use `assets` for either preparer and
|
|
297
|
+
`nativeAssets` in stored native funding. The snapshot is not retained in the stored plan.
|
|
298
|
+
|
|
299
|
+
V1 and V2 withdrawal plans also share preparation and validation: both prepare and store gross
|
|
300
|
+
`assets`, alongside the stored `requiredShareAllowance` quote. Neither accepts a slippage override.
|
|
301
|
+
|
|
302
|
+
`prepareVaultV1Redeem` prepares a Vault V1 exact-share redemption. Its required `shareToken: Token`
|
|
303
|
+
supplies the vault address and share-permit domain metadata; no accrual snapshot is required.
|
|
304
|
+
|
|
305
|
+
V1 and V2 redemptions both prepare and store exact `shares`. Their shared authorization resolver
|
|
306
|
+
also serves ordinary withdrawals: chain checks, code checks and requirements run concurrently,
|
|
307
|
+
while the requirements helper checks the RPC chain before allowance or nonce reads.
|
|
308
|
+
|
|
309
|
+
Migration plans take exactly one of `assets` or `shares`, store `vault: sourceVault` and derived
|
|
310
|
+
`maxSharePrice`, and translate that bound to the entity/ABI `maxSharePriceVaultV2` argument.
|
|
311
|
+
Pass the caller-fetched source and target snapshots once each, as `sourceVault: AccrualVault` and
|
|
312
|
+
`targetVault: AccrualVaultV2`. Their assets must match and their addresses must differ.
|
|
313
|
+
|
|
281
314
|
`applySignatures(plan, signatures)` synchronously verifies every supplied signature before attaching
|
|
282
315
|
it, without a client or RPC. It validates all requests against their actions, including permit/action
|
|
283
316
|
deadline agreement, rejects unknown or duplicate input IDs, and recovers the permit owner from the
|
|
@@ -296,17 +329,76 @@ clock or RPC and does not check expiry, live state, signature ownership or actio
|
|
|
296
329
|
constraints. It does not prove authenticity or intent: tampered-but-well-formed, internally consistent
|
|
297
330
|
plans pass, so integrators must still protect stored plans.
|
|
298
331
|
|
|
299
|
-
|
|
332
|
+
Supported action types are `erc20Approval`, `vaultV1Deposit`, `vaultV1Withdraw`, `vaultV1Redeem`, `vaultV1InKindRedeem`, `vaultV1MigrateToV2`,
|
|
333
|
+
`vaultV2Deposit`, `vaultV2Withdraw`, `vaultV2Redeem`,
|
|
334
|
+
`vaultV2ForceWithdraw`, `vaultV2ForceRedeem` and `vaultV2InKindRedeem`. Builders return plain `Readonly<Transaction>` objects without step metadata.
|
|
335
|
+
|
|
336
|
+
| Prepare function | Operation |
|
|
337
|
+
| --- | --- |
|
|
338
|
+
| `prepareVaultV2Deposit` | Deposit assets into Vault V2 |
|
|
339
|
+
| `prepareVaultV2Withdraw` | Withdraw assets from Vault V2 |
|
|
340
|
+
| `prepareVaultV2Redeem` | Redeem an exact number of Vault V2 shares |
|
|
341
|
+
| `prepareVaultV2ForceWithdraw` | Force-withdraw a penalty-inclusive asset amount from Vault V2 |
|
|
342
|
+
| `prepareVaultV2ForceRedeem` | Force-deallocate and redeem an exact number of Vault V2 shares |
|
|
343
|
+
| `prepareVaultV2InKindRedeem` | Exit a penalty-inclusive asset amount from Vault V2 in kind (idle assets and Blue supply positions) |
|
|
344
|
+
| `prepareVaultV1Deposit` | Deposit assets into Vault V1 |
|
|
345
|
+
| `prepareVaultV1Withdraw` | Withdraw assets from Vault V1 |
|
|
346
|
+
| `prepareVaultV1Redeem` | Redeem an exact number of Vault V1 shares |
|
|
347
|
+
| `prepareVaultV1InKindRedeem` | Redeem Vault V1 shares in kind |
|
|
348
|
+
| `prepareVaultV1MigrateToV2` | Migrate exclusive `assets` or `shares` from Vault V1 into Vault V2 |
|
|
349
|
+
|
|
350
|
+
`prepareVaultV2ForceRedeem` takes `vaultAddress` and top-level `shares`, with no snapshot.
|
|
351
|
+
Caller-supplied `deallocations[].assets` and `shares` are fixed on one `vaultV2ForceRedeem` step
|
|
352
|
+
with no approvals or signature requests. It accepts neither `supportSignature` nor `deployless`.
|
|
353
|
+
`expiresAt` is plan metadata only, not an onchain deadline.
|
|
354
|
+
|
|
355
|
+
`prepareVaultV2Deposit` and `prepareVaultV2Withdraw` take one `vault: AccrualVaultV2` snapshot.
|
|
356
|
+
`prepareVaultV1MigrateToV2` takes `sourceVault: AccrualVault` and `targetVault: AccrualVaultV2` snapshots.
|
|
357
|
+
|
|
358
|
+
Preparers with token authorization default to `supportSignature: false`. With `true`, ERC-2612 tokens use permits and other
|
|
359
|
+
tokens fall back to direct approval; no Permit2 or fetch requests are generated. Callers fetch
|
|
360
|
+
snapshots before preparation. Builders return plain SDK transactions without step IDs or kinds.
|
|
361
|
+
|
|
362
|
+
When existing allowance is insufficient, withdrawal, redemption and migration plans request an unlimited (`maxUint256`)
|
|
300
363
|
ERC-2612 vault-share permit or direct share approval. The quote's `requiredShareAllowance` remains
|
|
301
|
-
the minimum needed for that
|
|
364
|
+
the minimum needed for that exit; later exits reuse sufficient allowance without a
|
|
302
365
|
new signature. Deposit asset permits must instead sign the exact pull amount, not an unlimited
|
|
303
|
-
value.
|
|
366
|
+
value. Finite format-2 withdrawal permits that cover the quoted minimum allowance remain valid;
|
|
367
|
+
this finite-permit compatibility does not apply to force-withdraw plans.
|
|
304
368
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
internally, but withdrawals have no on-chain share-price or maximum-shares bound. A price drop
|
|
369
|
+
Deposit and migration plans accept `slippageTolerance`, which sets their on-chain maximum share price.
|
|
370
|
+
`vaultV1Withdraw` and `vaultV2Withdraw` plans do not accept it: the share-allowance quote uses `DEFAULT_SLIPPAGE_TOLERANCE`
|
|
371
|
+
internally, but these ordinary withdrawals have no on-chain share-price or maximum-shares bound. A price drop
|
|
308
372
|
before inclusion can burn more shares than quoted.
|
|
309
373
|
|
|
374
|
+
`vaultV1InKindRedeem` and `vaultV2InKindRedeem` are also asset-denominated, with no on-chain share-price or maximum-shares
|
|
375
|
+
bound. A price drop before inclusion can burn more shares than quoted.
|
|
376
|
+
Each preparer takes one caller-fetched `vault` snapshot (`AccrualVault` for V1, `AccrualVaultV2`
|
|
377
|
+
for V2) and no `deployless` option.
|
|
378
|
+
V1 and V2 prepare and stored in-kind quantities use `assets`; builders translate to the stable entity/ABI
|
|
379
|
+
`amount`. Share approvals store `shares`, while ERC-2612 typed data retains `value`.
|
|
380
|
+
|
|
381
|
+
Use `prepareVaultV2ForceWithdraw` with one caller-fetched `vault: AccrualVaultV2` snapshot for a
|
|
382
|
+
penalty-inclusive asset exit; it accepts no `deployless` option. Prepare and stored `assets`
|
|
383
|
+
include the penalty. Optional `slippageTolerance` derives the stored on-chain `minSharePriceE27`
|
|
384
|
+
floor from the snapshot, using the entity default when omitted; plans accept no raw floor override.
|
|
385
|
+
Share allowances and permits target VaultExitBundlesV1, and any permit
|
|
386
|
+
must be unlimited (`maxUint256`).
|
|
387
|
+
|
|
388
|
+
`prepareVaultV2ForceRedeem` takes `vaultAddress`, top-level `shares`, and ordered deallocations
|
|
389
|
+
with `assets`. It creates a native vault multicall with no `supportSignature` or `deployless`
|
|
390
|
+
option. Stored inputs retain `vault` and `redeem.shares`; the entity method is unchanged.
|
|
391
|
+
|
|
392
|
+
Use `prepareVaultV2Redeem(client, { shareToken, chainId, account, shares, supportSignature })`
|
|
393
|
+
to burn exactly `shares`; pass the account's share balance for a full redemption.
|
|
394
|
+
`supportSignature` defaults to `false` (direct approval); `true` uses an ERC-2612 share
|
|
395
|
+
permit when allowance is insufficient. No Permit2 is used. Exact-share redemption needs
|
|
396
|
+
no quote: `shareToken: Token` is required, but an address-only `new Token({ address })` is sufficient.
|
|
397
|
+
An accrual snapshot also satisfies `Token`. Redemption sets no minimum assets received and accepts
|
|
398
|
+
neither `slippageTolerance` nor `deployless`.
|
|
399
|
+
Plans are serializable data; `buildTransaction` and `buildTransactions` return plain
|
|
400
|
+
frozen SDK transactions without step `id` or `kind` fields.
|
|
401
|
+
|
|
310
402
|
```typescript
|
|
311
403
|
import {
|
|
312
404
|
buildTransactions,
|
|
@@ -522,13 +614,13 @@ Link this package to your app for local debugging:
|
|
|
522
614
|
|
|
523
615
|
```bash
|
|
524
616
|
# In this morpho-sdk project
|
|
525
|
-
|
|
526
|
-
|
|
617
|
+
bun run build
|
|
618
|
+
bun link
|
|
527
619
|
```
|
|
528
620
|
|
|
529
621
|
```bash
|
|
530
622
|
# In your other project
|
|
531
|
-
|
|
623
|
+
bun link @morpho-org/morpho-sdk
|
|
532
624
|
```
|
|
533
625
|
|
|
534
626
|
Contribute from the monorepo root. See [CONTRIBUTING.md](../../CONTRIBUTING.md) for setup, checks, and package workflow. Report vulnerabilities through [SECURITY.md](../../SECURITY.md).
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi as bluePreLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/cjs/abis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.midnightBlueBuyCallbackAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.
|
|
3
|
+
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightEventsAbi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightEcrecoverAuthorizerAbi = exports.midnightBlueBuyCallbackFactoryAbi = exports.midnightBlueBuyCallbackAbi = exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.bluePreLiquidationFactoryAbi = exports.bluePreLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
6
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -13,10 +13,6 @@ Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true,
|
|
|
13
13
|
Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
|
|
14
14
|
Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
|
|
15
15
|
Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
|
|
16
|
-
Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
|
|
17
|
-
Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
|
|
18
|
-
Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
|
|
19
|
-
Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
|
|
20
16
|
Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
|
|
21
17
|
Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
|
|
22
18
|
Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
|
|
@@ -29,8 +29,9 @@ const validateBlueBundlesV1NativeFunding = (params) => {
|
|
|
29
29
|
if (nativeAmount < 0n) {
|
|
30
30
|
throw new index_js_2.NegativeInputError("nativeAmount", nativeAmount);
|
|
31
31
|
}
|
|
32
|
-
if (nativeAmount === 0n)
|
|
32
|
+
if (nativeAmount === 0n) {
|
|
33
33
|
return 0n;
|
|
34
|
+
}
|
|
34
35
|
(0, index_js_1.validateNativeAsset)(params.chainId, params.token);
|
|
35
36
|
if (nativeAmount !== params.fundedAmount) {
|
|
36
37
|
throw new index_js_2.NativeFundingAmountMismatchError(nativeAmount, params.fundedAmount);
|
|
@@ -55,8 +56,9 @@ exports.getBlueBundlesV1TokenPermit = getBlueBundlesV1TokenPermit;
|
|
|
55
56
|
/** @internal */
|
|
56
57
|
const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
57
58
|
const { authorizationSignature } = params;
|
|
58
|
-
if (authorizationSignature == null)
|
|
59
|
+
if (authorizationSignature == null) {
|
|
59
60
|
return EMPTY_SIGNED_AUTHORIZATION;
|
|
61
|
+
}
|
|
60
62
|
const authorized = (0, morpho_ts_1.getChainAddress)(params.chainId, "bundles.blueBundlesV1");
|
|
61
63
|
if (!(0, viem_1.isAddressEqual)(authorizationSignature.args.owner, params.userAddress)) {
|
|
62
64
|
throw new index_js_2.DepositOwnerMismatchError(params.userAddress, authorizationSignature.args.owner);
|
|
@@ -49,8 +49,9 @@ const blueWithdrawBuyCallback = (params) => {
|
|
|
49
49
|
const { callbackAddress, userAddress, shares } = params.args;
|
|
50
50
|
(0, validate_js_1.validateMarketParamsId)(marketParams);
|
|
51
51
|
(0, validate_js_1.validateUint256Field)("shares", shares);
|
|
52
|
-
if (shares === 0n)
|
|
52
|
+
if (shares === 0n) {
|
|
53
53
|
throw new index_js_2.NonPositiveInputError("shares", shares);
|
|
54
|
+
}
|
|
54
55
|
let tx = {
|
|
55
56
|
to: (0, morpho_ts_1.getChainAddress)(chainId, "blue"),
|
|
56
57
|
value: 0n,
|
|
@@ -66,10 +66,10 @@ const resolveBundlesFunding = (params) => {
|
|
|
66
66
|
}
|
|
67
67
|
const assets = amount ?? nativeAmount ?? 0n;
|
|
68
68
|
if (assets < 0n) {
|
|
69
|
-
throw new index_js_2.NegativeInputError(amount
|
|
69
|
+
throw new index_js_2.NegativeInputError(amount == null ? "nativeAmount" : "amount", assets);
|
|
70
70
|
}
|
|
71
71
|
if (assets === 0n) {
|
|
72
|
-
throw new index_js_2.NonPositiveInputError(amount
|
|
72
|
+
throw new index_js_2.NonPositiveInputError(amount == null ? "nativeAmount" : "amount", assets);
|
|
73
73
|
}
|
|
74
74
|
return { assets, value: nativeAmount ?? 0n };
|
|
75
75
|
};
|
|
@@ -107,11 +107,13 @@ exports.resolveBundlesFunding = resolveBundlesFunding;
|
|
|
107
107
|
*/
|
|
108
108
|
const getBundlesTokenPermit = (params) => {
|
|
109
109
|
const { requirementSignature } = params;
|
|
110
|
-
if (requirementSignature == null)
|
|
110
|
+
if (requirementSignature == null) {
|
|
111
111
|
return { ...EMPTY_TOKEN_PERMIT };
|
|
112
|
+
}
|
|
112
113
|
const { type } = requirementSignature.action;
|
|
113
|
-
if (type !== "permit" && type !== "permit2SignatureTransfer")
|
|
114
|
+
if (type !== "permit" && type !== "permit2SignatureTransfer") {
|
|
114
115
|
throw new index_js_2.UnsupportedRequirementSignatureError(type);
|
|
116
|
+
}
|
|
115
117
|
if (!(0, viem_1.isAddressEqual)(requirementSignature.args.owner, params.userAddress)) {
|
|
116
118
|
throw new index_js_2.DepositOwnerMismatchError(params.userAddress, requirementSignature.args.owner);
|
|
117
119
|
}
|
|
@@ -362,10 +364,12 @@ exports.getBundlesSharesPermit = getBundlesSharesPermit;
|
|
|
362
364
|
* from the operation's, or when a carried action nonce is inconsistent with the signed nonce.
|
|
363
365
|
*/
|
|
364
366
|
const selectBundlesTokenRequirementSignature = (signatures, expected) => {
|
|
365
|
-
if (signatures == null)
|
|
367
|
+
if (signatures == null) {
|
|
366
368
|
return undefined;
|
|
367
|
-
|
|
369
|
+
}
|
|
370
|
+
if (signatures.length === 0) {
|
|
368
371
|
return undefined;
|
|
372
|
+
}
|
|
369
373
|
const selected = signatures.filter((signature) => signature.action.type === "permit" ||
|
|
370
374
|
signature.action.type === "permit2SignatureTransfer");
|
|
371
375
|
if (selected.length !== signatures.length) {
|
|
@@ -377,8 +381,9 @@ const selectBundlesTokenRequirementSignature = (signatures, expected) => {
|
|
|
377
381
|
throw new index_js_2.AmbiguousRequirementSignaturesError("permit", selected.length);
|
|
378
382
|
}
|
|
379
383
|
const selectedSignature = selected[0];
|
|
380
|
-
if (selectedSignature == null)
|
|
384
|
+
if (selectedSignature == null) {
|
|
381
385
|
return undefined;
|
|
386
|
+
}
|
|
382
387
|
const { action } = selectedSignature;
|
|
383
388
|
if (!(0, viem_1.isAddressEqual)(action.args.spender, expected.spender)) {
|
|
384
389
|
throw new index_js_2.BundlesPermitMismatchError({
|
|
@@ -387,9 +392,9 @@ const selectBundlesTokenRequirementSignature = (signatures, expected) => {
|
|
|
387
392
|
actual: action.args.spender,
|
|
388
393
|
});
|
|
389
394
|
}
|
|
390
|
-
const actualAmount = selectedSignature.args.amount
|
|
391
|
-
?
|
|
392
|
-
:
|
|
395
|
+
const actualAmount = selectedSignature.args.amount === expected.amount
|
|
396
|
+
? action.args.amount
|
|
397
|
+
: selectedSignature.args.amount;
|
|
393
398
|
if (actualAmount !== expected.amount) {
|
|
394
399
|
throw new index_js_2.BundlesPermitMismatchError({
|
|
395
400
|
field: "amount",
|
|
@@ -397,9 +402,9 @@ const selectBundlesTokenRequirementSignature = (signatures, expected) => {
|
|
|
397
402
|
actual: String(actualAmount),
|
|
398
403
|
});
|
|
399
404
|
}
|
|
400
|
-
const actualDeadline = selectedSignature.args.deadline
|
|
401
|
-
?
|
|
402
|
-
:
|
|
405
|
+
const actualDeadline = selectedSignature.args.deadline === expected.deadline
|
|
406
|
+
? action.args.deadline
|
|
407
|
+
: selectedSignature.args.deadline;
|
|
403
408
|
if (actualDeadline !== expected.deadline) {
|
|
404
409
|
throw new index_js_2.BundlesPermitMismatchError({
|
|
405
410
|
field: "deadline",
|
|
@@ -436,8 +441,9 @@ exports.selectBundlesTokenRequirementSignature = selectBundlesTokenRequirementSi
|
|
|
436
441
|
*/
|
|
437
442
|
const selectBundlesSharesPermitSignature = (signatures, expected) => {
|
|
438
443
|
const { permit } = (0, index_js_2.selectRequirementSignatures)(signatures, { permit: true });
|
|
439
|
-
if (permit == null)
|
|
444
|
+
if (permit == null) {
|
|
440
445
|
return undefined;
|
|
446
|
+
}
|
|
441
447
|
const { action } = permit;
|
|
442
448
|
if (action.type !== "permit") {
|
|
443
449
|
throw new index_js_2.BundlesPermitMismatchError({
|
|
@@ -71,8 +71,9 @@ const resolveBundlesTokenRequirements = (params) => {
|
|
|
71
71
|
});
|
|
72
72
|
// Reject invalid pulls before an approval encoder can cap the requested amount.
|
|
73
73
|
(0, validate_js_1.validateUint256Field)("amount", params.amount);
|
|
74
|
-
if (params.amount === 0n)
|
|
74
|
+
if (params.amount === 0n) {
|
|
75
75
|
return [];
|
|
76
|
+
}
|
|
76
77
|
if (params.state.type === "approval") {
|
|
77
78
|
return (0, getRequirementsApproval_js_1.getRequirementsApproval)({
|
|
78
79
|
address: params.token,
|
|
@@ -62,8 +62,9 @@ const midnightCancelOffers = (params) => {
|
|
|
62
62
|
if ((0, viem_1.isAddressEqual)(onBehalf, viem_1.zeroAddress)) {
|
|
63
63
|
throw new index_js_2.MidnightZeroOnBehalfError("onBehalf");
|
|
64
64
|
}
|
|
65
|
-
if (groups.length === 0)
|
|
65
|
+
if (groups.length === 0) {
|
|
66
66
|
throw new index_js_2.EmptyMidnightGroupCancellationsError();
|
|
67
|
+
}
|
|
67
68
|
const seen = new Set();
|
|
68
69
|
for (const [index, group] of groups.entries()) {
|
|
69
70
|
// Validation only; rejects groups that are not 32-byte hex.
|
|
@@ -49,8 +49,9 @@ const midnightSupplyCollateralBatch = (params) => {
|
|
|
49
49
|
// Direct batches require one entry per index rather than summing duplicates.
|
|
50
50
|
(0, validateMidnightCollateralBatch_js_1.validateMidnightCollateralBatch)(params.collateralSupplies, new index_js_2.EmptyMidnightCollateralSuppliesError());
|
|
51
51
|
const calls = params.collateralSupplies.map(({ collateralIndex, assets }) => {
|
|
52
|
-
if (assets <= 0n)
|
|
52
|
+
if (assets <= 0n) {
|
|
53
53
|
throw new index_js_2.NonPositiveInputError("assets", assets);
|
|
54
|
+
}
|
|
54
55
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("assets", assets);
|
|
55
56
|
// Reject indexes not configured on the market.
|
|
56
57
|
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
@@ -74,8 +75,9 @@ const midnightSupplyCollateralBatch = (params) => {
|
|
|
74
75
|
args: [calls],
|
|
75
76
|
}),
|
|
76
77
|
};
|
|
77
|
-
if (params.metadata)
|
|
78
|
+
if (params.metadata) {
|
|
78
79
|
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
80
|
+
}
|
|
79
81
|
return (0, morpho_ts_1.deepFreeze)({
|
|
80
82
|
...tx,
|
|
81
83
|
action: {
|
|
@@ -150,8 +150,9 @@ const midnightSupplyCollateralTakeBorrow = (params) => {
|
|
|
150
150
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
151
151
|
}
|
|
152
152
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
153
|
-
if (params.referralFeeRecipient !== undefined)
|
|
153
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
154
154
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
155
|
+
}
|
|
155
156
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
156
157
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
157
158
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -128,8 +128,9 @@ const midnightTakeBorrow = (params) => {
|
|
|
128
128
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
129
129
|
}
|
|
130
130
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
131
|
-
if (params.referralFeeRecipient !== undefined)
|
|
131
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
132
132
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
133
|
+
}
|
|
133
134
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
134
135
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
135
136
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -119,8 +119,9 @@ const midnightTakeLend = (params) => {
|
|
|
119
119
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
120
120
|
}
|
|
121
121
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
122
|
-
if (params.referralFeeRecipient !== undefined)
|
|
122
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
123
123
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
124
|
+
}
|
|
124
125
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
125
126
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
126
127
|
if (referralFeePct > 0n) {
|
|
@@ -154,8 +154,9 @@ const midnightTakeRepayWithdrawCollateral = (params) => {
|
|
|
154
154
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
155
155
|
}
|
|
156
156
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
157
|
-
if (params.referralFeeRecipient !== undefined)
|
|
157
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
158
158
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
159
|
+
}
|
|
159
160
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
160
161
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
161
162
|
if (referralFeePct > 0n) {
|
|
@@ -63,8 +63,9 @@ const validateParams = (params) => {
|
|
|
63
63
|
throw new index_js_2.UnboundedMidnightTakeInputError("deadline");
|
|
64
64
|
}
|
|
65
65
|
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
66
|
-
if (params.referralFeeRecipient !== undefined)
|
|
66
|
+
if (params.referralFeeRecipient !== undefined) {
|
|
67
67
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("referralFeeRecipient", params.referralFeeRecipient);
|
|
68
|
+
}
|
|
68
69
|
const { referralFeePct, referralFeeRecipient } = (0, validate_js_1.validateReferralFee)(params);
|
|
69
70
|
(0, validateMidnightBounds_js_1.validateMidnightReferralFeeCap)(referralFeePct);
|
|
70
71
|
(0, validateMidnightTakeFeasibility_js_1.validateMidnightSellTargetBounds)({ target, referralFeePct });
|
|
@@ -60,8 +60,9 @@ const midnightWithdrawCollateralBatch = (params) => {
|
|
|
60
60
|
// Direct batches require one entry per index rather than summing duplicates.
|
|
61
61
|
(0, validateMidnightCollateralBatch_js_1.validateMidnightCollateralBatch)(params.collateralWithdrawals, new index_js_2.EmptyMidnightCollateralWithdrawalsError());
|
|
62
62
|
const calls = params.collateralWithdrawals.map(({ collateralIndex, assets }) => {
|
|
63
|
-
if (assets <= 0n)
|
|
63
|
+
if (assets <= 0n) {
|
|
64
64
|
throw new index_js_2.NonPositiveInputError("assets", assets);
|
|
65
|
+
}
|
|
65
66
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("assets", assets);
|
|
66
67
|
// Reject indexes not configured on the market.
|
|
67
68
|
midnight_sdk_1.MarketUtils.getCollateralByIndex(params.market, collateralIndex);
|
|
@@ -86,8 +87,9 @@ const midnightWithdrawCollateralBatch = (params) => {
|
|
|
86
87
|
args: [calls],
|
|
87
88
|
}),
|
|
88
89
|
};
|
|
89
|
-
if (params.metadata)
|
|
90
|
+
if (params.metadata) {
|
|
90
91
|
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
92
|
+
}
|
|
91
93
|
return (0, morpho_ts_1.deepFreeze)({
|
|
92
94
|
...tx,
|
|
93
95
|
action: {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encodeErc20Permit2SignatureTransfer = void 0;
|
|
4
4
|
const blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
6
|
const signAndVerifyTypedData_js_1 = require("../../../helpers/signAndVerifyTypedData.js");
|
|
8
7
|
const validate_js_1 = require("../../../helpers/validate.js");
|
|
9
8
|
const validateRequirementSpender_js_1 = require("../../../helpers/validateRequirementSpender.js");
|
|
@@ -65,16 +64,8 @@ const encodeErc20Permit2SignatureTransfer = (params) => {
|
|
|
65
64
|
// this public encoder must reject the same out-of-range inputs itself.
|
|
66
65
|
(0, validate_js_1.validateUint256Field)("amount", amount);
|
|
67
66
|
(0, validate_js_1.validateUint256Field)("nonce", nonce);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (deadline > viem_1.maxUint256) {
|
|
72
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
73
|
-
field: "deadline",
|
|
74
|
-
value: deadline,
|
|
75
|
-
max: viem_1.maxUint256,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
67
|
+
// Reject deadlines outside the positive uint256 range before signing.
|
|
68
|
+
(0, validate_js_1.validateDeadline)(deadline);
|
|
78
69
|
// Reject an already-expired deadline before signing so a direct caller is never walked through a
|
|
79
70
|
// wallet EIP-712 prompt for a SignatureTransfer that Permit2 would revert with `SignatureExpired`.
|
|
80
71
|
// The sibling encodeErc20Permit and the token-requirement resolver enforce the same guard.
|
|
@@ -72,8 +72,9 @@ const getMidnightApprovalRequirements = async (params) => {
|
|
|
72
72
|
spender: params.spender,
|
|
73
73
|
allowed: ["midnight", "midnightBundlesV2"],
|
|
74
74
|
});
|
|
75
|
-
if (params.amount === 0n)
|
|
75
|
+
if (params.amount === 0n) {
|
|
76
76
|
return [];
|
|
77
|
+
}
|
|
77
78
|
await (0, validateClientChainId_js_1.validateClientChainId)(params.viemClient, params.chainId);
|
|
78
79
|
const allowance = await (0, actions_1.readContract)(params.viemClient, {
|
|
79
80
|
address: params.token,
|
|
@@ -68,8 +68,9 @@ const getMidnightAuthorizationRequirement = async (params) => {
|
|
|
68
68
|
functionName: "isAuthorized",
|
|
69
69
|
args: [params.owner, params.authorized],
|
|
70
70
|
});
|
|
71
|
-
if (isAuthorized)
|
|
71
|
+
if (isAuthorized) {
|
|
72
72
|
return null;
|
|
73
|
+
}
|
|
73
74
|
return (0, morpho_ts_1.deepFreeze)({
|
|
74
75
|
to: midnight,
|
|
75
76
|
value: 0n,
|
|
@@ -47,11 +47,13 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
49
|
const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
|
|
50
|
-
if (args.amount <= 0n)
|
|
50
|
+
if (args.amount <= 0n) {
|
|
51
51
|
throw new index_js_2.NonPositiveInputError("amount", args.amount);
|
|
52
|
+
}
|
|
52
53
|
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
53
|
-
if (args.marketParamsList.length === 0)
|
|
54
|
+
if (args.marketParamsList.length === 0) {
|
|
54
55
|
throw new index_js_2.EmptyMarketParamsListError();
|
|
56
|
+
}
|
|
55
57
|
const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
56
58
|
const marketParamsList = args.marketParamsList.map((marketParams) => ({
|
|
57
59
|
loanToken: marketParams.loanToken,
|
|
@@ -82,8 +84,9 @@ const vaultV1InKindRedeem = ({ vault, args, metadata, }) => {
|
|
|
82
84
|
],
|
|
83
85
|
}),
|
|
84
86
|
};
|
|
85
|
-
if (metadata)
|
|
87
|
+
if (metadata) {
|
|
86
88
|
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
89
|
+
}
|
|
87
90
|
return (0, morpho_ts_1.deepFreeze)({
|
|
88
91
|
...tx,
|
|
89
92
|
action: {
|
|
@@ -90,7 +90,7 @@ const vaultV1MigrateToV2 = (params) => {
|
|
|
90
90
|
throw new index_js_1.AmountAndSharesExclusiveError();
|
|
91
91
|
}
|
|
92
92
|
const selectedAmount = assets ?? shares ?? 0n;
|
|
93
|
-
const amountField = assets
|
|
93
|
+
const amountField = assets == null ? "shares" : "assets";
|
|
94
94
|
// Validation only; rejects non-positive migration amounts.
|
|
95
95
|
(0, validatePositiveInput_js_1.validatePositiveInput)(amountField, selectedAmount);
|
|
96
96
|
// Validation only; rejects non-positive share-price bounds.
|
|
@@ -77,8 +77,9 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
77
77
|
* ```
|
|
78
78
|
*/
|
|
79
79
|
const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
|
80
|
-
if (args.exitAssets <= 0n)
|
|
80
|
+
if (args.exitAssets <= 0n) {
|
|
81
81
|
throw new index_js_2.NonPositiveInputError("exitAssets", args.exitAssets);
|
|
82
|
+
}
|
|
82
83
|
(0, validate_js_1.validateUint256Field)("exitAssets", args.exitAssets);
|
|
83
84
|
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
84
85
|
// `0n` stays valid — it is the intentional "no on-chain bound" opt-out — but a value the uint256
|
|
@@ -112,8 +113,9 @@ const vaultV2ForceWithdraw = ({ vault, args, metadata, }) => {
|
|
|
112
113
|
],
|
|
113
114
|
}),
|
|
114
115
|
};
|
|
115
|
-
if (metadata)
|
|
116
|
+
if (metadata) {
|
|
116
117
|
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
118
|
+
}
|
|
117
119
|
return (0, morpho_ts_1.deepFreeze)({
|
|
118
120
|
...tx,
|
|
119
121
|
action: {
|
|
@@ -48,8 +48,9 @@ const common_js_1 = require("../bundles/common.js");
|
|
|
48
48
|
* ```
|
|
49
49
|
*/
|
|
50
50
|
const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
|
|
51
|
-
if (args.amount <= 0n)
|
|
51
|
+
if (args.amount <= 0n) {
|
|
52
52
|
throw new index_js_2.NonPositiveInputError("amount", args.amount);
|
|
53
|
+
}
|
|
53
54
|
(0, validate_js_1.validateDeadline)(args.deadline);
|
|
54
55
|
const to = (0, morpho_ts_1.getChainAddress)(vault.chainId, "bundles.vaultExitBundlesV1");
|
|
55
56
|
const marketParamsList = args.marketParamsList.map((marketParams) => ({
|
|
@@ -82,8 +83,9 @@ const vaultV2InKindRedeem = ({ vault, args, metadata, }) => {
|
|
|
82
83
|
],
|
|
83
84
|
}),
|
|
84
85
|
};
|
|
85
|
-
if (metadata)
|
|
86
|
+
if (metadata) {
|
|
86
87
|
tx = (0, index_js_1.addTransactionMetadata)(tx, metadata);
|
|
88
|
+
}
|
|
87
89
|
return (0, morpho_ts_1.deepFreeze)({
|
|
88
90
|
...tx,
|
|
89
91
|
action: {
|
package/lib/cjs/blue/abis.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { marketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi,
|
|
2
|
+
export { adaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
preLiquidationAbi,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/cjs/blue/abis.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.
|
|
3
|
+
exports.wstEthAbi = exports.wrappedBackedTokenAbi = exports.whitelistControllerAggregatorV2Abi = exports.vaultV2FactoryAbi = exports.vaultV2BluePublicAllocatorAbi = exports.vaultV2Abi = exports.preLiquidationFactoryAbi = exports.preLiquidationAbi = exports.permit2Abi = exports.permissionedErc20WrapperAbi = exports.morphoVaultV1AdapterFactoryAbi = exports.morphoVaultV1AdapterAbi = exports.morphoMarketV1AdapterV2FactoryAbi = exports.morphoMarketV1AdapterV2Abi = exports.morphoMarketV1AdapterFactoryAbi = exports.morphoMarketV1AdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.adaptiveCurveIrmAbi = exports.marketParamsAbi = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "marketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
6
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -13,10 +13,6 @@ Object.defineProperty(exports, "erc3643IdentityRegistryAbi", { enumerable: true,
|
|
|
13
13
|
Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
|
|
14
14
|
Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
|
|
15
15
|
Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
|
|
16
|
-
Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
|
|
17
|
-
Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
|
|
18
|
-
Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
|
|
19
|
-
Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
|
|
20
16
|
Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
|
|
21
17
|
Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
|
|
22
18
|
Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
|