# Specification-to-Code Compliance Report: Dices launchpad (EVM)

| Field | Value |
| --- | --- |
| Skill | `spec-to-code-compliance` 1.1.0 (Trail of Bits), phases 0 to 6 |
| Repository / commit | `dices-launchpad-evm`, `bcd45b2` on `main` |
| Date | 2026-11-25 |
| Spec corpus | `AGENT.md` (325 lines, sections 1 to 6), `README.md` (162 lines), NatSpec in `src/**` and in `script/deployment/V001.s.sol` |
| Code scope | `src/DicesHook.sol`, `src/DicesCoin.sol`, `src/core/{InternalSwapPool,FeeEscrow,TrustedRouters}.sol`, `src/calculators/{LiveCalculator,FeeCalculator}.sol`, `src/libraries/{CurrencySettler,UniswapEvents}.sol`, `src/interfaces/*`, `script/deployment/V001.s.sol`; `lib/` only to resolve inherited or imported behaviour |
| Method limits | Static reading only. Nothing was compiled, tested or executed against the repo (no `forge`, no `slither`). Numeric constants were re-derived with a standalone Python worksheet that ports `TickMath.getSqrtPriceAtTick`, `LiquidityAmounts` and `SqrtPriceMath` from `lib/` (Appendix D). Gas figures and test outcomes are recorded as "stated, not verified". |

Conventions used below: `A` = `AGENT.md`, `R` = `README.md`, `N` = NatSpec. Code is cited as `file:Lnn`. Paths are relative to the repository root. Every Spec-IR item (Appendix A) has exactly one row in the alignment matrix (section 5); every `mismatch`, `missing_in_code` and `code_weaker_than_spec` row names the divergence finding (section 6) that covers it.

---

## 1. Executive Summary

**Result.** The corpus describes two different systems. The parts written or revised for the game-level work (launch step 5, qualifying holders, Live and game levels, bankroll, deployment) match the code closely, and every numeric constant in them was reproduced by arithmetic. The parts that describe fees, ledgers, configuration, events and the lock mechanism describe an earlier design (USDC-only fees, ERC-6909 claims, reserve and race ledgers, `PoolConfig` snapshot). Commit `f64bd24` ("Rework launchpad core: swap pool, fee escrow, CreateX deployment") added `InternalSwapPool`, `FeeEscrow` and `TrustedRouters`, rewrote the hook and changed 11 lines of `AGENT.md`; the documents were not brought along. `README.md`, which carries no staleness note, still asserts the old fee and ledger behaviour.

**Counts.** 209 Spec-IR items; alignment by `match_type`:

| match_type | Count |
| --- | --- |
| `full_match` | 127 |
| `partial_match` | 7 |
| `mismatch` | 41 |
| `missing_in_code` | 23 |
| `code_stronger_than_spec` | 2 |
| `code_weaker_than_spec` | 9 |

By source, `full_match` covers 81 of 142 `AGENT.md` items, 7 of 16 `README.md` items and 39 of 51 NatSpec items. 17 divergence findings: 0 CRITICAL, 1 HIGH, 5 MEDIUM, 11 LOW. The 73 rows that are `mismatch`, `missing_in_code` or `code_weaker_than_spec` all map to one of the 17 findings; most are the same stale design counted once per sentence that states it.

**HIGH**

- **DIV-01. The buy surcharge to the reserve (0.50%, then 0.25% to the race pool), the per-coin `reserve` / `racePool` ledgers and the `reserveController` do not exist.** `A` section 2 "Trading fees" and `R` bullet 2 state them; `FeeCalculator.sol:L33-L38,L72-L74` has one rate per Live state for buys and sells alike and `DicesHook.sol:L471-L483` routes fees only to platform, creator and a buy-and-burn recipient. This is a missing required output, not an exploit.

**MEDIUM**

- **DIV-02. Fee split.** Spec: "split between the platform and the creator" (placeholder 50/50). Code: 40% platform, 30% creator, 30% to an owner-set `buyAndBurnRecipient` that `AGENT.md` never mentions and `README.md` names only in its deploy section (`FeeCalculator.sol:L23-L28,L85-L94`).
- **DIV-03. No per-pool snapshot and no caps.** Spec: "changing defaults can never alter a coin that already launched" and "enforced on-chain with caps". Code: fee rate and split are read from the owner-replaceable calculator on every swap with no bound (`DicesHook.sol:L462,L478,L752-L754,L819-L825`); `createFee` is unbounded (`L783-L786`); the level returned by a replacement Live calculator is stored without an upper bound (`L436-L439`).
- **DIV-04. Replacing the fee calculator only half applies.** `InternalSwapPool.feeCalculator` is `immutable` (`InternalSwapPool.sol:L75,L113,L265`) and the hook's pool reference has no setter, so converted coin-fee proceeds keep the constructor-time split after `setFeeCalculator`.
- **DIV-05. No sealed game commitment.** `CoinParams` is `{name, symbol, creator}` (`IDicesHook.sol:L24-L37`); nothing is registered or stored for the game at launch.
- **DIV-06. Launch-block guard.** NatSpec says "Prevents 0-block buys" and the comment beside the check adds "unless token creator"; the check is `!trustedRouters[sender]` on the router (`DicesHook.sol:L334`), there is no creator exception, and the deployment trusts the Universal Router (`V001.s.sol:L238`), so any account can buy in the launch block through it.

**Security guarantees stated in stale text, classified by what the code does**

| Stated guarantee | Holds? | What the code does |
| --- | --- | --- |
| "`beforeRemoveLiquidity` rejects everyone" (`A` 3 Launch) | Statement false, lock holds | `DicesHook.sol:L303` lets `internalSwapPool` through. The PoolManager keys positions by caller (`Pool.sol:L187`, `Position.sol` `calculatePositionKey(owner, ...)`), so the swap pool can remove only positions it owns, and its code removes exactly the JIT position it added in the same swap. DIV-07, LOW. |
| "the hook has no code path with a negative liquidity delta" | Holds | The only `modifyLiquidity` call in the hook is `DicesHook.sol:L715` with `int(uint(liquidity))`. |
| "the swap that triggers Live ... pays the pre-swap rate" | Holds, by a different mechanism | No transient storage; `_swapFee` (`L375`) and `_collectSwapFee` (`L377`) run before `_syncLevel` (`L382`). |
| "Invariant: hook's USDC ERC-6909 balance == sum of all claimable fees + all reserves + all race pools" | Does not exist | The hook holds no ERC-6909 claims. What holds instead: `FeeEscrow` balance of a currency is at least the sum of `claimable` in it (`FeeEscrow.sol:L60-L71,L104-L117`), and the hook passes on exactly `fee.amount` per swap when the default calculator is used (`FeeCalculator.sol:L93`). DIV-09, LOW. |
| "changing defaults can never alter a coin that already launched" (`A` 4) | Does not hold | DIV-03, MEDIUM. |

**The 2026-11-05 staleness note.** It is accurate about the four subsections it names and incomplete about the rest. Also stale and not named: section 3 "Principle", the section 2 component table (Locker, FeeVault, GameReserve, Parameter registry rows), Launch steps 1, 4 and 6 and the lock guarantees, "Indexer events" (`PoolSwap`, removal variant, `_launch`), four section 4 decisions, and `README.md` bullet 2. Of the three sections it calls current: launch step 5 matches in full; "Qualifying holders" matches except for the wording of the same-block rule (DIV-12); "Live and game levels" matches except that the 24 hours run from a pool's first observation, which `syncLevel` can create before any trade (DIV-11), and that the fail-safe is narrower than stated (DIV-13).

---

## 2. Documentation Sources Identified

| # | Source | Content used | Notes |
| --- | --- | --- | --- |
| 1 | `AGENT.md` section 1 | How to read the brief; engagement scope | Sets the rule applied here: section 2 is checked for outputs and numbers, sections 3 to 6 for stated architecture |
| 2 | `AGENT.md` section 2 | Client requirements restated: product, game levels (6 and 9 November updates), trading fees, casino economics, governance, component table | The original brief is not in the repository, so "Numbers are verbatim from the brief" cannot be checked |
| 3 | `AGENT.md` section 3 | Architecture: principle, contracts, launch, bankroll, fees, ledgers, qualifying holders, indexer events, Live and game levels, configuration, hook flags, deployment | Carries the 2026-11-05 note (SPEC-047) |
| 4 | `AGENT.md` sections 4 to 6 | Design decisions, open questions, working conventions | Open questions are treated as ambiguity hotspots; their factual assertions are extracted |
| 5 | `README.md` | Behaviour summary (5 bullets), deployment paragraph, build, test, deploy, generate-activity sections | Last changed in `bbbeb4c` (2026-11-25); no staleness note |
| 6 | NatSpec in `src/interfaces/*.sol` | ABI-level promises | Treated as spec; bodies treated as code |
| 7 | Contract and function NatSpec in `src/*.sol`, `src/core`, `src/calculators`, `src/libraries` | Behavioural promises and invariants | Often contradicts sources 3 and 5 and agrees with the code |
| 8 | NatSpec header of `script/deployment/V001.s.sol` | Deployment rules | Only for deployment and hook-flag claims |

Not found: whitepaper, design PDFs, diagrams. `deployments/deployment-84532.md` is an address book, not a specification. Other files under `audits/` were not used as specification.

Inconsistencies between spec documents are listed in section 13.

---

## 3. Spec Intent Breakdown (Spec-IR)

The full Spec-IR is Appendix A (209 records, YAML). Breakdown:

| Source | IDs | Count |
| --- | --- | --- |
| `A` section 1 (reading rule, scope) | SPEC-001 to 002 | 2 |
| `A` section 2 (product, levels, fees, governance, components) | SPEC-003 to 030 | 28 |
| `A` section 3 Principle and Contracts | SPEC-031 to 047 | 17 |
| `A` section 3 Launch and Bankroll | SPEC-048 to 067 | 20 |
| `A` section 3 Fees and Ledgers | SPEC-068 to 079 | 12 |
| `A` section 3 Qualifying holders and Indexer events | SPEC-080 to 091 | 12 |
| `A` section 3 Live and game levels | SPEC-092 to 111 | 20 |
| `A` section 3 Configuration, Hook address flags, Deployment | SPEC-112 to 119 | 8 |
| `A` sections 4 to 6 | SPEC-120 to 142 | 23 |
| `R` | SPEC-143 to 158 | 16 |
| `N` (src and V001) | SPEC-159 to 209 | 51 |

By semantic type: 51 invariants or security requirements (23 + 28), 37 formulas or constants (24 + 13), 36 flows or state transitions (31 + 5), 16 access-control rules, 23 event or ABI items (11 + 12), 26 structural claims, 8 conventions, 5 deferred items, 4 economic assumptions, 3 meta or scope items.

Quality thresholds of the skill: more than 10 items (209), more than 3 invariants (for example SPEC-063, 079, 093, 100), more than 2 security requirements (for example SPEC-058, 061, 062, 086, 137 to 139), more than 1 formula (SPEC-055 to 059, 094 to 096).

---

## 4. Code Behavior Summary (Code-IR)

The full Code-IR is Appendix B (61 YAML records covering every function in scope). Summary of what the code does, independent of the documents:

**Launch (`DicesHook.createCoin`, `L533-L578`; `unlockCallback`, `L587-L618`).** Requires `msg.value == createFee` (or zero when no fee) and credits it to `feeRecipient` in the escrow as native currency. Clones `coinImplementation` deterministically with salt `keccak256(chainid, coinCount++)`, initialises it with 1e27 units minted to the hook, transfers 1e26 to `DicesCoin(coin).bankroll()`, stores `poolKeys`, `poolCoins`, `poolCreators` (no validation of `params.creator`), then inside `unlock`: initialises the pool at `feeCalculator.getInitialSqrtPriceX96`, records `launchBlock`, emits `PoolCreated`, adds two positions (7e26 and 2e26 units, ranges in section 9), emits `PoolStateUpdated`, settles the coin debit. Liquidity-rounding dust stays in the hook with no way out.

**Swap path (`_beforeSwap`, `L325-L358`; `_afterSwap`, `L372-L386`).** Before: revert `CannotBuyZeroBlock` if the pool was launched in this block and the router is not in `trustedRouters`; write `lastSwapBlock`; ask the swap pool to add a single-tick-spacing JIT position of queued coin fees when the swap is a buy. Returns no delta. After: the swap pool removes its JIT position, settles the coin it sold, takes the USDC it earned and credits it to platform, creator and buy-and-burn recipient through the escrow; the hook computes `fee = |unspecified delta| * rate / 100_000` with rate 1,250 (not Live) or 1,000 (Live), takes that amount of the **unspecified** currency from the PoolManager, and either forwards it to the swap pool (coin) or splits it 40/30/30 into escrow credits (USDC); then calls `_syncLevel`, emits `HookFee` (if non-zero), `HookSwap`, `PoolStateUpdated`.

**Levels (`_syncLevel`, `L433-L449`; `LiveCalculator`).** `try liveCalculator.qualify(key)`; a higher result overwrites `poolLevel` and emits `PoolLive` (when leaving 0) and `PoolLevelUnlocked`. `qualify` (hook only) reads `slot0`, converts to a coin tick, extends a per-pool cumulative `tick x seconds`, writes hourly checkpoints, computes the floor average over a window that opens 24 whole hours before the current hour, maps the average to a level through ten fixed ticks and lowers it by ten fixed holder floors read from `DicesCoin.qualifiedHolders()`. `syncLevel(coin)` lets anyone trigger the same call.

**Holder count (`DicesCoin._afterTokenTransfer`, `L195-L224`).** Counts addresses crossing 300,000e18 in either direction, excluding zero, hook, PoolManager, swap pool and bankroll; `qualifiedHolders()` returns the lower of the current count and the count before the block's first change.

**Fee custody (`FeeEscrow`).** Permissionless, fully funded credits per `(beneficiary, currency)`; anyone can trigger payment to the beneficiary. No owner.

**Authorization graph.**

| Actor | Can do | Evidence |
| --- | --- | --- |
| Hook owner (`Ownable`, single step) | `setFeeCalculator`, `setLiveCalculator`, `setBuyAndBurnRecipient`, `setCreateFee`, `setFeeRecipient`, `setCoinImplementation`, `setTrustedRouter`, `pause`, `unpause`, `transferOwnership`, `renounceOwnership` | `DicesHook.sol:L752-L852`, `TrustedRouters.sol:L25` |
| PoolManager | Hook callbacks, `unlockCallback` | `BaseHook` `onlyPoolManager`; `DicesHook.sol:L587` |
| Hook | `InternalSwapPool.deposit/createInternalSwapPool/closeInternalSwapPool`, `LiveCalculator.qualify` | `InternalSwapPool.sol:L352-L358`, `LiveCalculator.sol:L406-L412` |
| InternalSwapPool | Add and remove its own liquidity in hook pools | `DicesHook.sol:L291,L303` |
| Trusted router | Swap in a pool's launch block | `DicesHook.sol:L334` |
| Anyone | `createCoin` (unless paused), `syncLevel`, swaps after the launch block, `FeeEscrow.deposit/claim/claimBatch`, `DicesCoin.burn` of own balance, `initialize` on an uninitialised coin | as cited in Appendix B |

No upgradeability. Storage: `DicesHook` state variables at `L110-L185`; `LiveCalculator.oracles` (one slot per pool) and `_checkpoints` (`int56[25]`, seven slots); `DicesCoin` packs `_initialized`, `_holdersChangedAt`, `_holders`, `_holdersBefore` into one slot (136 bits).

---
## 5. Full Alignment Matrix (Spec to Code to Status)

This table is the Alignment-IR in compact form: one record per Spec-IR item with `spec_ref`, `code_ref`, `match_type`, `confidence` and a one-line reasoning. Spec quotes are in Appendix A under the same ID; expanded records with reasoning traces and quotes from both sides are in Appendix C for every row that is not `full_match` and for every numerically verified row. `H` = `src/DicesHook.sol`, `C` = `src/DicesCoin.sol`, `ISP` = `src/core/InternalSwapPool.sol`, `ESC` = `src/core/FeeEscrow.sol`, `TR` = `src/core/TrustedRouters.sol`, `LC` = `src/calculators/LiveCalculator.sol`, `FC` = `src/calculators/FeeCalculator.sol`, `UE` = `src/libraries/UniswapEvents.sol`, `IH` = `src/interfaces/IDicesHook.sol`, `V` = `script/deployment/V001.s.sol`.

### 5.1 `AGENT.md` sections 1 and 2

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-001 | Brief is required outputs, not structure | Applied as the reading rule; no code counterpart | full_match | 0.70 | Methodological item |
| SPEC-002 | Scope: coin creation, locked liquidity, fees, Live trigger, ledgers; casino parts deferred | `H:L533-L578`, `H:L433-L449`, `ESC`; no casino contracts in `src/` | partial_match | 0.75 | "ledgers" exist only as escrow credits; reserve ledgers absent (DIV-01) |
| SPEC-003 | One transaction creates the coin, two locked v4 positions, hook attached | `H:L533-L578`, `H:L587-L618`, `H:L633-L655` | full_match | 0.95 | |
| SPEC-004 | Same transaction registers a sealed casino game | `IH:L24-L37`; grep `gameCommitment` in `src/`: 0 hits | missing_in_code | 0.95 | DIV-05 |
| SPEC-005 | Every buy adds liquidity (USDC flows into the pool) | `ISP:L155-L212`, `ISP:L260-L277` | partial_match | 0.80 | The share of a buy filled by the JIT position goes to fee recipients, not the pool; see DIV-08 |
| SPEC-006 | Every buy funds the coin's casino reserve | `H:L471-L483`; grep `reserve` identifiers: 0 hits | missing_in_code | 0.97 | DIV-01 |
| SPEC-007 | Original trigger ($35k raised and 150 wallets bought) is superseded by game levels | No raised or wallet tracking in `src/`; `H:L395-L397` | full_match | 0.90 | Code implements the superseding rule |
| SPEC-008 | On Live the pool switches state automatically and trading fees reduce | `H:L438-L446`, `FC:L72-L74` | full_match | 0.95 | |
| SPEC-009 | On Live the game is revealed and wagering opens | None | missing_in_code | 0.90 | DIV-16 (deferred by SPEC-002) |
| SPEC-010 | Players bet in USDC or the coin; reserve is the bankroll | None | missing_in_code | 0.90 | DIV-16 (deferred) |
| SPEC-011 | Game unlocks when 24-hour average market cap reaches target and holders reach floor | `LC:L309-L338`, `LC:L353-L376` | full_match | 0.93 | |
| SPEC-012 | Game 1 is Live; once unlocked a game stays unlocked | `H:L395-L397`, `H:L437-L439` | full_match | 0.95 | |
| SPEC-013 | Market cap targets $200K to $102M | `LC:L219-L242` | full_match | 0.97 | Ten ticks re-derived, section 9.1 |
| SPEC-014 | Holder floors 150 to 5,800 | `LC:L251-L253` | full_match | 0.99 | |
| SPEC-015 | Pre-Live base fee 1.25% on buys and sells | `FC:L33`, `FC:L72-L74`, `H:L462` | full_match | 0.95 | Rate matches; currency differs (DIV-08) |
| SPEC-016 | Post-Live base fee 1.00% | `FC:L38`, `FC:L72-L74` | full_match | 0.95 | |
| SPEC-017 | Buys pay a further 0.50% to the coin's reserve | `FC:L72-L74` (no direction input), `H:L458-L463` | missing_in_code | 0.97 | DIV-01 |
| SPEC-018 | After the reserve target: buys pay base + 0.25% to the race pool | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-019 | Base fee split between platform and creator | `FC:L23-L28`, `FC:L85-L94`, `H:L478-L481` | mismatch | 0.92 | DIV-02 |
| SPEC-020 | Casino profit distribution 40/30/15/15, rakeback | None | missing_in_code | 0.90 | DIV-16 (deferred) |
| SPEC-021 | Treasury is a Safe with a 48-hour timelock | `H:L199` (`Ownable(_owner)`), `V:L131`, `V:L306` | missing_in_code | 0.85 | DIV-16 (deferred) |
| SPEC-022 | Critical financial operations enforced on-chain with caps | `H:L462`, `H:L783-L786`, `H:L819-L825` | missing_in_code | 0.85 | DIV-03 |
| SPEC-023 | Factory is `DicesHook.createCoin`; Hook is `DicesHook` | `H:L533` | full_match | 0.98 | |
| SPEC-024 | Locker: hook owns positions, no removal path, `beforeRemoveLiquidity` always reverts | `H:L302-L307` | mismatch | 0.95 | DIV-07; first two clauses hold |
| SPEC-025 | FeeVault: hook claimable-fee ledger as ERC-6909 USDC claims | `H:L473`, `H:L731-L741`, `ESC:L25` | mismatch | 0.97 | DIV-09 |
| SPEC-026 | Hook keeps per-coin `reserve` and `racePool` ledgers with controller-gated withdraw/deposit | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-027 | GameVault, RewardsDistributor, ConversionExecutor, BridgeReceiver, Forwarder deferred | Absent from `src/` | full_match | 0.95 | |
| SPEC-028 | Any router implementing `IMsgSender` works today | `H:L334-L336`, `TR:L37-L52` | code_stronger_than_spec | 0.85 | Code adds a launch-block allowlist (DIV-06, UCP-04) |
| SPEC-029 | Treasury deferred; Safe + TimelockController as `feeRecipient` and owner | `V:L306`, `V:L323` | missing_in_code | 0.85 | DIV-16 (deferred) |
| SPEC-030 | Parameter registry: launch defaults snapshotted per pool as `PoolConfig` | grep `PoolConfig`: 0 hits; constants at `H:L71-L105` | missing_in_code | 0.97 | DIV-03 |

### 5.2 `AGENT.md` section 3: Principle, Contracts, Launch, Bankroll

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-031 | The hook is the only liquidity provider | `H:L291`, `ISP:L207` | mismatch | 0.97 | DIV-07 |
| SPEC-032 | Charges every fee as a USDC hook delta | `H:L458-L463`, `H:L474-L476` | mismatch | 0.97 | DIV-08 |
| SPEC-033 | The LP fee is zero | `H:L564`, `H:L357` | full_match | 0.97 | |
| SPEC-034 | Tracks each pool's game level | `H:L175` | full_match | 0.99 | |
| SPEC-035 | Holds fee proceeds as ERC-6909 claims until claimed | `H:L473` (`take` of ERC-20), `ESC:L34-L73` | mismatch | 0.97 | DIV-09 |
| SPEC-036 | Contracts table lists seven files | `src/core/*`, `src/libraries/CurrencySettler.sol`, six further interfaces exist | mismatch | 0.95 | DIV-15 |
| SPEC-037 | `DicesHook` role includes raised/wallet tracking, ledgers, claims | None of these in `H` | mismatch | 0.95 | DIV-15 |
| SPEC-038 | `DicesCoin`: fixed supply, solady, minimal clone, `initialize` once, `burn`, holder count | `C:L18`, `C:L123-L138`, `C:L182-L184`, `H:L551` | full_match | 0.93 | `burn` is callable now, see AMB-03 |
| SPEC-039 | `FeeCalculator`: rate schedule and USDC split into platform / creator / reserve / race | `FC:L85-L94` | mismatch | 0.97 | DIV-02 |
| SPEC-040 | `LiveCalculator`: ten ticks, ten floors, price history, 24-hour average | `LC:L219-L253`, `LC:L114-L120`, `LC:L309-L338` | full_match | 0.97 | |
| SPEC-041 | `UniswapEvents`: `PoolCreated`, `PoolSwap`, `PoolStateUpdated` emitted by the hook | `UE:L43` declared; no `emit PoolSwap` anywhere | mismatch | 0.97 | DIV-10 |
| SPEC-042 | Calculators are owner-replaceable | `H:L752-L763`; `ISP:L75,L113,L265` | code_weaker_than_spec | 0.92 | DIV-04 |
| SPEC-043 | The fee calculator holds no state | `FC:L14-L106` (constants only) | full_match | 0.99 | |
| SPEC-044 | Live calculator stores history and answers only to its hook | `LC:L114-L120`, `LC:L406-L412` | full_match | 0.97 | |
| SPEC-045 | Replacing the Live calculator restarts history, never lowers a level | `H:L175`, `H:L438`, `H:L832-L838` | full_match | 0.95 | |
| SPEC-046 | Always deploy a fresh calculator built for this hook; one built for another address reverts on every call | `H:L832-L838` (only `code.length`), `LC:L407` | code_weaker_than_spec | 0.85 | DIV-13; the revert clause holds |
| SPEC-047 | Note: Contracts, Fees, Ledgers, Configuration stale; Launch step 5, Qualifying holders, Live and game levels current | Sections 5.3 to 5.5 of this report | partial_match | 0.85 | Under-reports stale text; three small deviations in "current" sections (DIV-11, 12, 13) |
| SPEC-048 | `createCoin(CoinParams{name, symbol, creator, gameCommitment})` | `IH:L24-L37`, `H:L533` | mismatch | 0.97 | DIV-05 |
| SPEC-049 | Step 1: validate the creator split | `H:L533-L578` has no creator validation | missing_in_code | 0.93 | DIV-14 |
| SPEC-050 | Step 1: collect the optional ETH creation fee | `H:L535-L547` | full_match | 0.97 | |
| SPEC-051 | Step 2: clone, mint supply to hook, pay 10% (100M) to bankroll | `H:L551-L558`, `H:L71,L86` | full_match | 0.98 | |
| SPEC-052 | Step 3: key with fee 0, tick spacing 60, this hook; either ordering | `H:L561-L564`, `H:L105` | full_match | 0.99 | |
| SPEC-053 | Step 4: snapshot launch defaults into `PoolConfig` | None | missing_in_code | 0.97 | DIV-03 |
| SPEC-054 | Step 4: store creator config and `gameCommitment` | `H:L574` stores creator only | missing_in_code | 0.95 | DIV-05 |
| SPEC-055 | Step 5: initialise at the $12.5k FDV price inside `unlock` | `H:L595-L598`, `FC:L47-L63` | full_match | 0.97 | sqrt prices re-derived, section 9.1 |
| SPEC-056 | Step 5: two coin-only positions, 70% launch tick to $200k, 20% to the usable limit | `H:L633-L655`, `H:L76,L81,L95` | full_match | 0.95 | Dust below 1.3e14 wei stays in the hook |
| SPEC-057 | Step 5: ranges mirrored for currency1 | `H:L647-L654`, `H:L680-L683` | full_match | 0.95 | |
| SPEC-058 | Step 5: upper position reaches the usable limit | `H:L646`, `H:L653` | full_match | 0.98 | |
| SPEC-059 | Step 5: selling out the first position raises about $35,013 | `H:L645`, `H:L652` | full_match | 0.95 | $35,013.49 in both orderings, section 9.1 |
| SPEC-060 | Step 6: emit `CoinCreated` with the config snapshot | grep `CoinCreated`: 0 hits | missing_in_code | 0.97 | DIV-10 |
| SPEC-061 | `beforeAddLiquidity` rejects any sender but the hook | `H:L291` | mismatch | 0.97 | DIV-07 |
| SPEC-062 | `beforeRemoveLiquidity` rejects everyone | `H:L303` | mismatch | 0.97 | DIV-07 |
| SPEC-063 | Hook has no code path with a negative liquidity delta | `H:L715` (only `modifyLiquidity` call) | full_match | 0.95 | |
| SPEC-064 | 10% to `DicesCoin.bankroll()`, an immutable set from V001; hook reads it from the coin | `C:L60,L112`, `H:L558`, `V:L227` | full_match | 0.98 | |
| SPEC-065 | New bankroll needs a new implementation and `setCoinImplementation` | `H:L806-L812`, `C:L56-L58` | full_match | 0.95 | |
| SPEC-066 | 100M sold at $200k returns about $13.8k, cap to about $98k; test pins the empty pool | `test/DicesHookLaunchCurve.t.sol:L75` (not run) | full_match | 0.85 | $13,827 net and $98,031 by arithmetic |
| SPEC-067 | Nothing on chain restricts the bankroll | `C` has no transfer restriction | full_match | 0.97 | |

### 5.3 `AGENT.md` section 3: Fees, Ledgers, Qualifying holders, Indexer events

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-068 | Buy, exact-in USDC: fee in USDC through `beforeSwap` specified delta | `H:L357` (zero delta), `H:L460` | mismatch | 0.97 | DIV-08; fee is taken in the coin |
| SPEC-069 | Buy, exact-out coin: `afterSwap` unspecified delta on the USDC owed | `H:L460-L462`, `H:L472-L473` | full_match | 0.93 | |
| SPEC-070 | Sell, exact-in coin: `afterSwap` unspecified delta on the USDC received | `H:L460-L462` | full_match | 0.93 | |
| SPEC-071 | Sell, exact-out USDC: `beforeSwap` grossed-up specified delta | `H:L357`, `H:L460` | mismatch | 0.97 | DIV-08; fee is taken in the coin |
| SPEC-072 | The fee is always rate x gross USDC moved | `H:L460-L462` | mismatch | 0.97 | DIV-08 |
| SPEC-073 | Rates cached in transient storage in `beforeSwap` | grep `tstore`, `tload`, `transient`: 0 hits | mismatch | 0.97 | DIV-08 |
| SPEC-074 | The swap that triggers Live pays the pre-swap rate | `H:L375-L382` | full_match | 0.93 | Guarantee holds by statement order |
| SPEC-075 | Partial fill with USDC specified reverts `PartialFillWithSpecifiedCurrency` | grep: 0 hits | missing_in_code | 0.97 | DIV-08; not needed under the implemented design |
| SPEC-076 | Reserve capped; overshoot to race pool; `reserveTargetReached` permanent | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-077 | `claimableFees[recipient]`; `claimFees()` withdraws | `ESC:L25`, `ESC:L80-L94` | mismatch | 0.97 | DIV-09 |
| SPEC-078 | `reserve`, `racePool`, `reserveTargetReached`; only `reserveController` | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-079 | Invariant: hook's USDC ERC-6909 balance == claimable + reserves + race pools | None; see `ESC:L60-L71` | mismatch | 0.95 | DIV-09 |
| SPEC-080 | Qualifying holder: at least 300,000 coins (about $60 at $200k) | `C:L32` | full_match | 0.99 | 300,000 / 1e9 x $200,000 = $60 |
| SPEC-081 | Count maintained in `_afterTokenTransfer` on every mint, burn, transfer | `C:L195-L224`; solady `ERC20.sol:L244,L345,L519,L551,L586` | full_match | 0.95 | |
| SPEC-082 | Hook, PoolManager, InternalSwapPool, bankroll (immutables) and zero address never counted | `C:L40-L60`, `C:L247-L249` | full_match | 0.98 | |
| SPEC-083 | Wallets the bankroll pays count like any others | `C:L247-L249` | full_match | 0.97 | |
| SPEC-084 | `qualifiedHolders()` leaves out holders that crossed in the current block | `C:L168-L175`, `C:L215-L223` | code_weaker_than_spec | 0.90 | DIV-12; the anti-inflation property holds |
| SPEC-085 | Swapper identity is not used by the level rule | `LC:L146-L165`, `LC:L353-L376` | full_match | 0.97 | |
| SPEC-086 | Trusted routers and `IMsgSender`; never read a buyer from `hookData` | `TR:L37-L52`; `ISP:L146,L226` (unnamed, unused) | full_match | 0.93 | Resolved sender is itself unused (UCP-14) |
| SPEC-087 | `PoolCreated(poolId, coin, usdc)` once per launch, right after `initialize` | `H:L598-L604`, `UE:L67-L69` | full_match | 0.97 | |
| SPEC-088 | `PoolSwap(...)` after every swap; fee on the USDC leg only | `H:L383`, `UE:L93-L95` emit `HookSwap` | mismatch | 0.97 | DIV-10 |
| SPEC-089 | `PoolStateUpdated` after every swap and once per launch after both positions | `H:L384`, `H:L611`, `UE:L125-L128` | full_match | 0.97 | |
| SPEC-090 | Liquidity can never be removed, so no removal variant exists | `ISP:L239`; `UE:L48,L104-L106` | mismatch | 0.90 | DIV-10 |
| SPEC-091 | Emitted from `_launch` and `_afterSwap`; `noSelfCall` makes callbacks third-party guards only | `H:L587`, `H:L372`; `Hooks.sol:L171-L181` | mismatch | 0.85 | DIV-10; no `_launch`, no `afterAddLiquidity`; the `noSelfCall` part holds |

### 5.4 `AGENT.md` section 3: Live and game levels, Configuration, Flags, Deployment

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-092 | Level 0 to 10 kept in `poolLevel`; level 1 is Live | `H:L175`, `LC:L69` | full_match | 0.88 | Hook does not bound the value (DIV-13) |
| SPEC-093 | An unlocked level is never lost | `H:L438-L439` | full_match | 0.97 | |
| SPEC-094 | Market cap is a tick check; `levelTicks()` is the first tick worth the target | `LC:L219-L242`, `LC:L360-L362` | full_match | 0.97 | All ten exact, section 9.1 |
| SPEC-095 | Coin tick: pool tick when currency0, `-tick - 1` when currency1 | `LC:L159-L161`, `LC:L385-L387` | full_match | 0.97 | |
| SPEC-096 | Tick TWAP is a geometric mean; 2-second spike adds about 29 ticks (0.3%); $300k/$500k averages $387k | `LC:L309-L338` | full_match | 0.93 | 28.9 ticks; 1.0029; $387,298 |
| SPEC-097 | UI should show `averageMarketCap(poolId)` | `LC:L200-L209` | full_match | 0.95 | |
| SPEC-098 | After every swap, at every level, the hook calls `qualify` | `H:L382`, `H:L436` | full_match | 0.97 | |
| SPEC-099 | One slot per pool plus 25 hourly checkpoints | `LC:L47-L64` (144 bits), `LC:L89`, `LC:L120` | full_match | 0.97 | |
| SPEC-100 | History is exact; the hook must never swap | grep `.swap(` in `src/`: 0 hits; `Hooks.sol:L253,L293` | full_match | 0.90 | Subject to the `try` (DIV-13) |
| SPEC-101 | Window opens on the hour 24 hours before the current hour; 24 to 25 hours long | `LC:L310-L326` | full_match | 0.97 | |
| SPEC-102 | No level in a pool's first 24 hours of trading; earliest is the 25th hour after the hour of its first trade | `LC:L273-L275`, `LC:L314`, `H:L408-L417` | mismatch | 0.90 | DIV-11; code counts from the first observation |
| SPEC-103 | Holder floor applied after the average; count taken as it stands | `LC:L370-L375` | full_match | 0.97 | |
| SPEC-104 | Holders not read while the average is short of the first target | `LC:L364-L366` | full_match | 0.97 | |
| SPEC-105 | Hook records only a rise; one `PoolLevelUnlocked`, preceded by `PoolLive` when leaving 0 | `H:L436-L447` | full_match | 0.98 | |
| SPEC-106 | `poolLive` is `poolLevel != 0`; fees change at level 1 only | `H:L395-L397`, `FC:L72-L74` | full_match | 0.98 | |
| SPEC-107 | The swap that takes the pool Live still pays the pre-Live rate | `H:L375-L382` | full_match | 0.93 | |
| SPEC-108 | `syncLevel(coin)` for anyone; `qualifiedLevel(key)` is the read-only version | `H:L408-L417`, `LC:L175-L179` | full_match | 0.95 | |
| SPEC-109 | Fail-safe: a reverting calculator never blocks a swap | `H:L436-L448` | code_weaker_than_spec | 0.80 | DIV-13 |
| SPEC-110 | `qualify` accepts the hook alone; `OnlyHook` otherwise; `dicesHook` immutable | `LC:L109`, `LC:L146`, `LC:L406-L412` | full_match | 0.99 | |
| SPEC-111 | Gas figures (9.3k, 13.4k, 17.6k, 25.7k, 72k, 174k, 1.2k, 6.6k) | Not executable here | partial_match | 0.30 | NOT VERIFIED; structure (7 slots, 25 checkpoints, conditional holder read) is consistent |
| SPEC-112 | `PoolConfig` owner-set as launch defaults and snapshotted | None | missing_in_code | 0.97 | DIV-03 |
| SPEC-113 | Defaults: start tick -398400 (~$5k), sale to -375360, 50% sale share, reserve $10k, min buy $25, creator 50% | `H:L71-L95`, `FC:L23-L63` | mismatch | 0.95 | DIV-15; also contradicts SPEC-055/056 |
| SPEC-114 | Flags: beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta | `H:L236-L243` | full_match | 0.99 | |
| SPEC-115 | V001 mines a CREATE3 salt; `HOOK_FLAGS` in step with the hook | `V:L120`, `V:L418-L437`, `V:L511` | full_match | 0.98 | 0x2AC4 on both sides |
| SPEC-116 | Only path; every contract through `deployCreate3`; addresses depend on signer and salt alone | `V:L213-L234`, `V:L402-L412` | full_match | 0.93 | Also on contract name and the CreateX address |
| SPEC-117 | No contract infers an owner or recipient from `msg.sender` | `H:L199,L209`; other constructors take no owner | full_match | 0.97 | |
| SPEC-118 | Script reads nothing from the environment; constants in `_getConfig()` | grep `vm.env` in `V`: 0 hits; `V:L541-L573` | full_match | 0.95 | It reads `out/DicesHook.sol/DicesHook.json` (`V:L486`) |
| SPEC-119 | A bankroll that is a launchpad contract is rejected before broadcasting | `V:L333-L336`, `V:L205-L208` | code_weaker_than_spec | 0.85 | DIV-17; calculators and the events library are not checked |

### 5.5 `AGENT.md` sections 4 to 6

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-120 | Fees in USDC; no conversion step; trader's coin leg untouched | `H:L460`, `H:L474-L476`, `ISP:L226-L279` | mismatch | 0.97 | DIV-08 |
| SPEC-121 | Hook-as-LP is the lock | `H:L715`, `H:L303` | full_match | 0.93 | |
| SPEC-122 | Net raised, not gross volume | No raised tracking | mismatch | 0.90 | DIV-15; superseded by SPEC-007 without being removed |
| SPEC-123 | `IMsgSender` + trusted routers with access control; degrades to no attribution | `TR:L25`, `TR:L39-L51` | full_match | 0.95 | |
| SPEC-124 | TWAP: one slot written per swap, seven checkpoint slots, 24 to 25 hour window | `LC:L294`, `LC:L120` | full_match | 0.93 | `int56[25]` at four per slot is seven slots |
| SPEC-125 | Patient buyer: about $35k, 1.25% each way, 45M coins about $9k | `FC:L33`, `C:L32` | full_match | 0.93 | 150 x 300,000 = 45M; 4.5% x $200k = $9,000 |
| SPEC-126 | Level rule needs no price maths or iteration per swap | `LC:L285-L287`, `LC:L360-L362`, `LC:L373-L375` | partial_match | 0.60 | AMBIGUOUS (AMB-07): no price maths; bounded loops exist |
| SPEC-127 | 70% between $12.5k and $200k raises about $35k | `H:L645` | full_match | 0.95 | |
| SPEC-128 | Per-pool config snapshot: changing defaults can never alter a launched coin | `H:L115`, `H:L462`, `H:L478`, `H:L752-L754` | mismatch | 0.93 | DIV-03 |
| SPEC-129 | Sticky `reserveTargetReached` | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-130 | OQ4: no coin can go Live sooner than 24 hours after its first trade | `LC:L273-L275`, `H:L408-L417` | mismatch | 0.90 | DIV-11 |
| SPEC-131 | OQ5: holders by balance; a wallet stops counting below; unlocked level stays | `C:L203`, `H:L438` | full_match | 0.97 | |
| SPEC-132 | OQ8: listed $51M and $102M are used | `LC:L237-L240` | full_match | 0.97 | |
| SPEC-133 | OQ10: `BASE_MAINNET_BANKROLL` unset and deployment refuses to run without it | `V:L134`, `V:L325` | full_match | 0.97 | |
| SPEC-134 | OQ1/2/7 placeholders: 50/50 split, $10,000 reserve target, Base | `FC:L23-L28`; no reserve; `V:L544,L558` | mismatch | 0.85 | DIV-02 and DIV-01; the chain part holds |
| SPEC-135 | Toolchain 0.8.38/Osaka; PoolManager 0.8.26/Cancun; CI steps | `foundry.toml`, `.github/workflows/test.yml:L28-L44` | full_match | 0.93 | Not built here |
| SPEC-136 | Internal contracts use the legacy pipeline | `foundry.toml` `via_ir = false` | full_match | 0.95 | |
| SPEC-137 | Never add a liquidity-removal path to the hook | `H` has one `modifyLiquidity` call, `L715` | full_match | 0.95 | |
| SPEC-138 | Never read swapper identity from `hookData` | `H:L350,L373` forward it; `ISP:L146,L226` ignore it | full_match | 0.93 | |
| SPEC-139 | Never make the hook swap against its own pools | grep `.swap(` in `src/`: 0 hits | full_match | 0.97 | |
| SPEC-140 | `DicesCoin` and `LiveCalculator` constructor arguments; `_requireWiring` in step | `V:L219,L227`, `V:L525-L531` | full_match | 0.97 | |
| SPEC-141 | Launch price, sale end, supply split and first level target must agree | `H:L95` = `LC:L222`; `H:L71` = `LC:L94`; `H:L641,L648` | full_match | 0.95 | Enforced only by `InvalidLaunchPrice` |
| SPEC-142 | Test harness files, `PoolManagerArtifact`, dependencies through `lib/v4-hooks-public` | Files present; `remappings.txt` | full_match | 0.80 | Not executed; `forge-std` and `createx` are further submodules |

### 5.6 `README.md`

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-143 | One-transaction launch, 70/20/10, about $35,000; hook has no way to remove either position | `H:L533-L655`, `H:L715` | full_match | 0.95 | |
| SPEC-144 | Every fee is charged in USDC through hook deltas | `H:L460`, `H:L474-L476` | mismatch | 0.97 | DIV-08 |
| SPEC-145 | 1.25% pre-Live and 1.00% post-Live on buys and sells | `FC:L33-L38`, `FC:L72-L74` | full_match | 0.95 | |
| SPEC-146 | Plus 0.50% on buys to the reserve, then 0.25% to the race pool | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-147 | Base fee split between the platform and the creator | `FC:L85-L94` | mismatch | 0.92 | DIV-02 |
| SPEC-148 | Fees accrue as ERC-6909 USDC claims, withdrawn with `claimFees()` | `ESC:L80-L94`; grep `claimFees`: 0 hits | mismatch | 0.97 | DIV-09 |
| SPEC-149 | Reserve and race-pool ledgers controlled by `reserveController` | None | missing_in_code | 0.97 | DIV-01 |
| SPEC-150 | Levels 0 to 10, thresholds, TWAP over 24 to 25 hours after every swap, nothing in the first 24 hours | `H:L175`, `LC:L219-L253`, `LC:L309-L338` | full_match | 0.93 | True from the first observation |
| SPEC-151 | Holder count kept on every transfer; ignores wallets that reached the balance in the current block | `C:L168-L175` | code_weaker_than_spec | 0.90 | DIV-12 |
| SPEC-152 | Completing swap emits `PoolLevelUnlocked` (and `PoolLive`); `syncLevel`; never lost | `H:L436-L447`, `H:L408-L417` | full_match | 0.97 | |
| SPEC-153 | Calculators are owner-replaceable; fee calculator stateless; Live calculator hook-only, replacement restarts history | `H:L752-L763`, `ISP:L75`, `LC:L406-L412` | code_weaker_than_spec | 0.90 | DIV-04; all other clauses hold |
| SPEC-154 | CreateX deployment, six flags, explicit owner, set implementation, trust Universal Router, hand over | `V:L120`, `V:L237-L246`, `V:L476` | full_match | 0.97 | |
| SPEC-155 | 0.8.38 for Osaka; PoolManager 0.8.26/Cancun artifact | `foundry.toml`; pragmas in `src/` | full_match | 0.90 | Not built here |
| SPEC-156 | Suites, invariants over 64 runs of 32 actions, 100% coverage gate | `foundry.toml` invariant block; `test/DicesHookInvariant.t.sol:L83-L110`; workflow `L37-L44` | partial_match | 0.55 | NOT EXECUTED; configuration and files are present |
| SPEC-157 | Chains 8453 and 84532; no environment; reverts while fee or buy-and-burn recipient unset; address book written | `V:L541-L573`, `V:L323-L325`, `V:L623-L671` | full_match | 0.95 | Bankroll is required as well |
| SPEC-158 | Generate-activity script behaviour | `script/process/GenerateActivity.s.sol:L71-L77,L148` | partial_match | 0.50 | Outside the scoped code; constants spot-checked only |

### 5.7 NatSpec

| ID | Spec claim (abridged) | Code evidence | match_type | conf | Finding / note |
| --- | --- | --- | --- | --- | --- |
| SPEC-159 | Hook collects fees in the unspecified currency; coin fees queued; paired fees to protocol, creator, buy-and-burn | `H:L458-L483` | full_match | 0.97 | Contradicts SPEC-032/144 |
| SPEC-160 | `SALE_END_TICK` is a $200,000 cap; negated for currency1; sale raises about $35,000 | `H:L95`, `H:L648-L653` | full_match | 0.97 | |
| SPEC-161 | `usdc`: "Fees, reserves and the raised total are in this currency" | `H:L460`; no reserves, no raised total | mismatch | 0.95 | DIV-17 |
| SPEC-162 | `_owner` is the initial owner and protocol fee recipient | `H:L199`, `H:L209` | full_match | 0.99 | |
| SPEC-163 | Guards: third-party initialise only; hook and swap pool may add; only the swap pool may remove its own JIT | `H:L254-L307`; `Pool.sol:L187` | full_match | 0.95 | |
| SPEC-164 | "Prevents 0-block buys ... unless token creator"; "Only approved launching routers may swap in the launch block" | `H:L334-L336`; `V:L238` | mismatch | 0.80 | DIV-06 |
| SPEC-165 | `lastSwapBlock` marked "so BuyAndBurn cannot process after a swap in this block" | `H:L339`; no reader in `src/`; no BuyAndBurn contract | mismatch | 0.90 | DIV-17 |
| SPEC-166 | `_afterSwap` notice: "The hook's own swaps." | `H:L372-L386` | mismatch | 0.90 | DIV-17; the hook never swaps |
| SPEC-167 | "a fault in the calculator must never block a swap" | `H:L436-L448` | code_weaker_than_spec | 0.80 | DIV-13 |
| SPEC-168 | Chain-specific clone salt | `H:L551` | full_match | 0.97 | |
| SPEC-169 | Liquidity-rounding remainder stays in the hook | `H:L614`, `H:L718` | full_match | 0.95 | 1.27e14 wei (coin0) or 8.0e7 wei (coin1) per launch |
| SPEC-170 | Ticks used exactly as given; a reversed range fails in the PoolManager | `H:L703-L715`; `Pool.sol:L95` | full_match | 0.93 | |
| SPEC-171 | `CoinParams.creator`: recipient of the creator's trading fees | `H:L574`, `H:L480`, `ISP:L274` | full_match | 0.93 | No zero check (DIV-14) |
| SPEC-172 | `PoolLive` always followed by `PoolLevelUnlocked`; one event per rise | `H:L442-L446` | full_match | 0.99 | |
| SPEC-173 | Error set (`InvalidCreationFee` ... `UnknownCoin`) | `H:L202,L257,L262,L267,L272,L292,L304,L335,L413,L538,L546,L642,L649,L711,L772,L795,L808,L821,L834` | full_match | 0.88 | `InvalidFee`, `InvalidTickSpacing`, `InvalidPairedCurrency` sit in an unreachable block (UCP-15) |
| SPEC-174 | `createCoin` NatSpec: 70/20/10 split | `H:L76-L86` | full_match | 0.97 | |
| SPEC-175 | `syncLevel`: "Does nothing when the pool qualifies for no level above the one it holds" | `LC:L266-L295` writes on every call | mismatch | 0.90 | DIV-11 |
| SPEC-176 | Setters owner-only; `pause` pauses coin creation | `H:L752-L852`, `H:L533` (`whenNotPaused`) | full_match | 0.98 | |
| SPEC-177 | `DicesCoin`: whole supply to the hook; threshold 300,000 coins; O(1) read | `C:L32`, `C:L137`, `C:L168-L175` | full_match | 0.97 | |
| SPEC-178 | Hook, PoolManager, swap pool, bankroll excluded; exclusion belongs to the address | `C:L247-L249` | full_match | 0.98 | |
| SPEC-179 | Holder fields share the `_initialized` slot | `C:L78-L93` (8 + 64 + 32 + 32 bits) | full_match | 0.90 | Layout not compiled here |
| SPEC-180 | `qualifiedHolders`: a holder that crossed in this block is not reported until the next | `C:L168-L175` | code_weaker_than_spec | 0.90 | DIV-12 |
| SPEC-181 | `initialize` exactly once; `burn` from the caller | `C:L123-L138`, `C:L182-L184` | full_match | 0.95 | No caller restriction on `initialize` (UCP-22) |
| SPEC-182 | `IDicesCoin` ABI: ERC-20 metadata, permit, solady errors including the fixed Permit2 allowance | solady `ERC20.sol:L48,L122,L667-L669`; `C:L18` | full_match | 0.80 | `DicesCoin` does not declare `is IDicesCoin` |
| SPEC-183 | `LiveCalculator` contract NatSpec (rule, TWAP, hook-only, fresh calculator) | `LC:L146-L165`, `LC:L266-L376` | full_match | 0.93 | "doubling up to $102,000,000" is loose for levels 9 and 10 |
| SPEC-184 | `LEVELS` 10, `WINDOW` 24 hours, `PERIOD` 1 hour, 24 periods, 25 checkpoints, supply 1e27 | `LC:L69-L94` | full_match | 0.99 | |
| SPEC-185 | `levelTicks`: lowest tick at which 1e27 supply is worth at least the target | `LC:L219-L242` | full_match | 0.97 | Exact integer check and contract arithmetic, section 9.1 |
| SPEC-186 | View docs: `averageTick` rounded down, zero until ready; `averageMarketCap`; `qualifiedLevel` | `LC:L175-L209`, `LC:L329-L333` | full_match | 0.95 | |
| SPEC-187 | Numeric safety comments: 32-bit time to 2106; tick x seconds fits 56 bits; average fits a tick | `LC:L271`, `LC:L400`, `LC:L337` | full_match | 0.93 | 887,273 x 2^32 = 3.8e15, below 2^55 |
| SPEC-188 | `qualify` must be called after every swap; hook only; result can fall | `H:L382`, `LC:L146` | full_match | 0.97 | |
| SPEC-189 | `FeeCalculator` constants: creator 30%, buy and burn 30%, platform 40%; 1.25% and 1.00% | `FC:L18-L38`, `FC:L85-L94` | full_match | 0.99 | Contradicts SPEC-019/147 |
| SPEC-190 | Launch cap $12,500; sqrt prices `floor(sqrt(cap x 2^192 / 1e27))` and inverse | `FC:L47-L63` | full_match | 0.99 | Both exact, section 9.1 |
| SPEC-191 | `getFeeDistribution` `_amount`: "The amount of USDC being swapped"; "sent to the holders" | `FC:L85-L94`; `H:L478` passes the fee | mismatch | 0.90 | DIV-17 |
| SPEC-192 | `IFeeCalculator` ABI docs | `FC:L72,L85,L103` | full_match | 0.95 | |
| SPEC-193 | `FeeEscrow`: funded credits, anyone may fund or trigger payment, no administrator, fee-on-transfer unsupported | `ESC:L19-L121` | full_match | 0.97 | |
| SPEC-194 | `deposit` exact funds; `claim` pays the beneficiary whoever calls; `claimBatch` atomic; zero credits are no-ops | `ESC:L34-L120` | full_match | 0.97 | |
| SPEC-195 | Swap-pool `deposit` registers tokens already transferred; hook only | `ISP:L127-L138`, `H:L475-L476` | full_match | 0.97 | |
| SPEC-196 | JIT only for buys with inventory "worth interacting with"; skipped with no active liquidity, no usable range or zero liquidity | `ISP:L155-L202`, `ISP:L90` | full_match | 0.88 | Minimum is 1e6 wei of an 18-decimal coin (AMB-08) |
| SPEC-197 | Close: settle the coin, take paired proceeds, credit through escrow; router must sync after the swap | `ISP:L226-L279` | full_match | 0.90 | Router constraint not testable here |
| SPEC-198 | `IInternalSwapPool.feeCalculator`: "Fee calculator fixed at construction" | `ISP:L75,L113` | full_match | 0.99 | Contradicts SPEC-042/153 (DIV-04) |
| SPEC-199 | `trustedRouters`: "trusted for wallet attribution" | `TR:L37-L52`; `H:L334` | code_stronger_than_spec | 0.85 | Second, undocumented use as launch-block allowlist (DIV-06) |
| SPEC-200 | `CurrencySettler` syncs immediately before settling; routers must sync after the swap | `src/libraries/CurrencySettler.sol:L29-L50` | full_match | 0.93 | |
| SPEC-201 | `HookSwap` / `HookFee`: pre-fee deltas, fee in the currency it was taken from, `sender` is the router | `H:L504-L520`, `UE:L79-L95` | full_match | 0.97 | |
| SPEC-202 | `PoolSwap`: "emitted directly by DicesHook" | No emission in `src/` | mismatch | 0.97 | DIV-10 |
| SPEC-203 | `PoolLiquidityDelta` and `PoolDonation` describe liquidity and donation changes | `UE:L104-L117` never called | mismatch | 0.90 | DIV-10 |
| SPEC-204 | `IFlaunch`: external pool-token registry lookup | No user in `src/` | mismatch | 0.85 | DIV-17 |
| SPEC-205 | V001 destinations: zero owner keeps deployer; zero recipient or bankroll defaults on testnet, reverts on mainnet before broadcast | `V:L305-L326`, `V:L197-L208` | full_match | 0.97 | |
| SPEC-206 | V001: every contract and the events library through CreateX CREATE3; address book depends on signer and salt | `V:L213-L234`, `V:L402-L412`; `CreateX.sol:L894` | full_match | 0.93 | |
| SPEC-207 | V001: owner passed as argument; deployer wires, then transfers to `PROTOCOL_OWNER` when set | `V:L237-L246`, `V:L476` | full_match | 0.97 | |
| SPEC-208 | V001: `HOOK_FLAGS` mirrors `getHookPermissions()`; a match every 16,384 attempts | `V:L113-L120`, `V:L432` | full_match | 0.95 | Miss probability over 160,444 attempts is 5.6e-5 |
| SPEC-209 | V001: address book written only on a real broadcast | `V:L253-L258`, `V:L609-L611` | full_match | 0.95 | |

---
## 6. Divergence Findings

Severity follows the skill's ladder with one project rule applied on top: a divergence that is only stale documentation is LOW unless the stale sentence is a guarantee that someone could rely on, in which case it is classified by what the code does. Severity here measures distance from the documents; none of the findings below was reproduced by execution.

| ID | Severity | Title | Spec items |
| --- | --- | --- | --- |
| DIV-01 | HIGH | Reserve surcharge, reserve and race ledgers and `reserveController` are absent | 006, 017, 018, 026, 076, 078, 129, 146, 149 |
| DIV-02 | MEDIUM | Fees are split three ways, 30% to an undocumented buy-and-burn recipient | 019, 039, 134, 147 |
| DIV-03 | MEDIUM | No per-pool snapshot and no caps: the owner can change rate and split of launched pools without bound | 022, 030, 053, 112, 128 |
| DIV-04 | MEDIUM | `setFeeCalculator` does not reach the InternalSwapPool | 042, 153 |
| DIV-05 | MEDIUM | No sealed game commitment at launch | 004, 048, 054 |
| DIV-06 | MEDIUM | Launch-block guard does not do what its NatSpec says | 028, 164, 199 |
| DIV-07 | LOW | Lock statements are wrong in mechanism; the lock itself holds | 024, 031, 061, 062 |
| DIV-08 | LOW | Fee currency and mechanics differ from every non-NatSpec description | 032, 068, 071, 072, 073, 075, 120, 144 |
| DIV-09 | LOW | Fee custody: no ERC-6909 claims, no `claimFees()`, no hook-level balance invariant | 025, 035, 077, 079, 148 |
| DIV-10 | LOW | Events: no `CoinCreated`, `PoolSwap` never emitted, unused liquidity and donation events | 041, 060, 088, 090, 091, 202, 203 |
| DIV-11 | LOW | The 24 hours run from the first observation, which `syncLevel` can create before any trade | 102, 130, 175 |
| DIV-12 | LOW | `qualifiedHolders()` returns the lower of two counts, not "count minus this block's joiners" | 084, 151, 180 |
| DIV-13 | LOW | Calculator trust boundary: fail-safe covers reverts only; level and calculator identity unchecked | 046, 109, 167 |
| DIV-14 | LOW | `createCoin` validates nothing about the creator; a zero creator makes USDC-fee swaps revert | 049 |
| DIV-15 | LOW | Stale architecture and configuration text | 036, 037, 113, 122 |
| DIV-16 | LOW | Deferred components are absent, as the spec says | 009, 010, 020, 021, 029 |
| DIV-17 | LOW | NatSpec and comment drift inside the code; bankroll check narrower than stated | 119, 161, 165, 166, 191, 204 |

### DIV-01 (HIGH): reserve surcharge, reserve and race ledgers and `reserveController` are absent

```yaml
id: DIV-01
severity: HIGH
title: "Buys are not surcharged for the reserve; no reserve, race pool or reserveController exists"
spec_claim:
  - excerpt: "Every buy adds liquidity (USDC flows into the pool) and funds the coin's casino reserve."
    source: "AGENT.md section 2, Product"
  - excerpt: "| Pre-Live | 1.25% base + 0.50% to the coin's reserve | 1.25% | ... | Post-Live | 1.00% base + 0.50% to the reserve | 1.00% | ... | Reserve target reached | base + 0.25% to the race pool (interpretation: replaces the 0.50%) | base |"
    source: "AGENT.md section 2, Trading fees"
  - excerpt: "plus 0.50% on buys to the coin's reserve until the reserve target is reached, then 0.25% on buys to the race pool ... reserve and race-pool ledgers are controlled by the `reserveController`."
    source: "README.md, summary bullet 2"
  - excerpt: "`reserve`, `racePool`, `reserveTargetReached`: casino ledgers. Only `reserveController` (future GameReserve) may `withdrawReserve`, `withdrawRacePool`, `depositReserve`."
    source: "AGENT.md section 3, Ledgers (named stale by the 2026-11-05 note)"
  - excerpt: "GameReserve | Deferred. `DicesHook` already keeps per-coin `reserve` and `racePool` ledgers with controller-gated withdraw/deposit"
    source: "AGENT.md section 2, Client component list"
  semantic_type: fee_formula_and_ledger
  enforcement_level: "required output of the brief; in scope per section 1 ('fees', 'ledgers')"
code_finding:
  file: "src/calculators/FeeCalculator.sol, src/DicesHook.sol"
  function: "getSwapFee(bool), _swapFee, _collectSwapFee"
  lines: "FeeCalculator L33-L38, L72-L74; DicesHook L458-L463, L471-L483"
  observation: "One rate per Live state, with no swap-direction input. Collected fees go to the swap pool (coin) or to platform, creator and buy-and-burn credits (USDC). No reserve, race pool, target or controller exists in any file."
match_type: missing_in_code
confidence: 0.95
reasoning: |
  Spec: buys pay base + 0.50% (reserve) and later base + 0.25% (race pool); sells pay base.
  Code: getSwapFee takes only `_live`; `_swapFee` multiplies the unspecified amount by that single rate.
    pre-Live buy  : spec 1.75% , code 1.25%
    post-Live buy : spec 1.50% (1.25% once the reserve is full), code 1.00%
    sells         : spec = code (1.25% / 1.00%)
  No state variable or function holds or releases a reserve.
  The 2026-11-05 note covers the section 3 "Fees" and "Ledgers" text, but not section 2 (the brief's
  required outputs) and not README.md, which was edited in the rework commit f64bd24 and again in bbbeb4c.
  Section 1 lists "fees" and "ledgers" in the current engagement scope.
evidence:
  code_quotes:
    - "FeeCalculator.sol:L72-L74  function getSwapFee(bool _live) public view returns (uint) { return _live ? POST_LIVE_FEE : PRE_LIVE_FEE; }"
    - "DicesHook.sol:L462  fee.amount = Math.mulDiv(amount, feeCalculator.getSwapFee(poolLive(key.toId())), FEE_DENOMINATOR);"
    - "DicesHook.sol:L478  (uint platform, uint creator, uint buyAndBurn) = feeCalculator.getFeeDistribution(fee.amount, poolLive(poolId));"
  search_results:
    - "grep -rn 'reserveController|withdrawReserve|withdrawRacePool|depositReserve|racePool|reserveTargetReached' src/ -> 0 hits"
    - "grep -rn 'reserve' src/ -> only comments at DicesHook.sol:L108 and UniswapEvents.sol:L46-L48"
exploitability: |
  No attacker gains from this. It is a missing economic output.
  Quantified against the documents:
    - Raising $35,013 to the sale end: 0.50% of buy volume = at least $175 that the reserve does not receive.
    - Per $1,000,000 of buy volume: $5,000 (reserve) or $2,500 (race pool) not collected.
    - The placeholder reserve target of $10,000 (open question 2) would need $2,000,000 of buy volume; in the code it is never approached.
  Consequences: buyers pay 0.50 percentage points less than the published schedule; the USDC bankroll that
  section 2 calls "the casino bankroll" is empty for every coin launched from this build; a later GameReserve
  has nothing to control and no history to inherit.
remediation:
  decision_needed: "Confirm with the client whether the reserve surcharge was dropped with the f64bd24 rework. If it was, DIV-01 becomes documentation drift and section 2 and README must change. If it was not, implement it."
  immediate_fix: "See the sketch below. Under the implemented fee design the hook fee is taken in the unspecified currency, so an exact-in USDC buy pays in the coin. A USDC reserve therefore needs either the beforeSwapReturnDelta permission (a new hook address) or accrual from the InternalSwapPool's converted proceeds."
  testing_requirements:
    - "Unit: buy vs sell rate per Live state, with and without the reserve full."
    - "Unit: the crossing buy caps the reserve and sends the overshoot to the race pool; the flag never clears."
    - "Access: only reserveController can withdraw or deposit."
    - "Invariant: custody balance == escrow credits + sum(reserve) + sum(racePool)."
  breaking_changes: "Changes the IFeeCalculator ABI and the fee paid by buyers; adds storage and events to DicesHook; may change hook permissions (new CREATE3 salt and address, new DicesCoin implementation and LiveCalculator)."
  specification_update: "If dropped: remove the 0.50% / 0.25% rows and the reserve sentences from AGENT.md section 2 and README bullet 2, and delete the GameReserve claim in the component table."
```

Remediation sketch for DIV-01 (illustrative, not compiled):

```solidity
// FeeCalculator
uint internal constant RESERVE_FEE = 500; // 0.50%
uint internal constant RACE_FEE = 250;    // 0.25%

function getSwapFee(bool _live, bool _isBuy, bool _reserveFull) public pure returns (uint base_, uint surcharge_) {
    base_ = _live ? POST_LIVE_FEE : PRE_LIVE_FEE;
    surcharge_ = _isBuy ? (_reserveFull ? RACE_FEE : RESERVE_FEE) : 0;
}

// DicesHook
mapping(PoolId => uint) public reserve;
mapping(PoolId => uint) public racePool;
mapping(PoolId => bool) public reserveTargetReached;
address public reserveController;
```

### DIV-02 (MEDIUM): three-way fee split with an undocumented buy-and-burn recipient

```yaml
id: DIV-02
severity: MEDIUM
title: "Fees are split 40% platform, 30% creator, 30% buyAndBurnRecipient; the documents say platform and creator"
spec_claim:
  - excerpt: "The base fee is split between the platform and the creator (split not given; see open questions)."
    source: "AGENT.md section 2, Trading fees"
  - excerpt: "Creator vs platform split of the base trading fee (placeholder 50/50)."
    source: "AGENT.md section 5, open question 1"
  - excerpt: "The base fee is split between the platform and the creator."
    source: "README.md, summary bullet 2"
  - excerpt: "Rate schedule and USDC fee split into platform / creator / reserve / race"
    source: "AGENT.md section 3, Contracts table (named stale)"
code_finding:
  file: "src/calculators/FeeCalculator.sol; src/DicesHook.sol; src/core/InternalSwapPool.sol"
  function: "getFeeDistribution, _collectSwapFee, closeInternalSwapPool, setBuyAndBurnRecipient"
  lines: "FeeCalculator L23-L28, L85-L94; DicesHook L140, L218, L478-L481, L770-L776; InternalSwapPool L265-L277"
  observation: "A third beneficiary takes 30% of every collected fee. It is a plain address chosen by the owner; no in-scope contract buys or burns anything."
match_type: mismatch
confidence: 0.92
reasoning: |
  Spec: two beneficiaries. The numbers are an acknowledged open question, with 50/50 as placeholder.
  Code: creator_ = amount * 30_000 / 100_000; buyAndBurn_ = amount * 30_000 / 100_000; platform_ = remainder (40%).
  Per $1,000 of fees: creator $300 (placeholder: $500), platform $400 (placeholder: $500), buy-and-burn $300 (spec: none).
  The NatSpec in FeeCalculator.sol:L21-L28 and the V001 header document the three-way split, so the
  code is internally consistent; AGENT.md never mentions buy and burn and README mentions the recipient
  only in its deploy section.
evidence:
  code_quotes:
    - "FeeCalculator.sol:L23  uint internal constant CREATOR_FEE = 30_000;"
    - "FeeCalculator.sol:L28  uint internal constant BUY_AND_BURN_FEE = 30_000;"
    - "FeeCalculator.sol:L93  platform_ = _amount - creator_ - buyAndBurn_;"
    - "DicesHook.sol:L481  _creditFee(buyAndBurnRecipient, Currency.unwrap(fee.currency), buyAndBurn);"
  search_results:
    - "grep -n 'buy and burn\\|buyAndBurn' AGENT.md -> 0 hits"
    - "No BuyAndBurn contract in src/; the only other reference is the comment at DicesHook.sol:L338"
exploitability: |
  Not exploitable by a third party. The owner sets buyAndBurnRecipient (L770-L776), so in effect owner-chosen
  addresses receive 70% of fees and creators 30%. A creator who relied on the placeholder receives 40% less
  than expected ($300 instead of $500 per $1,000 of fees).
remediation:
  immediate_fix: "Decide the split with the client (open question 1). If buy and burn is intended, document it in AGENT.md section 2 and README, and say what receives it. If not, remove BUY_AND_BURN_FEE and set CREATOR_FEE to the agreed share."
  testing_requirements:
    - "Fuzz getFeeDistribution: the three outputs always sum to the input."
    - "Integration: escrow credits per recipient after a USDC-fee swap and after a converted coin-fee swap."
  breaking_changes: "A calculator change alone does not reach the InternalSwapPool (DIV-04)."
  specification_update: "State the three recipients and their shares wherever the split is described."
```

### DIV-03 (MEDIUM): no per-pool snapshot and no caps

```yaml
id: DIV-03
severity: MEDIUM
title: "Fee rate and split of launched pools follow the owner-replaceable calculator, with no bound"
spec_claim:
  - excerpt: "Per-pool config snapshot: changing defaults can never alter a coin that already launched."
    source: "AGENT.md section 4, Design decisions and rationale"
  - excerpt: "Snapshot the owner's launch defaults into `PoolConfig` for this pool; store creator config and `gameCommitment`."
    source: "AGENT.md section 3, Launch, step 4"
  - excerpt: "All critical financial operations are enforced on-chain with caps."
    source: "AGENT.md section 2, Governance"
  - excerpt: "Parameter registry | `DicesHook` launch defaults, snapshotted per pool as `PoolConfig`"
    source: "AGENT.md section 2, Client component list"
code_finding:
  file: "src/DicesHook.sol"
  function: "_swapFee, _collectSwapFee, setFeeCalculator, _setFeeCalculator, setCreateFee, _syncLevel"
  lines: "L115, L462, L478-L481, L752-L754, L783-L786, L819-L825, L436-L439"
  observation: "There is no PoolConfig. Rate and split are read from the current calculator on every swap. The setter checks only that the address has code. Nothing bounds the rate, the split sum, the creation fee or the level a Live calculator returns."
match_type: mismatch
confidence: 0.90
reasoning: |
  Guarantee stated: a launched coin's parameters cannot change. What the code does:
    - L462 reads feeCalculator.getSwapFee(...) at swap time; L478 reads getFeeDistribution(...) at swap time.
    - L752-L754 lets the owner point feeCalculator anywhere with code (L820).
    - No comparison of the returned rate with any maximum; no check that platform + creator + buyAndBurn == fee.amount.
    - setCreateFee (L783-L786) stores any value.
    - _syncLevel stores any uint8 above the current level (L438-L439), and levels never go down.
  Launch-curve parameters are compile-time constants (L71-L95), so that part cannot change for a launched pool.
  feeRecipient and buyAndBurnRecipient are global and owner-settable (L770-L799); the creator is fixed per pool (L574).
  The treasury timelock is deferred by section 1; the "caps" sentence is not listed as deferred.
evidence:
  code_quotes:
    - "DicesHook.sol:L820-L822  if (_calculator.code.length == 0) { revert InvalidCalculator(_calculator); }"
    - "DicesHook.sol:L784  createFee = _createFee;"
    - "DicesHook.sol:L438-L439  if (level > unlocked) { poolLevel[_poolId] = level;"
  search_results:
    - "grep -rn 'PoolConfig' src/ -> 0 hits"
    - "grep -n 'MAX_\\|cap' src/DicesHook.sol -> no fee or level bound"
exploitability: |
  Prerequisite: the owner key (today the deployer on any chain where PROTOCOL_OWNER is unset, V001.s.sol:L131, L145, L306;
  single-step Ownable; no timelock in scope).
  Sequence: owner calls setFeeCalculator(X). From the next swap, on every launched pool:
    - X.getSwapFee returning 100_000 takes the whole unspecified leg: a seller of 1,000,000 coins due 100 USDC
      receives 0 unless the router enforces a minimum output; a value above 100_000 makes the swapper owe more.
    - X.getFeeDistribution returning (amount, 0, 0) ends every creator's 30% share.
    - A split that sums above the fee makes escrow funding fail and every USDC-fee swap revert; a split that sums
      below leaves the difference in the hook with no way out.
  Separately, setLiveCalculator(Y) with Y.qualify returning 10 unlocks all levels of any pool at its next swap or
  syncLevel, permanently.
  Impact: creators lose 30% of their pool's fees going forward; traders can lose up to the whole output of a swap
  submitted without slippage protection. No third party can trigger this.
remediation:
  immediate_fix: "Either snapshot rate and split per pool at launch, or bound what a calculator may return (sketch below). Bound createFee. Clamp or reject levels above LEVELS. Use Ownable2Step and put the timelock in front of the owner before mainnet."
  testing_requirements:
    - "Unit: a calculator returning a rate above the cap reverts or is clamped."
    - "Unit: a split that does not sum to the fee reverts."
    - "Unit: a calculator returning level 11 or 255 cannot write poolLevel above 10."
    - "Fuzz: replace the calculator mid-life; rates of launched pools stay within the bound."
  breaking_changes: "A snapshot adds storage per pool and changes createCoin gas; a cap alone is not breaking."
  specification_update: "If neither is wanted, delete the snapshot sentence from section 4 and say plainly that the owner controls fees of launched pools."
```

Remediation sketch for DIV-03:

```solidity
uint internal constant MAX_SWAP_FEE = 2_000; // 2.00% on the 100_000 scale

uint rate = feeCalculator.getSwapFee(poolLive(key.toId()));
if (rate > MAX_SWAP_FEE) revert FeeTooHigh(rate);

(uint platform, uint creator, uint buyAndBurn) = feeCalculator.getFeeDistribution(fee.amount, poolLive(poolId));
if (platform + creator + buyAndBurn != fee.amount) revert InvalidFeeSplit();

if (level > liveCalculator.LEVELS()) revert InvalidLevel(level); // inside the try body
```

### DIV-04 (MEDIUM): `setFeeCalculator` does not reach the InternalSwapPool

```yaml
id: DIV-04
severity: MEDIUM
title: "The swap pool's fee calculator is immutable, so a replacement changes only half of the fee flow"
spec_claim:
  - excerpt: "Calculators are owner-replaceable."
    source: "AGENT.md section 3, Contracts"
  - excerpt: "`FeeCalculator` and `LiveCalculator` are owner-replaceable modules."
    source: "README.md, summary bullet 4"
code_finding:
  file: "src/core/InternalSwapPool.sol; src/DicesHook.sol"
  function: "closeInternalSwapPool; setFeeCalculator"
  lines: "InternalSwapPool L75, L113, L265; DicesHook L125, L212, L752-L754, L824"
  observation: "DicesHook.setFeeCalculator writes only DicesHook.feeCalculator. InternalSwapPool.feeCalculator is immutable and DicesHook.internalSwapPool has no setter."
match_type: code_weaker_than_spec
confidence: 0.90
reasoning: |
  Fees taken in USDC (exact-out buys, exact-in sells) are split by the hook's calculator (DicesHook L478).
  Fees taken in the coin (exact-in buys, exact-out sells) are queued, sold through a JIT position, and the USDC
  proceeds are split by the swap pool's own calculator (InternalSwapPool L265).
  The two references are equal at deployment (V001.s.sol:L230, L476). After setFeeCalculator they differ for good:
  neither the pool's calculator nor the hook's pool reference can be changed.
  The interface NatSpec says so ("Fee calculator fixed at construction", IInternalSwapPool.sol:L46-L50); AGENT.md and
  README do not.
evidence:
  code_quotes:
    - "InternalSwapPool.sol:L75  IFeeCalculator public immutable feeCalculator;"
    - "InternalSwapPool.sol:L265  (uint platform, uint creator, uint buyAndBurn) = feeCalculator.getFeeDistribution(proceeds, dicesHook.poolLive(poolId));"
    - "DicesHook.sol:L824  feeCalculator = IFeeCalculator(_calculator);"
  search_results:
    - "grep -n 'internalSwapPool =' src/DicesHook.sol -> L212 only (constructor)"
exploitability: |
  Not an attack; a documented owner operation that silently does half its job.
  Example: the client settles open question 1 at creator 50% and the owner deploys a new calculator.
  $10,000 of fees collected through exact-in buys are converted by the swap pool and split by the old calculator:
  creators receive $3,000 instead of $5,000. Exact-in buys are the usual way to buy, so most buy-side fees are affected.
  The only repair is a new InternalSwapPool, which needs a new hook (constructor-fixed), a new DicesCoin
  implementation and a new LiveCalculator.
remediation:
  immediate_fix: "Read the calculator through the hook at the point of use (sketch below) and remove the immutable."
  testing_requirements:
    - "Integration: replace the calculator, then two exact-in buys; assert the second buy's converted proceeds follow the new split."
    - "Invariant: hook.feeCalculator() is the only calculator consulted in a swap."
  breaking_changes: "InternalSwapPool constructor loses an argument; V001 and _requireWiring change with it."
  specification_update: "Until fixed, say in AGENT.md and README that a fee calculator replacement does not apply to converted coin fees."
```

Remediation sketch for DIV-04:

```solidity
(uint platform, uint creator, uint buyAndBurn) =
    dicesHook.feeCalculator().getFeeDistribution(proceeds, dicesHook.poolLive(poolId));
```

### DIV-05 (MEDIUM): no sealed game commitment at launch

```yaml
id: DIV-05
severity: MEDIUM
title: "createCoin neither takes nor stores a game commitment"
spec_claim:
  - excerpt: "**One transaction** creates the coin, locks all liquidity permanently in **two Uniswap v4 positions**, attaches the trading hook and registers a **sealed** casino game."
    source: "AGENT.md section 2, Product"
  - excerpt: "`createCoin(CoinParams{name, symbol, creator, gameCommitment})`"
    source: "AGENT.md section 3, Launch"
  - excerpt: "store creator config and `gameCommitment`"
    source: "AGENT.md section 3, Launch, step 4"
code_finding:
  file: "src/interfaces/IDicesHook.sol; src/DicesHook.sol"
  function: "struct CoinParams; createCoin"
  lines: "IDicesHook L24-L37; DicesHook L533-L578 (stores L570-L574)"
  observation: "CoinParams has name, symbol and creator. createCoin stores poolKeys, poolCoins and poolCreators only."
match_type: missing_in_code
confidence: 0.92
reasoning: |
  Section 1 defers casino settlement, profit distribution and rewards, but game registration at launch is part of
  the launch flow (step 4) and of the one-transaction output in section 2. No field, mapping or event carries a
  commitment. The Launch subsection is neither named stale nor named current by the 2026-11-05 note (only step 5 is).
evidence:
  code_quotes:
    - "IDicesHook.sol:L24-L37  struct CoinParams { string name; string symbol; address creator; }"
    - "DicesHook.sol:L574  poolCreators[poolId] = params.creator;"
  search_results:
    - "grep -rn 'gameCommitment\\|commitment\\|sealed' src/ -> 0 hits"
exploitability: |
  No funds move. Every coin launched from this build has no on-chain seal, so "the game is revealed" on Live
  (section 2) cannot be checked against anything fixed at launch: whoever assigns the game can choose it after
  seeing how the coin trades, and the missing seal cannot be added to a coin afterwards.
remediation:
  immediate_fix: "Add `bytes32 gameCommitment` to CoinParams, store it per pool and emit it at launch (sketch below); or record a client decision that sealing moves to the casino phase and remove the three sentences."
  testing_requirements:
    - "Unit: the commitment is stored and emitted; a zero commitment is rejected if a game is mandatory."
  breaking_changes: "createCoin ABI changes; GenerateActivity and front ends must pass the new field."
  specification_update: "If deferred, list game registration among the deferred items in section 1."
```

Remediation sketch for DIV-05:

```solidity
struct CoinParams { string name; string symbol; address creator; bytes32 gameCommitment; }
mapping(PoolId => bytes32) public gameCommitments;
event CoinCreated(PoolId indexed poolId, address indexed coin, address indexed creator, bytes32 gameCommitment);
```

### DIV-06 (MEDIUM): launch-block guard does not do what its NatSpec says

```yaml
id: DIV-06
severity: MEDIUM
title: "Any account can swap in the launch block through a trusted router; there is no creator exception"
spec_claim:
  - excerpt: "Runs before all swaps. Prevents 0-block buys and creates an internal swap pool JIT liquidity pool for the swap."
    source: "NatSpec, src/DicesHook.sol:L314"
  - excerpt: "Prevent 0-block buys: Prevents bots from buying in the same block as launch, unless token creator."
    source: "Comment block, src/DicesHook.sol:L328"
  - excerpt: "Only approved launching routers may swap in the launch block."
    source: "Comment, src/DicesHook.sol:L332"
  - excerpt: "Return whether a router is trusted for wallet attribution."
    source: "NatSpec, src/interfaces/ITrustedRouters.sol:L16"
code_finding:
  file: "src/DicesHook.sol; script/deployment/V001.s.sol"
  function: "_beforeSwap; run"
  lines: "DicesHook L333-L336; V001 L238, L516"
  observation: "The check is on the router address the PoolManager saw. The creator is never consulted. The deployment trusts the Universal Router."
match_type: mismatch
confidence: 0.80
reasoning: |
  Three statements, two behaviours:
    L314 / L328: bots cannot buy in the launch block; the creator can.
    L332 and IDicesHook.sol:L161-L163: only trusted routers can swap in the launch block.
  Code implements the second: `launchBlock[poolId] == block.number && !trustedRouters[sender]` reverts.
  `sender` is the router (BaseHook passes the PoolManager's msg.sender). poolCreators is not read in _beforeSwap.
  V001 trusts the Universal Router and requires it (L238, L516), so the allowlist that gates the launch block
  is the public router everybody uses. The same mapping is documented elsewhere as an attribution allowlist only.
  AGENT.md and README do not describe any launch-block rule (section 2 component table: "Any router implementing
  `IMsgSender` ... works today").
ambiguity_notes: "Which of the two comment readings is intended is not stated anywhere; classified MEDIUM as an ambiguity with a security implication, not as a proven defect."
evidence:
  code_quotes:
    - "DicesHook.sol:L334-L336  if (launchBlock[poolId] == block.number && !trustedRouters[sender]) { revert CannotBuyZeroBlock(); }"
    - "V001.s.sol:L238  hook.setTrustedRouter(cfg.universalRouter, true);"
  search_results:
    - "grep -n 'poolCreators' src/DicesHook.sol -> L170, L480, L574 (never in _beforeSwap)"
exploitability: |
  Prerequisite: none beyond using the Universal Router.
  Sequence: a bot sees the createCoin transaction (or its PoolCreated log) and lands a Universal Router buy in the
  same block. The guard passes because the router is trusted.
  On the launch curve (Appendix D): $1,000 buys 73.6M coins (7.4% of supply) and $5,000 buys 279.9M coins (28%),
  before the 1.25% fee. The creator has no reserved first buy: a creator using an untrusted router is blocked,
  one using the Universal Router competes with everyone else.
  Whether this is a loss depends on the intent that the comments leave open.
remediation:
  immediate_fix: "Choose one behaviour and make code, comments and NatSpec agree. For the 'unless token creator' reading, see the sketch below. Otherwise delete the 'unless token creator' comment and document that trusted routers may trade in the launch block. In either case give the launch-block rule its own allowlist."
  testing_requirements:
    - "Unit: launch-block buy through the trusted router by a non-creator (expected result per the chosen rule)."
    - "Unit: launch-block buy by the creator through a trusted and an untrusted router."
  breaking_changes: "Tightening the rule changes behaviour for integrators that launch and buy in one block."
  specification_update: "Add the launch-block rule to AGENT.md section 3 and to the README behaviour summary."
```

Remediation sketch for DIV-06 (the "unless token creator" reading):

```solidity
if (launchBlock[poolId] == block.number && _getSender(sender) != poolCreators[poolId]) {
    revert CannotBuyZeroBlock();
}
```

### DIV-07 to DIV-17 (LOW)

```yaml
- id: DIV-07
  severity: LOW
  title: "Lock statements are wrong in mechanism; the lock itself holds"
  spec_claim:
    - {excerpt: "`beforeAddLiquidity` rejects any sender but the hook, `beforeRemoveLiquidity` rejects everyone", source: "AGENT.md section 3, Launch, Lock guarantees"}
    - {excerpt: "Positions are owned by the hook, which has no removal path, and `beforeRemoveLiquidity` always reverts", source: "AGENT.md section 2, Client component list, Locker"}
    - {excerpt: "It is the only liquidity provider", source: "AGENT.md section 3, Principle"}
  code_finding: {file: "src/DicesHook.sol; src/core/InternalSwapPool.sol", lines: "DicesHook L291-L293, L303-L305, L715; InternalSwapPool L207, L239", observation: "Both guards admit internalSwapPool, which adds a JIT position before a buy and removes it after."}
  match_type: mismatch
  confidence: 0.95
  reasoning: "What holds: (1) the hook's only modifyLiquidity call has a positive delta (L715); (2) positions are keyed by caller in the PoolManager (Pool.sol:L187, Position.calculatePositionKey(owner, ...)), so the swap pool can touch only positions it owns; (3) third parties are rejected for add, remove and zero-delta pokes (Hooks.sol:L201-L205 routes liquidityDelta <= 0 to beforeRemoveLiquidity); (4) internalSwapPool cannot be replaced (no setter). The launch positions are therefore permanent. The NatSpec at DicesHook.sol:L283 and L299-L300 states this correctly."
  exploitability: "None found. A reader relying on 'rejects everyone' would wrongly conclude that no liquidity is ever removed from a Dices pool; JIT liquidity is, every time a buy meets queued inventory."
  remediation: "Rewrite the three sentences to: only the hook and the InternalSwapPool may add; only the InternalSwapPool may remove, and only its own position; the hook has no removal path."
- id: DIV-08
  severity: LOW
  title: "Fee currency and mechanics differ from AGENT.md and README"
  spec_claim:
    - {excerpt: "Every fee is charged in USDC through hook deltas", source: "README.md, summary bullet 2"}
    - {excerpt: "The fee is always `rate x gross USDC moved`. Rates are cached in transient storage in `beforeSwap` ... When USDC is the specified currency a partial fill reverts (`PartialFillWithSpecifiedCurrency`)", source: "AGENT.md section 3, Fees (named stale)"}
    - {excerpt: "Fees in USDC so the reserve is a USDC bankroll with no conversion step and the trader's coin leg is untouched.", source: "AGENT.md section 4"}
  code_finding: {file: "src/DicesHook.sol", lines: "L357, L458-L463, L471-L476", observation: "beforeSwap returns no delta. afterSwap charges rate x |unspecified delta| in the unspecified currency."}
  match_type: mismatch
  confidence: 0.97
  reasoning: |
    Unspecified currency by mode (DicesHook.sol:L460, `amountSpecified < 0 == zeroForOne`):
      buy exact-in USDC   -> coin   (spec: USDC, beforeSwap)   MISMATCH
      buy exact-out coin  -> USDC   (spec: USDC, afterSwap)    match
      sell exact-in coin  -> USDC   (spec: USDC, afterSwap)    match
      sell exact-out USDC -> coin   (spec: USDC, beforeSwap)   MISMATCH
    Coin fees are sent to the InternalSwapPool (L475-L476) and sold to later buyers, so there is a conversion step and
    the trader's coin leg is touched. No transient storage and no PartialFillWithSpecifiedCurrency exist; neither is
    needed, because the fee is computed from the swap's actual unspecified delta. The pre-Live rate for the swap that
    triggers Live still holds (L375 before L382). The hook NatSpec (L44-L47) describes the implemented behaviour.
  exploitability: "None found. Integration risk: a quoter or indexer built from README expects the fee on the USDC leg; for exact-in buys it is 1.25% or 1.00% of the coins received. Part of each later buyer's USDC pays for queued coin fees and goes to fee recipients instead of into pool liquidity."
  remediation: "Replace the Fees subsection and README bullet 2 with the four-mode table above and a description of the InternalSwapPool. Delete the section 4 bullet or restate it."
- id: DIV-09
  severity: LOW
  title: "Fee custody: FeeEscrow credits instead of ERC-6909 claims; no claimFees(); no hook balance invariant"
  spec_claim:
    - {excerpt: "holds fee proceeds as ERC-6909 claims on the PoolManager until claimed", source: "AGENT.md section 3, Principle"}
    - {excerpt: "`claimableFees[recipient]` (global) ... `claimFees()` withdraws.", source: "AGENT.md section 3, Ledgers (named stale)"}
    - {excerpt: "Invariant: hook's USDC ERC-6909 balance == sum of all claimable fees + all reserves + all race pools.", source: "AGENT.md section 3, Ledgers (named stale)"}
    - {excerpt: "Fees accrue as ERC-6909 USDC claims and are withdrawn with `claimFees()`", source: "README.md, summary bullet 2"}
  code_finding: {file: "src/DicesHook.sol; src/core/FeeEscrow.sol", lines: "DicesHook L473, L731-L741; FeeEscrow L25, L34-L73, L80-L120", observation: "The hook takes ERC-20 tokens out of the PoolManager and funds per-beneficiary credits in FeeEscrow. Anyone can trigger payment to a beneficiary with claim(Claim) or claimBatch."}
  match_type: mismatch
  confidence: 0.97
  reasoning: "The stated invariant has no subject: the hook never mints ERC-6909 (grep '6909', '.mint(' in src/: 0 hits). What holds instead: for every currency, FeeEscrow's balance >= sum of claimable (deposit credits only after the exact balance increase at L60-L67; _claim deletes before paying at L110-L117; both nonReentrant). With the default calculator the hook passes on exactly fee.amount (FeeCalculator.sol:L93), so it retains no USDC; the hook does not enforce that for a replacement calculator (DIV-03)."
  exploitability: "None found. A recipient cannot choose when it is paid: any account can push a credit to its beneficiary."
  remediation: "Document FeeEscrow, the claim ABI and the escrow solvency invariant; remove the ERC-6909 sentences. test/DicesHookInvariant.t.sol:L83 already names the real invariant."
- id: DIV-10
  severity: LOW
  title: "Events: CoinCreated absent, PoolSwap never emitted, unused liquidity and donation events"
  spec_claim:
    - {excerpt: "Emit `CoinCreated` with the full config snapshot.", source: "AGENT.md section 3, Launch, step 6"}
    - {excerpt: "`PoolSwap(poolId, amount0, amount1, fee0, fee1)` after every swap ... fees are the positive USDC fee on the USDC leg and zero on the coin leg", source: "AGENT.md section 3, Indexer events"}
    - {excerpt: "Liquidity can never be removed, so no removal variant exists. These are emitted from `_launch` and `_afterSwap`, not from `beforeInitialize` / `afterAddLiquidity`", source: "AGENT.md section 3, Indexer events"}
    - {excerpt: "Pool swap deltas and fees emitted directly by DicesHook.", source: "NatSpec, src/libraries/UniswapEvents.sol:L41; IUniswapEvents.sol:L39"}
  code_finding: {file: "src/DicesHook.sol; src/libraries/UniswapEvents.sol", lines: "DicesHook L378, L383-L384, L604, L611; UniswapEvents L26, L33, L43, L48, L53, L93-L117", observation: "The hook emits HookFee (non-zero fees), HookSwap and PoolStateUpdated per swap and PoolCreated and PoolStateUpdated per launch. PoolSwap, PoolLiquidityDelta and PoolDonation are declared and never emitted. No event carries the creator."}
  match_type: mismatch
  confidence: 0.95
  reasoning: "grep 'emit PoolSwap', 'CoinCreated', 'emitLiquidityDeltaUpdate(', 'emitDonationUpdate(' outside their declarations: 0 hits. HookSwap carries the fee in whichever currency it was taken, so the 'zero on the coin leg' rule is false for exact-in buys and exact-out sells. There is no `_launch` function (launch runs in unlockCallback) and the hook has no afterAddLiquidity permission; the noSelfCall explanation is correct (Hooks.sol:L171-L181)."
  exploitability: "None on chain. An indexer written against AGENT.md subscribes to an event that never fires, and cannot learn a coin's creator, name or symbol from hook logs."
  remediation: "Either emit CoinCreated(poolId, coin, creator, ...) and PoolSwap as documented, or document HookSwap/HookFee and remove the unused declarations."
- id: DIV-11
  severity: LOW
  title: "The 24 hours run from a pool's first observation, which syncLevel can create before any trade"
  spec_claim:
    - {excerpt: "**no level, Live included, can unlock in a pool's first 24 hours of trading**. The earliest moment is the start of the 25th hour after the hour of its first trade, which is 24 to 25 hours after that trade.", source: "AGENT.md section 3, Live and game levels, The window (named current)"}
    - {excerpt: "no coin can go Live sooner than 24 hours after its first trade", source: "AGENT.md section 5, open question 4"}
    - {excerpt: "Callable by anyone. Does nothing when the pool qualifies for no level above the one it holds.", source: "NatSpec, src/interfaces/IDicesHook.sol:L309"}
  code_finding: {file: "src/DicesHook.sol; src/calculators/LiveCalculator.sol", lines: "DicesHook L408-L417, L436; LiveCalculator L146-L164, L273-L275, L314", observation: "syncLevel calls qualify, which observes. On a pool with no history the call sets startedAt to the current time at the launch tick. Readiness is measured from startedAt."}
  match_type: mismatch
  confidence: 0.90
  reasoning: |
    LiveCalculator.sol:L273-L275: `if (oracle_.startedAt == 0) { oracle_.startedAt = timestamp; }` runs for any hook-originated call,
    and DicesHook.syncLevel is open to anyone for any launched coin (L408-L417). test/DicesHookLive.t.sol:L367-L373 shows
    syncLevel reaching qualify on a pool with no prior swap (stub calculator). So the clock can start at launch. The window still has to
    average the level-one tick, and the time before the first trade counts at the launch tick (-389,228), so an early
    unlock needs a higher price for the rest of the window (Appendix D): traded for half the window -> average cap
    must be about $3.2M (about $155k of USDC in the pool instead of $35k); traded for three quarters -> about $504k
    (about $58.5k). The property that does hold: no level within 24 to 25 hours of the first observation.
    Separately, syncLevel never "does nothing": every call writes the oracle slot and any due checkpoints.
  exploitability: "A buyer with more capital can take a coin Live sooner after its first trade than the document says (for example 12 hours after, at about 4.4 times the capital). No funds are at risk; the stated timing guarantee is what fails."
  remediation: "Either start the history only in _afterSwap (have syncLevel skip pools whose oracle has not started), or change the three sentences to 'first observation'. Test: createCoin, syncLevel, warp, first trade, assert the earliest unlock time."
- id: DIV-12
  severity: LOW
  title: "qualifiedHolders() is min(count before this block's first change, count now)"
  spec_claim:
    - {excerpt: "`qualifiedHolders()` leaves out holders that crossed the threshold in the current block.", source: "AGENT.md section 3, Qualifying holders (named current)"}
    - {excerpt: "ignores wallets that only reached the balance in the current block", source: "README.md, summary bullet 3"}
    - {excerpt: "A holder that crossed the threshold in this block is therefore not reported until the next block", source: "NatSpec, src/DicesCoin.sol:L163-L164"}
  code_finding: {file: "src/DicesCoin.sol", lines: "L168-L175, L215-L223", observation: "Returns _holdersBefore when the count changed this block and rose; otherwise _holders."}
  match_type: code_weaker_than_spec
  confidence: 0.90
  reasoning: "Counter-example to the literal sentence: 160 holders; in one block 20 drop below the threshold and 10 new wallets cross it. _holdersBefore = 160, _holders = 150, the function returns 150, which includes the 10 that crossed in this block. The purpose is intact: the result never exceeds the count before the block, so a count cannot be raised with coins borrowed inside one transaction (the code comment at L169 says exactly this)."
  exploitability: "None found. Same-block joiners can only offset same-block leavers, up to a level the coin already supported when the block began."
  remediation: "Reword the three sentences to 'reports the lower of the count now and the count before this block's first change'."
- id: DIV-13
  severity: LOW
  title: "Calculator trust boundary: the try covers reverts only; level bound and calculator identity are unchecked"
  spec_claim:
    - {excerpt: "The hook calls `qualify` in a `try`. A reverting calculator leaves the level as it is and never blocks a swap.", source: "AGENT.md section 3, Live and game levels, Fail-safe (named current)"}
    - {excerpt: "a fault in the calculator must never block a swap", source: "NatSpec, src/DicesHook.sol:L434-L435"}
    - {excerpt: "Always deploy a fresh Live calculator for a replacement, constructed with this hook's address", source: "AGENT.md section 3, Contracts"}
  code_finding: {file: "src/DicesHook.sol", lines: "L436-L448, L832-L838", observation: "try/catch around an external call returning uint8; setter checks code length only."}
  match_type: code_weaker_than_spec
  confidence: 0.80
  reasoning: "Reverts are caught (L448). Not covered: (a) return data that does not decode as uint8 reverts in the hook, outside the catch; (b) a calculator that burns all forwarded gas leaves one sixty-fourth, which is not enough to finish afterSwap, so the swap fails; (c) any level above 10 is stored (L438-L439), contradicting 'a level from 0 to 10'; (d) nothing checks ILiveCalculator(_calculator).dicesHook() == address(this) or that the calculator is fresh, so the 'always deploy a fresh one' rule is operator discipline. (a) and (b) are behaviour of the Solidity try statement and the 63/64 rule, not something the repository states; confidence is reduced accordingly. A caught revert also drops that swap's observation, so 'the history is exact' holds only while qualify succeeds."
  exploitability: "Owner only (setLiveCalculator). A wrong calculator can stop all trading or unlock every level for good."
  remediation: "In _setLiveCalculator require dicesHook() == address(this); bound the level; consider a low-level staticcall-style wrapper with explicit return-length handling and a gas stipend. Reword 'never blocks a swap' to 'a calculator that reverts'."
- id: DIV-14
  severity: LOW
  title: "createCoin validates nothing about the creator"
  spec_claim:
    - {excerpt: "Validate the creator split, collect the optional ETH creation fee.", source: "AGENT.md section 3, Launch, step 1"}
  code_finding: {file: "src/DicesHook.sol; src/core/FeeEscrow.sol; src/core/InternalSwapPool.sol", lines: "DicesHook L574, L480, L739; FeeEscrow L36-L38; InternalSwapPool L274, L295", observation: "params.creator is stored unchecked. There is no creator split to validate (the share is a calculator constant)."}
  match_type: missing_in_code
  confidence: 0.88
  reasoning: "With creator == address(0): any swap whose fee is in USDC and whose creator share is at least one unit (fee >= 4 units, that is a USDC leg of 320 units or more before Live) reaches FeeEscrow.deposit(address(0), ...) and reverts InvalidBeneficiary. The same happens when the swap pool converts queued coin fees. Net effect for that coin: exact-in sells and exact-out buys revert; exact-in buys revert once a later buy sells queued inventory through the JIT position; exact-out sells still work. No test covers a zero creator (grep 'creator: address(0)' in test/: 0 hits). The constructor likewise does not check _buyAndBurnRecipient (L218); V001 does (L324)."
  exploitability: "Self-inflicted by whoever launches the coin; the first buyer of such a coin can exit only through an exact-out sell. No effect on other pools."
  remediation: "Revert with ZeroAddress when params.creator is zero; check _buyAndBurnRecipient in the constructor. Remove 'Validate the creator split' from step 1 or say what is validated."
- id: DIV-15
  severity: LOW
  title: "Stale architecture and configuration text"
  spec_claim:
    - {excerpt: "Launch, two positions, USDC fee capture, raised/wallet tracking, Live transition, ledgers, claims, owner config", source: "AGENT.md section 3, Contracts table"}
    - {excerpt: "1e9 supply, start tick -398400 ~ $5k FDV, sale range to -375360 ~10x, 50% in the sale position, reserve target $10k, min qualifying buy $25, creator share 50% of the base fee", source: "AGENT.md section 3, Configuration"}
    - {excerpt: "Net raised, not gross volume: wash trading cannot inflate it; it is literally the USDC backing the positions.", source: "AGENT.md section 4"}
  code_finding: {file: "src/", lines: "DicesHook L71-L95; FeeCalculator L23-L63; src/core/*", observation: "No raised or wallet tracking, no hook ledgers or claims; launch at $12,500, sale end -361,500, 70% sale share, creator 30%. core/InternalSwapPool.sol, core/FeeEscrow.sol, core/TrustedRouters.sol, libraries/CurrencySettler.sol and six interfaces are missing from the table."}
  match_type: mismatch
  confidence: 0.95
  reasoning: "The Configuration numbers are self-consistent (tick -398,400 is $4,995 and -375,360 is 10.01 times that, Appendix D) but describe a curve the code does not have, and contradict Launch step 5 in the same document. 'Net raised' explains a quantity that the level rule no longer uses."
  exploitability: "None."
  remediation: "Rewrite the Contracts table, delete Configuration or replace it with the constants, delete the 'Net raised' bullet."
- id: DIV-16
  severity: LOW
  title: "Deferred components are absent, as section 1 says"
  spec_claim:
    - {excerpt: "the game is revealed, wagering opens", source: "AGENT.md section 2, Product"}
    - {excerpt: "Profits above each ledger's high-water mark are distributed 40% platform, 30% holders ..., 15% creator, 15% players as rakeback.", source: "AGENT.md section 2, Casino economics"}
    - {excerpt: "Treasury is a Safe secured by a 48-hour timelock.", source: "AGENT.md section 2, Governance"}
  code_finding: {file: "src/; script/deployment/V001.s.sol", lines: "DicesHook L199 (Ownable); V001 L131, L145, L306", observation: "No casino, treasury or timelock code. The hook owner is whatever address V001 resolves; with PROTOCOL_OWNER unset the deployer keeps ownership on any chain, mainnet included."}
  match_type: missing_in_code
  confidence: 0.88
  reasoning: "Recorded for completeness: section 1 defers these. The one consequence inside the current scope is that owner powers (section 11) are exercised by a single key with single-step transfer until the timelock exists."
  exploitability: "See DIV-03 for what the owner key can do."
  remediation: "Make V001 refuse a mainnet run with PROTOCOL_OWNER unset, as it already does for the recipients and the bankroll."
- id: DIV-17
  severity: LOW
  title: "NatSpec and comment drift inside the code; bankroll check narrower than stated"
  spec_claim:
    - {excerpt: "Fees, reserves and the raised total are in this currency", source: "NatSpec, src/DicesHook.sol:L108"}
    - {excerpt: "Mark the pool before external calls so BuyAndBurn cannot process after a swap in this block.", source: "Comment, src/DicesHook.sol:L338"}
    - {excerpt: "@notice The hook's own swaps.", source: "NatSpec, src/DicesHook.sol:L361"}
    - {excerpt: "@param _amount The amount of USDC being swapped. ... Calculate the fee that will be sent to the holders", source: "NatSpec and comment, src/calculators/FeeCalculator.sol:L79, L89"}
    - {excerpt: "External pool-token registry lookup API.", source: "NatSpec, src/interfaces/IFlaunch.sol:L7"}
    - {excerpt: "A bankroll that is one of the launchpad contracts is rejected before broadcasting.", source: "AGENT.md section 3, Deployment"}
  code_finding: {file: "src/DicesHook.sol; src/calculators/FeeCalculator.sol; src/interfaces/IFlaunch.sol; script/deployment/V001.s.sol", lines: "DicesHook L108, L185, L339, L361, L372; FeeCalculator L79-L90; IFlaunch L9-L16; V001 L333-L336", observation: "Fees can be in the coin and there are no reserves or raised total. lastSwapBlock is written on every swap and read nowhere in src/; no BuyAndBurn contract exists. _afterSwap is the afterSwap callback, and the hook must never swap. getFeeDistribution receives the collected fee, in either currency, and its third output goes to the buy-and-burn recipient. IFlaunch has no user. _requireSeparateBankroll checks hook, PoolManager, swap pool, escrow and coin implementation, but not the two calculators or the UniswapEvents library."}
  match_type: mismatch
  confidence: 0.90
  reasoning: "Each item is a sentence in the code's own documentation that the adjacent code contradicts or that refers to something absent. The bankroll item is a narrower check than the sentence promises (code_weaker_than_spec for SPEC-119): coins paid to a calculator or to the library address could not be moved again."
  exploitability: "None. lastSwapBlock costs a storage write per swap for a consumer that is not in the repository."
  remediation: "Correct the six sentences; remove IFlaunch and, unless an external consumer exists, lastSwapBlock; extend _requireSeparateBankroll to every predicted address."
```

---
## 7. Missing Invariants

| # | Invariant stated in the corpus | Enforced in code? | Evidence | Finding |
| --- | --- | --- | --- | --- |
| 1 | "hook's USDC ERC-6909 balance == sum of all claimable fees + all reserves + all race pools" (`A` 3 Ledgers) | No such balance exists. Replacement that is enforced: escrow balance >= sum of credits per currency | `ESC:L60-L71`, `ESC:L104-L117` | DIV-09 |
| 2 | "The reserve is capped at its target ... `reserveTargetReached` is set permanently" | Absent | grep, 0 hits | DIV-01 |
| 3 | "changing defaults can never alter a coin that already launched" | Not enforced for fee rate, split, platform and buy-and-burn recipients | `H:L462,L478,L752-L799` | DIV-03 |
| 4 | "Every pool has a level from 0 to 10" | Upper bound relies on the calculator; the hook stores any `uint8` | `H:L438-L439` | DIV-13 |
| 5 | "`beforeRemoveLiquidity` rejects everyone" | Replaced by "only the swap pool, and only its own position" | `H:L303`; `Pool.sol:L187` | DIV-07 |
| 6 | "no level ... in a pool's first 24 hours of trading" | Enforced from the first observation, not the first trade | `LC:L273-L275,L314` | DIV-11 |
| 7 | "Always deploy a fresh Live calculator ... constructed with this hook's address" | Not checked on `setLiveCalculator` | `H:L832-L838` | DIV-13 |
| 8 | "All critical financial operations are enforced on-chain with caps" | No cap on fee rate, split or `createFee` | `H:L462,L784` | DIV-03 |
| 9 | "Validate the creator split" | No creator validation at all | `H:L574` | DIV-14 |
| 10 | "Supply is fixed at 1e9" (basis of "market cap is a tick check") | `burn` reduces `totalSupply`; the calculator keeps using 1e27 | `C:L182-L184`, `LC:L94` | AMB-03 |
| 11 | Fee split sums to the fee (implied by "split") | True for the default calculator; not enforced by the hook | `FC:L93`; `H:L478-L481` | DIV-03 |

Invariants that are stated and enforced: level monotonicity (`H:L438`), hook-only `qualify` (`LC:L407`), hook-only swap-pool entry points (`ISP:L353`), third parties cannot initialise or add liquidity (`H:L256,L291`), no negative liquidity delta in the hook (`H:L715`), same-block holder counts cannot exceed the count at the start of the block (`C:L170-L172`), escrow credits are fully funded (`ESC:L65-L67`), `initialize` once (`C:L125-L127`).

---

## 8. Incorrect Logic

Items where the code contradicts a stated intent or its own documentation, as opposed to text that is simply out of date:

| # | Location | What is wrong | Finding |
| --- | --- | --- | --- |
| 1 | `ISP:L75,L265` vs `H:L752-L754` | Two calculator references, one replaceable and one not; they diverge after the documented replacement | DIV-04 |
| 2 | `H:L328-L336` | Comment says creator exception; code checks the router allowlist; the allowlist is the public router | DIV-06 |
| 3 | `H:L408-L417` with `LC:L273-L275` | A public call starts a pool's price history before any trade | DIV-11 |
| 4 | `H:L574` with `ESC:L36-L38` | Zero creator accepted at launch, rejected at every later USDC credit | DIV-14 |
| 5 | `H:L185,L339` | `lastSwapBlock` written every swap for a reader that does not exist in the repository | DIV-17, UCP-05 |
| 6 | `H:L260-L279` | Unreachable in production: the PoolManager skips `beforeInitialize` when the hook initialises, and any other sender reverts at `L257` | UCP-15 |
| 7 | `H:L350,L373` with `ISP:L146,L226` | The swapper is resolved with a `staticcall` to the trusted router twice per swap and the result is discarded | UCP-14 |
| 8 | `ISP:L90,L155` | "worth interacting with" threshold is 1e6 wei of an 18-decimal coin (1e-12 coin) | AMB-08 |

No logic error was found in the TWAP accumulator, the checkpoint indexing, the holder count or the launch-position construction. The checkpoint reasoning: a window opens on hour `H = period - 24`; when `H*3600 < observedAt` the slot `H % 25` was written by the first observation at or after hour `H` (`LC:L283-L287`), is not skipped by the long-silence branch (which skips hours at or below `q - 25` for an observation in hour `q <= period`), and cannot yet have been overwritten by hour `H + 25 = period + 1`; otherwise the opening value is extrapolated at the last tick (`LC:L322`). Readiness requires `H > startedAt / 3600` (`LC:L314`), so the never-written start hour is never read.

---

## 9. Math Inconsistencies

### 9.1 Constants verified by arithmetic

Method: Appendix D. Prices are raw units: USDC has 6 decimals, the coin 18, supply 1e27 units, so `market cap (raw USDC) = price x 1e27` and `price = 1.0001^tick` for a coin that is currency0.

**Level ticks** (`LC:L219-L242`). `T = ceil( ln(target x 1e6 / 1e27) / ln(1.0001) )`, confirmed with exact integers (`1e27 x 10000^n >= target_raw x 10001^n` at `n = -T`, false at `n = -T + 1`) and with the contract's own arithmetic (`mulDiv(mulDiv(s, s, 2^96), 1e27, 2^96)`, `s = getSqrtPriceAtTick(T)`).

| Level | Target | Real-valued tick | ceil | Code | Cap at code tick | Cap one tick lower | Result |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 1 | $200,000 | -361,500.2169 | -361,500 | -361,500 | $200,004.34 | $199,984.34 | match |
| 2 | $400,000 | -354,568.3985 | -354,568 | -354,568 | $400,015.94 | $399,975.94 | match |
| 3 | $800,000 | -347,636.5801 | -347,636 | -347,636 | $800,046.41 | $799,966.41 | match |
| 4 | $1,600,000 | -340,704.7618 | -340,704 | -340,704 | $1,600,121.88 | $1,599,961.88 | match |
| 5 | $3,200,000 | -333,772.9434 | -333,772 | -333,772 | $3,200,301.88 | $3,199,981.88 | match |
| 6 | $6,400,000 | -326,841.1250 | -326,841 | -326,841 | $6,400,080.00 | $6,399,440.06 | match |
| 7 | $12,800,000 | -319,909.3066 | -319,909 | -319,909 | $12,800,392.48 | $12,799,112.57 | match |
| 8 | $25,600,000 | -312,977.4883 | -312,977 | -312,977 | $25,601,249.93 | $25,598,690.06 | match |
| 9 | $51,000,000 | -306,084.8108 | -306,084 | -306,084 | $51,004,135.26 | $50,999,035.35 | match |
| 10 | $102,000,000 | -299,152.9925 | -299,152 | -299,152 | $102,010,123.18 | $101,999,923.19 | match |

Both orderings: the calculator compares a coin tick. For a coin that is currency0 the coin tick is the pool tick `t`, so level `k` needs `t >= T_k`. For a coin that is currency1 the coin tick is `-t - 1` (`LC:L160`), so level `k` needs `t <= -T_k - 1`; at `t = -T_k - 1` the pool price (coin per USDC) lies in `[1.0001^(-T_k-1), 1.0001^(-T_k))`, so USDC per coin lies in `(1.0001^T_k, 1.0001^(T_k+1)]` and the cap in `(cap(T_k), cap(T_k + 1)]`, for level 1 `($200,004.34, $200,024.34]`. The target is met in both orderings; the currency1 ordering is stricter by at most the exact boundary price. At launch both orderings give coin tick -389,228 (pool tick -389,228, and `-(389,227) - 1`).

**Other constants**

| Claim | Source | Arithmetic | Result |
| --- | --- | --- | --- |
| Supply 1e9, split 70 / 20 / 10 | `A` 3 Launch; `H:L71-L86` | 7e26 + 2e26 + 1e26 = 1e27 | match |
| Launch sqrt price, coin currency0 | `FC:L55` | `isqrt(12_500e6 x 2^192 / 1e27)` = 280113854873930699593; `s^2 x 1e27 <= 12_500e6 x 2^192 < (s+1)^2 x 1e27` | exact match |
| Launch sqrt price, coin currency1 | `FC:L63` | `isqrt(1e27 x 2^192 / 12_500e6)` = 22409108389914455967492775290983268704, same bracket test | exact match |
| Launch FDV $12.5k | `A`, `R`, `FC:L47` | cap at the stated sqrt price = $12,499.999999 | match |
| Aligned launch tick | `H:L670-L684` | pool tick -389,228 (coin0) / 389,227 (coin1); aligned to -389,220 / 389,220; launch price lies outside the range on the correct side in both orderings | match |
| Sale end $200k | `H:L95` | -361,500 = level-1 tick; multiple of 60 | match |
| Position ranges | `H:L645-L653` | coin0: [-389,220, -361,500) and [-361,500, 887,220]; coin1: [361,500, 389,220] and [-887,220, 361,500] | mirrored, match |
| Raise about $35,013 | `A` 3 Launch step 5 | `getAmount1Delta(sqrtA, sqrtB, L)` with `L = getLiquidityForAmount0(sqrtA, sqrtB, 7e26)` = $35,013.49; coin1 ordering $35,013.49; closed form `7e26 x 1.0001^(-375,360) / 1e6` = $35,013.49 | match |
| Launch dust | `H:L613` | coin0: 126,586,497,862,990 wei; coin1: 79,730,978 wei left in the hook | consistent with NatSpec |
| Bankroll sale | `A` 3 Bankroll | 1e26 coins sold from the sale-end price: gross $14,002.34, net of 1.25% $13,827.31, cap after $98,030.64, USDC left $21,011.15 | match ("about $13.8k", "about $98k") |
| Holder threshold | `C:L32` | 300,000 / 1e9 x $200,000 = $60 | match |
| 150 holders | `A` 4, 5 | 150 x 300,000 = 45,000,000 coins = 4.5% x $200,000 = $9,000 | match |
| Spike | `A` 3 Live | (887,272 + 361,500) x 2 s / 86,400 s = 28.9 ticks; 1.0001^29 = 1.0029 | match ("about 29 ticks, or 0.3%") |
| Geometric mean example | `A` 3 Live | sqrt(300,000 x 500,000) = $387,298 | match |
| Fee rates | `FC:L18-L38` | 1,250 / 100,000 = 1.25%; 1,000 / 100,000 = 1.00% | match |
| Window | `LC:L320-L326` | `now - (floor(now/3600) - 24) x 3600` is in [86,400, 90,000) seconds | match (24 to 25 hours) |
| Checkpoints | `LC:L89,L120` | 25 `int56` at 4 per 256-bit slot = 7 slots; oracle struct 32 + 32 + 24 + 56 = 144 bits = 1 slot | match |
| 56-bit bound | `LC:L398` | 887,273 x 2^32 = 3.81e15 < 2^55 = 3.60e16 | match |
| Hook flags | `H:L236-L243`; `V:L120` | 2^13 + 2^11 + 2^9 + 2^7 + 2^6 + 2^2 = 10,948 = 0x2AC4; one address in 2^14 matches | match |
| Gas figures | `A` 3 Live | none possible without execution | stated, not verified |

### 9.2 Inconsistencies

| # | Spec | Code | Difference | Finding |
| --- | --- | --- | --- | --- |
| 1 | Pre-Live buy 1.25% + 0.50% = 1.75% | 1.25% | -0.50 points; $5,000 per $1M of buys | DIV-01 |
| 2 | Post-Live buy 1.00% + 0.50% (or + 0.25%) | 1.00% | -0.50 or -0.25 points | DIV-01 |
| 3 | Split platform / creator, placeholder 50 / 50 | 40 / 30 / 30 with buy and burn | creator -20 points, platform -10 points, new recipient +30 points | DIV-02 |
| 4 | "rate x gross USDC moved" | `mulDiv(|unspecified delta|, rate, 100_000)`, rounded down, in coin or USDC | Different base for two of four swap modes | DIV-08 |
| 5 | Start tick -398,400 (~$5k), sale to -375,360, 50% sale share | $12,500 (tick -389,228), sale to -361,500, 70% | Stale placeholders; -398,400 is $4,995.43 and -375,360 is $50,019.27 | DIV-15 |
| 6 | "doubling up to $102,000,000" (`LC:L21`) | $51M and $102M are 1.9922x and 2x of their predecessors; tick steps 6,893 and 6,932 against 6,931.8 for a doubling | Wording; figures follow open question 8 | note under SPEC-183 |
| 7 | "about $35,000" / "$35,013" raised | $35,013.49 enters the pool; a buyer pays more because fees and JIT purchases come on top | Not an error; the figure is pool USDC, not buyer outlay | none |
| 8 | Market cap "of the coin" | `price x 1e27` whatever `totalSupply()` is after burns | Overstates after any burn | AMB-03 |

Rounding: `_average` floors negative averages (`LC:L330-L333`), `mulDiv` in `_swapFee` and `getFeeDistribution` rounds down with the platform taking the remainder (`FC:L93`), liquidity is rounded down and the coin debit up (launch dust). No rounding direction was found that favours a caller.

---

## 10. Flow and State Machine Mismatches

**Launch.**

| Spec step (`A` 3 Launch) | Code | Status |
| --- | --- | --- |
| 1. Validate the creator split | no validation | missing (DIV-14) |
| 1. Collect the optional ETH creation fee | `H:L535-L547`, credited to `feeRecipient` in escrow | match |
| 2. Clone, mint to hook, 10% to bankroll | `H:L551-L558` | match |
| 3. Build the pool key | `H:L561-L564` | match |
| 4. Snapshot `PoolConfig`; store creator config and `gameCommitment` | stores `poolKeys`, `poolCoins`, `poolCreators` | partly missing (DIV-03, DIV-05) |
| 5. `unlock`: initialise, two positions | `H:L577`, `H:L587-L618` | match |
| not in spec | `launchBlock` recorded, `PoolCreated` and `PoolStateUpdated` emitted, `whenNotPaused` | undocumented (UCP-04, UCP-06) |
| 6. Emit `CoinCreated` | none | missing (DIV-10) |

**Swap fee flow.** Spec: `beforeSwap` caches rates in transient storage and charges USDC on the specified side for two modes; `afterSwap` charges USDC on the unspecified side for the other two; USDC is split platform / creator / reserve / race and held as ERC-6909 claims. Code: `beforeSwap` checks the launch block, writes `lastSwapBlock`, may add a JIT position; `afterSwap` removes it and credits its USDC proceeds, charges the unspecified currency, queues coin fees or credits USDC fees three ways in `FeeEscrow`, syncs the level, emits events. Mismatch in currency, split, custody and timing (DIV-01, 02, 08, 09).

**Live state machine.** Spec and code agree: `level` in 0..10, transitions only upward, triggered by a swap or by `syncLevel`, decided by the calculator from a 24 to 25 hour tick average and the holder count; `PoolLive` on leaving 0, one `PoolLevelUnlocked` per rise; the fee rate switches at level 1 and the triggering swap pays the old rate. Two deviations: the start of the 24 hours (DIV-11) and what happens when the calculator misbehaves without reverting (DIV-13). The superseded trigger ($35,000 raised and 150 wallets that bought) is not implemented, as section 2 intends.

**Claim flow.** Spec: recipient calls `claimFees()` on the hook, which burns ERC-6909 and pays USDC. Code: anyone calls `FeeEscrow.claim({beneficiary, currency})` or `claimBatch`; the escrow pays the beneficiary (DIV-09).

**Reserve flow.** Spec: fill to target, overshoot to race pool, sticky flag, controller-gated withdraw and deposit. Code: none (DIV-01).

---

## 11. Access Control Drift

| Actor in the corpus | Stated powers | Code | Drift |
| --- | --- | --- | --- |
| Owner | "owner config"; replace calculators; set launch defaults that are snapshotted per pool | Everything in the section 4 table of this report: calculators, recipients, creation fee, coin implementation, trusted routers, pause, ownership | Powers reach launched pools (DIV-03); `pause`, `setBuyAndBurnRecipient`, `renounceOwnership` are not in `A` or `R` |
| Treasury Safe + 48h `TimelockController` as `feeRecipient` and owner | Deferred | `Ownable` single step; V001 leaves the deployer as owner when `PROTOCOL_OWNER` is zero, on mainnet too (`V:L131,L306`) | Deferred (DIV-16); mainnet run is refused for unset recipients and bankroll but not for an unset owner |
| `reserveController` | Only it may `withdrawReserve`, `withdrawRacePool`, `depositReserve` | Does not exist | DIV-01 |
| Fee recipients | Withdraw their own fees with `claimFees()` | Anyone can trigger payment to them; they cannot redirect it | DIV-09 |
| Liquidity providers | Hook only; nobody may remove | Hook and swap pool may add; swap pool may remove its own | DIV-07 |
| Routers | Any `IMsgSender` router works; trusted routers give attribution | Trusted routers additionally hold the right to swap in a pool's launch block | DIV-06 |
| `qualify` caller | Hook only | Hook only (`LC:L407`) | none |
| `syncLevel` caller | Anyone | Anyone (`H:L408`); also able to start a pool's history | DIV-11 |
| Bankroll | Unrestricted address, excluded from the holder count | Same (`C:L60,L248`) | none |
| Coin `initialize` | "`initialize` once" | Once, with no caller restriction; safe for clones because the hook initialises in the creating transaction (`H:L551-L554`); the implementation contract itself can be initialised by anyone | UCP-22 |

---

## 12. Undocumented Behavior

Code paths that `AGENT.md` and `README.md` do not describe (classification: UNDOCUMENTED CODE PATH). Several are described in NatSpec only.

| ID | Behaviour | Evidence |
| --- | --- | --- |
| UCP-01 | `InternalSwapPool`: coin-denominated fees are queued per coin and sold to later buyers through a single-tick-spacing JIT position added in `beforeSwap` and removed in `afterSwap`; USDC proceeds are split like fees | `ISP:L127-L279`; `H:L350,L373,L475-L476` |
| UCP-02 | `FeeEscrow`: permissionless funded credits per beneficiary and currency, native currency supported, payment can be triggered by anyone | `ESC:L34-L120` |
| UCP-03 | `buyAndBurnRecipient` receives 30% of fees; owner-settable | `H:L140,L218,L481,L770-L776`; `FC:L28` |
| UCP-04 | Launch-block rule: only trusted routers may swap in the block a pool is created; `trustedRouters` therefore has two meanings | `H:L334-L336` |
| UCP-05 | `lastSwapBlock[poolId]` written on every swap, read nowhere in `src/` | `H:L185,L339` |
| UCP-06 | `Pausable`: the owner can stop `createCoin`; trading is unaffected | `H:L533,L843-L852` |
| UCP-07 | `Ownable`: single-step `transferOwnership` and `renounceOwnership` are exposed | OpenZeppelin `Ownable.sol:L76,L84` |
| UCP-08 | `HookSwap` and `HookFee` are the swap events actually emitted; `PoolSwap`, `PoolLiquidityDelta`, `PoolDonation` are declared and unused | `UE:L26-L53,L79-L117` |
| UCP-09 | Liquidity-rounding dust of each launch stays in the hook permanently | `H:L613-L614` |
| UCP-10 | Every coin gives Permit2 an infinite allowance over every holder (solady default) | solady `ERC20.sol:L122-L125,L667-L669`; not overridden in `C` |
| UCP-11 | `DicesCoin.burn` is callable by any holder now; the document files it under "later phases" | `C:L182-L184` |
| UCP-12 | `IFlaunch` interface with no user | `src/interfaces/IFlaunch.sol` |
| UCP-13 | `InternalSwapPool` settles through `@uniswap/v4-core/test/utils/CurrencySettler.sol`, an upstream test utility that calls `transfer` / `transferFrom` without checking the return value, while `src/libraries/CurrencySettler.sol` (SafeERC20) exists and is used by the hook | `ISP:L9,L258,L262` |
| UCP-14 | `_getSender` performs a `staticcall` to the trusted router in `beforeSwap` and again in `afterSwap`; the swap pool ignores the result | `H:L350,L373`; `TR:L44`; `ISP:L146,L226` |
| UCP-15 | `_beforeInitialize` after `L258` cannot execute in production | `H:L260-L279`; `Hooks.sol:L171-L181` |
| UCP-16 | JIT minimum inventory is 1e6 wei of the coin | `ISP:L90` |
| UCP-17 | No donate hooks: anyone can donate to a pool; the hook has no way to collect what accrues to its positions | `H:L236-L243` |
| UCP-18 | The hook trusts calculator outputs: rate, split sum, launch price (bounded only by `InvalidLaunchPrice`), level | `H:L462,L478,L595,L641,L438` |
| UCP-19 | The creation fee is held as a native-currency escrow credit for `feeRecipient` | `H:L542,L736` |
| UCP-20 | `syncLevel` writes price history on every call | `LC:L266-L295` |
| UCP-21 | V001 keeps the deployer as hook owner when `PROTOCOL_OWNER` is zero, including on mainnet; salt mining starts at attempt 160,444 | `V:L113-L114,L306` |
| UCP-22 | `DicesCoin.initialize` has no caller restriction; the implementation contract can be initialised by anyone | `C:L123-L138` |
| UCP-23 | A price with no liquidity behind it can be crossed for free on the downside (before the first buy or after USDC is drained); the swap pool guards its JIT against this, the TWAP records it | `ISP:L156-L161`; `H:L633-L655` |

---

## 13. Ambiguity Hotspots

**In the specification**

| ID | Text | Why it is ambiguous | Affects |
| --- | --- | --- | --- |
| AMB-01 | Reserve surcharge: required in `A` 2 and `R`, described in subsections the note calls stale | Not stated whether the reserve was dropped or is still owed | DIV-01 |
| AMB-02 | "split not given"; placeholder 50/50; code 40/30/30 | No document states the intended split or the third recipient | DIV-02 |
| AMB-03 | "Fixed-supply", "Supply is fixed at 1e9", "market cap" | `burn` exists; market cap by tick is price x 1e27 and includes unsold pool coins and the bankroll (an FDV) | SPEC-094 |
| AMB-04 | "first 24 hours of trading", "first trade", "first observation" used as synonyms | They differ once `syncLevel` exists | DIV-11 |
| AMB-05 | "150 qualified wallets have bought" (brief) vs holders by balance (open question 5) | Awaiting client confirmation; code follows the balance reading | SPEC-131 |
| AMB-06 | The 2026-11-05 note names four stale subsections | Status of Principle, component table, Launch steps 1, 4, 6, Indexer events, section 4 is unstated | SPEC-047 |
| AMB-07 | "needs no price maths or iteration per swap" | `_levelAt` and `_observe` contain bounded loops (at most 10 and 25 steps); whether that is "iteration" is undefined | SPEC-126 |
| AMB-08 | "fees ... worth interacting with" | The threshold is 1e-12 coin | SPEC-196 |
| AMB-09 | "Prevents 0-block buys ... unless token creator" vs "Only approved launching routers" | Two different rules in adjacent comments | DIV-06 |
| AMB-10 | "All critical financial operations are enforced on-chain with caps" | Neither the operations nor the caps are listed; the treasury is deferred but this sentence is not | DIV-03 |
| AMB-11 | "locks all liquidity permanently" | 90% of supply is locked liquidity; 10% goes to an unrestricted bankroll (open question 10) | SPEC-003 |
| AMB-12 | Scope word "ledgers" | Could mean the reserve ledgers or fee credits | SPEC-002 |
| AMB-13 | $51M and $102M vs doubling | Open question 8; code uses the listed figures | SPEC-132 |
| AMB-14 | `trustedRouters`: "trusted for wallet attribution" | Also the launch-block allowlist | DIV-06 |
| AMB-15 | Gas figures | Cannot be checked without execution | SPEC-111 |

**Contradictions inside the corpus**

1. `A` 3 Fees table needs `beforeSwapReturnDelta`; `A` 3 Hook address flags (and the code) do not have it.
2. `A` 3 Configuration (-398,400, 50%, creator 50%) vs `A` 3 Launch step 5 ($12.5k, 70 / 20 / 10).
3. `A` 3 Principle "only liquidity provider" vs `A` 3 Qualifying holders, which names the InternalSwapPool.
4. `A` 3 Lock guarantees vs NatSpec `H:L299-L300`.
5. `R` "Every fee is charged in USDC" vs NatSpec `H:L46-L47` "Collects hook fees in the unspecified swap currency".
6. `A` / `R` two-way split vs NatSpec `FC:L21-L28` and the V001 header (three recipients).
7. `A` / `R` "owner-replaceable" vs NatSpec `IInternalSwapPool.sol:L47-L49` "fixed at construction".
8. `A` 3 Indexer events `PoolSwap` vs NatSpec `UE:L19-L26` `HookSwap`; `IUniswapEvents.sol:L39` says `PoolSwap` is "emitted directly by DicesHook".
9. `H:L328` vs `H:L332` (AMB-09).
10. `R` uses keystore name `deployer`; the V001 header uses `dices_deployer`.
11. `A` 3 Indexer events refers to `_launch` and `afterAddLiquidity`; neither exists in the hook.

**In the code**

- `H:L460`: `params.amountSpecified < 0 == params.zeroForOne` relies on operator precedence (`<` before `==`); correct, easy to misread.
- `LC:L74`: `WINDOW` is exposed but the computation uses `PERIODS x PERIOD`; equal today, not tied together.
- `C:L18`: `DicesCoin` does not inherit `IDicesCoin`, so ABI agreement is by convention.

---

## 14. Recommended Remediations

Ordered by how much they reduce the distance between what is promised and what is deployed.

| Priority | Action | Findings |
| --- | --- | --- |
| 1 | Decide with the client whether the reserve surcharge and ledgers are still required; implement or strike them from `A` 2 and `R` | DIV-01 |
| 2 | Bound calculator outputs in the hook (rate, split sum, level) or snapshot per pool; cap `createFee`; `Ownable2Step`; refuse a mainnet deployment with no `PROTOCOL_OWNER` | DIV-03, DIV-13, DIV-16 |
| 3 | Make the swap pool read `dicesHook.feeCalculator()` | DIV-04 |
| 4 | Settle the fee split and document the buy-and-burn recipient | DIV-02 |
| 5 | Decide the launch-block rule; separate it from the attribution allowlist | DIV-06 |
| 6 | Add `gameCommitment` (and a `CoinCreated` event) or defer it explicitly | DIV-05, DIV-10 |
| 7 | Reject a zero creator in `createCoin`; check `_buyAndBurnRecipient` in the constructor | DIV-14 |
| 8 | Start price history only from a swap, or reword the 24-hour statements | DIV-11 |
| 9 | Replace the upstream test `CurrencySettler` import in `InternalSwapPool` with `src/libraries/CurrencySettler.sol`; remove `IFlaunch`, unused events and, if no consumer exists, `lastSwapBlock` | UCP-13, DIV-17 |
| 10 | Rewrite the stale parts of `AGENT.md` and `README.md` (section 15) | DIV-07 to DIV-10, DIV-12, DIV-15, DIV-17 |

Tests to add with these changes: zero-creator launch; calculator replacement followed by a converted coin fee; calculator returning an out-of-range rate, split or level; `createCoin` then `syncLevel` then first trade; launch-block buy by a non-creator through the trusted router; holder count with leavers and joiners in one block.

---

## 15. Documentation Update Suggestions

`AGENT.md`

- Section 2 component table: Locker (swap pool may remove its own JIT position), FeeVault (`FeeEscrow`), GameReserve (no ledgers exist), Parameter registry (constants, no `PoolConfig`); add InternalSwapPool and FeeEscrow rows.
- Section 2 Trading fees: state the implemented schedule and the three-way split, or mark the reserve rows "not implemented".
- Section 3 Principle: fees in the unspecified currency; two liquidity providers; escrow credits instead of ERC-6909.
- Section 3 Contracts table: add `core/InternalSwapPool.sol`, `core/FeeEscrow.sol`, `core/TrustedRouters.sol`, `libraries/CurrencySettler.sol`; correct the hook and fee calculator roles and the event names.
- Section 3 Launch: `CoinParams{name, symbol, creator}`; drop steps "validate the creator split", `PoolConfig`, `gameCommitment`, `CoinCreated` or mark them planned; add `launchBlock`, the launch-block rule and `whenNotPaused`; restate the lock guarantees as in DIV-07.
- Section 3 Fees and Ledgers: replace with the four-mode table in DIV-08, the JIT conversion, the escrow and its solvency invariant.
- Section 3 Qualifying holders: "reports the lower of the count now and the count before this block's first change".
- Section 3 Indexer events: `HookSwap`, `HookFee`, `PoolCreated`, `PoolStateUpdated`; `unlockCallback` instead of `_launch`.
- Section 3 Live and game levels: "first observation (a swap or a `syncLevel` call)"; "a calculator that reverts" in the fail-safe; say that the hook does not bound the level.
- Section 3 Configuration: delete or replace with the constants (`LAUNCH_SUPPLY`, `SALE_SUPPLY`, `UPPER_SUPPLY`, `BANKROLL_SUPPLY`, `SALE_END_TICK`, `LAUNCH_MARKET_CAP`).
- Section 4: remove or restate "Fees in USDC", "Net raised", "Per-pool config snapshot", "Sticky `reserveTargetReached`".
- Replace the 2026-11-05 note once the above is done; as written it under-reports.

`README.md`

- Bullet 2: fee currency, split, escrow and claim ABI; remove reserve, race pool, `reserveController`, ERC-6909, `claimFees()`.
- Bullet 4: say that a fee calculator replacement does not reach the swap pool (until DIV-04 is fixed).
- Deploy: mention that the bankroll is required too; align the keystore name with V001.

NatSpec: the six sentences in DIV-17; `H:L314,L328` after DIV-06 is decided; `IDicesHook.sol:L309` (`syncLevel` always writes history); `IUniswapEvents.sol:L39` and `UE:L41` (`PoolSwap`); `LC:L21` ("doubling").

---

## 16. Final Risk Assessment

| Area | Compliance | Basis |
| --- | --- | --- |
| Launch curve and supply distribution | High | Every constant reproduced; ranges mirrored correctly in both orderings |
| Game levels, TWAP, holder count | High | Rule, storage layout, window, ratchet, events and all twenty numbers match; three LOW deviations (DIV-11, 12, 13) |
| Liquidity lock | High in substance | Stated mechanism is out of date (DIV-07); the property holds |
| Deployment | High | CreateX path, flags, wiring checks and destination rules match; owner default on mainnet is the open point |
| Trading fees and fee custody | Low | Rate matches; reserve surcharge, split, currency, custody and claim ABI do not (DIV-01, 02, 08, 09) |
| Configuration and governance | Low | No snapshot, no caps, no timelock in scope (DIV-03, DIV-16) |
| Events and off-chain ABI | Low | Two documented events absent, two undocumented events emitted (DIV-10) |
| Casino, rewards, bridge, forwarder | Not applicable | Deferred by section 1 |

**Overall.** No divergence was found that lets an outside party take funds or remove launch liquidity. The material gaps are functional and trust related: a fee component the brief requires is missing (HIGH), the fee split has an undocumented beneficiary, the owner's reach over launched pools is wider than the documents say and is unbounded, a calculator replacement is only half effective, the launch-block guard and the game seal do not match their descriptions. The largest practical risk is documentary: `README.md` and half of `AGENT.md` describe a fee and ledger system that is not the one deployed, so anyone integrating from them (indexers, a GameReserve, a front end quoting fees, a creator estimating revenue) will be wrong.

**Not determined.** Gas figures (SPEC-111); any claim that needs execution (test and invariant outcomes, coverage, contract size, storage layout as compiled); behaviour of the Universal Router with the swap pool's sync requirement (SPEC-197); whether the original brief matches section 2; the Solidity `try` edge cases cited in DIV-13 (a) and (b), which rest on language semantics and were not exercised.

---
## Appendix A: Spec-IR

One record per extracted claim. `source_document`: `AGENT.md`, `README.md`, or the file that carries the NatSpec. Excerpts are verbatim; `...` marks an elision. `confidence` is the confidence that the normalized form captures the sentence.

```yaml
# AGENT.md section 1
- {id: SPEC-001, source_document: AGENT.md, source_section: "1. How to read this file", semantic_type: meta, spec_excerpt: "Treat the brief as a statement of required outputs: behaviours, numbers and events the system must produce. Do not treat its contract list, file structure or internal logic as a specification.", normalized_form: "section 2 is checked for outputs and numbers; sections 3-6 for architecture", confidence: 0.95}
- {id: SPEC-002, source_document: AGENT.md, source_section: "1. How to read this file", semantic_type: scope, spec_excerpt: "Current engagement scope: **launchpad core only** (coin creation, locked liquidity, fees, Live trigger, ledgers). Casino settlement, profit distribution, rewards, bridge, gasless forwarding and the treasury timelock are documented here as deferred", normalized_form: "in_scope = {creation, lock, fees, live, ledgers}; deferred = {casino, profits, rewards, bridge, forwarder, timelock}", confidence: 0.9}
# AGENT.md section 2, Product
- {id: SPEC-003, source_document: AGENT.md, source_section: "2. Product", semantic_type: flow, spec_excerpt: "**One transaction** creates the coin, locks all liquidity permanently in **two Uniswap v4 positions**, attaches the trading hook ...", normalized_form: "createCoin: atomic {deploy coin, init pool with hook, add 2 permanent positions}", confidence: 0.95}
- {id: SPEC-004, source_document: AGENT.md, source_section: "2. Product", semantic_type: flow, spec_excerpt: "... and registers a **sealed** casino game.", normalized_form: "createCoin stores a game commitment", confidence: 0.85}
- {id: SPEC-005, source_document: AGENT.md, source_section: "2. Product", semantic_type: flow, spec_excerpt: "Every buy adds liquidity (USDC flows into the pool) ...", normalized_form: "for all buys: USDC in -> pool reserves", confidence: 0.8}
- {id: SPEC-006, source_document: AGENT.md, source_section: "2. Product", semantic_type: flow, spec_excerpt: "... and funds the coin's casino reserve.", normalized_form: "for all buys: reserve[pool] += f(buy)", confidence: 0.9}
- {id: SPEC-007, source_document: AGENT.md, source_section: "2. Product; 2. Game levels", semantic_type: state_transition, spec_excerpt: "The coin goes **Live** when **both**: $35,000 has been raised **and** 150 qualified wallets have bought. ... This supersedes the brief's Live trigger above ($35,000 raised and 150 qualified wallets).", normalized_form: "raised/wallet trigger is NOT the rule; Live == level 1 of the game-level rule", confidence: 0.9}
- {id: SPEC-008, source_document: AGENT.md, source_section: "2. Product", semantic_type: state_transition, spec_excerpt: "On Live: the pool switches state automatically, trading fees reduce ...", normalized_form: "on Live: automatic state change; fee rate decreases", confidence: 0.9}
- {id: SPEC-009, source_document: AGENT.md, source_section: "2. Product", semantic_type: deferred, spec_excerpt: "... the game is revealed, wagering opens.", normalized_form: "on Live: reveal game; enable wagering", confidence: 0.85}
- {id: SPEC-010, source_document: AGENT.md, source_section: "2. Product", semantic_type: deferred, spec_excerpt: "Players bet in USDC or the coin. The coin's reserve is the casino bankroll. Holders are effectively the house.", normalized_form: "casino wagering against reserve", confidence: 0.85}
# AGENT.md section 2, Game levels
- {id: SPEC-011, source_document: AGENT.md, source_section: "2. Game levels (client updates, 6 and 9 November 2026)", semantic_type: state_transition, spec_excerpt: "Each game unlocks when the coin's market cap against USDC, as a **24-hour average**, reaches its target and the coin has at least the game's **holder floor** of qualifying holders.", normalized_form: "unlock(k) iff avg24h(mcap) >= target[k] AND holders >= floor[k]", confidence: 0.95}
- {id: SPEC-012, source_document: AGENT.md, source_section: "2. Game levels", semantic_type: invariant, spec_excerpt: "Game 1 is \"the mother game\" and is the Live state. Once unlocked, a game stays unlocked.", normalized_form: "Live == level >= 1; level is non-decreasing", confidence: 0.95}
- {id: SPEC-013, source_document: AGENT.md, source_section: "2. Game levels, table", semantic_type: constant, spec_excerpt: "Market cap | $200K | $400K | $800K | $1.6M | $3.2M | $6.4M | $12.8M | $25.6M | $51M | $102M", normalized_form: "target = [2e5, 4e5, 8e5, 1.6e6, 3.2e6, 6.4e6, 1.28e7, 2.56e7, 5.1e7, 1.02e8] USD", confidence: 1.0}
- {id: SPEC-014, source_document: AGENT.md, source_section: "2. Game levels, table", semantic_type: constant, spec_excerpt: "Holder floor | 150 | 225 | 350 | 500 | 750 | 1,100 | 1,700 | 2,500 | 3,800 | 5,800", normalized_form: "floor = [150, 225, 350, 500, 750, 1100, 1700, 2500, 3800, 5800]", confidence: 1.0}
# AGENT.md section 2, Trading fees
- {id: SPEC-015, source_document: AGENT.md, source_section: "2. Trading fees", semantic_type: formula, spec_excerpt: "| Pre-Live | 1.25% base ... | 1.25% |", normalized_form: "base_rate(preLive) = 0.0125 for buys and sells", confidence: 1.0}
- {id: SPEC-016, source_document: AGENT.md, source_section: "2. Trading fees", semantic_type: formula, spec_excerpt: "| Post-Live | 1.00% base ... | 1.00% |", normalized_form: "base_rate(live) = 0.0100 for buys and sells", confidence: 1.0}
- {id: SPEC-017, source_document: AGENT.md, source_section: "2. Trading fees", semantic_type: formula, spec_excerpt: "1.25% base + 0.50% to the coin's reserve ... 1.00% base + 0.50% to the reserve", normalized_form: "buy_rate = base + 0.0050 -> reserve", confidence: 1.0}
- {id: SPEC-018, source_document: AGENT.md, source_section: "2. Trading fees", semantic_type: formula, spec_excerpt: "| Reserve target reached | base + 0.25% to the race pool (interpretation: replaces the 0.50%) | base |", normalized_form: "if reserveFull: buy_rate = base + 0.0025 -> racePool", confidence: 0.9}
- {id: SPEC-019, source_document: AGENT.md, source_section: "2. Trading fees", semantic_type: formula, spec_excerpt: "The base fee is split between the platform and the creator (split not given; see open questions).", normalized_form: "base_fee = platform_share + creator_share; no other recipient", confidence: 0.9}
# AGENT.md section 2, Casino economics, Governance
- {id: SPEC-020, source_document: AGENT.md, source_section: "2. Casino economics (deferred, recorded for continuity)", semantic_type: deferred, spec_excerpt: "Profits above each ledger's high-water mark are distributed 40% platform, 30% holders (reserve refill, then token burns), 15% creator, 15% players as rakeback. Rakeback is paid in the coin; wagers made in the coin get 2x weighting.", normalized_form: "profit split 40/30/15/15", confidence: 0.95}
- {id: SPEC-021, source_document: AGENT.md, source_section: "2. Governance", semantic_type: access_control, spec_excerpt: "Treasury is a Safe secured by a 48-hour timelock.", normalized_form: "owner/treasury = Safe behind 48h timelock", confidence: 0.9}
- {id: SPEC-022, source_document: AGENT.md, source_section: "2. Governance", semantic_type: security_requirement, spec_excerpt: "All critical financial operations are enforced on-chain with caps.", normalized_form: "every owner-set financial parameter has an on-chain maximum", confidence: 0.7}
# AGENT.md section 2, Client component list
- {id: SPEC-023, source_document: AGENT.md, source_section: "2. Client component list and where each lands", semantic_type: structure, spec_excerpt: "| Factory | `DicesHook.createCoin` | ... | Hook | `DicesHook` |", normalized_form: "factory and hook are one contract", confidence: 1.0}
- {id: SPEC-024, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: security_requirement, spec_excerpt: "| Locker | Not a contract. Positions are owned by the hook, which has no removal path, and `beforeRemoveLiquidity` always reverts |", normalized_form: "owner(positions) == hook; no removal path; beforeRemoveLiquidity reverts for all senders", confidence: 0.95}
- {id: SPEC-025, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: structure, spec_excerpt: "| FeeVault | `DicesHook` claimable-fee ledger held as PoolManager ERC-6909 USDC claims |", normalized_form: "fees custodied as ERC-6909 claims owned by the hook", confidence: 0.95}
- {id: SPEC-026, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: structure, spec_excerpt: "| GameReserve | Deferred. `DicesHook` already keeps per-coin `reserve` and `racePool` ledgers with controller-gated withdraw/deposit |", normalized_form: "hook has reserve[pool], racePool[pool], controller-gated", confidence: 0.95}
- {id: SPEC-027, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: deferred, spec_excerpt: "| GameVault, RewardsDistributor, ConversionExecutor | Deferred (casino phase) | ... | BridgeReceiver | Deferred | | Forwarder | Deferred; use OpenZeppelin `ERC2771Forwarder` |", normalized_form: "no such contracts in this phase", confidence: 0.95}
- {id: SPEC-028, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: access_control, spec_excerpt: "| Router | Any router implementing `IMsgSender` (Universal Router, `V4Router`) works today; a thin production router is deferred |", normalized_form: "no router restriction on swaps", confidence: 0.8}
- {id: SPEC-029, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: deferred, spec_excerpt: "| Treasury | Deferred; Safe + OpenZeppelin `TimelockController` (48h) as `feeRecipient` and hook owner |", normalized_form: "feeRecipient == owner == timelock (later)", confidence: 0.9}
- {id: SPEC-030, source_document: AGENT.md, source_section: "2. Client component list", semantic_type: structure, spec_excerpt: "| Parameter registry | `DicesHook` launch defaults, snapshotted per pool as `PoolConfig` |", normalized_form: "poolConfig[pool] = copy(defaults) at launch", confidence: 0.95}
# AGENT.md section 3, Principle
- {id: SPEC-031, source_document: AGENT.md, source_section: "3. Architecture, Principle", semantic_type: invariant, spec_excerpt: "The hook *is* the launchpad. It is the only liquidity provider ...", normalized_form: "for all positions: owner == hook", confidence: 0.95}
- {id: SPEC-032, source_document: AGENT.md, source_section: "3. Architecture, Principle", semantic_type: formula, spec_excerpt: "... charges every fee as a USDC hook delta ...", normalized_form: "currency(fee) == USDC for all swaps", confidence: 0.95}
- {id: SPEC-033, source_document: AGENT.md, source_section: "3. Architecture, Principle", semantic_type: constant, spec_excerpt: "... (the LP fee is zero) ...", normalized_form: "poolKey.fee == 0", confidence: 1.0}
- {id: SPEC-034, source_document: AGENT.md, source_section: "3. Architecture, Principle", semantic_type: structure, spec_excerpt: "... tracks each pool's game level ...", normalized_form: "hook stores level per pool", confidence: 1.0}
- {id: SPEC-035, source_document: AGENT.md, source_section: "3. Architecture, Principle", semantic_type: structure, spec_excerpt: "... and holds fee proceeds as ERC-6909 claims on the PoolManager until claimed.", normalized_form: "fee custody = PoolManager ERC-6909 balance of hook", confidence: 0.95}
# AGENT.md section 3, Contracts
- {id: SPEC-036, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: structure, spec_excerpt: "| `src/DicesHook.sol` | ... | `src/DicesCoin.sol` | ... | `src/calculators/FeeCalculator.sol` | ... | `src/calculators/LiveCalculator.sol` | ... | `src/interfaces/IDicesHook.sol` | ... | `src/interfaces/IFeeCalculator.sol`, `src/interfaces/ILiveCalculator.sol` | ... | `src/libraries/UniswapEvents.sol` |", normalized_form: "src/ consists of these files", confidence: 0.8}
- {id: SPEC-037, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: structure, spec_excerpt: "| `src/DicesHook.sol` | Launch, two positions, USDC fee capture, raised/wallet tracking, Live transition, ledgers, claims, owner config |", normalized_form: "hook implements each listed function", confidence: 0.9}
- {id: SPEC-038, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: structure, spec_excerpt: "| `src/DicesCoin.sol` | Fixed-supply ERC20 (solady) deployed as a minimal clone; `initialize` once, `burn` for later phases; keeps the count of qualifying holders |", normalized_form: "coin = solady ERC20 clone; initialize once; burn; holder count", confidence: 0.9}
- {id: SPEC-039, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: structure, spec_excerpt: "| `src/calculators/FeeCalculator.sol` | Rate schedule and USDC fee split into platform / creator / reserve / race |", normalized_form: "split outputs = {platform, creator, reserve, race}", confidence: 0.95}
- {id: SPEC-040, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: structure, spec_excerpt: "| `src/calculators/LiveCalculator.sol` | Level rule: ten market cap targets as ticks and ten holder floors, the per-pool price history, the 24-hour average |", normalized_form: "calculator holds 10 ticks, 10 floors, history, average", confidence: 0.95}
- {id: SPEC-041, source_document: AGENT.md, source_section: "3. Contracts, table", semantic_type: event, spec_excerpt: "| `src/libraries/UniswapEvents.sol` | Indexer-facing pool events `PoolCreated`, `PoolSwap`, `PoolStateUpdated`, emitted by the hook |", normalized_form: "hook emits PoolCreated, PoolSwap, PoolStateUpdated", confidence: 0.95}
- {id: SPEC-042, source_document: AGENT.md, source_section: "3. Contracts", semantic_type: access_control, spec_excerpt: "Calculators are owner-replaceable.", normalized_form: "owner can replace the fee and Live calculators, with full effect", confidence: 0.85}
- {id: SPEC-043, source_document: AGENT.md, source_section: "3. Contracts", semantic_type: invariant, spec_excerpt: "The fee calculator holds no state ...", normalized_form: "FeeCalculator has no storage", confidence: 1.0}
- {id: SPEC-044, source_document: AGENT.md, source_section: "3. Contracts", semantic_type: access_control, spec_excerpt: "... the Live calculator stores each pool's price history and answers only to the hook it was deployed for.", normalized_form: "history in calculator; qualify callable by its hook only", confidence: 0.95}
- {id: SPEC-045, source_document: AGENT.md, source_section: "3. Contracts; 4. Design decisions", semantic_type: invariant, spec_excerpt: "Replacing the Live calculator restarts every pool's 24 hours of history but never lowers a level, because levels are kept by the hook.", normalized_form: "level stored in hook; replacement resets history only", confidence: 0.95}
- {id: SPEC-046, source_document: AGENT.md, source_section: "3. Contracts", semantic_type: security_requirement, spec_excerpt: "Always deploy a fresh Live calculator for a replacement, constructed with this hook's address: a detached one stops observing ... and one built for another address reverts on every call, which leaves pools unable to unlock levels until it is replaced.", normalized_form: "replacement must be fresh and bound to this hook; wrong binding => OnlyHook on every call", confidence: 0.85}
- {id: SPEC-047, source_document: AGENT.md, source_section: "3. Contracts, Note (2026-11-05)", semantic_type: meta, spec_excerpt: "the Contracts table, Fees, Ledgers and Configuration subsections predate the internal-swap-pool rework and no longer match the code. Launch step 5, Qualifying holders and Live and game levels below are current.", normalized_form: "stale = {Contracts table, Fees, Ledgers, Configuration}; current = {Launch step 5, Qualifying holders, Live and game levels}", confidence: 0.95}
# AGENT.md section 3, Launch
- {id: SPEC-048, source_document: AGENT.md, source_section: "3. Launch (one transaction)", semantic_type: abi, spec_excerpt: "`createCoin(CoinParams{name, symbol, creator, gameCommitment})`:", normalized_form: "CoinParams has four fields including gameCommitment", confidence: 0.95}
- {id: SPEC-049, source_document: AGENT.md, source_section: "3. Launch, step 1", semantic_type: security_requirement, spec_excerpt: "Validate the creator split ...", normalized_form: "createCoin reverts on an invalid creator configuration", confidence: 0.75}
- {id: SPEC-050, source_document: AGENT.md, source_section: "3. Launch, step 1", semantic_type: flow, spec_excerpt: "... collect the optional ETH creation fee.", normalized_form: "if createFee > 0: msg.value must pay it", confidence: 0.9}
- {id: SPEC-051, source_document: AGENT.md, source_section: "3. Launch, step 2", semantic_type: flow, spec_excerpt: "Clone `DicesCoin`, mint `launchSupply` to the hook, which pays 10% of it (100M coins) to the coin's bankroll.", normalized_form: "mint 1e27 to hook; transfer 1e26 to bankroll", confidence: 1.0}
- {id: SPEC-052, source_document: AGENT.md, source_section: "3. Launch, step 3", semantic_type: constant, spec_excerpt: "Build the pool key (fee 0, tick spacing 60, this hook); the coin may be currency0 or currency1.", normalized_form: "key = {fee: 0, tickSpacing: 60, hooks: this}; ordering by address", confidence: 1.0}
- {id: SPEC-053, source_document: AGENT.md, source_section: "3. Launch, step 4", semantic_type: flow, spec_excerpt: "Snapshot the owner's launch defaults into `PoolConfig` for this pool ...", normalized_form: "poolConfig[pool] = defaults", confidence: 0.95}
- {id: SPEC-054, source_document: AGENT.md, source_section: "3. Launch, step 4", semantic_type: flow, spec_excerpt: "... store creator config and `gameCommitment`.", normalized_form: "store creator and commitment per pool", confidence: 0.9}
- {id: SPEC-055, source_document: AGENT.md, source_section: "3. Launch, step 5 (named current)", semantic_type: formula, spec_excerpt: "Inside `unlock`: initialise the pool at the $12.5k FDV launch price ...", normalized_form: "price0 x 1e27 = 12_500e6 raw USDC", confidence: 1.0}
- {id: SPEC-056, source_document: AGENT.md, source_section: "3. Launch, step 5 (named current)", semantic_type: formula, spec_excerpt: "... add **two** coin-only positions: 70% of supply from the aligned launch tick to the $200k sale end, and 20% from there to the usable tick limit.", normalized_form: "P1 = 7e26 in [align(launchTick), tick($200k)); P2 = 2e26 in [tick($200k), maxUsableTick]", confidence: 1.0}
- {id: SPEC-057, source_document: AGENT.md, source_section: "3. Launch, step 5 (named current)", semantic_type: formula, spec_excerpt: "The ranges are mirrored when the coin is currency1.", normalized_form: "coin1: ranges negated", confidence: 0.95}
- {id: SPEC-058, source_document: AGENT.md, source_section: "3. Launch, step 5 (named current)", semantic_type: security_requirement, spec_excerpt: "The upper position must reach the usable limit: any price beyond the end of the liquidity costs nothing to move through, which would let the market cap that levels depend on be set for free.", normalized_form: "P2 upper bound == usable tick limit", confidence: 1.0}
- {id: SPEC-059, source_document: AGENT.md, source_section: "3. Launch, step 5 (named current)", semantic_type: formula, spec_excerpt: "Selling out the first position raises about $35,013 of USDC.", normalized_form: "USDC to cross P1 ~= 35_013e6", confidence: 1.0}
- {id: SPEC-060, source_document: AGENT.md, source_section: "3. Launch, step 6", semantic_type: event, spec_excerpt: "Emit `CoinCreated` with the full config snapshot.", normalized_form: "event CoinCreated(...) at launch", confidence: 0.95}
- {id: SPEC-061, source_document: AGENT.md, source_section: "3. Launch, Lock guarantees", semantic_type: security_requirement, spec_excerpt: "`beforeAddLiquidity` rejects any sender but the hook ...", normalized_form: "add allowed iff sender == hook", confidence: 1.0}
- {id: SPEC-062, source_document: AGENT.md, source_section: "3. Launch, Lock guarantees", semantic_type: security_requirement, spec_excerpt: "... `beforeRemoveLiquidity` rejects everyone ...", normalized_form: "remove allowed for no sender", confidence: 1.0}
- {id: SPEC-063, source_document: AGENT.md, source_section: "3. Launch, Lock guarantees", semantic_type: invariant, spec_excerpt: "... and the hook has no code path with a negative liquidity delta.", normalized_form: "for all hook calls to modifyLiquidity: liquidityDelta > 0", confidence: 1.0}
# AGENT.md section 3, Bankroll
- {id: SPEC-064, source_document: AGENT.md, source_section: "3. Bankroll", semantic_type: structure, spec_excerpt: "10% of every coin is paid at launch to `DicesCoin.bankroll()` ... The address is an immutable of the coin implementation, set from the `BANKROLL` constants in `V001`, and the hook reads it from the coin", normalized_form: "recipient = coin.bankroll() (immutable)", confidence: 1.0}
- {id: SPEC-065, source_document: AGENT.md, source_section: "3. Bankroll", semantic_type: flow, spec_excerpt: "Changing the bankroll means deploying a new coin implementation and calling `setCoinImplementation`. Coins that already launched keep the old address ...", normalized_form: "bankroll fixed per implementation", confidence: 0.95}
- {id: SPEC-066, source_document: AGENT.md, source_section: "3. Bankroll", semantic_type: economic_assumption, spec_excerpt: "100M sold at a $200k cap returns about $13.8k and drops the cap to about $98k ... `test/DicesHookLaunchCurve.t.sol` pins that state.", normalized_form: "sell 1e26 at sale end: out ~= 13.8e9, cap ~= 98e9", confidence: 0.95}
- {id: SPEC-067, source_document: AGENT.md, source_section: "3. Bankroll", semantic_type: access_control, spec_excerpt: "Nothing on chain restricts the bankroll; see open question 10.", normalized_form: "no transfer restriction on bankroll", confidence: 1.0}
# AGENT.md section 3, Fees (named stale)
- {id: SPEC-068, source_document: AGENT.md, source_section: "3. Fees (all USDC, via hook deltas), table", semantic_type: flow, spec_excerpt: "| Buy, exact-in USDC | USDC | `beforeSwap` specified delta; pool swaps the remainder |", normalized_form: "buy exactIn: fee in USDC taken in beforeSwap", confidence: 1.0}
- {id: SPEC-069, source_document: AGENT.md, source_section: "3. Fees, table", semantic_type: flow, spec_excerpt: "| Buy, exact-out coin | coin | `afterSwap` unspecified delta on the USDC owed |", normalized_form: "buy exactOut: fee in USDC in afterSwap", confidence: 1.0}
- {id: SPEC-070, source_document: AGENT.md, source_section: "3. Fees, table", semantic_type: flow, spec_excerpt: "| Sell, exact-in coin | coin | `afterSwap` unspecified delta on the USDC received |", normalized_form: "sell exactIn: fee in USDC in afterSwap", confidence: 1.0}
- {id: SPEC-071, source_document: AGENT.md, source_section: "3. Fees, table", semantic_type: flow, spec_excerpt: "| Sell, exact-out USDC | USDC | `beforeSwap` grossed-up specified delta |", normalized_form: "sell exactOut: fee in USDC taken in beforeSwap", confidence: 1.0}
- {id: SPEC-072, source_document: AGENT.md, source_section: "3. Fees", semantic_type: formula, spec_excerpt: "The fee is always `rate x gross USDC moved`.", normalized_form: "fee = rate x |USDC delta|", confidence: 1.0}
- {id: SPEC-073, source_document: AGENT.md, source_section: "3. Fees", semantic_type: structure, spec_excerpt: "Rates are cached in transient storage in `beforeSwap` ...", normalized_form: "tstore(rate) in beforeSwap", confidence: 1.0}
- {id: SPEC-074, source_document: AGENT.md, source_section: "3. Fees", semantic_type: security_requirement, spec_excerpt: "... so the swap that triggers Live or fills the reserve pays the pre-swap rate.", normalized_form: "rate(swap) = rate at swap start", confidence: 0.95}
- {id: SPEC-075, source_document: AGENT.md, source_section: "3. Fees", semantic_type: security_requirement, spec_excerpt: "When USDC is the specified currency a partial fill reverts (`PartialFillWithSpecifiedCurrency`) rather than overcharging.", normalized_form: "revert on partial fill when specified == USDC", confidence: 1.0}
- {id: SPEC-076, source_document: AGENT.md, source_section: "3. Fees", semantic_type: invariant, spec_excerpt: "The reserve is capped at its target; the overshoot of the crossing buy goes to the race pool and `reserveTargetReached` is set permanently.", normalized_form: "reserve <= target; flag monotonic", confidence: 1.0}
# AGENT.md section 3, Ledgers (named stale)
- {id: SPEC-077, source_document: AGENT.md, source_section: "3. Ledgers (per pool unless noted)", semantic_type: abi, spec_excerpt: "`claimableFees[recipient]` (global): platform `feeRecipient` and creator receivers; `claimFees()` withdraws.", normalized_form: "hook.claimableFees(addr); hook.claimFees()", confidence: 1.0}
- {id: SPEC-078, source_document: AGENT.md, source_section: "3. Ledgers", semantic_type: access_control, spec_excerpt: "`reserve`, `racePool`, `reserveTargetReached`: casino ledgers. Only `reserveController` (future GameReserve) may `withdrawReserve`, `withdrawRacePool`, `depositReserve`.", normalized_form: "three ledgers; three controller-only functions", confidence: 1.0}
- {id: SPEC-079, source_document: AGENT.md, source_section: "3. Ledgers", semantic_type: invariant, spec_excerpt: "Invariant: hook's USDC ERC-6909 balance == sum of all claimable fees + all reserves + all race pools.", normalized_form: "PM.balanceOf(hook, USDC) == sum(claimable) + sum(reserve) + sum(racePool)", confidence: 1.0}
# AGENT.md section 3, Qualifying holders (named current)
- {id: SPEC-080, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: constant, spec_excerpt: "A qualifying holder is an address holding at least `DicesCoin.HOLDER_THRESHOLD` (300,000 coins, about $60 at the $200k Live market cap). The rule is a fixed coin balance, not a dollar value", normalized_form: "qualifies(a) iff balance(a) >= 300_000e18", confidence: 1.0}
- {id: SPEC-081, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: invariant, spec_excerpt: "`DicesCoin` maintains the count itself in `_afterTokenTransfer`, on every mint, burn and transfer.", normalized_form: "count updated on every balance change", confidence: 1.0}
- {id: SPEC-082, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: invariant, spec_excerpt: "The hook, the PoolManager, the InternalSwapPool and the bankroll hold coins without being holders; they are immutables of the coin implementation and are never counted, nor is the zero address.", normalized_form: "excluded = {hook, PM, ISP, bankroll, 0}", confidence: 1.0}
- {id: SPEC-083, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: economic_assumption, spec_excerpt: "Wallets that the bankroll pays count like any others, so the bankroll could seed all 150 holders at no cost.", normalized_form: "exclusion applies to the bankroll address only", confidence: 1.0}
- {id: SPEC-084, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: security_requirement, spec_excerpt: "`qualifiedHolders()` leaves out holders that crossed the threshold in the current block. ... Faking it now needs real coins held across a block boundary.", normalized_form: "reported = count - joiners(this block)", confidence: 0.9}
- {id: SPEC-085, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: invariant, spec_excerpt: "Swapper identity is not used by the level rule.", normalized_form: "level rule independent of msg.sender / swapper", confidence: 1.0}
- {id: SPEC-086, source_document: AGENT.md, source_section: "3. Qualifying holders", semantic_type: security_requirement, spec_excerpt: "trusted routers and `IMsgSender.msgSender()` (`TrustedRouters`). **Never read a buyer address from `hookData`.**", normalized_form: "identity only via trusted router msgSender(); hookData never parsed for identity", confidence: 1.0}
# AGENT.md section 3, Indexer events
- {id: SPEC-087, source_document: AGENT.md, source_section: "3. Indexer events (`UniswapEvents`)", semantic_type: event, spec_excerpt: "`PoolCreated(poolId, coin, usdc)` once per launch, right after `initialize`.", normalized_form: "emit PoolCreated after initialize", confidence: 1.0}
- {id: SPEC-088, source_document: AGENT.md, source_section: "3. Indexer events", semantic_type: event, spec_excerpt: "`PoolSwap(poolId, amount0, amount1, fee0, fee1)` after every swap: amounts are the pool's swap delta from the swapper's side excluding hook fees; fees are the positive USDC fee on the USDC leg and zero on the coin leg, so the swapper's net USDC movement is `amount - fee`.", normalized_form: "emit PoolSwap per swap; fee only on USDC leg", confidence: 1.0}
- {id: SPEC-089, source_document: AGENT.md, source_section: "3. Indexer events", semantic_type: event, spec_excerpt: "`PoolStateUpdated(poolId, sqrtPriceX96, tick, protocolFee, lpFee, liquidity)` after every swap and once per launch, after both positions are added", normalized_form: "emit PoolStateUpdated per swap and per launch", confidence: 1.0}
- {id: SPEC-090, source_document: AGENT.md, source_section: "3. Indexer events", semantic_type: invariant, spec_excerpt: "Liquidity can never be removed, so no removal variant exists.", normalized_form: "no liquidity removal in any pool", confidence: 0.9}
- {id: SPEC-091, source_document: AGENT.md, source_section: "3. Indexer events", semantic_type: structure, spec_excerpt: "These are emitted from `_launch` and `_afterSwap`, not from `beforeInitialize` / `afterAddLiquidity`: the PoolManager skips hook callbacks when the hook itself is the caller (`Hooks.noSelfCall`), so those callbacks never run for the hook's own launches and only serve as third-party guards.", normalized_form: "emit sites = {_launch, _afterSwap}; self-calls skip callbacks", confidence: 0.9}
# AGENT.md section 3, Live and game levels (named current)
- {id: SPEC-092, source_document: AGENT.md, source_section: "3. Live and game levels", semantic_type: invariant, spec_excerpt: "Every pool has a level from 0 to 10, kept by the hook in `poolLevel`. Level 1 is Live and each level is one game.", normalized_form: "0 <= poolLevel[pool] <= 10", confidence: 1.0}
- {id: SPEC-093, source_document: AGENT.md, source_section: "3. Live and game levels", semantic_type: invariant, spec_excerpt: "A level unlocks when the coin's market cap, averaged over the last 24 hours, is at or above its target and the coin has at least its floor of qualifying holders. An unlocked level is never lost.", normalized_form: "poolLevel non-decreasing", confidence: 1.0}
- {id: SPEC-094, source_document: AGENT.md, source_section: "3. Live and game levels, Market cap is a tick check", semantic_type: formula, spec_excerpt: "Supply is fixed at 1e9 and the pair is always USDC, so each target is one tick: the first tick at which the supply is worth the target (`LiveCalculator.levelTicks()`).", normalized_form: "T_k = min{t : 1.0001^t x 1e27 >= target_k x 1e6}", confidence: 1.0}
- {id: SPEC-095, source_document: AGENT.md, source_section: "3. Live and game levels, Market cap is a tick check", semantic_type: formula, spec_excerpt: "The calculator works in coin ticks, which rise with the coin's price in both currency orderings: the pool tick when the coin is currency0, `-tick - 1` when it is currency1.", normalized_form: "coinTick = coin0 ? tick : -tick - 1", confidence: 1.0}
- {id: SPEC-096, source_document: AGENT.md, source_section: "3. Live and game levels, The average is a tick TWAP", semantic_type: formula, spec_excerpt: "the time-weighted average of the coin tick, which is a geometric mean of the price ... one 2-second block at the highest price a pool can have adds about 29 ticks, or 0.3% ... (half a day at $300k and half at $500k averages $387k, not $400k)", normalized_form: "avg = sum(tick_i x dt_i) / window", confidence: 0.95}
- {id: SPEC-097, source_document: AGENT.md, source_section: "3. Live and game levels, The average is a tick TWAP", semantic_type: abi, spec_excerpt: "a UI should show `LiveCalculator.averageMarketCap(poolId)` rather than work out its own figure.", normalized_form: "view averageMarketCap(poolId) exists", confidence: 0.9}
- {id: SPEC-098, source_document: AGENT.md, source_section: "3. Live and game levels, History", semantic_type: flow, spec_excerpt: "After every swap, at every level, the hook calls `liveCalculator.qualify(key)`.", normalized_form: "afterSwap -> qualify, unconditionally", confidence: 1.0}
- {id: SPEC-099, source_document: AGENT.md, source_section: "3. Live and game levels, History", semantic_type: structure, spec_excerpt: "The calculator keeps one slot per pool (`oracles[poolId]`: first and latest observation times, latest coin tick, running sum of tick x seconds) and 25 hourly checkpoints of that sum.", normalized_form: "Oracle fits one slot; 25 checkpoints", confidence: 1.0}
- {id: SPEC-100, source_document: AGENT.md, source_section: "3. Live and game levels, History", semantic_type: invariant, spec_excerpt: "The pool price only moves through swaps and each one reaches `_afterSwap`, so the history is exact. The one exception is a swap made by the hook itself, which v4 does not call back: **the hook must never swap**.", normalized_form: "every price change is observed; hook never calls swap", confidence: 0.95}
- {id: SPEC-101, source_document: AGENT.md, source_section: "3. Live and game levels, The window", semantic_type: formula, spec_excerpt: "**The window** opens on the hour that is 24 hours before the current hour, so it lasts between 24 and 25 hours.", normalized_form: "opensAt = (floor(now/3600) - 24) x 3600", confidence: 1.0}
- {id: SPEC-102, source_document: AGENT.md, source_section: "3. Live and game levels, The window", semantic_type: security_requirement, spec_excerpt: "Nothing is decided until a window can open after the pool's first observation: **no level, Live included, can unlock in a pool's first 24 hours of trading**. The earliest moment is the start of the 25th hour after the hour of its first trade, which is 24 to 25 hours after that trade.", normalized_form: "unlock time >= first_trade_time + 24h", confidence: 0.85}
- {id: SPEC-103, source_document: AGENT.md, source_section: "3. Live and game levels, Holder floor", semantic_type: flow, spec_excerpt: "Once the average has earned a level, the calculator reads `DicesCoin.qualifiedHolders()` and brings the level down to the highest whose floor the count meets. The count is taken as it stands, not averaged ...", normalized_form: "level = max{k <= levelByTick : holders >= floor_k}", confidence: 1.0}
- {id: SPEC-104, source_document: AGENT.md, source_section: "3. Live and game levels, Holder floor", semantic_type: invariant, spec_excerpt: "It is not read while the average is short of the first target, so a coin that cannot report it never blocks an observation.", normalized_form: "no holder read when levelByTick == 0", confidence: 1.0}
- {id: SPEC-105, source_document: AGENT.md, source_section: "3. Live and game levels, The ratchet is in the hook", semantic_type: event, spec_excerpt: "The hook records only a rise, and emits `PoolLevelUnlocked(poolId, previousLevel, level)` for it: one event even when several levels are crossed, preceded by `PoolLive(poolId)` when the pool leaves level 0.", normalized_form: "if new > old: store; emit PoolLive if old == 0; emit PoolLevelUnlocked(old, new)", confidence: 1.0}
- {id: SPEC-106, source_document: AGENT.md, source_section: "3. Live and game levels, The ratchet is in the hook", semantic_type: formula, spec_excerpt: "`poolLive(poolId)` is `poolLevel(poolId) != 0`, and trading fees change at level 1 only.", normalized_form: "poolLive = level != 0; rate depends on poolLive only", confidence: 1.0}
- {id: SPEC-107, source_document: AGENT.md, source_section: "3. Live and game levels, Triggering", semantic_type: security_requirement, spec_excerpt: "A swap that completes an average unlocks the level, and still pays the pre-Live fee rate if it is the one that takes the pool Live.", normalized_form: "fee computed before the level is synced", confidence: 1.0}
- {id: SPEC-108, source_document: AGENT.md, source_section: "3. Live and game levels, Triggering", semantic_type: access_control, spec_excerpt: "`syncLevel(coin)` lets anyone run the same check. `LiveCalculator.qualifiedLevel(key)` is the read-only version", normalized_form: "syncLevel public; qualifiedLevel view", confidence: 1.0}
- {id: SPEC-109, source_document: AGENT.md, source_section: "3. Live and game levels, Fail-safe", semantic_type: security_requirement, spec_excerpt: "The hook calls `qualify` in a `try`. A reverting calculator leaves the level as it is and never blocks a swap.", normalized_form: "calculator failure never reverts a swap", confidence: 0.9}
- {id: SPEC-110, source_document: AGENT.md, source_section: "3. Live and game levels, Hook only", semantic_type: access_control, spec_excerpt: "`qualify` writes the history, so it accepts calls from the hook alone (`dicesHook`, an immutable set at construction) and reverts with `OnlyHook` for anyone else.", normalized_form: "qualify: msg.sender == dicesHook else OnlyHook", confidence: 1.0}
- {id: SPEC-111, source_document: AGENT.md, source_section: "3. Live and game levels, Measured cost", semantic_type: economic_assumption, spec_excerpt: "9.3k gas per swap during a pool's first day, 13.4k once it has a full window, and 17.6k once the average earns a level ... A pool's first observation costs 25.7k ... about 72k, or 174k if the slots have never been written ... A coin transfer pays about 1.2k for the holder count, or 6.6k when it moves a wallet across the threshold.", normalized_form: "gas figures", confidence: 0.9}
# AGENT.md section 3, Configuration (named stale), Hook address flags, Deployment
- {id: SPEC-112, source_document: AGENT.md, source_section: "3. Configuration", semantic_type: structure, spec_excerpt: "`PoolConfig` (fees, wallet/raised/min-buy/reserve targets, launch ticks, sale share, supply) is owner-set as launch defaults and snapshotted at creation.", normalized_form: "owner-set defaults; per-pool copy", confidence: 1.0}
- {id: SPEC-113, source_document: AGENT.md, source_section: "3. Configuration", semantic_type: constant, spec_excerpt: "1e9 supply, start tick -398400 ~ $5k FDV, sale range to -375360 ~10x, 50% in the sale position, reserve target $10k, min qualifying buy $25, creator share 50% of the base fee", normalized_form: "defaults = {supply 1e9, start -398400, saleEnd -375360, sale 50%, reserve 10_000e6, minBuy 25e6, creator 50%}", confidence: 1.0}
- {id: SPEC-114, source_document: AGENT.md, source_section: "3. Hook address flags", semantic_type: constant, spec_excerpt: "`beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta`.", normalized_form: "permissions == these six", confidence: 1.0}
- {id: SPEC-115, source_document: AGENT.md, source_section: "3. Hook address flags", semantic_type: convention, spec_excerpt: "`script/deployment/V001.s.sol` mines a matching CREATE3 salt and deploys everything through CreateX; keep its `HOOK_FLAGS` constant in step with `DicesHook.getHookPermissions()`.", normalized_form: "V001.HOOK_FLAGS == flags(getHookPermissions())", confidence: 1.0}
- {id: SPEC-116, source_document: AGENT.md, source_section: "3. Deployment", semantic_type: flow, spec_excerpt: "`script/deployment/V001.s.sol` is the only deployment path. Every contract goes through CreateX `deployCreate3`, so addresses depend on the signer and `DEPLOYMENT_SALT` alone.", normalized_form: "address = f(signer, DEPLOYMENT_SALT)", confidence: 0.9}
- {id: SPEC-117, source_document: AGENT.md, source_section: "3. Deployment", semantic_type: security_requirement, spec_excerpt: "**no contract may infer an owner or recipient from `msg.sender`**: pass it as an argument.", normalized_form: "no constructor uses msg.sender for a role", confidence: 1.0}
- {id: SPEC-118, source_document: AGENT.md, source_section: "3. Deployment", semantic_type: convention, spec_excerpt: "The script reads nothing from the environment; chain addresses and destinations (owner, fee recipients, bankroll) are constants in `_getConfig()`.", normalized_form: "no vm.env*; constants only", confidence: 1.0}
- {id: SPEC-119, source_document: AGENT.md, source_section: "3. Deployment", semantic_type: security_requirement, spec_excerpt: "A bankroll that is one of the launchpad contracts is rejected before broadcasting.", normalized_form: "bankroll not in {all launchpad contracts}", confidence: 0.9}
# AGENT.md section 4
- {id: SPEC-120, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: invariant, spec_excerpt: "**Fees in USDC** so the reserve is a USDC bankroll with no conversion step and the trader's coin leg is untouched.", normalized_form: "no fee in coin; no conversion", confidence: 1.0}
- {id: SPEC-121, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: security_requirement, spec_excerpt: "**Hook-as-LP is the lock**: cheaper and more verifiable than a separate Locker holding position NFTs.", normalized_form: "lock = hook-owned positions without removal path", confidence: 0.95}
- {id: SPEC-122, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: structure, spec_excerpt: "**Net raised, not gross volume**: wash trading cannot inflate it; it is literally the USDC backing the positions.", normalized_form: "hook tracks net raised", confidence: 0.85}
- {id: SPEC-123, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: access_control, spec_excerpt: "**`IMsgSender` + trusted routers** per the Uniswap guide; the guide's sample lacks access control and never checks its allowlist, so ours fixes both and degrades to \"no attribution\" instead of reverting.", normalized_form: "setter owner-only; allowlist checked; failure => address(0)", confidence: 1.0}
- {id: SPEC-124, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: structure, spec_excerpt: "Hourly checkpoints were chosen over a per-block observation ring: one slot written per swap and seven checkpoint slots per pool, at the price of a window that is 24 to 25 hours long rather than exactly 24.", normalized_form: "1 oracle slot write per swap; 7 checkpoint slots", confidence: 0.95}
- {id: SPEC-125, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: economic_assumption, spec_excerpt: "Holding a $200k average for a day takes about $35k in the pool and about 1.25% in fees each way; the 150 holders are 45M coins, about $9k of what was bought", normalized_form: "cost model", confidence: 0.95}
- {id: SPEC-126, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: invariant, spec_excerpt: "**Market cap by tick, holders by balance**: every target is a fixed tick and every floor a fixed count, so the level rule needs no price maths or iteration per swap and stays fully on chain.", normalized_form: "no price arithmetic; no loops per swap", confidence: 0.6}
- {id: SPEC-127, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: formula, spec_excerpt: "**Sale range sized to the brief's raise**: 70% of the supply between $12.5k and $200k raises about $35k.", normalized_form: "raise(P1) ~= 35_000e6", confidence: 1.0}
- {id: SPEC-128, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: security_requirement, spec_excerpt: "**Per-pool config snapshot**: changing defaults can never alter a coin that already launched.", normalized_form: "parameters of a launched pool are immutable", confidence: 1.0}
- {id: SPEC-129, source_document: AGENT.md, source_section: "4. Design decisions and rationale", semantic_type: invariant, spec_excerpt: "**Sticky `reserveTargetReached`**: mirrors the brief's one-time transition and keeps trader-facing rates predictable", normalized_form: "flag monotonic", confidence: 1.0}
# AGENT.md section 5
- {id: SPEC-130, source_document: AGENT.md, source_section: "5. Open questions for the client, 4", semantic_type: security_requirement, spec_excerpt: "no coin can go Live sooner than 24 hours after its first trade (it was about 40 seconds), and the average is a geometric mean over 24 to 25 hours", normalized_form: "liveTime >= firstTradeTime + 24h", confidence: 0.9}
- {id: SPEC-131, source_document: AGENT.md, source_section: "5. Open questions for the client, 5", semantic_type: state_transition, spec_excerpt: "A qualifying holder is 300,000 coins held ..., counted by balance rather than by having bought; a wallet stops counting when it drops below, but an unlocked level stays.", normalized_form: "count decrements on dropping below; level unaffected", confidence: 1.0}
- {id: SPEC-132, source_document: AGENT.md, source_section: "5. Open questions for the client, 8", semantic_type: constant, spec_excerpt: "Levels 9 and 10 are listed as $51M and $102M, where doubling gives $51.2M and $102.4M. We use the listed figures.", normalized_form: "target_9 = 5.1e7; target_10 = 1.02e8", confidence: 1.0}
- {id: SPEC-133, source_document: AGENT.md, source_section: "5. Open questions for the client, 10", semantic_type: flow, spec_excerpt: "(`BASE_MAINNET_BANKROLL` is unset, and the deployment refuses to run without it)", normalized_form: "mainnet: bankroll == 0 => revert", confidence: 1.0}
- {id: SPEC-134, source_document: AGENT.md, source_section: "5. Open questions for the client, 1, 2, 7", semantic_type: constant, spec_excerpt: "Creator vs platform split of the base trading fee (placeholder 50/50). ... Reserve target per coin in USDC (placeholder $10,000). ... Target chain (assumed Base) and USDC contract.", normalized_form: "placeholders: 50/50; 10_000e6; Base", confidence: 0.85}
# AGENT.md section 6
- {id: SPEC-135, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: convention, spec_excerpt: "Toolchain: Foundry, solc 0.8.38, Osaka for internal sources, scripts and tests. The upstream Uniswap v4 `PoolManager` alone is compiled with 0.8.26/Cancun ... CI runs `forge fmt --check`, `forge build --sizes`, `forge test -vvv`, and the production coverage gate.", normalized_form: "compiler and CI configuration", confidence: 1.0}
- {id: SPEC-136, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: convention, spec_excerpt: "Internal contracts currently use the legacy pipeline; production coverage disables optimization for accurate source maps.", normalized_form: "via_ir = false", confidence: 0.95}
- {id: SPEC-137, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: security_requirement, spec_excerpt: "Never add a liquidity-removal path to the hook ...", normalized_form: "hook: no negative liquidityDelta", confidence: 1.0}
- {id: SPEC-138, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: security_requirement, spec_excerpt: "... and never read swapper identity from `hookData`.", normalized_form: "hookData not decoded for identity", confidence: 1.0}
- {id: SPEC-139, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: security_requirement, spec_excerpt: "Never make the hook swap against its own pools: v4 skips `afterSwap` for the hook's own calls, so the price history behind the levels would miss that move.", normalized_form: "hook never calls PoolManager.swap", confidence: 1.0}
- {id: SPEC-140, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: convention, spec_excerpt: "`DicesCoin` and `LiveCalculator` take constructor arguments (the launchpad contracts, including the hook's predicted address, the bankroll, and USDC). Keep `script/deployment/V001.s.sol` and its `_requireWiring` checks in step when they change.", normalized_form: "V001 passes and verifies those arguments", confidence: 1.0}
- {id: SPEC-141, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: invariant, spec_excerpt: "The launch curve and levels have to agree: the launch price in `FeeCalculator`, the sale end and supply split in `DicesHook`, and the first level's target in `LiveCalculator`. Change them together.", normalized_form: "SALE_END_TICK == levelTicks[0]; supplies equal", confidence: 0.95}
- {id: SPEC-142, source_document: AGENT.md, source_section: "6. Working conventions", semantic_type: convention, spec_excerpt: "Test harness: `test/DicesHook.t.sol` ... `test/DicesHookTrading.t.sol` ... `test/Calculators.t.sol`, `test/CalculatorUpdates.t.sol`, `test/DicesHookLive.t.sol` ... and `test/DicesHookLaunchCurve.t.sol` ... Dependencies come through the `lib/v4-hooks-public` submodule (v4-core, v4-periphery, solady, OpenZeppelin).", normalized_form: "files and dependency layout", confidence: 0.9}
# README.md
- {id: SPEC-143, source_document: README.md, source_section: "Dices launchpad, bullet 1", semantic_type: flow, spec_excerpt: "`DicesHook.createCoin` deploys a fixed-supply `DicesCoin`, initialises a USDC pool with the hook attached at a $12.5k FDV launch price and shares out the supply, in one transaction: 70% ... 20% ... and 10% to the bankroll ... Selling out the first position raises about $35,000 of USDC. The hook has no way to remove either position, so the liquidity is locked permanently.", normalized_form: "as SPEC-003, 055, 056, 059, 063", confidence: 1.0}
- {id: SPEC-144, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: formula, spec_excerpt: "Every fee is charged in USDC through hook deltas", normalized_form: "currency(fee) == USDC", confidence: 1.0}
- {id: SPEC-145, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: formula, spec_excerpt: "1.25% pre-Live and 1.00% post-Live on buys and sells", normalized_form: "rates 0.0125 / 0.0100", confidence: 1.0}
- {id: SPEC-146, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: formula, spec_excerpt: "plus 0.50% on buys to the coin's reserve until the reserve target is reached, then 0.25% on buys to the race pool.", normalized_form: "buy surcharge 0.0050 then 0.0025", confidence: 1.0}
- {id: SPEC-147, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: formula, spec_excerpt: "The base fee is split between the platform and the creator.", normalized_form: "two recipients", confidence: 0.95}
- {id: SPEC-148, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: abi, spec_excerpt: "Fees accrue as ERC-6909 USDC claims and are withdrawn with `claimFees()`", normalized_form: "ERC-6909 custody; claimFees()", confidence: 1.0}
- {id: SPEC-149, source_document: README.md, source_section: "Dices launchpad, bullet 2", semantic_type: access_control, spec_excerpt: "reserve and race-pool ledgers are controlled by the `reserveController`.", normalized_form: "reserveController role", confidence: 1.0}
- {id: SPEC-150, source_document: README.md, source_section: "Dices launchpad, bullet 3", semantic_type: state_transition, spec_excerpt: "Every pool has a game level from 0 to 10, read with `poolLevel(poolId)`. ... $200,000 and 150 holders for level 1 ... $102M/5,800. The average is a time-weighted average of the pool tick over the last 24 to 25 hours, recorded after every swap, so nothing unlocks in a pool's first 24 hours", normalized_form: "as SPEC-011, 013, 014, 101", confidence: 0.95}
- {id: SPEC-151, source_document: README.md, source_section: "Dices launchpad, bullet 3", semantic_type: security_requirement, spec_excerpt: "the holder count is kept by `DicesCoin` on every transfer and ignores wallets that only reached the balance in the current block.", normalized_form: "as SPEC-084", confidence: 0.9}
- {id: SPEC-152, source_document: README.md, source_section: "Dices launchpad, bullet 3", semantic_type: event, spec_excerpt: "The swap that completes the conditions unlocks the level and emits `PoolLevelUnlocked` (and `PoolLive` for level 1); anyone can call `syncLevel(coin)` to do the same between swaps. An unlocked level is never lost.", normalized_form: "as SPEC-105, 108, 093", confidence: 1.0}
- {id: SPEC-153, source_document: README.md, source_section: "Dices launchpad, bullet 4", semantic_type: access_control, spec_excerpt: "`FeeCalculator` and `LiveCalculator` are owner-replaceable modules. The fee calculator is stateless; the Live calculator keeps each pool's price history, so a replacement restarts every pool's 24 hours but leaves unlocked levels in place. It accepts `qualify` calls from the hook it was deployed for and nobody else", normalized_form: "as SPEC-042 to 046", confidence: 0.95}
- {id: SPEC-154, source_document: README.md, source_section: "Dices launchpad, deployment paragraph", semantic_type: flow, spec_excerpt: "It mines a hook address carrying the `beforeInitialize`, `beforeAddLiquidity`, `beforeRemoveLiquidity`, `beforeSwap`, `afterSwap` and `afterSwapReturnDelta` flags, passes the deployer as the hook's explicit owner, then sets the coin implementation, trusts the Universal Router and hands ownership to the configured protocol owner.", normalized_form: "V001 sequence", confidence: 1.0}
- {id: SPEC-155, source_document: README.md, source_section: "Usage, Build", semantic_type: convention, spec_excerpt: "Our contracts, interfaces, deployment scripts and tests compile with **Solidity 0.8.38** for **Osaka** ... The upstream Uniswap v4 `PoolManager` pins Solidity 0.8.26.", normalized_form: "compiler pins", confidence: 1.0}
- {id: SPEC-156, source_document: README.md, source_section: "Usage, Test", semantic_type: convention, spec_excerpt: "Stateful invariants check escrow solvency, token conservation, zero PoolManager debts, and the permanent launch-position lock over 64 runs of up to 32 actions. CI requires **100% line, statement, branch, and function coverage**", normalized_form: "test and coverage claims", confidence: 0.9}
- {id: SPEC-157, source_document: README.md, source_section: "Usage, Deploy", semantic_type: flow, spec_excerpt: "Supported chains are Base (8453) and Base Sepolia (84532). Nothing is read from the environment ... the script reverts while the fee recipient or buy and burn recipient is unset. A broadcast writes the address book to `deployments/deployment-<chainId>.json` and `.md`.", normalized_form: "chains; no env; mainnet guards; outputs", confidence: 1.0}
- {id: SPEC-158, source_document: README.md, source_section: "Usage, Generate activity", semantic_type: flow, spec_excerpt: "launches an Activity Coin (`ACT`), then makes three buys and two sells through the trusted Universal Router ... The signer needs **30 USDC** ... These small trades do not meet the thresholds for `PoolLive`.", normalized_form: "activity script behaviour (outside scoped code)", confidence: 0.8}
# NatSpec: src/DicesHook.sol and src/interfaces/IDicesHook.sol
- {id: SPEC-159, source_document: src/DicesHook.sol, source_section: "contract NatSpec, L44-L47", semantic_type: flow, spec_excerpt: "Collects hook fees in the unspecified swap currency. Launched-token fees are queued for internal conversion, while paired-currency fees are credited to protocol, creator and buy-and-burn recipients.", normalized_form: "fee currency = unspecified; coin -> ISP; USDC -> 3 credits", confidence: 1.0}
- {id: SPEC-160, source_document: src/DicesHook.sol, source_section: "SALE_END_TICK NatSpec, L89-L93", semantic_type: constant, spec_excerpt: "The tick at which the sale position ends and the upper position begins: a $200,000 market cap. ... the tick is negated for that ordering. Buying the whole sale position from a $12,500 launch raises about $35,000 of USDC.", normalized_form: "SALE_END_TICK = tick($200k) = -361_500", confidence: 1.0}
- {id: SPEC-161, source_document: src/DicesHook.sol, source_section: "usdc NatSpec, L108", semantic_type: structure, spec_excerpt: "The paired currency for every pool. Fees, reserves and the raised total are in this currency", normalized_form: "fees, reserves, raised total all in USDC", confidence: 0.95}
- {id: SPEC-162, source_document: src/DicesHook.sol, source_section: "constructor NatSpec, L196-L197", semantic_type: access_control, spec_excerpt: "The initial owner and protocol fee recipient. Passed explicitly because the hook is deployed through a CREATE3 factory", normalized_form: "owner = feeRecipient = _owner", confidence: 1.0}
- {id: SPEC-163, source_document: src/DicesHook.sol, source_section: "guard NatSpec, L246-L247, L283, L299-L300", semantic_type: security_requirement, spec_excerpt: "The hook supplies launch liquidity; the internal swap pool supplies its own temporary positions. ... Hook-owned launch liquidity is locked. Only the internal swap pool may remove its own JIT positions. ... PoolManager keys position ownership to its caller, so the internal pool cannot withdraw the hook's positions.", normalized_form: "add: {hook, ISP}; remove: {ISP, own positions only}", confidence: 1.0}
- {id: SPEC-164, source_document: src/DicesHook.sol, source_section: "_beforeSwap NatSpec and comments, L314, L328, L332; IDicesHook.sol L161-L163", semantic_type: security_requirement, spec_excerpt: "Prevents 0-block buys ... Prevents bots from buying in the same block as launch, unless token creator. ... Only approved launching routers may swap in the launch block.", normalized_form: "launch block: only the creator may buy (L328) OR only trusted routers may swap (L332)", confidence: 0.6}
- {id: SPEC-165, source_document: src/DicesHook.sol, source_section: "comment, L338", semantic_type: structure, spec_excerpt: "Mark the pool before external calls so BuyAndBurn cannot process after a swap in this block.", normalized_form: "a BuyAndBurn component reads lastSwapBlock", confidence: 0.8}
- {id: SPEC-166, source_document: src/DicesHook.sol, source_section: "_afterSwap NatSpec, L361", semantic_type: structure, spec_excerpt: "@notice The hook's own swaps.", normalized_form: "_afterSwap handles swaps made by the hook", confidence: 0.7}
- {id: SPEC-167, source_document: src/DicesHook.sol, source_section: "_syncLevel comment, L434-L435", semantic_type: security_requirement, spec_excerpt: "Unlocking a level is a side effect of trading, so a fault in the calculator must never block a swap. A call that reverts simply leaves the pool as it is.", normalized_form: "any calculator fault is contained", confidence: 0.85}
- {id: SPEC-168, source_document: src/DicesHook.sol, source_section: "createCoin comment, L549-L550", semantic_type: structure, spec_excerpt: "Deploy the coin with a chain-specific salt so other chains cannot replicate its address", normalized_form: "salt includes block.chainid", confidence: 1.0}
- {id: SPEC-169, source_document: src/DicesHook.sol, source_section: "unlockCallback comment, L613", semantic_type: structure, spec_excerpt: "Settle the actual debit of both positions; any liquidity-rounding remainder stays in the hook", normalized_form: "hook keeps launch dust", confidence: 1.0}
- {id: SPEC-170, source_document: src/DicesHook.sol, source_section: "_addInitialTokenLiquidity NatSpec, L689-L691", semantic_type: invariant, spec_excerpt: "The ticks are used exactly as given. A range that is the wrong way round has to fail in the PoolManager rather than be reordered here", normalized_form: "no tick reordering", confidence: 1.0}
- {id: SPEC-171, source_document: src/interfaces/IDicesHook.sol, source_section: "CoinParams NatSpec, L24-L37", semantic_type: abi, spec_excerpt: "Metadata and fee recipient supplied when launching a coin. ... Recipient of the creator's trading fees.", normalized_form: "CoinParams = {name, symbol, creator}", confidence: 1.0}
- {id: SPEC-172, source_document: src/interfaces/IDicesHook.sol, source_section: "events NatSpec, L40-L53", semantic_type: event, spec_excerpt: "Always followed by `PoolLevelUnlocked`, which carries the level that was reached. ... Emitted once per rise, so `level` can be more than one above `previousLevel`.", normalized_form: "PoolLive then PoolLevelUnlocked; one per rise", confidence: 1.0}
- {id: SPEC-173, source_document: src/interfaces/IDicesHook.sol, source_section: "errors NatSpec, L96-L169", semantic_type: abi, spec_excerpt: "The native value supplied for a launch differs from its creation fee. ... A caller tried to add unauthorized liquidity or remove locked liquidity. ... An untrusted router tried to swap in the pool's launch block. ... A level check was requested for an address that the hook did not launch.", normalized_form: "each declared error is raised for its stated condition", confidence: 0.9}
- {id: SPEC-174, source_document: src/interfaces/IDicesHook.sol, source_section: "createCoin NatSpec, L298-L304", semantic_type: formula, spec_excerpt: "The supply is split three ways: 70% in a sale position from the launch price to a $200,000 market cap, 20% in an upper position from there to the usable tick limit, and 10% to the coin's bankroll.", normalized_form: "70 / 20 / 10", confidence: 1.0}
- {id: SPEC-175, source_document: src/interfaces/IDicesHook.sol, source_section: "syncLevel NatSpec, L307-L312", semantic_type: flow, spec_excerpt: "Callable by anyone. Does nothing when the pool qualifies for no level above the one it holds.", normalized_form: "no state change unless a level is unlocked", confidence: 0.9}
- {id: SPEC-176, source_document: src/interfaces/IDicesHook.sol, source_section: "setters NatSpec, L315-L358", semantic_type: access_control, spec_excerpt: "Replace the trading fee and initial-price calculator; callable only by the owner. ... Pause coin creation; callable only by the owner.", normalized_form: "all setters onlyOwner; pause affects createCoin only", confidence: 1.0}
# NatSpec: DicesCoin
- {id: SPEC-177, source_document: src/DicesCoin.sol, source_section: "contract NatSpec, L9-L16; L30-L32", semantic_type: structure, spec_excerpt: "The whole supply is minted to the hook at creation. ... The count is maintained on every balance change, so reading it is a single storage read however many holders there are. ... The balance that an address needs to count as a qualifying holder (300,000 coins)", normalized_form: "mint all to hook; O(1) count; threshold 300_000e18", confidence: 1.0}
- {id: SPEC-178, source_document: src/DicesCoin.sol, source_section: "immutables NatSpec, L35-L58", semantic_type: invariant, spec_excerpt: "it is never counted as a holder ... The exclusion belongs to this address alone. Coins that the bankroll pays out count like any others", normalized_form: "four excluded addresses", confidence: 1.0}
- {id: SPEC-179, source_document: src/DicesCoin.sol, source_section: "_initialized NatSpec, L75-L76", semantic_type: structure, spec_excerpt: "The three holder fields below share this slot, which `initialize` has already written", normalized_form: "one slot for {_initialized, _holdersChangedAt, _holders, _holdersBefore}", confidence: 0.9}
- {id: SPEC-180, source_document: src/DicesCoin.sol, source_section: "qualifiedHolders NatSpec, L159-L166; IDicesCoin.sol L109-L115", semantic_type: security_requirement, spec_excerpt: "A holder that crossed the threshold in this block is therefore not reported until the next block, by which point the coins must really belong to it.", normalized_form: "as SPEC-084", confidence: 0.9}
- {id: SPEC-181, source_document: src/interfaces/IDicesCoin.sol, source_section: "initialize and burn NatSpec, L63-L76", semantic_type: abi, spec_excerpt: "Set a clone's metadata and mint its initial supply exactly once. ... Burn tokens from the caller's balance.", normalized_form: "initialize once; burn(msg.sender)", confidence: 1.0}
- {id: SPEC-182, source_document: src/interfaces/IDicesCoin.sol, source_section: "interface NatSpec, L8-L60", semantic_type: abi, spec_excerpt: "DicesCoin initialization and burning, with its inherited ERC20 and permit API. ... An approval attempted to change Solady's fixed infinite Permit2 allowance.", normalized_form: "ABI = ERC20 + permit + solady errors", confidence: 0.85}
# NatSpec: LiveCalculator
- {id: SPEC-183, source_document: src/calculators/LiveCalculator.sol, source_section: "contract NatSpec, L18-L39", semantic_type: flow, spec_excerpt: "A level needs the coin's market cap, averaged over the last 24 hours, to be at or above that level's target, $200,000 for level one and doubling up to $102,000,000 for level ten ... The average is taken from the checkpoint that is at least 24 hours old ... Only the hook that the calculator was deployed for can call `qualify`", normalized_form: "as SPEC-011, 101, 110", confidence: 0.95}
- {id: SPEC-184, source_document: src/calculators/LiveCalculator.sol, source_section: "constants NatSpec, L66-L94", semantic_type: constant, spec_excerpt: "The number of game levels. ... The shortest span of history that the market cap is averaged over ... The number of checkpoints kept per pool: one for each end of every period in a window ... The launch supply of every coin", normalized_form: "LEVELS 10; WINDOW 24h; PERIOD 1h; PERIODS 24; CHECKPOINTS 25; SUPPLY 1e27", confidence: 1.0}
- {id: SPEC-185, source_document: src/calculators/LiveCalculator.sol, source_section: "levelTicks NatSpec, L212-L218", semantic_type: formula, spec_excerpt: "Each is the lowest tick at which the 1e27 launch supply is worth at least the level's target in six-decimal USDC, so an average at the tick is never short of the target.", normalized_form: "as SPEC-094", confidence: 1.0}
- {id: SPEC-186, source_document: src/calculators/LiveCalculator.sol, source_section: "view NatSpec, L168-L209; ILiveCalculator.sol L59-L84", semantic_type: abi, spec_excerpt: "The average coin tick, rounded down. Zero when `ready_` is false ... The average market cap in USDC, or zero until the pool has a full window of history", normalized_form: "view return conventions", confidence: 1.0}
- {id: SPEC-187, source_document: src/calculators/LiveCalculator.sol, source_section: "comments, L269, L324, L335, L398", semantic_type: invariant, spec_excerpt: "A timestamp does not reach 32 bits until the year 2106 ... A window is at least `WINDOW` long, so the division is never by zero ... A tick is under 2^20 and a timestamp under 2^32, so their product over any span fits in 56 bits", normalized_form: "no overflow, no division by zero", confidence: 0.95}
- {id: SPEC-188, source_document: src/interfaces/ILiveCalculator.sol, source_section: "qualify NatSpec, L86-L94", semantic_type: flow, spec_excerpt: "Must be called after every swap of a pool, otherwise the price history would miss the move. Only the hook that the calculator was deployed for may call it ... It can fall; the hook is what keeps levels from going down.", normalized_form: "as SPEC-098, 110, 105", confidence: 1.0}
# NatSpec: FeeCalculator
- {id: SPEC-189, source_document: src/calculators/FeeCalculator.sol, source_section: "constants NatSpec, L16-L38", semantic_type: constant, spec_excerpt: "The share of every collected fee that goes to the creator (30%) ... buy and burn (30%). The platform receives the rest (40%). ... The trading fee rate before the pool goes Live (1.25%) ... once the pool is Live (1.00%)", normalized_form: "30 / 30 / 40; 1250; 1000 of 100_000", confidence: 1.0}
- {id: SPEC-190, source_document: src/calculators/FeeCalculator.sol, source_section: "launch constants NatSpec, L41-L63", semantic_type: formula, spec_excerpt: "The market cap that every coin launches at, in six-decimal USDC ($12,500) ... `sqrt(LAUNCH_MARKET_CAP * 2**192 / 1e27)`, rounded down. ... `sqrt(1e27 * 2**192 / LAUNCH_MARKET_CAP)`, rounded down.", normalized_form: "two sqrtPriceX96 constants", confidence: 1.0}
- {id: SPEC-191, source_document: src/calculators/FeeCalculator.sol, source_section: "getFeeDistribution NatSpec, L77-L89", semantic_type: abi, spec_excerpt: "@param _amount The amount of USDC being swapped. ... Calculate the fee that will be sent to the holders", normalized_form: "_amount = USDC swapped; third share goes to holders", confidence: 0.8}
- {id: SPEC-192, source_document: src/interfaces/IFeeCalculator.sol, source_section: "interface NatSpec, L4-L30", semantic_type: abi, spec_excerpt: "Collected fee in raw units of the currency being distributed. ... Pool Live flag, currently unused by the default implementation.", normalized_form: "ABI semantics", confidence: 1.0}
# NatSpec: FeeEscrow, InternalSwapPool, TrustedRouters, libraries, IFlaunch
- {id: SPEC-193, source_document: src/core/FeeEscrow.sol, source_section: "contract NatSpec, L14-L17", semantic_type: security_requirement, spec_excerpt: "Shared, fully funded address credits. Anyone may fund or trigger payment to a beneficiary. ... No administrator can redirect credits. ... Unsolicited transfers do not create credits. Fee-on-transfer and rebasing currencies are unsupported.", normalized_form: "balance >= credits; no admin", confidence: 1.0}
- {id: SPEC-194, source_document: src/core/FeeEscrow.sol, source_section: "function NatSpec, L28, L76, L85, L97", semantic_type: flow, spec_excerpt: "Credit a beneficiary with exactly the supplied funds. ... Pay a beneficiary's full currency credit to that beneficiary, regardless of caller. ... Any failed payment restores the entire batch. ... Zero credits (including duplicate batch entries) are no-ops. Effects precede interaction.", normalized_form: "deposit, claim, claimBatch semantics", confidence: 1.0}
- {id: SPEC-195, source_document: src/core/InternalSwapPool.sol, source_section: "deposit NatSpec, L120-L126; IInternalSwapPool.sol L59-L64", semantic_type: access_control, spec_excerpt: "This function works as a registration function and assume tokens have already been transferred to this contract. ... callable only by the hook.", normalized_form: "deposit: onlyHook; bookkeeping only", confidence: 1.0}
- {id: SPEC-196, source_document: src/core/InternalSwapPool.sol, source_section: "createInternalSwapPool comments, L151-L160, L189-L201", semantic_type: flow, spec_excerpt: "We also make sure that there are fees in the internal swap pool that are worth interacting with. ... A spot price that no active liquidity backs would place the whole inventory where it is worth dust, so keep it for a swap that trades inside the liquidity.", normalized_form: "JIT only for buys with inventory >= minimum and active liquidity", confidence: 0.9}
- {id: SPEC-197, source_document: src/core/InternalSwapPool.sol, source_section: "closeInternalSwapPool NatSpec, L217-L223, L241-L242", semantic_type: flow, spec_excerpt: "Runs inside `afterSwap`, where it settles the launched token with `sync`/`settle` and takes the paired proceeds. ... a router must sync its own input only after the swap", normalized_form: "close: settle coin, take USDC, credit escrow", confidence: 0.95}
- {id: SPEC-198, source_document: src/interfaces/IInternalSwapPool.sol, source_section: "feeCalculator NatSpec, L46-L50", semantic_type: structure, spec_excerpt: "Return the calculator used to split converted fee proceeds. @return Fee calculator fixed at construction.", normalized_form: "ISP.feeCalculator immutable", confidence: 1.0}
- {id: SPEC-199, source_document: src/interfaces/ITrustedRouters.sol, source_section: "interface NatSpec, L4-L27", semantic_type: access_control, spec_excerpt: "Return whether a router is trusted for wallet attribution. ... Whether the hook may attribute swaps through this router.", normalized_form: "trustedRouters used for attribution only", confidence: 0.85}
- {id: SPEC-200, source_document: src/libraries/CurrencySettler.sol, source_section: "settle NatSpec, L18-L28", semantic_type: flow, spec_excerpt: "Syncs immediately before settling, as PoolManager requires. ... routers must sync after the swap.", normalized_form: "sync -> transfer -> settle", confidence: 1.0}
- {id: SPEC-201, source_document: src/libraries/UniswapEvents.sol, source_section: "HookSwap and HookFee NatSpec, L18-L33", semantic_type: event, spec_excerpt: "`amount0`/`amount1` are the pool's pre-fee swap deltas from the swapper's view, and the fee is reported in the currency it was taken from (the unspecified currency), the other slot being zero. `sender` is the router PoolManager saw, not the resolved swapper.", normalized_form: "HookSwap / HookFee semantics", confidence: 1.0}
- {id: SPEC-202, source_document: src/libraries/UniswapEvents.sol, source_section: "PoolSwap NatSpec, L40-L43; IUniswapEvents.sol L38-L46", semantic_type: event, spec_excerpt: "Pool swap deltas and fees emitted directly by DicesHook.", normalized_form: "hook emits PoolSwap", confidence: 0.95}
- {id: SPEC-203, source_document: src/libraries/UniswapEvents.sol, source_section: "PoolLiquidityDelta and PoolDonation NatSpec, L45-L53, L97-L117", semantic_type: event, spec_excerpt: "Net reserve changes from liquidity modification, including collected LP fees. ... Donation credits retained by a pool until LP fees are withdrawn.", normalized_form: "these events are emitted on liquidity changes and donations", confidence: 0.8}
- {id: SPEC-204, source_document: src/interfaces/IFlaunch.sol, source_section: "interface NatSpec, L6-L15", semantic_type: abi, spec_excerpt: "External pool-token registry lookup API.", normalized_form: "an external registry is consulted", confidence: 0.7}
# NatSpec: script/deployment/V001.s.sol
- {id: SPEC-205, source_document: script/deployment/V001.s.sol, source_section: "header, Configuration, L51-L69", semantic_type: flow, spec_excerpt: "PROTOCOL_OWNER Final owner of the hook. Zero keeps the deployer as owner, on any chain. ... On a testnet a zero recipient or bankroll defaults to the deployer. On mainnet either one reverts before anything is broadcast ... A bankroll that is one of the launchpad contracts is rejected on every chain.", normalized_form: "destination resolution rules", confidence: 1.0}
- {id: SPEC-206, source_document: script/deployment/V001.s.sol, source_section: "header, Deterministic addresses, L71-L85", semantic_type: invariant, spec_excerpt: "Every contract, including the UniswapEvents library, is deployed through the canonical CreateX factory using CREATE3. The address book depends only on the signing wallet and DEPLOYMENT_SALT ... An occupied address aborts a run before broadcasting.", normalized_form: "addresses = f(signer, salt, name)", confidence: 0.95}
- {id: SPEC-207, source_document: script/deployment/V001.s.sol, source_section: "header, Ownership, L87-L91", semantic_type: access_control, spec_excerpt: "the hook takes its owner as an argument. The deployer is that initial owner ... Ownership is then transferred to PROTOCOL_OWNER when one is set.", normalized_form: "owner handover sequence", confidence: 1.0}
- {id: SPEC-208, source_document: script/deployment/V001.s.sol, source_section: "constants NatSpec, L110-L120", semantic_type: constant, spec_excerpt: "A matching address is expected every 16,384 attempts ... Mirror of `DicesHook.getHookPermissions()`. The mined hook address must carry exactly these bits", normalized_form: "HOOK_FLAGS == 0x2AC4; exact-match mining", confidence: 1.0}
- {id: SPEC-209, source_document: script/deployment/V001.s.sol, source_section: "header, Output, L93-L96", semantic_type: flow, spec_excerpt: "After a broadcast deployment the address book is written ... Dry runs write nothing.", normalized_form: "persist iff broadcasting", confidence: 1.0}
```

---
## Appendix B: Code-IR

One record per function. `pre` lists revert conditions, `reads` / `writes` state, `calls` external calls with return handling, `inv` the invariants or postconditions the block enforces. Line numbers refer to commit `bcd45b2`.

```yaml
# ---------------- src/DicesHook.sol ----------------
- {id: CODE-H01, file: src/DicesHook.sol, function: "constructor(IPoolManager,address,address payable,address,address,address,address)", lines: 199-225, visibility: public, modifiers: ["BaseHook(_poolManager)", "Ownable(_owner)"],
   pre: ["_usdc == 0 or decimals() != 6 -> InvalidUSDC (L201-L203)", "hook address bits != permissions -> revert in BaseHook.validateHookAddress (BaseHook.sol:L19)", "calculator without code -> InvalidCalculator (L820, L833)"],
   writes: ["usdc L206 (immutable)", "feeRecipient = _owner L209", "internalSwapPool L212", "feeEscrow L215", "buyAndBurnRecipient L218 (no zero check)", "feeCalculator L221", "liveCalculator L224"],
   calls: ["IERC20Metadata(_usdc).decimals() L201", "internalSwapPool.feeEscrow() L215 (ISP must already exist)"], events: [FeeCalculatorUpdated, LiveCalculatorUpdated],
   inv: ["usdc has 6 decimals", "internalSwapPool and feeEscrow have no setter", "owner passed explicitly, never msg.sender"]}
- {id: CODE-H02, file: src/DicesHook.sol, function: "getHookPermissions()", lines: 236-243, visibility: "public pure", modifiers: [],
   computations: ["sets beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta"],
   inv: ["no beforeSwapReturnDelta", "no donate hooks", "no after-liquidity hooks"]}
- {id: CODE-H03, file: src/DicesHook.sol, function: "_beforeInitialize(address,PoolKey,uint160)", lines: 254-280, visibility: internal, modifiers: ["via BaseHook.beforeInitialize onlyPoolManager"],
   pre: ["_sender != this -> Unauthorized L256-L258", "fee != 0 -> InvalidFee L261-L263", "tickSpacing != 60 -> InvalidTickSpacing L266-L268", "neither currency is usdc -> InvalidPairedCurrency L271-L273"],
   writes: ["launchBlock[poolId] L276"],
   inv: ["third parties cannot initialise a pool on this hook", "L260-L279 unreachable in production: PoolManager skips the callback when the hook is the caller (Hooks.sol:L171-L181)", "the three key checks are therefore guaranteed only by createCoin building the key"]}
- {id: CODE-H04, file: src/DicesHook.sol, function: "_beforeAddLiquidity(address,PoolKey,ModifyLiquidityParams,bytes)", lines: 289-296, visibility: "internal view", modifiers: ["via BaseHook onlyPoolManager"],
   pre: ["_sender not in {this, internalSwapPool} -> LiquidityLocked L291-L293"], reads: [internalSwapPool],
   inv: ["only two addresses can add liquidity", "not invoked for the hook's own calls", "params not inspected"]}
- {id: CODE-H05, file: src/DicesHook.sol, function: "_beforeRemoveLiquidity(address,PoolKey,ModifyLiquidityParams,bytes)", lines: 302-307, visibility: "internal view", modifiers: ["via BaseHook onlyPoolManager"],
   pre: ["sender != internalSwapPool -> LiquidityLocked L303-L305"],
   inv: ["called for liquidityDelta <= 0 (Hooks.sol:L203), so zero-delta pokes by others revert", "ISP can affect only positions keyed to itself (Pool.sol:L187)", "hook positions unreachable"]}
- {id: CODE-H06, file: src/DicesHook.sol, function: "_beforeSwap(address,PoolKey,SwapParams,bytes)", lines: 325-358, visibility: internal, modifiers: ["via BaseHook onlyPoolManager"],
   pre: ["launchBlock[poolId] == block.number and !trustedRouters[sender] -> CannotBuyZeroBlock L334-L336"],
   reads: [launchBlock, trustedRouters], writes: ["lastSwapBlock[poolId] = block.number L339"],
   calls: ["_getSender(sender): staticcall to a trusted router L350", "internalSwapPool.createInternalSwapPool(...) L350 (reverts bubble)"],
   computations: ["returns (selector, zero BeforeSwapDelta, 0) L357"],
   inv: ["no fee taken before the swap", "LP fee override 0", "guard keyed on router, not swapper"]}
- {id: CODE-H07, file: src/DicesHook.sol, function: "_afterSwap(address,PoolKey,SwapParams,BalanceDelta,bytes)", lines: 372-386, visibility: internal, modifiers: ["via BaseHook onlyPoolManager"],
   calls: ["internalSwapPool.closeInternalSwapPool L373", "_swapFee L375", "_collectSwapFee L377", "_syncLevel L382", "UniswapEvents.emitHookFee / emitSwapUpdate / emitPoolStateUpdate (linked library, delegatecall) L378-L384"],
   events: ["HookFee (fee != 0)", HookSwap, PoolStateUpdated, "PoolLive / PoolLevelUnlocked via _syncLevel"],
   inv: ["fee uses the Live state from before _syncLevel", "price is observed after it moved", "returnDelta == fee amount in the unspecified currency"]}
- {id: CODE-H08, file: src/DicesHook.sol, function: "poolLive(PoolId)", lines: 395-397, visibility: "public view", modifiers: [], reads: [poolLevel], inv: ["poolLive == (poolLevel != 0)", "pure function of storage", "never reverts"]}
- {id: CODE-H09, file: src/DicesHook.sol, function: "syncLevel(address)", lines: 408-417, visibility: external, modifiers: [],
   pre: ["poolKeys[_coin].hooks == 0 -> UnknownCoin L412-L414"], reads: [poolKeys], calls: ["_syncLevel L416"],
   inv: ["callable by anyone", "only for coins this hook launched", "every call makes the calculator observe (write)"]}
- {id: CODE-H10, file: src/DicesHook.sol, function: "_syncLevel(PoolKey,PoolId)", lines: 433-449, visibility: private, modifiers: [],
   calls: ["try liveCalculator.qualify(_poolKey) L436; catch {} L448"], reads: ["poolLevel L437"], writes: ["poolLevel[_poolId] = level if level > unlocked L438-L439"],
   events: ["PoolLive if unlocked == 0 L442-L444", "PoolLevelUnlocked(unlocked, level) L446"],
   inv: ["level never decreases", "a reverting calculator changes nothing", "no upper bound on level (uint8)"]}
- {id: CODE-H11, file: src/DicesHook.sol, function: "_swapFee(PoolKey,SwapParams,BalanceDelta)", lines: 458-463, visibility: "private view", modifiers: [],
   computations: ["unspecified = (amountSpecified < 0 == zeroForOne) ? currency1 : currency0 L460", "amount = |delta of unspecified| L461", "fee = mulDiv(amount, feeCalculator.getSwapFee(poolLive), 100_000), rounds down L462"],
   calls: ["feeCalculator.getSwapFee (view) L462"],
   inv: ["fee currency is always the unspecified currency", "no buy/sell distinction", "rate not bounded"]}
- {id: CODE-H12, file: src/DicesHook.sol, function: "_collectSwapFee(PoolId,SwapFee)", lines: 471-483, visibility: private, modifiers: [],
   pre: ["fee > int128 max -> SafeCast revert L472"],
   calls: ["poolManager.take(currency, this, fee) L473", "coin: currency.transfer(ISP) + ISP.deposit L475-L476", "USDC: feeCalculator.getFeeDistribution L478; three _creditFee L479-L481"],
   reads: [poolCoins, poolCreators, feeRecipient, buyAndBurnRecipient],
   inv: ["hook take is offset by the returned hook delta", "coin fees never reach the escrow", "split sum not checked against fee"]}
- {id: CODE-H13, file: src/DicesHook.sol, function: "_feeAmounts / _emitHookFee / _emitHookSwap", lines: "492-495, 504-507, 517-520", visibility: private, modifiers: [],
   events: ["HookFee(id, router, fee0, fee1)", "HookSwap(id, router, amount0, amount1, fee0, fee1)"],
   inv: ["fee reported in the slot of the currency it was taken in", "amounts are pre-fee swap deltas", "sender is the router"]}
- {id: CODE-H14, file: src/DicesHook.sol, function: "createCoin(CoinParams)", lines: 533-578, visibility: "external payable", modifiers: [whenNotPaused],
   pre: ["createFee > 0 and msg.value != createFee -> InvalidCreationFee L537-L539", "createFee == 0 and msg.value != 0 -> InvalidCreationFee L545-L547", "paused -> revert in Pausable.whenNotPaused"],
   writes: ["coinCount++ L551", "poolKeys[coin], poolCoins[poolId] L570-L571", "poolCreators[poolId] = params.creator L574 (unchecked)"],
   calls: ["_creditFee(feeRecipient, native, createFee) L542", "LibClone.cloneDeterministic(coinImplementation, keccak256(chainid, coinCount)) L551", "DicesCoin.initialize(name, symbol, 1e27, this) L554", "coin.transfer(coin.bankroll(), 1e26) L558", "poolManager.unlock L577"],
   inv: ["exact creation fee", "10% to the coin's own bankroll", "key = {fee 0, spacing 60, hooks this}", "no creator validation, no game commitment, no event of its own"]}
- {id: CODE-H15, file: src/DicesHook.sol, function: "unlockCallback(bytes)", lines: 587-618, visibility: external, modifiers: [onlyPoolManager],
   calls: ["feeCalculator.getInitialSqrtPriceX96 L595", "poolManager.initialize L598", "_addLaunchLiquidity L607", "CurrencySettler.settle(coin, owed) L614"],
   writes: ["launchBlock[poolId] = block.number L601"], events: ["PoolCreated L604", "PoolStateUpdated L611"],
   inv: ["reachable only through createCoin (unlock is called only at L577)", "settles exactly the debit of both positions", "dust stays in the hook"]}
- {id: CODE-H16, file: src/DicesHook.sol, function: "_addLaunchLiquidity(PoolKey,bool)", lines: 633-655, visibility: private, modifiers: [],
   pre: ["coin0: launchTick >= SALE_END_TICK -> InvalidLaunchPrice L641-L643", "coin1: launchTick <= -SALE_END_TICK -> InvalidLaunchPrice L648-L650"],
   calls: ["poolManager.getSlot0 L635", "_addInitialTokenLiquidity x2 L645-L646 / L652-L653"],
   inv: ["coin0: [launchTick, -361500) 7e26 and [-361500, maxUsableTick] 2e26", "coin1: [361500, launchTick] and [minUsableTick, 361500]", "both positions out of range at launch"]}
- {id: CODE-H17, file: src/DicesHook.sol, function: "_launchTick(uint160,int24,bool)", lines: 670-684, visibility: "internal pure", modifiers: [],
   computations: ["truncate tick to a multiple of 60 L673", "coin0: +60 if price > price(tick) L677-L679", "coin1: -60 if tick < aligned L680-L683"],
   inv: ["coin0: aligned tick >= launch price", "coin1: aligned tick <= launch tick", "result is a multiple of 60"]}
- {id: CODE-H18, file: src/DicesHook.sol, function: "_addInitialTokenLiquidity(PoolKey,bool,int24,int24,uint)", lines: 701-719, visibility: internal, modifiers: [],
   pre: ["liquidity == 0 -> ZeroLiquidity L710-L712", "misordered ticks -> PoolManager TicksMisordered"],
   calls: ["poolManager.modifyLiquidity(key, {lower, upper, +liquidity, salt ''}, '') L715"],
   inv: ["liquidityDelta strictly positive (the hook's only modifyLiquidity call)", "position owner is the hook", "owed = coin debit, rounded up by the manager"]}
- {id: CODE-H19, file: src/DicesHook.sol, function: "_creditFee(address,address,uint)", lines: 731-741, visibility: private, modifiers: [],
   pre: ["recipient == 0 and amount > 0 -> InvalidBeneficiary in escrow (FeeEscrow.sol:L36-L38)"],
   calls: ["feeEscrow.deposit{value}(recipient, 0, amount) L736", "forceApprove + feeEscrow.deposit L738-L739"],
   inv: ["zero amounts skipped", "exact approval per deposit", "credit is funded or the call reverts"]}
- {id: CODE-H20, file: src/DicesHook.sol, function: "setFeeCalculator / setLiveCalculator / _setFeeCalculator / _setLiveCalculator", lines: "752-754, 761-763, 819-825, 832-838", visibility: "external / private", modifiers: [onlyOwner],
   pre: ["_calculator.code.length == 0 -> InvalidCalculator L820-L822, L833-L835"], writes: [feeCalculator, liveCalculator], events: [FeeCalculatorUpdated, LiveCalculatorUpdated],
   inv: ["owner only", "address has code", "no interface, hook-binding, rate or level check; takes effect for all pools at once"]}
- {id: CODE-H21, file: src/DicesHook.sol, function: "setBuyAndBurnRecipient / setFeeRecipient", lines: "770-776, 793-799", visibility: external, modifiers: [onlyOwner],
   pre: ["zero address -> ZeroAddress L771-L773, L794-L796"], writes: [buyAndBurnRecipient, feeRecipient], events: [BuyAndBurnRecipientUpdated, FeeRecipientUpdated],
   inv: ["owner only", "non-zero", "affects future credits only; existing escrow credits stay with the old address"]}
- {id: CODE-H22, file: src/DicesHook.sol, function: "setCreateFee(uint)", lines: 783-786, visibility: external, modifiers: [onlyOwner], writes: [createFee], events: [CreateFeeUpdated], inv: ["owner only", "no upper bound", "applies to later launches"]}
- {id: CODE-H23, file: src/DicesHook.sol, function: "setCoinImplementation(address)", lines: 806-812, visibility: external, modifiers: [onlyOwner], pre: ["no code -> ZeroAddress L807-L809"], writes: [coinImplementation], events: [CoinImplementationUpdated], inv: ["owner only", "has code", "launched coins unaffected"]}
- {id: CODE-H24, file: src/DicesHook.sol, function: "pause() / unpause()", lines: "843-845, 850-852", visibility: external, modifiers: [onlyOwner], writes: ["Pausable._paused"], inv: ["owner only", "gates createCoin only", "swaps and syncLevel unaffected"]}
- {id: CODE-H25, file: src/DicesHook.sol, function: "inherited: BaseHook callbacks without override; Ownable.transferOwnership / renounceOwnership", lines: "BaseHook.sol:L49, L98, L121, L180, L199; Ownable.sol:L76-L97", visibility: external, modifiers: ["onlyPoolManager / onlyOwner"],
   inv: ["unimplemented callbacks revert HookNotImplemented and are never called (flags unset)", "ownership transfer is single step", "ownership can be renounced"]}
# ---------------- src/core/TrustedRouters.sol ----------------
- {id: CODE-T01, file: src/core/TrustedRouters.sol, function: "setTrustedRouter(address,bool)", lines: 25-28, visibility: public, modifiers: [onlyOwner], writes: [trustedRouters], events: [TrustedRouterSet], inv: ["owner only", "no code check on the router", "also changes who may swap in a launch block"]}
- {id: CODE-T02, file: src/core/TrustedRouters.sol, function: "_getSender(address)", lines: 37-52, visibility: "internal view", modifiers: [], reads: [trustedRouters],
   calls: ["_router.staticcall(IMsgSender.msgSender()) L44; failure or short data -> address(0)"],
   inv: ["untrusted router -> address(0) without a call", "never reverts", "allowlist is consulted before the call"]}
# ---------------- src/DicesCoin.sol ----------------
- {id: CODE-C01, file: src/DicesCoin.sol, function: "constructor(address,address,address,address)", lines: 103-113, visibility: public, modifiers: [], pre: ["_bankroll == 0 -> ZeroBankroll L105-L107"], writes: ["immutables hook, poolManager, internalSwapPool, bankroll L109-L112"], inv: ["bankroll non-zero", "exclusions fixed per implementation", "no owner"]}
- {id: CODE-C02, file: src/DicesCoin.sol, function: "initialize(string,string,uint,address)", lines: 123-138, visibility: external, modifiers: [], pre: ["_initialized -> AlreadyInitialized L125-L127"], writes: ["_initialized L130", "_name, _symbol L133-L134", "balances and totalSupply via _mint L137"], inv: ["once per contract", "no caller restriction", "mint goes through _afterTokenTransfer"]}
- {id: CODE-C03, file: src/DicesCoin.sol, function: "name() / symbol()", lines: "145-147, 154-156", visibility: "public view", modifiers: [], reads: [_name, _symbol], inv: ["set once", "empty before initialize", "no setter"]}
- {id: CODE-C04, file: src/DicesCoin.sol, function: "qualifiedHolders()", lines: 168-175, visibility: "external view", modifiers: [], reads: [_holdersChangedAt, _holdersBefore, _holders],
   computations: ["if changed this block and _holdersBefore < _holders return _holdersBefore else _holders"],
   inv: ["result <= count before this block's first change", "result <= current count", "single slot read"]}
- {id: CODE-C05, file: src/DicesCoin.sol, function: "burn(uint)", lines: 182-184, visibility: external, modifiers: [], pre: ["balance < amount -> InsufficientBalance (solady)"], writes: ["balance, totalSupply"], inv: ["caller's own balance only", "holder count updated", "LiveCalculator.SUPPLY is not"]}
- {id: CODE-C06, file: src/DicesCoin.sol, function: "_afterTokenTransfer(address,address,uint)", lines: 195-224, visibility: internal, modifiers: ["called by solady transfer, transferFrom, _mint, _burn, _transfer (ERC20.sol:L244, L345, L519, L551, L586)"],
   computations: ["skip if amount == 0 or from == to L197-L199", "left = countable(from) and balance(from) < T <= balance(from) + amount L203", "joined = countable(to) and balance(to) - amount < T <= balance(to) L207", "no change if left == joined L210-L212"],
   writes: ["_holdersChangedAt, _holdersBefore on the block's first change L216-L221", "_holders +/- 1 L223"],
   inv: ["count == number of countable addresses with balance >= 300_000e18", "_holdersBefore is the count before the block's first change", "checked uint32 arithmetic"]}
- {id: CODE-C07, file: src/DicesCoin.sol, function: "_spansThreshold / _isCountable", lines: "234-236, 247-249", visibility: "internal pure / view", modifiers: [], inv: ["threshold crossing test is inclusive at 300_000e18", "excluded: 0, hook, poolManager, internalSwapPool, bankroll", "FeeEscrow and calculators are countable"]}
- {id: CODE-C08, file: src/DicesCoin.sol, function: "inherited solady ERC20 (transfer, transferFrom, approve, permit)", lines: "solady ERC20.sol:L186-L431", visibility: public, modifiers: [], inv: ["Permit2 has a fixed infinite allowance (L667-L669)", "transfers revert on insufficient balance", "no transfer restriction for any address"]}
# ---------------- src/core/InternalSwapPool.sol ----------------
- {id: CODE-P01, file: src/core/InternalSwapPool.sol, function: "constructor(IPoolManager,IDicesHook,IFeeCalculator,IFeeEscrow)", lines: 105-117, visibility: public, modifiers: [], writes: ["four immutables L107-L116"], inv: ["hook fixed", "fee calculator fixed", "no owner"]}
- {id: CODE-P02, file: src/core/InternalSwapPool.sol, function: "deposit(address,uint)", lines: 127-138, visibility: public, modifiers: [onlyHook], writes: ["internalSwapPool[token] += amount L134"], events: [Deposit], inv: ["hook only", "zero is a no-op", "bookkeeping only: trusts that tokens arrived"]}
- {id: CODE-P03, file: src/core/InternalSwapPool.sol, function: "createInternalSwapPool(address,PoolKey,SwapParams,bytes)", lines: 146-214, visibility: public, modifiers: [onlyHook],
   pre: ["returns without action unless buy and inventory >= 1e6 L155", "pool liquidity == 0 -> return L159-L161", "range outside usable ticks -> return L190-L192", "liquidity == 0 -> return L200-L202"],
   reads: ["dicesHook.poolCoins L149", "internalSwapPool[token]", "slot0, liquidity, tick liquidity"],
   calls: ["poolManager.modifyLiquidity(+liquidity, JIT salt) L207"], writes: ["_internalSwapPoolState L212"],
   inv: ["position is one tick spacing wide and single sided in the coin", "liquidity clamped to per-tick capacity", "sender and hookData arguments unused"]}
- {id: CODE-P04, file: src/core/InternalSwapPool.sol, function: "closeInternalSwapPool(address,PoolKey,SwapParams,BalanceDelta,bytes)", lines: 226-279, visibility: public, modifiers: [onlyHook],
   pre: ["no JIT flag -> return L228-L230", "tokenDelta > 0 or pairedDelta < 0 -> 'Invalid JIT delta' L246", "creator or recipient == 0 with a non-zero share -> InvalidBeneficiary"],
   writes: ["delete _internalSwapPoolState L234", "internalSwapPool[token] -= spent L254"],
   calls: ["poolManager.modifyLiquidity(-liquidity) L239", "settle coin (upstream test CurrencySettler) L258", "take paired L262", "feeCalculator.getFeeDistribution (immutable calculator) L265", "three _creditFee L271-L277"],
   inv: ["removes exactly what create added", "inventory reduced by the coins actually sold", "proceeds fully credited (default calculator)"]}
- {id: CODE-P05, file: src/core/InternalSwapPool.sol, function: "_creditFee / _liquidityForInventory / _availableLiquidity / onlyHook / receive", lines: "287-297, 314-327, 341-347, 352-358, 363-365", visibility: "private / internal / modifier / external payable", modifiers: [],
   inv: ["zero credits skipped", "liquidity never exceeds remaining tick capacity", "msg.sender == dicesHook else OnlyHook"]}
# ---------------- src/core/FeeEscrow.sol ----------------
- {id: CODE-E01, file: src/core/FeeEscrow.sol, function: "deposit(address,address,uint)", lines: 34-73, visibility: "external payable", modifiers: [nonReentrant],
   pre: ["beneficiary == 0 -> InvalidBeneficiary L36-L38", "amount == 0 -> InvalidAmount L41-L43", "native: msg.value != amount -> InvalidNativeValue L47-L49", "ERC20: msg.value != 0 -> InvalidNativeValue L54-L56", "balance increase != amount -> UnexpectedTokenAmount L65-L67"],
   writes: ["claimable[beneficiary][currency] += amount L71"], calls: ["token.safeTransferFrom(msg.sender, this, amount) L61"], events: [Deposited],
   inv: ["every credit is fully funded", "permissionless", "fee-on-transfer tokens rejected"]}
- {id: CODE-E02, file: src/core/FeeEscrow.sol, function: "claim(Claim) / claimBatch(Claim[]) / _claim", lines: "80-82, 89-94, 102-120", visibility: "external / internal", modifiers: [nonReentrant],
   writes: ["delete claimable[beneficiary][currency] L110"], calls: ["safeTransferETH L114 or safeTransfer L116 to the beneficiary"], events: [Claimed],
   inv: ["pays the beneficiary whoever calls", "effects before interaction", "batch is atomic; zero credits are no-ops"]}
# ---------------- src/calculators/LiveCalculator.sol ----------------
- {id: CODE-L01, file: src/calculators/LiveCalculator.sol, function: "constructor(IPoolManager,address,address)", lines: 129-133, visibility: public, modifiers: [], writes: ["immutables poolManager, usdc, dicesHook"], inv: ["hook fixed", "no owner", "no validation of arguments"]}
- {id: CODE-L02, file: src/calculators/LiveCalculator.sol, function: "qualify(PoolKey)", lines: 146-165, visibility: external, modifiers: [onlyHook],
   pre: ["msg.sender != dicesHook -> OnlyHook L407-L409", "sqrtPriceX96 == 0 -> return 0 L153-L155"],
   calls: ["poolManager.getSlot0 L150", "coin.qualifiedHolders() inside _levelAt L371"],
   computations: ["coin1: tick = -tick - 1 L159-L161", "_observe then _average then _levelAt L163-L164"],
   inv: ["history written only by the hook", "observation precedes the level decision", "a revert in the holder read undoes the observation"]}
- {id: CODE-L03, file: src/calculators/LiveCalculator.sol, function: "qualifiedLevel / averageTick / averageMarketCap", lines: "175-179, 189-191, 200-209", visibility: "external view", modifiers: [],
   computations: ["market cap = mulDiv(mulDiv(s, s, 2^96), 1e27, 2^96), s = getSqrtPriceAtTick(avg) L207-L208"],
   inv: ["no state change", "zero until a full window exists", "assumes the pool stayed at its last observed tick"]}
- {id: CODE-L04, file: src/calculators/LiveCalculator.sol, function: "levelTicks() / levelHolders()", lines: "219-242, 251-253", visibility: "public pure", modifiers: [],
   computations: ["[-361500, -354568, -347636, -340704, -333772, -326841, -319909, -312977, -306084, -299152]", "[150, 225, 350, 500, 750, 1100, 1700, 2500, 3800, 5800]"],
   inv: ["both arrays strictly increasing", "compile-time constants", "ten entries each"]}
- {id: CODE-L05, file: src/calculators/LiveCalculator.sol, function: "_observe(PoolId,int24)", lines: 266-295, visibility: internal, modifiers: [],
   reads: ["oracles[poolId] L267"], writes: ["_checkpoints[poolId][hour % 25] for each hour started since the last observation, at most 25 L283-L287", "oracles[poolId] L294"],
   computations: ["first call: startedAt = now L273-L275", "cumulative += tick x elapsed L289"],
   inv: ["cumulative is exact while every price change is observed", "every hour after the start hour up to the latest observation has a checkpoint", "one oracle slot write per call"]}
- {id: CODE-L06, file: src/calculators/LiveCalculator.sol, function: "_average(PoolId,Oracle)", lines: 309-338, visibility: "internal view", modifiers: [],
   pre: ["startedAt == 0 or period <= startedAt/3600 + 24 -> (0, false) L314-L316"],
   computations: ["opensAt = (period - 24) x 3600 L320", "opening = checkpoint or extrapolation L322", "average = floor((cumulative(now) - opening) / (now - opensAt)) L326-L333"],
   inv: ["window length in [86400, 90000) seconds", "rounds toward negative infinity", "never reads the start hour's unwritten checkpoint"]}
- {id: CODE-L07, file: src/calculators/LiveCalculator.sol, function: "_levelAt(PoolKey,int24,bool)", lines: 353-376, visibility: "internal view", modifiers: [],
   computations: ["level = number of level ticks <= average L360-L362", "return 0 before any holder read if level == 0 L364-L366", "lower level while holders < floor L373-L375"],
   calls: ["IDicesCoin(coin).qualifiedHolders() L371"],
   inv: ["result in 0..10", "needs both tick and holder floor", "bounded loops (at most 10 + 10 steps)"]}
- {id: CODE-L08, file: src/calculators/LiveCalculator.sol, function: "_coinIsCurrency0 / _cumulativeAt / onlyHook", lines: "385-387, 397-401, 406-412", visibility: "internal / modifier", modifiers: [],
   inv: ["coin is currency0 iff currency1 == usdc", "tick x seconds fits int56 (below 2^52)", "msg.sender == dicesHook else OnlyHook"]}
# ---------------- src/calculators/FeeCalculator.sol ----------------
- {id: CODE-F01, file: src/calculators/FeeCalculator.sol, function: "getSwapFee(bool)", lines: 72-74, visibility: "public view", modifiers: [], computations: ["_live ? 1_000 : 1_250"], inv: ["two rates only", "no direction or reserve input", "no state"]}
- {id: CODE-F02, file: src/calculators/FeeCalculator.sol, function: "getFeeDistribution(uint,bool)", lines: 85-94, visibility: "public pure", modifiers: [], computations: ["creator = amount x 30_000 / 100_000 L87", "buyAndBurn = amount x 30_000 / 100_000 L90", "platform = amount - creator - buyAndBurn L93"], inv: ["outputs sum to the input", "rounding dust goes to the platform", "Live flag ignored"]}
- {id: CODE-F03, file: src/calculators/FeeCalculator.sol, function: "getInitialSqrtPriceX96(bool)", lines: 103-105, visibility: "public pure", modifiers: [], computations: ["coin0: 280113854873930699593; coin1: 22409108389914455967492775290983268704"], inv: ["$12,500 launch cap in both orderings", "constants", "no state"]}
# ---------------- src/libraries ----------------
- {id: CODE-S01, file: src/libraries/CurrencySettler.sol, function: "settle(Currency,IPoolManager,address,uint) / take(Currency,IPoolManager,address,uint)", lines: "29-50, 60-64", visibility: internal, modifiers: [], calls: ["manager.sync, safeTransferFrom or currency.transfer, manager.settle L38-L48", "manager.take L63"], inv: ["sync immediately before transfer", "SafeERC20 for third-party payers", "used by the hook only"]}
- {id: CODE-U01, file: src/libraries/UniswapEvents.sol, function: "emitPoolCreated / emitHookFee / emitSwapUpdate / emitPoolStateUpdate", lines: "67-69, 79-81, 93-95, 125-128", visibility: public, modifiers: [], events: [PoolCreated, HookFee, HookSwap, PoolStateUpdated], inv: ["public library functions: linked and delegate-called, so the hook is the emitter", "state update reads slot0 and liquidity at call time", "no PoolSwap emission"]}
- {id: CODE-U02, file: src/libraries/UniswapEvents.sol, function: "emitLiquidityDeltaUpdate / emitDonationUpdate", lines: "104-106, 115-117", visibility: public, modifiers: [], events: [PoolLiquidityDelta, PoolDonation], inv: ["no caller in src/", "dead code in the linked library", "none"]}
# ---------------- script/deployment/V001.s.sol ----------------
- {id: CODE-D01, file: script/deployment/V001.s.sol, function: "run()", lines: 195-259, visibility: external, modifiers: [],
   pre: ["unsupported chain -> revert L572", "external contracts missing or USDC decimals != 6 or router lacks msgSender() L341-L347", "mainnet recipient or bankroll unset L323-L325", "occupied address L439-L451", "bankroll is a checked launchpad contract L333-L336", "broadcaster != deployer L210"],
   calls: ["CreateX.deployCreate3 x7 L213-L234", "setCoinImplementation, setTrustedRouter, setFeeRecipient, transferOwnership L237-L246"],
   inv: ["all checks precede startBroadcast (L208)", "deployed address must equal the prediction (L460)", "_requireWiring after the broadcast (L251)"]}
- {id: CODE-D02, file: script/deployment/V001.s.sol, function: "_resolveDestinations / _requireSeparateBankroll / _getConfig", lines: "305-326, 333-336, 541-573", visibility: internal, modifiers: [],
   inv: ["owner defaults to the deployer on every chain L306", "testnet defaults for recipients and bankroll L311-L321", "bankroll compared with hook, PoolManager, swap pool, escrow, coin implementation only"]}
- {id: CODE-D03, file: script/deployment/V001.s.sol, function: "_saltFor / _create3Address / _mineHookSalt / _predictAddresses", lines: "402-437, 377-388", visibility: internal, modifiers: [],
   computations: ["salt = signer (20 bytes) | 0x00 | uint88(keccak(DEPLOYMENT_SALT, name, attempt)) L402-L405", "address = CREATE3(keccak(signer, salt), CreateX) L410-L412", "hook: first attempt in [160444, 320888) with (address & 0x3FFF) == HOOK_FLAGS L424-L435"],
   inv: ["addresses independent of nonce, chain and constructor arguments", "exact flag match", "deterministic, so predict and run agree"]}
- {id: CODE-D04, file: script/deployment/V001.s.sol, function: "_deployHook / _linkedHookCreationCode / _requireWiring", lines: "475-505, 510-532", visibility: internal, modifiers: [],
   inv: ["hook owner argument is the deployer L476", "UniswapEvents linked from the predicted address L496-L503", "21 wiring assertions including flags, owner, recipients, calculators, coin immutables"]}
- {id: CODE-D05, file: script/deployment/V001.s.sol, function: "predict / output helpers", lines: "265-280, 579-675", visibility: "external / internal", modifiers: [], inv: ["predict deploys nothing", "files written only when broadcasting or resuming L609-L611", "no environment reads"]}
```

Records: 25 (hook) + 2 (routers) + 8 (coin) + 5 (swap pool) + 2 (escrow) + 8 (Live calculator) + 3 (fee calculator) + 3 (libraries) + 5 (deployment) = 61 records covering every function in scope; small helpers and paired setters share a record where their behaviour is identical in kind.

---

## Appendix C: Alignment-IR (expanded records)

The matrix in section 5 is the complete Alignment-IR. Expanded records follow for the rows that carry the weight of the conclusions: every `partial_match` and `code_stronger_than_spec` row, and the main `full_match` rows (numeric and security). Every `mismatch`, `missing_in_code` and `code_weaker_than_spec` row has its expanded record, with quotes from both sides, in the divergence finding named in the matrix.

```yaml
- id: ALIGN-002
  spec_ref: SPEC-002
  code_ref: [CODE-H14, CODE-H10, CODE-E01]
  spec_claim: "launchpad core only (coin creation, locked liquidity, fees, Live trigger, ledgers)"
  code_behavior: "creation, lock, fees and level trigger exist; the only ledger is FeeEscrow.claimable; no casino contract exists"
  match_type: partial_match
  confidence: 0.75
  reasoning: "Four of five scope words map to code. 'ledgers' is ambiguous (AMB-12): if it means the reserve and race ledgers of section 3, they are absent (DIV-01)."
  evidence: {spec_location: "AGENT.md section 1", code_location: "src/core/FeeEscrow.sol:L25", code_quote: "mapping(address beneficiary => mapping(address currency => uint amount)) public override claimable;"}
- id: ALIGN-003
  spec_ref: SPEC-003
  code_ref: [CODE-H14, CODE-H15, CODE-H16, CODE-H18]
  spec_claim: "One transaction creates the coin, locks all liquidity permanently in two Uniswap v4 positions, attaches the trading hook"
  code_behavior: "createCoin clones and initialises the coin, builds a key with hooks = this, and inside one unlock initialises the pool and adds two positions owned by the hook"
  match_type: full_match
  confidence: 0.95
  reasoning: "All steps run inside createCoin (L533-L578) and its unlock callback (L587-L618). Permanence: SPEC-063."
  evidence: {spec_location: "AGENT.md section 2, Product", code_location: "src/DicesHook.sol:L564, L577, L645-L646", code_quote: "poolManager.unlock(abi.encode(poolKey, coinIsCurrency0));"}
- id: ALIGN-005
  spec_ref: SPEC-005
  code_ref: [CODE-P03, CODE-P04]
  spec_claim: "Every buy adds liquidity (USDC flows into the pool)"
  code_behavior: "USDC paid for coins sold by the launch positions stays in the pool; USDC paid for coins sold by the JIT position is taken out and credited to fee recipients"
  match_type: partial_match
  confidence: 0.80
  reasoning: "The JIT position shares its tick range with launch liquidity, so a buy that reaches it is filled by both pro rata; the pool still receives part of every such buy, but not all of it. The swap pool is skipped when no pool liquidity is active (L159-L161)."
  evidence: {spec_location: "AGENT.md section 2, Product", code_location: "src/core/InternalSwapPool.sol:L260-L262", code_quote: "paired.take(poolManager, address(this), proceeds, false);"}
- id: ALIGN-013
  spec_ref: [SPEC-013, SPEC-094, SPEC-185]
  code_ref: CODE-L04
  spec_claim: "each target is one tick: the first tick at which the supply is worth the target"
  code_behavior: "ten constants in levelTicks()"
  match_type: full_match
  confidence: 0.97
  reasoning: "For each target, ceil(ln(target x 1e6 / 1e27) / ln 1.0001) equals the constant; exact integer comparison confirms the constant satisfies the target and the tick below does not; the contract's averageMarketCap arithmetic gives a value at or above the target at the constant and below it one tick lower (section 9.1, Appendix D)."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels", code_location: "src/calculators/LiveCalculator.sol:L219-L242", code_quote: "int24(-361_500), -354_568, -347_636, -340_704, -333_772, -326_841, -319_909, -312_977, -306_084, -299_152"}
- id: ALIGN-028
  spec_ref: [SPEC-028, SPEC-199]
  code_ref: [CODE-H06, CODE-T01]
  spec_claim: "Any router implementing IMsgSender ... works today" / "trusted for wallet attribution"
  code_behavior: "after the launch block any router can swap; in the launch block only routers in trustedRouters can"
  match_type: code_stronger_than_spec
  confidence: 0.85
  reasoning: "The code adds a restriction that neither sentence mentions and gives the attribution allowlist a second purpose. UNDOCUMENTED CODE PATH (UCP-04); discussed in DIV-06."
  evidence: {spec_location: "AGENT.md section 2 component table; ITrustedRouters.sol:L16", code_location: "src/DicesHook.sol:L334", code_quote: "if (launchBlock[poolId] == block.number && !trustedRouters[sender]) {"}
- id: ALIGN-047
  spec_ref: SPEC-047
  code_ref: "sections 5.2 to 5.4"
  spec_claim: "Contracts table, Fees, Ledgers and Configuration ... no longer match the code. Launch step 5, Qualifying holders and Live and game levels below are current."
  code_behavior: "named-stale subsections: 15 of 20 extracted claims do not match. Named-current: step 5, 5 of 5 match; Qualifying holders, 6 of 7 match (SPEC-084); Live and game levels, 17 of 20 match (SPEC-102 mismatch, SPEC-109 weaker, SPEC-111 unverified)"
  match_type: partial_match
  confidence: 0.85
  reasoning: "The note is right about what it names and silent about other stale text: Principle (3 of 5 claims), the component table (4 rows), Launch steps 1, 4, 6 and the lock sentences, Indexer events (3 of 5), four section 4 bullets."
  evidence: {spec_location: "AGENT.md section 3, Contracts, Note (2026-11-05)", code_location: "see matrix rows SPEC-031 to 113", code_quote: "n/a (meta claim)"}
- id: ALIGN-055
  spec_ref: [SPEC-055, SPEC-190]
  code_ref: [CODE-F03, CODE-H15]
  spec_claim: "initialise the pool at the $12.5k FDV launch price"
  code_behavior: "unlockCallback initialises at getInitialSqrtPriceX96(coinIsCurrency0)"
  match_type: full_match
  confidence: 0.99
  reasoning: "isqrt(12_500e6 x 2^192 / 1e27) = 280113854873930699593 and isqrt(1e27 x 2^192 / 12_500e6) = 22409108389914455967492775290983268704, both equal to the constants and both the exact floor of the real square root. Market cap at the first constant: $12,499.999999."
  evidence: {spec_location: "AGENT.md section 3, Launch, step 5", code_location: "src/calculators/FeeCalculator.sol:L55, L63", code_quote: "uint160 internal constant LAUNCH_SQRT_PRICE_COIN_IS_CURRENCY0 = 280113854873930699593;"}
- id: ALIGN-056
  spec_ref: [SPEC-056, SPEC-057, SPEC-058, SPEC-059]
  code_ref: [CODE-H16, CODE-H17, CODE-H18]
  spec_claim: "70% of supply from the aligned launch tick to the $200k sale end, and 20% from there to the usable tick limit. The ranges are mirrored ... raises about $35,013"
  code_behavior: "coin0: 7e26 in [-389220, -361500), 2e26 in [-361500, 887220]; coin1: 7e26 in [361500, 389220], 2e26 in [-887220, 361500]"
  match_type: full_match
  confidence: 0.95
  reasoning: "Launch pool tick is -389,228 (coin0) and 389,227 (coin1); _launchTick aligns to -389,220 and 389,220, keeping the launch price outside the range on the coin-only side. USDC to cross the sale range with the liquidity the code computes: $35,013.49 in both orderings."
  evidence: {spec_location: "AGENT.md section 3, Launch, step 5", code_location: "src/DicesHook.sol:L645-L653", code_quote: "owed_ = _addInitialTokenLiquidity(_poolKey, true, launchTick, SALE_END_TICK, SALE_SUPPLY);"}
- id: ALIGN-063
  spec_ref: [SPEC-063, SPEC-121, SPEC-137, SPEC-143]
  code_ref: [CODE-H18, CODE-H05]
  spec_claim: "the hook has no code path with a negative liquidity delta"
  code_behavior: "one modifyLiquidity call in DicesHook.sol, with int(uint(liquidity))"
  match_type: full_match
  confidence: 0.95
  reasoning: "grep 'modifyLiquidity' in src/DicesHook.sol returns L715 only. The swap pool's removal (InternalSwapPool.sol:L239) addresses the position keyed to the swap pool and its salt, not the hook's."
  evidence: {spec_location: "AGENT.md section 3, Launch, Lock guarantees", code_location: "src/DicesHook.sol:L715", code_quote: "ModifyLiquidityParams({tickLower: _tickLower, tickUpper: _tickUpper, liquidityDelta: int(uint(liquidity)), salt: ''})"}
- id: ALIGN-074
  spec_ref: [SPEC-074, SPEC-107]
  code_ref: CODE-H07
  spec_claim: "the swap that triggers Live ... pays the pre-swap rate"
  code_behavior: "fee computed and collected at L375-L379, level synced at L382"
  match_type: full_match
  confidence: 0.93
  reasoning: "poolLive is read inside _swapFee (L462) and _collectSwapFee (L478) before _syncLevel can write poolLevel. The swap pool's split at closeInternalSwapPool (L373) also precedes the sync. The mechanism in the spec (transient cache in beforeSwap) is absent; the guarantee is not."
  evidence: {spec_location: "AGENT.md section 3, Fees; section 3, Live and game levels, Triggering", code_location: "src/DicesHook.sol:L375-L382", code_quote: "// The swap that unlocks level one uses the pre-Live rate calculated above; unlocked levels are irreversible."}
- id: ALIGN-081
  spec_ref: [SPEC-081, SPEC-082]
  code_ref: [CODE-C06, CODE-C07]
  spec_claim: "maintains the count itself in _afterTokenTransfer, on every mint, burn and transfer"
  code_behavior: "override of the solady hook; solady calls it from transfer, transferFrom, _mint, _burn, _transfer"
  match_type: full_match
  confidence: 0.95
  reasoning: "All five balance-changing paths in the inherited ERC20 end with _afterTokenTransfer (ERC20.sol:L244, L345, L519, L551, L586). Exclusions match the sentence exactly."
  evidence: {spec_location: "AGENT.md section 3, Qualifying holders", code_location: "src/DicesCoin.sol:L248", code_quote: "return account != address(0) && account != hook && account != poolManager && account != internalSwapPool && account != bankroll;"}
- id: ALIGN-095
  spec_ref: SPEC-095
  code_ref: CODE-L02
  spec_claim: "the pool tick when the coin is currency0, -tick - 1 when it is currency1"
  code_behavior: "if (!_coinIsCurrency0(_poolKey)) tick = -tick - 1"
  match_type: full_match
  confidence: 0.97
  reasoning: "floor(-x) = -ceil(x), so -floor(-x) - 1 = floor(x) for non-integer x; at an exact tick boundary the result is one tick lower, which is the conservative side."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels", code_location: "src/calculators/LiveCalculator.sol:L159-L161", code_quote: "tick = -tick - 1;"}
- id: ALIGN-101
  spec_ref: SPEC-101
  code_ref: CODE-L06
  spec_claim: "opens on the hour that is 24 hours before the current hour, so it lasts between 24 and 25 hours"
  code_behavior: "opensAt = (block.timestamp / 1 hours - 24) * 1 hours; duration = block.timestamp - opensAt"
  match_type: full_match
  confidence: 0.97
  reasoning: "duration = 86,400 + (now mod 3,600), in [86,400, 90,000)."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels, The window", code_location: "src/calculators/LiveCalculator.sol:L320, L326", code_quote: "uint opensAt = (period - PERIODS) * PERIOD;"}
- id: ALIGN-105
  spec_ref: [SPEC-105, SPEC-093, SPEC-172]
  code_ref: CODE-H10
  spec_claim: "records only a rise ... one event even when several levels are crossed, preceded by PoolLive(poolId) when the pool leaves level 0"
  code_behavior: "if (level > unlocked) { store; if (unlocked == 0) emit PoolLive; emit PoolLevelUnlocked(_poolId, unlocked, level); }"
  match_type: full_match
  confidence: 0.98
  reasoning: "Single write, at most two events, order as stated."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels, The ratchet is in the hook", code_location: "src/DicesHook.sol:L438-L446", code_quote: "emit PoolLevelUnlocked(_poolId, unlocked, level);"}
- id: ALIGN-110
  spec_ref: SPEC-110
  code_ref: CODE-L08
  spec_claim: "accepts calls from the hook alone ... reverts with OnlyHook for anyone else"
  code_behavior: "modifier onlyHook: if (msg.sender != dicesHook) revert OnlyHook();"
  match_type: full_match
  confidence: 0.99
  reasoning: "dicesHook is immutable (L109) and the modifier is on qualify (L146); the views carry no modifier and write nothing."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels, Hook only", code_location: "src/calculators/LiveCalculator.sol:L406-L412", code_quote: "if (msg.sender != dicesHook) { revert OnlyHook(); }"}
- id: ALIGN-111
  spec_ref: SPEC-111
  code_ref: [CODE-L05, CODE-L07, CODE-C06]
  spec_claim: "9.3k gas per swap during a pool's first day, 13.4k once it has a full window, 17.6k once the average earns a level ..."
  code_behavior: "not measurable by reading"
  match_type: partial_match
  confidence: 0.30
  reasoning: "NOT VERIFIED. No build or test command was permitted. Structural statements next to the figures are consistent with the code: seven checkpoint slots, 25 checkpoints after a day of silence, holder read only once a level is earned."
  evidence: {spec_location: "AGENT.md section 3, Live and game levels, Measured cost", code_location: "src/calculators/LiveCalculator.sol:L283-L287, L364-L371", code_quote: "uint hour = period - observedPeriod > PERIODS ? period - PERIODS : observedPeriod + 1;"}
- id: ALIGN-114
  spec_ref: [SPEC-114, SPEC-115, SPEC-208]
  code_ref: [CODE-H02, CODE-D03]
  spec_claim: "beforeInitialize, beforeAddLiquidity, beforeRemoveLiquidity, beforeSwap, afterSwap, afterSwapReturnDelta"
  code_behavior: "six permission flags set to true; V001.HOOK_FLAGS is the OR of the six matching constants"
  match_type: full_match
  confidence: 0.99
  reasoning: "Bits 13, 11, 9, 7, 6, 2 on both sides (Hooks.sol:L29-L45) = 0x2AC4; mining compares against the full 14-bit mask."
  evidence: {spec_location: "AGENT.md section 3, Hook address flags", code_location: "src/DicesHook.sol:L237-L242; script/deployment/V001.s.sol:L120, L432", code_quote: "if (uint160(predicted) & Hooks.ALL_HOOK_MASK == HOOK_FLAGS) {"}
- id: ALIGN-126
  spec_ref: SPEC-126
  code_ref: [CODE-L05, CODE-L07]
  spec_claim: "the level rule needs no price maths or iteration per swap"
  code_behavior: "tick comparisons only; three bounded loops"
  match_type: partial_match
  confidence: 0.60
  reasoning: "AMBIGUOUS. 'No price maths' holds (no sqrt-price arithmetic on the swap path; averageMarketCap is a view). 'No iteration' is false if bounded loops count (L285-L287 up to 25 steps, L360-L362 and L373-L375 up to 10 each) and true if it means iteration over holders or observations."
  evidence: {spec_location: "AGENT.md section 4", code_location: "src/calculators/LiveCalculator.sol:L360-L362", code_quote: "while (level_ < LEVELS && _tick >= ticks[level_]) {"}
- id: ALIGN-156
  spec_ref: SPEC-156
  code_ref: "test/, foundry.toml, .github/workflows/test.yml"
  spec_claim: "Stateful invariants ... over 64 runs of up to 32 actions. CI requires 100% ... coverage"
  code_behavior: "invariant profile runs = 64, depth = 32; five invariant functions; coverage step in the workflow"
  match_type: partial_match
  confidence: 0.55
  reasoning: "NOT EXECUTED. Configuration and files exist; outcomes were not observed."
  evidence: {spec_location: "README.md, Usage, Test", code_location: "foundry.toml [profile.default.invariant]; test/DicesHookInvariant.t.sol:L83-L110", code_quote: "runs = 64 / depth = 32"}
- id: ALIGN-158
  spec_ref: SPEC-158
  code_ref: "script/process/GenerateActivity.s.sol"
  spec_claim: "launches an Activity Coin (ACT), then makes three buys and two sells ... The signer needs 30 USDC"
  code_behavior: "COIN_SYMBOL = 'ACT', BUY_AMOUNT_USDC = 10e6, USDC_BUDGET = 3 x BUY_AMOUNT_USDC, creator claim at L148"
  match_type: partial_match
  confidence: 0.50
  reasoning: "Outside the scoped code; constants spot-checked, flow not traced."
  evidence: {spec_location: "README.md, Usage, Generate activity", code_location: "script/process/GenerateActivity.s.sol:L71-L74", code_quote: "uint internal constant USDC_BUDGET = 3 * BUY_AMOUNT_USDC;"}
```

---
## Appendix D: Arithmetic worksheet

The worksheet is plain Python integer and decimal arithmetic, run outside the repository. It ports three library routines read from `lib/v4-hooks-public/lib/` so that results use the contracts' own rounding: `TickMath.getSqrtPriceAtTick` (v4-core, the twenty Q128.128 constants and the round-up shift), `LiquidityAmounts.getLiquidityForAmount0/1` (v4-periphery) and `SqrtPriceMath.getAmount0Delta/getAmount1Delta` (v4-core). `tickAt(s)` is the greatest tick whose ported sqrt price is at most `s`.

```python
Q96 = 1 << 96; SUPPLY = 10**27; SP = 60; SALE_END = -361_500; MAX_TICK = 887272
def sqrtAt(tick): ...            # port of TickMath.getSqrtPriceAtTick
def L0(sa, sb, x): return x * (sa * sb // Q96) // (sb - sa)       # getLiquidityForAmount0
def L1(sa, sb, y): return y * Q96 // (sb - sa)                    # getLiquidityForAmount1
def amt0(sa, sb, L, up): ...     # getAmount0Delta
def amt1(sa, sb, L, up): ...     # getAmount1Delta
def mcap(tick): s = sqrtAt(tick); return (s * s // Q96) * SUPPLY // Q96   # LiveCalculator.averageMarketCap

# 1. launch sqrt prices (FeeCalculator.sol:L55, L63)
isqrt((12_500 * 10**6 << 192) // 10**27) == 280113854873930699593                      # True
isqrt((10**27 << 192) // (12_500 * 10**6)) == 22409108389914455967492775290983268704   # True
# exact floor: s*s*den <= num < (s+1)*(s+1)*den                                         # True, True

# 2. launch ticks and DicesHook._launchTick
tickAt(280113854873930699593) == -389228 ; tickAt(22409108389914455967492775290983268704) == 389227
# coin0: trunc(-389228 / 60) * 60 = -389220 ; launch sqrt price <= sqrtAt(-389220), no step  -> -389220
# coin1: trunc( 389227 / 60) * 60 =  389220 ; 389227 >= 389220, no step                      ->  389220

# 3. level ticks: for each target, x = ln(target * 1e6 / 1e27) / ln(1.0001), T = ceil(x)
#    exact check: 1e27 * 10000**n >= target_raw * 10001**n at n = -T, and not at n = -T + 1
#    contract check: mcap(T) >= target_raw > mcap(T - 1)

# 4. raise: sa = sqrtAt(-389220); sb = sqrtAt(-361500); Ls = L0(sa, sb, 7 * 10**26)
#    amt1(sa, sb, Ls, True) / 1e6 ; mirrored with L1 and amt0 for the currency1 ordering

# 5. bankroll sale of 1e26 from sb: s2 = Ls*Q96*sb // (Ls*Q96 + 1e26*sb) ; out = Ls*(sb - s2) // Q96
```

Output (abridged; the section 7 lines are relabelled with the finding they support):

```text
== 1. FeeCalculator launch sqrt prices ==
coin0 computed 280113854873930699593 stated 280113854873930699593 True
coin1 computed 22409108389914455967492775290983268704 stated 22409108389914455967492775290983268704 True
coin0 exact floor sqrt: True
coin1 exact floor sqrt: True
launch mcap from stated sqrt (coin0), USD: 12499.999999
== 2. launch ticks, _launchTick ==
pool tick coin0: -389228  pool tick coin1: 389227
launchTick coin0: -389220 (< SALE_END: True )  launchTick coin1: 389220 (> -SALE_END: True )
coin0 sale range [-389220,-361500) upper range [-361500,887220]
coin1 sale range [361500,389220] upper range [-887220,361500]
coin0 launch price below sale lower: True  coin1 launch price above sale upper: True
SALE_END multiple of 60: True
== 3. level ticks ==
$200000      real tick -361500.2169 lowest -361500 stated -361500 match True exact-int True | contract mcap@tick $200004.34 @tick-1 $199984.34 (>=target: True / False)
$400000      real tick -354568.3985 lowest -354568 stated -354568 match True exact-int True | contract mcap@tick $400015.94 @tick-1 $399975.94 (>=target: True / False)
$800000      real tick -347636.5801 lowest -347636 stated -347636 match True exact-int True | contract mcap@tick $800046.41 @tick-1 $799966.41 (>=target: True / False)
$1600000     real tick -340704.7618 lowest -340704 stated -340704 match True exact-int True | contract mcap@tick $1600121.88 @tick-1 $1599961.88 (>=target: True / False)
$3200000     real tick -333772.9434 lowest -333772 stated -333772 match True exact-int True | contract mcap@tick $3200301.88 @tick-1 $3199981.88 (>=target: True / False)
$6400000     real tick -326841.1250 lowest -326841 stated -326841 match True exact-int True | contract mcap@tick $6400080.00 @tick-1 $6399440.06 (>=target: True / False)
$12800000    real tick -319909.3066 lowest -319909 stated -319909 match True exact-int True | contract mcap@tick $12800392.48 @tick-1 $12799112.57 (>=target: True / False)
$25600000    real tick -312977.4883 lowest -312977 stated -312977 match True exact-int True | contract mcap@tick $25601249.93 @tick-1 $25598690.06 (>=target: True / False)
$51000000    real tick -306084.8108 lowest -306084 stated -306084 match True exact-int True | contract mcap@tick $51004135.26 @tick-1 $50999035.35 (>=target: True / False)
$102000000   real tick -299152.9925 lowest -299152 stated -299152 match True exact-int True | contract mcap@tick $102010123.18 @tick-1 $101999923.19 (>=target: True / False)
doubling in ticks ln2/ln1.0001 = 6931.818373413796
== 4. raise from selling out the sale position (contract arithmetic) ==
coin0: L_sale 3301467936545706412 coins debited 699999999999873413557157325 USDC to cross sale range $35013.49
coin0: L_upper 2828457794755274655 coins debited 199999999999999999944979685 dust left in hook (wei) 126586497862990
coin1: L_sale 3301467936546303442 coins debited 699999999999999999975128441 USDC to cross sale range $35013.49
coin1: L_upper 2828457794755274655 coins debited 199999999999999999945140581 dust left in hook (wei) 79730978
real-number check 7e26*1.0001^(-(389220+361500)/2)/1e6 = $35013.49
== 5. bankroll sells 100M at the $200k cap (coin0) ==
gross USDC out $14002.34; net of 1.25% $13827.31; net of 1.00% $13862.32
market cap after: $98030.64  USDC left in pool $21011.15
== 6. misc numbers ==
spike: (887272+361500)*2/86400 = 28.90675925925926 ticks; 1.0001^29 = 1.0029040636563762
geo mean sqrt(300k*500k) = 387298.33462074166
holder threshold $ at $200k:  59.99999999999999  150 holders coins: 45000000  $: 9000.0
supply split: 0.7 0.2 0.1 sum == supply: True
hook flags value: 10948 0x2ac4 1/2^14 = 6.103515625e-05  miss prob over 160444 attempts: 5.583981169309742e-05
int56 bound: max|tick|*2^32 = 3810808517623808 < 2^55 = 36028797018963968 True
stale config: tick -398400 FDV $4995.43 ; tick -375360 FDV $50019.27 ; ratio 10.013
== 7. scenarios used in findings ==
DIV-11: fraction of window traded 0.50 -> needed coin tick -333772 (cap $3200302), USDC in pool ~ $155022
DIV-11: fraction of window traded 0.75 -> needed coin tick -352257 (cap $504008), USDC in pool ~ $58512
DIV-06: buy $1000 at launch -> 73.6M coins gross, 72.7M after 1.25% coin fee, cap after $14744
DIV-06: buy $5000 at launch -> 279.9M coins gross, 276.4M after 1.25% coin fee, cap after $25516
DIV-01: buy volume $35013: 0.50% reserve = $175.07 ; buy volume $1000000: 0.50% = $5000.00, 0.25% = $2500.00
DIV-01: buy volume needed to fill $10k reserve at 0.50%: $2000000
DIV-14: min fee for creator share >= 1 unit: 4 units; USDC leg >= 320 units pre-Live
```

Notes on the worksheet. The bankroll-sale and scenario lines use the contract's liquidity value with real-number price steps and ignore the eight-tick gap between the launch price and the sale position; they are estimates to the stated precision. The DIV-11 line solves `H = T1 + (T1 - launchCoinTick) x (1 - f) / f` for the coin tick `H` that the traded fraction `f` of the window must hold, with `T1 = -361,500` and `launchCoinTick = -389,228`, and prices `H` on the upper position.

---

## Appendix E: Completeness checklist

| Item | Status |
| --- | --- |
| Spec-IR: explicit invariants, formulas, actors, flows, security requirements extracted, each with `source_section` and confidence | Done, 209 records (Appendix A) |
| Spec-IR: more than 10 items, 3 invariants, 2 security requirements, 1 formula | Done |
| Code-IR: every public and external function, and the internal functions they call | Done, 61 records (Appendix B); paired setters and trivial helpers share a record |
| Code-IR: reads, writes, external calls, revert conditions, modifiers with line numbers | Done |
| Code-IR: storage layout, initialisation, authorization graph | Section 4 |
| Code-IR: three invariants per record | Done (`inv` lists); `CODE-U02` has two, the code is dead |
| Alignment-IR: one record per Spec-IR item, with `match_type` from the six allowed values | Done, section 5 (209 rows) |
| Alignment-IR: reasoning and quotes from both sides | Section 5 (one line), Appendix C and section 6 (expanded) |
| Every `mismatch`, `missing_in_code`, `code_weaker_than_spec` mapped to a divergence finding | Done (DIV-01 to DIV-17) |
| Undocumented behaviour flagged | Section 12 (UCP-01 to UCP-23); SPEC-028 and SPEC-199 as `code_stronger_than_spec` |
| Ambiguities classified, not guessed | Section 13 (AMB-01 to AMB-15); confidence below 0.8 on SPEC-001, 002, 111, 126, 156, 158 |
| CRITICAL / HIGH findings with scenario, quantified impact, remediation, tests, breaking changes | DIV-01; the five MEDIUM findings carry the same fields |
| Final report: 16 sections | Sections 1 to 16 |
| Not done, by instruction | No compilation, tests, coverage, gas measurement or static-analysis tool run |

---

## Reconciliation with the consolidated findings

Added by the lead reviewer after this report was written. The report above was produced from the documents
and the code alone, without sight of the other reviews. Its divergences were then checked and merged into
[`findings.md`](findings.md) under `DICES-nn` identifiers. Severities here are compliance severities (how far
the code is from what the documents say); `findings.md` rates security and functional impact, and takes
precedence where they differ. "Run" means a proof-of-concept test was executed (see
[`poc-tests.md`](poc-tests.md)).

| This report | Consolidated | Status after verification |
| --- | --- | --- |
| DIV-01, DIV-02, DIV-05, DIV-08, DIV-09 | DICES-09 | Confirmed. Left as "Undetermined" in the consolidated list: whether the reserve surcharge, the two-way split and the sealed game were dropped by agreement is not in the repository |
| DIV-03 | DICES-03 | Confirmed; run (`testPoC4`, `testPoC10`) |
| DIV-04 | DICES-08 | Confirmed; run (`testPoC5`) |
| DIV-06 | DICES-06 | Confirmed; run (`testPoC2`) |
| DIV-07 | DICES-17; rejected candidate R-06 | The lock holds; the documents describe its mechanism wrongly |
| DIV-10 | DICES-16, DICES-18 | Confirmed |
| DIV-11 | DICES-17; rejected candidate R-08 | Confirmed as a documentation error; not exploitable |
| DIV-12 | DICES-17 | Confirmed; the anti-inflation property holds |
| DIV-13 | DICES-07; rejected candidate R-01 | Undecodable return data: confirmed and run (`testPoC3`). Gas exhaustion escaping the `try`: tested and rejected (`testPoC6`) |
| DIV-14 | DICES-01 | Confirmed; run for both orderings (`testPoC1`). Rated Medium in the consolidated list |
| DIV-15, DIV-17 | DICES-17 | Confirmed |
| DIV-16 | none | Deferred components are absent, as the documents say |

Two consolidated findings are not divergences from any document and so do not appear above: DICES-02 (levels
9 and 10 are unreachable; the documents and the code agree on the constants, which are jointly impossible)
and DICES-05 (fee conversion at a price any caller can push down; no document says at what price fees
convert).
