Skip to content
Business logic Audit finding Intermediate

_getPositionTVL of UNIv3Connector wrongly assumes ownership of all liquidity of the provided ticks inside positionManager

The `_getPositionTVL` function in the UNIv3Connector contract calculates the total value locked (TVL) by querying the Uniswap V3 pool's `positions` mapping using a key derived only from the position manager and tick range, without verifying that the connector actually owns that liquidity. This causes the TVL to be overstated, potentially inflating the protocol's perceived assets and undermining solvency.

said Follow with SBSecurity, BenRai and 1 other

Originally disclosed on Code4rena

Submitted by said, also found by SBSecurity, BenRai, and SeveritySquad

Impact

When _getPositionTVL is called, it queries position information from the pool using the calculated key. However, it assumes that all liquidity within the provided ticks in the positionManager is owned by the connector.

Proof of Concept

When _getPositionTVL is called, it calculate key by providing positionManager, tL, tU. Then used the key to get liquidity information inside the pool.

https://github.com/code-423n4/2024-04-noya/blob/main/contracts/connectors/UNIv3Connector.sol#L136-L138

    function _getPositionTVL(HoldingPI memory p, address base) public view override returns (uint256 tvl) {
        PositionBP memory positionInfo = registry.getPositionBP(vaultId, p.positionId);
        uint256 tokenId = abi.decode(p.data, (uint256));
        (address token0, address token1) = abi.decode(positionInfo.data, (address, address));
        uint256 amount0;
        uint256 amount1;
        (int24 tL, int24 tU, uint24 fee) = abi.decode(p.additionalData, (int24, int24, uint24));
        {
            IUniswapV3Pool pool = IUniswapV3Pool(factory.getPool(token0, token1, fee));
>>>         bytes32 key = keccak256(abi.encodePacked(positionManager, tL, tU));

>>>         (uint128 liquidity,,, uint128 tokensOwed0, uint128 tokensOwed1) = pool.positions(key);

            (uint160 sqrtPriceX96,,,,,,) = pool.slot0();
            (amount0, amount1) = LiquidityAmounts.getAmountsForLiquidity(
                sqrtPriceX96, TickMath.getSqrtRatioAtTick(tL), TickMath.getSqrtRatioAtTick(tU), liquidity
            );
            amount0 += tokensOwed0;
            amount1 += tokensOwed1;
        }

        tvl += valueOracle.getValue(token0, base, amount0);
        tvl += valueOracle.getValue(token1, base, amount1);
    }

This assumption is incorrect as it presumes that all liquidity within the provided ticks is owned by Noya’s UniV3 Connector. This leads to wrong TVL calculation within the protocol, potentially inflating the TVL beyond its actual value. Consequently, this could undermine the protocol’s solvency by incorrectly inflating its perceived total assets.

Recommended Mitigation Steps

User positionsManager positions getter instead to provide accurate liquidity owner by connector.

HadiEsna (NOYA) confirmed and commented:

True, needs to be fixed. Not High severity though in my opinion.


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

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

Root cause

Likely, the function uses the pool's `positions` mapping with a key that does not include the owner address, so it retrieves the total liquidity for that tick range regardless of who owns it.

Impact

The TVL calculation is inflated, which could undermine the protocol's solvency by overstating its total assets.

What the attacker needed

None

The fix

The function should use the position manager's `positions` getter to retrieve liquidity owned by the connector, rather than querying the pool directly.

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.

This report is about a smart contract that tracks how much money (TVL) is in a Uniswap V3 position. The contract mistakenly counts all liquidity in a given price range as its own, even if other people own some of it. That makes the protocol look richer than it is, which could cause problems if people rely on that number.

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 said

View all

21 more disclosed reports, best first.

More from NOYA

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.