@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.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-v5-to-v6.md +206 -3
- package/README.md +81 -41
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +1 -1
- package/lib/cjs/actions/blue/borrow.js +1 -1
- package/lib/cjs/actions/blue/common.d.ts +6 -19
- package/lib/cjs/actions/blue/common.js +25 -138
- package/lib/cjs/actions/blue/refinance.d.ts +1 -1
- package/lib/cjs/actions/blue/refinance.js +1 -1
- package/lib/cjs/actions/blue/repay.d.ts +3 -3
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/actions/blue/supply.d.ts +3 -3
- package/lib/cjs/actions/blue/supply.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
- package/lib/cjs/actions/blue/withdraw.js +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
- package/lib/cjs/actions/bundles/common.d.ts +200 -0
- package/lib/cjs/actions/bundles/common.js +469 -0
- package/lib/cjs/actions/bundles/index.d.ts +3 -0
- package/lib/cjs/actions/bundles/index.js +23 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
- package/lib/cjs/actions/index.d.ts +1 -0
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeLend.js +2 -2
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +13 -13
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/index.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
- package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/cjs/actions/vaultV1/deposit.js +110 -109
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
- package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/cjs/actions/vaultV1/redeem.js +56 -33
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
- package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/cjs/actions/vaultV2/deposit.js +111 -109
- package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/cjs/actions/vaultV2/redeem.js +56 -34
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
- package/lib/cjs/entities/blue/blue.d.ts +19 -19
- package/lib/cjs/entities/blue/blue.js +3 -1
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +61 -65
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +17 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +5 -1
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +90 -1
- package/lib/cjs/helpers/slippage.js +123 -0
- package/lib/cjs/helpers/validate.d.ts +2 -0
- package/lib/cjs/helpers/validate.js +12 -1
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +179 -70
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +62 -14
- package/lib/cjs/types/error.js +88 -22
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +1 -1
- package/lib/esm/actions/blue/borrow.js +1 -1
- package/lib/esm/actions/blue/common.d.ts +6 -19
- package/lib/esm/actions/blue/common.js +27 -140
- package/lib/esm/actions/blue/refinance.d.ts +1 -1
- package/lib/esm/actions/blue/refinance.js +1 -1
- package/lib/esm/actions/blue/repay.d.ts +3 -3
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/esm/actions/blue/supply.d.ts +3 -3
- package/lib/esm/actions/blue/supply.js +1 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateral.js +1 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -1
- package/lib/esm/actions/blue/withdraw.js +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +200 -0
- package/lib/esm/actions/bundles/common.js +457 -0
- package/lib/esm/actions/bundles/index.d.ts +3 -0
- package/lib/esm/actions/bundles/index.js +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
- package/lib/esm/actions/index.d.ts +1 -0
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/takeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
- package/lib/esm/actions/midnight/takeLend.js +2 -2
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +11 -11
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/index.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
- package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/esm/actions/vaultV1/deposit.js +112 -111
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
- package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/esm/actions/vaultV1/redeem.js +56 -33
- package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/esm/actions/vaultV1/withdraw.js +86 -34
- package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/esm/actions/vaultV2/deposit.js +113 -111
- package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/esm/actions/vaultV2/redeem.js +56 -34
- package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/esm/actions/vaultV2/withdraw.js +86 -35
- package/lib/esm/entities/blue/blue.d.ts +19 -19
- package/lib/esm/entities/blue/blue.js +4 -2
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +51 -55
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +90 -1
- package/lib/esm/helpers/slippage.js +122 -2
- package/lib/esm/helpers/validate.d.ts +2 -0
- package/lib/esm/helpers/validate.js +11 -1
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +179 -70
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +62 -14
- package/lib/esm/types/error.js +80 -16
- package/package.json +3 -3
package/MIGRATION-v5-to-v6.md
CHANGED
|
@@ -5,6 +5,62 @@ write-method names while routing them through five direct BlueBundlesV1 entrypoi
|
|
|
5
5
|
versioned reallocation-data helpers remain on the same entity. There is no parallel BlueBundlesV1
|
|
6
6
|
extension or automatic fallback to the v5 route.
|
|
7
7
|
|
|
8
|
+
## Vault V1 and Vault V2 deposits
|
|
9
|
+
|
|
10
|
+
`MorphoVaultV1.deposit`, `MorphoVaultV2.deposit`, `vaultV1Deposit`, and `vaultV2Deposit` keep their
|
|
11
|
+
names but now route through the chain's registered VaultBundlesV1 contract instead of Bundler3 and
|
|
12
|
+
GeneralAdapter1.
|
|
13
|
+
|
|
14
|
+
> **Chain availability.** Vault deposits and withdrawals require the `bundles.vaultBundlesV1`
|
|
15
|
+
> deployment on the target chain. On a registered chain without it, including Fraxtal,
|
|
16
|
+
> `MorphoVaultV1.deposit()`, `MorphoVaultV2.deposit()`, `MorphoVaultV1.withdraw()`, and
|
|
17
|
+
> `MorphoVaultV2.withdraw()` throw `UnknownAddressError` synchronously at handle creation,
|
|
18
|
+
> before `getRequirements()` or `buildTx()` can be called. This is a breaking loss of deposit
|
|
19
|
+
> and withdrawal functionality on chains previously supported through Bundler3/GeneralAdapter1
|
|
20
|
+
> deposits and direct vault withdrawals; there is no automatic fallback. Confirm coverage before
|
|
21
|
+
> upgrading with `getChainAddresses(chainId).bundles?.vaultBundlesV1 != null`. Stay on v5 if your
|
|
22
|
+
> application needs deposits or withdrawals on an affected chain until VaultBundlesV1 is deployed
|
|
23
|
+
> and registered in the SDK.
|
|
24
|
+
|
|
25
|
+
As checked on 2026-09-07, the [official deployment list](https://docs.morpho.org/developers/contracts/addresses/#bundles)
|
|
26
|
+
and the [SDK registry](../morpho-ts/src/addresses.ts) list VaultBundlesV1 on 13 chains: Ethereum,
|
|
27
|
+
Arbitrum, Base, HyperEVM, Katana, Monad, Optimism, Polygon, Robinhood, Stable, Tempo, Unichain, and
|
|
28
|
+
World Chain. Bundler3 availability alone does not imply support for v6 vault deposits or withdrawals.
|
|
29
|
+
|
|
30
|
+
Update deposit inputs as follows:
|
|
31
|
+
|
|
32
|
+
| v5 | v6 |
|
|
33
|
+
| --- | --- |
|
|
34
|
+
| `amount` plus optional additive `nativeAmount` | Choose exactly one positive `amount` or `nativeAmount`. |
|
|
35
|
+
| Low-level `args.recipient` | Remove it. VaultBundlesV1 mints shares to `msg.sender`; `userAddress` must be the signing and submitting account. |
|
|
36
|
+
| Optional Bundler3 `PermitRequirementSignature` | Use an ERC-2612 or Permit2 SignatureTransfer requirement returned by the prepared entity handle. |
|
|
37
|
+
| No deadline or referral fee | Entity methods accept an optional `deadline` that defaults to two hours from preparation; low-level builders require it. Both surfaces accept optional `referralFeePct` and `referralFeeRecipient`. |
|
|
38
|
+
|
|
39
|
+
For ERC-20 funding, approvals and ERC-2612 permits now name VaultBundlesV1 as spender. Permit2
|
|
40
|
+
keeps its ERC-20 approval on canonical Permit2, while its one-time SignatureTransfer payload names
|
|
41
|
+
VaultBundlesV1. Resolve requirements and build from the same prepared handle so its captured nonce,
|
|
42
|
+
deadline, asset, owner, amount, and spender remain consistent:
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
const deposit = vault.deposit({
|
|
46
|
+
amount: 1_000_000n,
|
|
47
|
+
userAddress,
|
|
48
|
+
vaultData,
|
|
49
|
+
referralFeePct,
|
|
50
|
+
referralFeeRecipient,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const requirements = await deposit.getRequirements({ permit2Nonce });
|
|
54
|
+
// Submit approval transactions or sign the returned token requirement first.
|
|
55
|
+
const tx = deposit.buildTx(requirementSignature ? [requirementSignature] : undefined);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Deposit action metadata no longer contains `recipient`. It now reports the gross `amount`, optional
|
|
59
|
+
`nativeAmount`, `maxSharePrice`, `referralFeePct`, `referralFeeRecipient`, exact
|
|
60
|
+
`referralFeeAssets`, resulting `netAssets`, and `deadline`.
|
|
61
|
+
|
|
62
|
+
## Blue write routing
|
|
63
|
+
|
|
8
64
|
> **Chain availability.** The direct BlueBundlesV1 route requires the `bundles.blueBundlesV1`
|
|
9
65
|
> deployment on the target chain. On a registered chain without it (the previous Bundler3-routed
|
|
10
66
|
> flows covered more chains), **every** Blue write — `supply`, `supplyCollateral`, `borrow`,
|
|
@@ -13,6 +69,57 @@ extension or automatic fallback to the v5 route.
|
|
|
13
69
|
> `validateWriteCommon`). Confirm coverage before upgrading, for example
|
|
14
70
|
> `getChainAddresses(chainId).bundles?.blueBundlesV1 != null`.
|
|
15
71
|
|
|
72
|
+
Version 6 also preserves the Vault V1 and Vault V2 method and builder names while routing `deposit`,
|
|
73
|
+
`withdraw`, and `redeem` through VaultBundlesV1. Vault V1 `migrateToV2` uses the same fixed route.
|
|
74
|
+
|
|
75
|
+
> **Chain availability.** The VaultBundlesV1 route requires the `bundles.vaultBundlesV1` deployment
|
|
76
|
+
> on the target chain. On a registered chain without it (Celo, for example, still registers
|
|
77
|
+
> MetaMorpho and Vault V2 deployments), **every** routed vault write — Vault V1 `deposit`,
|
|
78
|
+
> `withdraw`, `redeem`, and `migrateToV2`, and Vault V2 `deposit`, `withdraw`, and `redeem` — throws
|
|
79
|
+
> `UnknownAddressError` synchronously at handle creation, where v5 built a direct vault or Bundler3
|
|
80
|
+
> call. Confirm coverage before upgrading, for example
|
|
81
|
+
> `getChainAddresses(chainId).bundles?.vaultBundlesV1 != null`. Vault `inKindRedeem` is unaffected:
|
|
82
|
+
> it already routed through `bundles.vaultExitBundlesV1` in v5, and its chain coverage is unchanged.
|
|
83
|
+
|
|
84
|
+
## Update Vault V1 and Vault V2 methods
|
|
85
|
+
|
|
86
|
+
| Stable method | v5 input/workflow | v6 input/workflow |
|
|
87
|
+
| --- | --- | --- |
|
|
88
|
+
| `deposit` | Additive `amount` and `nativeAmount`; Bundler3/GeneralAdapter1 requirements. | Supply exactly one of `amount` or `nativeAmount`; optionally set `deadline`, `referralFeePct`, and `referralFeeRecipient`. Token requirements authorize VaultBundlesV1 and may return Permit2 SignatureTransfer. |
|
|
89
|
+
| `withdraw` | Direct vault withdrawal with no share requirement. | Exact-assets VaultBundlesV1 exit. Optionally set `slippageTolerance`, `deadline`, and referral fields; resolve a vault-share approval or ERC-2612 permit before building. |
|
|
90
|
+
| `redeem` | Direct vault redemption with no share requirement. | Exact-shares VaultBundlesV1 exit. Optionally set `deadline` and referral fields; resolve a vault-share approval or ERC-2612 permit before building. |
|
|
91
|
+
| `migrateToV2` (Vault V1 only) | Share-denominated Bundler3 migration with a source `minSharePriceVaultV1`. | Keep the existing `shares` mode or supply the new `assets` alternative; remove the source share-price bound; optionally set `slippageTolerance`, `deadline`, and referral fields. Resolve source-vault share authorization before building. The destination deposit retains its onchain maximum-share-price bound. |
|
|
92
|
+
|
|
93
|
+
`userAddress` now means the account that will submit the transaction. VaultBundlesV1 always deposits
|
|
94
|
+
for, burns shares from, and pays `msg.sender`; arbitrary `recipient` and `onBehalf` values are no
|
|
95
|
+
longer supported. Keep `userAddress` equal to the eventual signer, including when preparing a
|
|
96
|
+
transaction with a public client.
|
|
97
|
+
|
|
98
|
+
The lazy workflow now applies to Vault V1 exits as well as deposits: await `getRequirements()`, send
|
|
99
|
+
any returned approval transactions or collect the returned signature, and pass collected signatures
|
|
100
|
+
to `buildTx(signatures)`. Deposit requirement options accept `useSimplePermit` and an explicit
|
|
101
|
+
`permit2Nonce`; exit requirements use the vault share token's ERC-2612 permit. The built transaction
|
|
102
|
+
targets VaultBundlesV1 rather than Bundler3 or the vault itself.
|
|
103
|
+
|
|
104
|
+
Pure builder names remain stable, but their `args` objects change:
|
|
105
|
+
|
|
106
|
+
| Stable builder | v6 `args` fields |
|
|
107
|
+
| --- | --- |
|
|
108
|
+
| `vaultV1Deposit` | Exclusive `amount`/`nativeAmount`, `maxSharePrice`, `userAddress`, optional bundles token `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
109
|
+
| `vaultV1Withdraw` | `amount`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
110
|
+
| `vaultV1Redeem` | `shares`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
111
|
+
| `vaultV1MigrateToV2` | Exclusive `assets`/`shares`, `targetVault`, `targetAsset`, `maxSharePriceVaultV2`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
112
|
+
| `vaultV2Deposit` | Exclusive `amount`/`nativeAmount`, `maxSharePrice`, `userAddress`, optional bundles token `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
113
|
+
| `vaultV2Withdraw` | `amount`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
114
|
+
| `vaultV2Redeem` | `shares`, `userAddress`, optional vault-share `requirementSignature`, required `deadline`, and optional referral fields. |
|
|
115
|
+
|
|
116
|
+
Every vault builder replaces v5's `recipient` and `onBehalf` with a single `userAddress` that must be
|
|
117
|
+
the eventual `msg.sender`, and `vault` now takes `{ chainId, address }` (plus `asset` on the deposit
|
|
118
|
+
and migration builders) so the builder can resolve the VaultBundlesV1 address for the target chain.
|
|
119
|
+
|
|
120
|
+
Vault V1 deposit and migration destination bounds are forecast through the selected deadline, so an
|
|
121
|
+
explicit deadline beyond the two-hour default remains covered by the computed maximum share price.
|
|
122
|
+
|
|
16
123
|
## Update Blue methods
|
|
17
124
|
|
|
18
125
|
| Stable method | v5 input | v6 input |
|
|
@@ -30,7 +137,38 @@ extension or automatic fallback to the v5 route.
|
|
|
30
137
|
The two combined methods require at least one non-zero leg. See the dedicated **Blue refinance**
|
|
31
138
|
section below for that method's larger shape change.
|
|
32
139
|
|
|
33
|
-
##
|
|
140
|
+
## Vault V1 and V2 withdrawals
|
|
141
|
+
|
|
142
|
+
The established `withdraw` methods and the `vaultV1Withdraw` / `vaultV2Withdraw` builder names stay
|
|
143
|
+
stable, but now encode one direct VaultBundlesV1 call instead of a direct vault call.
|
|
144
|
+
|
|
145
|
+
> **Chain availability.** Both entity `withdraw()` methods require `bundles.vaultBundlesV1` and
|
|
146
|
+
> throw `UnknownAddressError` synchronously at handle creation on registered chains without it,
|
|
147
|
+
> including Fraxtal. Stay on v5 if your application needs withdrawals on an affected chain until
|
|
148
|
+
> VaultBundlesV1 is deployed and registered in the SDK, even if your application makes no deposits.
|
|
149
|
+
|
|
150
|
+
| Flow | v5 input | v6 input |
|
|
151
|
+
| --- | --- | --- |
|
|
152
|
+
| `withdraw` | `amount`, `userAddress` | Keep `amount` and `userAddress`; remove the implicit `recipient` / `onBehalf` (VaultBundlesV1 burns `msg.sender`'s shares and pays `msg.sender`); add optional `slippageTolerance`, `deadline`, and referral-fee fields. |
|
|
153
|
+
|
|
154
|
+
`withdraw` now returns `{ buildTx, getRequirements }` instead of `{ buildTx }`. VaultBundlesV1 spends
|
|
155
|
+
the caller's vault shares, so the withdrawal needs a vault-share allowance for VaultBundlesV1 — a
|
|
156
|
+
prerequisite v5 withdrawals did not have. Await `getRequirements()` and satisfy it before calling
|
|
157
|
+
`buildTx()`, or the withdrawal reverts:
|
|
158
|
+
|
|
159
|
+
- Without signature support, it returns one ERC-20 approval transaction to send first.
|
|
160
|
+
- With `supportSignature: true`, it returns one signable ERC-2612 shares permit; pass the signature
|
|
161
|
+
to `buildTx([sharesPermit])` and it is folded into the VaultBundlesV1 call.
|
|
162
|
+
|
|
163
|
+
The allowance is the only cap on the burn, since asset-mode calldata carries no maximum-shares
|
|
164
|
+
argument. `getRequirements()` therefore derives an exact cap from the vault snapshot, the deadline,
|
|
165
|
+
and `slippageTolerance` (default 0.03%), and returns an approval or permit for exactly that amount
|
|
166
|
+
whenever the current allowance differs — including when a larger leftover approval already exists.
|
|
167
|
+
|
|
168
|
+
`getRequirements()` re-validates the deadline on every call, so a prepared withdrawal reused after
|
|
169
|
+
its deadline throws `ExpiredDeadlineError` rather than returning cached prerequisites.
|
|
170
|
+
|
|
171
|
+
## Blue pure action builder inputs and metadata
|
|
34
172
|
|
|
35
173
|
Direct action consumers keep the root-barrel builder and parameter-type names, but must replace
|
|
36
174
|
their `args` objects as follows. `metadata` is unchanged.
|
|
@@ -113,7 +251,7 @@ high-level writes.
|
|
|
113
251
|
SignatureTransfer consumes an owner-global unordered nonce rather than an allowance, so the SDK no
|
|
114
252
|
longer allocates one implicitly. For a client with `supportSignature: true`, the default supply
|
|
115
253
|
requirement path selects Permit2 and `supply(...).getRequirements()` now throws
|
|
116
|
-
`
|
|
254
|
+
`MissingPermit2SignatureTransferNonceError` when no nonce is supplied. Pass an unused nonce explicitly:
|
|
117
255
|
|
|
118
256
|
```ts
|
|
119
257
|
const requirements = await market
|
|
@@ -122,7 +260,7 @@ const requirements = await market
|
|
|
122
260
|
```
|
|
123
261
|
|
|
124
262
|
Allocate any `uint256` whose Permit2 `nonceBitmap` bit is still unset for `userAddress` (each nonce
|
|
125
|
-
is single-use; a consumed one throws `
|
|
263
|
+
is single-use; a consumed one throws `Permit2SignatureTransferNonceAlreadyUsedError`). To skip Permit2
|
|
126
264
|
for ERC-2612 tokens, pass `getRequirements({ useSimplePermit: true })`, which prefers a one-signature
|
|
127
265
|
ERC-2612 permit and needs no nonce.
|
|
128
266
|
|
|
@@ -191,11 +329,76 @@ The `BlueReallocationPlan` union is removed. High-level Blue write inputs accept
|
|
|
191
329
|
`Iterable<VaultV2BlueReallocation>` directly; for explicit low-level Vault V1 composition, use
|
|
192
330
|
`VaultV1Reallocation[]`.
|
|
193
331
|
|
|
332
|
+
## Update Vault V1 and Vault V2 writes
|
|
333
|
+
|
|
334
|
+
Vault V1 and Vault V2 keep their existing `deposit`, `withdraw`, and `redeem` names, while Vault V1
|
|
335
|
+
keeps `migrateToV2`. In v6 these methods encode one direct `VaultBundlesV1` call instead of a direct
|
|
336
|
+
ERC-4626 call or Bundler3 multicall.
|
|
337
|
+
|
|
338
|
+
- Deposits accept exactly one of `amount` and `nativeAmount`. Split a former additive ETH + WETH
|
|
339
|
+
deposit into two transactions. Classic approvals and ERC-2612 permits now authorize
|
|
340
|
+
VaultBundlesV1; Permit2 uses SignatureTransfer and requires an explicit unused `permit2Nonce`.
|
|
341
|
+
- Remove `recipient` from deposits and remove `recipient` and `onBehalf` from exits. VaultBundlesV1
|
|
342
|
+
always operates for and pays `msg.sender`. `userAddress` now means the account that must submit the
|
|
343
|
+
transaction. A connected builder account may prepare a transaction for a different submitter;
|
|
344
|
+
identity-bound signature helpers still enforce `userAddress` when signing.
|
|
345
|
+
- `withdraw` and `redeem` now return a full `ActionOutput`. Call `getRequirements()` and satisfy the
|
|
346
|
+
exact vault-share approval or ERC-2612 permit before calling `buildTx(signatures)`.
|
|
347
|
+
- Vault calls gain `deadline`, `referralFeePct`, and `referralFeeRecipient`. Entity deadlines default
|
|
348
|
+
to two hours; pure builder callers provide them explicitly. Amounts remain gross, and fixed-asset
|
|
349
|
+
action metadata reports `referralFeeAssets` and `netAssets`.
|
|
350
|
+
- `migrateToV2` accepts exactly one of `assets` and `shares`, removes `recipient` and source
|
|
351
|
+
`minSharePriceVaultV1`, and retains only the destination `maxSharePriceVaultV2` bound.
|
|
352
|
+
|
|
353
|
+
VaultBundlesV1 permits only one call to itself in a transaction. Do not put two vault calls into one
|
|
354
|
+
Safe multisend or EIP-5792 batch; use `migrateToV2` for an atomic V1-to-V2 move. Permissioned Vault
|
|
355
|
+
V2 deployments must allow VaultBundlesV1 in both send-assets and receive-assets gates. Because gates
|
|
356
|
+
can inspect the bundle's transient initiator, validate them by simulating the finalized transaction
|
|
357
|
+
after satisfying requirements rather than by pre-reading the gate.
|
|
358
|
+
|
|
359
|
+
```ts
|
|
360
|
+
const withdrawal = vault.withdraw({ amount, userAddress });
|
|
361
|
+
const signatures = [];
|
|
362
|
+
for (const requirement of await withdrawal.getRequirements()) {
|
|
363
|
+
if ("sign" in requirement) {
|
|
364
|
+
signatures.push(await requirement.sign(walletClient, userAddress));
|
|
365
|
+
} else {
|
|
366
|
+
const hash = await walletClient.sendTransaction(requirement);
|
|
367
|
+
await publicClient.waitForTransactionReceipt({ hash });
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
const transaction = withdrawal.buildTx(signatures);
|
|
371
|
+
```
|
|
372
|
+
|
|
194
373
|
## Upgrade checklist
|
|
195
374
|
|
|
375
|
+
- Confirm `bundles.vaultBundlesV1` coverage for vault deposits and withdrawals and
|
|
376
|
+
`bundles.blueBundlesV1` coverage for Blue writes on every chain your application supports.
|
|
377
|
+
Stay on v5 if you need vault deposits or withdrawals on a chain without VaultBundlesV1.
|
|
196
378
|
- Update every Blue write call using the table above; method names remain stable.
|
|
197
379
|
- Remove Blue slippage and PublicAllocator V1 write inputs.
|
|
198
380
|
- Re-run approval and Morpho-authorization setup against the new spender/operator.
|
|
199
381
|
- Update transaction decoding, simulation fixtures, and action metadata fields; discriminator
|
|
200
382
|
names remain stable.
|
|
201
383
|
- Test native funding, full repay, and full-position migration paths used by the application.
|
|
384
|
+
|
|
385
|
+
## Fixed-bundles token requirement APIs
|
|
386
|
+
|
|
387
|
+
The Blue-only fixed-bundles requirement surface is generalized into a shared surface used by both
|
|
388
|
+
BlueBundlesV1 and VaultBundlesV1.
|
|
389
|
+
|
|
390
|
+
| v5 symbol | v6 replacement |
|
|
391
|
+
| --- | --- |
|
|
392
|
+
| `getBlueBundlesV1TokenRequirements` (action-layer) | `getBundlesTokenRequirements` (entity-layer; reads state, so it now lives under `entities/requirements` instead of `actions/requirements/blue`). Takes the same funding parameters plus a `spender` naming the registered fixed bundles deployment (BlueBundlesV1 or VaultBundlesV1). |
|
|
393
|
+
| `BlueBundlesV1TokenSignatureRequirement` / `BlueBundlesV1TokenRequirementSignature` | `BundlesTokenSignatureRequirement` / `BundlesTokenRequirementSignature` |
|
|
394
|
+
| `encodeErc20Permit2TransferFrom` | `encodeErc20Permit2SignatureTransfer` |
|
|
395
|
+
| Action discriminator `"permit2TransferFrom"` | `"permit2SignatureTransfer"` |
|
|
396
|
+
| `Permit2TransferFromAction` / `Permit2TransferFromRequirementSignature` | `Permit2SignatureTransferAction` / `Permit2SignatureTransferRequirementSignature` |
|
|
397
|
+
| `isPermit2TransferFromSignature` | `isPermit2SignatureTransferSignature` |
|
|
398
|
+
| `selectRequirementSignatures` option and result field `permit2TransferFrom` | `permit2SignatureTransfer` |
|
|
399
|
+
| `MissingPermit2TransferFromNonceError` | `MissingPermit2SignatureTransferNonceError` (old name kept as a `@deprecated` alias) |
|
|
400
|
+
| `Permit2TransferFromNonceAlreadyUsedError` | `Permit2SignatureTransferNonceAlreadyUsedError` (old name kept as a `@deprecated` alias) |
|
|
401
|
+
|
|
402
|
+
Update call sites and `switch`/discriminated-union checks on `action.type` to the new
|
|
403
|
+
`"permit2SignatureTransfer"` tag; the signed payload shape (`nonce`, `deadline`, `signature`) is
|
|
404
|
+
unchanged.
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
> 📖 **Full documentation → [docs.morpho.org/developers/sdks/morpho-sdk](https://docs.morpho.org/developers/sdks/morpho-sdk/)**
|
|
9
9
|
|
|
10
|
-
Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**, and **Midnight** fixed-rate markets on
|
|
10
|
+
Build transactions for Morpho's **VaultV1** (MetaMorpho), **VaultV2**, **Blue**, and **Midnight** fixed-rate markets on chains with the required protocol and periphery deployments. Custom deployments can be added with `registerCustomAddresses` from `@morpho-org/morpho-sdk/addresses`.
|
|
11
11
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
@@ -15,21 +15,19 @@ 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
|
|
19
|
-
write integrations.
|
|
18
|
+
Upgrading from v5? Read the [v5 → v6 migration guide](./MIGRATION-v5-to-v6.md) before updating vault
|
|
19
|
+
deposit or Blue write integrations.
|
|
20
20
|
|
|
21
21
|
## Actions
|
|
22
22
|
|
|
23
|
-
Each entity exposes a set of actions.
|
|
24
|
-
|
|
23
|
+
Each entity exposes a set of actions. Common vault writes call VaultBundlesV1, Blue writes call
|
|
24
|
+
BlueBundlesV1, and the remaining rows identify their destination.
|
|
25
25
|
|
|
26
26
|
| Entity | Actions | Route |
|
|
27
27
|
| --- | --- | --- |
|
|
28
|
-
| **VaultV1** (MetaMorpho) | `deposit`, `migrateToV2` |
|
|
29
|
-
| | `withdraw`, `redeem` | Direct call |
|
|
28
|
+
| **VaultV1** (MetaMorpho) | `deposit`, `withdraw`, `redeem`, `migrateToV2` | VaultBundlesV1 |
|
|
30
29
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
31
|
-
| **VaultV2** | `deposit` |
|
|
32
|
-
| | `withdraw`, `redeem` | Direct call |
|
|
30
|
+
| **VaultV2** | `deposit`, `withdraw`, `redeem` | VaultBundlesV1 |
|
|
33
31
|
| | `forceWithdraw`, `forceRedeem` | Vault multicall |
|
|
34
32
|
| | `inKindRedeem` | VaultExitBundlesV1 |
|
|
35
33
|
| **Blue** | `supply`, `withdraw`, `supplyCollateral`, `borrow`, `supplyCollateralBorrow`, `repay`, `withdrawCollateral`, `repayWithdrawCollateral`, `refinance` | BlueBundlesV1 |
|
|
@@ -44,17 +42,17 @@ Robinhood Chain. Custom deployments can still be configured with `registerCustom
|
|
|
44
42
|
## How it works
|
|
45
43
|
|
|
46
44
|
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
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
`forceRedeem` — have no prerequisites and return only `{ buildTx }`.
|
|
45
|
+
writes use this lazy shape while still encoding one direct BlueBundlesV1 call. Vault deposits and
|
|
46
|
+
exits use the same shape for token or exact share authorization. Vault `inKindRedeem` additionally
|
|
47
|
+
checks live Blue liquidity. Calling `buildTx()` directly skips RPC-backed pre-flight checks.
|
|
48
|
+
`forceWithdraw` and `forceRedeem` remain direct Vault V2 multicalls without prerequisites.
|
|
52
49
|
|
|
53
50
|
- **`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.
|
|
54
51
|
- **`buildTx(signatures?)`** — synchronous; the final, deep-frozen viem transaction. Pass any signatures collected from the requirements.
|
|
55
52
|
|
|
56
53
|
```typescript
|
|
57
|
-
const
|
|
54
|
+
const vaultData = await vault.getData();
|
|
55
|
+
const { buildTx, getRequirements } = vault.deposit({ amount, userAddress, vaultData });
|
|
58
56
|
|
|
59
57
|
const requirements = await getRequirements();
|
|
60
58
|
// Send each approval tx and collect each signature, then:
|
|
@@ -63,12 +61,12 @@ const tx = buildTx([permitSignature]);
|
|
|
63
61
|
|
|
64
62
|
Enable off-chain approvals (permit / Permit2) with `morphoViemExtension({ supportSignature: true })`.
|
|
65
63
|
|
|
66
|
-
### `userAddress`
|
|
64
|
+
### `userAddress` is the eventual submitter
|
|
67
65
|
|
|
68
|
-
`userAddress` must be the account that signs and sends the transaction.
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
66
|
+
`userAddress` must be the account that eventually signs and sends the transaction. A connected
|
|
67
|
+
builder account may prepare a direct bundles call for a different submitter; signature helpers
|
|
68
|
+
enforce the expected identity at `sign()`. VaultBundlesV1 and BlueBundlesV1 always operate on
|
|
69
|
+
`msg.sender`.
|
|
72
70
|
|
|
73
71
|
## Usage
|
|
74
72
|
|
|
@@ -101,30 +99,73 @@ Create an entity — every factory takes a chain ID as its last argument:
|
|
|
101
99
|
|
|
102
100
|
### Vault deposit / withdraw
|
|
103
101
|
|
|
104
|
-
Deposit
|
|
102
|
+
Deposit calls VaultBundlesV1 and may require an approval or permit. ERC-20 approvals and ERC-2612
|
|
103
|
+
permits authorize VaultBundlesV1. Permit2 SignatureTransfer also names VaultBundlesV1 as spender,
|
|
104
|
+
while the ERC-20 approval prerequisite targets canonical Permit2.
|
|
105
105
|
|
|
106
106
|
```typescript
|
|
107
107
|
const vault = client.morpho.vaultV2("0xVault...", 1);
|
|
108
|
-
|
|
109
|
-
const { buildTx, getRequirements } =
|
|
108
|
+
const vaultData = await vault.getData();
|
|
109
|
+
const { buildTx, getRequirements } = vault.deposit({
|
|
110
110
|
amount: 1000000000000000000n,
|
|
111
111
|
userAddress: "0xUser...",
|
|
112
|
+
vaultData,
|
|
112
113
|
});
|
|
113
114
|
const requirements = await getRequirements();
|
|
114
115
|
const tx = buildTx([permitSignature]);
|
|
115
116
|
```
|
|
116
117
|
|
|
117
|
-
Withdraw is a
|
|
118
|
+
Withdraw is a VaultBundlesV1 call that burns the caller's shares, so it needs the exact share
|
|
119
|
+
allowance returned by `getRequirements()`:
|
|
118
120
|
|
|
119
121
|
```typescript
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
import { morphoViemExtension } from "@morpho-org/morpho-sdk";
|
|
123
|
+
import {
|
|
124
|
+
createPublicClient,
|
|
125
|
+
createWalletClient,
|
|
126
|
+
custom,
|
|
127
|
+
http,
|
|
128
|
+
type EIP1193Provider,
|
|
129
|
+
} from "viem";
|
|
130
|
+
import { mainnet } from "viem/chains";
|
|
131
|
+
|
|
132
|
+
async function withdrawUsdc(provider: EIP1193Provider, supportSignature = false) {
|
|
133
|
+
const client = createPublicClient({ chain: mainnet, transport: http() }).extend(
|
|
134
|
+
morphoViemExtension({ supportSignature }),
|
|
135
|
+
);
|
|
136
|
+
const walletClient = createWalletClient({ chain: mainnet, transport: custom(provider) });
|
|
137
|
+
const [userAddress] = await walletClient.requestAddresses();
|
|
138
|
+
if (!userAddress) throw new Error("Connect a wallet account before withdrawing.");
|
|
139
|
+
const vault = client.morpho.vaultV2("0x04422053aDDbc9bB2759b248B574e3FCA76Bc145", mainnet.id);
|
|
140
|
+
const withdrawal = vault.withdraw({ amount: 500_000n, userAddress });
|
|
141
|
+
const requirements = await withdrawal.getRequirements();
|
|
142
|
+
const requirement = requirements[0];
|
|
143
|
+
|
|
144
|
+
if (requirement && "sign" in requirement) {
|
|
145
|
+
// With signature support enabled, sign the vault-share permit for this handle.
|
|
146
|
+
const signedPermit = await requirement.sign(walletClient, userAddress);
|
|
147
|
+
return walletClient.sendTransaction({
|
|
148
|
+
...withdrawal.buildTx([signedPermit]),
|
|
149
|
+
account: userAddress,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
for (const approval of requirements) {
|
|
154
|
+
if ("to" in approval) {
|
|
155
|
+
const hash = await walletClient.sendTransaction({ ...approval, account: userAddress });
|
|
156
|
+
const receipt = await client.waitForTransactionReceipt({ hash });
|
|
157
|
+
if (receipt.status !== "success") throw new Error("The share approval reverted.");
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
// Approval is confirmed, or the exact allowance was already in place.
|
|
161
|
+
return walletClient.sendTransaction({ ...withdrawal.buildTx(), account: userAddress });
|
|
162
|
+
}
|
|
163
|
+
// await withdrawUsdc(provider) returns the withdrawal transaction hash.
|
|
164
|
+
// Pass true as the second argument to use a signed share permit instead of an approval.
|
|
125
165
|
```
|
|
126
166
|
|
|
127
|
-
For wNative vaults, pass `nativeAmount` instead of `amount
|
|
167
|
+
For wNative vaults, pass `nativeAmount` instead of `amount`. The transaction sends that amount as
|
|
168
|
+
`tx.value` to VaultBundlesV1, which wraps it internally; native deposits require no token permit.
|
|
128
169
|
|
|
129
170
|
### Blue: BlueBundlesV1 writes
|
|
130
171
|
|
|
@@ -219,11 +260,11 @@ graph LR
|
|
|
219
260
|
MV1 --> V1IKR[vaultV1InKindRedeem]
|
|
220
261
|
MV1 --> V1M[vaultV1MigrateToV2]
|
|
221
262
|
|
|
222
|
-
V1D
|
|
223
|
-
V1W
|
|
224
|
-
V1R
|
|
263
|
+
V1D --> VBV1[VaultBundlesV1]
|
|
264
|
+
V1W --> VBV1
|
|
265
|
+
V1R --> VBV1
|
|
266
|
+
V1M --> VBV1
|
|
225
267
|
V1IKR -->|direct call| VEB[VaultExitBundlesV1]
|
|
226
|
-
V1M -->|erc20TransferFrom + erc4626Redeem + erc4626Deposit| B1
|
|
227
268
|
end
|
|
228
269
|
|
|
229
270
|
subgraph VaultV2 Flow
|
|
@@ -235,11 +276,11 @@ graph LR
|
|
|
235
276
|
MV2 --> V2FW[vaultV2ForceWithdraw]
|
|
236
277
|
MV2 --> V2FR[vaultV2ForceRedeem]
|
|
237
278
|
|
|
238
|
-
V2D
|
|
239
|
-
V2W
|
|
240
|
-
V2R
|
|
279
|
+
V2D --> VBV1
|
|
280
|
+
V2W --> VBV1
|
|
281
|
+
V2R --> VBV1
|
|
241
282
|
V2IKR -->|direct call| VEB
|
|
242
|
-
V2FW -->|multicall| V2C
|
|
283
|
+
V2FW -->|multicall| V2C[VaultV2 Contract]
|
|
243
284
|
V2FR -->|multicall| V2C
|
|
244
285
|
end
|
|
245
286
|
|
|
@@ -288,10 +329,9 @@ graph LR
|
|
|
288
329
|
MM1 -.->|approval / permit / authorization| REQ
|
|
289
330
|
MN1 -.->|approval / authorization / root signature or ratification| REQ
|
|
290
331
|
|
|
291
|
-
style
|
|
292
|
-
style B2 fill:#e8f5e9,stroke:#4caf50
|
|
332
|
+
style VBV1 fill:#e8f5e9,stroke:#4caf50
|
|
293
333
|
style BBV1 fill:#e8f5e9,stroke:#4caf50
|
|
294
|
-
style
|
|
334
|
+
style VEB fill:#fff3e0,stroke:#ff9800
|
|
295
335
|
style V2C fill:#e3f2fd,stroke:#2196f3
|
|
296
336
|
style REQ fill:#f3e5f5,stroke:#9c27b0
|
|
297
337
|
style BPA fill:#fff9c4,stroke:#f9a825
|