The incorrect staking logic lead to the incorrect distribution
User1 deposit early (T80-T84) when the rate is higher (1.2e27 for some period).
User2 stakes later (T83-T84) when the rate is lower (1.1 for some period).
The contract does not properly account for these changes, leading to User1 receiving fewer rewards than expected and User2 receiving more.
(totalRewards * userDeposit) / totalDeposits
Alice scenario
(100e18 * 50e18) / 110e18 = 45e18
(100e18 * 60e18) / 110e18 = 54e18
0.13 per 13 sec
((0.13 * 5) * 50) / 110 = 0.29 → receive Alice for 5 blocks if she stakes 50 tokens
((0.16 * 5) * 50) / 110 = 0.36 → receive Alice for 5 other blocks, with higher emission rate if she stakes 50 tokens
At the end of B90 she entitles for 0.65 reward tokens
((0.16 * 2) * 60) / 110 = 0.17 → receive Bob for 2 blocks if he stakes 60 tokens
At the end of B90 he entitles for 0.17 reward tokens
totalRewards = 0.82
(0.82 * 50) / 110 = 0.37 → rewards receive alice upon withdrawing
(0.82 * 60) / 110 = 0.44 → rewards receive bob upon withdrawing
| Block.timestamp | 80 | 81 | 82 | 83 | 84 |
|---|---|---|---|---|---|
| Alice | Alice | Alice | Alice | Alice | |
| Bob | Bob | ||||
| Bob | Bob | ||||
| Bob | Bob |
131944444444444444 (0.13e18) is basic emission rate upon contract deployment
231944444444444444 (0.23e18) is updated *PoC rate after some time.
Receive Alice for 2 blocks if she stakes 50e18 tokens with basic emission rate (80-82)
((131944444444444444 * 3) * 50e18) / 50e18 = 395833333333333332 (0.39e18)
Bob deposit 60e18 tokens more, the rate has updated. Now, from (83-84) Alice receive:
((231944444444444444 * 2) * 50e18) / 110e18 = 210858585858585858 (0.21e18)
Receive Bib for 2 blocks (83-84) if she stakes 60e18 tokens with updated emission rate
((231944444444444444 * 2) * 60e18) / 110e18 = 253030303030303029 (0.25e18)
totalRewards minted
131944444444444444 * 3 = 395833333333333332
231944444444444444 * 2 = 463888888888888888
= 859722222222222220 → 0.85e18
Upon final claiming, both Alice and Bob will receive
Alice
(859722222222222220 * 50e18) / 110e18 = 390782828282828281 (0.39e18)
Bob
(468939393939393939 * 60e18) / 60e18 = 468939393939393939 (0.46e18)
Funds loss for user
Manual reviwe
Implement correct staking logic
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.