The code contains an issue where users can exploit the staking system by repeatedly staking and unstaking to farm points. The current implementation does not account for points being deducted when a user unstakes, leading to a potential abuse of the system.
The smart contract includes an unstake
function that allows users to remove their staked tokens. However, the current event listener in the JavaScript code only listens to the STAKED
event and increments the user's points when they stake tokens. There is no corresponding listener for the UNSTAKED
event to reduce the points when a user unstakes. This loophole allows users to stake, earn points, and then unstake without losing the points, thereby enabling them to repeatedly farm points without maintaining a stake.
This vulnerability allows users to artificially inflate their points by repeatedly staking and unstaking, which could lead to an unfair distribution of rewards, compromise the integrity of the staking system, and potentially affect the overall tokenomics of the project.
Vyper smart contract
ethers
library
JavaScript
To mitigate this issue, the code should be updated to listen for the UNSTAKED
event and appropriately deduct points from the user's account when they unstake tokens. Below is an example of how the code can be modified to include this logic:
This ensures that points are accurately adjusted based on both staking and unstaking actions, preventing users from exploiting the system to farm points.
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.