hats-finance / Inverter-Network-0xe47e52c4fea05e555920f1dcdcc6fb8eca103eeb

Fork of the Inverter Smart Contracts Repository
GNU Lesser General Public License v3.0
0 stars 3 forks source link

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

Open hats-bug-reporter[bot] opened 3 months ago

hats-bug-reporter[bot] commented 3 months ago

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.

FHieser commented 3 months ago

Sounds reasonable