Skip to content
Business logic Audit finding Intermediate

Panoptic pool can be non-profitable by specific Uniswap governance

The contract converts a Uniswap pool fee into basis points by integer division, so any pool fee below 0.01% rounds down to zero. If Uniswap governance ever adds such a low fee level, the Panoptic pool would charge no swap commission on in-the-money positions.

petro_1912 Follow with Joshuajee

Originally disclosed on Code4rena

Submitted by petro_1912, also found by Joshuajee

https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/CollateralTracker.sol#L247-L251

https://github.com/code-423n4/2024-04-panoptic/blob/main/contracts/CollateralTracker.sol#L261-L263

Swap commission is paid on the intrinsic value based on s_ITMSpreadFee in CollateralTracker contract. If s_ITMSpreadFee is zero, then swap commission can not be paid.

Proof of Concept

    function startToken(
        bool underlyingIsToken0,
        address token0,
        address token1,
        uint24 fee,
        PanopticPool panopticPool
    ) external {

        __SNIP__
        // cache the pool fee in basis points
        uint24 _poolFee;
        unchecked {
            _poolFee = fee / 100; // @audit below fee 0.01%, then _poolFee = 0
        }
        s_poolFee = _poolFee;

        ...

        __SNIP__
        // Additional risk premium charged on intrinsic value of ITM positions
        unchecked {
            s_ITMSpreadFee = uint128((ITM_SPREAD_MULTIPLIER * _poolFee) / DECIMALS);
        }
    }

As you can see above code snippet, if fee(Uniswap fee) is below 100, then _poolFee and s_ITMSpreadFee can be zero. Currently, there are no such pools that have below 0.01% fee on the UniswapV3. But Uniswap fee level can be adjusted by the governance proposal like November 2021. Here is the mention about it in Uniswap Protocol:

Uniswap v3 introduces multiple pools for each token pair, each with a different swapping fee. Liquidity providers may initially create pools at three fee levels: 0.05%, 0.30%, and 1%. More fee levels may be added by UNI governance, e.g. the 0.01% fee level added by this governance proposal in November 2021, as executed here.

https://dune.com/jcarnes/The-StableSwap-Wars

Competitions between Protocols like Uniswap and Carbon, more fee levels can be added in the future.

Indeed, there are several discussions on the less fee levels in stable coins pair. https://gov.bancor.network/t/custom-taker-fee-on-stable-to-stable-trades/4370

  • Carbon has a protocol wide fee of 20 BP (basis points).
  • This fee, while appropriate for volatile pairs - is not in line with the market when it comes to stable to stable trades.
  • For reference, Uniswap added a 1 BP fee option (0.01%) - in November 2021 (link)
  • This proposal seeks to take this one step further and introduce a fee of 0.001% on stable to stable trades. This is 1/10th of a single basis point.

If protocol fee is less than 100 (i.e fee < 0.01 %), then PanopticPool’s swap commission can not be taken.

Recommended Mitigation Steps

Use Uniswap’s DECIMALS (1e6) instead 10_000 and update all code related to DECIMALS.

Assessed type

Uniswap

dyedm1 (Panoptic) confirmed

Picodes (judge) commented:

This report shows how the current version of the protocol may not support all Uniswap V3 pools whereas the sponsor’s label suggests it was their intention, so Medium severity seems appropriate under “broken functionality”.


The original report as published on Code4rena, by petro_1912. 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 fee is scaled down with integer division into basis points, so fees below 0.01% truncate to zero and the spread fee derived from it also becomes zero.

Impact

If Uniswap governance introduces a fee level below 0.01%, the Panoptic pool could not collect swap commission, making it non-profitable for those pools; no such pool exists today.

What the attacker needed

Uniswap governance adds a fee below 0.01%

The fix

The code should use Uniswap's own decimal scale (1e6) instead of 10,000 and update all related code.

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 pool charges a small commission on trades, and that commission is calculated from the pool's fee level. The code divides the fee by 100 to convert it to a smaller unit, and whole-number division throws away the remainder, so a very small fee becomes zero. The result is that the pool would earn nothing on those trades.

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 from Panoptic

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.