Launch app
Cover: Metrological Design: the theory behind a contract that measures instead of believing

Metrological Design: the theory behind a contract that measures instead of believing

Metrological Design is the BlazePhoenix engineering method: build the contract as an instrument. Code that believes is attack surface; code that measures is defence. The three rules — one morphism, measured coordinates, monotone inputs — and the real mechanisms that instantiate them.

Known formally as Metrological Design in the BlazePhoenix whitepaper.

BlazePhoenix Engineering · article updated 2026-08-26 · site dataset through 2026-11-30 · 10 min · written from the deployed bytecode

At a glance
LevelAdvanced
Formal nameMetrological Design
Reading time10 min
Sections6
Sources cited2
Updated2026-08-26

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

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

English — Metrological Design is the BlazePhoenix engineering method: build the contract as an instrument, because code that believes is attack surface and code that measures is defence. Three rules — one morphism, measured coordinates, monotone inputs — govern every load-bearing mechanism in the protocol.

Português — Metrological Design é o método de engenharia da BlazePhoenix: construir o contrato como um instrumento, porque código que acredita é superfície de ataque e código que mede é defesa. Três regras — um morfismo, coordenadas medidas, entradas monótonas — regem cada mecanismo estrutural do protocolo.

Español — Metrological Design es el método de ingeniería de BlazePhoenix: construir el contrato como un instrumento, porque el código que cree es superficie de ataque y el código que mide es defensa. Tres reglas — un morfismo, coordenadas medidas, entradas monótonas — rigen cada mecanismo estructural del protocolo.

Français — Metrological Design est la méthode d'ingénierie de BlazePhoenix : construire le contrat comme un instrument, car le code qui croit est une surface d'attaque et le code qui mesure est une défense. Trois règles — un morphisme, des coordonnées mesurées, des entrées monotones — gouvernent chaque mécanisme porteur du protocole.

Deutsch — Metrological Design ist die Engineering-Methode von BlazePhoenix: den Vertrag als Instrument bauen, denn Code, der glaubt, ist Angriffsfläche, und Code, der misst, ist Verteidigung. Drei Regeln — ein Morphismus, gemessene Koordinaten, monotone Eingaben — tragen jeden lastführenden Mechanismus des Protokolls.

Русский — Metrological Design — инженерный метод BlazePhoenix: строить контракт как инструмент, потому что код, который верит, — это поверхность атаки, а код, который измеряет, — защита. Три правила — один морфизм, измеренные координаты, монотонные входы — держат каждый несущий механизм протокола.

Türkçe — Metrological Design, BlazePhoenix'in mühendislik yöntemidir: kontratı bir ölçüm aleti gibi inşa et, çünkü inanan kod saldırı yüzeyi, ölçen kod savunmadır. Üç kural — tek morfizm, ölçülmüş koordinatlar, monoton girdiler — protokolün her taşıyıcı mekanizmasını yönetir.

العربية — التصميم المترولوجي Metrological Design هو منهج الهندسة في BlazePhoenix: ابنِ العقد كأداة قياس، لأن الكود الذي يصدّق سطحُ هجوم والكود الذي يقيس دفاع. ثلاث قواعد — تشاكل واحد، إحداثيات مقيسة، مدخلات رتيبة — تحكم كل آلية حاملة في البروتوكول.

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

日本語 — Metrological DesignはBlazePhoenixのエンジニアリング手法です。コントラクトを計測器として作る——信じるコードは攻撃面、測るコードは防御だからです。三つの規則(単一の射、測られた座標、単調な入力)がプロトコルの要となる全機構を律します。

中文 — Metrological Design 是 BlazePhoenix 的工程方法:把合约造成一台测量仪器——相信的代码是攻击面,测量的代码才是防御。三条规则——单一态射、被测坐标、单调输入——支配协议中每个承重机制。

한국어 — Metrological Design은 BlazePhoenix의 엔지니어링 방법입니다. 컨트랙트를 측정 기기로 만드는 것 — 믿는 코드는 공격 표면이고 측정하는 코드가 방어이기 때문입니다. 세 가지 규칙 — 하나의 사상, 측정된 좌표, 단조 입력 — 이 프로토콜의 모든 핵심 메커니즘을 지배합니다.

Bahasa Indonesia — Metrological Design adalah metode rekayasa BlazePhoenix: bangun kontrak sebagai instrumen, karena kode yang percaya adalah permukaan serangan dan kode yang mengukur adalah pertahanan. Tiga aturan — satu morfisme, koordinat terukur, masukan monoton — mengatur setiap mekanisme penopang protokol.

বাংলা — Metrological Design হলো BlazePhoenix-এর প্রকৌশল পদ্ধতি: কন্ট্রাক্টকে একটি যন্ত্রের মতো গড়ো, কারণ যে কোড বিশ্বাস করে তা আক্রমণ-পৃষ্ঠ আর যে কোড মাপে তা প্রতিরক্ষা। তিনটি নিয়ম — একটি মরফিজম, মাপা স্থানাঙ্ক, মনোটোন ইনপুট — প্রোটোকলের প্রতিটি ভারবাহী মেকানিজম শাসন করে।

Filipino — Ang Metrological Design ang pamamaraan ng inhinyeriya ng BlazePhoenix: itayo ang kontrata bilang instrumento, dahil ang code na naniniwala ay attack surface at ang code na sumusukat ay depensa. Tatlong panuntunan — isang morphism, sinukat na coordinates, monotone na input — ang namamahala sa bawat mahalagang mekanismo ng protocol.

Every security review of a smart contract eventually asks the same question in a hundred costumes: where does this code act on a value it did not check? BlazePhoenix organises its entire design around asking that question exactly once, structurally, everywhere — and the method has proven distinctive enough that the v2.1 whitepaper gives it a name: Metrological Design, the discipline of building a contract as an instrument. The thesis fits in one line: code that believes is attack surface; code that measures is defence.

Metrology is the science of measurement — calibration, error bounds, instrument drift. Applying it to contract engineering means something concrete: wherever a quantity can be read from chain state, the contract reads it and never accepts a substitute; wherever it cannot, the design makes dishonesty self-defeating. Three rules carry the whole method, and every load-bearing mechanism in the protocol is an application of at least one of them.

Rule one: one morphism, evaluated at a point

The aggregator does not contain an integration per exchange. It is the evaluation of one parametrised pricing morphism at a point of the space (venue shape, chain, fee model). If venues were branches, the live venue kinds across the chains served — each with its own fee convention — would multiply into hundreds of combinations, and multiplicative combinations mean multiplicative bytecode, multiplicative audit surface, multiplicative drift. Expressed as a morphism, the same coverage is a handful of state shapes, one stateless Core, fee conventions carried in their native units, and registration tables. Bytecode grows additively: a new venue is a row, not a branch.

The rule that guards the collapse is KIND maps to SHAPE: a new venue family is data — a kind assigned to an existing pricing shape and an address-derivation mode — never a new code path that adversarial input gets to select. And the collapse has an honesty brake: there is no single universal formula. Two closed forms are evaluated exactly (constant product, concentrated liquidity), and where replicating a curve would itself be a risk, the venue is asked through the narrowest honest channel it exposes. The morphism collapses membership, never verification.

Rule two: coordinates are measured, never believed

The axiom under the whole attack model: the contract never acts on a modelled, nominal or caller-supplied value where an on-chain measurement exists — and no permissionless datum ever chooses which code runs. Data supplied by an untrusted party (a route, a declared fee, a claimed depth, a pool id) are coordinates: places to point the instrument, which the contract then reads for itself, fail-closed. That yields a definition of attack surface the code can actually defend: the number of code paths an adversarial input can select.

Every load-bearing defence in the engine is an instance. The Router measures its own balance delta after the pull instead of trusting the nominal amount. The fee base is re-derived in-frame from the legs as they actually executed, never read from calldata. The believability band is anchored to the candidate holding the largest measured balance of the output token — truth votes with capital, not existence. The capacity clamp cuts a concentrated leg against the pool's measured holdings, not its promised liquidity. The V4 fee gate reads the live fee from the singleton's own storage and refuses to quote when the measurement cannot be exact. Discovery proves a pool exists by reading storage nobody else can write, rather than trusting any list.

One axiom applied everywhere is also a review instrument. To audit this protocol, hunt for a site that acts on a nominal value where a measurement was available. That is the whole hunt — and it is a question a reviewer can ask mechanically, file by file, which is precisely what a named discipline is for.

Rule three: where measurement ends, monotonicity begins

Some numbers can be neither measured nor re-derived: a caller's attested floor, a declared scale, the trader's own minimum. For these the design accepts the number and shapes the function so that lying can only hurt the liar. The attested floor can only raise the enforced floor, never lower it. The fee base is a minimum, so understating a quote cannot cheapen the fee — the coverage guard charges on delivery instead. Declared scaling is capped by measured arrival, so overstating cannot route funds that never existed. And the one bound only the trader can choose — the minimum — is mandatory at every entry point.

The economic consequence is quiet and load-bearing: a monotone input needs no trust, so it can be computed off-chain, by anyone, for free, and carried in calldata. That is how the protocol moves work off-chain without moving trust off-chain — and why the Router can offer both a solving surface and a calldata surface under the same guarantees.

effMin=max(userMinOut,routeFloor,finalHopQuote·floorBps/104)
The three-way maximum the Router enforces. Caller-supplied fields appear only inside a max, so they can tighten protection and can never loosen it — monotonicity as a security primitive.

The discipline governs the engineering, not just the artefact

An instrument is only as good as its calibration, so the same standard applies to the process around the code. Safety margins are priced from measured hazards, never from mood: an earlier planning shave insured multi-leg routes at 5 bps per leg until the drift it insured against was measured at 2 bps — the margin was retired, because a margin that outweighs its measured hazard 27 times over is not safety, it is a tax on every honest trade. External comparisons carry their error bars or they are not published: the execution benchmark pinned quotes to the exact block they were built for after an early round mis-attributed ordinary market movement to routing, and discarded a competitor API's own gas estimates outright after real execution measured one of them 148% low.

And the measuring apparatus is itself measured. The factory census deploys through the production deployment path behind an equality gate that fails the suite if harness and deployment ever drift — because a green suite that exercises different wiring than the chain runs is not evidence, it is decoration. Instruments that test the instruments: that is the part of the method most engineering cultures skip, and the part that has caught the most.

Why it deserves a name

Pieces of this exist elsewhere under other names. Defensive programming says validate inputs; design-by-contract says state pre- and post-conditions; formal verification proves properties about the code as written. None of them makes measurement the organising principle — the systematic preference, at every seam, for a number read from live state over a number believed from any other source, with monotone shaping as the fallback where reading is impossible, and with the engineering process held to the same standard as the artefact.

Named, the discipline becomes checkable. A reviewer does not need to absorb a hundred design decisions; they need one question and a grep. Every tolerance in this article sits in public source at a named constant, every mechanism behind it ships in the deployed bytecode, and the standing instruments — the fidelity matrix, the census, the benchmark — keep re-measuring the claims after publication. That is the difference between a philosophy and a method: a method leaves instruments running.

Do not trust this page — reproduce it

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

git clone https://github.com/blazephoenixxyz-crypto/Blaze-Phoenix-Dex && cd Blaze-Phoenix-Dex && grep -n 'MEDIAN_FILTER_BPS\|MIN_SPLIT_IMPROVEMENT_PPM\|LEG_FLOOR_BPS\|MAX_CONC_DRAIN_BPS' src/*.sol  # every tolerance in this article, at its defining site
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). Metrological Design: the theory behind a contract that measures instead of believing. BlazePhoenix Engineering. https://blazephoenix.xyz/learn/metrological-design/
@misc{blazephoenix_metrological_design,
  title  = {Metrological Design: the theory behind a contract that measures instead of believing},
  author = {BlazePhoenix},
  year   = {2026},
  url    = {https://blazephoenix.xyz/learn/metrological-design/},
  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). Sources cited: BIPM — International Vocabulary of Metrology (VIM): calibration, measurement uncertainty, instrumental drift. · B. Meyer — Design by Contract (Object-Oriented Software Construction), the nearest prior discipline.

Related engineering

Next in Evidence standards · 7 / 8
The Shared-Quantity Register: how we hunt the bug class that type systems cannot catch ›In every security review of this codebase the dominant defect was two places answering the same question with different answers, and nothing forcing them to agree. A type system cannot catch that; enumeration can — the register, the four row states, and why WEAK is more dangerous than OPEN.9 min

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

Go to APP