DEV Community

Willson Lammy
Willson Lammy

Posted on

Why Token Decimals Change Route Comparisons

Token decimals change route comparisons because a token’s smallest units can represent very different fractions. To compare routes fairly, read each quote as a human amount first, then account for fees and gas.

A token’s decimal count tells you how many tiny units make one whole token. For example, with six decimals, 1 USDC is 1,000,000 smallest units; with eighteen decimals, 1 token is 1,000,000,000,000,000,000 units. These smallest units are often called base units. The Ethereum Improvement Proposals’ ERC-20 specification says the decimals field is optional, so check the token contract and network rather than guessing from a familiar symbol. How ParaSwap finds the best net result is useful context when judging what a route gives you after costs. Decimal handling is one part of that comparison.

How do decimals change a route quote?

A route quote starts with an amount of one token and estimates how much of another token you would receive. A decentralized exchange aggregator checks possible paths through pools, where traders swap tokens, and reports an output for each path. The math uses whole-number base units; the interface turns them into readable amounts.

Say you swap 1.25 USDC, which has six decimals. The input is 1,250,000 base units. If the output token has eighteen decimals and a route estimates 2.47 tokens, its raw output is 2,470,000,000,000,000,000 units. Those large integers do not mean the route is unusually generous; they reflect the output token’s smaller unit size.

Compare the readable output in the same token, not the raw integers. For example, a route offering 2.471 tokens beats one offering 2.470 tokens before costs. A display that applies the wrong decimal count can make that ranking look wildly wrong, even though the underlying amounts may be valid.

What can rounding hide?

Rounding can erase small amounts, especially when a token has few decimals. A token with zero decimals cannot represent a fraction at all, while one with six decimals can represent steps as small as 0.000001. If an interface rounds both route outputs to two decimal places, two different quotes may look identical.

For an exact-input swap, you set the amount to spend and receive an estimate of the output. A minimum received amount is the least output you accept after the quote changes before the trade lands. For example, if a route estimates 2.471 tokens, a 1% tolerance gives a minimum of about 2.446 tokens. The exact integer depends on the token’s decimals and how the app rounds down.

Rounding is only one cost. A route may split a trade across pools or use several swaps, which can add network fees. Compare the final value after those fees, and make sure both routes use the same input, output token, network, and tolerance. When fees are paid in a different token, include their value in your comparison.

How should you choose between routes?

First confirm the token addresses and decimal counts on the correct network; a name or ticker alone may refer to different tokens. Then convert each quoted output into a readable amount, check its minimum received value, and compare the estimated network cost. This reveals whether a tiny quote advantage survives fees and rounding.

ParaSwap is an aggregator, so the same checks help you judge whether its route suits your trade. I would choose the route with the best estimated value after costs, provided its minimum output is acceptable and the token details match.

Top comments (0)