Collateral Vault
Protocol's Central Registry and Price Coordinator
Core Purpose
The Collateral Vault serves as the backbone of the ZeUSD protocol, performing three critical functions:
Role as Central Registry
Price Coordination Role
The Collateral Vault implements a sophisticated dual-path pricing mechanism:
Primary Path (Oracle Pricing)
Queries oracle price from sub vault
Validates price freshness and reasonability
Applies necessary scaling and conversions
Used when oracle is available and healthy
Fallback Path (Stored Pricing)
Uses administratively set prices
Activated when:
Oracle is unavailable
Oracle returns invalid price
Oracle price is stale
Price validation fails
Position Tracking
Maintains comprehensive records of all user positions
Tracks active and historical deposits
Records minted ZeUSD amounts per position
Manages position lifecycle (creation, updates, closure)
Key Functionalities Explained
1. Sub Vault Registration System
The sub Vault registration process follows a strict validation and storage pattern:
This ensures:
No duplicate registrations for same collateral
Proper configuration updates
Clear audit trail through events
2. Mint Amount Calculation
The mint calculation process is a critical function that determines how much ZeUSD can be minted against collateral:
For Primary Collateral:
For Stable coins:
Key Considerations:
Price scaling for different decimal places
LTV (Loan-to-Value) ratio application
Overflow protection in calculations
Proper decimal handling for different tokens
3. Deposit Recording System
The deposit recording system maintains the protocol's state:
Deposit Creation:
Assigns unique deposit ID
Records collateral details
Tracks minted ZeUSD
Links to specific sub vault
State Updates:
Handles position modifications
Manages active/inactive status
Updates minted amounts
Query Capabilities:
User position lookup
Active deposits filtering
Collateral type aggregation
Historical position tracking
4. Price Management
Price management involves multiple layers of validation and calculation:
Oracle Price Resolution:
Price Validation Rules:
Non-zero check
Staleness check (if from oracle)
Bounds check against min/max
Decimal place verification
Price Application:
Properly scaled for calculations
Correctly applied with LTV
Maintains precision throughout
Security Architecture
1. Access Control Layers
Three-tiered access control system:
Admin Layer: Configuration and emergency functions
Router Layer: Operational functions
Public Layer: View functions
2. Value Validation
Comprehensive validation system:
Input parameter checks
State validity checks
Balance and allowance verification
Price sanity checks
3. State Protection
Multiple safeguards for state integrity:
Reentrancy protection
Proper state updates
Event emission for tracking
Failure recovery mechanisms
Integration Patterns
1. Router Integration
Router interaction flow:
2. Sub Vault Integration
Each sub vault integration requires:
Registration in Collateral Vault
Price feed configuration
LTV ratio setting
Activity status management
3. Oracle Integration
Oracle integration patterns:
Primary price source
Fallback mechanisms
Price validation rules
Update frequency check
Last updated