Skip to the article
Tokenbearing

Crypto protocols, markets and policy

Why Tiny AMM Swaps Differ From Their Ideal Quote

An AMM’s ideal quote follows a continuous curve, but contracts return integer token units; on tiny swaps, flooring can erase output or alter the quoted rate.

Tokenbearing Editorial3 min read#10baa2

Cover artwork

A tiny swap can receive less output than an ideal AMM quote because the quote is continuous while the contract settles whole token units. The difference comes from integer arithmetic: a contract cannot transfer a fraction of the smallest unit recorded for a token. When the calculated output lies between units, the contract rounds it down, and the gap matters most when the expected output is small.

How does an AMM calculate an ideal quote?

An ideal quote estimates output from the pool’s pricing curve before that output is rounded to token units. In a constant-product pool, the reserves satisfy a product relationship: as a trader adds one asset and removes another, the reserves move along the curve. For input reserve x, output reserve y, and fee-adjusted input x′, a common formula for the output is y × x′ / (x + x′).

This calculation describes a theoretical amount. The actual contract also applies its fee rules and integer arithmetic, and other AMM designs can use different formulas. The quote may then be shown in human-readable token amounts after accounting for each token’s decimals. Those display conversions do not give the contract permission to transfer a fraction of a smallest unit.

Reserve depth still determines how far the trade moves along the curve, so a small trade relative to the reserves generally has less price impact than a larger one. Pool choice is a separate part of the decision; a fuller explanation of that comparison is available in this guide to a base swap. Here, the focus is what happens to the calculated output after a pool has been chosen.

What does integer rounding change in a tiny swap?

Rounding turns a continuous estimate into a discrete amount the token contract can transfer. If the ideal output is 2.8 smallest units, a contract that floors the result sends 2. It does not send 2.8, and under that rounding rule it does not round up to 3. If the result is below one smallest unit, flooring can produce zero output.

The size of one smallest unit depends on the token’s decimals, so the same displayed fraction of a token can correspond to different integer amounts for different tokens. A quote interface may show many decimal places, but extra display precision cannot make an untransferable fraction executable. For a tiny trade, compare the expected output in the output token’s smallest units, not just the human-readable rate.

Several effects are easy to confuse:

  • Price impact is the change in the pool’s curve price caused by the trade.
  • Fee is the amount removed or retained under the pool’s fee rules.
  • Rounding is the loss of fractional smallest units when an amount is converted to an integer.

How should a trader read a tiny-swap quote?

Check whether the quoted output is an estimate or the integer amount the transaction can actually receive. The execution amount is the one that matters: contracts compare and transfer integer units. If a transaction sets a minimum output, that threshold is also expressed in units the contract can represent; a threshold above the executable amount causes the swap to fail rather than deliver a fraction.

For practical comparison, look at the final integer output after fees and rounding, then compare it with the amount spent. A displayed rate can look favorable while rounding removes a meaningful share of a tiny expected output. Increasing the trade may reduce rounding’s share of the output, but it also changes the curve movement and fee paid. The better choice depends on those costs together, not on the ideal quote alone.

The useful rule is simple: treat the curve quote as a model of pricing, and the contract’s integer output as the executable result. For larger outputs, the fractional remainder is often a small part of the total. For tiny swaps, it can determine whether any output is transferred at all.