# BlazePhoenix-Dex Whitepaper v2.4.0 — part 5 of 9: Part IV — Security and verification > One part of the whitepaper in llms.txt form; every part and every section is listed in > https://blazephoenix.xyz/whitepaper/llms.txt. The parts are the full text, unabridged: the bodies of parts > 1-9, joined in order, are https://blazephoenix.xyz/whitepaper.md byte for byte (sha256 a47389f947e4aa6656f693004e43fbe3e0101dccaf133e49c303767811f223cc). > Cite as https://doi.org/10.5281/zenodo.24517342; numbering (§, E, INV-) as in the paper. ----- verbatim text of whitepaper.md follows ----- ## Part IV — Security and verification ## §14 Security model ### §14.1 Attacks and the checks that refuse them The catalogue below is the founding set of 23 classes, kept in the order the proof was built. The machine-readable catalogue in `docs/assurance/threats.json` has since grown to 93 classes (85 answered by a named guard, 8 out of scope with the reason recorded), and `.github/scripts/assurance/threat_coverage.py` fails the build if a guard symbol no longer exists in `src/` or a named test no longer exists in `test/`. Guards are named by symbol, never by line. | Class (id) | The check that refuses it | Where it is enforced | Status | The test that shows the check can fail | |---|---|---|---|---| | Reentrancy (DASP-1) | transient lock `nrEntrant` on every value-moving door; the callback surface authenticates its caller | Router `nrEntrant` (Router:307) → `RouterE(7)`; `fallback` → `RouterE(6)` | blocked | `invariant_reentrancyBlocked` (`test/RouterAdversarialV4FromV1.t.sol`) | | Access control (DASP-2) | four roles; every privileged door gated; the control tier renounceable for ever | Hub `onlyAdmin` / `onlyControl` → `HubE(1)` (Hub:436); Router `onlyControl` → `RouterE(1)` | blocked | `test/HubAllowHookAfterRenounce.t.sol`, `test/ControlEvents.t.sol` | | Arithmetic over/underflow (DASP-3) | checked arithmetic throughout; every `unchecked` block carries a written bound; the hard curves' representability tested at the boundary (`MAX_SQRT_PRICE_MINUS_ONE`, Core:478) | Core | blocked | `test/BoundaryEquality.t.sol`, `test/CompilerPanicSurface.t.sol` | | Denial of service by unbounded iteration (DASP-5) | every route dimension bounded: `MAX_HOPS = 2` (Core:136), `MAX_LEGS_PER_HOP = 5` (Core:149), so a route holds at most 10 legs, the product of the two and no third constant; `MAX_SLOTS = 16` (Hub:93), `MAX_FACTORIES = 16` (Hub:144); in-transaction search capped at `SOLVE_GAS` | Router `_execute` → `RouterE(3)`; Solver; Hub → `HubE(4)` (factories, Hub:818), `_canInsert` (slots, Hub:2038) | blocked | `test/RouteHopCeiling.t.sol`, `test/Pin01LegCeiling.t.sol` | | Transaction-order dependence / sandwiching (DASP-7) | the Iron-Law floor, hard-clamped at `FLOOR_HARD_MAX_LOSS_BPS = 2,000` (Core:400), enforced independently of the caller's minimum, which may only tighten it | Core `ironFloorBpsShv` (Core:3345); Router `_execute` → `RouterE(5)` | blocked (bounded, §14.3) | `test/regime/SandwichCurve.t.sol`; `invariant_DeliveredNeverBelowTheProtocolFloor` | | Cross-function reentrancy through a venue (SWC-107) | the same transient lock spans the whole swap, pool callbacks included | Router `nrEntrant` | blocked | `test/V4LockedRegionReentrancy.t.sol` | | Price-oracle manipulation (SOK-ORACLE) | there is no feed: the reference quote is produced in the executing frame from the venues traded, and the floor is derived from it (`ironFloorBps`) | Core; Router `_execute` | blocked | `test_Parity_SplitRoute_AttestedFloorEqualsEnforcedFloor` (`test/FloorParitySolverRouter.t.sol`) | | Caller-supplied quantity substituted for a measured one (SOK-FEE-BASE) | the fee base is a measured balance (`_chargeHopFee`, Router:748); `route.totalOut` is read by nothing | Router `_chargeHopFee` | blocked | `test_FeeBase_IgnoresLiedAboutTotalOut` (`test/BlazePhoenixRouter.t.sol`) | | Fee-on-transfer and rebasing tokens (SOK-FOT) | every amount that matters is a measured balance delta (`balanceOf`), never an assumed transfer amount | Router, every seam | blocked | `test/FotFloorReprice.t.sol`, `test/PartialFotAtPrePulledDoors.t.sol` | | Hostile venue admitted to the registry (SOK-VENUE-ADMISSION) | admission is curator-only, one row per address; the derivation origin is attested at admission (`factoryDeployer`, Hub:386) and frozen after renunciation | Hub `addFactory`, `_probe` (Hub:1200) | blocked | `test_C4_FirstPin_AfterRenounce_MustNotAttestTheLiveAnswer` (`test/T19ReadmissionEdge.t.sol`) | | Admitted venue whose logic moves behind a proxy (SOK-PROXY-VENUE) | re-admission after renunciation refused when the runtime moved (`factoryCodehash`, Hub:357); where a proxy can move its answer without moving its code, the answer is pinned instead | Hub `addFactory` → `HubE(1)` | blocked | `test/FactoryCodehashPin.t.sol`, `test/RenouncedFactoryRearm.t.sol` | | Venue row converted from derived to asked after ossification (SOK-MODE-FLIP) | a derive row cannot become an ask row once `controlRenounced`; tightening in the other direction stays allowed | Hub `addFactory` | blocked | `test_C4_S3_DeriveRowMustNotBecomeAnAskRowAfterRenounce` (`test/T19ReadmissionEdge.t.sol`) | | Published metric reporting the caller's declaration (SOK-VOLUME) | the registry is handed the amount the hop was able to spend, from the measured-over-declared ratio, not the declaration | Router `_recordHits` (Router:2267) | blocked | `test_INV_F4_VolumeInEqualsTheMeasuredPoolDelta` (`test/VolumeEventFidelity.t.sol`) | | Preview that does not predict execution (SOK-QUOTE-EXEC) | preview and delivery asserted equal in both fee regimes (`previewRoute`) | Quoter; Router | blocked | `test_INV_F2_PreviewPredictsDeliveryWithNoBridge` (`test/ExhaustionRegimePreviewParity.t.sol`) | | Deterministic derivation steered to an attacker's address (SOK-V4-DERIVE) | the CREATE2 preimage has one producer (`create2Address`, Core:639); a pool id derives from its own key; `hasCode` and the liveness proof discard what does not resolve | Core; Hub `_probe`, `_scanV4` (Hub:1284) | blocked | `test/ConditionAdequacyCore.t.sol`, `test/KindIsDerivedNotDeclared.t.sol` | | Malicious hook on a hooked venue (SOK-HOOK) | three layers, §14.2: immutable address bits (`hookAltersDeltas`, Core:3369 at `969bcc6`, Core:3425 at `6387350`), allow-list with codehash pin for any hook that runs in the swap (`hookPaused`, `isHookLive`), the projector in the Solver's candidate merge (Solver:1556-1590) | Router `_execV4Amt` → `RouterE(9)` (Router:2033,2049); Hub `allowHook` → `HubE(1)`, `_admitOnRegistration` → `HubE(8)` | blocked | `test/V4SievedHookIsTheExecutedHook.t.sol`, `test/SeedPoolHookMustBeAllowed.t.sol`, `test/RenouncedHookRearm.t.sol` | | Registry exhaustion by repeated admission (SOK-GRIEF-SEATS) | one row per address; a repeated add refreshes in place instead of consuming a seat (`MAX_FACTORIES`) | Hub `addFactory` → `HubE(4)` | blocked | `test/RenouncedFactoryRearm.t.sol` | | Arbitrary external call or transfer-from sink (SOK-ARBITRARY-CALL) | the executor never takes a caller-supplied call target; venue interaction is dispatched from a closed set of shapes selected by kind (`_execScaled`, Router:1722), and an unknown kind reverts | Router `_execScaled` → `RouterE(8)` (Router:1777) | blocked | `test/regime/HostileVenueMatrix.t.sol` | | Signature replay on delegated approval (SOK-SIG-REPLAY) | delegated approval is handled by the canonical Permit2 (`permitTransferFrom`); the system holds no signature scheme of its own | Router `swapExactInWithPermit2` (Router:461) | blocked | `test/RouterPermit2OneStep.t.sol` | | Governance capture (SOK-GOV) | there is no governance: no token vote, no timelock, no proxy; the control powers (pausing, the role and configuration setters, the fee treasuries, the Router's 48-hour rescue of tokens sent to it by mistake) end for ever with `renounceControl`, and venue admission, which outlives renunciation by design, only grows the registry | — | out of scope | — | | Malicious upgrade (SOK-UPGRADE) | the contracts are immutable; there is no proxy and no implementation slot | — | out of scope | — | | Compromise of an external bridge or venue (SOK-BRIDGE-EXT) | third-party venues are composed, not controlled; their failure is bounded here by the floor and the caller's minimum, and their internal security is not claimed | — | out of scope | — | | Compromise of a user's private key (SOK-KEY) | outside the trust boundary; recorded because the published incident data attribute a large share of losses to it | — | out of scope | — | Nineteen of these twenty-three classes are answered by a named guard and four are out of scope with the reason recorded; the later classes in `threats.json` (the quote surfaces, the Gate, the registry clock, the fee push) follow the same two-way rule. The catalogue is a lagging denominator, because it holds only what has already happened to someone, so it is cross-checked from the other direction by an asset closure (`docs/assurance/assets.json`, checked by `asset_closure.py`): six things the system holds or decides (funds in transit, delegated allowance, the protocol fee, registry integrity, stranded balances, caller gas) crossed with five ways a thing can be lost (theft, freeze, dilution, misdirection, griefing), thirty cells, each carrying a status. Nineteen cells are covered by named threat classes; every threat id the closure names must exist in the catalogue. The closure's value is that it can name a cell nobody has ever exploited. ### §14.2 Hostile hooks: three layers, cheapest first A hook is arbitrary code running inside the settlement the Router is performing, and the naïve defence — asking it what it will do — is no defence, because a hostile hook lies or re-enters. Three independent layers stand instead, arranged so the cheapest and most certain runs first. They bound delta alteration; the one residual they do not reach — a delta-free hook overriding its dynamic fee (§5.4) — is bounded by Φ and the caller's minimum instead. **Layer 1 — the permission bits live in the address, and the address cannot lie.** V4 encodes a hook's permissions in the low 14 bits of its own contract address; those bits are fixed at deployment by the CREATE2 salt, and the PoolManager itself checks the same bits before invoking the hook, so a hook cannot have a permission its address does not declare. Exactly two bits allow a hook to modify swap accounting, and the Router masks them with a single AND before any token moves (`hookAltersDeltas`, Core:3425 at `6387350`): $$ \left(\mathrm{uint160}(\mathrm{hook})\ \&\ \mathtt{0x3FFF}\right)\ \&\ \left((1 \ll 3) \mid (1 \ll 2)\right) \ne 0 \;\;\Longrightarrow\;\; \text{leg refused, } \mathtt{RouterE(9)}\ \text{(Router:2033)} $$ ^e18 No call into untrusted code, nothing to deceive, and evasion would require an address whose bits contradict the manager's own enforcement. A proxy can replace every line of its logic and still gain no bit its address never had — which is why this refusal sits at projection distance zero (§15.9) while the codehash pin beneath it does not. **Layer 2 — an allow-list and a code pin, for the hooks that run in the swap.** The same address answers a second question without a call: does the manager enter this hook during a swap at all? Four bits say so — before-swap (1 ≪ 7), after-swap (1 ≪ 6) and the two delta flags — and the Router reads them with one mask (`hookRunsInSwap`, `0xCC`, Core:3443). The list and the pin are required of exactly those hooks. A hook with none of the four bits is never entered by its own pool's swap, so there is nothing about its code an operator could judge that could change a swap, and the Router admits its pools by the bits alone; quote equals execution for it exactly as for a hookless pool (the comment above Core:3443 states the rule and is the source, no derivation beyond the dispatch-on-bits fact is claimed) . For a hook that does run in the swap, the Hub holds the allow-list (default closed) and pins the hook's codehash at admission (`allowHook`, Hub:543). A hook is *paused* (`hookPaused`, Hub:595) when the curator revoked it, or when it is listed and its runtime has moved since the pin — it is then refused on every door (`RouterE(9)`, Router:2049) and resumes only if re-admitted, with its pools' registry state preserved. After renunciation the curator keeps the power to admit and loses the power to withdraw: `allowHook(h, false)` is refused (`HubE(1)`, Hub:551), and a listed hook whose code moved cannot be re-armed at its new code (`HubE(1)`, Hub:559), so it stays paused for ever, while listing a new hook or re-listing an unchanged one still works. A revoked hook is not re-admitted by registering a pool that carries it (`HubE(8)`, Hub:582); registering a hooked pool is otherwise the admission of its hook (`_admitOnRegistration`, Hub:580). A hook nobody ever listed is a different case and is stated as one: the explicit door accepts it as the caller's own signed choice, bounded like every venue by the in-frame promise, the attestation gate and `userMinOut`; the automatic door never proposes it, because the registry reads filter rows by `isHookLive` (Hub:621; the filter in `getActivePools`, Hub:1596). The pin's limit is stated at the site: it binds runtime code, so it catches a redeploy or a direct mutation and does not catch a delegate proxy whose implementation is swapped while its own runtime stays byte-identical, because the EVM gives a contract no way to read another's storage. Admitting an upgradeable hook is a human judgement this pin cannot replace. The layers that do not depend on it stand regardless. One reach the bits do not describe is stated rather than hidden: a hook that runs in the swap can call the manager on any pool, and a donate, a swap or a liquidity change there enters that pool's hooks. That is bounded by the manager's flash accounting — a delta left unsettled reverts the whole unlock, which the fork tests exercise (`test/fork/NestedHookSettlementFork.t.sol`: a nested donate reaching an unadmitted hook, a take that never settles, an admitted hook that never settles its donate) — by the same floors, and by the admission of the hook that makes the call, never by the bits of the one it reaches. **Layer 3 — the automatic route is never even shown.** The projector Ξ removes any pool whose hook alters deltas from the Solver's candidate set before ranking: the filter sits in the merge of registered and discovered pools inside `_rankedPools` (Solver:1531; the two loops at Solver:1584 and :1590), and the Hub's read channel serves only hooks that are live. A route touching a delta hook does not participate in the maximisation, so the planned door cannot assemble a route the Router would refuse. The Router's own check is not removed to make the two agree: it stays as the fail-closed floor. A route-shape rule completes the layer: canonical order, route-wide — no hookless leg ever executes after a hook has run (§11.4). ![FIG-11 — Three layers against hostile hooks, cheapest first](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-11.svg) *FIG-11 — Three layers against hostile hooks, cheapest first: the address bit-mask (no call into untrusted code), the allow-list with the codehash pin for hooks that run in the swap (default closed), the projector Ξ (route not representable on the automatic door). Each layer answers a different capability; the residual is named.* Defeating the stack requires a hook that carries no delta bits, sits on the allow-list unchanged (or runs in no swap at all), and still subverts settlement — a combination Layer 1's appeal to V4's own immutable enforcement rules out for delta alteration; the fee-override residual of §5.4 remains, and the floor bounds it. An allow-listed, delta-free hook can still revert mid-swap and waste the gas of trying; that is the named residual of the middle layer. And the sieve's single lever is named: the sieved hook binds the executed swap because the canonical PoolManager echoes unlock data verbatim and calls back only its unlock caller; the Hub's `setV4Manager` (`onlyControl`, Hub:536), a control power that dies with renunciation, is the one address that assumption rests on, and a dishonest manager collapses the measured output so the caller's own bound refuses the swap (`HostileV4Manager` campaign) — bounded, not absent. ### §14.3 Bounded, not eliminated: staleness, ordering, and the sandwich curve A quote is a statement about the past, and the trade happens in the future. The in-frame solving door closes the operator-side half of that gap completely — the route is derived inside the transaction that executes it, from reserves as they stand in that block. What remains is the chain's own half: the pool can move between the moment you sign and the moment your transaction is included. Nobody can prevent this from inside a contract, because ordering is decided before the code runs; a protocol claiming to have eliminated front-running has either moved your trade off the public queue, trusting whoever now holds it, or is describing something narrower than it sounds. What this protocol does is bound it, twice and independently: your minimum caps the damage at the number you chose, and the Iron-Law floor — re-derived by the Router from measured impact and the final hop's in-frame quote (`ironFloorBpsShv`, Core:3345), not from anything the attacker or the route supplied — caps it again on the protocol's own account. The bound is measured from the attacker's side (`test/regime/SandwichCurve.t.sol`): the victim's route and floor are fixed at quote time, as in a pending transaction; the attacker trades a fraction of the pool's depth ahead of the victim, the victim executes, the attacker trades back. The venue is a constant-product pair — the shape every sandwich model uses — so the curve is a property of the floor. On a 1 %-of-depth trade (10,000 against 1,000,000 a side): | Attacker moves | Victim | Victim's loss vs the quote | Attacker's round trip | |---|---|---|---| | 0.1 % of depth | settles | 0.47 % | +13.9 | | 0.5 % | settles | 1.26 % | +68.9 | | 1 % | settles | 2.22 % | +136.7 | | 2 % | settles | 4.12 % | +268.7 | | 3 % and beyond | **refused** | 0 | −174.5 … −544.9 | Re-run in CI at 969bcc6; every figure matches the 2.3 measurement. With no attacker the victim's gap to the quote is 0.27 %. The guarantee the test asserts at every grid point is structural, and it is the part that does not depend on the table: a settled victim never receives less than the floor attested at quote time, so the loss is bounded by the distance between the attested quote and the attested floor; and the refusal region is closed upward (`test_SandwichCurve_TheFloorBoundsTheVictimAndStarvesTheAttacker`, line 132: `assertFalse(settled, "the refusal region is closed upward")` once the first refusal has occurred) — past the edge every larger manipulation is refused and the attacker is left holding the price they moved. The in-frame route adds a quieter deterrent: there is no pre-published path for a searcher to study, because the path does not exist until the block that executes it. A wide minimum is an invitation; a tight one is the single most effective control in this section that belongs to you. ### §14.4 Hostile venues Venue pathologies have their own matrix (§15.5): ten misbehaviours — a pool that pays nothing, pays half, returns a 64 KiB returndata bomb, burns all gas on the read, burns all gas on the swap, a token whose `decimals()` never returns, a payment callback fired twice, a pool that re-enters the Router before paying, a reverting `slot0()`, a factory answering with a pool on other tokens — crossed with the calldata door and the solving door. The file holds 20 cells, ten venues times two doors (`test/regime/HostileVenueMatrix.t.sol`, 20 `test_Matrix_*` functions, counted at 969bcc6); the rule for every cell is that the swap settles with the delivered amount equal to the balance delta and nothing left on the Router, or refuses with a selector of ours, with sharper oracles for the pays-nothing and pays-half cells (they must be refused) and for the re-entering pool (the harness records whether its nested swap ever ran). A swap that burns all forwarded gas is the one cell no caller can decide for its callee; the transaction reverts whole and the user's balance is untouched. All 20 cells pass in the CI run at 969bcc6. Every guarded read the Core makes to a venue is capped at `GAS_CAP = 100,000` gas (Core:215), so a venue that burns gas on a *read* costs a bounded amount and is dropped, not fatal. A venue the protocol does not control can also arrive behind a wrapper. The Gate puts a permissioned venue behind an immutable wrapper whose adapter is proposed, pinned by codehash and accepted only after a 48-hour delay (`ADAPTER_DELAY`, Gate:76); a pair holds at most four wrappers (`GATE_MAX_WRAPPERS = 4`, Core:192; the fifth is refused with `GateE(16)`), and a wrapper's quote on the planning path runs under a fixed gas allowance (`GATE_QUOTE_GAS = 500,000`, Core:3271), so one adapter cannot spend the caller's gas. Three classes in `docs/assurance/threats.json` answer the abuse this invites, each with its guard and the test that fails without it: an unbounded wrapper list spending a solve's gas (`GATED-AUTO-LIST-GAS`, guard `GATE_MAX_WRAPPERS`, `test_GatedAuto_WrapperListIsCappedAtFour`); an adapter that over-quotes its venue (`GATED-AUTO-OVERQUOTE`, guard `LEG_FLOOR_BPS`, `test_GatedAuto_OverquotingAdapterHoldsTheFloorUntilCleared`: no funds move, the floor and the caller's minimum hold); and dust swaps that pump a wrapper's use counter (`GATE-DUST-USE`, guard `MATERIAL_SHIFT`, `test_GateVital_DustInputNeverTicks`). The third-party venue's own security is still not claimed (§14.1, SOK-BRIDGE-EXT). ### §14.5 The hostile front end On every aggregator ever built, the interface proposes the minimum, and a careless one proposes it badly — no contract can know what you would have chosen. What a contract can do is make the proposal provable: every swap emits `ExecutionProof(user, tokenOut, quoted, realized, floorUsed, blockNumber)` (Router:272-275, emitted at Router:1697) — the final hop's quote, the amount delivered, the floor applied — permanently, on-chain, so any interface's execution quality is a public, per-transaction record that anyone can audit, including you. `user` is the payer and `tokenOut` is indexed, so the record is filterable by either. `floorUsed` is published net of a transfer tax on the output token, in the units the floor is attested in, so on a settled swap with no output-side fee it never exceeds `realized` (the event's own documentation, Router:268-270). An interface that consistently proposes bad minimums writes its own indictment into the event log. The defence that completes the mechanism is a habit: look at the minimum before you sign; it is the one field that is entirely yours. ### §14.6 What a hostile key can and cannot do Before renunciation, administrative keys exist, and the honest way to describe them is by capability, hostile holder assumed; the full enumeration of powers is §16.4. **What a hostile Router key can do:** hand the admin seat to another address (`setAdmin`); redirect the two fee slots (`setTreasuries`); pause swaps (`setPaused`); repoint the WETH and Permit2 contracts the native and Permit2 doors call (`setWeth`, `setPermit2`), which makes those two doors only as trustworthy as the addresses set; queue and, 48 hours later, execute a rescue of tokens stranded in the Router (`queueRescue`, `cancelRescue`, `executeRescue`, `RESCUE_DELAY = 48 hours`, announced on-chain by `RescueQueued`, `RescueCancelled` and `Rescued`). Every one of these is gated by one modifier, `onlyControl`, which refuses any caller that is not the admin and refuses everyone once control is renounced (`RouterE(1)`, Router:305). **What it cannot do:** move the fee rate or the split, because both are compile-time constants with no setter (`PROTOCOL_FEE_BPS = 28`, Core:426; `TREASURY1_SHARE = 3_000`, Router:149); take principal, because the Router grants no allowance (its own header states "No `approve` anywhere", Router:28), there is no `selfdestruct` anywhere in `src`, and there is no upgrade function; or reach the fees the treasuries are owed through the rescue path. A rescue returns the Router's balance of a token *less* what is booked as owed to the two fee slots (`executeRescue`, Router:416-420), so even a hostile admin who queues a rescue of a fee token takes only the stray remainder. One refinement of the 2.3 wording is needed here: the Router does not hold *literally* nothing at rest. Swaps settle or revert inside their own frame and fees are pushed to the treasuries as they are charged, but a push that the fee token refuses (an issuer's blacklist, for example) is booked to `owed` instead of reverting the swap, and waits there for its slot's holder to claim it (`claimFee`, Router:347; register row in `SHARED_QUANTITIES.md`). At the end of a swap the Router holds zero in any token that moves the amount it is asked to move, and in native; the one stated bound is a token that keeps balances as shares and rounds each transfer down, which can leave at most one share per outbound transfer (Router header, R1; `test/RouterBalanceAfterSettlement.t.sol`). What the Router holds at rest is therefore the booked `owed` balance and that bounded crumb, and neither is a swapper's principal. **What a hostile Hub key can do:** list a venue or a hook (`addFactory`, `allowHook`) and add a bridge token (`addBridge`, at most three); seed pools (`seedPool`, `addV4`, through an operator seat or the admin itself); pause the registry's learning (`setPaused`); repoint the Hub's view of the Router, Solver and Quoter (`setRoles`); grant or revoke operator seats (`setOperator`); remove a bridge (`removeBridge`); and repoint the V4 manager (`setV4Manager`, the sieve's single lever; the Hub's own comment records what the sieve rests on and that a dishonest manager is bounded, not absent). **What it cannot do:** misprice a fill, because the registry decides only what is seen (§9.6) — the sharpest thing a hostile listing reaches is the gap between a quote and *your minimum*; principal is out of reach, your slippage tolerance is not, which is one more reason the minimum is yours to set tightly. ### §14.7 The One-Way Door Administrative authority ends irreversibly, in bytecode, not by promise. Both the Hub and the Router expose `renounceControl`, and each refuses to be called while paused (`RouterE(2)`, Router:377; `HubE(2)`, Hub:486): a paused-then-renounced protocol would be a terminal state nobody wants and nobody can leave, and pausing is worth doing precisely because control is retained to act. The renunciation flag is written `true` at exactly one site in each contract (Router:378, Hub:487) and written `false` at none, so no function in the deployed bytecode can reopen the door — the difference between "we won't" and "we can't". What closes and what stays open is enumerated, not summarised. On the Router, everything under `onlyControl` dies: `setAdmin`, `setTreasuries`, `setPermit2`, `setWeth`, `setPaused` and the whole rescue path (`queueRescue`, `cancelRescue`, `executeRescue`). The fee rate and the split were constants and stay so; the wiring (Permit2, WETH) and the pause flag freeze at their current values for ever, and the Router keeps executing swaps under that fixed configuration. One door on the Router is deliberately left open, and it opens onto the payee, not the protocol. `moveTreasury(to)` has no `onlyControl` modifier: whoever currently holds treasury slot 1 or slot 2 may reassign *that* slot to any non-zero address, also after renunciation (Router:337-342). It exists because a fee token that blacklists a treasury address would otherwise revert every swap of that token in the fee push, and with control renounced nobody else could move the address (the function's own comment, citing bounty #55). What it can do is narrow and stated: the holder moves only the slot it holds (a caller holding neither slot is refused with `RouterE(1)`); the new address cannot be zero (`RouterE(3)`); if one address holds both slots, a call moves slot 1 first; the call emits `Cfg(1, to)` or `Cfg(2, to)`. What it cannot do: change the admin, touch the other slot, touch the fee rate or the split, or pause anything. Because the *slot*, not the address, is the creditor of any fee booked to `owed`, a slot that has moved claims everything booked to it (`claimFee`, Router:347), so a payee that rotates an address does not strand what it was owed. Earlier versions of this text said the treasuries freeze at renunciation; that was true only of `setTreasuries`, and the contract's own `renounceControl` documentation says so (Router:361-365). On the Hub, the **control tier** dies: `setRoles`, `setOperator`, `setPaused`, `setV4Manager`, `removeBridge`, hook *de-listing* (`allowHook(h, false)` reverts with `HubE(1)` once control is renounced, Hub:551), and `initialize`, which is also refused after renunciation (Hub:457). The **curator tier** survives, and only grows the registry: `addFactory` (refusing, after renunciation, a re-listing whose runtime codehash moved or whose kind, mode, init hash or fee and spacing set differs from the listed row, Hub:881-887), `addBridge` (add-only, at most three, idempotent: Hub:111, :649-658), and `allowHook(h, true)` (refusing a listed hook whose code moved, Hub:559; re-listing an unchanged hook re-pins it); registering a pool with a revoked hook through `seedPool` or `addV4` does not re-admit that hook (`HubE(8)`, Hub:582). The admin and existing operator seats keep `seedPool` and `addV4`, and because `setOperator` is dead no new seat can be granted. A malicious listing after renunciation cannot drain: pools are validated at quote and at execution and bounded by the floor and the caller's minimum, as the Hub's own documentation puts it. The registry keeps learning by trading. Anyone repeating "renounced" about this protocol should be able to say which doors stay open — admission, bridges, hook listing, curated seeding, and a payee moving its own fee slot — and which close: every power that redirects or freezes. ### §14.8 What this model asks of you The protocol closes what a contract can close: address forgery, callback spoofing, accounting forgery, hostile hooks, arithmetic. It bounds what no contract can eliminate: staleness and ordering, by your minimum and the floor. And it publishes evidence against what it cannot even bound: a front end proposing bad minimums on your behalf. Every row converges on the same field. Set your minimum yourself, deliberately, every time — it is the one protection in this section whose quality depends on nobody's competence but yours. ### §14.9 The guarantees, each with its own check Everything in this section reduces to nine guarantees that the repository's README states in one table. Each row names the code that enforces it and the command that turns red if it stops holding; none of them asks to be taken on trust. The table below adds the on-chain refusal and the section of this paper that derives it. | Guarantee | Enforced by | Check it yourself | Here | |---|---|---|---| | No swap without the caller's own floor | `RouterE(10)` on every value door when `userMinOut == 0` (Router:456, :467, :523, :560) | `forge test --match-path test/A1EveryValueDoorRefusesZeroMinOut.t.sol` | §11.7 | | Delivered output at least `max(protocol floor, userMinOut)`, or the swap reverts | the Router's settlement check, priced by the Core evaluator (`RouterE(5)`) | `halmos --contract CoreFormalGateSpec` | §11.5 | | The quote and the enforced floor agree | one evaluator for preview and execution | `forge test --match-path test/PreviewExecutionParity.t.sol` | §12, §15.1 | | No reentry during a swap, pool callbacks and the output transfer included | a transient (`tstore`) lock spanning the swap (`RouterE(7)`) | `forge test --match-path test/ReentryFromTheOutputTransfer.t.sol` | §11.4 | | The Router ends a swap holding nothing of what it moved, with the single rounding bound for share tokens stated and pinned | balance-delta settlement | `forge test --match-path test/RouterBalanceAfterSettlement.t.sol` | §11.6, §14.6 | | The Router leaves no token allowance standing | a static guard over the source | the `Router grants no allowance` step of the CI workflow (`.github/workflows/ci.yml`) | §14.6 | | The V4 fee is measured and fails closed | `effV4Fee` | `halmos --contract EffV4FeeFormalSpec`; Certora rules `dynamicUsesMeasuredLpFee` and `dynamicWithProtoFeeFailsClosed` (two of the five rules), specified in `certora/specs/EffV4Fee.spec` (`certora/conf/effv4fee.conf`; Appendix B.5) | §15.1 | | Every contract fits EIP-170 with a published margin | size guard in CI (fails at 24,000 bytes of runtime, 576 bytes under the 24,576 limit) and in the suite | `FOUNDRY_PROFILE=release forge build --sizes` and `test/DeployedSizeGate.t.sol` | §16.3 | | What is deployed cannot change unnoticed | codehash and property pins of the live generation | `forge test --match-path test/fork/DeployedParity.t.sol` (archive RPC) | §14.2, §16.3 | Read the table in two directions. From a claim to its evidence: each check is a single command, and a guarantee with no failing command is not on the list. From the evidence to its limit: a check proves the property it names under the conditions it names, and §15.11 states what the whole apparatus does not establish. The ninth row is the one that cannot be run from a clean checkout alone, because it compares the repository with chain state through an archive node. ## §15 The verification apparatus, measured ### §15.1 The suite in numbers Every figure carries its denominator and the command that reproduces it. Measured at commit `969bcc6` (CI run 43886865849, 2026-11-16). | What | Count | How it is counted | |---|---|---| | declared tests | 3,517 functions in 515 files; 3,562 executed in CI at 969bcc6 (3,416 suite + 146 fork; 8 skipped, 0 failed) | `grep` over `test/`; CI | | green on the default profile, fork suites excluded | 3,408 passed · 0 failed · 8 skipped, of 3,416 tests in 521 suites | `forge test --no-match-path "test/fork/**"` | | of which, by kind | 54 `invariant_*` · 240 fuzz · 3,122 unit (derived: 3,416 − 54 − 240) | count of `[PASS]`/`[SKIP]` lines by name and by `runs:` in the same run | | green on live liquidity | 146 passed · 0 failed · 0 skipped, in 48 files of `test/fork/` | `forge test --match-path "test/fork/**"` with an archive RPC | | suite plus fork lane | 3,562 tests: 3,554 passed · 0 failed · 8 skipped (derived: 3,416 + 146) | the two lines above | | stateful invariants | 54 `invariant_*` functions in 18 files | `git grep 'function invariant_' -- test` | | symbolic and formal | 15 Halmos checks reporting `[PASS]` at `6387350` (Appendix B.3) · 4 Certora specs (specified, Appendix B.5) | `halmos --contract `; `certora/conf/` | | curated mutants | 1,895 registered in `M`, plus 19 in `M_FORK`; 1,753 run on this commit, all killed | `.github/scripts/mutants.py`; `check_targets.py` | | regime covering arrays | strength 2: 60 rows · strength 3: 145 rows; 237 pairs and 1,441 triples in the arrays | `test/regime/RegimeCoverage.t.sol`, `RegimeCoverageT3.t.sol` | | shipped sizes (runtime bytes; EIP-170 limit 24,576; project gate 24,000) | Hub 23,360 · Router 23,710 · Solver 21,253 · Quoter 19,760 · Core 21,801 · Gate 10,710 | `FOUNDRY_PROFILE=release forge build --sizes src` | Reading the table. - **Fuzz and invariant settings are fixed, not tuned per run.** The fuzz seed is `0xb1a2ef00`, fuzz runs are 256, invariant campaigns run 50 sequences of depth 50 (`foundry.toml`); nine fuzz tests override the run count in their own file (seven at 64, two at 32). A failure therefore reproduces from the seed. - **Profiles.** The suite runs on the default profile. The default and release profiles share every compiler option (solc 0.8.36, cancun, `optimizer_runs` 200, `via_ir`, `bytecode_hash = none`), and `profile_parity.py` pins that equality; the release profile itself is what the size guard builds. This paper does not claim a suite run on the release profile. - **Skipped is not passed.** The 8 skipped tests are counted out of the 3,408: five are fuzz tests of the n-version lane, declared with 0 runs, and three are unit tests. - **Covering arrays.** The regime matrix is exercised by a strength-2 array (every pair of factor levels appears in some row) of 60 rows and a strength-3 array (every triple) of 145 rows. The assurance documents still quote an earlier generation of the arrays, built when the Router still accepted a third hop (before 2026-11-06); with `MAX_HOPS = 2` (Core L136 at `6387350`) the factor is gone and the arrays above are what runs. - **Sizes.** At `969bcc6` the margin to the EIP-170 limit is 1,216 bytes for the Hub and 866 for the Router; the CI guard fails a build at 24,000 bytes of runtime, 576 below the limit. The full 16-contract table, measured at the later commit `6387350` (Hub 21,780, Router 22,717), is in §16.3. ### §15.2 The evidence chain, and the curated mutation guard A property is only as good as the shortest path from a threat to something that would fail if the property broke: ``` threat -> property -> guard -> test -> mutant ``` A guard is named by symbol, a test by name, a mutant by the exact line it alters; if any of the three leaves the tree, the build fails. The first rule of the repository's contributing contract is red before green: a change that fixes a defect arrives with a test that fails without it, and the test header names the commit at which it was red. A guard without a mutant does not merge. The mutation guard is a fixed, versioned register, not a generic mutation tool: 1,895 entries in `M` and 19 in `M_FORK`, each pairing one exact line of source, a replacement, and the single test that must fail once that line is altered. It deletes a guard, flips a comparison at the bound that decides a refusal, widens an authorisation, or swaps an error code for its neighbour's. Three properties make it a guard rather than a score. - **The paired test is green first.** `baseline()` runs the suite on the unmutated tree, and a mutant whose paired test is already red, or never ran, is reported as a failure of the guard, because a test that is red for its own reasons would "kill" every mutant pinned to it for free. - **A mutation that changes nothing is inert, not killed.** `artefact_fingerprint()` hashes the deployed bytecode before and after; a source edit the optimiser folds away yields a byte-identical artefact and is reported as inert. - **A target that moves is caught.** `check_targets.py` is a static check, run on every push, that every mutant still points at exactly one line of source. Killed: all 1,753 run on this commit. The figure is adequacy against this register: a kill count is a floor on what the suite notices, never a ceiling on what could be wrong. ### §15.3 Mutants aimed at the invariants Until 2026-09-05 none of the curated mutants named a stateful invariant as the test that must die to it. The invariants were green, and nothing had asked whether any of them could go red: a campaign whose handler never reaches the state a property protects certifies that property over an empty universe, and looks identical from outside to one that reaches it. The measurement is the guard's, pointed at the campaigns: alter one guard in the source, run every invariant on one seed, record which ones notice (`docs/assurance/invariant-mutants.json` holds the matrix, with the exact edit). It was taken on the 40 `invariant_*` functions in 14 campaigns of that date; the suite now holds 54 in 18 files (§15.1), and the map below is that first measurement, not a re-count on the current set. The map, mutant to the invariants that die to it. | Mutant | What it removes | Noticed by | |---|---|---| | the final transfer pays one wei less | holds-nothing | `RouterHoldsNothing`, `routerHoldsNothing`, `HoldsNothingBeyondTheSeed` | | the protocol fee doubles | the fee ceiling | `FeeNeverExceedsProtocolMax` | | the input-side fee is never charged | the fee floor | `FeeNeverEscapes`, `DeliveredNeverBelowUserMinOut` | | the fee is charged on both sides | one fee, one side | `FeeIsChargedOnExactlyOneSide` | | 30 % of every fee goes to a dead address | conservation | `conservationA/B/C/H`, `TokenConservation`, `LedgerConservationA` | | the leg-pair guard admits a leg on the wrong pair | homogeneous hops | `DivergentLegNeverSettles`, `HoldsNothingBeyondTheSeed`, `StrandedMoneyIsNeverSwept` | | `whenLive` no longer checks `paused` | the pause | `PausedRouterNeverSettles` | | the reentrancy lock no longer refuses | the lock | `reentrancyBlocked` | | `MAX_SLOTS` becomes 17 | the registry bound | `neverExceedsMaxSlots` | | the input-residual sweep ignores its baseline | stranded money | `StrandedMoneyIsNeverSwept`, `HoldsNothingBeyondTheSeed` | Each mutant above became an entry in the mutation guard, paired with the invariant that dies to it. ### §15.4 Regime covering arrays Coverage criteria index the code; mutation indexes an injected fault; neither indexes the state a *fixture* fixes before the call. Ten such factors are enumerated: venue family (V2, V3, Solidly), hops (1 or 2, the routes the Router accepts under `MAX_HOPS = 2`), legs per hop (1-2), whether the input token is a registered bridge, whether the intermediate is, fee-on-transfer shape (none, pull-only, every transfer), the input token's decimals (18, 6), the door (calldata route, solve-in-transaction, Permit2), control (live, renounced) and whether the pair is full. That is 3,456 combinations (`docs/assurance/regimes-covering.json`). `covering_array.py` generates arrays in which every pair (strength 2) or every triple (strength 3) of factor values appears in at least one row. Each row is one fixture through one harness (`test/regime/RegimeHarness.sol`) with one assertion: the swap settles, with the delivered amount equal to the recipient's balance delta, at least the floor the Router emitted, and nothing left on the Router; or it is refused with a selector of ours. A panic, a foreign selector, an under-delivery or a stranded balance is a third way and fails the row. | Strength | Rows | Tuples in the array | Settled | Refused, ours | Not constructible | Third way | |---|---|---|---|---|---|---| | 2 | 60 | 237 pairs | 53 | 1 | 6 | 0 | | 3 | 145 | 1,441 triples | 138 | 7 | 0 | 0 | The outcome columns are measured by running `test/regime/RegimeCoverage.t.sol` and `RegimeCoverageT3.t.sol`, and a row is counted as passing only if its single assertion holds; the 60 and 145 rows pass in the suite run of §15.1 (60 of 60, 145 of 145). The rows the fixture cannot build are printed by name and count against the denominator. At 969bcc6 the six it cannot build (strength 2) are all pull-only fee-on-transfer rows at six decimals; at strength 3 every row is built. The split is in the table. ![FIG-14 — Regime covering arrays: outcome of every generated row](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-14.svg) *FIG-14 — Regime covering arrays: outcomes of every generated row at strength 2 and strength 3 — settled, refused with a selector of ours, not constructible, third way — over the combinations of ten factors.* The families not in the array are stated in `docs/assurance/regimes-covering.json`: V4, native V4, Algebra, the native door and hooks, whose harness mocks live in individual test files. The array's first run made a frame explicit that the parity tests had pinned only on one side: the floor the Router enforces equals the attested floor when the fee comes off the output, and sits inside $[\mathrm{attested}, \mathrm{attested} / (1 - \mathrm{fee})]$, one factor per charging hop, when it comes off the input: the lower edge because a curve concave through the origin delivers at least the net share of the gross output, the upper edge the floor read back on the gross output, which the enforced floor never exceeds. Both frames are asserted on every row. `covering_array.py --check` fails if a committed array has drifted from the factors it claims to cover. ### §15.5 The hostile-venue matrix Token pathologies (fee-on-transfer, rebasing, blocklists, pausing, odd decimals) have long had their tests. Venue pathologies did not have a matrix. `test/regime/HostileVenues.sol` holds one misbehaviour per venue, and `HostileVenueMatrix.t.sol` crosses each with the calldata door (`EXACT_IN`) and the solving door (`BEST`) under the covering array's rule: the swap settles with the delivered amount equal to the recipient's balance delta and nothing left on the Router, or it is refused with a selector of ours. | Venue | What it does | Oracle beyond the rule | |---|---|---| | lying V2 pair | takes the input and pays nothing | must be refused | | half-paying V2 pair | pays half | must be refused | | returndata bomb | answers the reserve read with a returndata bomb | the rule | | gas bomb on the read | the reserve read burns all gas | the rule | | gas bomb on the swap | the swap burns all forwarded gas | the transaction reverts whole and the user's balance is untouched: no caller can decide this case for the callee | | gas bomb on `decimals()` | a token whose `decimals()` never returns | the rule | | double callback (V3) | fires the payment callback twice | the rule | | re-entrant (V3) | re-enters the Router before paying | the pool records whether the Router let the nested swap run; it must not | | `slot0()` reverts (V3) | the state read reverts | the rule | | wrong-pair factory | its `getPair()` answers with a pool on other tokens | nothing settles through a pool on other tokens; discovery must not list it | Ten venues times two doors: 20 test functions, `test_Matrix__ExactIn` and `test_Matrix__Best`, all in the suite run of §15.1. Each cell prints `CELL ` (settled, refused with our selector, or admission refused), so the outcome of every cell is read from the run and not asserted from memory. At `969bcc6`: six cells settle, ten are refused with a selector of ours (`RouterE(5)`, `(6)`, `(8)`, `SolverE(5)`), two are refused at admission (`HubE(4)`), and two exhaust the forwarded gas and revert whole with the user's balance untouched. A cell passes by settling or by a refusal with a selector of ours, never a third way. The last row is what the matrix's first run changed. Discovery listed a pool that a curator-admitted factory answered with, and the Solver planned it; the executor refused it at the seam that pays (`LEG-01`), so funds were never at risk, but the pair stayed refused for as long as the impostor won the split. Discovery now proves an asked pool's own pair before listing it, and the cell asserts that `discoverFor` never returns the impostor (§7.2). ### §15.6 Canonical oracles Every mock in the suite quotes with the Core's own formulas, so a defect in a formula is invisible to every parity test that uses them: the oracle is the object. `test/regime/CanonicalOracles.t.sol` holds three implementations written from the venues' published invariants, not from the Core, and fuzzes the Core against them: constant product with the fee on the input (Uniswap V2), the single-tick square-root-price step with the pool's own against-the-trader rounding (Uniswap V3), and the stable curve $x^3 y + x y^3 = k$ solved by Newton's method (Solidly). The direction is asserted first: the Core never promises more than the venue's own mathematics delivers, because a quote above the truth is the defect that reaches a user, while a quote below it is a worse price the floor still bounds. Tightness is asserted second, to the width the rounding order can explain. | Family | Direction (asserted in the test) | Tightness (asserted in the test) | |---|---|---| | Uniswap V2 | `core <= spec` | `spec - core <= 1` wei | | Solidly stable | `core <= spec + 2` wei | `spec - core <= spec / 10^6 + 4` | | Uniswap V3 | `core <= spec + ulp`, with `ulp = L / 2^96 + 1` | `spec - core <= spec / 10^9 + 4` | The V3 bound is stated in the quantity that causes it. The pool rounds its new price against the trader and the Core rounds it once, so the two can differ by one unit of $\sqrt{P}$, which is worth $L / 2^{96}$ wei of output; for any pool with $L < 2^{96}$ that is below one wei, plus the one wei the bound carries. The assertion is the bound, not a sample. The stable curve is the loosest, because Newton's method stops within a wei of the root on either side and the Core may carry its own margin. The test also prints the worst gap it observes on a fixed grid for each family (`test_Grid_TightnessIsMeasured`). Each fuzzed oracle runs at the suite's default budget, 256 inputs per test. The oracles are written from the specifications, not from the venues' bytecode; that is their limit. ### §15.7 Metamorphic relations An oracle written from the same formula cannot catch the formula. A metamorphic relation asks instead how the output must *move* when the input moves, and the venue's own curve answers that without a reference implementation. `test/CoreMetamorphicRelations.t.sol` holds fifteen test functions over the Core's quote maths (seven relations, MR1 to MR7, instantiated per curve) and `test/RouteMetamorphicRelations.t.sol` holds eight over the Solver's plan, on a two-pool universe with a real Hub and a real Solver and no Router: the relations are about routing decisions, and settlement has the covering arrays of §15.4. | Level | Relation | What it says | Bound the assertion states | |---|---|---|---| | Core, V2 · V3 · stable | MR1 monotone | more in, never less out | none (`<=`) | | Core, V2 · V3 · stable | MR2 sub-additive | splitting an order across the same pool never gains | whole `<=` parts + 2 wei (V2, stable); + 2 wei + 2 ulp (V3) | | Core, V2 · stable | MR3 no round trip | in, then back on the updated reserves, never returns more than went in | none (`back <= a`) | | Core, V2 · V3 · stable | MR4 scale equivariance | scaling order and pool together scales the output, to rounding | V2: at most $k$ wei over, 1 wei under; V3: $2k + 1$ + ulp; stable: $k$ + a millionth of the output | | Core, V2 · V3 | MR5 fee monotone | a higher fee never pays more | none (`>=`) | | Core, V3 | MR6 direction symmetry | at price 1.0 the two arms of `outV3` agree | two ulps + 2 wei | | Core, Solidly | MR7 identity | the volatile arm *is* `outV2`, one producer | equality | | plan | MR-R1 | the split never pays less than the best single pool would | none (`>=`), over pools the band keeps | | plan | MR-R1d | a dust pool is not quoted, and dropping it costs at most the price gap | `got * 10_401 >= best * 10_000` | | plan | MR-R2 | monotone in `amountIn` | none (`<=`) | | plan | MR-R3 | adding a pool inside the price band never lowers the plan | none (`>=`), over pools the band keeps | | plan | MR-R4 | registration order moves the plan by at most one weight unit of the split | `fwd / 10 000 + 16` wei | | plan | MR-R5 | the attested floor never exceeds the expected output, and is not zero | `floor <= expected`, `floor > 0` | Three of the bounds (MR6, MR-R1d and MR-R4) were measured before they were written, and the number in the assertion is the mechanism, not the sample; the domain limits of MR-R1 and MR-R3 were set by measurement in the same way. - **MR6.** At $L = 8.5 \times 10^{37}$ and 1,374 wei in, one arm quoted 1,073,741,823 wei, exactly $L / 2^{96}$ (one ulp: the price moved one step, worth that much output), while the other quoted zero, its price step rounded to nothing and failing closed. The relation states two ulps, one per arm. Both arms have since been made to round against the trader (commit `e5ced25`); the bound was kept. - **MR-R1 and MR-R3.** Before the price band existed, the file's header records that with one pool priced $10^{10}$ away from the other the plan paid 35 % less than the outlier alone (MR-R1); the relations now run inside the band's domain, so that figure is history, not a property asserted at 969bcc6. The relations therefore hold over pools the band keeps. Since the band became the band of no arbitrage (2026-10-28, §10.3), the two prices stay within ±0.5 % of each other in these two relations, and the two depths within 1 : $10^4$. The header records the measurements that set those limits: over ±4 %, MR-R1 met a plan 1.9 % under the pool the band had dropped, and MR-R3 a pool whose arrival lowered the plan 2.7 % (the deeper pool set the median and the cheaper one left). - **MR-R1d.** A pool holding under 25 ppm of the rest of its pair (`MIN_SPLIT_IMPROVEMENT_PPM`, §10.4) is dropped before it is quoted. Measured on the CI seed before the domain was written: a pool at 7.7 ppm of the other, priced 3.97 % better, would have paid 309 bps more on an order of 0.85 % of its reserve, and a deep pool added next to a 5 ppm one replaced it at 311 bps less; both plans were the deep pool alone, to the wei. MR-R1d pins that cost: never more than the price gap. - **MR-R4.** A pool whose depth weight floors to the minimum (1 of 10,000 against the deepest) is kept as a dust leg when registered first and cut when registered second. Both plans are sound; they differ by what one weight unit earns in one pool versus the other, observed at $3 \times 10^{-7}$ of the output inside the ±4 % domain. The bound is that weight unit plus the split's floors, and it is written where it was found. ### §15.8 N-version: the same source under other code generation The suite executes one binary, the one the default profile emits, and `profile_parity.py` keeps that profile identical to the release profile (F:146). Every other optimiser setting is a different program compiled from the same source, and the compiler is a component. `test/nversion/` compiles the Core's quote maths, the Math library's band selection and the Router under three more profiles: `nver1` (`optimizer_runs` 1), `nver2` (`optimizer_runs` 20,000, under solc's built-in Yul step sequence, without which it runs out of stack there) and `nver3` (solc's built-in Yul step sequence, with the function specialiser that the release profile drops), everything else equal to the release settings. `NVersionCore.t.sol` deploys the shipped binary beside the alternates and asserts equality on fuzzed inputs: `outV2`, `outV3`, `outSolidly`, `outSolidlyStable`, `mulDiv` and `mulDivUp` value by value, and the band selection byte for byte, the whole return or the whole revert. In CI each fuzzed comparison runs 2,000 inputs (`ci.yml`, the N-version lane). ![FIG-15.8 — The N-version lane](https://blazephoenix.xyz/whitepaper/figs/v2.4/fig-15.8.svg) *FIG-15.8 — The N-version lane: one source, four binaries (shipped, nver1, nver2, nver3), the same fuzzed input into each, and one assertion, equality.* The lane cannot pass by comparing a program with itself. Its first test asserts that each alternate differs from the shipped build (modulo the 20 bytes of the linked library address, so a profile that changed nothing is not called "different"), and a missing artefact skips the test unless `NVERSION_LANE=1` turns the skip into a failure. In the default run of §15.1 (at 969bcc6) the lane's five fuzz tests were skipped (F:142: five skipped fuzz tests with zero runs); it runs in its own job, after the alternates are built. ### §15.9 Projection distance Every defect confirmed in this repository, internal or reported, has one shape: a check observes one object while a *different* object decides the behaviour. That makes the interesting property of a refusal not its complexity but its distance, how far what it reads sits from what decides. `projection_distance.py` classifies the predicate guarding every `revert` in the contracts: a constant, an immutable, a balance delta or a quantity computed in-frame from one is distance 0; a field of the caller's route, or a lookup in another contract's mutable storage, is distance 1; a property of a contract that can delegate its behaviour is unbounded. Run on 969bcc6, the screen reads 134 refusal sites: 112 at distance 0, 18 at distance 1 and 4 unbounded (an adapter's, a hook's, a factory's and the maths library's code hash). The 2.3 counted 99, 86, 11 and 2 on the tree of 2026-09-05. A run of the script on `origin/main` at `969bcc6` (this run) lists four sites as unbounded, all of them `codehash` comparisons: the Hub's hook pin (`Hub:559`), the Hub's factory pin after renunciation (`Hub:887`), the Gate's adapter pin (`Gate:177`) and the Solver's check of its linked Math library against its own runtime code (`Solver:202`). The last two are screen hits rather than open residuals: the Solver compares against code compiled into itself, and the Gate pins an adapter behind an immutable wrapper (§14.4). The two that matter are the hook pin and the factory pin, and they are not symmetric: for hooks the residual is closed by the address bits the pin does not carry (§14.2); for factories there is no equivalent, and the residual is bounded by pool admission, the per-leg floor and the user's minimum, so the damage is route degradation rather than drainage, documented at the site. The screen's limit: it reads one predicate and cannot see that a value was constrained three frames up; a caller-declared field that is also the pool selector is at distance 0 only because one assignment binds them, and that assignment is pinned by `test/V4SievedHookIsTheExecutedHook.t.sol`. ### §15.10 Evidence independence, the shared-quantity register, and the artefact For each load-bearing guard the apparatus records how many *independent* confirmations exist, by source, oracle, tool, environment and methodology, and reports the minimum, because a chain of evidence fails at its weakest link; load-bearing properties are confirmed by at least two routes that share no hypothesis. The register of shared quantities (`SHARED_QUANTITIES.md`, §2.5) enumerates every quantity with more than one producer or consumer, states the *question* it answers, and grades what binds the copies, from `SINGLE` (one producer, nothing to disagree) to `PINNED` (a named test ties the copies), with a CI rule that demotes a row whose test does not reach what it claims to pin. At `969bcc6` the DEX register has 131 rows in five sections and the staking register (`9958d5f`) 37 rows in three (F:101, F:112). Every two-producer quantity in the relational register is tied by a named test: 11 of 11 (`docs/assurance/relational.json`). | Register | Rows | Sections | Source | |---|---|---|---| | DEX | 131 | Floors and fees; Registry state; Identity and keys; Transient state; Measurement harness | `SHARED_QUANTITIES.md` @969bcc6 (F:101) | | Staking | 37 | Rates and utilisation; Curves; Accounting and identity; Reward and interest projection; Time boundaries | `SHARED_QUANTITIES.md` @9958d5f (F:112) | And the compiled artefact is read, not only the source (`bytecode_invariants.py`): opcodes that must never appear in the contracts (`SELFDESTRUCT`, `CALLCODE`, `ORIGIN`); `DELEGATECALL`, `SSTORE` and `TSTORE` counted rather than forbidden, so that a second delegation, an extra write or a persistent slot where a transient one was meant is visible as an event; and the transient opcodes still present in the executor, so the reentrancy lock has not quietly become persistent storage. For one recorded honest V2 swap replayed on the release artefacts at 969bcc6, 4,948 Router instructions, 426 Hub instructions and 1,078 Core instructions ran with zero opcode mismatches: 32.1 %, 2.7 % and 7.3 % of the three code sections. The bytecode invariants hold on all 15 artefacts the check reads, every declared function among them: the sixteen of §16.3 less `BlazePhoenixGateWrapper`, which shares its source file with the Gate and which the check's filter skips. The 88.3 % lower bound on executed instructions was measured at 84d1553 (2026-09-04, Version 2.3 measurement). What they mean: the complement of an executed fraction is code no recorded scenario ran, not dead code. ### §15.11 What none of this establishes - **No probability of correctness.** The literature on validating ultra-high dependability is explicit that testing cannot produce one; none is stated here. - **Mutation adequacy is adequacy against this register.** It is hand-curated; a saturated score is a floor. - **Threat and regime coverage are floors on what has been considered.** Classes and factors nobody has named are outside the denominator by construction. - **The distributions of §12 are over mocks.** Live Base gives reach, not a distribution. - **Detection rates are per test at a fixed fuzz budget per seed.** A test that misses at that budget may catch at a larger one. Here: the default budget, 256 runs per seed, over 20 seeds (measured 2026-09-05). - **Some lanes are not in the default run.** The N-version lane skips unless its alternates are built (§15.8), and the fork suite needs an archive RPC (146 tests on five chains: Base, Arbitrum, Optimism, Robinhood Chain and Avalanche; F:142); a green default run says nothing about either. - **This repository is V2, and V2 is not deployed at the time of writing** (§19). - **The repository's own list of limits is the boundary of every claim above.** `docs/KNOWN_ISSUES.md` records what is by design (for instance, a route the caller writes is the caller's intent: the Router measures every leg and enforces the floors and the caller's `userMinOut`, and does not refuse a consistent venue for being a worse price), what is an accepted and documented limit (for instance, `canExecute` does not detect tokens that refuse contract recipients), and what is out of scope (read-only figures that cannot change what a user signs). A finding is judged against that file first; what it says is not repeated here, and a statement in this paper never widens it. Every instrument above was calibrated before its number was printed: run first against a defect already known by another route, and corrected where it missed it. A text matcher that read documentation as behaviour because it matched inside comments is the standing example, and `projection_distance.py` now strips comments before it classifies. An instrument is worth nothing until it finds the instance already known; a verdict without a search is vacuity; and anything the compiler decides is measured, never estimated. The artefacts are in the repository: a curated mutation guard with per-mutant killing tests, a shared-quantity register, invariant-aimed mutants, a strength-3 covering array, N-version quote maths, a quote-ageing curve and fee-mutant detection rates with confidence intervals. If you know a prior public instance of any of them, we would like to know.