How bubble-finance/bubble-v1-protocol works
Project Type and Purpose
• This project is a smart contract-based decentralized exchange (DEX) platform built on Monad. It is focused on providing a gamified, ecosystem-driven liquidity hub and includes features such as MEV shield, gas sponsored swaps, raffles, launchpads, and farms.
• The README confirms that the project uses Solidity for its smart contracts, Foundry for development and testing, and pnpm for package management, with an emphasis on modularity in its smart contract code.
File Structure
• Top-Level Directories:
• src: Contains the core source code for the protocol. Subdirectories include:
• campaigns: Likely modules handling promotional or community-driven campaigns.
• core: Represents the core logic and functionalities of the DEX.
• governance: Contains smart contracts for protocol governance.
• interfaces: Holds contract interfaces for standardized interactions.
• library: Utility contracts or shared internal libraries.
• raffle: Contains the logic for the raffle feature.
• router: Manages routing for transactions or liquidity paths.
• lib: Third-party libraries such as OpenZeppelin Contracts, Forge-std, and Solmate indicating reusable modules, security utilities, and helper contracts.
• script: Deployment or utility scripts to handle contract deployment and operations.
• test: Contains unit and integration tests structured alongside helper functions and test notes.
• Other Files:
• foundry.toml, package.json, pnpm-lock.yaml, and remappings.txt are configuration and dependency management files.
• The presence of Makefile and shell scripts indicates automation in building and testing the system.
• .github/workflows directory shows integrated CI/CD testing using GitHub Actions.
a. Main Components:
• Smart Contract Modules (represented in the src directory):
• Core: The main logic of the DEX.
• Campaigns: Components handling promotional or community campaigns.
• Governance: Modules that allow stakeholders to participate in decision making.
• Raffle: Modules that drive the raffle functionality.
• Router: Facilitates the transaction routing logic.
• Interfaces & Library: Utility layers and standardized contract interfaces.
• Dependency / Library Components:
• OpenZeppelin Contracts: Standard token and security contracts.
• Solmate & Forge-std: Used to bolster the development, testing, and security.
• External Tools & Environment:
• Foundry: For testing and building smart contracts.
• pnpm: For package management.
• CI/CD Pipeline (GitHub Actions): Automated testing as defined in the .github/workflows directory.
• Deployment Scripts:
• Scripts used for deployment and utilities found in the script directory.
• Testing Infrastructure:
• Test modules and utilities as seen in the test directory.
b. Relationships and Interactions:
• The "Router" module interfaces with the "Core" to process swaps and liquidity transactions.
• "Governance" interacts with "Core" and possibly "Campaigns" to modify rules or proposals.
• "Raffle" is connected to both "Core" (for liquidity tracking or participation) and the "Campaigns" mechanics.
• The "Interfaces" and "Library" modules act as shared resources for multiple smart contract modules.
• The CI/CD pipeline triggers tests and builds that cover all these components.
• Deployment scripts use configuration files (like foundry.toml, remappings.txt) to correctly deploy the smart contracts.
c. Architectural Patterns and Design Principles:
• Modular Contract Design: Each separate folder under src represents a well-defined module.
• Separation of Concerns: Different functionality (campaigns, governance, raffle, router) is isolated within their own components.
• Dependency Reuse: Libraries like OpenZeppelin and Solmate are leveraged, which is standard practice in Solidity development.
• Testing and CI/CD Integration: Ensuring that each component is covered by unit/integration tests with automated testing pipelines.
d. Relevant Technologies, Frameworks, or Libraries:
• Solidity: Core programming language for smart contracts.
• Foundry: Development, testing, and deployment framework.
• OpenZeppelin, Solmate, and Forge-std: Utility libraries for security, token standards, and testing.
• pnpm: Package management.
• GitHub Actions: CI/CD workflow management.
Elements
• Use clear, concise labels for each component (e.g., "Core DEX Logic", "Governance Module", "Raffle Module", "Router", "Campaigns").
• For example, use rectangles for smart contract components.