Canto Dex Oracle contest - pashov's results

Execution layer for original work.

General Information

Platform: Code4rena

Start Date: 07/09/2022

Pot Size: $20,000 CANTO

Total HM: 7

Participants: 65

Period: 1 day

Judge: 0xean

Total Solo HM: 3

Id: 159

League: ETH

Canto

Findings Distribution

Researcher Performance

Rank: 45/65

Findings: 1

Award: $39.22

๐ŸŒŸ Selected for report: 0

๐Ÿš€ Solo Findings: 0

Misleading variable name

The local variable decimals in both getPriceCanto() and getPriceNote() is not really decimals - it is 10 to the power of the token decimals. It is passed to the IBaseV1Pair::quote() function as the granularity argument. Rename variable from decimals to `granularity

And again, decimals in getPriceLP() is not really decimals, but it is 10 to the power of a tokenโ€™s decimals. It is passed to the IBaseV1Pair::sample() function as the amountIn argument. Rename variable from decimals to amount or amountIn.

Inconsistent variable naming

In BaseV1-core.sol for the reserves() function we have a granularity parameter. The problem is the same parameter is passed as the argument named points for sampleReserves. It is the same situation with totalSupplyAvg()'s granularity and sampleSupply's points parameter. Choose only granularity or only points and stick to this naming to simplify the code for both developers and auditors.

Division before multiplication

In getPriceLP() we have

uint token0TVL = assetReserves[i] * (prices[i] / decimals);

Where the division comes before the multiplication because of the braces. This is a bad practice in Solidity, because there is a loss of precision this way, and also if prices[i] is smaller than decimals then the division will return 0 and the value of token0TVL will be zero, whatever the assetReserves[i] are. So instead, first do the multiplication and then the division.

#0 - pashov

2022-09-11T16:00:31Z

Division before multiplication is mentioned, which should be duplicate of #41

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