@morpho-org/morpho-sdk 10.1.0 → 10.3.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 +126 -140
- package/lib/cjs/abis.d.ts +34 -0
- package/lib/cjs/abis.js +21 -1
- package/lib/cjs/actions/blue/borrow.d.ts +11 -3
- package/lib/cjs/actions/blue/borrow.internal.js +1 -0
- package/lib/cjs/actions/blue/borrow.js +8 -2
- package/lib/cjs/actions/blue/common.d.ts +4 -1
- package/lib/cjs/actions/blue/common.js +17 -3
- package/lib/cjs/actions/blue/refinance.d.ts +11 -3
- package/lib/cjs/actions/blue/refinance.internal.js +4 -1
- package/lib/cjs/actions/blue/refinance.js +8 -2
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +3 -2
- package/lib/cjs/actions/blue/refinanceValidation.js +10 -6
- package/lib/cjs/actions/blue/repay.d.ts +4 -3
- package/lib/cjs/actions/blue/repay.js +3 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +3 -2
- package/lib/cjs/actions/blue/supply.d.ts +5 -3
- package/lib/cjs/actions/blue/supply.js +4 -2
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +3 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +11 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +5 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +8 -2
- package/lib/cjs/actions/blue/withdraw.d.ts +11 -3
- package/lib/cjs/actions/blue/withdraw.internal.js +4 -1
- package/lib/cjs/actions/blue/withdraw.js +8 -2
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/withdrawCollateral.js +3 -2
- package/lib/cjs/actions/bundles/common.d.ts +2 -8
- package/lib/cjs/actions/bundles/common.js +8 -20
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +0 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +0 -1
- package/lib/cjs/actions/midnight/takeLend.js +0 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +0 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +0 -1
- package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/deposit.js +2 -1
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +3 -2
- package/lib/cjs/actions/vaultV1/migrateToV2.js +2 -1
- package/lib/cjs/actions/vaultV1/redeem.d.ts +3 -2
- package/lib/cjs/actions/vaultV1/redeem.js +2 -1
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +2 -1
- package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/deposit.js +2 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -1
- package/lib/cjs/actions/vaultV2/redeem.d.ts +3 -2
- package/lib/cjs/actions/vaultV2/redeem.js +2 -1
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/entities/blue/blue.d.ts +83 -20
- package/lib/cjs/entities/blue/blue.js +38 -12
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -6
- package/lib/cjs/entities/vaultV1/vaultV1.js +6 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +12 -7
- package/lib/cjs/entities/vaultV2/vaultV2.js +4 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +11 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +19 -21
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
- package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/cjs/helpers/reallocationPenalty.js +32 -0
- package/lib/cjs/helpers/referralFee.d.ts +2 -1
- package/lib/cjs/helpers/referralFee.js +5 -1
- package/lib/cjs/helpers/validate.d.ts +31 -4
- package/lib/cjs/helpers/validate.js +48 -9
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
- package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/cjs/transactionPlan/blue/refinance.js +20 -3
- package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/repay.js +1 -2
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
- package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/supply.js +1 -2
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +15 -5
- package/lib/cjs/transactionPlan/blue/withdraw.js +25 -6
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +11 -7
- package/lib/cjs/transactionPlan/deposit.js +4 -0
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/intent.js +4 -2
- package/lib/cjs/transactionPlan/plan.d.ts +8 -4
- package/lib/cjs/transactionPlan/plan.js +8 -4
- package/lib/cjs/transactionPlan/types.d.ts +6 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/cjs/types/error.d.ts +7 -6
- package/lib/cjs/types/error.js +10 -9
- package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +34 -0
- package/lib/esm/abis.js +20 -0
- package/lib/esm/actions/blue/borrow.d.ts +11 -3
- package/lib/esm/actions/blue/borrow.internal.js +1 -0
- package/lib/esm/actions/blue/borrow.js +8 -2
- package/lib/esm/actions/blue/common.d.ts +4 -1
- package/lib/esm/actions/blue/common.js +17 -3
- package/lib/esm/actions/blue/refinance.d.ts +11 -3
- package/lib/esm/actions/blue/refinance.internal.js +4 -1
- package/lib/esm/actions/blue/refinance.js +8 -2
- package/lib/esm/actions/blue/refinanceValidation.d.ts +3 -2
- package/lib/esm/actions/blue/refinanceValidation.js +10 -6
- package/lib/esm/actions/blue/repay.d.ts +4 -3
- package/lib/esm/actions/blue/repay.js +3 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -2
- package/lib/esm/actions/blue/supply.d.ts +5 -3
- package/lib/esm/actions/blue/supply.js +4 -2
- package/lib/esm/actions/blue/supplyCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/supplyCollateral.js +3 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +11 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +5 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +8 -2
- package/lib/esm/actions/blue/withdraw.d.ts +11 -3
- package/lib/esm/actions/blue/withdraw.internal.js +4 -1
- package/lib/esm/actions/blue/withdraw.js +8 -2
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/withdrawCollateral.js +3 -2
- package/lib/esm/actions/bundles/common.d.ts +2 -8
- package/lib/esm/actions/bundles/common.js +4 -17
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +1 -2
- package/lib/esm/actions/midnight/takeBorrow.js +1 -2
- package/lib/esm/actions/midnight/takeLend.js +1 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +1 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +2 -1
- package/lib/esm/actions/vaultV1/deposit.js +2 -1
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +3 -2
- package/lib/esm/actions/vaultV1/migrateToV2.js +2 -1
- package/lib/esm/actions/vaultV1/redeem.d.ts +3 -2
- package/lib/esm/actions/vaultV1/redeem.js +2 -1
- package/lib/esm/actions/vaultV1/withdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV1/withdraw.js +2 -1
- package/lib/esm/actions/vaultV2/deposit.d.ts +2 -1
- package/lib/esm/actions/vaultV2/deposit.js +2 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +2 -1
- package/lib/esm/actions/vaultV2/redeem.d.ts +3 -2
- package/lib/esm/actions/vaultV2/redeem.js +2 -1
- package/lib/esm/actions/vaultV2/withdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV2/withdraw.js +2 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +83 -20
- package/lib/esm/entities/blue/blue.js +38 -12
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -6
- package/lib/esm/entities/vaultV1/vaultV1.js +7 -1
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +12 -7
- package/lib/esm/entities/vaultV2/vaultV2.js +5 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +11 -2
- package/lib/esm/entities/vaultV2BlueReallocationData.js +17 -19
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/esm/helpers/quoteBlueRepay.js +21 -8
- package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/esm/helpers/reallocationPenalty.js +28 -0
- package/lib/esm/helpers/referralFee.d.ts +2 -1
- package/lib/esm/helpers/referralFee.js +5 -1
- package/lib/esm/helpers/validate.d.ts +31 -4
- package/lib/esm/helpers/validate.js +48 -11
- package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/esm/helpers/validateMidnightBounds.js +1 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/esm/transactionPlan/blue/borrow.js +27 -9
- package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/esm/transactionPlan/blue/refinance.js +20 -3
- package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/repay.js +1 -2
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
- package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/supply.js +1 -2
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +15 -5
- package/lib/esm/transactionPlan/blue/withdraw.js +25 -6
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +11 -7
- package/lib/esm/transactionPlan/deposit.js +5 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/intent.js +4 -2
- package/lib/esm/transactionPlan/plan.d.ts +8 -4
- package/lib/esm/transactionPlan/plan.js +8 -4
- package/lib/esm/transactionPlan/types.d.ts +6 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/esm/types/error.d.ts +7 -6
- package/lib/esm/types/error.js +11 -10
- package/lib/esm/types/sharedLiquidity.d.ts +7 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,16 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
> 📖 **Full documentation → [docs.morpho.org/developers/sdks/morpho-sdk](https://docs.morpho.org/developers/sdks/morpho-sdk/)**
|
|
9
9
|
|
|
10
|
-
Build transactions for Morpho's **
|
|
11
|
-
|
|
12
|
-
## Removed in v6
|
|
13
|
-
|
|
14
|
-
Vault V1 PublicAllocator APIs, low-level Bundler3 composition, migration adapters, and legacy
|
|
15
|
-
MORPHO wrapping were removed. Use Vault V2 BluePublicAllocator APIs:
|
|
16
|
-
`getVaultV2BlueReallocationData()` fetches the state and `getVaultV2BlueReallocations()` prepares a
|
|
17
|
-
plan for a Blue action.
|
|
18
|
-
|
|
19
|
-
General Vault V1 operations remain supported.
|
|
10
|
+
Build transactions for Morpho's **Midnight** fixed-rate markets, **Blue** markets, **VaultV2**, and **VaultV1** (MetaMorpho) on chains with the required protocol and periphery deployments. Custom deployments can be added with `registerCustomAddresses` from `@morpho-org/morpho-sdk/addresses`.
|
|
20
11
|
|
|
21
12
|
## Installation
|
|
22
13
|
|
|
@@ -28,36 +19,18 @@ Read [Dead-share validators](./DEAD-SHARE-PROTECTION.md) for the exported checks
|
|
|
28
19
|
enforce the dead-deposit rule; integrators should validate their snapshot before building.
|
|
29
20
|
Snapshot-free Blue `supply` remains deprecated.
|
|
30
21
|
|
|
31
|
-
Upgrading
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
Upgrading from v8? Read the [v8 → v9 migration guide](./MIGRATION-v8-to-v9.md) for the approval
|
|
35
|
-
API removals and the new unlimited-approval behavior.
|
|
36
|
-
|
|
37
|
-
Upgrading from v6? Read the [v6 → v7 migration guide](./MIGRATION-v6-to-v7.md) before updating
|
|
38
|
-
Midnight maker integrations. Upgrading from v7? Read the
|
|
39
|
-
[v7 → v8 migration guide](./MIGRATION-v7-to-v8.md) before relying on fail-closed token metadata or
|
|
40
|
-
permit requirement errors. The guide also covers wrong-chain RPC checks (`eth_chainId`)
|
|
41
|
-
on entity reads and requirement resolvers. It also covers missing-contract checks. Upgrading from
|
|
42
|
-
v5? Read the
|
|
43
|
-
[v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating vault deposit or Blue write
|
|
44
|
-
integrations.
|
|
22
|
+
Upgrading? Read the [v9 → v10 migration guide](./MIGRATION-v9-to-v10.md). Older guides:
|
|
23
|
+
[v8 → v9](./MIGRATION-v8-to-v9.md), [v7 → v8](./MIGRATION-v7-to-v8.md),
|
|
24
|
+
[v6 → v7](./MIGRATION-v6-to-v7.md), [v5 → v6](./MIGRATION-v5-to-v6.md).
|
|
45
25
|
|
|
46
26
|
## Actions
|
|
47
27
|
|
|
48
|
-
Each entity exposes a set of actions.
|
|
49
|
-
BlueBundlesV1, and the remaining rows identify their
|
|
28
|
+
Each entity exposes a set of actions. Midnight takes and makes call MidnightBundlesV2, Blue writes
|
|
29
|
+
call BlueBundlesV1, common vault writes call VaultBundlesV1, and the remaining rows identify their
|
|
30
|
+
destination.
|
|
50
31
|
|
|
51
32
|
| Entity | Actions | Route |
|
|
52
33
|
| --- | --- | --- |
|
|
53
|
-
| **VaultV1** (MetaMorpho) | `deposit`, `withdraw`, `redeem`, `migrateToV2` | VaultBundlesV1 |
|
|
54
|
-
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
55
|
-
| **VaultV2** | `deposit`, `withdraw`, `redeem` | VaultBundlesV1 |
|
|
56
|
-
| | `forceWithdraw` | VaultExitBundlesV1 |
|
|
57
|
-
| | `forceRedeem` | Vault multicall |
|
|
58
|
-
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
59
|
-
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
60
|
-
| **Blue** | `withdrawBuyCallback` | Morpho Blue (direct `withdraw` for a BlueBuyCallback's owner) |
|
|
61
34
|
| **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `takeRepayWithdrawCollateral`, `repayWithdrawCollateral`, `takeWithdraw` | MidnightBundlesV2 (Ethereum, Base, Arbitrum, Arc, Robinhood, Tempo) |
|
|
62
35
|
| | `supplyCollateral` | Midnight Core; ERC-20 only, no wrapping |
|
|
63
36
|
| | `supplyCollateralWithNative` | MidnightBundlesV2 `midnightBundlesV2CancelAndMake`; wraps a positive `nativeAmount` into registered wNative, requires a `deadline`, and uses bundle approval and Midnight authorization |
|
|
@@ -65,6 +38,14 @@ BlueBundlesV1, and the remaining rows identify their destination.
|
|
|
65
38
|
| | `supplyCollateralBatch`, `withdrawCollateralBatch` | Midnight multicall |
|
|
66
39
|
| | `cancelOffers` | Direct call for one group (`setConsumed`), Midnight multicall for several; every Midnight chain |
|
|
67
40
|
| | `makeLend`, `makeBorrow`, `makeWithdraw`, `makeRepay`, `supplyCollateralMakeBorrow`, `supplyBlueMakeLend` | MidnightBundlesV2 (Ethereum, Base, Arbitrum, Arc, Robinhood, Tempo) |
|
|
41
|
+
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
42
|
+
| | `withdrawBuyCallback` | Morpho Blue (direct `withdraw` for a BlueBuyCallback's owner) |
|
|
43
|
+
| **VaultV2** | `deposit`, `withdraw`, `redeem` | VaultBundlesV1 |
|
|
44
|
+
| | `forceWithdraw` | VaultExitBundlesV1 |
|
|
45
|
+
| | `forceRedeem` | Vault multicall |
|
|
46
|
+
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
47
|
+
| **VaultV1** (MetaMorpho) | `deposit`, `withdraw`, `redeem`, `migrateToV2` | VaultBundlesV1 |
|
|
48
|
+
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
68
49
|
|
|
69
50
|
`makeBorrow` publishes without collateral; `supplyCollateralMakeBorrow` requires collateral and
|
|
70
51
|
supplies it in the same transaction.
|
|
@@ -157,14 +138,14 @@ const walletClient = createWalletClient({
|
|
|
157
138
|
|
|
158
139
|
Create an entity — every factory takes a chain ID as its last argument:
|
|
159
140
|
|
|
160
|
-
- `client.morpho.vaultV1(address, chainId)` / `client.morpho.vaultV2(address, chainId)`
|
|
161
|
-
- `client.morpho.blue(marketParams, chainId)`
|
|
162
141
|
- `client.morpho.midnight(chainId)`
|
|
142
|
+
- `client.morpho.blue(marketParams, chainId)`
|
|
143
|
+
- `client.morpho.vaultV2(address, chainId)` / `client.morpho.vaultV1(address, chainId)`
|
|
163
144
|
|
|
164
145
|
### Vault deposit / withdraw
|
|
165
146
|
|
|
166
147
|
Deposit calls VaultBundlesV1 and may require an approval or permit. ERC-20 approvals and ERC-2612
|
|
167
|
-
permits authorize VaultBundlesV1.
|
|
148
|
+
permits authorize VaultBundlesV1.
|
|
168
149
|
|
|
169
150
|
```typescript
|
|
170
151
|
const vault = client.morpho.vaultV2("0xVault...", 1);
|
|
@@ -232,6 +213,81 @@ async function withdrawUsdc(provider: EIP1193Provider, supportSignature = false)
|
|
|
232
213
|
For wNative vaults, pass `nativeAmount` instead of `amount`. The transaction sends that amount as
|
|
233
214
|
`tx.value` to VaultBundlesV1, which wraps it internally; native deposits require no token permit.
|
|
234
215
|
|
|
216
|
+
### Midnight: take a fixed-rate offer
|
|
217
|
+
|
|
218
|
+
```typescript
|
|
219
|
+
const midnight = client.morpho.midnight(8453);
|
|
220
|
+
const marketData = await midnight.getMarketData(marketId);
|
|
221
|
+
|
|
222
|
+
const output = midnight.takeLend({
|
|
223
|
+
accountAddress: lender,
|
|
224
|
+
marketData,
|
|
225
|
+
target: { type: "assets", assets: 1_000_000n, minUnits: 900_000n },
|
|
226
|
+
takeableOffers: quote.data.takeableOffers,
|
|
227
|
+
maxContinuousFee: maxUint256,
|
|
228
|
+
deadline,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
const requirements = await output.getRequirements();
|
|
232
|
+
const tx = output.buildTx();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Midnight: collateral batches
|
|
236
|
+
|
|
237
|
+
`supplyCollateralBatch` and `withdrawCollateralBatch` move several collaterals of one position in
|
|
238
|
+
one transaction: a Midnight core `multicall` of direct `supplyCollateral` or `withdrawCollateral`
|
|
239
|
+
calls that reverts as a whole. Pass one entry per collateral index; duplicates throw
|
|
240
|
+
`DuplicateMidnightCollateralIndexError`, unlike the bundle flows, which sum them.
|
|
241
|
+
|
|
242
|
+
A supply batch returns one unlimited Midnight approval per collateral token whose allowance is
|
|
243
|
+
below that token's total:
|
|
244
|
+
|
|
245
|
+
```typescript
|
|
246
|
+
const supply = midnight.supplyCollateralBatch({
|
|
247
|
+
accountAddress: user,
|
|
248
|
+
marketData,
|
|
249
|
+
collateralSupplies: [
|
|
250
|
+
{ collateralIndex: 0n, assets: 1_000_000n },
|
|
251
|
+
{ collateralIndex: 1n, assets: 2_000_000_000_000_000_000n },
|
|
252
|
+
],
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
for (const approval of await supply.getRequirements()) {
|
|
256
|
+
const hash = await walletClient.sendTransaction({ ...approval, account: user });
|
|
257
|
+
await client.waitForTransactionReceipt({ hash });
|
|
258
|
+
}
|
|
259
|
+
await walletClient.sendTransaction({ ...supply.buildTx(), account: user });
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
A withdraw batch checks every entry against `positionData` and, when the position has debt, checks
|
|
263
|
+
the remaining collateral against the LLTV buffer using `collateralPrices`. `maxUint256` withdraws
|
|
264
|
+
that index's whole balance. It needs no requirements:
|
|
265
|
+
|
|
266
|
+
```typescript
|
|
267
|
+
import { blueOracleAbi } from "@morpho-org/morpho-sdk/abis";
|
|
268
|
+
import { maxUint256 } from "viem";
|
|
269
|
+
|
|
270
|
+
const positionData = await midnight.getPositionData({ marketId, accountAddress: user });
|
|
271
|
+
const collateralPrices = await Promise.all(
|
|
272
|
+
marketData.params.collateralParams.map(({ oracle }) =>
|
|
273
|
+
client.readContract({ address: oracle, abi: blueOracleAbi, functionName: "price" }),
|
|
274
|
+
),
|
|
275
|
+
);
|
|
276
|
+
|
|
277
|
+
const withdrawal = midnight.withdrawCollateralBatch({
|
|
278
|
+
accountAddress: user,
|
|
279
|
+
marketData,
|
|
280
|
+
positionData,
|
|
281
|
+
collateralPrices,
|
|
282
|
+
collateralWithdrawals: [
|
|
283
|
+
{ collateralIndex: 0n, assets: 500_000n },
|
|
284
|
+
{ collateralIndex: 1n, assets: maxUint256 },
|
|
285
|
+
],
|
|
286
|
+
receiver: user,
|
|
287
|
+
});
|
|
288
|
+
await walletClient.sendTransaction({ ...withdrawal.buildTx(), account: user });
|
|
289
|
+
```
|
|
290
|
+
|
|
235
291
|
### Blue: BlueBundlesV1 writes
|
|
236
292
|
|
|
237
293
|
```typescript
|
|
@@ -273,24 +329,20 @@ borrowing. That path may also require Morpho authorization for BlueBundlesV1. Op
|
|
|
273
329
|
instant liquidation. Blue writes do not accept `slippageTolerance`, `minSharePrice`, or
|
|
274
330
|
`maxSharePrice` because BlueBundlesV1 has no share-price-bound inputs.
|
|
275
331
|
|
|
276
|
-
> High-level Blue writes and shared-liquidity planning use Vault V2 only. Vault V1 allocator and
|
|
277
|
-
> low-level composition surfaces were removed in v6; direct Vault V1 flows remain.
|
|
278
|
-
|
|
279
332
|
### TransactionPlan: sign and verify permits
|
|
280
333
|
|
|
281
334
|
> **Beta:** TransactionPlan is experimental; breaking changes may ship in minor releases.
|
|
282
335
|
> Existing entity flows remain the recommended stable path during the shadow-mode rollout.
|
|
283
336
|
|
|
284
|
-
Preparers emit stored format `version: 2`.
|
|
285
|
-
`
|
|
286
|
-
restoring them. There is no legacy parser.
|
|
337
|
+
Preparers emit stored format `version: 2`. Parsing rejects a version that is missing or not a safe integer
|
|
338
|
+
with `InvalidTransactionPlanError` and any other safe-integer version with `UnsupportedTransactionPlanVersionError`.
|
|
287
339
|
|
|
288
340
|
Prepare a Vault V2 deposit, withdrawal, force-withdraw or exact-share redemption plan, or a Vault V1 deposit or withdrawal plan with
|
|
289
341
|
`prepareVaultV1Deposit` or `prepareVaultV1Withdraw` and a `fetchAccrualVault` snapshot, then sign its pending requests with your wallet.
|
|
290
342
|
Deposit and withdrawal preparers take `assets`; redemption takes `shares`. Stored operation inputs
|
|
291
343
|
use the same names, except native-funded deposits store `nativeAssets` instead of `assets`.
|
|
292
344
|
Stored ERC-20 approval inputs likewise use `assets` for underlying-token approvals or `shares`
|
|
293
|
-
for vault-share approvals. See the [TransactionPlan format
|
|
345
|
+
for vault-share approvals. See the [TransactionPlan format notes](./src/transactionPlan/README.md).
|
|
294
346
|
Pass the caller-fetched `AccrualVault` (V1) or `AccrualVaultV2` (V2) once as `vault` for deposits,
|
|
295
347
|
and the matching snapshot as `vault` for withdrawals;
|
|
296
348
|
the contract address comes from `vault.address`. Only deposit preparation accepts `deployless`.
|
|
@@ -333,7 +385,8 @@ constraints. A successful parse does not prove intent or protect unsigned fields
|
|
|
333
385
|
must still protect stored plans.
|
|
334
386
|
|
|
335
387
|
Supported action types are `erc20Approval`, `morphoAuthorization`, `blueSupply`,
|
|
336
|
-
`blueSupplyCollateral`, `blueSupplyCollateralBorrow`, `
|
|
388
|
+
`blueSupplyCollateral`, `blueBorrow`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueWithdraw`,
|
|
389
|
+
`blueWithdrawCollateral`, `blueRepayWithdrawCollateral`, `blueRefinance`, `vaultV1Deposit`, `vaultV1Withdraw`,
|
|
337
390
|
`vaultV1Redeem`, `vaultV1InKindRedeem`, `vaultV1MigrateToV2`,
|
|
338
391
|
`vaultV2Deposit`, `vaultV2Withdraw`, `vaultV2Redeem`,
|
|
339
392
|
`vaultV2ForceWithdraw`, `vaultV2ForceRedeem` and `vaultV2InKindRedeem`. Builders return plain `Readonly<Transaction>` objects without step metadata.
|
|
@@ -342,7 +395,13 @@ Supported action types are `erc20Approval`, `morphoAuthorization`, `blueSupply`,
|
|
|
342
395
|
| --- | --- |
|
|
343
396
|
| `prepareBlueSupply` | Supply loan assets to a Blue market |
|
|
344
397
|
| `prepareBlueSupplyCollateral` | Supply collateral to a Blue market without borrowing |
|
|
398
|
+
| `prepareBlueBorrow` | Borrow from a Blue market against existing collateral |
|
|
345
399
|
| `prepareBlueSupplyCollateralBorrow` | Supply collateral, borrow, or perform both atomically on Blue |
|
|
400
|
+
| `prepareBlueRepay` | Repay Blue debt by assets or shares |
|
|
401
|
+
| `prepareBlueWithdraw` | Withdraw supplied loan assets from a Blue market |
|
|
402
|
+
| `prepareBlueWithdrawCollateral` | Withdraw collateral from a Blue market |
|
|
403
|
+
| `prepareBlueRepayWithdrawCollateral` | Repay, withdraw collateral, or perform both atomically on Blue |
|
|
404
|
+
| `prepareBlueRefinance` | Move a Blue borrow position to another market |
|
|
346
405
|
| `prepareVaultV2Deposit` | Deposit assets into Vault V2 |
|
|
347
406
|
| `prepareVaultV2Withdraw` | Withdraw assets from Vault V2 |
|
|
348
407
|
| `prepareVaultV2Redeem` | Redeem an exact number of Vault V2 shares |
|
|
@@ -448,85 +507,10 @@ intent. Empty signature input still validates all requests and returns the origi
|
|
|
448
507
|
IDs retain their existing signatures. Supplied IDs can replace invalid stored signatures, but every
|
|
449
508
|
replacement is verified.
|
|
450
509
|
|
|
451
|
-
###
|
|
510
|
+
### Import paths
|
|
452
511
|
|
|
453
512
|
Protocol-specific names are qualified in shared facades, for example `fetchBluePosition` and `fetchMidnightPosition` from `@morpho-org/morpho-sdk/fetch`. Canonical raw upstream names remain available under `/blue/{abis,addresses,constants,entities,errors,fetch,types,utils}` and `/midnight/{abis,constants,entities,errors,fetch,types,utils}`.
|
|
454
513
|
|
|
455
|
-
Morpho-ts registers MidnightBundlesV2 on Ethereum, Base, Arbitrum, Arc, Robinhood, and Tempo.
|
|
456
|
-
|
|
457
|
-
```typescript
|
|
458
|
-
const midnight = client.morpho.midnight(8453);
|
|
459
|
-
const marketData = await midnight.getMarketData(marketId);
|
|
460
|
-
|
|
461
|
-
const output = midnight.takeLend({
|
|
462
|
-
accountAddress: lender,
|
|
463
|
-
marketData,
|
|
464
|
-
target: { type: "assets", assets: 1_000_000n, minUnits: 900_000n },
|
|
465
|
-
takeableOffers: quote.data.takeableOffers,
|
|
466
|
-
maxContinuousFee: maxUint256,
|
|
467
|
-
deadline,
|
|
468
|
-
});
|
|
469
|
-
|
|
470
|
-
const requirements = await output.getRequirements();
|
|
471
|
-
const tx = output.buildTx();
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
### Midnight: collateral batches
|
|
475
|
-
|
|
476
|
-
`supplyCollateralBatch` and `withdrawCollateralBatch` move several collaterals of one position in
|
|
477
|
-
one transaction: a Midnight core `multicall` of direct `supplyCollateral` or `withdrawCollateral`
|
|
478
|
-
calls that reverts as a whole. Pass one entry per collateral index; duplicates throw
|
|
479
|
-
`DuplicateMidnightCollateralIndexError`, unlike the bundle flows, which sum them.
|
|
480
|
-
|
|
481
|
-
A supply batch returns one unlimited Midnight approval per collateral token whose allowance is
|
|
482
|
-
below that token's total:
|
|
483
|
-
|
|
484
|
-
```typescript
|
|
485
|
-
const supply = midnight.supplyCollateralBatch({
|
|
486
|
-
accountAddress: user,
|
|
487
|
-
marketData,
|
|
488
|
-
collateralSupplies: [
|
|
489
|
-
{ collateralIndex: 0n, assets: 1_000_000n },
|
|
490
|
-
{ collateralIndex: 1n, assets: 2_000_000_000_000_000_000n },
|
|
491
|
-
],
|
|
492
|
-
});
|
|
493
|
-
|
|
494
|
-
for (const approval of await supply.getRequirements()) {
|
|
495
|
-
const hash = await walletClient.sendTransaction({ ...approval, account: user });
|
|
496
|
-
await client.waitForTransactionReceipt({ hash });
|
|
497
|
-
}
|
|
498
|
-
await walletClient.sendTransaction({ ...supply.buildTx(), account: user });
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
A withdraw batch checks every entry against `positionData` and, when the position has debt, checks
|
|
502
|
-
the remaining collateral against the LLTV buffer using `collateralPrices`. `maxUint256` withdraws
|
|
503
|
-
that index's whole balance. It needs no requirements:
|
|
504
|
-
|
|
505
|
-
```typescript
|
|
506
|
-
import { blueOracleAbi } from "@morpho-org/morpho-sdk/abis";
|
|
507
|
-
import { maxUint256 } from "viem";
|
|
508
|
-
|
|
509
|
-
const positionData = await midnight.getPositionData({ marketId, accountAddress: user });
|
|
510
|
-
const collateralPrices = await Promise.all(
|
|
511
|
-
marketData.params.collateralParams.map(({ oracle }) =>
|
|
512
|
-
client.readContract({ address: oracle, abi: blueOracleAbi, functionName: "price" }),
|
|
513
|
-
),
|
|
514
|
-
);
|
|
515
|
-
|
|
516
|
-
const withdrawal = midnight.withdrawCollateralBatch({
|
|
517
|
-
accountAddress: user,
|
|
518
|
-
marketData,
|
|
519
|
-
positionData,
|
|
520
|
-
collateralPrices,
|
|
521
|
-
collateralWithdrawals: [
|
|
522
|
-
{ collateralIndex: 0n, assets: 500_000n },
|
|
523
|
-
{ collateralIndex: 1n, assets: maxUint256 },
|
|
524
|
-
],
|
|
525
|
-
receiver: user,
|
|
526
|
-
});
|
|
527
|
-
await walletClient.sendTransaction({ ...withdrawal.buildTx(), account: user });
|
|
528
|
-
```
|
|
529
|
-
|
|
530
514
|
See the [documentation](https://docs.morpho.org/developers/sdks/morpho-sdk/) for the full API:
|
|
531
515
|
native wrapping, Vault V2 BluePublicAllocator reallocations, borrow-position migration, vault V1 →
|
|
532
516
|
V2 migration, force withdraw/redeem, and Midnight maker flows.
|
|
@@ -537,10 +521,10 @@ V2 migration, force withdraw/redeem, and Midnight maker flows.
|
|
|
537
521
|
graph LR
|
|
538
522
|
MC["client.morpho<br/>(morphoViemExtension)"]
|
|
539
523
|
|
|
540
|
-
MC -->|.vaultV1| MV1
|
|
541
|
-
MC -->|.vaultV2| MV2
|
|
542
|
-
MC -->|.blue| MM1
|
|
543
524
|
MC -->|.midnight| MN1
|
|
525
|
+
MC -->|.blue| MM1
|
|
526
|
+
MC -->|.vaultV2| MV2
|
|
527
|
+
MC -->|.vaultV1| MV1
|
|
544
528
|
|
|
545
529
|
subgraph VaultV1 Flow
|
|
546
530
|
MV1[MorphoVaultV1]
|
|
@@ -574,6 +558,22 @@ graph LR
|
|
|
574
558
|
V2FR -->|multicall| V2C[VaultV2 Contract]
|
|
575
559
|
end
|
|
576
560
|
|
|
561
|
+
subgraph Midnight Flow
|
|
562
|
+
MN1[MorphoMidnight]
|
|
563
|
+
MN1 --> MNT[fixed-rate taker actions]
|
|
564
|
+
MN1 --> MNM[maker offer submission]
|
|
565
|
+
MN1 --> MNR[repayWithdrawCollateral]
|
|
566
|
+
MN1 --> MNP[ERC-20 collateral supply / redeem]
|
|
567
|
+
MN1 --> MNS[native collateral supply]
|
|
568
|
+
MN1 --> MNCB[collateral batches]
|
|
569
|
+
MNT --> MNB2[MidnightBundlesV2]
|
|
570
|
+
MNM --> MNB2
|
|
571
|
+
MNR --> MNB2
|
|
572
|
+
MNS --> MNB2
|
|
573
|
+
MNP --> MNC[Midnight]
|
|
574
|
+
MNCB -->|multicall| MNC
|
|
575
|
+
end
|
|
576
|
+
|
|
577
577
|
subgraph Blue Flow
|
|
578
578
|
MM1[MorphoBlue]
|
|
579
579
|
MM1 --> M1S[supply]
|
|
@@ -585,6 +585,7 @@ graph LR
|
|
|
585
585
|
MM1 --> M1RW[repayWithdrawCollateral]
|
|
586
586
|
MM1 --> M1W[withdraw]
|
|
587
587
|
MM1 --> M1M[refinance]
|
|
588
|
+
MM1 --> M1WBC[withdrawBuyCallback]
|
|
588
589
|
|
|
589
590
|
M1S --> BBV1[BlueBundlesV1]
|
|
590
591
|
M1SC --> BBV1
|
|
@@ -596,25 +597,10 @@ graph LR
|
|
|
596
597
|
M1W --> BBV1
|
|
597
598
|
M1M --> BBV1
|
|
598
599
|
|
|
600
|
+
M1WBC -->|direct call| MB[Morpho Blue]
|
|
599
601
|
BBV1 -.->|reallocate / allocateFromIdle| BPA[Blue Public Allocator]
|
|
600
602
|
end
|
|
601
603
|
|
|
602
|
-
subgraph Midnight Flow
|
|
603
|
-
MN1[MorphoMidnight]
|
|
604
|
-
MN1 --> MNT[fixed-rate taker actions]
|
|
605
|
-
MN1 --> MNM[maker offer submission]
|
|
606
|
-
MN1 --> MNR[repayWithdrawCollateral]
|
|
607
|
-
MN1 --> MNP[ERC-20 collateral supply / redeem]
|
|
608
|
-
MN1 --> MNS[native collateral supply]
|
|
609
|
-
MN1 --> MNCB[collateral batches]
|
|
610
|
-
MNT --> MNB2[MidnightBundlesV2]
|
|
611
|
-
MNM --> MNB2
|
|
612
|
-
MNR --> MNB2
|
|
613
|
-
MNS --> MNB2
|
|
614
|
-
MNP --> MNC[Midnight]
|
|
615
|
-
MNCB -->|multicall| MNC
|
|
616
|
-
end
|
|
617
|
-
|
|
618
604
|
|
|
619
605
|
subgraph Shared
|
|
620
606
|
REQ[getRequirements]
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
+
/** Numeric permit kinds consumed by `TokenLib.pullToken`. */
|
|
2
|
+
export declare const BundlesPermitKind: {
|
|
3
|
+
readonly None: 0;
|
|
4
|
+
readonly ERC2612: 1;
|
|
5
|
+
readonly Permit2: 2;
|
|
6
|
+
};
|
|
7
|
+
/** A numeric permit kind consumed by `TokenLib.pullToken`. */
|
|
8
|
+
export type BundlesPermitKind = (typeof BundlesPermitKind)[keyof typeof BundlesPermitKind];
|
|
9
|
+
/** ABI parameters for nonempty `TokenLib` token permit payloads. */
|
|
10
|
+
export declare const bundlesPermitParameters: {
|
|
11
|
+
readonly 1: readonly [{
|
|
12
|
+
readonly type: "uint256";
|
|
13
|
+
readonly name: "deadline";
|
|
14
|
+
}, {
|
|
15
|
+
readonly type: "uint8";
|
|
16
|
+
readonly name: "v";
|
|
17
|
+
}, {
|
|
18
|
+
readonly type: "bytes32";
|
|
19
|
+
readonly name: "r";
|
|
20
|
+
}, {
|
|
21
|
+
readonly type: "bytes32";
|
|
22
|
+
readonly name: "s";
|
|
23
|
+
}];
|
|
24
|
+
readonly 2: readonly [{
|
|
25
|
+
readonly type: "uint256";
|
|
26
|
+
readonly name: "nonce";
|
|
27
|
+
}, {
|
|
28
|
+
readonly type: "uint256";
|
|
29
|
+
readonly name: "deadline";
|
|
30
|
+
}, {
|
|
31
|
+
readonly type: "bytes";
|
|
32
|
+
readonly name: "signature";
|
|
33
|
+
}];
|
|
34
|
+
};
|
|
1
35
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
36
|
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc3643Abi, erc3643IdentityRegistryAbi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
3
37
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
package/lib/cjs/abis.js
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
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.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = exports.erc3643IdentityRegistryAbi = exports.erc3643Abi = exports.erc2612Abi = exports.blueOracleAbi = exports.blueAbi = exports.blueAdaptiveCurveIrmAbi = exports.blueMarketParamsAbi = void 0;
|
|
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 = exports.bundlesPermitParameters = exports.BundlesPermitKind = void 0;
|
|
4
|
+
/** Numeric permit kinds consumed by `TokenLib.pullToken`. */
|
|
5
|
+
exports.BundlesPermitKind = {
|
|
6
|
+
None: 0,
|
|
7
|
+
ERC2612: 1,
|
|
8
|
+
Permit2: 2,
|
|
9
|
+
};
|
|
10
|
+
/** ABI parameters for nonempty `TokenLib` token permit payloads. */
|
|
11
|
+
exports.bundlesPermitParameters = {
|
|
12
|
+
[exports.BundlesPermitKind.ERC2612]: [
|
|
13
|
+
{ type: "uint256", name: "deadline" },
|
|
14
|
+
{ type: "uint8", name: "v" },
|
|
15
|
+
{ type: "bytes32", name: "r" },
|
|
16
|
+
{ type: "bytes32", name: "s" },
|
|
17
|
+
],
|
|
18
|
+
[exports.BundlesPermitKind.Permit2]: [
|
|
19
|
+
{ type: "uint256", name: "nonce" },
|
|
20
|
+
{ type: "uint256", name: "deadline" },
|
|
21
|
+
{ type: "bytes", name: "signature" },
|
|
22
|
+
],
|
|
23
|
+
};
|
|
4
24
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
25
|
Object.defineProperty(exports, "blueMarketParamsAbi", { enumerable: true, get: function () { return blue_sdk_1.marketParamsAbi; } });
|
|
6
26
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
@@ -18,9 +18,11 @@ export interface BlueBorrowParams {
|
|
|
18
18
|
readonly maxLtv: bigint;
|
|
19
19
|
/** Optional validated Vault V2 BluePublicAllocator reallocations. */
|
|
20
20
|
readonly reallocations?: Iterable<VaultV2BlueReallocation>;
|
|
21
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
22
|
+
readonly maxPenalty?: bigint;
|
|
21
23
|
/** Final call deadline in Unix seconds. */
|
|
22
24
|
readonly deadline: bigint;
|
|
23
|
-
/** Optional WAD-scaled referral fee,
|
|
25
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
24
26
|
readonly referralFeePct?: bigint;
|
|
25
27
|
/** Recipient required when `referralFeePct` is positive. */
|
|
26
28
|
readonly referralFeeRecipient?: Address;
|
|
@@ -43,8 +45,9 @@ export interface BlueBorrowParams {
|
|
|
43
45
|
* @param params.args.borrowAssets - Gross loan assets borrowed.
|
|
44
46
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
45
47
|
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
48
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
46
49
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
47
|
-
* @param params.args.referralFeePct - Optional WAD-scaled referral fee
|
|
50
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee, at most 10%.
|
|
48
51
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
49
52
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
50
53
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -52,10 +55,15 @@ export interface BlueBorrowParams {
|
|
|
52
55
|
* combined BlueBundlesV1 entrypoint with a zero collateral leg.
|
|
53
56
|
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
54
57
|
* `id` that does not hash from its tuple fields.
|
|
58
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
55
59
|
* @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
|
|
60
|
+
* Also thrown when maxPenalty is negative.
|
|
56
61
|
* @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
|
|
57
|
-
* @throws {InputExceedsMaxError} when a
|
|
62
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its bound.
|
|
63
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
58
64
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
65
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
66
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
59
67
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
60
68
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
61
69
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -14,6 +14,7 @@ const parseBlueBorrow = (params) => ({
|
|
|
14
14
|
borrowAssets: params.args.borrowAssets,
|
|
15
15
|
maxLtv: params.args.maxLtv,
|
|
16
16
|
reallocations: params.args.reallocations,
|
|
17
|
+
maxPenalty: params.args.maxPenalty,
|
|
17
18
|
deadline: params.args.deadline,
|
|
18
19
|
referralFeePct: params.args.referralFeePct,
|
|
19
20
|
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
@@ -15,8 +15,9 @@ const borrow_internal_js_1 = require("./borrow.internal.js");
|
|
|
15
15
|
* @param params.args.borrowAssets - Gross loan assets borrowed.
|
|
16
16
|
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
17
17
|
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
18
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound total proceeds lost.
|
|
18
19
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
19
|
-
* @param params.args.referralFeePct - Optional WAD-scaled referral fee
|
|
20
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee, at most 10%.
|
|
20
21
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
21
22
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
22
23
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -24,10 +25,15 @@ const borrow_internal_js_1 = require("./borrow.internal.js");
|
|
|
24
25
|
* combined BlueBundlesV1 entrypoint with a zero collateral leg.
|
|
25
26
|
* @throws {MarketIdMismatchError} when the target market or a reallocation source market has an
|
|
26
27
|
* `id` that does not hash from its tuple fields.
|
|
28
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
27
29
|
* @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
|
|
30
|
+
* Also thrown when maxPenalty is negative.
|
|
28
31
|
* @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
|
|
29
|
-
* @throws {InputExceedsMaxError} when a
|
|
32
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its bound.
|
|
33
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
30
34
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
35
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
36
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
31
37
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
32
38
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
33
39
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -70,7 +70,10 @@ export declare const getBlueBundlesV1SignedAuthorization: (params: {
|
|
|
70
70
|
authorizationSignature?: AuthorizationRequirementSignature;
|
|
71
71
|
}) => BlueBundlesV1SignedAuthorization;
|
|
72
72
|
/** Parses an ordered reallocation plan and its aggregate penalty once. @internal */
|
|
73
|
-
export declare const parseBlueAllocations: (reallocations: readonly VaultV2BlueReallocation[],
|
|
73
|
+
export declare const parseBlueAllocations: (reallocations: readonly VaultV2BlueReallocation[], { marketParams: targetMarketParams, maxPenalty, }: {
|
|
74
|
+
readonly marketParams: BlueMarket;
|
|
75
|
+
readonly maxPenalty?: bigint;
|
|
76
|
+
}) => {
|
|
74
77
|
readonly publicAllocations: readonly {
|
|
75
78
|
readonly vault: Address;
|
|
76
79
|
readonly adapter: Address;
|
|
@@ -92,13 +92,27 @@ const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
92
92
|
};
|
|
93
93
|
exports.getBlueBundlesV1SignedAuthorization = getBlueBundlesV1SignedAuthorization;
|
|
94
94
|
/** Parses an ordered reallocation plan and its aggregate penalty once. @internal */
|
|
95
|
-
const parseBlueAllocations = (reallocations, targetMarketParams) => {
|
|
95
|
+
const parseBlueAllocations = (reallocations, { marketParams: targetMarketParams, maxPenalty, }) => {
|
|
96
|
+
// Snapshot each Vault V2 entry so validation, accounting and encoding read the same values.
|
|
97
|
+
const snapshots = reallocations.map((reallocation) => {
|
|
98
|
+
if (reallocation === null ||
|
|
99
|
+
typeof reallocation !== "object" ||
|
|
100
|
+
"withdrawals" in reallocation ||
|
|
101
|
+
"fee" in reallocation) {
|
|
102
|
+
return reallocation;
|
|
103
|
+
}
|
|
104
|
+
const { vault, from, to, assets, penalty } = reallocation;
|
|
105
|
+
return { vault, from, to, assets, penalty };
|
|
106
|
+
});
|
|
96
107
|
// Reject malformed plans before constructing allocation calls.
|
|
97
|
-
(0, validate_js_1.validateVaultV2BlueReallocations)(
|
|
108
|
+
(0, validate_js_1.validateVaultV2BlueReallocations)(snapshots, {
|
|
109
|
+
targetMarketId: targetMarketParams.id,
|
|
110
|
+
maxPenalty,
|
|
111
|
+
});
|
|
98
112
|
// Hoisted out of the map: idle sources all reference the same synthetic idle market, whose
|
|
99
113
|
// construction eagerly hashes the market id — computing it once per call instead of per entry.
|
|
100
114
|
const idleMarketParams = (0, parse_js_1.parseBlueMarket)(blue_sdk_1.MarketParams.idle(targetMarketParams.loanToken));
|
|
101
|
-
const publicAllocations =
|
|
115
|
+
const publicAllocations = snapshots.map((reallocation) => {
|
|
102
116
|
if (reallocation.from.type === "market" &&
|
|
103
117
|
!(0, viem_1.isAddressEqual)(reallocation.from.marketParams.loanToken, targetMarketParams.loanToken)) {
|
|
104
118
|
throw new index_js_2.ReallocationLoanTokenMismatchError(targetMarketParams.loanToken, reallocation.from.marketParams.loanToken);
|
|
@@ -21,9 +21,11 @@ export interface BlueRefinanceParams {
|
|
|
21
21
|
readonly maxLtv: bigint;
|
|
22
22
|
/** Optional Vault V2 reallocations into the destination market. */
|
|
23
23
|
readonly reallocations?: Iterable<VaultV2BlueReallocation>;
|
|
24
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound the total penalty added to destination debt. */
|
|
25
|
+
readonly maxPenalty?: bigint;
|
|
24
26
|
/** Final call deadline in Unix seconds. */
|
|
25
27
|
readonly deadline: bigint;
|
|
26
|
-
/** Optional WAD-scaled referral fee,
|
|
28
|
+
/** Optional WAD-scaled referral fee, at most 10%. */
|
|
27
29
|
readonly referralFeePct?: bigint;
|
|
28
30
|
/** Recipient required when `referralFeePct` is positive. */
|
|
29
31
|
readonly referralFeeRecipient?: Address;
|
|
@@ -49,8 +51,9 @@ export interface BlueRefinanceParams {
|
|
|
49
51
|
* BlueBundlesV1 always migrates `msg.sender`.
|
|
50
52
|
* @param params.args.maxLtv - Maximum destination LTV.
|
|
51
53
|
* @param params.args.reallocations - Vault V2 reallocations into the destination.
|
|
54
|
+
* @param params.args.maxPenalty - Maximum WAD-scaled penalty rate per reallocation in [0, WAD], defaulting to zero. Each rate applies to that reallocation's assets, so it does not bound the total penalty added to destination debt.
|
|
52
55
|
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
53
|
-
* @param params.args.referralFeePct - Optional WAD-scaled fee
|
|
56
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee at most 10%.
|
|
54
57
|
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
55
58
|
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
56
59
|
* @param params.metadata - Optional transaction metadata.
|
|
@@ -59,11 +62,16 @@ export interface BlueRefinanceParams {
|
|
|
59
62
|
* @throws {MarketIdMismatchError} when the migration source, destination, or a reallocation
|
|
60
63
|
* source market has an `id` that does not hash from its tuple fields.
|
|
61
64
|
* @throws {RefinanceSameMarketError} when source and destination IDs match.
|
|
65
|
+
* @throws {InvalidBigIntInputError} when a supplied maxPenalty is not a bigint.
|
|
62
66
|
* @throws {RefinanceTokenMismatchError} when their loan or collateral tokens differ.
|
|
63
67
|
* @throws {NegativeInputError} when `maxLtv`, a referral fee, or a reallocation penalty is negative.
|
|
68
|
+
* Also thrown when maxPenalty is negative.
|
|
64
69
|
* @throws {NonPositiveInputError} when the deadline or a reallocation amount is not positive.
|
|
65
|
-
* @throws {InputExceedsMaxError} when a
|
|
70
|
+
* @throws {InputExceedsMaxError} when a reallocation amount or penalty exceeds its ABI bound.
|
|
71
|
+
* Also thrown when maxPenalty exceeds WAD or a penalty exceeds maxPenalty (zero by default).
|
|
66
72
|
* @throws {ReferralFeeRecipientMissingError} when a positive fee has no recipient.
|
|
73
|
+
* @throws {ReferralFeePctExceededError} when the referral fee is at least WAD.
|
|
74
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
67
75
|
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
68
76
|
* @throws {InvalidVaultV2BlueReallocationShapeError} when a reallocation entry is not a valid Vault V2 reallocation.
|
|
69
77
|
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
@@ -33,7 +33,10 @@ const parseBlueRefinance = (params) => {
|
|
|
33
33
|
...common,
|
|
34
34
|
authorizationSignature: params.args.authorizationSignature,
|
|
35
35
|
});
|
|
36
|
-
const allocations = (0, common_js_1.parseBlueAllocations)([...(params.args.reallocations ?? [])],
|
|
36
|
+
const allocations = (0, common_js_1.parseBlueAllocations)([...(params.args.reallocations ?? [])], {
|
|
37
|
+
marketParams: markets.destinationMarketParams,
|
|
38
|
+
maxPenalty: params.args.maxPenalty,
|
|
39
|
+
});
|
|
37
40
|
const fields = {
|
|
38
41
|
...parsedMarkets,
|
|
39
42
|
...normalized,
|