How immunefi-team/spectra-audit-competition works
Project Type and Purpose
• This is a smart contract–based DeFi protocol for interest rate derivatives.
• The system is built around the concept of users depositing ERC-4626 compliant tokens (or underlying assets), receiving a Principal Token (PT) and a Yield Token (YT), with additional components for swapping, fee settings, and registry management.
• It is also highly composable and permissionless, using standard contracts (e.g., OpenZeppelin’s Access Manager) and tailored libraries to perform specialized functionality.
Main Architectural Components
• Core Contracts:
• Principal Token (PT): Implements EIP-5095 and EIP-2612, handling the separation of yield.
• Yield Token (YT): An ERC-20/EIP-2612 token representing the yield earned.
• Utility and Interaction Contracts:
• Router: Provides utility functions for swapping, liquidity additions/removals, and handling native tokens.
• Factory and FactorySNG: Responsible for deploying new PTs and Curve pools and registering them in the Registry.
• Registry and RateOracleRegistry: Hold key addresses and fee values, and register rate oracles.
• RateAdjustmentOracle (and its math library): Provides adjustment rate calculations for stable swap pools.
• Libraries:
• A suite of libraries (PrincipalTokenUtil, CurvePoolUtil, CurveNGPoolUtil, Roles, NamingUtil, RateAdjustmentMath, etc.) that encapsulate recurring logic and mathematical computations.
• Access and Governance:
• Access Manager and Ownable: Implements roles via OpenZeppelin standards to manage permissions like UPGRADER_ROLE, PAUSER_ROLE, etc.
Relationships and Interactions
• Data Flow:
• Users deposit their tokens into the PrincipalToken contract which, in turn, mints both PT and YT.
• The Yield Token contract synchronizes with the Principal Token contract for yield generation.
• The Router facilitates extra operations (such as interacting with external pool protocols like Curve), linking with the deployed PTs and IBTs.
• Factories deploy new tokens and pool contracts and update the Registry so that other components (and external interfaces) can discover the new instances.
• Rate Oracles feed data into Curve-based pools to adjust ratios and yield calculations in real time.
• Dependency and Communication:
• Core contracts call upon libraries for recurrent functions (calculations, naming, role management).
• Multiple contracts interact with the Registry and Access Manager to maintain security and proper configuration.
• Testing and simulation utilities are provided to verify that these interactions hold during fuzz runs and unit tests.
Architectural Patterns and Technologies
• The design leverages modularization:
• Single-responsibility contracts (for PT, YT, router, factory, registry, oracles).
• Extensive use of libraries for pure computations and standardized operations.
• Decentralized finance patterns such as deposit-mint-burn mechanisms, dynamic rate oracles, and upgradeable proxies (as judged from the use of OpenZeppelin contracts and foundry/hardhat configuration).