Hodlock

On-chain CDs on Base. 100% principal protected. Earn from early exit penalties.

Hodlock

Created At

HackMoney 2026

Project Description

Hodlock is an on-chain Certificate of Deposit (CD) protocol deployed on Base (Ethereum L2) that solves DeFi's sustainability problem by creating a zero-sum reward mechanism where patient holders profit from impatient ones. Core Mechanism: Users deposit ERC20 tokens into individual Hodlock contracts (one per token type) for customizable lock periods (minimum 5 minutes, typically 30-365 days). Each deposit becomes a separate "certificate" with its own unlock time and penalty rate (5%-100%). The protocol uses a sophisticated share-based reward distribution system where longer locks receive exponentially higher shares (calculated as t²/(t+365 days)), ensuring long-term holders capture more rewards. Sustainable Yield Model: Unlike Ponzi-like yield farms that rely on constant new deposits, Hodlock generates rewards purely from early withdrawal penalties. When users withdraw before maturity, they forfeit a percentage of their principal (based on their chosen penalty rate) plus any accumulated rewards. These penalties are distributed proportionally to all remaining holders based on their shares. The protocol also includes a 10% developer fee and optional 30% referrer commission from penalties. Principal Protection: Your deposited tokens are always returned in full at maturity—no impermanent loss, no rug pulls, no dependency on external price feeds or liquidity pools. The smart contracts are non-upgradeable and fully auditable. NFT Certificates: Each deposit can mint a soulbound NFT (ERC-721) that serves as proof of your diamond-hand status. These NFTs are non-transferable during the lock period but become tradeable after maturity, creating a secondary market for matured positions. Referral System: Users can invite others with unique referral links. Referrers earn 30% of all early withdrawal penalties from their referees—permanently, with no expiration. This creates a sustainable passive income stream aligned with protocol growth. Technical Architecture: The system consists of four main contracts: HodlockFactory (deploys new token pools), Hodlock (core deposit/withdrawal logic with reentrancy guards and fee-on-transfer token support), HodlockNFT (soulbound certificates), and HodlockNFTRenderer (on-chain SVG metadata). The factory includes a blacklist to prevent incompatible tokens (like rebase tokens) from being added.

How it's Made

Smart Contract Stack: Built with Solidity 0.8.20 using OpenZeppelin's battle-tested libraries (ERC20, ERC721, Ownable, ReentrancyGuard, SafeERC20). The contracts are deployed on Base (Ethereum L2) for low gas costs and fast finality. We used Foundry for development, testing, and deployment, which provided superior testing capabilities compared to Hardhat. Core Architecture: The HodlockFactory contract uses the factory pattern to deploy individual Hodlock instances for each ERC20 token, ensuring isolated risk per token. Each Hodlock contract implements a sophisticated share-based reward distribution system inspired by MasterChef but adapted for penalty-based rewards instead of emissions. The share calculation formula (t²/(t+365 days)) creates a non-linear incentive curve that heavily favors long-term locks. Frontend Stack: Built with Next.js 14 (App Router), TypeScript, and Tailwind CSS for a modern, type-safe development experience. We used wagmi v2 + viem for blockchain interactions, which provides excellent TypeScript support and automatic ABI type inference. The UI leverages Framer Motion for smooth animations and shadcn/ui components for consistent design. We implemented a multi-step transaction flow that chains approve → deposit → mintNFT operations seamlessly, with clear progress indicators for users. Notable Technical Decisions:

Fee-on-Transfer Token Support: Implemented balance-checking before/after transfers to handle tokens that take fees on transfer. Precision Handling: Used a PRECISION factor (1e18) for reward calculations to support low-decimal tokens without losing accuracy; tracks accumulated remainders to prevent dust loss. Soulbound NFT Logic: Used a _hodlockBurning flag to allow contract-initiated burns during early withdrawal while preventing user burns/transfers before maturity (overrides ERC721 _update). Timelock for Fee Changes: 2-day timelock on developer and referrer fee modifications to prevent rug pulls. Dynamic Token Discovery: Frontend dynamically fetches all deployed Hodlock contracts from the factory and queries token metadata on-chain.

background image mobile

Join the mailing list

Get the latest news and updates