Skip to content
Business logic Audit finding Intermediate

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

The collectFees() function uses the main position's upper tick instead of the vesting position's upper tick when collecting fees, causing fees to be lost or the call to revert if the vesting lower tick exceeds the main upper tick. This can block deposit, withdraw, rebalance, and compound, and prevent the vesting position from being closed, potentially locking the protocol.

0xaxaxa Follow with AlexCzm, Drynooo and 16 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2025-02-yieldoor-judging/issues/376

Found by

0xaxaxa, AlexCzm, Drynooo, Foundation, HChang26, KiteWeb3, R-Nemes, Ragnarok, anchabadze, armoking32, azanux, eLSeR17, elolpuer, iamephraim, iamnmt, itsgreg, mussucal, octopus_testjjj, yotov721

Description:

In the collectFees() function of the Strategy contract, there is a critical error when collecting fees from the vesting position. The function incorrectly uses the upper tick of the main position (mainPosition.tickUpper) instead of the upper tick of the vesting position (vestPosition.tickUpper):

https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L167

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

Although the vesting position is created with the same ticks as the main position... https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L433

Solidity
        vp.tickLower = mainPosition.tickLower;
        vp.tickUpper = mainPosition.tickUpper;

...rebalance() function changes the ticks of the main position using the internal _setMainTicks() function, so after calling rebalance(), the ticks of the main position and the vesting position will no longer be the same https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L209

Solidity
function rebalance() public onlyRebalancer {
    // ...
    _setMainTicks(tick);
    // ...
}

https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L232

Solidity
    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);
    }

This mismatch in parameters means the contract is attempting to collect fees from a position defined by the lower tick of the vesting position and the upper tick of the main position, rather than from the actual vesting position and can lead to the situation where vestPosition.tickLower > mainPosition.tickUpper

Impact:

The protocol fails to collect fees that have accrued to the vesting position, resulting in direct financial loss and if vestPosition.tickLower > mainPosition.tickUpper, the call to collect() will revert, since Uniswap V3 requires the lower tick to be less than the upper tick. https://docs.uniswap.org/contracts/v3/reference/error-codes

MARKDOWN
TLU: The lower tick must be below the upper tick

This will cause the entire collectFees() function to revert, leading to failures in critical protocol functions such as deposit(), withdraw(), rebalance() and compound(), where collectFees() is a part of them. As a result, this can lead to a malfunction of the entire protocol.

Since the mechanism for closing the vesting position is inside the _withdrawPartOfVestingPosition() function, which is only called from collectFees()... https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L179 https://github.com/sherlock-audit/2025-02-yieldoor/blob/main/yieldoor/src/Strategy.sol#L459

...and collectFees() always reverts due to incorrect ticks, the vesting position cannot be closed, leading to a complete protocol lockup with no way to resolve the issue.

Recommended Mitigation:

Correct the parameter in the fee collection call to use the upper tick of the vesting position:

Diff
if (ongoingVestingPosition) {
-   collectPositionFees(vestPosition.tickLower, mainPosition.tickUpper);
+   collectPositionFees(vestPosition.tickLower, vestPosition.tickUpper);
}

The original report as published on Sherlock, by 0xaxaxa. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Impact

The protocol fails to collect fees from the vesting position, causing financial loss, and if the lower tick exceeds the upper tick, collectFees() reverts, blocking deposit, withdraw, rebalance, and compound, and preventing the vesting position from being closed, potentially locking the protocol.

What the attacker needed

Vesting position exists; rebalance() called after vesting creation; vestPosition.tickLower > mainPosition.tickUpper

The fix

The parameter in the fee collection call should be corrected to use the upper tick of the vesting position.

How it was found

  1. A vesting position is created with the same ticks as the main position.
  2. The rebalance() function changes the main position's ticks via _setMainTicks().
  3. The vesting position's ticks remain unchanged, so they no longer match the main position's ticks.
  4. collectFees() is called and uses vestPosition.tickLower and mainPosition.tickUpper to collect fees.
  5. If vestPosition.tickLower > mainPosition.tickUpper, the collect() call reverts, causing collectFees() to fail.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract collects trading fees from a special vesting position. It accidentally uses the wrong boundary (tick) for that position, so it either misses fees or tries to collect from an invalid range. If the range is invalid, the whole fee collection fails, and many other actions that depend on it also fail.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by 0xaxaxa

View all

4 more disclosed reports, best first.

More from Yieldoor

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.