How naizo01/harmonia_protocol works
Project Overview and Main Components
• The Harmonia Protocol is a blockchain-based system that intervenes in decentralized exchange (DEX) fee structures. It relies on on-chain smart contracts to adjust fees dynamically, while integrating with external services such as Lit Protocol and Web3Auth for secure social logins (via Discord) and attestation verification.
• The project is organized into three main parts:
a. Smart Contracts (located in the “contracts” directory): These Solidity contracts are responsible for handling dynamic fee adjustments, attestations, and interactions with oracles (Pyth) as well as Uniswap V4 hooks.
b. Frontend (in the “nextjs” directory): A Next.js application that provides the user interface for interacting with the protocol. It includes components, hooks, and utility functions to integrate with blockchain features, authentication (Web3Auth & Lit Protocol), and token swap components.
c. Backend / Sign Module (in the “sign” folder): An API server (built with Express) in charge of generating and verifying attestations (called “Sign Attestation”) along with helper libraries and scripts. It handles encryption and the connection between Discord membership and on-chain records.
Analyzing the File Structure
• The “contracts” directory: Contains multiple deployment scripts, environment examples, a structured folder for deployments (with subdirectories for different networks and components like ATTESTER, DYNAMICFEE, etc.), integration with Forge, and external libraries (like OpenZeppelin). This setup indicates a thorough segregation of contracts and environment-specific deployments.
• The “nextjs” directory: Holds the full front-end stack, including components (UI elements, dialogs, hooks, contexts for handling Lit and attestation logic), configuration files, and connection utilities. It is structured to incorporate blockchain data, authentication via external protocols, and UI/UX features.
• The “sign” directory: Hosts an Express server (with middleware, routes, and tests) and example scripts revealing its use for managing attestations. It also includes cryptographic utility libraries.
Relationships and Data Flow
• The End-User interacts with the Next.js frontend, which is responsible for:
• Initiating blockchain transactions (like token swaps or fee adjustments) via Uniswap V4 hooks.
• Handling authentication through Web3Auth and Lit Protocol (which abstracts Discord login and secure, encrypted attestations).
• The Next.js client communicates with the backend “sign” service when it needs to create or validate attestations. This backend uses its crypto utilities and Express routes to generate signatures or fetch schema/attestation data.
• On the blockchain, smart contracts deployed via the “contracts” directory receive transactions (for dynamic fee adjustments, attestation verifications, etc.) and interact with external oracles (like Pyth) for price feeds.
• External Services:
• Discord: Used for community membership validation.
• Lit Protocol and Web3Auth: Facilitate secure social logins and encryption.
• Uniswap V4 & Pyth: Provide core DeFi functions and real-time price information.
Summary of Inclusions
• Clear labels for each component: “Smart Contracts (with submodules),” “Frontend (Next.js),” and “Backend (Express Sign Service)”.
• From the user (via Frontend) to authentication services (Web3Auth and Lit Protocol).
• From Frontend to Backend for attestation services.
• From both Frontend/Backend to Smart Contracts for DEX transactions.
• From Smart Contracts to external services like Pyth (price feed) and Uniswap V4.
• Annotation with relevant protocols (Lit Protocol, Web3Auth, Uniswap V4, Pyth, Discord) and deployment details (network-specific deployments under “contracts/deployments”).