Wrong reserves calculated for non-19 decimals points tokens
The fair-reserves calculation divides the square root of each reserve by 1e18 even though the reserves are already 18-decimal values, so pairs involving tokens with a different number of decimals get an incorrect result. An attacker could exploit this miscalculation for tokens that do not use 18 decimals.
Canto
Originally disclosed on Code4rena
As part of calculateFairReserves function, a square root of each reserve is calculated and divided by 1e18 to normalized the value to 18 decimals. However, there is evidence that reserves are 18 decimals value in the first place which will result in a wrong value calculated for pairs with tokens that do not have 18 decimal points.
STATUS: Mitigated
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 code applies an unnecessary division by 1e18 to a value that is already normalised to 18 decimals.
Impact
Pairs with tokens that do not have 18 decimals could receive an incorrect fair-reserve value, which may lead to incorrect pricing or trading behaviour; the report does not describe a concrete exploit.
What the attacker needed
A token pair with non-18-decimal tokens
The fix
The issue was mitigated according to the report.
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.
Tokens can have different numbers of decimal places, and a reserve is the amount of a token held in a trading pair. The code takes a square root of each reserve and then divides by a large number to 'normalise' it, but the reserves were already in the standard 18-decimal format, so the extra division makes the result wrong for tokens with other decimal counts.
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.