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
Rank: 60/72
Findings: 1
Award: $11.32
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: osmanozdemir1
Also found by: 0xCiphky, Audinarey, Banditx0x, CRYP70, Cryptor, D1r3Wolf, KupiaSec, LokiThe5th, Sathish9098, Skylice, ThenPuli, Topmark, Udsen, ZanyBonzy, baice, ether_sky, fatherOfBlocks, foxb868, grearlake, hihen, hubble, hunter_w3b, lanrebayode77, leegh, lsaudit, minhtrng, nocoder, onchain-guardians, ptsanev, ro1sharkm, seaton0x1, sivanesh_808, t4sk, tapir, tpiliposian, ustas
11.3163 USDC - $11.32
When there is borrowed liquidity, but zero net liquidity for a positionKey, the premia for the borrowed position is not updated.
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.
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.
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