Skip to content

cypherpulse/HoneyDEX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

942 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HoneyDEX

License: MIT Solidity Foundry

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.

Table of Contents

Overview

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.

Features

  • 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.

Architecture

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
Loading

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.

System Flow

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
Loading

Contracts

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)

HoneyDEX

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)

Getting Started

Prerequisites

  • Foundry: For compilation and testing.
  • Node.js: Version 16+ for tooling.
  • Ethereum wallet (e.g., MetaMask) configured for Base network.

Installation

  1. Clone the repository:

    git clone https://github.com/your-repo/basedhoney.git
    cd basedhoney/contract
  2. Install Foundry dependencies:

    forge install
  3. Build the project:

    forge build

Deployment

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 --verify

Replace $PRIVATE_KEY with your deployer key. For verification, set ETHERSCAN_API_KEY.

Usage

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() or swapHoneyForEth().

API Reference

For detailed function signatures and parameters, refer to the Solidity source files. Key interfaces:

Security

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.

Testing

Run tests with Foundry:

forge test

For gas reporting:

forge test --gas-report

Coverage includes unit tests for contracts and integration tests for full flows.

Contributing

Contributions are welcome. Follow these steps:

  1. Fork the repository.
  2. Create a branch: git checkout -b feature/your-feature.
  3. Implement changes with tests.
  4. Ensure forge test passes.
  5. Submit a pull request.

Guidelines:

  • Adhere to Solidity Style Guide.
  • Include documentation for new functions.
  • Update tests for modified logic.

Learning Resources

License

Licensed under the MIT License. See LICENSE for details.

About

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 automated market maker exchange for seamless trading of these tokens with ETH.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors