# Bad check in `Vesting.sol::_resetVestingPlans` will prevent users from adding additional liquidity in `SymmVesting.sol`

Vesting.sol's _resetVestingPlans reverts when increasing locked tokens if new amount is below unlocked amount, blocking users from adding liquidity in SymmVesting.

- Payout: Audit contest
- Severity: medium
- Program: Symm Io Stacking
- Found by: 0x73696d616f
- Disclosed: 2025-03-05
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2025-03-symm-io-stacking-judging/issues/509
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-03-symm-io-stacking%3AM-3
- Tags: area:web3 domain:web3 impact:dos kind:contest platform:sherlock sev:medium tech:solidity technique:source-review vuln:business-logic

**Target:** Vesting.sol and SymmVesting.sol smart contracts
**Root cause:** The check `if (amount < vestingPlan.unlockedAmount()) revert AlreadyClaimedMoreThanThis();` in _resetVestingPlans incorrectly reverts when increasing locked tokens if the new total amount is less than the already unlocked amount, even though the increase is valid.
**Steps:**
1. Admin sets up a vesting plan for a user with 10e18 SYMM over 10 days.
2. User calls `addLiquidity(userVestAmount / 2, 0, 0)` to add half as liquidity.
3. Warp time forward 7 days so more than half of the LP vesting tokens are unlocked.
4. User calls `addLiquidity(secondLiquidityAmount, 0, 0)` where secondLiquidityAmount is the locked amount; transaction reverts with 'AlreadyClaimedMoreThanThis'.
**How found:** Likely identified by reviewing the _resetVestingPlans logic and noticing the check compares the new amount to unlockedAmount, which is incorrect when increasing locked tokens.
**Insight:** When reviewing vesting or staking contracts, check that reset functions correctly handle increases in locked amounts, especially when unlocked amounts are non-zero; a check meant to prevent decreasing below unlocked may wrongly block increases.

## Proof of concept (copied exactly from the original report)

**Foundry test proving addLiquidity reverts after unlock**

```
function testUsersWillBeUnableToProvideLiquidityAfterACertainNumberOfUnlockedTokens() public {
        //admin creates user vest with symm
        address user = makeAddr("user");
        uint256 userVestAmount = 10e18;
        uint256 totalVestedSymmAmount = 100e18;
        uint256 startTime = block.timestamp;
        uint256 endTime = block.timestamp + 10 days;
        deal(usdc, user, 1000e18); 

        address[] memory users = new address[](1);
        users[0] = user;
        uint256[] memory amounts = new uint256[](1);
        amounts[0] = userVestAmount;

        vm.startPrank(admin);
        deal(address(symm), address(symmVesting), totalVestedSymmAmount);
        symmVesting.setupVestingPlans(address(symm), startTime, endTime, users, amounts);
        vm.stopPrank();

        //user adds half their vested tokens as liquidity
        vm.startPrank(user);
        MockERC20(usdc).approve(address(symmVesting), type(uint256).max);
        symmVesting.addLiquidity(userVestAmount / 2, 0, 0);
        vm.stopPrank();

        //move time so more than half of created symm_lp vesting tokens are unlocked
        vm.warp(block.timestamp + 7 days);

        uint256 secondLiquidityAmount = symmVesting.getLockedAmountsForToken(user, address(symm));

        //second addLiquidity call will revert with "AlreadyClaimedMoreThanThis" error
        vm.startPrank(user);
        MockERC20(usdc).approve(address(symmVesting), type(uint256).max);
        vm.expectRevert();    
        symmVesting.addLiquidity(secondLiquidityAmount, 0, 0);
        vm.stopPrank();
    }
```

