Holder dividends and staking compete for the same balance · 33 Hardhat tests
DividendToken.sol is a mintable ERC-20 with ETH-backed mint/burn and owner-pushed dividends:
mint — send ETH (1 ETH = 1000 DTK)distributeDividends — owner pushes extra ETHwithdrawDividends — holders pull their shareburn — returns a slice of the ETH reservestake / unstake — staked tokens stop earning holder dividends until unstakedWhy this lab: after staking 300 of 1000 DTK, a 0.7 ETH distribution pays the holder 0.49 ETH (700/1000), not 0.7 ETH. Dividends follow the balance the contract sees.
Guards: ReentrancyGuard on mint, burn, withdraw, stake, unstake · onlyOwner on distributeDividends and fundStakingRewards.
Local Hardhat suite (no private key, no public network):
npm install npx hardhat test
Evidence 2026-09-09: 33 passing, 0 failing, 534ms.
| Group | Tests | Result |
|---|---|---|
| Deployment | 3 | pass |
| Minting | 5 | pass |
| Burning | 4 | pass |
| Dividend distribution | 8 | pass |
| Transfers and dividend tracking | 1 | pass |
| Staking | 5 | pass |
| View functions | 2 | pass |
| Edge cases | 3 | pass |
| Reentrancy guards still complete | 2 | pass |
The last two tests only check that burn and withdrawDividends finish under ReentrancyGuard. They are not an exploit suite and do not prove absence of bugs.
Source: test/DividendToken.test.js · evidence in results/tests.json and results/test-output.txt.
Author: Harsha Nandhan Reddy Gajulapalli · MIT · harshanandhanreddy820@gmail.com