HoneyDEX is a decentralized finance (DeFi) protocol on Ethereum's Base Layer 2 network, designed to empower honey farmers by enabling the tokenization of their physical honey into digital assets. It features an ERC-20 token (BaseHoney, where 1 token = 1kg of honey) and an automated market maker (AMM) exchange (HoneyDEX) for seamless trading of these tokens with ETH.
HoneyDEX provides a robust DeFi ecosystem for minting, trading, and managing digital honey tokens. The protocol integrates:
- BaseHoney: An ERC-20 token backed by honey commodities.
- HoneyDEX: An AMM DEX for efficient token swaps.
Key objectives include low-cost transactions, security, and community-driven liquidity.
- ERC-20 Compliance: Standard token interface with extensions for minting and burning.
- AMM Functionality: Constant product market maker with liquidity incentives.
- Fee Optimization: Minimal fees (0.001% minting, 0.3% swapping) for sustainability.
- Layer 2 Optimization: Deployed on Base for reduced gas costs and faster confirmations.
- OpenZeppelin Integration: Leverages battle-tested libraries for security.
The protocol's architecture is modular, separating token management from exchange operations.
graph TB
subgraph "User Layer"
U[Users]
end
subgraph "Contract Layer"
BH[BaseHoney Contract]
HD[HoneyDEX Contract]
end
subgraph "Infrastructure"
T[Treasury]
LP[Liquidity Pools]
end
U --> BH
U --> HD
BH --> T
HD --> BH
HD --> LP
LP --> T
Components:
- BaseHoney Contract: Handles token lifecycle (mint, burn, transfer).
- HoneyDEX Contract: Manages AMM logic, liquidity, and swaps.
- Treasury: Accumulates protocol fees.
- Liquidity Pools: ETH and BaseHoney reserves for trading.
User interactions follow a structured flow for token operations and trading.
sequenceDiagram
participant User
participant BaseHoney
participant HoneyDEX
participant Treasury
Note over User,Treasury: Minting Flow
User->>BaseHoney: mint(to, amount)
BaseHoney->>BaseHoney: Calculate fee (0.001%)
BaseHoney->>Treasury: Transfer fee
BaseHoney->>User: Mint tokens
Note over User,Treasury: Liquidity Provision
User->>HoneyDEX: addLiquidity(honeyAmount, ethAmount)
HoneyDEX->>HoneyDEX: Update reserves
HoneyDEX->>User: Mint LP tokens
Note over User,Treasury: Swapping
User->>HoneyDEX: swapEthForHoney(ethIn)
HoneyDEX->>HoneyDEX: Compute output (0.3% fee)
HoneyDEX->>Treasury: Collect fee
HoneyDEX->>User: Transfer BaseHoney
Note over User,Treasury: Liquidity Removal
User->>HoneyDEX: removeLiquidity(lpAmount)
HoneyDEX->>User: Return ETH + BaseHoney
Location: src/BaseHoney.sol
An ERC-20 token with controlled minting and burning.
Key Functions:
mint(address to, uint256 amount): Mints tokens with a fee to treasury.burn(uint256 amount): Burns caller's tokens.setMinter(address minter): Sets authorized minter (owner only).pause()/unpause(): Emergency controls.
Events:
MinterSet(address oldMinter, address newMinter)TreasurySet(address oldTreasury, address newTreasury)
Location: src/HoneyDEX.sol
An AMM DEX issuing LP tokens.
Key Functions:
addLiquidity(uint256 honeyAmount, uint256 ethAmountMin): Adds liquidity and mints LP tokens.removeLiquidity(uint256 lpAmount): Burns LP tokens and returns assets.swapEthForHoney(uint256 minOut): Swaps ETH for BaseHoney.swapHoneyForEth(uint256 honeyIn, uint256 minOut): Swaps BaseHoney for ETH.getPrice(): Returns current exchange rate.
Events:
LiquidityAdded(address provider, uint256 honeyAmount, uint256 ethAmount, uint256 lpTokens)LiquidityRemoved(address provider, uint256 lpAmount, uint256 ethOut, uint256 honeyOut)Swap(address user, uint256 ethIn, uint256 honeyIn, uint256 ethOut, uint256 honeyOut)
- Foundry: For compilation and testing.
- Node.js: Version 16+ for tooling.
- Ethereum wallet (e.g., MetaMask) configured for Base network.
-
Clone the repository:
git clone https://github.com/your-repo/basedhoney.git cd basedhoney/contract -
Install Foundry dependencies:
forge install
-
Build the project:
forge build
Deploy to Base testnet or mainnet using the script:
forge script script/DeployBase.s.sol --rpc-url https://mainnet.base.org --private-key $PRIVATE_KEY --broadcast --verifyReplace $PRIVATE_KEY with your deployer key. For verification, set ETHERSCAN_API_KEY.
Interact via Etherscan or a frontend:
- Mint Tokens: Authorized minters call
BaseHoney.mint(). - Add Liquidity: Users call
HoneyDEX.addLiquidity()with ETH and tokens. - Swap: Use
HoneyDEX.swapEthForHoney()orswapHoneyForEth().
For detailed function signatures and parameters, refer to the Solidity source files. Key interfaces:
BasedHoney prioritizes security through:
- Audits: Planned third-party audit by a reputable firm (e.g., OpenZeppelin or Certik). Contact maintainers for status.
- OpenZeppelin Libraries: ReentrancyGuard, Ownable, Pausable for protection.
- Testing: Comprehensive test suite covering edge cases.
- Bug Bounty: Report vulnerabilities to security@basedhoney.com (placeholder).
Do not use in production without audit completion.
Run tests with Foundry:
forge testFor gas reporting:
forge test --gas-reportCoverage includes unit tests for contracts and integration tests for full flows.
Contributions are welcome. Follow these steps:
- Fork the repository.
- Create a branch:
git checkout -b feature/your-feature. - Implement changes with tests.
- Ensure
forge testpasses. - Submit a pull request.
Guidelines:
- Adhere to Solidity Style Guide.
- Include documentation for new functions.
- Update tests for modified logic.
Licensed under the MIT License. See LICENSE for details.