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

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

Which way does integer rounding go in a swap, and can a round trip ever make money?

Quotes and payouts round down; protective floors and the fee round up. The direction is fixed by one rule, and a metamorphic test checks that going in and straight back never returns more than went in.

Known formally as INV-13: rounding runs against over-promise in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · article updated 2026-11-16 · site dataset through 2026-11-19 · 7 min · written from the deployed bytecode

By Mitra (@Sigmacrit) — anonymous developer of the BlazePhoenix protocol. The code is the résumé.

Abstract in 15 languages · resumo · resumen · 摘要 · 要旨 · ملخص

English — 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.

Português — O arredondamento corre sempre contra a promessa em excesso: cotações e pagamentos arredondam para baixo, enquanto os pisos de proteção e a comissão do protocolo arredondam para cima, de modo que cada passo deixa a cotação um fio abaixo do valor exato. Um teste metamórfico verifica que entrar e voltar logo a seguir nunca devolve mais do que entrou.

Español — El redondeo siempre va contra la promesa excesiva: las cotizaciones y los pagos redondean hacia abajo, mientras que los pisos de protección y la comisión del protocolo redondean hacia arriba, de modo que cada paso deja la cotización un pelo por debajo del valor exacto. Una prueba metamórfica comprueba que entrar y volver enseguida nunca devuelve más de lo que entró.

Français — L'arrondi va toujours contre la promesse excessive : les cotations et les paiements arrondissent vers le bas, tandis que les planchers de protection et les frais du protocole arrondissent vers le haut, si bien que chaque étape laisse une cotation un cheveu sous la valeur exacte. Un test métamorphique vérifie qu'entrer puis revenir aussitôt ne rend jamais plus que ce qui est entré.

Deutsch — Die Rundung läuft immer gegen ein Zuviel-Versprechen: Kurse und Auszahlungen werden abgerundet, Schutzuntergrenzen und die Protokollgebühr aufgerundet, sodass jeder Schritt einen Kurs einen Hauch unter dem exakten Wert lässt. Ein metamorpher Test prüft, dass Hin- und unmittelbarer Rücktausch nie mehr zurückgibt, als hineinging.

Русский — Округление всегда работает против завышенных обещаний: котировки и выплаты округляются вниз, а защитные нижние границы и комиссия протокола вверх, поэтому каждый шаг оставляет котировку чуть ниже точного значения. Метаморфический тест проверяет, что обмен туда и сразу обратно никогда не возвращает больше, чем было внесено.

Türkçe — Yuvarlama her zaman aşırı vaade karşı işler: kotasyonlar ve ödemeler aşağı, koruyucu tabanlar ile protokol ücreti yukarı yuvarlanır; böylece her adım kotasyonu tam değerin bir kıl altında bırakır. Metamorfik bir test, içeri girip hemen geri dönmenin girenden fazlasını asla geri vermediğini kontrol eder.

العربية — يسير التقريب دائمًا ضد الوعد الزائد: تُقرَّب عروض الأسعار والمدفوعات إلى الأسفل، بينما تُقرَّب الحدود الدنيا الواقية ورسوم البروتوكول إلى الأعلى، فيترك كل خطوة عرض السعر أدنى بقليل من القيمة الدقيقة. ويتحقق اختبار ميتامورفي من أن الدخول ثم العودة مباشرة لا يعيد أبدًا أكثر مما دخل.

हिन्दी — राउंडिंग हमेशा अत्यधिक वादे के विरुद्ध चलती है: कोट और भुगतान नीचे की ओर राउंड होते हैं, जबकि सुरक्षात्मक फ़्लोर और प्रोटोकॉल फ़ीस ऊपर की ओर, इसलिए हर चरण कोट को सटीक मान से ज़रा नीचे छोड़ता है। एक मेटामॉर्फ़िक टेस्ट जाँचता है कि अंदर जाकर तुरंत वापस आने पर कभी उससे अधिक नहीं लौटता जितना गया था।

日本語 — 丸めは常に過大な約束に逆らう向きで働きます。見積もりと支払いは切り捨て、保護用のフロアとプロトコル手数料は切り上げるため、各ステップは見積もりを正確な値のわずか下に置きます。メタモルフィックテストが、入って直ちに戻っても入れた量より多くは戻らないことを確認します。

中文 — 舍入始终与过度承诺相反:报价和支付向下取整,保护性下限和协议费用向上取整,因此每一步都让报价略低于精确值。一个蜕变测试会检查,换入后立即换回,返回的数量永远不会多于投入的数量。

한국어 — 반올림은 항상 과장된 약속에 반하는 방향으로 작동합니다. 견적과 지급액은 내림하고, 보호용 하한과 프로토콜 수수료는 올림하므로 각 단계는 견적을 정확한 값보다 아주 조금 낮게 둡니다. 메타모픽 테스트는 들어갔다가 곧바로 되돌아와도 넣은 것보다 더 많이 돌아오지 않음을 확인합니다.

Bahasa Indonesia — Pembulatan selalu berjalan melawan janji berlebihan: kuotasi dan pembayaran dibulatkan ke bawah, sedangkan batas bawah pelindung dan biaya protokol dibulatkan ke atas, sehingga setiap langkah menjaga kuotasi sedikit di bawah nilai persisnya. Uji metamorfik memeriksa bahwa masuk lalu langsung kembali tidak pernah mengembalikan lebih dari yang masuk.

বাংলা — রাউন্ডিং সবসময় অতিরিক্ত প্রতিশ্রুতির বিরুদ্ধে চলে: কোট ও পেআউট নিচের দিকে রাউন্ড হয়, আর সুরক্ষামূলক ফ্লোর ও প্রোটোকল ফি ওপরের দিকে, ফলে প্রতিটি ধাপ কোটকে সঠিক মানের সামান্য নিচে রাখে। একটি মেটামরফিক টেস্ট যাচাই করে যে ভেতরে গিয়ে সঙ্গে সঙ্গে ফিরে এলে যা গিয়েছিল তার বেশি কখনও ফেরত আসে না।

Filipino — Ang rounding ay laging tumatakbo laban sa labis na pangako: ang mga quote at payout ay nag-round down, habang ang mga protective floor at ang protocol fee ay nag-round up, kaya ang bawat hakbang ay nag-iiwan ng quote na bahagyang mas mababa sa eksaktong halaga. Sinusuri ng isang metamorphic test na ang pagpasok at agarang pagbalik ay hindi kailanman nagbabalik ng higit sa ipinasok.

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.

QuantityRoundsWhy that direction
A quote or a payoutDownIt may understate a delivery and never overstate one
A leg's input in the capacity walkUpThe walk uses the pool's own arithmetic, input up and output down; its one stated exception is bounded in section 4.2
A protective floorUpA floor that rounds down would admit a smaller delivery than stated
The protocol fee (28 bps)UpIt is never zero, and nothing grows with the gap between quote and delivery

Source: Whitepaper 2.4, INV-13, section 4.2 (the walk), sections 13 and 18 (the fee).

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`.

  1. Take a pool and an input amount a.
  2. Swap a in, then swap everything received straight back on the updated reserves.
  3. Assert that the amount back is at most a. A rounding step that favoured the trader would turn this red.

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.

Do not trust this page — reproduce it

Every claim above is checkable against the chain. Start here:

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.
Cite this article

Licensed CC BY-NC-ND 4.0: quote and cite it with attribution and a link. Commercial use and derivative versions need written permission from BlazePhoenix; translations are made by BlazePhoenix. Copy a ready-made citation:

BlazePhoenix (2026). Rounding and the round trip: every rounding step is chosen to understate, never to promise. BlazePhoenix Engineering. https://blazephoenix.xyz/learn/rounding-and-the-round-trip/
@misc{blazephoenix_rounding_and_the_round_trip,
  title  = {Rounding and the round trip: every rounding step is chosen to understate, never to promise},
  author = {BlazePhoenix},
  year   = {2026},
  url    = {https://blazephoenix.xyz/learn/rounding-and-the-round-trip/},
  note   = {Accessed: reproduce the claim with the command above}
}

Writing an answer, a wiki entry or a paper? The claim above is reproducible against the chain before you quote it — which is the only sound basis for citing a technical source at all.

Contracts are verified on every chain we deploy to — addresses in the protocol manifest. Deeper formal treatment: the whitepaper (PDF).

Related engineering

Next in Execution semantics · 4 / 7
How a quote ages: 240 samples of a promise executed 0–10 seconds later ›A quote taken through previewAndEncode, the world moving against it, the calldata executed unchanged up to ten seconds later. The drift table, the delay table, the live Base rows, and the reading they share: time is not what moves a quote; drift is.6 min

Questions, a partnership or a bug to report? Contact us or email contact@blazephoenix.xyz

Go to APP