How infinifi-labs/infinifi-protocol works
Project Type and Purpose
• This project is a blockchain-based decentralized finance (DeFi) protocol primarily implemented in Solidity. It handles the minting and redemption of receipt tokens (like iUSD, iETH) against collateral assets (USDC, ETH) while integrating yield generation, locking mechanisms, and a governance system.
• The README identifies the main features as yield generation via multiple farm integrations, enhanced rewards through token locking, and dynamic governance for farm allocation voting.
Core File Structure
• The top-level directories (src, test, lib) indicate that the project is structured around smart contracts with extensive testing (unit and integration) and dependencies (OpenZeppelin, Solmate, Forge-std).
• Under “src” you have dedicated modules that clearly mirror the protocol architecture described in the README: core, gateway, funding, locking, governance, finance, and integrations. Each of these directories contains Solidity contracts representing a distinct part of the protocol.
• The “lib” directory houses external dependencies and libraries that provide well-known frameworks for security, testing, and deployment.
Components
• Core Module:
– Include “InfiniFiCore.sol” & “CoreControlled.sol”. Represent this as the central entity handling roles, access control, and permissions that serve as a base for many contracts.
• Gateway Module:
• Funding Module:
– Illustrate components like “MintController.sol”, “RedeemController.sol”, and “RedemptionPool.sol” as responsible for token minting and redemption workflow. Also show the “ReceiptToken.sol” under tokens.
• Locking Module:
– Incorporate “LockingController.sol” and “UnwindingModule.sol” and represent the associated token “LockedPositionToken.sol” (an ERC20 token that symbolizes locked positions).
• Governance Module:
– Include “AllocationVoting.sol”. Indicate how it uses locked tokens (weighted votes) to dynamically decide farm allocations.
• Finance Module:
– Represent “YieldSharing.sol” and “Accounting.sol” for distributing yield and managing protocol accounting/data.
• Integrations Module:
– Show “FarmRegistry.sol” along with movement components (from the “farms/movement/” directory such as “ManualRebalancer.sol”, “AfterMintHook.sol”, “BeforeRedeemHook.sol”). This module connects the protocol to external yield farms (such as Aave and Pendle) and facilitates asset movement or rebalancing.
Relationships and Interactions
• Within the Funding module, connect the minting process to the receipt token contract and then route redemption flows through the redemption queue.
• Link the Locking module’s operations with Governance, showing that locked tokens affect voting power.
Architectural Patterns and Design Principles
• Use of modular design: each “module” (Core, Gateway, Funding, etc.) encapsulates a distinct aspect of functionality.
• Separation of concerns (for example, minting/redemption logic in the Funding module vs. locking and reward calculations in the Locking module).
• If appropriate, mention that the design fosters upgradeability and testability, as hinted by the presence of extensive testing directories and use of libraries like OpenZeppelin and Solmate.
Specific Elements
• Each component should be clearly marked with its name (e.g., “InfiniFiCore”, “MintController”, etc.).
• Optionally, include notes for security features (like role-based access control and emergency/guardian override) that are critical for understanding the design.