Skip to content

EquiFund is a decentralized quadratic funding platform built on Base Sepolia that amplifies the impact of small donations through mathematical fairness. Where your voice matters more than your wallet size.

Notifications You must be signed in to change notification settings

Mrwicks00/EquiFund

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EquiFund 🌟

Democratizing Public Goods Funding Through Quadratic Matching

EquiFund is a decentralized quadratic funding platform built on Base Sepolia that amplifies the impact of small donations through mathematical fairness. Where your voice matters more than your wallet size.

Built on Base Foundry License: MIT


πŸ“– What is Quadratic Funding?

Quadratic Funding (QF) is a mathematically optimal way to fund public goods in democratic communities. It works by:

  • Amplifying Small Donations: A project with 100 people donating $1 receives more matching funds than one person donating $100
  • Preventing Whale Dominance: Large donors can't monopolize the matching pool
  • Community Signal: Broad support matters more than total capital
  • Math-Enforced Fairness: The quadratic formula ensures democratic distribution

The Formula

Project Match = (Σ√contribution_i)² 

Each project's share of the matching pool is proportional to the square of the sum of square roots of contributions.


🎯 Features

MVP (Current)

  • βœ… Funding Rounds: Time-bound contribution periods with matching pools
  • βœ… Project Registry: Verified projects eligible for funding
  • βœ… Quadratic Matching: Automated calculation and distribution
  • βœ… Sybil Resistance: Basic cooldown mechanism to prevent gaming
  • βœ… Transparent: All contributions and matches on-chain
  • βœ… Base Sepolia: Deployed on L2 for low gas fees

Roadmap

  • πŸ”œ Multi-token support (ERC20)
  • πŸ”œ Advanced Sybil resistance (BrightID/Gitcoin Passport integration)
  • πŸ”œ Governance voting on project eligibility
  • πŸ”œ Automated round scheduling
  • πŸ”œ Grant streaming/vesting
  • πŸ”œ Multi-chain deployment

πŸ—οΈ Architecture

Smart Contracts

src/
β”œβ”€β”€ EquiFundPool.sol      # Main funding pool & round management
β”œβ”€β”€ ProjectRegistry.sol    # Whitelisted projects registry
β”œβ”€β”€ QuadraticMath.sol      # QF formula implementation
└── SybilGuard.sol         # Anti-gaming mechanisms

Contract Overview

Contract Purpose Key Functions
EquiFundPool Manages funding rounds, contributions, and matching distribution contribute(), finalizeRound(), withdrawMatching()
ProjectRegistry Maintains verified projects list registerProject(), isProjectActive()
QuadraticMath Pure math library for QF calculations calculateMatch(), sqrt()
SybilGuard Prevents multiple contributions from same entity checkEligibility(), recordContribution()

πŸš€ Getting Started

Prerequisites

  • Foundry installed
  • Node.js v18+ (for frontend)
  • Base Sepolia ETH (faucet)
  • MetaMask or compatible wallet

Installation

# Clone the repository
git clone https://github.com/yourusername/equifund.git
cd equifund

# Install Foundry dependencies
forge install

# Install OpenZeppelin contracts
forge install OpenZeppelin/openzeppelin-contracts

# Install frontend dependencies (if applicable)
cd frontend
npm install

Environment Setup

Create a .env file in the project root:

# Network
BASE_SEPOLIA_RPC_URL=https://sepolia.base.org
CHAIN_ID=84532

# Deployment
PRIVATE_KEY=your_private_key_here
ETHERSCAN_API_KEY=your_basescan_api_key

# Contract Addresses (after deployment)
EQUIFUND_POOL=0x...
PROJECT_REGISTRY=0x...
SYBIL_GUARD=0x...

πŸ”¨ Development

Compile Contracts

forge build

Run Tests

# Run all tests
forge test

# Run with verbosity
forge test -vvv

# Run specific test
forge test --match-test testContribution

# Generate gas report
forge test --gas-report

Test Coverage

forge coverage

Deploy to Base Sepolia

# Deploy all contracts
forge script script/Deploy.s.sol --rpc-url $BASE_SEPOLIA_RPC_URL --broadcast --verify

# Deploy with mock data for testing
forge script script/MockSetup.s.sol --rpc-url $BASE_SEPOLIA_RPC_URL --broadcast

Local Development

# Start local Anvil node
anvil

# Deploy to local node (new terminal)
forge script script/Deploy.s.sol --rpc-url http://localhost:8545 --broadcast

πŸ“ Usage

For Contributors

  1. Connect Wallet: Connect to Base Sepolia network
  2. Browse Projects: View active projects in current round
  3. Contribute: Donate ETH to projects you support
  4. Track Impact: See your contribution + projected match amount

For Project Owners

  1. Register: Submit project for admin approval
  2. Get Verified: Admin verifies project legitimacy
  3. Receive Funds: Collect contributions during round
  4. Claim Match: Withdraw matched funds after round finalization

For Administrators

  1. Create Round: Set duration and add matching pool
  2. Register Projects: Approve eligible projects
  3. Finalize Round: Calculate and distribute matches
  4. Monitor: Track participation and prevent abuse

πŸ§ͺ Testing Scenarios

Test Cases Covered

  • βœ… Single vs multiple contributors
  • βœ… Whale dominance prevention (1 donor $100 vs 100 donors $1)
  • βœ… Quadratic formula accuracy
  • βœ… Sybil guard cooldown enforcement
  • βœ… Round finalization idempotency
  • βœ… Access control (admin-only functions)
  • βœ… Edge cases (zero contributions, single project)
  • βœ… Reentrancy protection
  • βœ… Emergency withdrawal

Example Test

function testQuadraticAmplification() public {
    // 1 whale donates 100 ETH
    vm.prank(whale);
    pool.contribute{value: 100 ether}(projectA);
    
    // 100 smols donate 1 ETH each
    for(uint i = 0; i < 100; i++) {
        vm.prank(smols[i]);
        pool.contribute{value: 1 ether}(projectB);
    }
    
    pool.finalizeRound();
    
    // ProjectB should receive more matching funds
    assert(pool.getProjectMatchAmount(1, projectB) > 
           pool.getProjectMatchAmount(1, projectA));
}

🎨 Frontend

The frontend is built with modern web3 tooling:

  • Framework: React + Vite / Next.js
  • Styling: Tailwind CSS + Framer Motion
  • Web3: wagmi + viem
  • UI: Glass-morphism design with animated elements
  • Charts: Recharts for data visualization

Run Frontend

cd frontend
npm run dev

Visit http://localhost:5173


πŸ”’ Security

Audits

  • ⚠️ Not audited yet - MVP for testnet only
  • DO NOT use on mainnet without professional audit

Security Features

  • OpenZeppelin battle-tested contracts
  • ReentrancyGuard on all payable functions
  • Access control (Ownable pattern)
  • Pausable emergency stops
  • Checks-effects-interactions pattern
  • SafeMath for overflow protection

Known Limitations (MVP)

  • Basic Sybil resistance (time-based cooldown only)
  • Centralized admin control
  • No dispute resolution mechanism
  • Single token support (ETH only)

🀝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Write tests for new features
  • Follow Solidity style guide
  • Comment complex logic
  • Update documentation
  • Run forge fmt before committing

πŸ“š Resources

Learn About Quadratic Funding

Technical Documentation


πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ™ Acknowledgments

  • Gitcoin: For pioneering quadratic funding in crypto
  • Vitalik Buterin: For the quadratic funding mechanism
  • Base: For the scalable L2 infrastructure
  • OpenZeppelin: For secure smart contract libraries
  • Foundry: For the blazing fast development toolkit

πŸ“ž Contact & Community


πŸ’‘ Why EquiFund?

"In traditional funding, $1 from a billionaire equals $1 from a student. In EquiFund, community consensus matters more than capital size. We're building a funding mechanism where democracy meets math."

Built with ❀️ for public goods


🎯 Quick Links


Star ⭐ this repo if you believe in democratizing public goods funding!

About

EquiFund is a decentralized quadratic funding platform built on Base Sepolia that amplifies the impact of small donations through mathematical fairness. Where your voice matters more than your wallet size.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •