ETH0 DaoCollateral
High-Level Overview
The DaoCollateral contract is a fundamental component of the ETH0 stablecoin ecosystem, designed to manage the collateralization, minting, and redemption of ETH0 tokens. It ensures that the circulating supply of ETH0 is always fully backed by collateral, providing transparency and security for ETH0 holders. The contract facilitates the swapping of collateral tokens for ETH0, redemption of ETH0 for collateral tokens, and implements a Counter Bank Run (CBR) mechanism for emergency situations.
Contract Summary
Inherited Contracts
ReentrancyGuardUpgradeable (OZ): Prevents reentrant attacks on sensitive functions.
PausableUpgradeable (OZ): Enables pausing of contract functionality by authorized accounts.
EIP712Upgradeable (OZ): Implements EIP-712 for structured data hashing and signing.
Functionality Breakdown
Key Functionalities
Minting and redeeming ETH0: The contract manages the collateralization of ETH0 by handling collateral tokens. When a user sends collateral, the DaoCollateral contract mints the equivalent amount of ETH0 stablecoins, and vice versa, allowing users to exchange their ETH0 stablecoins for collateral at the current exchange rate.
Swap: Facilitates the conversion of collateral into ETH0. Upon initiating this function, users exchange their collateral tokens for ETH0 stablecoins directly.
Redeem: Allows users to redeem their ETH0 stablecoins for collateral against a fee. By invoking this function, users exchange their ETH0 stablecoins for collateral at the current exchange rate.
Counter Bank Run (CBR) Mechanism: The contract implements a Counter Bank Run mechanism that can be activated in emergency situations. When activated:
The CBR coefficient is applied to reduce the amount of collateral returned during redemptions
Swap functionality is automatically paused
The system helps maintain protocol stability during market stress
Role-Based Access Control
The contract implements a role-based access control system for sensitive operations:
DEFAULT_ADMIN_ROLE: Has the highest level of access, including the ability to manage CBR parameters and perform critical administrative tasks.
DAO_REDEMPTION_ROLE: Required for special DAO redemption operations.
PAUSING_CONTRACTS_ROLE: Grants the ability to pause specific contract functionalities in case of emergencies.
UNPAUSING_CONTRACTS_ROLE: Grants the ability to unpause contract functionalities.
Functions Description
Public/External Functions
initialize
: Sets up the contract with initial parameters including registry information and redeem fee.swap
: Allows users to swap collateral tokens for ETH0.swapWithPermit
: Similar to swap but uses permit for approval.redeem
: Enables users to redeem ETH0 for collateral tokens.redeemDao
: Special redemption function for DAO operations. Only callable by DAO_REDEMPTION_ROLE.activateCBR
: Activates the Counter Bank Run mechanism. Only callable by DEFAULT_ADMIN_ROLE.deactivateCBR
: Deactivates the Counter Bank Run mechanism. Only callable by DEFAULT_ADMIN_ROLE.setRedeemFee
: Sets the fee for redemption operations. Only callable by DEFAULT_ADMIN_ROLE.pauseRedeem
,pause
,pauseSwap
: Pausing functions for specific operations. Only callable by PAUSING_CONTRACTS_ROLE.unpause
,unpauseRedeem
,unpauseSwap
: Global unpausing functions. Only callable by UNPAUSING_CONTRACTS_ROLE.
Constants
CONTRACT_REGISTRY_ACCESS
: Address of the registry access contract.CONTRACT_TOKEN_MAPPING
: Address of the token mapping contract.CONTRACT_ORACLE
: Address of the oracle contract.CONTRACT_TREASURY
: Address of the treasury contract.CONTRACT_ETH0
: Address of the ETH0 token contract.CONTRACT_YIELD_TREASURY
: Address of the yield treasury contract.DEFAULT_ADMIN_ROLE
: Role identifier for the default admin.DAO_REDEMPTION_ROLE
: Role identifier for DAO redemption operations.PAUSING_CONTRACTS_ROLE
: Role identifier for pausing contract operations.UNPAUSING_CONTRACTS_ROLE
: Role identifier for unpausing contract operations.MAX_REDEEM_FEE
: Maximum allowed redemption fee (25%).BASIS_POINT_BASE
: Base value for basis point calculations (10000).SCALAR_ONE
: Scalar value representing 1 in the contract's decimal system.
Key Components
Oracle Integration: Uses an oracle to fetch real-time price data for collateral tokens.
Token Mapping: Manages the mapping of supported collateral tokens.
Access Control: Implements role-based access control for administrative functions.
Treasury Management: Handles the storage and distribution of collateral tokens.
Safeguards Implementation
Pausability: Allows pausing of critical functions in emergencies.
Reentrancy Protection: Uses OpenZeppelin's ReentrancyGuard to prevent reentrancy attacks.
Access Control: Restricts sensitive operations to authorized roles.
CBR Mechanism: Implements a Counter Bank Run mechanism for emergency situations.
Fee Management: Implements a configurable redemption fee system with a maximum cap of 25%.
Last updated
Was this helpful?