Bundles

Bundles repository

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-2612 permit or a Permit2 SignatureTransfer, 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 every vaultExitBundlesV1* entrypoint) take an ERC-2612 Permit on the vault shares instead, or rely on a prior share allowance to the Bundle. Shares never go through Permit2.
  • Signed authorization - BlueBundlesV1 entrypoints that act on the caller's Morpho position (borrow, withdraw, repay-and-withdraw-collateral, migrate) accept an optional Morpho SignedAuthorization so 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 BluePublicAllocator reallocations executed before the operation.
  • Referral fee and deadline - every entrypoint except the two in-kind redemptions takes a caller-chosen referralFeePct (WAD-scaled, strictly below WAD) and referralFeeRecipient, 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 (including vaultExitBundlesV1ForceWithdrawVaultV2) 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)). On blueBundlesV1MigrateBorrowPosition the fee and any public allocator penalties are borrowed on top of the migrated debt, so they increase the debt on the destination market; on vaultBundlesV1Migrate the fee is deducted from the withdrawn assets before the deposit into the destination vault. Pass 0 for 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):

EntrypointWhat it does
blueBundlesV1SupplySupply loan assets to a market.
blueBundlesV1WithdrawWithdraw supplied loan assets, by assets or by shares.
blueBundlesV1SupplyCollateralAndBorrowSupply collateral and borrow, bounded by a maxLtv check.
blueBundlesV1RepayAndWithdrawCollateralRepay debt, by assets or by shares, and withdraw collateral, bounded by a maxLtv check.
blueBundlesV1MigrateBorrowPositionMove 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:

EntrypointWhat it does
vaultBundlesV1DepositDeposit assets into a vault.
vaultBundlesV1WithdrawWithdraw assets from a vault.
vaultBundlesV1MigrateMigrate assets from one vault to another vault.

VaultExitBundlesV1

Exit paths for vaults whose liquidity is constrained:

EntrypointWhat it does
vaultExitBundlesV1InKindRedemptionVaultV1Redeem in kind from an illiquid Vault V1.
vaultExitBundlesV1InKindRedemptionVaultV2Withdraw idle assets and redeem the remainder in kind from an illiquid Vault V2.
vaultExitBundlesV1ForceWithdrawVaultV2Force 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.