The MartenitsaMarketplace::collectRewards
function overwrites the _collectedRwards
instead of adding to it. The formula use to calculating the result amountRewards = (count / requiredMartenitsaTokens) - _collectedRewards[msg.sender];
is subtracting the collected tokens and the overwriting the collected result.
Let say Bob has gathered 3 Martenitsa tokens and want to collect his reward. If we use the formula amountRewards = (count / requiredMartenitsaTokens) - _collectedRewards[msg.sender];
. Bob gets 1 Health token as expected. Since the required Martenitsa token for 1 health token is 3.
If Bob comes back after some days with 6 Martenitsa tokens, he expects to get 2 Health token, but instead he gets 1.
lets use the formula; amountRewards = (count / requiredMartenitsaTokens) - _collectedRewards[msg.sender];
count = 6 Martenitsa token
requiredMarenitsaToken = 3
collectReward of Bob = 1
applying the formula
= (6/3) -1 = 2 - 1 = 1;
Now, amountRewards = 1 and it is push into bob's collected reward as seen below
This occurs because after subtracting the initial reward of bob, the amountRewards
is pushed into the mapping of the collectRewards instead of adding it
This could make your users feel like you are cheating them and they will call it a scam. It could also render the platform useless since the endpoint is HealthToken, and it's supposed to be 3: 1 with Martenitsa token but instead they are stuck with undervalued health token
proof of Concept
manual review
Add the rewards
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.