Good Entry - UniversalCrypto's results

The best day trading platform to make every trade entry a Good Entry.

General Information

Platform: Code4rena

Start Date: 01/08/2023

Pot Size: $91,500 USDC

Total HM: 14

Participants: 80

Period: 6 days

Judge: gzeon

Total Solo HM: 6

Id: 269

League: ETH

Good Entry

Findings Distribution

Researcher Performance

Rank: 69/80

Findings: 1

Award: $15.35

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

15.3494 USDC - $15.35

Labels

bug
downgraded by judge
grade-b
QA (Quality Assurance)
duplicate-162
Q-02

External Links

Lines of code

https://github.com/code-423n4/2023-08-goodentry/blob/71c0c0eca8af957202ccdbf5ce2f2a514ffe2e24/contracts/TokenisableRange.sol#L338

Vulnerability details

Impact

The asset ratio calculation in returnExpectedBalanceWithoutFees may round to 0 with tokens that have a substantial price difference, returning incorrect values which may prevent the case for fees to be accumulated

Proof of Concept

(amt0, amt1) = LiquidityAmounts.getAmountsForLiquidity( uint160( sqrt( (2 ** 192 * ((TOKEN0_PRICE * 10 ** TOKEN1.decimals) / TOKEN1_PRICE)) / ( 10 ** TOKEN0.decimals ) ) ), TickMath.getSqrtRatioAtTick(lowerTick), TickMath.getSqrtRatioAtTick(upperTick), liquidity);

This function calculates sqrtPriceX96, using square root of token0Price and token1Price, corrected for difference in decimals.

The issue is caused by the inner function (2 ** 192 * ((TOKEN0_PRICE * 10 ** TOKEN1.decimals) / TOKEN1_PRICE)) / (10 ** TOKEN0.decimals) which may round to 0 making the whole expression 0, which incorrectly represents the expected value.

If this is the case then when calling claimFees() the condition which compounds the fees will never be reached

(uint256 bal0, uint256 bal1) = returnExpectedBalanceWithoutFees(0, 0); // If accumulated more than 1% worth of fees, compound by adding fees to Uniswap position if ((fee0 * 100 > bal0 ) && (fee1 * 100 > bal1)) {

Tools Used

manual

uint160( sqrt( (2 ** 192 * TOKEN0_PRICE) / ( TOKEN1_PRICE / 10 ** (TOKEN1.decimals - TOKEN0.decimals) ) ) ) to prevent rounding to 0

Assessed type

Math

#0 - c4-pre-sort

2023-08-09T07:42:50Z

141345 marked the issue as duplicate of #106

#1 - c4-pre-sort

2023-08-09T08:05:52Z

141345 marked the issue as duplicate of #316

#2 - c4-pre-sort

2023-08-09T14:17:21Z

141345 marked the issue as not a duplicate

#3 - c4-pre-sort

2023-08-09T14:17:40Z

141345 marked the issue as duplicate of #162

#4 - c4-judge

2023-08-20T16:06:05Z

gzeon-c4 changed the severity to QA (Quality Assurance)

#5 - c4-judge

2023-08-20T17:24:00Z

gzeon-c4 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