How regolith-labs/ore-boost works
Project Type and Overall Purpose
• This is a blockchain-related project (likely on Solana) that implements a liquidity mining program. It operates by enabling users (stakers) to deposit, withdraw, claim rewards, and manage stake accounts, while administrators can manage boosts and program configurations.
• The project is modular and composed of multiple components (API, CLI, and Program) that work together to deliver the desired staking functionality.
Key Components
a. API Layer:
• Contains shared code, constants, custom errors, instructions, and SDK functionalities.
• Files like consts.rs, error.rs, instruction.rs, and several state modules (boost.rs, config.rs, stake.rs) define and manage on-chain state representations.
• Acts as the foundational library used by both the CLI and Program modules.
b. CLI (Command-Line Interface):
• Provides a user-facing interface with specific commands for actions (such as claim, close, deposit, open, rotate, withdraw) as well as administrative tasks (activate, deactivate, initialize, new, update).
• The CLI calls into the underlying libraries (from API) and may trigger blockchain transactions via the program.
c. Program Module (Smart Contract Logic):
• Implements the blockchain instructions corresponding to both user and admin operations.
• Files in this module (activate.rs, claim.rs, close.rs, etc.) are the smart contract endpoints that interact with on-chain state.
• This module processes transactions and updates the global accounts (Config) and individual accounts (Boost, Stake) based on instructions.
d. State:
• Represented by dedicated state accounts that store persistent on-chain data.
• Components include Boost (tracking incentives per mint), Config (singleton for program-wide variables), and Stake (tracks user-specific staked tokens).
• These states are shared by the API definitions and manipulated by the program instructions.
e. Tests:
• The tests directory (within the program subdirectory) contains integration tests (like test_rewards.rs) to validate the program’s behavior using the Solana toolchain.
Relationships and Interactions
• The CLI serves as an external entry point (or client) that packages user/admin commands.
• CLI commands utilize the API (via libraries such as the SDK and defined instructions) to form appropriate transactions that are sent to the Program.
• The Program receives and handles these instructions, updating the state accounts (Boost, Config, Stake) as needed.
• Errors and events defined in the API help with debugging, logging, and ensuring proper flow.
• The test suite interacts with the Program and APIs to simulate real-world use cases and confirm expected behavior.
Architectural Patterns and Design Principles
• Clear Separation of Concerns: The project is cleanly divided into API (business rules and state definitions), CLI (user interface layer), and Program (smart contract implementation).
• Modularity: Each directory targets a specific domain (interface, library code, on-chain logic), facilitating reusability and ease of maintenance.
• Use of Rust/Cargo for dependency and build management — note configuration files like Cargo.toml and Cargo.lock.