Panoptic - Banditx0x's results

Effortless options trading on any token, any strike, any size.

General Information

Platform: Code4rena

Start Date: 27/11/2023

Pot Size: $60,500 USDC

Total HM: 7

Participants: 72

Period: 7 days

Judge: Picodes

Total Solo HM: 2

Id: 309

League: ETH

Panoptic

Findings Distribution

Researcher Performance

Rank: 60/72

Findings: 1

Award: $11.32

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

11.3163 USDC - $11.32

Labels

bug
downgraded by judge
grade-b
QA (Quality Assurance)
edited-by-warden
duplicate-211
Q-11

External Links

Lines of code

https://github.com/code-423n4/2023-11-panoptic/blob/aa86461c9d6e60ef75ed5a1fe36a748b952c8666/contracts/SemiFungiblePositionManager.sol#L1050-L1059

Vulnerability details

Impact

When there is borrowed liquidity, but zero net liquidity for a positionKey, the premia for the borrowed position is not updated.

Proof of Concept

liquidity.rightSlot is the net liquidity (totalLiquidity - removedLiquidity). It is possible for this value to be 0 when there has been liquidity added and 100% of the liquidity has been removed/borrowed. In this case, liquidity.leftSlot() is positive, while liquidity.rightSlot() is 0.

Within the _createLegInAmm function, the _collectAndWritePositionData is skipped if right slot is 0, even if there is a value in the left slot:

        if (currentLiquidity.rightSlot() > 0) {
            _totalCollected = _collectAndWritePositionData(
                _liquidityChunk,
                _univ3pool,
                currentLiquidity,
                positionKey,
                _moved,
                isLong
            );
        }

This makes some sense as when there is no net liquidity, no fees are collected via the collect call to the Uniswap pool. However, _collectAndWritePositionData also contains the _updatePremiaDelta function call. This is NOT meant to be skipped when there is non-zero removedLiquidity in the liquidity chunk. The premiaOwed ends up not being tracked for the borrowed liquidity.

Tools Used

Manual Review

Change:

if (currentLiquidity.rightSlot() > 0)

to:

if (currentLiquidity > 0)

Within the collectAndWritePositionData call, a condition could be added that the logic that collects the fees can is skipped when there is no net liquidity. However, the premia update should still execute if there is borrowed liquidity.

Assessed type

Invalid Validation

#0 - c4-judge

2023-12-14T13:07:05Z

Picodes marked the issue as duplicate of #362

#1 - c4-judge

2023-12-26T21:49:37Z

Picodes changed the severity to QA (Quality Assurance)

#2 - c4-judge

2023-12-26T23:08:51Z

Picodes marked the issue as grade-b

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter