The staking rewards calculation in streets::unstake
uses integer division that truncates fractional days, causing users to lose rewards for staking periods under 24 hours. This creates unfair reward distribution where users staking for 23.9 hours receive zero rewards.
The calculation staked_duration / 86400
uses integer division that discards any remainder, effectively rounding down to the nearest whole day and penalizing users for partial day staking.
Likelihood:
Users staking for less than 24 hours will receive no rewards due to integer truncation
The truncation occurs on every unstake operation, affecting all users
The issue affects every staking period that isn't an exact multiple of 24 hours
Impact:
Unfair reward distribution penalizing users for partial day staking
Economic inefficiency where protocol doesn't compensate shorter staking periods
User frustration from lost rewards for near-full day staking
This PoC demonstrates the exact reward loss due to integer truncation:
The mitigation provides multiple options to address the truncation issue:
This mitigation provides fair compensation for all staking durations by eliminating the harsh truncation at 24-hour boundaries.
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.