# The authentic callback: the Router checks a committed pool, not a derived address

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

The Router authenticates a callback by remembering who it called: before pool.swap it commits the pool, the token and the maximum payment in transient storage, and the callback must come from that pool, within that maximum, once. The check uses a committed address, not a CREATE2-derived one.

Short answer: the Router remembers who it called. Just before it calls `pool.swap`, it writes the pool, the token it will be paid in and the most it may be paid into transient storage. When a callback arrives, the caller must be that pool, the amount must not exceed that maximum, and the record is erased before any payment moves. The authentication is a committed address, not a derived one.

This is section 26.3 of the 2.4 whitepaper. The Router does not recompute the pool address with CREATE2 at this point, and the difference matters for what the guard can and cannot be fooled by.

## What happens inside one leg

A V3-shaped venue (V3, Algebra, and a Gate wrapper, which speaks the same swap and callback ABI) asks to be paid from inside its own `swap`. The Router answers in a `fallback()` that accepts any selector, as long as the calldata holds at least 4 + 64 bytes, and hands the two words to the callback handler.

## What bounds a fake pool

An impostor that calls the Router while a swap is in flight is not the committed pool, so it reverts at the sender check. A real pool that lies about what it is owed is stopped by the committed maximum: a callback can never take more than this leg's input. A pool that calls back twice meets an erased record.

Behind those sit two measurements. The Router checks that the pool received what the callback paid, and refuses a fee-on-transfer input with `RouterE(13)`. And the per-leg floor requires the leg to deliver at least 80 % of its bound whenever it has one, or the whole swap reverts with `RouterE(5)`.

## Where CREATE2 does belong

The derivation lives where a pool is discovered and attested, in the Hub and the Core, and the Router never calls it. The mechanism is CREATE2: a contract's address is a pure function of its deployer, a salt and the hash of its init code. The preimage is 1 + 20 + 32 + 32 = 85 bytes, and the pool is the last twenty bytes of the keccak256 of it. The Core spells that out exactly once, in `create2Address`, so the live derivation and the attested one cannot drift apart.

The Hub also holds the invariant that no address without runtime bytecode enters a route. The split of duties is deliberate: discovery asks which address a pool should have, and execution asks which pool it just called.

## The guard has tests that can fail

Three tests keep it honest. `CallbackAuthImpostorDrain` has a swap in flight while a different contract asks to be paid, and the assertion is the impostor's balance. `V3ContextDiesWithTheSwap` checks that the context is cleared when a pool returns without calling back. `FallbackCalldataLengthGate` covers the minimum calldata length. For the first two, their headers state the mutant each one kills: deleting the sender check, and deleting the clear after the swap.

**Verify it yourself:** grep -n 'create2Address\|deriveAddress' src/BlazePhoenixRouter.sol   # prints nothing at commit 969bcc6, in a checkout of the V2 repository. The three tests are test/CallbackAuthImpostorDrain.t.sol, test/V3ContextDiesWithTheSwap.t.sol and test/FallbackCalldataLengthGate.t.sol. For the discovery side, recompute a pool address with cast keccak over 0xff, the origin, the salt and the init code hash, and keep the last 20 bytes. Reading: sections 26.3 and 7.1 of the 2.4 whitepaper.

Related: https://blazephoenix.xyz/learn/one-callback-doctrine/ · https://blazephoenix.xyz/learn/create2-discovery/ · https://blazephoenix.xyz/learn/verifying-beats-solving/
