Bundles
Bundles structure
Most Bundle entrypoints share the same building blocks:
- Token permits - each underlying token the Bundle pulls from the caller accepts an optional
TokenPermit, either an ERC-2612permitor a Permit2SignatureTransfer, so the approval and the operation land in one transaction. An empty permit means the caller granted a standard ERC-20 allowance to the Bundle beforehand. - Share permits - share-based entrypoints (
vaultBundlesV1Withdraw,vaultBundlesV1Migrate, and everyvaultExitBundlesV1*entrypoint) take an ERC-2612Permiton the vault shares instead, or rely on a prior share allowance to the Bundle. Shares never go through Permit2. - Signed authorization -
BlueBundlesV1entrypoints that act on the caller's Morpho position (borrow, withdraw, repay-and-withdraw-collateral, migrate) accept an optional MorphoSignedAuthorizationso the caller can authorize the Bundle in the same transaction. An empty signature means the Bundle is already authorized. Vault entrypoints take share permits, not Morpho authorizations. - Public allocations - entrypoints that consume market liquidity accept a list of Vault V2
BluePublicAllocatorreallocations executed before the operation. - Referral fee and deadline - every entrypoint except the two in-kind redemptions takes a caller-chosen
referralFeePct(WAD-scaled, strictly belowWAD) andreferralFeeRecipient, plus a call deadline after which the transaction reverts. The fee is paid in the loan or vault asset to the recipient within the same transaction, so integrators can use it to monetize their integration without any extra contract. On borrow and withdraw entrypoints (includingvaultExitBundlesV1ForceWithdrawVaultV2) the fee is taken from the proceeds, after any public allocator penalties; on supply and deposit it is deducted from the supplied amount; on repay it is charged on top of the repaid amount (fee = repaidAssets * referralFeePct / (WAD - referralFeePct)). OnblueBundlesV1MigrateBorrowPositionthe fee and any public allocator penalties are borrowed on top of the migrated debt, so they increase the debt on the destination market; onvaultBundlesV1Migratethe fee is deducted from the withdrawn assets before the deposit into the destination vault. Pass0for no fee. See How to monetize your borrow product.
The deployment addresses of every Bundle are listed in the addresses page.
BlueBundlesV1
Entrypoints for Variable Rate Markets (Morpho Blue):
| Entrypoint | What it does |
|---|---|
blueBundlesV1Supply | Supply loan assets to a market. |
blueBundlesV1Withdraw | Withdraw supplied loan assets, by assets or by shares. |
blueBundlesV1SupplyCollateralAndBorrow | Supply collateral and borrow, bounded by a maxLtv check. |
blueBundlesV1RepayAndWithdrawCollateral | Repay debt, by assets or by shares, and withdraw collateral, bounded by a maxLtv check. |
blueBundlesV1MigrateBorrowPosition | Move a full borrow position (collateral and debt) from one market to another in one transaction - the source debt is repaid atomically with assets borrowed on the destination market, so the caller needs no repay funds. |
blueBundlesV1SupplyCollateralAndBorrow, blueBundlesV1Withdraw and blueBundlesV1MigrateBorrowPosition accept Vault V2 BluePublicAllocator reallocations.
VaultBundlesV1
Entrypoints for Vault V1 and Vault V2:
| Entrypoint | What it does |
|---|---|
vaultBundlesV1Deposit | Deposit assets into a vault. |
vaultBundlesV1Withdraw | Withdraw assets from a vault. |
vaultBundlesV1Migrate | Migrate assets from one vault to another vault. |
VaultExitBundlesV1
Exit paths for vaults whose liquidity is constrained:
| Entrypoint | What it does |
|---|---|
vaultExitBundlesV1InKindRedemptionVaultV1 | Redeem in kind from an illiquid Vault V1. |
vaultExitBundlesV1InKindRedemptionVaultV2 | Withdraw idle assets and redeem the remainder in kind from an illiquid Vault V2. |
vaultExitBundlesV1ForceWithdrawVaultV2 | Force withdraw assets from an illiquid Vault V2 whose underlying markets are liquid, paying the force-deallocate penalty (idle and liquidity-adapter assets are withdrawn penalty-free first). |
Midnight Bundles
Taker entrypoints (MidnightBundlesV1) - taking offers by units or assets target, supplying collateral and selling, and repaying and withdrawing collateral - for Midnight are documented in the Midnight resources.
Permit2
In November 2022, Uniswap Labs introduced Permit2, a robust token approval contract designed to standardize and secure token approvals across various smart contracts. By enabling signature-based approvals and efficient management of token allowances, Permit2 significantly enhances the user experience. It reduces transaction costs and bolsters smart contract security by mitigating risks associated with traditional approval methods.
Bundles accept Permit2 SignatureTransfer permits, naming the Bundle as spender, as an alternative to ERC-2612 permits and standard ERC-20 approvals. Discover the full potential of Permit2 and how it revolutionizes token approvals in the integration guide.
Bundler3 (deprecated)
Bundles are protocol-specific by design. Flows that Bundler3 enabled through arbitrary call composition - DEX swaps and leverage via ParaswapAdapter, migrations from other lending protocols via the migration adapters, and Vault V1 PublicAllocator reallocations - have no Bundle equivalent today.