How dangerousfood/ethstrategy works
Project Type and Purpose
• EtherStrategy is a blockchain-based, onchain tokenized protocol operating on Ethereum. It manages an ETH pool and issues $ETHXR tokens to represent a share in the growing ETH pool.
• Its primary functions include managing a deposit pool of ETH, raising funds through convertible bonds (using USDC), issuing new tokens through ATM offerings, and handling NAV options through onchain governance.
• Think of it as a decentralized, onchain version of MicroStrategy, but with transparent and governed mechanisms.
Analyzing the File Structure
• Top-level directories include:
• src: Likely contains the Solidity smart contract source files that implement the core protocol logic (e.g., deposit pool, bond conversion, token issuance, governance).
• test: Contains tests for smart contracts, ensuring the correctness of protocol logic.
• lib: Contains important dependencies and libraries like OpenZeppelin contracts, Forge Standard Library (forge-std), Solady, and a custom TReentrancyGuard. These support secure contract development.
• script & ts-scripts: These directories host deployment and auxiliary scripts (the ts-scripts directory indicates TypeScript-based tools for signing whitelist data and verifying contracts, while the script directory likely offers forge/solidity-based deployment or operation scripts).
• Additional files such as foundry.toml, package.json, and deploy.config.json indicate a build and deployment system using Foundry and pnpm, aligning with modern Solidity development practices.
Architectural Insights from the README
• The README details multiple interactable protocol elements: deposit pool, convertible bonds, ATM offerings, NAV options, and onchain governance.
• It describes key flows like:
• Deposits from initial funders, resulting in $ETHXR token issuance.
• The mechanics behind buying bonds with USDC that convert to tokens or get redeemed.
• Issuance of new tokens when market conditions meet ATM offering criteria.
• Governance mechanisms (voting, rage quit, transfer pausing) for protocol control.
• These insights help identify the main components and interactions within the protocol.
a. Main Components:
• User Interface/Interaction Layer: This isn’t explicitly described in the file tree but could be integrated through web3 frontends interfacing with contracts.
• Smart Contract Layer (Core Protocol):
• Deposit Pool: Manages ETH deposited by early backers.
• Convertible Bonds Module: Handles bond issuance, conversion to $ETHXR tokens, and redemption in USDC.
• ATM Offering Module: Manages token issuance when $ETHXR trades at a premium.
• NAV Options Module: Governs minting of tokens based on net asset value.
• Governance Module: Manages proposals, votes, token transfer restrictions, and rage quit functionality.
• External Services/Dependencies:
• External Tokens: USDC for bonds and ETH.
• Libraries: OpenZeppelin contracts, forge-std, and other security libraries used as dependencies.
• Supporting Scripts:
• Deployment Scripts: Scripts in “script” and “ts-scripts” directories for contract deployment and verification.
• Testing & CI/CD: GitHub workflow files (.github/workflows) ensure continuous testing and integration.
b. Relationships and Data Flow:
• Users or offchain services interact with the protocol’s smart contracts via transactions:
• Deposits result in issuance of $ETHXR tokens.
• Bonds are purchased with USDC, which then trigger ETH acquisitions to grow the pool.
• ATM offerings and NAV options are triggered based on token market price relative to the pool’s net asset value.
• Governance decisions can pause token transfers or trigger a “rage quit” flow.
• From User → Deposit Pool (ETH deposit)
• From Bond Buyers → Convertible Bonds Module (USDC in, bonds out)
• Bonds Module → ETH Pool (using USDC to purchase ETH)
• ATM Offering Module → New token issuance → ETH Pool replenishment
• Governance Module → Various protocol actions (pausing, execution delay, rage quit)
• Interactions between these modules with clear labels.
c. Architectural Patterns and Design Principles:
• Modularity: Each protocol function (deposit, bonds, ATM, NAV options, governance) is implemented as a distinct module within the smart contracts.
• Onchain Transparency: All actions (deposits, conversions, governance votes) are executed by smart contracts, enhancing auditability.
• Secure Contract Development: Usage of libraries like OpenZeppelin and custom reentrancy guards emphasizes security best practices.
• CI/CD Integration: The presence of GitHub workflows and testing scripts underlines a disciplined deployment and testing lifecycle.
d. Relevant Technologies:
• Solidity & Foundry (with foundry.toml and forge commands) are used for contract development and testing.
• pnpm is used for package management.
• Libraries: OpenZeppelin, Forge Standard Library (forge-std), Solady.
• TypeScript scripts in ts-scripts suggest integration for offchain operations like signing and verifying contracts.