@morpho-org/morpho-sdk 6.6.0 → 7.1.0-next.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/MIGRATION-v6-to-v7.md +297 -0
- package/README.md +26 -12
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +7 -2
- package/lib/cjs/actions/bundles/common.d.ts +9 -5
- package/lib/cjs/actions/bundles/common.js +22 -13
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
- package/lib/cjs/actions/midnight/authorization.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
- package/lib/cjs/actions/midnight/index.d.ts +3 -3
- package/lib/cjs/actions/midnight/index.js +3 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
- package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
- package/lib/cjs/actions/midnight/takeLend.js +111 -54
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
- package/lib/cjs/actions/midnight/types.d.ts +7 -26
- package/lib/cjs/actions/midnight/types.js +0 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/midnight/index.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/entities/index.d.ts +6 -6
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +585 -108
- package/lib/cjs/entities/midnight/midnight.js +984 -509
- package/lib/cjs/entities/midnight/types.d.ts +142 -60
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +32 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/cjs/entities/vaultV2/vaultV2.js +68 -41
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +10 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/callback.d.ts +54 -0
- package/lib/cjs/helpers/callback.js +73 -0
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +6 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/cjs/helpers/validate.d.ts +43 -2
- package/lib/cjs/helpers/validate.js +60 -3
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -2
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/types/action.d.ts +219 -90
- package/lib/cjs/types/action.js +103 -20
- package/lib/cjs/types/error.d.ts +126 -40
- package/lib/cjs/types/error.js +154 -49
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +9 -5
- package/lib/esm/actions/bundles/common.js +22 -13
- package/lib/esm/actions/midnight/authorization.d.ts +3 -2
- package/lib/esm/actions/midnight/authorization.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
- package/lib/esm/actions/midnight/index.d.ts +3 -3
- package/lib/esm/actions/midnight/index.js +3 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
- package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/esm/actions/midnight/takeBorrow.js +98 -57
- package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
- package/lib/esm/actions/midnight/takeLend.js +114 -57
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
- package/lib/esm/actions/midnight/types.d.ts +7 -26
- package/lib/esm/actions/midnight/types.js +1 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/esm/actions/requirements/midnight/index.js +0 -1
- 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/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/index.d.ts +6 -6
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +585 -108
- package/lib/esm/entities/midnight/midnight.js +990 -515
- package/lib/esm/entities/midnight/types.d.ts +142 -60
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +33 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/esm/entities/vaultV2/vaultV2.js +69 -42
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/callback.d.ts +54 -0
- package/lib/esm/helpers/callback.js +68 -0
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/esm/helpers/validate.d.ts +43 -2
- package/lib/esm/helpers/validate.js +58 -2
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/esm/helpers/validateRequirementSpender.js +4 -5
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/types/action.d.ts +219 -90
- package/lib/esm/types/action.js +103 -19
- package/lib/esm/types/error.d.ts +126 -40
- package/lib/esm/types/error.js +135 -38
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +10 -10
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
- package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/esm/actions/midnight/cancelOffer.js +0 -69
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Migrating `@morpho-org/morpho-sdk` from v6 to v7
|
|
2
|
+
|
|
3
|
+
Version 7 publishes Midnight maker offers through MidnightBundlesV2 in one transaction. The v6
|
|
4
|
+
flow sent a separate root-ratification transaction or root signature, then posted the offers to
|
|
5
|
+
MidnightMempool. v7 removes that route instead of keeping it selectable; stay on v6 if you
|
|
6
|
+
still need it.
|
|
7
|
+
|
|
8
|
+
## Maker methods
|
|
9
|
+
|
|
10
|
+
| v6 | v7 |
|
|
11
|
+
| --- | --- |
|
|
12
|
+
| `makeLend` | `makeLend` (retyped) |
|
|
13
|
+
| `makeBorrow` | `makeBorrow` (retyped) |
|
|
14
|
+
| `supplyCollateralMakeBorrow` | `supplyCollateralMakeBorrow` (retyped) |
|
|
15
|
+
|
|
16
|
+
Each MidnightBundlesV2 call cancels the groups you are replacing, authorizes the ratifier, activates
|
|
17
|
+
the new root, and publishes the payload. `supplyCollateralMakeBorrow` also supplies borrow
|
|
18
|
+
collateral in that call; `makeBorrow` does not. If any cancelled group was filled beyond its
|
|
19
|
+
`maxConsumed` before the transaction lands, the whole call reverts and nothing is published.
|
|
20
|
+
|
|
21
|
+
`makeBorrow` still takes `MidnightMakeOffersParams`, which now requires `deadline` and accepts
|
|
22
|
+
optional `cancellations` (see below), and does not accept collateral. Use
|
|
23
|
+
`supplyCollateralMakeBorrow` to supply collateral; it requires a non-empty
|
|
24
|
+
`supplies` list and throws `EmptyMidnightCollateralSuppliesError` for an empty list. Both methods
|
|
25
|
+
build the `midnightCancelAndMake` action directly.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// v6
|
|
29
|
+
const output = await midnight.makeLend({ accountAddress, offers, loanToken, loanAssets });
|
|
30
|
+
const tx = output.buildTx(await signRequirements(await output.getRequirements()));
|
|
31
|
+
|
|
32
|
+
// v7: repost over previousGroup; pass `cancellations: []` for a fresh publication
|
|
33
|
+
const output = await midnight.makeLend({
|
|
34
|
+
accountAddress,
|
|
35
|
+
offers,
|
|
36
|
+
cancellations: [{ group: previousGroup, maxConsumed: 0n }],
|
|
37
|
+
deadline,
|
|
38
|
+
loanToken,
|
|
39
|
+
loanAssets,
|
|
40
|
+
});
|
|
41
|
+
const tx = output.buildTx();
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
// v6
|
|
46
|
+
await midnight.supplyCollateralMakeBorrow({ accountAddress, offers, market, collateralAssets });
|
|
47
|
+
|
|
48
|
+
// v7
|
|
49
|
+
await midnight.supplyCollateralMakeBorrow({
|
|
50
|
+
accountAddress,
|
|
51
|
+
offers,
|
|
52
|
+
collateral: { market, supplies: [{ collateralIndex: 0n, assets }] },
|
|
53
|
+
deadline,
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The method returns `MidnightMakeOffersOutput`, whose transaction action is
|
|
58
|
+
`midnightCancelAndMake`. Its required `collateral: { market, supplies }` replaces the v6
|
|
59
|
+
`market`, `collateralAssets`, and `collateralIndex` inputs; `reservedCollateralAssets` is removed.
|
|
60
|
+
An empty `supplies` list throws `EmptyMidnightCollateralSuppliesError`.
|
|
61
|
+
|
|
62
|
+
## Taker methods
|
|
63
|
+
|
|
64
|
+
`takeLend`, `takeBorrow` and `supplyCollateralTakeBorrow` now call MidnightBundlesV2. Each takes a
|
|
65
|
+
`target` that picks the amount the trade is sized by, and acts for the sender: there is no `taker`
|
|
66
|
+
input, and `accountAddress` must send the transaction.
|
|
67
|
+
|
|
68
|
+
| v6 input | v7 input |
|
|
69
|
+
| --- | --- |
|
|
70
|
+
| `takeLend` `assets`, `minUnits` | `target: { type: "assets", assets, minUnits }` or `{ type: "units", units, maxBuyerAssets }` |
|
|
71
|
+
| `takeBorrow` `loanAssets`, `maxUnits` | `target: { type: "assets", assets, maxUnits }` or `{ type: "units", units, minSellerAssets }` |
|
|
72
|
+
| `supplyCollateralTakeBorrow` `collateralAssets`, `collateralIndex` | `collateralSupplies: [{ collateralIndex, assets }]` (non-empty) |
|
|
73
|
+
| — | `takeLend` `maxContinuousFee` (required; `maxUint256` for no cap) |
|
|
74
|
+
| — | optional `referralFeePct`, `referralFeeRecipient` |
|
|
75
|
+
| — | `takeBorrow` and `supplyCollateralTakeBorrow` optional `receiver` (defaults to `accountAddress`) |
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
// v6
|
|
79
|
+
midnight.takeLend({ accountAddress, marketData, assets, minUnits, takeableOffers, deadline });
|
|
80
|
+
|
|
81
|
+
// v7
|
|
82
|
+
midnight.takeLend({
|
|
83
|
+
accountAddress,
|
|
84
|
+
marketData,
|
|
85
|
+
target: { type: "assets", assets, minUnits },
|
|
86
|
+
takeableOffers,
|
|
87
|
+
maxContinuousFee: maxUint256,
|
|
88
|
+
deadline,
|
|
89
|
+
});
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- Low-level builders: `midnightTakeBorrow` and `midnightSupplyCollateralTakeBorrow` replace `taker`
|
|
93
|
+
with a required `receiver`; `midnightTakeLend` drops `taker` with no replacement.
|
|
94
|
+
- Deadlines on `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `takeWithdraw` and
|
|
95
|
+
`takeRepayWithdrawCollateral` must be greater than now and no more than
|
|
96
|
+
`MIDNIGHT_TAKE_MAX_DEADLINE_SECONDS` (one hour) from now. Builders reject `maxUint256` deadlines
|
|
97
|
+
with `UnboundedMidnightTakeInputError` and `0n` with `NonPositiveInputError`; entity methods
|
|
98
|
+
reject expired deadlines with `ExpiredDeadlineError` and deadlines beyond the window with
|
|
99
|
+
`MidnightTakeDeadlineTooFarError`.
|
|
100
|
+
- Target amounts and bounds must be positive. `takeWithdraw` requires a positive `minSellerAssets`
|
|
101
|
+
on units targets and rejects `maxUint256` for `target.units` or `target.maxUnits`.
|
|
102
|
+
`takeRepayWithdrawCollateral` requires positive `minUnits` on assets targets. Its units target
|
|
103
|
+
still allows `units: maxUint256` to repay the whole debt, bounded by finite, positive
|
|
104
|
+
`maxBuyerAssets`; it rejects `maxUint256` for `maxBuyerAssets`. `takeLend`, `takeBorrow`, and
|
|
105
|
+
`supplyCollateralTakeBorrow` reject unbounded target fields with
|
|
106
|
+
`UnboundedMidnightTakeInputError`; `receiver` cannot be the zero address or throws
|
|
107
|
+
`MidnightZeroReceiverError`.
|
|
108
|
+
- Maker `continuousFeeCap` must be `0n` or throws `MidnightOfferContinuousFeeCapError`. A sell
|
|
109
|
+
offer's `receiverIfMakerIsSeller` must equal its maker or throws
|
|
110
|
+
`MidnightOfferSellerReceiverMismatchError`.
|
|
111
|
+
- Requirements approve the loan token (`takeLend`: `assets` or `maxBuyerAssets`) or each collateral
|
|
112
|
+
token (summed per token) to MidnightBundlesV2, and authorize MidnightBundlesV2 on Midnight.
|
|
113
|
+
Approvals are now unlimited: `getRequirements()`/`getMidnightApprovalRequirements` return a
|
|
114
|
+
`maxUint256` approval (capped per token by `MAX_TOKEN_APPROVALS`) instead of the exact pulled
|
|
115
|
+
amount, still only when the allowance is below the pulled amount. Callers can pass
|
|
116
|
+
`getRequirements({ approvalAmount })` (or `approvalAmount` on
|
|
117
|
+
`getMidnightApprovalRequirements`) to set a different allowance.
|
|
118
|
+
- `takeBorrow` and `supplyCollateralTakeBorrow` withdraw the sender's existing credit before
|
|
119
|
+
taking offers, so a lender who borrows nets the credit first.
|
|
120
|
+
- Action metadata exposes `target` instead of `assets`/`minUnits` or `loanAssets`/`maxUnits`, and
|
|
121
|
+
drops `taker`. `MidnightSupplyCollateralTakeBorrowAction.collateralSupplies` is the supply list
|
|
122
|
+
instead of a count, and `MidnightTakeBorrowAction.args` no longer has `collateralSupplies`.
|
|
123
|
+
- New types: `MidnightBuyTarget`, `MidnightSellTarget`, `MidnightReferralFeeParams`.
|
|
124
|
+
`MidnightCollateralSupply` is removed; use `MidnightCollateralTransfer`.
|
|
125
|
+
- New `takeRepayWithdrawCollateral` (and the `midnightTakeRepayWithdrawCollateral` builder) repays
|
|
126
|
+
debt by taking borrow-side offers with `reduceOnly` set, repays the rest directly when
|
|
127
|
+
`repayEnabled` is true, then withdraws `collateralWithdrawals` to `collateralReceiver`
|
|
128
|
+
(default `accountAddress`). It takes a `MidnightBuyTarget` and needs the same approval and
|
|
129
|
+
authorization as `takeLend`.
|
|
130
|
+
- New `takeWithdraw` (and the `midnightTakeWithdraw` builder) withdraws the sender's credit: it
|
|
131
|
+
redeems what market liquidity allows, then sells the rest of a `MidnightSellTarget` to lend-side
|
|
132
|
+
offers with `reduceOnly` set, so it never opens debt. It needs only MidnightBundlesV2
|
|
133
|
+
authorization. `redeem` stays the direct, offer-free path.
|
|
134
|
+
|
|
135
|
+
## Removed MidnightBundles (V1) support
|
|
136
|
+
|
|
137
|
+
v7 no longer routes anything through the V1 `midnightBundles` contract:
|
|
138
|
+
|
|
139
|
+
- `midnightBundlesAbi` is no longer re-exported from `@morpho-org/morpho-sdk` or
|
|
140
|
+
`@morpho-org/morpho-sdk/midnight`, and `midnight-sdk` 2.0.0 removes it too. Integrations that
|
|
141
|
+
still call V1 stay on `morpho-sdk` 6.x with `midnight-sdk` 1.x and `morpho-ts` 3.x.
|
|
142
|
+
- `RequirementSpenderKey` drops `"midnightBundles"`. `encodeErc20Approval` and
|
|
143
|
+
`getMidnightApprovalRequirements` reject a `midnightBundles` spender, and `encodeErc20Permit` no
|
|
144
|
+
longer signs permits for it (V2 takes no inline permits).
|
|
145
|
+
- `midnightSetIsAuthorized` and `getMidnightAuthorizationRequirement` accept only
|
|
146
|
+
`midnightBundlesV2` as the operator to grant. Revocations through `midnightSetIsAuthorized`
|
|
147
|
+
(`isAuthorized: false`) still accept any operator.
|
|
148
|
+
- `UnsupportedErc20ApprovalSpenderError` no longer takes a `midnightBundles` constructor field.
|
|
149
|
+
- `PermitKind` and `MidnightTokenPermit` are removed with no replacement: V2 takes no inline token
|
|
150
|
+
permits.
|
|
151
|
+
|
|
152
|
+
## repayWithdrawCollateral
|
|
153
|
+
|
|
154
|
+
`repayWithdrawCollateral` now calls MidnightBundlesV2 for the sender (no `onBehalf`). It repays
|
|
155
|
+
debt directly, without taking offers, and can withdraw several collaterals in the same call.
|
|
156
|
+
|
|
157
|
+
| v6 input | v7 input |
|
|
158
|
+
| --- | --- |
|
|
159
|
+
| `repayAssets` | `repay: { type: "assets", assets }` (repays exactly `assets`; `0n` for withdraw-only) or `repay: { type: "full", maxBuyerAssets }` (repays the whole debt at execution time, pulling the finite `maxBuyerAssets` upfront and refunding the rest, so the sender must hold the full cap; reverts with `Panic(0x11)` if the debt at execution exceeds it) |
|
|
160
|
+
| `withdrawCollateralAssets`, `collateralIndex` | `collateralWithdrawals: [{ collateralIndex, assets }]` (`assets: maxUint256` withdraws the whole balance) |
|
|
161
|
+
| — | optional `collateralReceiver` (defaults to `accountAddress`) |
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
// v6
|
|
165
|
+
midnight.repayWithdrawCollateral({ accountAddress, marketData, repayAssets, withdrawCollateralAssets, deadline });
|
|
166
|
+
|
|
167
|
+
// v7: close the position
|
|
168
|
+
midnight.repayWithdrawCollateral({
|
|
169
|
+
accountAddress,
|
|
170
|
+
marketData,
|
|
171
|
+
repay: { type: "full", maxBuyerAssets },
|
|
172
|
+
collateralWithdrawals: [{ collateralIndex: 0n, assets: maxUint256 }],
|
|
173
|
+
deadline,
|
|
174
|
+
});
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
- Requirements approve the loan token to MidnightBundlesV2 when the allowance is below the pulled
|
|
178
|
+
assets (`assets`, or `maxBuyerAssets` on a full repay; skipped when `0n`) and authorize
|
|
179
|
+
MidnightBundlesV2 on Midnight. Unused assets
|
|
180
|
+
are refunded. A full repay rejects `maxBuyerAssets` of `0n` or `maxUint256`, and an `assets` repay
|
|
181
|
+
rejects `assets: maxUint256` (use `{ type: "full" }` to repay the whole debt).
|
|
182
|
+
- `deadline` must be positive: `0n` now throws `NonPositiveInputError` (v6 only rejected negative
|
|
183
|
+
values). Pass `maxUint256` for no expiry.
|
|
184
|
+
- `MidnightRepayWithdrawCollateralAction.args` exposes `repay` and the `collateralWithdrawals`
|
|
185
|
+
list, and drops `repayAssets` and `onBehalf`.
|
|
186
|
+
- The `midnightRepayWithdrawCollateral` builder takes the same `repay` and `collateralWithdrawals`
|
|
187
|
+
plus a required `collateralReceiver`; it drops `repayAssets`, `withdrawCollateralAssets`,
|
|
188
|
+
`collateralIndex` and `onBehalf`. Like the other V2 builders, it throws `UnknownAddressError`
|
|
189
|
+
on chains without a `midnightBundlesV2` deployment.
|
|
190
|
+
|
|
191
|
+
## Ratifiers
|
|
192
|
+
|
|
193
|
+
Offers must use PriceRatifierV1 or RateRatifierV1. Pass a `Tree<"priceV1">`, a `Tree<"rateV1">`,
|
|
194
|
+
or the matching tree-create request; every offer's `ratifier` must be the tree's ratifier
|
|
195
|
+
(`MidnightOfferRatifierMismatchError`). Ecrecover and Setter trees are no longer accepted by
|
|
196
|
+
maker methods. `getOffersData` follows the same rule and now returns the V1 payload and ratifier
|
|
197
|
+
address.
|
|
198
|
+
|
|
199
|
+
## Ownership and requirements
|
|
200
|
+
|
|
201
|
+
- MidnightBundlesV2 acts on `msg.sender`. `accountAddress` must be the sender and the maker of every
|
|
202
|
+
offer; there is no `onBehalf`.
|
|
203
|
+
- `getRequirements()` returns only onchain transactions: the MidnightBundlesV2 Midnight
|
|
204
|
+
authorization, the lend-side loan-token approval to Midnight for later fills, and borrow-side
|
|
205
|
+
collateral approvals to MidnightBundlesV2 for `supplyCollateralMakeBorrow`. `makeBorrow`
|
|
206
|
+
requires only MidnightBundlesV2 authorization. It no longer returns a root signature or a
|
|
207
|
+
SetterRatifier root transaction, so `buildTx()` takes no signatures.
|
|
208
|
+
- Replacement offers need fresh groups. A group cannot be both published and cancelled
|
|
209
|
+
(`MidnightReplacementGroupCancelledError`).
|
|
210
|
+
- `makeLend`, `makeBorrow`, and `supplyCollateralMakeBorrow` reject `reduceOnly` offers with
|
|
211
|
+
`MidnightOfferReduceOnlyError`.
|
|
212
|
+
|
|
213
|
+
## Renamed and changed types
|
|
214
|
+
|
|
215
|
+
| v6 | v7 |
|
|
216
|
+
| --- | --- |
|
|
217
|
+
| `MidnightMakeOffersParams` | `MidnightMakeOffersParams` (retyped) |
|
|
218
|
+
| `MidnightMakeLendParams` | `MidnightMakeLendParams` (retyped) |
|
|
219
|
+
| `MidnightSupplyCollateralMakeBorrowParams` | `MidnightSupplyCollateralMakeBorrowParams` (required `collateral`) |
|
|
220
|
+
| `MidnightMakeOffersOutput` | `MidnightMakeOffersOutput` (retyped) |
|
|
221
|
+
| — | `MidnightMakeBorrowCollateral` |
|
|
222
|
+
| — | `MidnightOfferPublication`, `MidnightCancelAndMakeParams`, and `MidnightRootActivationSignature` |
|
|
223
|
+
|
|
224
|
+
- `MidnightMakeOffersParams`, and so `MidnightMakeLendParams` and
|
|
225
|
+
`MidnightSupplyCollateralMakeBorrowParams`, adds a required `deadline: bigint` bundle execution
|
|
226
|
+
deadline with no default; pass `maxUint256` for no expiry. It also adds optional
|
|
227
|
+
`cancellations: readonly MidnightGroupCancellation[]`; omit it or pass `[]` for a new publication.
|
|
228
|
+
- `MidnightMakeOffersParams` is used by `makeBorrow`, as in v6, and does not include collateral.
|
|
229
|
+
`MidnightSupplyCollateralMakeBorrowParams` extends it with required
|
|
230
|
+
`collateral: MidnightMakeBorrowCollateral`. Its nested supplies replace the v6 `market`,
|
|
231
|
+
`collateralAssets`, and `collateralIndex` inputs; `reservedCollateralAssets` is removed. The
|
|
232
|
+
collateral approval now goes to MidnightBundlesV2 instead of Midnight.
|
|
233
|
+
- `MidnightCancelAndMakeParams` takes ratifier, root, groups, payload, root signature, and optional
|
|
234
|
+
collateral together under `publication?: MidnightOfferPublication`. Omit `publication` for
|
|
235
|
+
cancel-only calls; this preserves `cancelOffers` behavior.
|
|
236
|
+
- `offers` accepts only `MidnightMakerTreeInput` (a PriceRatifierV1 or RateRatifierV1 tree or
|
|
237
|
+
`Tree.create` request) instead of any `TreeInput`.
|
|
238
|
+
- `MidnightOfferValidationParams` no longer accepts `ratification`; the ratifier comes from the tree.
|
|
239
|
+
- `MidnightOffersData.ratifierType` is `"priceV1" | "rateV1"` instead of `"ecrecover" | "setter"`.
|
|
240
|
+
- `MidnightOffersData.setterPayload` is replaced by `payload`, set for every tree.
|
|
241
|
+
|
|
242
|
+
## Removed exports
|
|
243
|
+
|
|
244
|
+
- Actions and requirements: `mempoolSubmitOffers` (`MempoolSubmitOffersParams`),
|
|
245
|
+
`setterRatifierRatifyRoot` (`SetterRatifierRatifyRootParams`),
|
|
246
|
+
`getSetterRatifierRatifyRootRequirement` (`GetSetterRatifierRatifyRootRequirementParams`).
|
|
247
|
+
- Types: `MempoolSubmitOffersAction`, `SetterRatifierRatifyRootAction`,
|
|
248
|
+
`MidnightOfferRootSignatureAction`, `MidnightOfferRootSignatureArgs`,
|
|
249
|
+
`MidnightOfferRootSignature`, `MidnightOfferRootRequirement`, `MidnightActionSignatures`.
|
|
250
|
+
- Helpers and errors: `isMidnightOfferRootSignature`, the `midnightOfferRoot` slot of
|
|
251
|
+
`selectRequirementSignatures`, `MissingMidnightOfferRootSignatureError`,
|
|
252
|
+
`MidnightOfferRootMismatchError`, `MidnightOfferRootOwnerMismatchError`,
|
|
253
|
+
`MidnightOfferRootRatifierMismatchError`, `MidnightOfferRootOfferCountMismatchError`,
|
|
254
|
+
`UnpreparedMidnightOfferRootSignatureError`, `UnknownMidnightRatifierError`.
|
|
255
|
+
|
|
256
|
+
- `getMidnightAuthorizationRequirement` and `midnightSetIsAuthorized` no longer accept the
|
|
257
|
+
Ecrecover or Setter ratifier as a target; MidnightBundlesV2 authorizes the V1 ratifier itself.
|
|
258
|
+
- `RequirementSignatureKind` no longer includes `"midnightOfferRootSignature"`.
|
|
259
|
+
|
|
260
|
+
There is no replacement for `UnknownMidnightRatifierError`: the `MidnightMakerTreeInput` type
|
|
261
|
+
makes it unreachable. The pure `midnightCancelAndMake` builder accepts only the chain's registered
|
|
262
|
+
`priceRatifierV1` or `rateRatifierV1` and throws `UnsupportedMidnightAuthorizationTargetError`
|
|
263
|
+
otherwise; entity methods derive the registered ratifier from the tree type.
|
|
264
|
+
|
|
265
|
+
The Ecrecover and Setter protocol utilities in `@morpho-org/midnight-sdk` are unchanged.
|
|
266
|
+
|
|
267
|
+
## Single-group cancellation
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
// v6
|
|
271
|
+
midnight.cancelOffer({ group, accountAddress });
|
|
272
|
+
|
|
273
|
+
// v7
|
|
274
|
+
midnight.cancelOffers({
|
|
275
|
+
accountAddress,
|
|
276
|
+
cancellations: [{ group, maxConsumed: maxUint128 }],
|
|
277
|
+
deadline,
|
|
278
|
+
});
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
v6 `cancelOffer` called `Midnight.setConsumed` directly and returned no requirements. v7 `cancelOffers`
|
|
282
|
+
goes through MidnightBundlesV2, so call `getRequirements()` first: it returns the maker's Midnight
|
|
283
|
+
authorization of `MidnightBundlesV2` when it is missing. The bundle also needs a `deadline`, and
|
|
284
|
+
`maxConsumed` only caps how much of the group may already be consumed when the cancellation runs.
|
|
285
|
+
|
|
286
|
+
Send the transaction from `accountAddress`. v6 reverted unless the sender was the maker or an
|
|
287
|
+
account the maker authorized on Midnight. v7 does not: MidnightBundlesV2 cancels the groups of
|
|
288
|
+
whichever account sends the transaction, so a transaction from another account that has also
|
|
289
|
+
authorized MidnightBundlesV2 succeeds and leaves the maker's offers fillable. `accountAddress` is
|
|
290
|
+
only used to check the maker's authorization.
|
|
291
|
+
|
|
292
|
+
Removed: `cancelOffer`, `midnightCancelOffer`, `MidnightCancelOfferParams`, `MidnightCancelOfferAction` and
|
|
293
|
+
`MidnightAmountExceedsMaxOfferCapError`.
|
|
294
|
+
|
|
295
|
+
## Deployment
|
|
296
|
+
|
|
297
|
+
MidnightBundlesV2 is pinned on Ethereum, Base, Arc, and Robinhood.
|
package/README.md
CHANGED
|
@@ -24,7 +24,8 @@ General Vault V1 operations remain supported.
|
|
|
24
24
|
pnpm add @morpho-org/morpho-sdk
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
Upgrading from
|
|
27
|
+
Upgrading from v6? Read the [v6 → v7 migration guide](./MIGRATION-v6-to-v7.md) before updating Midnight
|
|
28
|
+
maker integrations. Upgrading from v5? Read the [v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating vault
|
|
28
29
|
deposit or Blue write integrations.
|
|
29
30
|
|
|
30
31
|
## Actions
|
|
@@ -41,9 +42,18 @@ BlueBundlesV1, and the remaining rows identify their destination.
|
|
|
41
42
|
| | `forceRedeem` | Vault multicall |
|
|
42
43
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
43
44
|
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
44
|
-
| **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `repayWithdrawCollateral` |
|
|
45
|
-
| | `
|
|
46
|
-
| | `
|
|
45
|
+
| **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `takeRepayWithdrawCollateral`, `repayWithdrawCollateral`, `takeWithdraw` | MidnightBundlesV2 (Ethereum, Base, Arc, Robinhood) |
|
|
46
|
+
| | `supplyCollateral`, `redeem` | Direct call |
|
|
47
|
+
| | `makeLend`, `makeBorrow`, `makeWithdraw`, `makeRepay`, `supplyCollateralMakeBorrow`, `supplyBlueMakeLend`, `cancelOffers` | MidnightBundlesV2 (Ethereum, Base, Arc, Robinhood) |
|
|
48
|
+
|
|
49
|
+
`makeBorrow` publishes without collateral; `supplyCollateralMakeBorrow` requires collateral and
|
|
50
|
+
supplies it in the same transaction.
|
|
51
|
+
|
|
52
|
+
`makeWithdraw` publishes reduce-only sell offers for lend limit exits. `makeRepay` publishes
|
|
53
|
+
reduce-only buy offers for borrow limit exits and uses the same loan reserve inputs as `makeLend`.
|
|
54
|
+
Both preserve the supplied offer tree and use `midnightCancelAndMake`; neither executes a fill
|
|
55
|
+
or withdraws collateral during publication. Send their approval/authorization requirements first,
|
|
56
|
+
then call `buildTx()` without a separate root signature.
|
|
47
57
|
|
|
48
58
|
`VaultExitBundlesV1`, `VaultBundlesV1`, and `BlueBundlesV1` are registered on Ethereum, Base,
|
|
49
59
|
Arbitrum, Optimism, Polygon, World Chain, Unichain, HyperEVM, Katana, Monad, Stable, Tempo,
|
|
@@ -60,7 +70,7 @@ live Blue liquidity — before invoking `buildTx()`. Calling `buildTx()` directl
|
|
|
60
70
|
RPC-backed pre-flight checks. `forceRedeem` remains a direct Vault V2 multicall without
|
|
61
71
|
prerequisites.
|
|
62
72
|
|
|
63
|
-
- **`getRequirements()`** — async; the on-chain prerequisites to satisfy first: ERC-20 approvals, permit / Permit2 signatures, Morpho authorization, or (for Midnight) operator authorization
|
|
73
|
+
- **`getRequirements()`** — async; the on-chain prerequisites to satisfy first: ERC-20 approvals, permit / Permit2 signatures, Morpho authorization, or (for Midnight) operator authorization.
|
|
64
74
|
- **`buildTx(signatures?)`** — synchronous; the final, deep-frozen viem transaction. Pass any signatures collected from the requirements.
|
|
65
75
|
|
|
66
76
|
```typescript
|
|
@@ -230,6 +240,8 @@ instant liquidation. Blue writes do not accept `slippageTolerance`, `minSharePri
|
|
|
230
240
|
|
|
231
241
|
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}`.
|
|
232
242
|
|
|
243
|
+
Morpho-ts registers MidnightBundlesV2 on Ethereum, Base, Arc, and Robinhood.
|
|
244
|
+
|
|
233
245
|
```typescript
|
|
234
246
|
const midnight = client.morpho.midnight(8453);
|
|
235
247
|
const marketData = await midnight.getMarketData(marketId);
|
|
@@ -237,9 +249,9 @@ const marketData = await midnight.getMarketData(marketId);
|
|
|
237
249
|
const output = midnight.takeLend({
|
|
238
250
|
accountAddress: lender,
|
|
239
251
|
marketData,
|
|
240
|
-
assets: 1_000_000n,
|
|
241
|
-
minUnits: 900_000n,
|
|
252
|
+
target: { type: "assets", assets: 1_000_000n, minUnits: 900_000n },
|
|
242
253
|
takeableOffers: quote.data.takeableOffers,
|
|
254
|
+
maxContinuousFee: maxUint256,
|
|
243
255
|
deadline,
|
|
244
256
|
});
|
|
245
257
|
|
|
@@ -323,10 +335,12 @@ graph LR
|
|
|
323
335
|
MN1[MorphoMidnight]
|
|
324
336
|
MN1 --> MNT[fixed-rate taker actions]
|
|
325
337
|
MN1 --> MNM[maker offer submission]
|
|
326
|
-
MN1 -->
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
338
|
+
MN1 --> MNR[repayWithdrawCollateral]
|
|
339
|
+
MN1 --> MNP[collateral supply / redeem]
|
|
340
|
+
MNT --> MNB2[MidnightBundlesV2]
|
|
341
|
+
MNM --> MNB2
|
|
342
|
+
MNR --> MNB2
|
|
343
|
+
MNP --> MNC[Midnight]
|
|
330
344
|
end
|
|
331
345
|
|
|
332
346
|
|
|
@@ -337,7 +351,7 @@ graph LR
|
|
|
337
351
|
MV1 -.->|approval / permit| REQ
|
|
338
352
|
MV2 -.->|approval / permit| REQ
|
|
339
353
|
MM1 -.->|approval / permit / authorization| REQ
|
|
340
|
-
MN1 -.->|approval / authorization
|
|
354
|
+
MN1 -.->|approval / authorization| REQ
|
|
341
355
|
|
|
342
356
|
style VBV1 fill:#e8f5e9,stroke:#4caf50
|
|
343
357
|
style BBV1 fill:#e8f5e9,stroke:#4caf50
|
package/lib/cjs/abis.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { marketParamsAbi as blueMarketParamsAbi } from "@morpho-org/blue-sdk";
|
|
2
|
-
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, morphoMarketV1AdapterAbi, morphoMarketV1AdapterFactoryAbi, morphoMarketV1AdapterV2Abi, morphoMarketV1AdapterV2FactoryAbi, morphoVaultV1AdapterAbi, morphoVaultV1AdapterFactoryAbi, permissionedErc20WrapperAbi, permit2Abi,
|
|
2
|
+
export { adaptiveCurveIrmAbi as blueAdaptiveCurveIrmAbi, blueAbi, blueOracleAbi, erc2612Abi, erc5267Abi, metaMorphoAbi, metaMorphoFactoryAbi, midnightAdapterAbi, midnightAdapterFactoryAbi, midnightAdapterPriceRatifierV1Abi, midnightAdapterRateRatifierV1Abi, 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. */
|
|
6
6
|
preLiquidationFactoryAbi as bluePreLiquidationFactoryAbi, vaultV2Abi, vaultV2BluePublicAllocatorAbi, vaultV2FactoryAbi, whitelistControllerAggregatorV2Abi, wrappedBackedTokenAbi, wstEthAbi, } from "@morpho-org/blue-sdk-viem";
|
|
7
|
-
export { ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi,
|
|
7
|
+
export { blueBuyCallbackFactoryAbi as midnightBlueBuyCallbackFactoryAbi, ecrecoverRatifierAbi as midnightEcrecoverRatifierAbi, midnightAbi, midnightBundlesV2Abi, priceRatifierV1Abi as midnightPriceRatifierV1Abi, rateRatifierV1Abi as midnightRateRatifierV1Abi, setterRatifierAbi as midnightSetterRatifierAbi, } from "@morpho-org/midnight-sdk";
|
|
8
8
|
/** ABI for the VaultExitBundlesV1 periphery contract. */
|
|
9
9
|
export declare const vaultExitBundlesV1Abi: readonly [{
|
|
10
10
|
readonly type: "constructor";
|
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.
|
|
3
|
+
exports.blueBundlesV1Abi = exports.vaultBundlesV1Abi = exports.vaultExitBundlesV1Abi = exports.midnightSetterRatifierAbi = exports.midnightRateRatifierV1Abi = exports.midnightPriceRatifierV1Abi = exports.midnightBundlesV2Abi = exports.midnightAbi = exports.midnightEcrecoverRatifierAbi = exports.midnightBlueBuyCallbackFactoryAbi = 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.midnightAdapterRateRatifierV1Abi = exports.midnightAdapterPriceRatifierV1Abi = exports.midnightAdapterFactoryAbi = exports.midnightAdapterAbi = exports.metaMorphoFactoryAbi = exports.metaMorphoAbi = exports.erc5267Abi = 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");
|
|
@@ -11,6 +11,10 @@ Object.defineProperty(exports, "erc2612Abi", { enumerable: true, get: function (
|
|
|
11
11
|
Object.defineProperty(exports, "erc5267Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.erc5267Abi; } });
|
|
12
12
|
Object.defineProperty(exports, "metaMorphoAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoAbi; } });
|
|
13
13
|
Object.defineProperty(exports, "metaMorphoFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.metaMorphoFactoryAbi; } });
|
|
14
|
+
Object.defineProperty(exports, "midnightAdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterAbi; } });
|
|
15
|
+
Object.defineProperty(exports, "midnightAdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterFactoryAbi; } });
|
|
16
|
+
Object.defineProperty(exports, "midnightAdapterPriceRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterPriceRatifierV1Abi; } });
|
|
17
|
+
Object.defineProperty(exports, "midnightAdapterRateRatifierV1Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.midnightAdapterRateRatifierV1Abi; } });
|
|
14
18
|
Object.defineProperty(exports, "morphoMarketV1AdapterAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterAbi; } });
|
|
15
19
|
Object.defineProperty(exports, "morphoMarketV1AdapterFactoryAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterFactoryAbi; } });
|
|
16
20
|
Object.defineProperty(exports, "morphoMarketV1AdapterV2Abi", { enumerable: true, get: function () { return blue_sdk_viem_1.morphoMarketV1AdapterV2Abi; } });
|
|
@@ -30,9 +34,10 @@ Object.defineProperty(exports, "whitelistControllerAggregatorV2Abi", { enumerabl
|
|
|
30
34
|
Object.defineProperty(exports, "wrappedBackedTokenAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.wrappedBackedTokenAbi; } });
|
|
31
35
|
Object.defineProperty(exports, "wstEthAbi", { enumerable: true, get: function () { return blue_sdk_viem_1.wstEthAbi; } });
|
|
32
36
|
var midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
37
|
+
Object.defineProperty(exports, "midnightBlueBuyCallbackFactoryAbi", { enumerable: true, get: function () { return midnight_sdk_1.blueBuyCallbackFactoryAbi; } });
|
|
33
38
|
Object.defineProperty(exports, "midnightEcrecoverRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.ecrecoverRatifierAbi; } });
|
|
34
39
|
Object.defineProperty(exports, "midnightAbi", { enumerable: true, get: function () { return midnight_sdk_1.midnightAbi; } });
|
|
35
|
-
Object.defineProperty(exports, "
|
|
40
|
+
Object.defineProperty(exports, "midnightBundlesV2Abi", { enumerable: true, get: function () { return midnight_sdk_1.midnightBundlesV2Abi; } });
|
|
36
41
|
Object.defineProperty(exports, "midnightPriceRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.priceRatifierV1Abi; } });
|
|
37
42
|
Object.defineProperty(exports, "midnightRateRatifierV1Abi", { enumerable: true, get: function () { return midnight_sdk_1.rateRatifierV1Abi; } });
|
|
38
43
|
Object.defineProperty(exports, "midnightSetterRatifierAbi", { enumerable: true, get: function () { return midnight_sdk_1.setterRatifierAbi; } });
|
|
@@ -203,18 +203,22 @@ export declare const selectBundlesTokenRequirementSignature: (signatures: readon
|
|
|
203
203
|
* @internal
|
|
204
204
|
*
|
|
205
205
|
* @param signatures - Signatures passed to the operation's `buildTx` function.
|
|
206
|
-
* @param expected - Immutable spender, amount, and deadline required by the operation.
|
|
206
|
+
* @param expected - Immutable spender, amount bounds, and deadline required by the operation.
|
|
207
207
|
* @param expected.spender - Fixed bundles contract the permit must authorize.
|
|
208
|
-
* @param expected.amount -
|
|
208
|
+
* @param expected.amount - Minimum share allowance the permit must cover.
|
|
209
|
+
* @param expected.maxAmount - Optional inclusive share allowance ceiling; defaults to
|
|
210
|
+
* `expected.amount`, which accepts only an exact match.
|
|
209
211
|
* @param expected.deadline - Deadline the permit must carry.
|
|
210
212
|
* @returns The matching ERC-2612 signature, or `undefined` when no signature is supplied.
|
|
211
|
-
* @throws {BundlesPermitMismatchError} when the signature is not ERC-2612
|
|
212
|
-
*
|
|
213
|
-
*
|
|
213
|
+
* @throws {BundlesPermitMismatchError} when the signature is not ERC-2612, its spender or
|
|
214
|
+
* deadline differ from the operation's, its signed amount differs from its action's amount, or
|
|
215
|
+
* its amount is outside `[expected.amount, expected.maxAmount ?? expected.amount]`.
|
|
216
|
+
* The nonce is not checked here: it is onchain state the vault's `permit` verifies at execution.
|
|
214
217
|
*/
|
|
215
218
|
export declare const selectBundlesSharesPermitSignature: (signatures: readonly RequirementSignature[] | undefined, expected: {
|
|
216
219
|
readonly spender: Address;
|
|
217
220
|
readonly amount: bigint;
|
|
221
|
+
readonly maxAmount?: bigint;
|
|
218
222
|
readonly deadline: bigint;
|
|
219
223
|
}) => Erc2612RequirementSignature | undefined;
|
|
220
224
|
/** @internal Returns the exact referral fee deducted from a fixed gross asset amount. */
|
|
@@ -364,11 +364,7 @@ const selectBundlesTokenRequirementSignature = (signatures, expected) => {
|
|
|
364
364
|
if (selected.length !== signatures.length) {
|
|
365
365
|
const unexpected = signatures.find((signature) => signature.action.type !== "permit" &&
|
|
366
366
|
signature.action.type !== "permit2SignatureTransfer");
|
|
367
|
-
throw new index_js_2.UnexpectedRequirementSignatureError(unexpected?.action.type === "authorization"
|
|
368
|
-
? "authorization"
|
|
369
|
-
: unexpected?.action.type === "midnightOfferRootSignature"
|
|
370
|
-
? "midnightOfferRootSignature"
|
|
371
|
-
: "permit");
|
|
367
|
+
throw new index_js_2.UnexpectedRequirementSignatureError(unexpected?.action.type === "authorization" ? "authorization" : "permit");
|
|
372
368
|
}
|
|
373
369
|
if (selected.length > 1) {
|
|
374
370
|
throw new index_js_2.AmbiguousRequirementSignaturesError("permit", selected.length);
|
|
@@ -421,14 +417,17 @@ exports.selectBundlesTokenRequirementSignature = selectBundlesTokenRequirementSi
|
|
|
421
417
|
* @internal
|
|
422
418
|
*
|
|
423
419
|
* @param signatures - Signatures passed to the operation's `buildTx` function.
|
|
424
|
-
* @param expected - Immutable spender, amount, and deadline required by the operation.
|
|
420
|
+
* @param expected - Immutable spender, amount bounds, and deadline required by the operation.
|
|
425
421
|
* @param expected.spender - Fixed bundles contract the permit must authorize.
|
|
426
|
-
* @param expected.amount -
|
|
422
|
+
* @param expected.amount - Minimum share allowance the permit must cover.
|
|
423
|
+
* @param expected.maxAmount - Optional inclusive share allowance ceiling; defaults to
|
|
424
|
+
* `expected.amount`, which accepts only an exact match.
|
|
427
425
|
* @param expected.deadline - Deadline the permit must carry.
|
|
428
426
|
* @returns The matching ERC-2612 signature, or `undefined` when no signature is supplied.
|
|
429
|
-
* @throws {BundlesPermitMismatchError} when the signature is not ERC-2612
|
|
430
|
-
*
|
|
431
|
-
*
|
|
427
|
+
* @throws {BundlesPermitMismatchError} when the signature is not ERC-2612, its spender or
|
|
428
|
+
* deadline differ from the operation's, its signed amount differs from its action's amount, or
|
|
429
|
+
* its amount is outside `[expected.amount, expected.maxAmount ?? expected.amount]`.
|
|
430
|
+
* The nonce is not checked here: it is onchain state the vault's `permit` verifies at execution.
|
|
432
431
|
*/
|
|
433
432
|
const selectBundlesSharesPermitSignature = (signatures, expected) => {
|
|
434
433
|
const { permit } = (0, index_js_2.selectRequirementSignatures)(signatures, { permit: true });
|
|
@@ -449,11 +448,21 @@ const selectBundlesSharesPermitSignature = (signatures, expected) => {
|
|
|
449
448
|
actual: action.args.spender,
|
|
450
449
|
});
|
|
451
450
|
}
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
const maxAmount = expected.maxAmount ?? expected.amount;
|
|
452
|
+
const expectedAmount = expected.maxAmount == null || expected.maxAmount === expected.amount
|
|
453
|
+
? String(expected.amount)
|
|
454
|
+
: `[${expected.amount}, ${expected.maxAmount}]`;
|
|
455
|
+
if (permit.args.amount !== action.args.amount) {
|
|
454
456
|
throw new index_js_2.BundlesPermitMismatchError({
|
|
455
457
|
field: "amount",
|
|
456
|
-
expected: String(
|
|
458
|
+
expected: String(action.args.amount),
|
|
459
|
+
actual: String(permit.args.amount),
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
if (permit.args.amount < expected.amount || permit.args.amount > maxAmount) {
|
|
463
|
+
throw new index_js_2.BundlesPermitMismatchError({
|
|
464
|
+
field: "amount",
|
|
465
|
+
expected: expectedAmount,
|
|
457
466
|
actual: String(permit.args.amount),
|
|
458
467
|
});
|
|
459
468
|
}
|
|
@@ -9,7 +9,8 @@ export interface MidnightSetIsAuthorizedParams {
|
|
|
9
9
|
readonly metadata?: Metadata;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
|
-
* Encodes `Midnight.setIsAuthorized
|
|
12
|
+
* Encodes `Midnight.setIsAuthorized`. Grants target MidnightBundlesV2;
|
|
13
|
+
* revocations accept any operator.
|
|
13
14
|
*
|
|
14
15
|
* Prefer requirement helpers or entity `getRequirements()` in app flows; they
|
|
15
16
|
* read `isAuthorized` first and return this transaction only when needed. Use
|
|
@@ -29,7 +30,7 @@ export interface MidnightSetIsAuthorizedParams {
|
|
|
29
30
|
*
|
|
30
31
|
* const tx = midnightSetIsAuthorized({
|
|
31
32
|
* chainId: 8453,
|
|
32
|
-
* authorized:
|
|
33
|
+
* authorized: midnightBundlesV2,
|
|
33
34
|
* onBehalf: user,
|
|
34
35
|
* });
|
|
35
36
|
* ```
|
|
@@ -7,7 +7,8 @@ const viem_1 = require("viem");
|
|
|
7
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
8
|
const validateMidnightAuthorizationTarget_js_1 = require("../../helpers/validateMidnightAuthorizationTarget.js");
|
|
9
9
|
/**
|
|
10
|
-
* Encodes `Midnight.setIsAuthorized
|
|
10
|
+
* Encodes `Midnight.setIsAuthorized`. Grants target MidnightBundlesV2;
|
|
11
|
+
* revocations accept any operator.
|
|
11
12
|
*
|
|
12
13
|
* Prefer requirement helpers or entity `getRequirements()` in app flows; they
|
|
13
14
|
* read `isAuthorized` first and return this transaction only when needed. Use
|
|
@@ -27,7 +28,7 @@ const validateMidnightAuthorizationTarget_js_1 = require("../../helpers/validate
|
|
|
27
28
|
*
|
|
28
29
|
* const tx = midnightSetIsAuthorized({
|
|
29
30
|
* chainId: 8453,
|
|
30
|
-
* authorized:
|
|
31
|
+
* authorized: midnightBundlesV2,
|
|
31
32
|
* onBehalf: user,
|
|
32
33
|
* });
|
|
33
34
|
* ```
|