# Incorrect tick parameter in collectFees() function leads to loss of vesting position fees or possible complete protocol lockup

Strategy.collectFees uses mainPosition.tickUpper instead of vestPosition.tickUpper, causing fee loss or revert that locks the protocol.

- Payout: Audit contest
- Severity: high
- Program: Yieldoor
- Found by: 0xaxaxa
- Disclosed: 2025-02-21
- Write-up quality: 7/10
- Original: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/376
- Library page: https://bugbountylibrary.com/r/sherlock%3A2025-02-yieldoor%3AH-6
- Tags: area:web3 domain:web3 impact:dos impact:funds-loss kind:contest platform:sherlock sev:high tech:evm tech:solidity technique:source-review vuln:accounting-error vuln:dos

**Target:** Strategy.sol collectFees() in Uniswap V3 LP strategy
**Root cause:** collectFees passes vestPosition.tickLower with mainPosition.tickUpper to collectPositionFees; after rebalance() changes main ticks, the pair no longer matches the vesting position and may invert (lower > upper).
**Steps:**
1. Deploy Strategy with vesting position created using mainPosition ticks.
2. Call `rebalance()` which invokes `_setMainTicks(tick)` and changes mainPosition.tickLower/tickUpper.
3. Call `collectFees()`; it executes `collectPositionFees(vestPosition.tickLower, mainPosition.tickUpper)`.
4. Observe fees not collected from vesting position, or if `vestPosition.tickLower > mainPosition.tickUpper`, Uniswap `collect()` reverts with TLU.
5. Because `_withdrawPartOfVestingPosition()` is only called from collectFees, the vesting position cannot be closed, blocking deposit/withdraw/rebalance/compound.
**How found:** Code review of collectFees noticed mismatched tick variables; traced vesting position creation and rebalance() tick mutation to confirm divergence.
**Exploitation:** No attacker action needed; any call to collectFees after a rebalance triggers incorrect fee collection or a revert, causing protocol lockup or fee loss.
**Escalation:** Revert in collectFees propagates to deposit(), withdraw(), rebalance(), and compound(), causing complete protocol lockup.
**Insight:** When a contract caches position boundaries at creation, audit every later use of those boundaries after any function that mutates the original position's ticks; mismatched tick pairs can invert and revert Uniswap V3 collect().

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

**collectFees uses mainPosition.tickUpper for vesting position**

```
if (ongoingVestingPosition) {
    collectPositionFees(vestPosition.tickLower, mainPosition.tickUpper);
}
```

**Vesting position initialized with main position ticks**

```
vp.tickLower = mainPosition.tickLower;
        vp.tickUpper = mainPosition.tickUpper;
```

**_setMainTicks changes main position ticks on rebalance**

```
function _setMainTicks(int24 tick) internal {
        int24 halfWidth = int24(positionWidth / 2);
        int24 modulo = tick % tickSpacing;
        if (modulo < 0) modulo += tickSpacing; // if tick is negative, modulo is also negative
        bool isLowerSided = modulo < (tickSpacing / 2);

        int24 tickBorder = tick - modulo;
        if (!isLowerSided) tickBorder += tickSpacing;
        mainPosition.tickLower = tickBorder - halfWidth;
        mainPosition.tickUpper = tickBorder + halfWidth;

        emit NewMainTicks(tickBorder - halfWidth, tickBorder + halfWidth);
```

