@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +201 -0
- package/README.md +58 -40
- package/lib/cjs/actions/blue/borrow.d.ts +62 -61
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +99 -0
- package/lib/cjs/actions/blue/common.js +318 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -112
- package/lib/cjs/actions/blue/refinance.js +97 -199
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- package/lib/cjs/actions/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +207 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +2 -0
- package/lib/cjs/actions/requirements/blue/index.js +2 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +7 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +123 -0
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- package/lib/cjs/bundler/actions.d.ts +4 -4
- package/lib/cjs/bundler/actions.js +4 -4
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +806 -374
- package/lib/cjs/entities/blue/blue.js +447 -696
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/validate.d.ts +14 -23
- package/lib/cjs/helpers/validate.js +30 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -0
- package/lib/cjs/types/action.d.ts +146 -162
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +141 -14
- package/lib/cjs/types/error.js +198 -21
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- package/lib/esm/actions/blue/borrow.d.ts +62 -61
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +99 -0
- package/lib/esm/actions/blue/common.js +306 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -112
- package/lib/esm/actions/blue/refinance.js +98 -200
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
- package/lib/esm/actions/blue/withdraw.d.ts +68 -79
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- package/lib/esm/actions/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +203 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +2 -0
- package/lib/esm/actions/requirements/blue/index.js +2 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +8 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +119 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- package/lib/esm/bundler/actions.d.ts +4 -4
- package/lib/esm/bundler/actions.js +4 -4
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +806 -374
- package/lib/esm/entities/blue/blue.js +453 -702
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/validate.d.ts +14 -23
- package/lib/esm/helpers/validate.js +30 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -0
- package/lib/esm/types/action.d.ts +146 -162
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +141 -14
- package/lib/esm/types/error.js +184 -17
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +4 -3
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Migrating `@morpho-org/morpho-sdk` from v5 to v6
|
|
2
|
+
|
|
3
|
+
Version 6 keeps the Blue entity at `client.morpho.blue(marketParams, chainId)` and preserves its
|
|
4
|
+
write-method names while routing them through five direct BlueBundlesV1 entrypoints. Blue reads and
|
|
5
|
+
versioned reallocation-data helpers remain on the same entity. There is no parallel BlueBundlesV1
|
|
6
|
+
extension or automatic fallback to the v5 route.
|
|
7
|
+
|
|
8
|
+
> **Chain availability.** The direct BlueBundlesV1 route requires the `bundles.blueBundlesV1`
|
|
9
|
+
> deployment on the target chain. On a registered chain without it (the previous Bundler3-routed
|
|
10
|
+
> flows covered more chains), **every** Blue write — `supply`, `supplyCollateral`, `borrow`,
|
|
11
|
+
> `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `withdraw`, and
|
|
12
|
+
> `refinance` — throws `UnknownAddressError` synchronously at handle creation (via
|
|
13
|
+
> `validateWriteCommon`). Confirm coverage before upgrading, for example
|
|
14
|
+
> `getChainAddresses(chainId).bundles?.blueBundlesV1 != null`.
|
|
15
|
+
|
|
16
|
+
## Update Blue methods
|
|
17
|
+
|
|
18
|
+
| Stable method | v5 input | v6 input |
|
|
19
|
+
| --- | --- | --- |
|
|
20
|
+
| `supply` | `amount`/`nativeAmount`, `marketData`, `slippageTolerance` | Rename gross `amount` to `assets`; remove `marketData` and slippage; add required `deadline` plus optional `referralFeePct` and `referralFeeRecipient`. ERC-20 and native funding are now exclusive. |
|
|
21
|
+
| `withdraw` | `assets` or `shares`, optional `receiver`, `slippageTolerance`, mixed-version `reallocations` | Keep `assets`/`shares`; remove `receiver` and slippage; use only `VaultV2BlueReallocation`; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
22
|
+
| `supplyCollateral` | `amount` plus optional additive `nativeAmount` | Rename `amount` to `collateralAssets`; make native and ERC-20 funding exclusive; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
23
|
+
| `borrow` | `amount`, `slippageTolerance`, mixed-version `reallocations` | Rename `amount` to `borrowAssets`; remove slippage; use only `VaultV2BlueReallocation`; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
24
|
+
| `supplyCollateralBorrow` | `amount`, `borrowAmount`, required `positionData`, `slippageTolerance`, mixed-version `reallocations` | Rename the legs to `collateralAssets` and `borrowAssets`; `positionData` is required only when borrowing; use exclusive native funding and V2-only reallocations; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
25
|
+
| `repay` | `amount` or `shares`, optional additive `nativeAmount`, `slippageTolerance` | Rename the modes to `repayAssets` or `repayShares`; use `maxUint256` shares for a full close; remove slippage; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. Native funding must cover the full derived cap. |
|
|
26
|
+
| `withdrawCollateral` | `amount` | Rename `amount` to `collateralAssets`; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
27
|
+
| `repayWithdrawCollateral` | `amount` or `shares`, `withdrawAmount`, optional additive `nativeAmount`, `slippageTolerance` | Rename the repay modes to `repayAssets`/`repayShares` and `withdrawAmount` to `collateralAssets`; remove slippage; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. |
|
|
28
|
+
| `refinance` | `target`, `collateralAmount`, `borrowAssets`/`borrowShares`, `slippageTolerance`, `targetReallocations` | Rename `target` to `destination`; remove partial-leg amounts and share-price inputs; rename V2-only `targetReallocations` to `reallocations`; add `deadline`, `referralFeePct`, and `referralFeeRecipient`. The full live position always moves. |
|
|
29
|
+
|
|
30
|
+
The two combined methods require at least one non-zero leg. See the dedicated **Blue refinance**
|
|
31
|
+
section below for that method's larger shape change.
|
|
32
|
+
|
|
33
|
+
## Update pure action builder inputs and metadata
|
|
34
|
+
|
|
35
|
+
Direct action consumers keep the root-barrel builder and parameter-type names, but must replace
|
|
36
|
+
their `args` objects as follows. `metadata` is unchanged.
|
|
37
|
+
|
|
38
|
+
| Stable builder / params | v6 `args` fields |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `blueSupply` / `BlueSupplyParams` | `userAddress`, `assets`, optional `nativeAmount`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `requirementSignature`. |
|
|
41
|
+
| `blueWithdraw` / `BlueWithdrawParams` | `userAddress`, `withdrawAssets`, `withdrawShares`, optional V2 `reallocations`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `authorizationSignature`. |
|
|
42
|
+
| `blueSupplyCollateral` / `BlueSupplyCollateralParams` | `userAddress`, `collateralAssets`, optional `nativeAmount`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `requirementSignature`. |
|
|
43
|
+
| `blueBorrow` / `BlueBorrowParams` | `userAddress`, `borrowAssets`, `maxLtv`, optional V2 `reallocations`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `authorizationSignature`. |
|
|
44
|
+
| `blueSupplyCollateralBorrow` / `BlueSupplyCollateralBorrowParams` | `userAddress`, `collateralAssets`, `borrowAssets`, `maxLtv`, optional `nativeAmount`/V2 `reallocations`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, `requirementSignature`, and `authorizationSignature`. |
|
|
45
|
+
| `blueRepay` / `BlueRepayParams` | `userAddress`, `repayAssets`, `repayShares`, `maxRepayAssets`, optional `nativeAmount`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `requirementSignature`. |
|
|
46
|
+
| `blueWithdrawCollateral` / `BlueWithdrawCollateralParams` | `userAddress`, `collateralAssets`, `maxLtv`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `authorizationSignature`. |
|
|
47
|
+
| `blueRepayWithdrawCollateral` / `BlueRepayWithdrawCollateralParams` | `userAddress`, `repayAssets`, `repayShares`, `maxRepayAssets`, `collateralAssets`, `maxLtv`, optional `nativeAmount`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, `requirementSignature`, and `authorizationSignature`. |
|
|
48
|
+
| `blueRefinance` / `BlueRefinanceParams` | `userAddress`, `maxLtv`, optional V2 `reallocations`, required `deadline`, optional `referralFeePct`, `referralFeeRecipient`, and `authorizationSignature`; replace `source`/`target` with `market: { chainId, sourceMarketParams, destinationMarketParams }`. |
|
|
49
|
+
|
|
50
|
+
The transaction metadata exports and discriminator strings stay stable; their argument fields change
|
|
51
|
+
as below. The table lists only the delta: unchanged fields are retained and omitted. In particular
|
|
52
|
+
every Blue action keeps its `market` (`Hex` market id) field, so a strict decoder must keep matching
|
|
53
|
+
it alongside the added fields.
|
|
54
|
+
|
|
55
|
+
| Stable action type / discriminator | Removed v5 `action.args` fields | Changed / added v6 `action.args` fields |
|
|
56
|
+
| --- | --- | --- |
|
|
57
|
+
| `BlueSupplyAction` / `"blueSupply"` | `amount`, `maxSharePrice` | `assets`, `onBehalf`, optional `nativeAmount`, `referralFeePct`, `referralFeeRecipient`, `deadline`. |
|
|
58
|
+
| `BlueWithdrawAction` / `"blueWithdraw"` | `assets`, `shares`, `receiver`, `minSharePrice`, `reallocationFee` | `withdrawAssets`, `withdrawShares`, `onBehalf`, `reallocations`, `reallocationPenaltyAssets`, `referralFeePct`, `referralFeeRecipient`, `deadline`. |
|
|
59
|
+
| `BlueSupplyCollateralAction`, `BlueBorrowAction`, `BlueSupplyCollateralBorrowAction` | `amount`, `collateralAmount`, `borrowAmount`, `receiver`, `minSharePrice`, `reallocationFee` | All three use the combined shape: `collateralAssets`, `borrowAssets`, `maxLtv`, `onBehalf`, optional `nativeAmount`, `reallocations`, `reallocationPenaltyAssets`, `referralFeePct`, `referralFeeRecipient`, `deadline`; an inactive simple-method leg is zero. |
|
|
60
|
+
| `BlueRepayAction`, `BlueWithdrawCollateralAction`, `BlueRepayWithdrawCollateralAction` | `amount`, `shares`, `transferAmount`, `withdrawAmount`, `receiver`, `maxSharePrice` | All three use the combined shape: `repayAssets`, `repayShares`, `maxRepayAssets`, `collateralAssets`, `maxLtv`, `onBehalf`, optional `nativeAmount`, `referralFeePct`, `referralFeeRecipient`, `deadline`; inactive simple-method legs are zero. |
|
|
61
|
+
| `BlueRefinanceAction` / `"blueRefinance"` | `targetMarket`, `collateralAmount`, `borrowAssets`, `borrowShares`, borrow/repay share-price bounds, `user`, `reallocationFee` | `sourceMarket`, `destinationMarket`, `maxLtv`, `onBehalf`, `reallocations`, `reallocationPenaltyAssets`, `referralFeePct`, `referralFeeRecipient`, `deadline`. |
|
|
62
|
+
|
|
63
|
+
`RepayAmountArgs` and `RepayActionAmountArgs` are removed. Use the mutually exclusive
|
|
64
|
+
`repayAssets` / `repayShares` fields on the replacement method or builder instead.
|
|
65
|
+
|
|
66
|
+
## Update write inputs
|
|
67
|
+
|
|
68
|
+
- Remove Blue `slippageTolerance`, `minSharePrice`, and `maxSharePrice` inputs. BlueBundlesV1 does
|
|
69
|
+
not expose the Bundler3 share-price checks. Vault deposit slippage protection is unchanged.
|
|
70
|
+
- Remove Blue `receiver`, `to`, and arbitrary `onBehalf` overrides. BlueBundlesV1 operates on the
|
|
71
|
+
transaction sender and sends proceeds and refunds back to that sender; `userAddress` must be the
|
|
72
|
+
eventual sender used to resolve requirements and position snapshots.
|
|
73
|
+
- Replace PublicAllocator V1 or mixed-version reallocation write inputs with Vault V2
|
|
74
|
+
`VaultV2BlueReallocation` inputs. All Vault V1 reallocation planning, data, input, validation,
|
|
75
|
+
and explicit low-level Bundler3-composition surfaces remain available only as deprecated
|
|
76
|
+
compatibility surfaces and will be removed in the next major; the high-level Blue writes do not
|
|
77
|
+
accept their outputs.
|
|
78
|
+
- Provide the BlueBundlesV1 execution deadline and any optional referral-fee configuration through
|
|
79
|
+
the new typed method inputs. Share-mode repayment deadlines are limited to two hours so the SDK's
|
|
80
|
+
derived `maxRepayAssets` remains sufficient through execution.
|
|
81
|
+
- Treat `supply` assets as gross funding: referral fees reduce assets supplied. Allocator penalties
|
|
82
|
+
and referral fees similarly affect proceeds or destination debt on the other operations.
|
|
83
|
+
- For native funding, the funded token must be the chain's wNative. Native and ERC-20 funding are
|
|
84
|
+
not additive on the direct BlueBundlesV1 call.
|
|
85
|
+
|
|
86
|
+
Borrow, collateral-withdraw, and migration legs retain the SDK's buffered LLTV validation. Pure
|
|
87
|
+
collateral supply and pure repay intentionally disable the onchain LTV cap so they can improve an
|
|
88
|
+
already-unhealthy position.
|
|
89
|
+
|
|
90
|
+
## Update requirements and transaction handling
|
|
91
|
+
|
|
92
|
+
The lazy workflow is unchanged: await `getRequirements()`, satisfy approval transactions, collect
|
|
93
|
+
signatures, then pass the signatures to synchronous `buildTx(signatures)`.
|
|
94
|
+
|
|
95
|
+
The destinations are different:
|
|
96
|
+
|
|
97
|
+
- Classic ERC-20 approvals and ERC-2612 permits now authorize BlueBundlesV1.
|
|
98
|
+
- Permit2 keeps its ERC-20 approval on canonical Permit2, but the SignatureTransfer payload names
|
|
99
|
+
BlueBundlesV1 as spender. Explicit Permit2 nonces are now required — see the subsection below.
|
|
100
|
+
- Morpho authorization now grants BlueBundlesV1 operator rights instead of GeneralAdapter1.
|
|
101
|
+
- Without signature support, saturated full-repay requirements use the token's reusable maximum
|
|
102
|
+
allowance so a later bounded debt quote remains covered; BlueBundlesV1 still refunds unused
|
|
103
|
+
transaction funding.
|
|
104
|
+
- The built transaction's `to` is BlueBundlesV1, not Bundler3, and calldata contains one fixed
|
|
105
|
+
BlueBundlesV1 entrypoint rather than a `BundlerAction[]` multicall.
|
|
106
|
+
|
|
107
|
+
Update simulations and analytics for the v6 action-field changes. Do not assert
|
|
108
|
+
Bundler3/GeneralAdapter1 destinations or inspect Bundler3 sub-actions for these
|
|
109
|
+
high-level writes.
|
|
110
|
+
|
|
111
|
+
### Permit2 SignatureTransfer requires an explicit nonce
|
|
112
|
+
|
|
113
|
+
SignatureTransfer consumes an owner-global unordered nonce rather than an allowance, so the SDK no
|
|
114
|
+
longer allocates one implicitly. For a client with `supportSignature: true`, the default supply
|
|
115
|
+
requirement path selects Permit2 and `supply(...).getRequirements()` now throws
|
|
116
|
+
`MissingPermit2TransferFromNonceError` when no nonce is supplied. Pass an unused nonce explicitly:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const requirements = await market
|
|
120
|
+
.supply({ userAddress, assets, deadline })
|
|
121
|
+
.getRequirements({ permit2Nonce });
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Allocate any `uint256` whose Permit2 `nonceBitmap` bit is still unset for `userAddress` (each nonce
|
|
125
|
+
is single-use; a consumed one throws `Permit2TransferFromNonceAlreadyUsedError`). To skip Permit2
|
|
126
|
+
for ERC-2612 tokens, pass `getRequirements({ useSimplePermit: true })`, which prefers a one-signature
|
|
127
|
+
ERC-2612 permit and needs no nonce.
|
|
128
|
+
|
|
129
|
+
## Blue refinance
|
|
130
|
+
|
|
131
|
+
The `refinance` entity method and the `blueRefinance` pure builder keep their names but now call
|
|
132
|
+
BlueBundlesV1's full-position migration entrypoint. Both drop partial and collateral-only migration:
|
|
133
|
+
the full live source debt and collateral always move, the source and destination markets must use the
|
|
134
|
+
same loan and collateral tokens and must not be the same market, and Morpho authorization targets
|
|
135
|
+
BlueBundlesV1.
|
|
136
|
+
|
|
137
|
+
`userAddress` must be the account that sends the transaction and, when used, signs the Morpho
|
|
138
|
+
authorization. BlueBundlesV1 migration calldata carries no owner field and always migrates
|
|
139
|
+
`msg.sender`; a supplied authorization signature is likewise bound to that sender. Unlike the v5
|
|
140
|
+
Bundler3 route (where `args.user` was encoded as `onBehalf` in every leg), a relayer can no longer
|
|
141
|
+
migrate a third party's position. Builders cannot enforce that `userAddress` matches the sender; a
|
|
142
|
+
mismatch does not itself revert, and BlueBundlesV1 still migrates `msg.sender`. The SDK uses
|
|
143
|
+
`userAddress` only to validate snapshots, build the authorization requirement, and populate action
|
|
144
|
+
metadata.
|
|
145
|
+
|
|
146
|
+
`market.refinance(...)` (entity method):
|
|
147
|
+
|
|
148
|
+
- Rename `target` to `destination`.
|
|
149
|
+
- Remove `collateralAmount`, `borrowAssets`, `borrowShares`, slippage, and share-price bounds.
|
|
150
|
+
- Rename V2-only `targetReallocations` to `reallocations`.
|
|
151
|
+
- Add `deadline` and optional referral-fee fields.
|
|
152
|
+
- Pass source and destination position snapshots.
|
|
153
|
+
|
|
154
|
+
`blueRefinance(...)` (pure builder):
|
|
155
|
+
|
|
156
|
+
- Replace the top-level `{ source: { chainId, marketParams }, target: { marketParams } }` shape with
|
|
157
|
+
`{ market: { chainId, sourceMarketParams, destinationMarketParams } }`.
|
|
158
|
+
- Rename `args.user` to `args.userAddress` and supply `args.maxLtv` (the buffered destination LTV).
|
|
159
|
+
- Remove `args.collateralAmount`, `args.borrowAssets`, `args.borrowShares`,
|
|
160
|
+
`args.minBorrowSharePrice`, and `args.maxRepaySharePrice`.
|
|
161
|
+
- Rename `args.targetReallocations` to `args.reallocations`.
|
|
162
|
+
- Add `args.deadline` and optional referral-fee fields.
|
|
163
|
+
|
|
164
|
+
The action metadata replaces `targetMarket`, partial-leg amounts, user, share-price bounds, and the
|
|
165
|
+
V1 fee with `destinationMarket`, `maxLtv`, `onBehalf`, a reallocation count and penalty total,
|
|
166
|
+
referral-fee fields, and `deadline`.
|
|
167
|
+
|
|
168
|
+
Stay on v5 if the product requires partial or collateral-only refinance behavior.
|
|
169
|
+
|
|
170
|
+
The partial-migration error classes `BorrowAmountAndSharesExclusiveError`,
|
|
171
|
+
`RefinanceExceedsCollateralError`, `RefinanceExceedsBorrowSharesError`,
|
|
172
|
+
`RefinanceExceedsBorrowAssetsError`, and `RefinanceSharesMissingBorrowAssetsError` are **deprecated,
|
|
173
|
+
not removed**: they stay exported through v6 (marked `@deprecated`) for consumers pattern-matching on
|
|
174
|
+
the v5 surface, are never thrown by the full-position route, and are removed in the next major. The
|
|
175
|
+
full-position route validates snapshot ownership and token/market compatibility, accounts for
|
|
176
|
+
reallocation penalties in destination debt, then checks the combined destination position against
|
|
177
|
+
the buffered LLTV (`BorrowExceedsSafeLtvError`); `RefinanceSameMarketError` and
|
|
178
|
+
`RefinanceTokenMismatchError` stay.
|
|
179
|
+
|
|
180
|
+
## Removed action-output field: `reallocationFee`
|
|
181
|
+
|
|
182
|
+
`BlueBorrowAction`, `BlueWithdrawAction`, `BlueSupplyCollateralBorrowAction`, and
|
|
183
|
+
`BlueRefinanceAction` no longer expose `reallocationFee` in `action.args`. That field only ever
|
|
184
|
+
carried Vault V1 native PublicAllocator fees, which high-level writes no longer emit. Read
|
|
185
|
+
`reallocationPenaltyAssets` for the loan-token penalty donated by Vault V2 BluePublicAllocator
|
|
186
|
+
reallocations.
|
|
187
|
+
|
|
188
|
+
## Removed type: `BlueReallocationPlan`
|
|
189
|
+
|
|
190
|
+
The `BlueReallocationPlan` union is removed. High-level Blue write inputs accept
|
|
191
|
+
`Iterable<VaultV2BlueReallocation>` directly; for explicit low-level Vault V1 composition, use
|
|
192
|
+
`VaultV1Reallocation[]`.
|
|
193
|
+
|
|
194
|
+
## Upgrade checklist
|
|
195
|
+
|
|
196
|
+
- Update every Blue write call using the table above; method names remain stable.
|
|
197
|
+
- Remove Blue slippage and PublicAllocator V1 write inputs.
|
|
198
|
+
- Re-run approval and Morpho-authorization setup against the new spender/operator.
|
|
199
|
+
- Update transaction decoding, simulation fixtures, and action metadata fields; discriminator
|
|
200
|
+
names remain stable.
|
|
201
|
+
- Test native funding, full repay, and full-position migration paths used by the application.
|
package/README.md
CHANGED
|
@@ -15,36 +15,40 @@ Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**,
|
|
|
15
15
|
pnpm add @morpho-org/morpho-sdk
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
+
Upgrading from v5? Read the [v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating Blue
|
|
19
|
+
write integrations.
|
|
20
|
+
|
|
18
21
|
## Actions
|
|
19
22
|
|
|
20
|
-
Each entity exposes a set of actions.
|
|
23
|
+
Each entity exposes a set of actions. Vault deposits route through Bundler3 via `GeneralAdapter1`;
|
|
24
|
+
Blue writes call BlueBundlesV1 directly; the remaining rows identify their direct destination.
|
|
21
25
|
|
|
22
26
|
| Entity | Actions | Route |
|
|
23
27
|
| --- | --- | --- |
|
|
24
|
-
| **VaultV1** (MetaMorpho) | `deposit`, `migrateToV2` |
|
|
28
|
+
| **VaultV1** (MetaMorpho) | `deposit`, `migrateToV2` | Bundler3 → GeneralAdapter1 |
|
|
25
29
|
| | `withdraw`, `redeem` | Direct call |
|
|
26
30
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
27
|
-
| **VaultV2** | `deposit` |
|
|
31
|
+
| **VaultV2** | `deposit` | Bundler3 → GeneralAdapter1 |
|
|
28
32
|
| | `withdraw`, `redeem` | Direct call |
|
|
29
33
|
| | `forceWithdraw`, `forceRedeem` | Vault multicall |
|
|
30
34
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
31
|
-
| **Blue** | `supply`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `
|
|
32
|
-
| | `withdrawCollateral` | Direct call |
|
|
35
|
+
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
33
36
|
| **Midnight** | `takeLend`, `takeBorrow`, `supplyCollateralTakeBorrow`, `repayWithdrawCollateral` | Midnight Bundles |
|
|
34
37
|
| | `makeLend`, `makeBorrow` | Midnight mempool |
|
|
35
38
|
| | `supplyCollateral`, `redeem`, `cancelOffer` | Direct call |
|
|
36
39
|
|
|
37
|
-
`VaultExitBundlesV1`
|
|
38
|
-
Unichain, HyperEVM, Katana, Monad, Stable, Tempo, and
|
|
39
|
-
be configured with `registerCustomAddresses`.
|
|
40
|
+
`VaultExitBundlesV1`, `VaultBundlesV1`, and `BlueBundlesV1` are registered on Ethereum, Base,
|
|
41
|
+
Arbitrum, Optimism, Polygon, World Chain, Unichain, HyperEVM, Katana, Monad, Stable, Tempo, and
|
|
42
|
+
Robinhood Chain. Custom deployments can still be configured with `registerCustomAddresses`.
|
|
40
43
|
|
|
41
44
|
## How it works
|
|
42
45
|
|
|
43
|
-
Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`.
|
|
46
|
+
Actions that pull tokens or touch a position return `{ buildTx, getRequirements }`. All Blue
|
|
47
|
+
writes use this lazy shape while still encoding one direct BlueBundlesV1 call. Vault
|
|
44
48
|
`inKindRedeem` uses this shape so callers can await `getRequirements()` to check live Blue liquidity
|
|
45
49
|
and share authorization before invoking `buildTx()`. Calling `buildTx()` directly skips those
|
|
46
50
|
RPC-backed pre-flight checks. Other direct calls — vault `withdraw` / `redeem`, `forceWithdraw` /
|
|
47
|
-
`forceRedeem
|
|
51
|
+
`forceRedeem` — have no prerequisites and return only `{ buildTx }`.
|
|
48
52
|
|
|
49
53
|
- **`getRequirements()`** — async; the on-chain prerequisites to satisfy first: ERC-20 approvals, permit / Permit2 signatures, Morpho authorization, or (for Midnight) operator authorization and offer-root signatures.
|
|
50
54
|
- **`buildTx(signatures?)`** — synchronous; the final, deep-frozen viem transaction. Pass any signatures collected from the requirements.
|
|
@@ -61,7 +65,10 @@ Enable off-chain approvals (permit / Permit2) with `morphoViemExtension({ suppor
|
|
|
61
65
|
|
|
62
66
|
### `userAddress` must be the signer
|
|
63
67
|
|
|
64
|
-
`userAddress` must be the account that signs and sends the transaction. Builders don't enforce
|
|
68
|
+
`userAddress` must be the account that signs and sends the transaction. Builders don't enforce
|
|
69
|
+
this, but the signature helpers do — `sign()` throws `AddressMismatchError` when the wallet's
|
|
70
|
+
account differs. BlueBundlesV1 always operates on `msg.sender`, so a Blue transaction must be sent
|
|
71
|
+
by that same account.
|
|
65
72
|
|
|
66
73
|
## Usage
|
|
67
74
|
|
|
@@ -119,7 +126,7 @@ const tx = buildTx();
|
|
|
119
126
|
|
|
120
127
|
For wNative vaults, pass `nativeAmount` instead of `amount` to deposit native ETH (wrapped automatically).
|
|
121
128
|
|
|
122
|
-
### Blue:
|
|
129
|
+
### Blue: BlueBundlesV1 writes
|
|
123
130
|
|
|
124
131
|
```typescript
|
|
125
132
|
const market = client.morpho.blue(
|
|
@@ -133,18 +140,15 @@ const market = client.morpho.blue(
|
|
|
133
140
|
1,
|
|
134
141
|
);
|
|
135
142
|
|
|
136
|
-
const positionData = await market.getPositionData("0xUser...");
|
|
137
|
-
|
|
138
143
|
const { buildTx, getRequirements } = market.supplyCollateralBorrow({
|
|
139
|
-
amount: 1000000000000000000n, // collateral
|
|
140
|
-
borrowAmount: 500000000000000000n, // loan asset
|
|
141
144
|
userAddress: "0xUser...",
|
|
142
|
-
|
|
145
|
+
collateralAssets: 1_000_000n,
|
|
146
|
+
borrowAssets: 0n,
|
|
147
|
+
deadline: 1_900_000_000n,
|
|
143
148
|
});
|
|
144
149
|
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// every collected signature to buildTx.
|
|
150
|
+
// Satisfy each BlueBundlesV1 approval or signature requirement, then pass every
|
|
151
|
+
// collected signature to buildTx.
|
|
148
152
|
const signatures = [];
|
|
149
153
|
for (const requirement of await getRequirements()) {
|
|
150
154
|
if (isRequirementSignature(requirement)) {
|
|
@@ -157,7 +161,15 @@ for (const requirement of await getRequirements()) {
|
|
|
157
161
|
const tx = buildTx(signatures);
|
|
158
162
|
```
|
|
159
163
|
|
|
160
|
-
|
|
164
|
+
Set `borrowAssets` to a non-zero amount and provide `positionData` to combine collateral supply and
|
|
165
|
+
borrowing. That path may also require Morpho authorization for BlueBundlesV1. Optional
|
|
166
|
+
`reallocations` are Vault V2 only, and the LLTV buffer guards the resulting position against
|
|
167
|
+
instant liquidation. Blue writes do not accept `slippageTolerance`, `minSharePrice`, or
|
|
168
|
+
`maxSharePrice` because BlueBundlesV1 has no share-price-bound inputs.
|
|
169
|
+
|
|
170
|
+
> High-level Blue writes accept only `VaultV2BlueReallocation`. Vault V1 planning and explicit
|
|
171
|
+
> low-level Bundler3 composition remain available only as deprecated compatibility surfaces and
|
|
172
|
+
> will be removed in the next major.
|
|
161
173
|
|
|
162
174
|
> All SDK surfaces for the Vault V1 shared-liquidity algorithm and its PublicAllocator Bundler3
|
|
163
175
|
> composition are deprecated and will be removed in the next major. Use Vault V2
|
|
@@ -184,7 +196,9 @@ const requirements = await output.getRequirements();
|
|
|
184
196
|
const tx = output.buildTx();
|
|
185
197
|
```
|
|
186
198
|
|
|
187
|
-
See the [documentation](https://docs.morpho.org/developers/sdks/morpho-sdk/) for the full API:
|
|
199
|
+
See the [documentation](https://docs.morpho.org/developers/sdks/morpho-sdk/) for the full API:
|
|
200
|
+
native wrapping, Vault V2 BluePublicAllocator reallocations, borrow-position migration, vault V1 →
|
|
201
|
+
V2 migration, force withdraw/redeem, and Midnight maker flows.
|
|
188
202
|
|
|
189
203
|
## Architecture
|
|
190
204
|
|
|
@@ -231,22 +245,27 @@ graph LR
|
|
|
231
245
|
|
|
232
246
|
subgraph Blue Flow
|
|
233
247
|
MM1[MorphoBlue]
|
|
234
|
-
MM1 --> M1S[
|
|
235
|
-
MM1 --> M1SC[
|
|
236
|
-
MM1 --> M1B[
|
|
237
|
-
MM1 --> M1SCB[
|
|
238
|
-
MM1 -->
|
|
239
|
-
MM1 -->
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
248
|
+
MM1 --> M1S[supply]
|
|
249
|
+
MM1 --> M1SC[supplyCollateral]
|
|
250
|
+
MM1 --> M1B[borrow]
|
|
251
|
+
MM1 --> M1SCB[supplyCollateralBorrow]
|
|
252
|
+
MM1 --> M1R[repay]
|
|
253
|
+
MM1 --> M1WC[withdrawCollateral]
|
|
254
|
+
MM1 --> M1RW[repayWithdrawCollateral]
|
|
255
|
+
MM1 --> M1W[withdraw]
|
|
256
|
+
MM1 --> M1M[refinance]
|
|
257
|
+
|
|
258
|
+
M1S --> BBV1[BlueBundlesV1]
|
|
259
|
+
M1SC --> BBV1
|
|
260
|
+
M1B --> BBV1
|
|
261
|
+
M1SCB --> BBV1
|
|
262
|
+
M1R --> BBV1
|
|
263
|
+
M1WC --> BBV1
|
|
264
|
+
M1RW --> BBV1
|
|
265
|
+
M1W --> BBV1
|
|
266
|
+
M1M --> BBV1
|
|
267
|
+
|
|
268
|
+
BBV1 -.->|reallocate / allocateFromIdle| BPA[Blue Public Allocator]
|
|
250
269
|
end
|
|
251
270
|
|
|
252
271
|
subgraph Midnight Flow
|
|
@@ -271,11 +290,10 @@ graph LR
|
|
|
271
290
|
|
|
272
291
|
style B1 fill:#e8f5e9,stroke:#4caf50
|
|
273
292
|
style B2 fill:#e8f5e9,stroke:#4caf50
|
|
274
|
-
style
|
|
293
|
+
style BBV1 fill:#e8f5e9,stroke:#4caf50
|
|
275
294
|
style MM fill:#fff3e0,stroke:#ff9800
|
|
276
295
|
style V2C fill:#e3f2fd,stroke:#2196f3
|
|
277
296
|
style REQ fill:#f3e5f5,stroke:#9c27b0
|
|
278
|
-
style PA1 fill:#fff9c4,stroke:#f9a825
|
|
279
297
|
style BPA fill:#fff9c4,stroke:#f9a825
|
|
280
298
|
```
|
|
281
299
|
|
|
@@ -1,84 +1,85 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import type { Address } from "viem";
|
|
3
|
-
import {
|
|
3
|
+
import type { AuthorizationRequirementSignature, BlueBorrowAction, Metadata, Transaction, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueBorrow}. */
|
|
5
5
|
export interface BlueBorrowParams {
|
|
6
|
-
market
|
|
6
|
+
/** Chain and scoped Morpho Blue market. */
|
|
7
|
+
readonly market: {
|
|
7
8
|
readonly chainId: number;
|
|
8
9
|
readonly marketParams: MarketParams;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
authorizationSignature?: AuthorizationRequirementSignature;
|
|
11
|
+
/** Direct BlueBundlesV1 borrow arguments. */
|
|
12
|
+
readonly args: {
|
|
13
|
+
/** User whose debt position is increased. */
|
|
14
|
+
readonly userAddress: Address;
|
|
15
|
+
/** Gross loan assets borrowed before penalties and referral fees. */
|
|
16
|
+
readonly borrowAssets: bigint;
|
|
17
|
+
/** Maximum post-operation LTV enforced by BlueBundlesV1. */
|
|
18
|
+
readonly maxLtv: bigint;
|
|
19
|
+
/** Optional validated Vault V2 BluePublicAllocator reallocations. */
|
|
20
|
+
readonly reallocations?: Iterable<VaultV2BlueReallocation>;
|
|
21
|
+
/** Final call deadline in Unix seconds. */
|
|
22
|
+
readonly deadline: bigint;
|
|
23
|
+
/** Optional WAD-scaled referral fee, strictly below 100%. */
|
|
24
|
+
readonly referralFeePct?: bigint;
|
|
25
|
+
/** Recipient required when `referralFeePct` is positive. */
|
|
26
|
+
readonly referralFeeRecipient?: Address;
|
|
27
|
+
/** Optional Morpho authorization signature for BlueBundlesV1. */
|
|
28
|
+
readonly authorizationSignature?: AuthorizationRequirementSignature;
|
|
28
29
|
};
|
|
29
|
-
metadata
|
|
30
|
+
/** Optional transaction metadata suffix. */
|
|
31
|
+
readonly metadata?: Metadata;
|
|
30
32
|
}
|
|
31
33
|
/**
|
|
32
|
-
*
|
|
34
|
+
* Encodes a pure borrow through BlueBundlesV1.
|
|
33
35
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* transaction construction and execution.
|
|
36
|
+
* Delegates to {@link blueSupplyCollateralBorrow} with a zero collateral leg. Vault V2 allocator
|
|
37
|
+
* penalties and referral fees reduce the assets received, and no Bundler3 action is encoded.
|
|
37
38
|
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
* @param params.
|
|
44
|
-
* @param params.
|
|
45
|
-
* @param params.args.
|
|
46
|
-
* @param params.args.
|
|
47
|
-
* @param params.args.
|
|
48
|
-
* @param params.args.
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
52
|
-
* @
|
|
53
|
-
* @
|
|
54
|
-
*
|
|
55
|
-
* @throws {
|
|
56
|
-
*
|
|
57
|
-
* @throws {
|
|
58
|
-
* @throws {InconsistentReallocationPenaltyError} when
|
|
59
|
-
* @throws {
|
|
60
|
-
* @throws {
|
|
61
|
-
* @throws {
|
|
62
|
-
* @throws {
|
|
63
|
-
* @throws {
|
|
64
|
-
* @throws {
|
|
65
|
-
* @throws {ReallocationWithdrawalOnTargetMarketError} when any reallocation withdrawal references
|
|
66
|
-
* the target market.
|
|
67
|
-
* @throws {UnsortedReallocationWithdrawalsError} when reallocation withdrawals are not strictly
|
|
68
|
-
* sorted by market id.
|
|
39
|
+
* @param params - Borrow encoding parameters.
|
|
40
|
+
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
41
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
42
|
+
* @param params.args.userAddress - User whose debt position is increased.
|
|
43
|
+
* @param params.args.borrowAssets - Gross loan assets borrowed.
|
|
44
|
+
* @param params.args.maxLtv - Maximum post-operation LTV.
|
|
45
|
+
* @param params.args.reallocations - Vault V2 reallocations executed before borrowing.
|
|
46
|
+
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
47
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee.
|
|
48
|
+
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
49
|
+
* @param params.args.authorizationSignature - Optional Blue authorization signature.
|
|
50
|
+
* @param params.metadata - Optional transaction metadata.
|
|
51
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueBorrowAction>>` whose calldata invokes the
|
|
52
|
+
* combined BlueBundlesV1 entrypoint with a zero collateral leg.
|
|
53
|
+
* @throws {NegativeInputError} when an amount, LTV, fee, or reallocation penalty is negative.
|
|
54
|
+
* @throws {NonPositiveInputError} when the borrow, deadline, or reallocation amount is not positive.
|
|
55
|
+
* @throws {InputExceedsMaxError} when a fee, reallocation amount, or penalty exceeds its bound.
|
|
56
|
+
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
57
|
+
* @throws {InvalidReallocationAddressError} when a vault or adapter address is malformed.
|
|
58
|
+
* @throws {InvalidReallocationSourceTypeError} when a reallocation source is malformed.
|
|
59
|
+
* @throws {InconsistentReallocationPenaltyError} when one vault uses different penalties.
|
|
60
|
+
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
61
|
+
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
62
|
+
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
63
|
+
* @throws {BlueBundlesV1RequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
64
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
65
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
69
66
|
* @example
|
|
70
67
|
* ```ts
|
|
68
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
71
69
|
* import { blueBorrow } from "@morpho-org/morpho-sdk";
|
|
70
|
+
* import { zeroAddress } from "viem";
|
|
71
|
+
* import { mainnet } from "viem/chains";
|
|
72
72
|
*
|
|
73
73
|
* const tx = blueBorrow({
|
|
74
|
-
* market: { chainId:
|
|
74
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
75
75
|
* args: {
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* userAddress: zeroAddress,
|
|
77
|
+
* borrowAssets: 1_000_000n,
|
|
78
|
+
* maxLtv: 850000000000000000n,
|
|
79
|
+
* deadline: 1_900_000_000n,
|
|
79
80
|
* },
|
|
80
81
|
* });
|
|
81
82
|
* // tx satisfies Readonly<Transaction<BlueBorrowAction>>
|
|
82
83
|
* ```
|
|
83
84
|
*/
|
|
84
|
-
export declare const blueBorrow: (
|
|
85
|
+
export declare const blueBorrow: (params: BlueBorrowParams) => Readonly<Transaction<BlueBorrowAction>>;
|