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.
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
| 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 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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) β β
β ββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
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
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)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 |
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.
- 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"
# Clone the repository
git clone https://github.com/BahadorGh/HooLotto.git
cd HooLotto
# Install dependencies
forge install
# Build
forge build# 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 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 |
// After deploying the hook and initializing a pool
hook.enablePool(poolId);// Claim all pending rewards across epochs
(uint128 claimed0, uint128 claimed1) = hook.claimRewards(poolId);(uint128 claimable0, uint128 claimable1) = hook.getClaimableRewards(poolId, userAddress);// Enable NFT boost for a collection
hook.configureNFTBoost(
nftContractAddress,
ILotteryRewardsHook.NFTBoostTier.Legendary,
true // enabled
);// Anyone can trigger (after week ends)
hook.drawJackpot(poolId);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)
| 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 |
| 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 |
- Delayed Multiplier Reveal: Multipliers are calculated from block hash after epoch ends, preventing front-running
- Reentrancy Protection: All external functions use
nonReentrantmodifier - Safe Token Transfers: Uses OpenZeppelin's
SafeERC20 - Owner Controls: Pool enabling/disabling and NFT configuration require owner
No partner integrations (EigenLayer, Fhenix) are not used in this submission.
This hook is a standalone implementation focused on gamified reward distribution mechanics.
- Submission Type: Uniswap Hook Incubator (UHI)
- Demo Video: [I Link to demo video]
- GitHub: https://github.com/BahadorGh/HooLotto
- 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)
MIT
HooLotto Team