Overview
TheEscrowRegistry is a registry contract that manages a whitelist of authorized escrow contracts. It provides a flexible system that can either operate in whitelist mode (only specific escrows allowed) or in permissionless mode (all escrows accepted).
Contract Location: contracts/registries/EscrowRegistry.sol
Purpose
The EscrowRegistry serves several important functions:- Escrow Whitelisting: Maintain a list of trusted escrow contracts
- Flexible Mode: Support both whitelisted and permissionless operation modes
- Access Control: Prevent unauthorized escrow contracts from being used
- Governance: Enable protocol owners to control which escrows are trusted
State Variables
acceptAllEscrows: When true, all escrows are accepted; when false, only whitelisted escrowsisWhitelistedEscrow: Maps escrow addresses to their whitelist statusescrows: Array of all whitelisted escrow addresses
Core Functions
Adding Escrows
_escrow: Address of the escrow contract to whitelist
- Escrow address cannot be zero address
- Escrow must not already be whitelisted
- Only callable by owner
EscrowAdded(address indexed escrow)
Reference: contracts/registries/EscrowRegistry.sol:33
Removing Escrows
_escrow: Address of the escrow contract to remove
- Escrow must be currently whitelisted
- Only callable by owner
EscrowRemoved(address indexed escrow)
Reference: contracts/registries/EscrowRegistry.sol:48
Setting Permissionless Mode
_acceptAll: True to accept all escrows, false to require whitelisting
true: Permissionless mode - any escrow can be used (less restrictive)false: Whitelist mode - only explicitly added escrows can be used (more secure)
AcceptAllEscrowsUpdated(bool acceptAll)
Reference: contracts/registries/EscrowRegistry.sol:62
View Functions
Check Acceptance Status
contracts/registries/EscrowRegistry.sol:70
Get Whitelisted Escrows
contracts/registries/EscrowRegistry.sol:74
Check Escrow Status
TheisWhitelistedEscrow mapping is public, allowing anyone to check if a specific escrow is whitelisted:
Integration with Core Contracts
Orchestrator
The Orchestrator contracts (Orchestrator.sol and OrchestratorV2.sol) use the EscrowRegistry to validate escrow contracts:
contracts/Orchestrator.sol:82
RateManagerV1
The RateManagerV1 also references the EscrowRegistry to ensure it only interacts with authorized escrows. Reference:contracts/RateManagerV1.sol:126
Configuration Updates
Orchestrator contracts can update their escrow registry reference:contracts/Orchestrator.sol:279
Access Control
Owner-Only Functions
All state-modifying functions require owner privileges:addEscrow(): Add escrow to whitelistremoveEscrow(): Remove escrow from whitelistsetAcceptAllEscrows(): Configure permissionless mode
Ownable with onlyOwner modifier
View Functions
All query functions are publicly accessible:isAcceptingAllEscrows()getWhitelistedEscrows()isWhitelistedEscrow[address](public mapping)
Events
- Monitoring escrow whitelist changes
- Tracking mode switches between whitelist and permissionless
- Off-chain indexing of authorized escrows
Usage Patterns
Whitelist Mode (Recommended for Production)
Permissionless Mode (Testing/Development)
Security Considerations
Whitelist Mode Security
- Explicit Trust: Only explicitly approved escrows can be used
- Owner Control: Centralized governance over escrow approval
- Audit Trail: Events track all whitelist changes
Permissionless Mode Risks
- No Validation: Any contract can act as an escrow
- Malicious Escrows: Unaudited escrows could be exploited
- User Risk: Users must verify escrow trustworthiness themselves
acceptAllEscrows = false) in production
Upgrade Safety
- Removing an escrow doesn’t affect existing deposits in that escrow
- Adding an escrow doesn’t automatically make it trusted by users
- Mode changes are immediate and affect all subsequent validations
Deployment Strategy
- Initial Deployment: Deploy with
acceptAllEscrows = false(secure default) - Add Escrows: Whitelist production escrow contracts
- Configure Orchestrator: Set registry address in Orchestrator
- Monitor Events: Track whitelist changes via events
Related Contracts
- Orchestrator - Uses registry to validate escrow contracts
- OrchestratorV2 - Updated orchestrator with registry integration
- RateManagerV1 - Uses registry for escrow validation
- EscrowV2 - Escrow contract that can be whitelisted