# Rounding and the round trip: every rounding step is chosen to understate, never to promise

> Canonical: https://blazephoenix.xyz/learn/rounding-and-the-round-trip/
> License: CC BY-NC-ND 4.0 (attribution + link) · © 2026 BlazePhoenix
> Updated: 2026-11-16

Rounding always runs against over-promise: quotes and payouts round down, while protective floors and the protocol fee round up, so each step leaves a quote a hair below the exact value. A metamorphic test checks that swapping in and straight back never returns more than went in.

Short answer: rounding always runs against over-promise. Wherever the contract states what you will receive, it rounds down. Wherever it states a floor that protects you, or the fee it charges, it rounds up. Each rounding step is therefore chosen to leave a quote a hair below the exact value, not above it.

The whitepaper records this as invariant INV-13: quotes and payouts floor, protective floors and the fee round up, implemented with `mulDiv` and `mulDivUp` at each site.

## One rule, four directions

Integer arithmetic has to drop something. The only design question is who the dropped remainder belongs to, and the rule answers it the same way every time. The table lists each place the rounding direction is stated.

## The fee cannot be rounded away

The fee is 0.28 %, charged once on the first bridge coin the Router holds, and it is rounded up so it is never zero. That closes a quiet failure: a swap small enough that a rounded-down fee would be nothing still pays a fee of at least one unit. The rounding is on the protocol's own charge, in the direction that costs the protocol its convenience and not the user their floor.

## Where the remainder goes

Splitting an input by shares leaves a remainder, and so does a capacity clamp that frees input. The whitepaper gives each one an owner. One function, `Math._seatTheSplit`, seats the remainder on the deepest survivor by measured weight, and ties go to the lowest address, never to the order of the funnel. That one producer answers the question of who absorbs the rounding.

Tokens whose balances are denominated in shares round too, so a swap can leave a few shares in the Router. The repository states the bound: for a token that keeps balances as shares and rounds each transfer down, fewer than k plus d over n shares remain after k outbound transfers, where d over n is the number of shares per unit. That is at most one share per outbound transfer while a share is worth at least one unit. For a token that moves the exact amount it is asked to move, the bound is zero.

## The round trip, as a test

If every step rounds against the trader, a swap in and then straight back on the updated reserves must return no more than went in. The whitepaper lists this as metamorphic relation MR3: in, then back, never returns more than went in, with the assertion `back <= a`, for the V2 and stable families. The relation needs no oracle and no expected value. It only compares the result with the input.

Conservation is guarded from the other side by `invariant_conservationA` in `test/RouterAdversarialInvariantFromV1.t.sol`.

## What this does not claim

It does not say the quote is exact: it says the quote errs low. It does not claim a round trip is free of loss, only that it cannot be a gain. The remainder of a rounded share can still move a few units between legs, and that movement is bounded by the floors the Router enforces on the delivered amount.

**Verify it yourself:** forge test --match-path 'test/*MetamorphicRelations.t.sol'   # the metamorphic relations, including MR3 (back <= a), in a checkout of the V2 repository at commit 969bcc6. Then grep -n invariant_conservationA test/RouterAdversarialInvariantFromV1.t.sol. Reading: invariant INV-13 and section 15.7 of the 2.4 whitepaper.

Related: https://blazephoenix.xyz/learn/the-512-bit-multiply/ · https://blazephoenix.xyz/learn/master-conservation-identity/ · https://blazephoenix.xyz/learn/measuring-beats-recomputing/
