How hai-on-op/core works
Main Components
• Core Smart Contracts: Include the directories under src/contracts – for instance, contracts related to governance, tokens, oracles, proxies (and proxy actions), settlement, and utilities.
• Factories & Interfaces: There is a “factories” sub-directory (both under contracts and interfaces) which indicates the use of the factory pattern for creating contract instances dynamically.
• Modules: In the docs you see detailed sections on auctions, modules (like liq_engine, oracle_relayer, pid_controller, safe_engine, sf_treasury, tax_collector) – these should be highlighted as key modular components of the system.
• Proxies and Action Management: Under src/contracts/proxies (with actions, hai_proxy, hai_proxy_factory, etc.) you have a well-developed proxy mechanism suggesting a separation between core logic and upgradeability or protocol management.
• Testing Suite: Although not part of the runtime architecture, the test directories (unit tests, simulation tests including PID controllers, and e2e tests) verify how these components interact.
Relationships and Interactions
• Interconnections between modules – for instance, how the pid_controller in the simulations interacts with auction modules or settlement modules.
• If applicable, map out interactions such as governance decisions triggering executable contracts, token issuance affecting settlement mechanisms, and oracle data updates influencing modules like the oracle_relayer.
Architectural Patterns and Design Principles
• Modularity: The project is highly modular – each contract group (governance, tokens, proxies, settlement) represents individual components that communicate with each other.
• Separation of Concerns: By dividing code into specific directories (contracts, interfaces, libraries, and tests), the architecture reinforces a separation between contract implementations, their external interfaces, and testing.
• Factory Pattern: The clear “factories” directories indicate dynamic instantiation – show that factories are responsible for creating contract instances.
• Proxy Pattern: With proxies and proxy actions as separate components, indicate that upgradeability or indirection control is a core design principle.