Skip to content

HooLotto gamifies DeFi participation with lottery multipliers that level the playing field, hybrid rewards that give LPs passive income, and engagement drivers like jackpots and NFT boosts

Notifications You must be signed in to change notification settings

BahadorGh/HooLotto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HooLotto LotteryRewardsHook

A Uniswap V4 hook that implements a gamified lottery-based rewards system for liquidity providers (LPs) and swappers. Built on Uniswap V4's hook architecture, it transforms DeFi participation into an engaging experience with randomized multipliers, NFT boosts, and weekly jackpots.

Overview

The LotteryRewardsHook collects a 2% fee on all pool operations and redistributes rewards through a lottery system:

  • 1.8% goes to the rewards pool (distributed to participants)
  • 0.2% goes to the protocol owner

Key Features

Feature Description
🎰 Lottery Multipliers LPs earn 1-5x, swappers earn 1-3x on their contributions
πŸ’° Hybrid LP Rewards LPs earn from both liquidity provision AND ongoing swaps (50/50 split)
πŸ† Weekly Jackpots 10% of epoch rewards accumulate for weekly lottery drawings
πŸ“Š Volume Milestones Pool-wide bonuses at $100K (1.2x), $500K (1.5x), $1M (2x)
🎨 NFT Boosts Hold partner NFTs for 1.1x-2x reward multipliers
⏰ 24-Hour Epochs Daily reward distribution cycles

How It Works

Reward Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         2% Total Fee                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                 β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚   β”‚  1.8% Rewards   β”‚         β”‚   0.2% Owner    β”‚               β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚            β”‚                                                    β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”                                           β”‚
β”‚   β”‚                 β”‚                                           β”‚
β”‚   β–Ό                 β–Ό                                           β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”‚
β”‚ β”‚   90%   β”‚   β”‚    10%      β”‚                                   β”‚
β”‚ β”‚ Epoch   β”‚   β”‚  Jackpot    β”‚                                   β”‚
β”‚ β”‚ Rewards β”‚   β”‚   Pool      β”‚                                   β”‚
β”‚ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β”‚
β”‚      β”‚                                                          β”‚
β”‚      β–Ό                                                          β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚
β”‚ β”‚     Distributed Based On:              β”‚                      β”‚
β”‚ β”‚  β€’ Contribution amount                 β”‚                      β”‚
β”‚ β”‚  β€’ Random multiplier (1-5x LP, 1-3x)   β”‚                      β”‚
β”‚ β”‚  β€’ Volume tier bonus (up to 2x)        β”‚                      β”‚
β”‚ β”‚  β€’ NFT boost (up to 2x)                β”‚                      β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Hybrid LP Rewards Mechanism

LPs don't just earn from their own liquidity operationsβ€”they also earn a share of all swap fees in the pool:

                    Swap Fees (1.8% rewards portion)
                              β”‚
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚                               β”‚
              β–Ό                               β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚    50%    β”‚                  β”‚    50%    β”‚
        β”‚  Swapper  β”‚                  β”‚ LP Pool   β”‚
        β”‚  Lottery  β”‚                  β”‚  Rewards  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
                                             β”‚
                                             β–Ό
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚  Distributed proportionally  β”‚
                          β”‚  to LP liquidity share       β”‚
                          β”‚  Γ— lottery multiplier (1-5x) β”‚
                          β”‚  Γ— volume bonus              β”‚
                          β”‚  Γ— NFT boost                 β”‚
                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example:

  • LP1 provides 25% of pool liquidity β†’ earns 25% of LP swap rewards pool
  • LP2 provides 75% of pool liquidity β†’ earns 75% of LP swap rewards pool
  • Both also apply lottery multipliers and bonuses to their share

Multiplier System

Multipliers are revealed after the epoch ends to prevent manipulation:

Participant Type Multiplier Range Reveal Timing
Liquidity Providers 1x - 5x At epoch distribution
Swappers 1x - 3x At epoch distribution
LP Swap Rewards 1x - 5x At epoch distribution

The multiplier is calculated deterministically using:

keccak256(blockhash(endBlock), poolId, epochId, participant)

Volume Tier Bonuses

When combined epoch volume reaches milestones, all participants get boosted:

Tier Volume Threshold Bonus Multiplier
None < $100K 1.0x
πŸ₯‰ Bronze β‰₯ $100K 1.2x
πŸ₯ˆ Silver β‰₯ $500K 1.5x
πŸ₯‡ Gold β‰₯ $1M 2.0x

NFT Boosts

Configure partner NFT collections for additional reward multipliers:

Tier Boost Multiplier
Common 1.1x
Rare 1.25x
Epic 1.5x
Legendary 2.0x

The highest tier NFT held by a participant is used.

Weekly Jackpot

  • 10% of each epoch's rewards go to the jackpot pool
  • Drawing occurs after 7 epochs (1 week)
  • Winner selected weighted by weekly participation
  • Higher participation = more "tickets"

Installation

# Clone the repository
git clone https://github.com/BahadorGh/HooLotto.git
cd HooLotto

# Install dependencies
forge install

# Build
forge build

Testing

# Run all tests
forge test

# Run with fork (for mainnet integration tests)
forge test --fork-url https://ethereum-rpc.publicnode.com

# Run specific test suites
forge test --match-contract LotteryRewardsHookTest        # Unit tests
forge test --match-contract Integration                   # Integration tests  
forge test --match-contract Fork                          # Fork tests

# Run with verbosity
forge test -vvv

Test Coverage

Test Suite Tests Description
Unit Tests 65 Core functionality
Integration Tests 15 End-to-end scenarios
Fork Tests 24 Mainnet DAI/WETH pool
Total 104 Full coverage

Usage

Enabling a Pool

// After deploying the hook and initializing a pool
hook.enablePool(poolId);

Claiming Rewards

// Claim all pending rewards across epochs
(uint128 claimed0, uint128 claimed1) = hook.claimRewards(poolId);

Checking Claimable Rewards

(uint128 claimable0, uint128 claimable1) = hook.getClaimableRewards(poolId, userAddress);

Configuring NFT Boosts (Owner)

// Enable NFT boost for a collection
hook.configureNFTBoost(
    nftContractAddress,
    ILotteryRewardsHook.NFTBoostTier.Legendary,
    true // enabled
);

Drawing Weekly Jackpot

// Anyone can trigger (after week ends)
hook.drawJackpot(poolId);

Architecture

src/
β”œβ”€β”€ LotteryRewardsHook.sol      # Main hook implementation
└── interfaces/
    └── ILotteryRewardsHook.sol # Interface with all types and events

test/
β”œβ”€β”€ LotteryRewardsHook.t.sol           # Unit tests (65 tests)
β”œβ”€β”€ LotteryRewardsHook.integration.t.sol # Integration tests (15 tests)
└── LotteryRewardsHook.fork.t.sol      # Fork tests (24 tests)

Key Constants

Constant Value Description
REWARDS_FEE_BPS 180 (1.8%) Fee for rewards pool
OWNER_FEE_BPS 20 (0.2%) Fee for protocol
LP_SWAP_FEE_SHARE_BPS 5000 (50%) LP share of swap fees
EPOCH_DURATION 24 hours Epoch length
MAX_LP_MULTIPLIER 5 Maximum LP lottery multiplier
MAX_SWAP_MULTIPLIER 3 Maximum swapper lottery multiplier
JACKPOT_PERCENTAGE_BPS 1000 (10%) Jackpot allocation

Events

Event Description
EpochStarted New epoch begins
EpochDistributed Rewards distributed for epoch
ParticipantRegistered User registered for epoch
MultiplierRevealed Lottery multiplier assigned
RewardsClaimed User claimed rewards
SwapRewardsSplit Swap fee split between swapper/LP pools
LPPositionUpdated LP liquidity tracking updated
JackpotWon Weekly jackpot claimed
VolumeMilestoneReached Volume tier unlocked
NFTBoostApplied NFT boost applied to participant

Security Considerations

  1. Delayed Multiplier Reveal: Multipliers are calculated from block hash after epoch ends, preventing front-running
  2. Reentrancy Protection: All external functions use nonReentrant modifier
  3. Safe Token Transfers: Uses OpenZeppelin's SafeERC20
  4. Owner Controls: Pool enabling/disabling and NFT configuration require owner

Partner Integrations

No partner integrations (EigenLayer, Fhenix) are not used in this submission.

This hook is a standalone implementation focused on gamified reward distribution mechanics.

Hookathon Submission

What's New

  • Gamified lottery-based rewards for Uniswap V4
  • Hybrid LP rewards mechanism (LPs earn from swaps)
  • Weekly jackpot system
  • NFT boost integration
  • Volume milestone bonuses
  • 104 comprehensive tests (unit, integration, mainnet fork)

License

MIT

Author

HooLotto Team

About

HooLotto gamifies DeFi participation with lottery multipliers that level the playing field, hybrid rewards that give LPs passive income, and engagement drivers like jackpots and NFT boosts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published