The ZeUSD Router is the primary gateway for users to interact with the ZeUSD protocol. It acts as a central hub that enables users to:
- Create ZeUSD by depositing collateral or stable coins
- Bridge ZeUSD across different blockchain networks
- Burn ZeUSD to retrieve their collateral
- Manage their positions and interactions with the protocol
The access control system ensures secure and compliant protocol usage through multiple layers:
- DEFAULT_ADMIN_ROLE (Owner)
- Highest level of access in the protocol
- Can grant/revoke other roles
- Controls critical protocol parameters
- Manages emergency operations
- ADMIN_ROLE (Admin)
- Manages day-to-day operations
- Controls whitelist
- Updates protocol configurations
- Monitor system health
- Whitelist System
- Ensures KYC/KYB compliance
- Controls who can mint ZeUSD
- Maintains regulatory standards
- Tracks user permissions
- Blacklist Integration
- Blocks malicious actors
- Enforces compliance requirements
- Protects protocol security
- Maintains system integrity
2.1 Collateral Vault Integration
The Collateral Vault manages all collateral positions in the protocol:
- Tracks user deposits and positions
- Calculates collateral ratios
- Manages liquidation thresholds
- Provides price feed integration
2.2 ZeUSD Token Management
Direct interface with the ZeUSD token contract for:
- Minting new tokens based on collateral
- Burning tokens during redemption
- Managing token supply
- Tracking user balances
Enables seamless cross-chain functionality through:
- Secure message passing between chains
- Token bridging capabilities
- Cross-chain position management
- Unified liquidity across networks
Manages specialized vaults for different asset types:
- RWA (Real World Asset) vaults
- Stable coin vaults
- Protocol-specific integrations
- Custom asset handlers
Users can create ZeUSD through two primary methods:
In this process:
- Users deposit supported collateral (e.g., ZTLN)
- System validates collateral and user eligibility
- Calculates appropriate ZeUSD amount based on:
- Collateral value
- Current oracle prices
- LTV ratios
- Mints ZeUSD to user's wallet
- Records position in Collateral Vault
In this process:
- Deposit supported stablecoins (e.g., USDC)
- System routes to appropriate SubVault
- SubVault invests in underlying protocol
- Mints equivalent ZeUSD based on deposit
When users want to move ZeUSD across chains:
This enables:
- Seamless cross-chain movement
- Unified liquidity across networks
- Chain-agnostic usage
- Optimized gas efficiency
Users can redeem their ZeUSD for underlying collateral through a secure process:
The system:
- Verifies user's ZeUSD balance
- Checks position exists and is active
- Burns specified ZeUSD amount
- Returns equivalent collateral
- Updates position records
- Tracks all user positions
- Manages partial redemptions
- Updates collateral ratios
- Maintains position history
Multiple layers of security ensure safe operations:
modifier whitelistedOnly() {
if (!_whitelisted[msg.sender]) revert NotWhitelisted(msg.sender);
_;
}
modifier notBlacklisted() {
if (zeusdToken.isBlacklisted(msg.sender)) revert Blacklisted(msg.sender);
_;
}
modifier whenNotPaused() {
if (depositsPaused) revert DepositsArePaused();
_;
}
- Reentrancy Guards: Prevent multiple calls
- Pause Mechanism: Emergency stops
- Role Validation: Access control
- Amount Validation: Input checking
In this flow:
- User Initiation: User calls mintWithCollateral with their chosen collateral asset (e.g., ZTLN) and amount
- Access Verification: Router checks if user is whitelisted and not blacklisted
- SubVault Location: Gets the appropriate SubVault address for the collateral type
- Asset Validation: Verifies the collateral is supported by the SubVault
- Collateral Transfer: Transfers user's collateral to the designated SubVault
- Position Recording: Records the deposit details in CollateralVault for tracking
- Amount Calculation: Calculates how much ZeUSD to mint based on collateral value and LTV
- Token Minting: Mints the calculated amount of ZeUSD to user's wallet
This process involves:
- User Request: User initiates stable token deposit (e.g., USDC)
- Access Checks: Verifies user's permission to use the protocol
- Vault Verification: Locates correct Sub Vault for the stable token
- Asset Validation: Confirms stable token is supported
- Token Transfer: Moves stable tokens to Sub Vault
- Protocol Integration: Sub Vault deposits stables into underlying protocol
- Record Keeping: Records the stable deposit in Collateral Vault
- ZeUSD Issuance: Mints equivalent ZeUSD based on stable deposit
The burn process includes:
- Burn Request: User initiates burn of ZeUSD to reclaim their collateral
- Permission Check: Verifies user's authorization
- Vault Location: Identifies correct Sub Vault storing user's collateral
- Asset Verification: Confirms asset type matches original deposit
- Position Update: Marks the deposit as inactive in Collateral Vault
- Token Burning: Burns the specified amount of ZeUSD
- Collateral Release: Withdraws collateral from Sub Vault
- Return Assets: Transfers collateral back to user's wallet
The Router relies on price oracles through the Collateral Vault for calculating mint amounts:
- Price Discovery
- Collateral prices from Chainlink oracles
- Price validation and fallback mechanisms
- Staleness checks and safety bounds
- Mint Amount Calculation
- Oracle Safety Measures
- Price deviation checks
- Minimum/maximum bounds
- Heartbeat verification
- Multiple oracle support for critical assets
- Custom Errors
error NotWhitelisted(address account);
error Blacklisted(address account);
error InvalidAddress(address address);
error ZeroAmount();
error DepositsArePaused();
error InsufficientBalance(string token);
- State Validation
- Pre-condition checks
- Balance verification
- Allowance validation
- Asset support verification
The Router implements UUPS upgradeability pattern:
- State variable organization
- Implementation slot management
- Proper initialization sequence
- Storage gap for future upgrades