Contract map
Contract systems
BlendSafeFactory - Safe deployment and setup
BlendSafeFactory - Safe deployment and setup
Deploys and sets up Gnosis Safe proxies with Blend’s module and guard architecture.Key functions:
deploySafe is restricted to the module’s executor (StrategyManager(module).executor()). It validates non-empty owners, valid threshold, and that module/guard are set.enableModuleAndSetGuardFromFactory reads module and guard addresses from factory storage at runtime. This is what enables cross-chain address determinism. Module and guard can differ per chain while Safe addresses stay identical.Setup installs three components:- RolesReceiver as module (strategy execution)
- RolesGuard as transaction guard (pause + access control)
- Safe4337Module as module and fallback handler (account abstraction)
StrategyManager - Rebalance orchestration and rate limiting
StrategyManager - Rebalance orchestration and rate limiting
Core orchestration layer. Manages vault configs, executes rebalances, and enforces rate limiting.Key structs:Key functions:Security invariants:
- Rate limited per (safe, vault) pair via
keccak256(abi.encodePacked(safe, vault)) MIN_SECONDS_BETWEEN_OPERATIONSenforced (1-300 seconds)- Timestamp set before execution; full transaction reverts on failure
- Config validation rejects duplicate marketIds and duplicate action controllers
Roles system - Transaction guard and timelocked config
Roles system - Transaction guard and timelocked config
Two contracts that validate transactions and hold timelocked configuration.RolesGuard - Transaction guard on every Safe:When paused:
checkTransaction allows Safe owners to execute directly. checkModuleTransaction blocks ALL module transactions with no owner bypass.RolesReceiver - Holds vault configs and the executor. Extends StrategyManager. Two timelocks on the same chain administer it directly, with no cross-chain messaging:- Only the operational timelock can call
updateVaultConfig. Each config change waits 2 days. - Only the security timelock can call
setExecutor. It owns the contract, and its changes wait 7 days.
MorphoVaultController - Morpho vault rebalancing
MorphoVaultController - Morpho vault rebalancing
Orchestrates Morpho vault rebalancing.Execution flow:
- Wrap native ETH if vault token is WETH
- Deposit existing vault tokens into vault
- Process all decrease operations (withdraw collateral)
- Process all increase operations (supply collateral)
- MorphoSeedingLib - Handles collateral supply and withdrawal. No borrowing involved.
- MorphoVaultLib - Utility functions for deposit/withdraw with slippage checks and price data decoding.
- Slippage protection via
assets/sharesratio checks againstassetPerShare - Processes decreases before increases (frees capital first)
Withdrawal controllers - User withdrawals
Withdrawal controllers - User withdrawals
UserWithdrawController - Full 9-step withdrawal lifecycle:The 9 steps:
- Validate amount, module, vault, single-owner requirement
- Liquidity reset via VaultController.executeRebalance
- Snapshot balance, resolve max withdrawal
- Force deallocate from adapters (zero-penalty only)
- Vault withdrawal with slippage protection
- Determine actual withdrawn amount
- Deduct withdrawal fee (max 5%)
- Transfer to owner OR bridge cross-chain
- Redeposit remaining assets into vault
bridgeOffsets (recipientOffset, inputAmountOffset, outputAmountOffset, destDecimals) to inject values into pre-built bridge calldata.Swap adapters - DEX execution with slippage protection
Swap adapters - DEX execution with slippage protection
These adapters handle token swaps within Bundler3 multicalls.SwapAdapter - Base contract:Three layers of slippage protection:
- Governance max (
maxSlippageBps) - hard ceiling - Per-swap (
slippageBps <= maxSlippageBps) - caller-specified - Oracle-verified minimum output via
PriceLib
checkSwapInvariants ensures the adapter holds zero tokens before and after every swap.BalanceReplacementAdapter - Reads token balances and injects them into calldata at specified offsets using bitwise OR. Handles temporary approvals and balance draining.Cross-chain adapters - Across and CCTP bridging
Cross-chain adapters - Across and CCTP bridging
Two bridge adapters and a batching controller for cross-chain transfers.AcrossXChainAdapter - Bridges via Across V3 SpokePool:Supports any token. Validates slippage via
PriceLib.normalize and applySlippage. Validates all address and amount parameters match. Refunds dust to sender.CCTPXChainAdapter - Bridges USDC via Circle CCTP V2:USDC-only. Queries burnLimitsPerMessage from the minter. If the amount exceeds the limit, it splits into multiple depositForBurn calls automatically.Uses maxFee=0, minFinalityThreshold=2000 (Standard finality).XChainVaultAction - Orchestrates batched cross-chain vault actions:- Requests MUST be sorted ascending by
destinationChainId(enables O(N) duplicate detection) - Single vault withdrawal, then executes each bridge request
- Verifies zero adapter balance after each transfer
- Sweeps remaining balance back to vault
Vault controllers - Base controllers and vault actions
Vault controllers - Base controllers and vault actions
Layered controller system for vault operations.DelegateController - Base security.
_onlyDelegateCall modifier compares address(this) against immutable SELF. Ensures code only runs via delegatecall from a Safe.VaultController - Extends DelegateController. Provides _validateRebalanceData modifier that checks rebalanceData length matches markets, all marketIds match, and vault is configured.VaultActionController - Extends DelegateController. Provides the executeAction(vault, strategyData, extraData) entry point that delegates to abstract _execute.VaultToVaultAction - Moves funds between vaults with optional swap. Validates both source and destination vaults are registered. Uses SwapAdapter with oracle slippage protection when asset types differ.Supporting libraries - Oracle and decimal utilities
Supporting libraries - Oracle and decimal utilities
Utility contracts used across the protocol.PriceLib - Oracle and decimal utilities:
Architecture overview
See how these contracts fit into the full system.
Security deep dive
Understand the 3 security layers protecting every transaction.
Deployments
Find deployed contract addresses on each chain.
Audits
Review independent security audit reports.