Earn 5% APR on staked ETH with instant withdrawals - built with Hardhat v3 for secure DeFi staking.
StakeVault is a decentralized ETH staking protocol that enables users to earn passive income through a simple and secure smart contract. Users can deposit any amount of ETH and start earning 5% Annual Percentage Rate (APR) immediately, with rewards calculated automatically based on staking duration.
Key Features: • Flexible Staking: Deposit any amount of ETH with no minimum requirements • 5% APR: Competitive annual returns calculated pro-rata based on time staked • No Lock-up Period: Withdraw your principal and earned rewards anytime • Automatic Reward Calculation: Time-weighted rewards computed on-chain in real-time • Gas Efficient: Optimized Solidity code minimizes transaction costs • Fully Tested: 13 comprehensive tests (6 Solidity + 7 TypeScript) ensuring security
The smart contract tracks each user's deposit time and balance, calculating rewards using the formula: reward = (balance × 5% × time_staked) / 365_days
This means if you stake 10 ETH for 37 days, you'll earn approximately 0.05 ETH in rewards. The contract handles all calculations on-chain, ensuring transparency and trustless operation.
StakeVault demonstrates modern DeFi principles with a focus on simplicity, security, and user experience. It's designed for both individual stakers looking for passive income and as a building block for more complex DeFi protocols.
Live Contract: 0xf8c7cce6a80140b6c6cba4fe9ca172b6c544fe75 (Sepolia Testnet)
Technical feedback for Avail Nexus SDK is included in the project README.
StakeVault was built entirely with Hardhat v3, leveraging the latest features and best practices in Ethereum development.
Core Technologies:
Hardhat v3 (3.0.9) - The latest version of Hardhat with ESM support
Solidity 0.8.28 - Latest stable version
Viem (2.38.4) - Modern TypeScript library replacing ethers.js
Testing Stack:
Development Tools:
Notable Technical Decisions:
• Integer Math Precision: Since Solidity doesn't support floating-point, we calculate rewards as (balance × rate × time) / (seconds_per_year × 100). This means the effective APR shows slight variations over short periods (4% after 7 days, 4.93% after 37 days) but converges to 5% over longer durations.
• Vault Funding Strategy: The contract needs pre-funded ETH to pay rewards. In tests, we use testClient.setBalance() to fund the vault with 100 ETH. In production, this would be handled through protocol fees or treasury allocations.
• Dual Testing Approach: Combining Solidity unit tests (fast, focused) with TypeScript integration tests (realistic, full workflow) ensures both contract logic correctness and real-world usability.
• Time Travel for Demos: Created demo scripts that use Hardhat's time manipulation to compress 37 days of staking into seconds, allowing judges to see the complete lifecycle instantly.
Hardhat v3 Specific Features Used:
Particularly Hacky/Clever Solutions:
Demo Script with Delays: Added 4-second pauses between steps in demo-local.ts using async/await, making it perfect for live video demonstrations without visible "waiting" messages.
getUserInfo Helper Function: Added a view function that returns (staked, rewards, depositTime) in one call, reducing RPC calls and improving frontend performance.
Automatic Vault Funding in Tests: Instead of manually funding the vault before each test, we added vm.deal() in setUp() to ensure the vault always has 100 ETH for reward payouts.
Multiple Demo Scripts: Created separate scripts (demo-deposit, demo-check-rewards, demo-withdraw, demo-multi-user) for modular demonstrations, plus one comprehensive demo-local.ts that shows the entire flow.
The project showcases modern Ethereum development practices while maintaining simplicity and security, making it both a functional DeFi protocol and an educational reference for Hardhat v3 patterns.
Technical feedback for Avail Nexus SDK is included in the project README.

