Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minimumStake Check in stake Function Prevents Existing Users from Adding Smaller Amounts #136

Open
hats-bug-reporter bot opened this issue Jun 16, 2024 · 1 comment
Labels
bug Something isn't working low

Comments

@hats-bug-reporter
Copy link

Github username: @0xmahdirostami
Twitter username: 0xmahdirostami
Submission hash (on-chain): 0x6527a4a1918635e5e5bc8e452b168130541067cc339a7d72bd0abeb48174c691
Severity: low

Description:
Description:
The stake function implements a minimumStake check to prevent anyone from filling the stakingQueue with small amounts. However, the issue arises when users who are already in the stakingQueue want to add a new amount that is lower than minimumStake. This check unnecessarily restricts existing users from staking additional smaller amounts.

Impact:
Users who are already in the stakingQueue cannot add new amounts if the new amount is lower than minimumStake.

Mitigation:
Modify the stake function to apply the minimumStake check only when the user is not already in the stakingQueue.

Proposed Change:

-        if (amount < minimumStake) {
-            revert Module__LM_PC_KPIRewarder_v1__InvalidStakeAmount();
-        }

         address sender = _msgSender();

         if (stakingQueueAmounts[sender] == 0) {
+            if (amount < minimumStake) {
+                revert Module__LM_PC_KPIRewarder_v1__InvalidStakeAmount();
+            }

This change ensures that the minimumStake check is only applied when the user is not already in the stakingQueue, allowing existing users to add smaller amounts without restriction.

@hats-bug-reporter hats-bug-reporter bot added the bug Something isn't working label Jun 16, 2024
@FHieser FHieser added the low label Jun 26, 2024
@FHieser
Copy link

FHieser commented Jun 26, 2024

Sounds reasonable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working low
Projects
None yet
Development

No branches or pull requests

1 participant