All of tokens have decimals property, e.g. WBNB token has 18 decimals.

If there was a pair using different decimals, then we would first need to divide both sides before we calculate rates.

(token0 / pow(10, decimals0)) / (token1 / pow(10, decimals1))

What's the reason we need decimals as opposed to just having all tokens use the same base?

Is this is a limitation / optimization of ?

1 Answer 1


What's the reason all tokens have decimals?

They don't have to use decimals.

According to the ERC-20 standard description for decimals:

"OPTIONAL - This method can be used to improve usability, but interfaces and other contracts MUST NOT expect these values to be present."

For ERC-721:

"...we find it contrived to require all ERC-721 implementations to support the decimals function."

18 decimals equates to the equivalent translation from ETH -> wei, which is why it's so popular.

Other values do exist in the wild, such as 6 decimal places for USDT and USDC. (See: Why fiat-backed stablecoins have a decimal of more than 2?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.