ERC-20 tokens do not specify the maximum number of decimals. Theoretically, these tokens support as many decimals as fit in 256 bits. Using a token with a much larger number of decimals when creating a pool could rapidly read to a non-operating pool, as many critical functions - mint, swap, burn - are calling the _update function which would revert due to overflow.
Impact
Low, as the probability of using such a token are low.
Funny Merlot Yeti
Low/Info
_update function from Pair.sol can overflow for some ERC20 tokens
Summary
For ERC-20 tokens with more than 18 decimals, the
_update
andcurrentCumulativePrices
can revert due to overflow.Vulnerability Detail
ERC-20 tokens do not specify the maximum number of decimals. Theoretically, these tokens support as many decimals as fit in 256 bits. Using a token with a much larger number of decimals when creating a pool could rapidly read to a non-operating pool, as many critical functions -
mint
,swap
,burn
- are calling the_update
function which would revert due to overflow.Impact
Low, as the probability of using such a token are low.
Code snippet
To simplify the review process
Tool used
Manual Review
Recommendation
Impose max digits for the ERC-20 token