When users acquire enough martenitsa tokens they can claim the corresponding amount of health tokens by calling MartenitsaMarketplace::collectReward
. This function updates the amount being claimed and it is discounted in future redemptions, however the way in which this value is updated is not correct.
MartenitsaMarketplace::_collectedRewards
stores how many health tokens a user has claimed, this value is updated after each function call as indicated below:
The number of health tokens to which the user is eligible is calculated as the substraction of the coefficient of the total number of owned martenitsas divided by the minimum required to claim one health token and the tokens claimed in the previous call. Since this update mechanism only takes into account the previous snapshot instead of the full history of claims, every health token acquired before the claim n-1
where n
represents the current number of claims, is rewarded for free to the user.
Users have access to unlimited health tokens by just minting 6 martentitsas. The process can be described into more detail as follows:
bob
acquires three martentisas.
bob
claims his health token. MartenitsaMarketplace::_collectedRewards
is updated to 1.
bob
acquires another three martentitas.
bob
claims another health token. MartenitsaMarketplace::_collectedRewards
is updated to 1, ignoring the previously claimed health token.
Since MartenitsaMarketplace::_collectedRewards
will only look at the previous snapshot, now the health token corresponding to claim n-2
will be rewarded for free in the next claim.
See PoC below.
Place this in MartenitsaMarketplace.t.sol
.
Foundry and manual review.
Implement a mechanism which compounds the previously claimed rewards instead of considering only the previous snapshot:
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.