Anatomy of a DEX aggregator: the six stages between your input and your output

Aggregation is six distinct problems wearing one button: discovery, filtering, pricing, allocation, execution and settlement guarantees. Knowing which stage runs where — and which run off-chain — explains almost every difference between one aggregator and another.

Known formally as Aggregator Anatomy in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · updated 2026-07-29 · 12 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 · 摘要 · 要旨 · ملخص

EnglishAggregation is six problems wearing one button: discovery, filtering, pricing, allocation, execution and settlement guarantees. Almost every observable difference between two aggregators traces to one of those six answers — and each is checkable by observation, not trust.

PortuguêsAgregação são seis problemas com um só botão: descoberta, filtragem, formação de preço, alocação, execução e garantias de liquidação. Quase toda a diferença observável entre dois agregadores está numa dessas seis respostas — e cada uma verifica-se por observação, não por confiança.

EspañolAgregar son seis problemas con un solo botón: descubrimiento, filtrado, fijación de precio, asignación, ejecución y garantías de liquidación. Casi toda diferencia observable entre dos agregadores está en una de esas seis respuestas, y cada una se comprueba observando, no confiando.

FrançaisAgréger, c'est six problèmes sous un seul bouton : découverte, filtrage, tarification, allocation, exécution et garanties de règlement. Presque toute différence observable entre deux agrégateurs tient à l'une de ces six réponses — chacune vérifiable par observation, non par confiance.

DeutschAggregation sind sechs Probleme unter einem Knopf: Entdeckung, Filterung, Preisbildung, Allokation, Ausführung und Settlement-Garantien. Fast jeder beobachtbare Unterschied zwischen zwei Aggregatoren geht auf eine dieser sechs Antworten zurück — jede prüfbar durch Beobachtung, nicht durch Vertrauen.

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

TürkçeToplulaştırma tek düğme altındaki altı problemdir: keşif, filtreleme, fiyatlama, tahsis, yürütme ve takas garantileri. İki toplayıcı arasındaki gözlemlenebilir farkların neredeyse tümü bu altı yanıttan birine dayanır ve her biri güvenle değil gözlemle doğrulanır.

العربيةالتجميع ست مسائل تحت زر واحد: الاكتشاف، والتصفية، والتسعير، والتوزيع، والتنفيذ، وضمانات التسوية. يكاد كل فرق ملحوظ بين مجمّعَين يعود إلى واحدة من تلك الإجابات الست — وكل منها يُتحقق منه بالملاحظة لا بالثقة.

हिन्दीएग्रीगेशन एक बटन के नीचे छह समस्याएँ हैं: खोज, छँटाई, मूल्य-निर्धारण, आवंटन, निष्पादन और निपटान की गारंटी। दो एग्रीगेटरों के बीच लगभग हर दृश्य अंतर इन्हीं छह उत्तरों में से एक से आता है — और हर एक भरोसे से नहीं, अवलोकन से जाँचा जा सकता है।

日本語アグリゲーションは一つのボタンの下にある六つの問題です。発見、選別、価格形成、配分、執行、決済保証。二つのアグリゲーターの観測可能な差は、ほぼすべてこの六つの答えのどれかに帰着し、いずれも信頼ではなく観測で確認できます。

中文聚合是一个按钮下的六个问题:发现、筛选、定价、分配、执行与结算保证。两个聚合器之间几乎所有可观察的差异,都能追溯到这六个答案之一——而每一个都可以用观察而非信任来验证。

한국어애그리게이션은 버튼 하나 아래의 여섯 문제입니다: 발견, 선별, 가격 산정, 배분, 실행, 정산 보증. 두 애그리게이터 사이의 관측 가능한 차이는 거의 전부 이 여섯 답 중 하나로 환원되며, 각각은 신뢰가 아니라 관측으로 확인됩니다.

Bahasa IndonesiaAgregasi adalah enam masalah di balik satu tombol: penemuan, penyaringan, penetapan harga, alokasi, eksekusi dan jaminan penyelesaian. Hampir semua perbedaan yang teramati antara dua agregator berpangkal pada salah satu dari enam jawaban itu — dan tiap satunya dapat diperiksa lewat pengamatan.

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

FilipinoAng aggregation ay anim na problema sa ilalim ng isang pindutan: pagtuklas, pagsala, pagpepresyo, paglalaan, pagpapatupad at garantiya ng settlement. Halos lahat ng nakikitang pagkakaiba ng dalawang aggregator ay nagmumula sa isa sa anim na sagot na iyon — at bawat isa ay masusuri sa pagmamasid, hindi tiwala.

From the outside, a swap aggregator is a box with an input and an output. Inside, it is six separate engineering problems, each with its own failure mode, and each of which a given implementation may solve on-chain, off-chain, or not at all. Almost every observable difference between two aggregators — price, reliability, trust assumptions — traces back to a decision at one of these six stages.

Stage 1 — Discovery: which venues even exist

Before anything can be priced, the set of candidate pools must be found. Two approaches exist. A registry-driven aggregator maintains a list, which is fast but stale by construction: a pool deployed an hour ago is invisible until someone adds it. A derivation-driven one computes where a pool WOULD live given the factory and the token pair, then checks whether code exists at that address — permissionless, no list to maintain, and a new venue is visible the moment it is deployed.

The trade-off is cost: derivation costs reads, and reads cost gas or latency. A serious implementation does both and unions the results, because a registry alone goes stale and derivation alone rediscovers what it already knows.

Stage 2 — Filtering: which candidates deserve a share

Not every discovered pool should receive part of your trade. Two independent tests apply, and conflating them is a classic error. The first is PRICE QUALITY: is this venue's rate consistent with the others, or is it mispriced? The second is CAPACITY: can it absorb your size at that rate?

The subtlety is what the price test should be measured against. A plain median across candidates can be poisoned: seed the set with several near-empty pools quoting a stale rate and the median moves toward the fiction. Anchoring the comparison on the venue with the largest real token balance fixes it, because moving that anchor requires depositing genuine capital — at which point the manipulator IS the deep pool and arbitrage corrects them.

Stage 3 — Pricing: where the number comes from

This is the stage that most determines whether a displayed quote survives contact with execution. Three architectures are in use. Off-chain pricing computes the route on a private server and returns signed calldata: fast and flexible, but the number cannot be reproduced by anyone else and disappears when the server does. On-chain pricing computes the quote by calling the same contracts that will settle the trade: slower per request, reproducible by anyone with a node, and structurally unable to diverge from execution. Quoted pricing asks each venue for its own answer rather than re-implementing its curve.

Each has a genuine cost. The point is not that one is universally right — it is that the choice is invisible in the interface and decisive in the outcome, and a user is entitled to know which one produced the number on their screen.

Stage 4 — Allocation: how much goes where

Given a filtered candidate set, how should the order be divided? The answer is a constrained optimisation with a clean solution: because impact is convex in size, splitting is never worse than a single fill, and the optimum is reached when every venue receiving a share pays the same marginal rate. Shares therefore track real depth, not venue count.

Two bounds apply in practice. Each additional leg costs gas and adds one more pool whose state can move before inclusion, so the leg budget should extend only while the expected saving exceeds the marginal cost. And the depth used for weighting must be comparable across venue families — a raw liquidity figure from one family is not the same quantity as a reserve balance from another.

Stage 5 — Execution: the shapes a swap can take

Different venue families demand different interaction patterns. Some expect tokens pushed in first and then a swap call with the computed output; some call back into the caller mid-swap to collect payment; some require an approval and a named exchange function; some hold all assets in a singleton that must be unlocked, settled and drawn from in sequence.

Two properties separate a robust router from a fragile one here. First, it should measure what actually arrived rather than trusting the amount it requested, because fee-charging and rebasing tokens deliver something else. Second, it should end the transaction holding nothing: real execution leaves residuals — partial fills at a price limit, rounding across split legs — and those must be returned to the caller rather than accumulating in a contract where a later transaction can sweep them.

Stage 6 — Settlement guarantees: what is promised, and by whom

The last stage is the one users feel and rarely inspect. A displayed quote is not a promise; the enforceable promise is the minimum output the settling contract will accept. Where that minimum comes from matters enormously. If it is supplied by the caller, anyone who can widen it can widen it to nothing. If it is re-derived on-chain from the real trade at execution time, it is a property of the system rather than a parameter of the request.

This is also where a wide slippage tolerance stops being a safety margin and becomes a disclosure: a pending transaction publishes exactly how much value can be extracted before it stops settling. The tightest honest configuration is a quote that equals execution plus a floor derived at settlement — the displayed number is real, and the worst case is bounded rather than open.

Reading any aggregator through the six stages

The framework is diagnostic. For any implementation, ask: does it discover new venues or only listed ones; does it separate price quality from capacity; is the number computed by the code that settles or by a server; is allocation depth-weighted or naive; does execution measure delivery or trust the request; and is the minimum output derived on-chain or accepted from the caller.

Six questions, each answerable by observation rather than by trust. Most of what looks like a difference in "which aggregator is better" is one of these six answers, and every one of them can be checked without asking anybody's permission.

Do not trust this page — reproduce it

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

Take any aggregator and answer the six questions by observation — request a quote with its hosted surfaces unreachable to test stage 3, and compare its displayed number against what the transaction actually delivered to test stage 6
Cite this article

Licensed CC BY 4.0 — quote, translate and reuse freely, including commercially, with attribution and a link. Copy a ready-made citation:

BlazePhoenix (2026). Anatomy of a DEX aggregator: the six stages between your input and your output. BlazePhoenix Engineering. https://blazephoenix.xyz/learn/anatomy-of-an-aggregator
@misc{blazephoenix_anatomy_of_an_aggregator,
  title  = {Anatomy of a DEX aggregator: the six stages between your input and your output},
  author = {BlazePhoenix},
  year   = {2026},
  url    = {https://blazephoenix.xyz/learn/anatomy-of-an-aggregator},
  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). Standards cited: EIP-20

Share this article · join the discussion

Related engineering