# Trail of Bits development guidelines review: Dices launchpad

| | |
| --- | --- |
| Skill | `building-secure-contracts` 1.1.1 / `guidelines-advisor` (all 5 phases, all 11 assessment areas) |
| Commit | `bcd45b2` on `main` ("Merge launch distribution with TWAP game levels") |
| Date | 2026-11-25 |
| Scope | `src/**` (9 contracts and libraries, 8 interfaces), `script/deployment/V001.s.sol`, `test/**` (testing area only), `foundry.toml`, `.github/workflows/test.yml`, `.gitmodules`, `foundry.lock`, `remappings.txt`. `lib/` only where `src/` depends on its behaviour |
| Method | Manual read, in full, of every file under `src/`, of `script/deployment/V001.s.sol`, the build and CI configuration, and the invariant, trading, level and fixture test files; the remaining test files were read in part (setup, test names and the tests cited below). No build, test or analysis tool was run for this report. Slither 0.11.5 output, coverage output and baseline build facts were supplied and are cited as such |
| Docs treated as claims, not truth | `README.md`, `AGENT.md` |

Conventions: `file:line` references are to commit `bcd45b2`. "Not determined" means the question could not be
answered from the repository under the review rules. "Not evidenced in the repository" marks design intent or
off-chain process that only the team can supply; those items are collected in section 5.

---

## 0. Summary

The code is small (1,024 SLOC in `src/` per `slither/printer-human-summary.txt`), consistently commented, free of
inline assembly, `unchecked` blocks, `delegatecall` and `tx.origin` (search results in section 2.3), and gated by a
100% line/statement/branch/function coverage check in CI. The level oracle (`LiveCalculator`) and the holder
count (`DicesCoin`) are carefully reasoned and I found no arithmetic or window-indexing error in them.

No finding met the CRITICAL bar (direct, unconditional loss of funds or a broken proxy). The material problems are:

1. **A specification defect in the level table.** Levels 9 and 10 need 3,800 and 5,800 qualifying holders, but a
   1,000,000,000-coin supply and a 300,000-coin threshold allow at most 3,333. They can never unlock (F-01).
2. **The written specification describes a different product.** `README.md` and most of `AGENT.md` section 3
   describe USDC-only fees, a reserve, a race pool, ERC-6909 claims and `claimFees()`. None of that exists in
   `src/`. The brief's 0.50% buy surcharge is not produced by the code (F-02).
3. **Governance is a single key with no bounds.** The owner can replace the fee and level calculators instantly;
   the hook does not cap a fee rate, check that a fee split sums to the fee, or bound a level. The deployment
   script leaves the deployer EOA as owner on mainnet when `PROTOCOL_OWNER` is unset (F-03).
4. **Input and configuration gaps that brick trading for a pool or for the system**: a zero `creator` (F-05), a
   zero `buyAndBurnRecipient` at construction (F-09), a calculator that returns malformed data (F-08).
5. **Two fee calculators.** `InternalSwapPool` keeps the calculator it was constructed with, while the hook's is
   replaceable, so a replaced split applies to only some fees (F-06).
6. **Verification depth.** Slither could not analyse three functions, including the two that settle fees; the
   invariant suite drives one actor on one pool in one currency ordering with no passage of time; 30 of 40
   `testFuzz_` functions fuzz only a boolean; nothing runs against a fork of the deployed PoolManager (F-18).

Overall maturity against the guidelines: **moderate**. Implementation quality is good; documentation accuracy,
governance and adversarial testing are the areas that hold it back.

---

## 1. Documentation and specifications (area 1)

### 1.1 Plain-English system description (generated from the code)

**Purpose.** Dices is a memecoin launchpad built as a single Uniswap v4 hook. Anyone can create a fixed-supply
ERC-20 coin that trades against USDC in a v4 pool whose only liquidity provider is the hook. The hook charges a
fee on every swap, routes it to three recipients, and tracks a "game level" from 0 to 10 for each pool based on a
24-hour average market cap and a count of qualifying holders. Level 1 is called Live and lowers the fee.

**Components.**

| Contract | Role as implemented | Key references |
| --- | --- | --- |
| `DicesHook` | Launch (`createCoin`), launch liquidity, swap callbacks, fee collection, level ratchet, owner configuration, pause of creation | `src/DicesHook.sol:49`, `:533`, `:325`, `:372`, `:433`, `:752-852` |
| `DicesCoin` | Solady ERC-20, deployed per coin as a deterministic minimal clone, initialised once with 1e27 units; maintains an O(1) count of addresses holding at least 300,000 coins | `src/DicesCoin.sol:18`, `:32`, `:123`, `:168`, `:195` |
| `InternalSwapPool` (ISP) | Holds fees that were charged in the coin. On every buy it places that inventory as a one-tick-spacing just-in-time (JIT) position ahead of the price, removes it after the swap, and credits the USDC it earned to fee recipients | `src/core/InternalSwapPool.sol:127`, `:146`, `:226` |
| `FeeEscrow` | Permissionless pull-payment ledger of fully funded credits per (beneficiary, currency); anyone can trigger a payout to the beneficiary | `src/core/FeeEscrow.sol:34`, `:80`, `:89` |
| `LiveCalculator` | Per-pool tick accumulator with 25 hourly checkpoints; returns the level that the 24-to-25-hour average tick and the coin's holder count support. Only the hook may write | `src/calculators/LiveCalculator.sol:146`, `:266`, `:309`, `:353` |
| `FeeCalculator` | Stateless: fee rate (1.25% before Live, 1.00% after), split (40% platform, 30% creator, 30% buy-and-burn), launch price ($12.5k market cap) | `src/calculators/FeeCalculator.sol:23-38`, `:72`, `:85`, `:103` |
| `TrustedRouters` | Owner-managed router allowlist and `IMsgSender` lookup | `src/core/TrustedRouters.sol:25`, `:37` |
| `CurrencySettler` (local) | `sync`/transfer/`settle` and `take` helpers used by the hook | `src/libraries/CurrencySettler.sol:29`, `:60` |
| `UniswapEvents` | Externally linked library that emits indexer events from the hook's address | `src/libraries/UniswapEvents.sol:67-128` |

**Actors and privileges.**

| Actor | Can do | Reference |
| --- | --- | --- |
| Owner (single-step `Ownable`) | Replace fee calculator, level calculator, coin implementation; set fee recipient, buy-and-burn recipient, creation fee, trusted routers; pause/unpause creation; transfer or renounce ownership | `src/DicesHook.sol:752-852`, `src/core/TrustedRouters.sol:25`; `renounceOwnership`/`transferOwnership` listed in `slither/printer-entry-points.txt` |
| Anyone | `createCoin` (when not paused), swap through any router after the launch block, `syncLevel`, `FeeEscrow.deposit/claim/claimBatch`, `DicesCoin.burn` of own balance | `src/DicesHook.sol:533`, `:408`; `src/core/FeeEscrow.sol:34-94`; `src/DicesCoin.sol:182` |
| Users of a trusted router | Additionally swap in a pool's launch block | `src/DicesHook.sol:334` |
| Coin creator (`params.creator`) | Receives 30% of fees for that pool as escrow credit | `src/DicesHook.sol:574`, `:480`; `src/core/InternalSwapPool.sol:274` |
| Bankroll (immutable of the coin implementation) | Receives 10% of every coin at launch with no on-chain restriction; excluded from the holder count | `src/DicesHook.sol:558`, `src/DicesCoin.sol:60`, `:248` |
| PoolManager | Only caller of hook callbacks and `unlockCallback` | `lib/v4-hooks-public/lib/v4-periphery/src/base/ImmutableState.sol:17-20`, `src/DicesHook.sol:587` |

**Assumptions the code relies on** (items marked * are not written down in `README.md` or `AGENT.md`).

- USDC has 6 decimals (checked once: `src/DicesHook.sol:201`), never charges a transfer fee, and does not
  blacklist the hook, the ISP or the escrow.* A blacklisted escrow would revert every USDC fee credit and with it
  every swap that produces one (`src/core/FeeEscrow.sol:61`).
- Every coin has 18 decimals and a supply of exactly 1e27 units. The value is hard-coded three times:
  `src/DicesHook.sol:71`, `src/calculators/LiveCalculator.sol:94`, and implicitly in the tick constants
  (`src/DicesHook.sol:95`, `src/calculators/LiveCalculator.sol:222-240`, `src/calculators/FeeCalculator.sol:55,63`).
  Nothing on chain checks that the three files agree; `AGENT.md:316-317` asks developers to change them together.
- The pool price moves only through swaps and every swap reaches `_afterSwap`; the hook itself never swaps
  (`src/DicesHook.sol:422-425`).
- The PoolManager holds enough USDC from other activity for the hook and the ISP to `take` USDC before the swapper
  has paid it in.* `closeInternalSwapPool` takes JIT proceeds (`src/core/InternalSwapPool.sol:262`) and
  `_collectSwapFee` takes an exact-output buy's USDC fee (`src/DicesHook.sol:473`) inside `afterSwap`, before the
  router settles. `README.md:81` mentions this only as a property of the test router.
- A router must not call `PoolManager.sync` for its input before swapping, because the ISP syncs and settles the
  coin inside `afterSwap` (`src/core/InternalSwapPool.sol:219-222`, `src/libraries/CurrencySettler.sol:20-22`).*
  This integration constraint lives only in code comments.
- `block.number` advances per L2 block (launch-block gate `src/DicesHook.sol:334`, holder-count delay
  `src/DicesCoin.sol:170`).*
- The fee calculator and level calculator are honest and well-formed; the hook does not bound their outputs
  (F-03, F-08).

**Critical operations.**

1. *Launch* (`createCoin`, `src/DicesHook.sol:533-578` and `unlockCallback`, `:587-618`): collect the optional ETH
   creation fee into escrow; clone and initialise the coin; pay 100M coins to the bankroll; initialise the pool at
   the calculator's launch price; add a 700M-coin sale position (launch tick to tick -361,500) and a 200M-coin upper
   position (tick -361,500 to the usable limit), mirrored when the coin is currency1 (`:633-655`); settle.
2. *Swap, before* (`_beforeSwap`, `:325-358`): launch-block gate; record `lastSwapBlock`; ask the ISP to open a
   JIT position if the swap is a buy and inventory is queued.
3. *Swap, after* (`_afterSwap`, `:372-386`): ISP closes its position and credits USDC proceeds; the hook charges
   `rate x |unspecified amount|` in the **unspecified** currency (`:458-463`); a coin-denominated fee is queued in
   the ISP, a USDC fee is split and deposited in escrow (`:471-483`); the level calculator observes the pool in a
   `try` and the hook ratchets `poolLevel` upward (`:433-449`); indexer events are emitted.
4. *Level sync without a swap* (`syncLevel`, `:408-417`): same observation, callable by anyone.
5. *Payout* (`FeeEscrow.claim`, `claimBatch`): full credit to the beneficiary regardless of caller.

Which currency carries the fee follows from "unspecified currency" and is worth stating because both documents
say "USDC only":

| Trade | Specified | Fee currency | Destination |
| --- | --- | --- | --- |
| Buy, exact USDC in | USDC | coin | ISP inventory (`src/DicesHook.sol:474-476`) |
| Buy, exact coin out | coin | USDC | escrow, 40/30/30 (`:478-481`) |
| Sell, exact coin in | coin | USDC | escrow, 40/30/30 |
| Sell, exact USDC out | USDC | coin | ISP inventory |

`test/DicesHookTrading.t.sol:90-117` asserts this table.

### 1.2 Architectural diagrams

Hand-written from the code. The saved Slither outputs that back them are
`audits/2026-11-25-skills-review/slither/inheritance-graph.dot`, `printer-entry-points.txt`,
`printer-vars-and-auth.txt` and `printer-function-summary.txt`; no printer was run for this report.

**Inheritance** (interfaces included; `inheritance-graph.dot` shows only the contract edges
`DicesHook -> Pausable, BaseHook, TrustedRouters`, `TrustedRouters -> Ownable`, `DicesCoin -> ERC20`,
`FeeEscrow -> ReentrancyGuard`).

```mermaid
graph BT
  DicesHook --> BaseHook
  DicesHook --> IDicesHook
  DicesHook --> Pausable
  DicesHook --> TrustedRouters
  BaseHook --> IHooks
  BaseHook --> ImmutableState
  ImmutableState --> IImmutableState
  IDicesHook --> IHooks
  IDicesHook --> IUnlockCallback
  IDicesHook --> IImmutableState
  IDicesHook --> ITrustedRouters
  TrustedRouters --> Ownable
  TrustedRouters --> ITrustedRouters
  Ownable --> Context
  Pausable --> Context
  DicesCoin --> SoladyERC20[solady ERC20]
  FeeEscrow --> ReentrancyGuard
  FeeEscrow --> IFeeEscrow
  InternalSwapPool --> IInternalSwapPool
  LiveCalculator --> ILiveCalculator
  FeeCalculator --> IFeeCalculator
```

**Contract interactions.**

```mermaid
flowchart LR
  Creator -->|"createCoin + ETH fee"| Hook[DicesHook]
  Trader -->|execute| Router[Router]
  Router -->|"unlock, swap, settle, take"| PM[Uniswap v4 PoolManager]
  PM -->|"beforeSwap, afterSwap, beforeAdd/RemoveLiquidity, beforeInitialize, unlockCallback"| Hook
  Hook -->|"cloneDeterministic, initialize, transfer to bankroll"| Coin[DicesCoin clone]
  Coin -.->|"delegatecall (ERC-1167)"| Impl[DicesCoin implementation]
  Hook -->|"unlock, initialize, modifyLiquidity, take, sync, settle"| PM
  Hook -->|"createInternalSwapPool, closeInternalSwapPool, deposit"| ISP[InternalSwapPool]
  ISP -->|"modifyLiquidity, sync, settle, take, extsload"| PM
  ISP -->|"poolCoins, poolLive, feeRecipient, poolCreators, buyAndBurnRecipient"| Hook
  Hook -->|"getSwapFee, getFeeDistribution, getInitialSqrtPriceX96"| FC[FeeCalculator, replaceable]
  ISP -->|"getFeeDistribution"| FC0[FeeCalculator, fixed at ISP construction]
  Hook -->|"qualify, in try/catch"| LC[LiveCalculator, replaceable]
  LC -->|"getSlot0 via extsload"| PM
  LC -->|qualifiedHolders| Coin
  Hook -->|"deposit: USDC fee credits, ETH creation fee"| Esc[FeeEscrow]
  ISP -->|"deposit: USDC proceeds"| Esc
  Anyone -->|"claim, claimBatch"| Esc
  Esc -->|"USDC, ETH"| Ben[Platform, creator, buy-and-burn recipient]
  Hook -.->|"delegatecall (linked library)"| UE[UniswapEvents]
  Hook -->|"msgSender staticcall, result unused"| Router
  Owner -->|"set*, pause, transferOwnership"| Hook
  Anyone -->|syncLevel| Hook
```

**Launch sequence** (`src/DicesHook.sol:533-618`).

```mermaid
sequenceDiagram
  participant C as Caller
  participant H as DicesHook
  participant E as FeeEscrow
  participant K as DicesCoin clone
  participant PM as PoolManager
  participant F as FeeCalculator
  C->>H: createCoin(name, symbol, creator) with msg.value
  opt createFee is non-zero
    H->>E: deposit(feeRecipient, native, createFee)
  end
  H->>K: cloneDeterministic(implementation, keccak(chainid, coinCount++))
  H->>K: initialize(name, symbol, 1e27, hook)
  H->>K: transfer(bankroll, 1e26)
  H->>PM: unlock(poolKey, coinIsCurrency0)
  PM->>H: unlockCallback
  H->>F: getInitialSqrtPriceX96(coinIsCurrency0)
  H->>PM: initialize(poolKey, price)
  Note over PM,H: hook callbacks are skipped for the hook's own calls (Hooks.noSelfCall)
  H->>PM: modifyLiquidity(sale position, 7e26 coins)
  H->>PM: modifyLiquidity(upper position, 2e26 coins)
  H->>PM: sync(coin), transfer owed coins, settle
  PM-->>H: all deltas zero, lock
  H-->>C: coin address
```

**Buy with queued inventory** (`src/DicesHook.sol:325-386`, `src/core/InternalSwapPool.sol:146-279`).

```mermaid
sequenceDiagram
  participant R as Router
  participant PM as PoolManager
  participant H as DicesHook
  participant I as InternalSwapPool
  participant E as FeeEscrow
  participant L as LiveCalculator
  R->>PM: unlock, then swap(key, params)
  PM->>H: beforeSwap(router, key, params)
  H->>H: launch-block gate, lastSwapBlock = block.number
  H->>I: createInternalSwapPool
  I->>PM: modifyLiquidity(+JIT, one tick spacing ahead of spot)
  PM->>H: beforeAddLiquidity(sender = ISP)
  PM->>PM: pool swap
  PM->>H: afterSwap(router, key, params, delta)
  H->>I: closeInternalSwapPool
  I->>PM: modifyLiquidity(-JIT)
  PM->>H: beforeRemoveLiquidity(sender = ISP)
  I->>PM: sync(coin), transfer coins sold, settle
  I->>PM: take(USDC proceeds)
  I->>E: deposit x3 (platform, creator, buy-and-burn)
  H->>PM: take(fee in the unspecified currency)
  alt fee currency is the coin
    H->>I: transfer, deposit(coin, fee)
  else fee currency is USDC
    H->>E: deposit x3
  end
  H->>L: qualify(key), inside try/catch
  L-->>H: level supported now
  H->>H: raise poolLevel if higher, emit PoolLive / PoolLevelUnlocked
  H-->>PM: selector and +fee as the hook's unspecified delta
  R->>PM: settle input, take output
```

**State machines.**

```mermaid
stateDiagram-v2
  [*] --> LaunchBlock: createCoin
  LaunchBlock --> Level0: next block
  Level0 --> Live: calculator reports level 1 or more
  Live --> HigherLevel: calculator reports a level above poolLevel
  HigherLevel --> HigherLevel: calculator reports a level above poolLevel
  note right of LaunchBlock
    Swaps revert unless the router is trusted
  end note
  note right of Level0
    Fee 1.25 percent. No level for 24 to 25 hours after the first observation
  end note
  note right of Live
    Fee 1.00 percent. Levels never decrease
  end note
```

```mermaid
stateDiagram-v2
  state "ISP JIT position (single storage slot pair, not keyed by pool)" as jit {
    [*] --> Idle
    Idle --> Open: beforeSwap, buy with inventory, range usable, liquidity non-zero
    Open --> Idle: afterSwap, state deleted before external calls
  }
  state "DicesCoin clone" as coin {
    [*] --> Uninitialised
    Uninitialised --> Initialised: initialize (same transaction as the clone)
  }
```

### 1.3 Documentation gaps

**F-02 (HIGH). The written specification does not describe the code.** `AGENT.md:102-103` warns that its
Contracts table, Fees, Ledgers and Configuration subsections are stale. `README.md` carries no such warning and
its summary of the fee system is wrong in every clause. Further stale statements sit outside the subsections that
the warning names.

| Statement | Where | What the code does |
| --- | --- | --- |
| "Every fee is charged in USDC through hook deltas" | `README.md:10`, `AGENT.md:132-140`, `AGENT.md:250` | The fee is charged in the unspecified currency, so half of the trade types pay in the coin: `src/DicesHook.sol:460`, `:474-476` |
| "plus 0.50% on buys to the coin's reserve ... then 0.25% on buys to the race pool" | `README.md:10-11`, `AGENT.md:45-47` | One rate for both directions: `return _live ? POST_LIVE_FEE : PRE_LIVE_FEE;` (`src/calculators/FeeCalculator.sol:73`). No `reserve`, `racePool` or `reserveController` identifier exists in `src/` or `script/` (grep) |
| "The base fee is split between the platform and the creator" | `README.md:12`, `AGENT.md:49` | Three-way split, 40% platform, 30% creator, 30% buy-and-burn: `src/calculators/FeeCalculator.sol:23-28`, `:85-94` |
| "Fees accrue as ERC-6909 USDC claims and are withdrawn with `claimFees()`" | `README.md:12-13`, `AGENT.md:146-149` | ERC-20 USDC is taken from the PoolManager and deposited in `FeeEscrow`: `src/DicesHook.sol:473`, `:731-741`; payout is `FeeEscrow.claim`: `src/core/FeeEscrow.sol:80` |
| `createCoin(CoinParams{name, symbol, creator, gameCommitment})`, "Validate the creator split", "Snapshot ... `PoolConfig`", "Emit `CoinCreated`" | `AGENT.md:106-116` | `CoinParams` has `name`, `symbol`, `creator` only (`src/interfaces/IDicesHook.sol:24-37`); no validation, snapshot or `CoinCreated` event in `createCoin` (`src/DicesHook.sol:533-578`) |
| "`beforeAddLiquidity` rejects any sender but the hook, `beforeRemoveLiquidity` rejects everyone" | `AGENT.md:118` | Both admit the ISP: `src/DicesHook.sol:291`, `:303` |
| "`PoolSwap(poolId, amount0, amount1, fee0, fee1)` after every swap" | `AGENT.md:168` | `HookSwap` and `HookFee` are emitted (`src/DicesHook.sol:504-520`); `PoolSwap` is declared (`src/libraries/UniswapEvents.sol:43`) and never emitted |
| "a partial fill reverts (`PartialFillWithSpecifiedCurrency`)" | `AGENT.md:141-142` | No such error in `src/` |
| Contracts table lists 7 files | `AGENT.md:84-95` | Omits `core/InternalSwapPool.sol`, `core/FeeEscrow.sol`, `core/TrustedRouters.sol`, `libraries/CurrencySettler.sol` |
| "registers a **sealed** casino game" in the one launch transaction | `AGENT.md:24-25` (brief output) | Nothing is stored or emitted for a game at launch |
| "Treasury is a Safe secured by a 48-hour timelock. All critical financial operations are enforced on-chain with caps" | `AGENT.md:56` (brief output, marked deferred at `AGENT.md:75`) | No cap exists on any owner-settable value (F-03) |
| "the script reverts while the fee recipient or buy and burn recipient is unset" | `README.md:116-117` | Correct, but omits that the owner placeholder does **not** revert on mainnet (`script/deployment/V001.s.sol:306`) |
| Address book for Base Sepolia | `deployments/deployment-84532.md` | Has no Bankroll row although `_saveMarkdown` writes one (`script/deployment/V001.s.sol:660`), so the committed book predates the current script. Whether the testnet was redeployed is not determined |

Consequence: an integrator, indexer author or auditor who reads the documents will model a system with different
fee currencies, different recipients, different events and a different liquidity-lock guarantee from the one
deployed. `AGENT.md:9-12` makes the brief's numbers binding outputs, and the brief's buy surcharge is not
produced; whether the client has accepted the 40/30/30 model is not evidenced in the repository (question Q2).

**NatSpec.** Coverage is complete: every function, modifier, event and error in `src/` carries a notice. Accuracy
problems:

| Location | Text | Problem |
| --- | --- | --- |
| `src/DicesHook.sol:361` | "@notice The hook's own swaps." | `_afterSwap` runs for third-party swaps only; the hook must never swap (`:424-425`) |
| `src/DicesHook.sol:328` | "Prevents bots from buying in the same block as launch, unless token creator." | No creator check exists; the exemption is router trust (`:334`). See F-07 |
| `src/DicesHook.sol:323` | "@return The protocol fee percentage" | The third return value of `beforeSwap` is the LP fee override |
| `src/DicesHook.sol:588` | "Decode the pool key, coin is currency0, and config passed to the callback" | No config is passed |
| `src/calculators/FeeCalculator.sol:79` | "@param _amount The amount of USDC being swapped." | It is the collected fee (the interface says so: `src/interfaces/IFeeCalculator.sol:24`) |
| `src/libraries/UniswapEvents.sol:41` | "Pool swap deltas and fees emitted directly by DicesHook." | `PoolSwap` is never emitted |
| `src/interfaces/ITrustedRouters.sol:11`, `:16` | "Whether the hook may attribute swaps through this router" | Attribution is computed and discarded (F-12); the only effect of trust is the launch-block exemption |
| `src/core/InternalSwapPool.sol:256` | "An untouched position owes nothing back" | Add rounds up and remove rounds down, so an untouched position can owe 1 unit; the code handles it (`:257`), the comment is imprecise |

**Undocumented behaviour worth a paragraph each in the design reference:** the fee-currency table in 1.1; the
PoolManager-balance assumption; the router `sync` ordering constraint; the fact that `HookSwap` duplicates the
PoolManager's own `Swap` and that `HookFee` repeats the fee already carried in `HookSwap`
(`src/libraries/UniswapEvents.sol:21-24`, `:31`); Solady's default infinite Permit2 allowance on every coin (F-16).

---

## 2. Architecture analysis

### 2.1 On-chain versus off-chain computation (area 2)

Everything is on chain. The repository contains no off-chain component; indexers and a UI are implied by
`UniswapEvents` and by `LiveCalculator.averageMarketCap` (`src/calculators/LiveCalculator.sol:200`), but their
design is not evidenced in the repository.

What is computed on chain and whether that is appropriate:

- **Level rule.** Market-cap targets are precomputed ticks and holder floors are constants
  (`src/calculators/LiveCalculator.sol:219-253`), so no price maths runs per swap. The holder count is maintained
  incrementally in the token (`src/DicesCoin.sol:195-224`). Checkpoint writes are bounded at 25 per call
  (`src/calculators/LiveCalculator.sol:283-287`). This is a sound use of "precompute off chain, verify on chain".
  I spot-checked levels 1, 2, 9 and 10 by hand against `ln(target / 1e27) / ln(1.0001)` and they agree.
- **No sorting, iteration over users, or unbounded loops** exist in `src/`. The only loops are the 25-step
  checkpoint loop, two 10-step level loops (`:360`, `:373`) and `claimBatch` over caller-supplied input
  (`src/core/FeeEscrow.sol:91`).

Optimisation opportunities (gas only; amounts not measured because no tool was run):

1. `InternalSwapPool._internalSwapPoolState` is written and deleted in regular storage on every buy
   (`src/core/InternalSwapPool.sol:212`, `:234`); it occupies two slots (`:40-47`). The target EVM is Osaka
   (`foundry.toml:6`), so `transient` storage is available.
2. Each USDC fee event performs three `forceApprove` + `transferFrom` + two `balanceOf` round trips
   (`src/DicesHook.sol:479-481`, `src/core/FeeEscrow.sol:60-67`). One transfer with three ledger writes would do.
3. `DicesHook.internalSwapPool` and `feeEscrow` are storage variables with no setter (`src/DicesHook.sol:125`,
   `:145`); Slither flags both under `immutable-states`. Check `forge build --sizes` if changed: the hook has
   1,499 bytes of headroom (baseline).
4. `lastSwapBlock` costs a storage write per swap and nothing reads it (F-12).
5. `_getSender` makes a `staticcall` to the router twice per swap and both results are discarded (F-12).
6. `MINIMUM_INTERNAL_SWAP_POOL_SIZE` does not filter anything in practice (F-13), so every buy with any inventory
   pays for two `modifyLiquidity` calls.

`AGENT.md:223-229` records measured gas for the level calculator only. No gas snapshot is committed and
`forge snapshot` is not part of CI (`.github/workflows/test.yml:28-44`).

### 2.2 Upgradeability (area 3)

Verified by search before writing: `grep -rnE "delegatecall|Proxy|proxy|LibClone|clone|selfdestruct" src` returns
only `LibClone.cloneDeterministic` (`src/DicesHook.sol:551`) and comments. There is no upgradeable proxy, no
`UUPSUpgradeable`/`TransparentUpgradeableProxy`/beacon, and no admin slot. Contracts are immutable once deployed.

The system is nonetheless **reconfigurable by module replacement**, which the guidelines treat as upgradeability:

| Component | Replaceable | By | Effect on existing pools | Reference |
| --- | --- | --- | --- | --- |
| Fee calculator (hook) | Yes, instant | Owner | Rate and split of USDC-denominated fees change for every pool; launch price changes for new coins | `src/DicesHook.sol:752-754`, `:462`, `:478`, `:595` |
| Fee calculator (ISP) | **No** | - | Split of JIT proceeds stays as constructed | `src/core/InternalSwapPool.sol:75`, `:265` |
| Level calculator | Yes, instant | Owner | History restarts; unlocked levels stay; any level it returns is recorded | `src/DicesHook.sol:761-763`, `:436-440` |
| Coin implementation | Yes, instant | Owner | Future coins only; changes bankroll, threshold and excluded addresses for them | `src/DicesHook.sol:806-812` |
| ISP, FeeEscrow, USDC, PoolManager | No | - | - | `src/DicesHook.sol:110`, `:212`, `:215` |
| Trusted routers, recipients, creation fee, pause | Yes | Owner | Immediate | `src/DicesHook.sol:770-852` |

Assessment against the guidelines:

- **Migration over upgradeability** is the approach taken, which the guidelines favour. The data-separation
  pattern is applied where it matters: levels live in the hook and survive a calculator replacement
  (`src/DicesHook.sol:175`, tested in `test/DicesHookLive.t.sol:256-283`).
- **There is no migration path for liquidity, by design.** The hook has no negative `liquidityDelta`
  (`src/DicesHook.sol:715` is the only `modifyLiquidity` call) and swaps cannot be paused (`whenNotPaused` is on
  `createCoin` only, `:533`). A defect in the swap path of the hook or the ISP therefore cannot be stopped or
  migrated away from for coins that already exist. That is the product's promise, but it raises the bar for
  pre-deployment verification, and an incident-response plan is not evidenced in the repository (Q9).
- **Replacement procedure is documented in prose only.** `AGENT.md:95-100` states the rule for replacing the
  level calculator. There is no script for replacing a calculator or the coin implementation, and the hook does
  not enforce the documented rule on chain: `_setLiveCalculator` checks code length only
  (`src/DicesHook.sol:832-838`), although `LiveCalculator.dicesHook()` is public
  (`src/calculators/LiveCalculator.sol:109`) and could be compared with `address(this)`. Likewise
  `setCoinImplementation` does not check `hook()`, `poolManager()` or `internalSwapPool()` on the new
  implementation (`src/DicesHook.sol:806-812`); only the initial deployment does
  (`script/deployment/V001.s.sol:528-531`).
- **Deployment and initialisation.** `V001.s.sol` predicts every address, refuses occupied addresses
  (`:439-451`), binds salts to the signer (`:402-405`), and asserts wiring after the run (`:510-532`). Gaps:
  `_requireWiring` does not check `internalSwapPool.feeCalculator()`; it runs in the simulation, and there is no
  read-only entry point that re-checks a live deployment (only `predict()`, `:265-280`).

### 2.3 Delegatecall proxy pattern (area 4)

No upgradeable delegatecall proxy exists (search above). Two delegatecall mechanisms are present and were
reviewed against the guideline checklist:

**(a) ERC-1167 minimal clones of `DicesCoin`.**

| Check | Result |
| --- | --- |
| Storage layout | One implementation per clone, fixed in the clone's bytecode at creation; no shared-storage upgrade is possible. `_name`, `_symbol` and one packed slot (`src/DicesCoin.sol:65-93`); Solady balances use hashed slots |
| Inheritance order | Single base (`ERC20`), `src/DicesCoin.sol:18` |
| Initialisation of clones | `initialize` has no access control (`:123`) but the hook clones and initialises in one transaction (`src/DicesHook.sol:551-554`), so it cannot be front-run |
| Initialisation of the implementation | **Not locked.** See F-10 |
| Constructor logic | Constructor writes immutables only (`src/DicesCoin.sol:109-112`), so clones and implementation agree |
| Immutables | `hook`, `poolManager`, `internalSwapPool`, `bankroll` live in implementation bytecode and are shared by every clone of it (`:40-60`). Intended and documented (`:37-38`, `:56-58`) |
| Function shadowing | Not applicable: a minimal proxy has no functions of its own |
| Direct use / self-destruct of implementation | No `selfdestruct` or `delegatecall` in `DicesCoin` or in Solady `ERC20` paths it uses; implementation cannot be destroyed |
| Contract-existence check | `setCoinImplementation` requires code (`src/DicesHook.sol:807`). `coinImplementation` is not assigned in the constructor (`:199-225`). By inspection, a clone of the zero address returns empty data, so `createCoin` reverts when decoding `bankroll()` (`:558`) and no coin can launch against an empty implementation; no test covers this |
| `slither-check-upgradeability` | Not run; no output was supplied and the tool targets upgradeable proxies |

**(b) Externally linked library `UniswapEvents`.** Its functions are `public` (`src/libraries/UniswapEvents.sol:67-125`),
so the compiler emits `DELEGATECALL` from the hook. The library holds no state, writes no storage, and its
address is fixed in hook bytecode at link time (`script/deployment/V001.s.sol:485-505`). The linker reads
`out/DicesHook.sol/DicesHook.json` from disk and patches hex (`:486-504`); a stale or differently profiled
artifact would be deployed as-is. `test/scripts/V001.t.sol:372` covers the absence of automatic links, not
artifact freshness.

---

## 3. Implementation review

### 3.1 Function composition (area 5)

Function sizes (measured from source; cyclomatic complexity from `slither/printer-function-summary.txt`, which is
unreliable for the three functions Slither could not lower to IR):

| Function | Lines | Slither CC | Comment |
| --- | --- | --- | --- |
| `InternalSwapPool.createInternalSwapPool` (`src/core/InternalSwapPool.sol:146-214`) | 69 | 5 | Eligibility, tick selection for two orderings, capacity sizing, position creation, state write. The tick selection (`:166-187`) duplicates the rounding logic of `DicesHook._launchTick` (`src/DicesHook.sol:670-684`) and should be one tested pure helper |
| `InternalSwapPool.closeInternalSwapPool` (`:226-279`) | 54 | 6 (IR failed) | Removal, delta validation, inventory accounting, settlement, three-way credit. Split into `_settleJit` and `_distribute` |
| `DicesHook.createCoin` (`src/DicesHook.sol:533-578`) | 46 | 7 | Acceptable; fee collection could be a helper |
| `FeeEscrow.deposit` (`src/core/FeeEscrow.sol:34-73`) | 40 | 7 | Acceptable |
| `DicesHook._beforeSwap` (`:325-358`) | 34 | 2 | Mostly banner comments |
| `LiveCalculator._observe`, `_average` (`src/calculators/LiveCalculator.sol:266-295`, `:309-338`) | 30 each | 4 | Dense but well explained |

Median function length is 7 lines in `DicesHook` and `LiveCalculator`, 12 in the ISP. Grouping is clear: rate
logic in `FeeCalculator`, level logic in `LiveCalculator`, custody in `FeeEscrow`, authentication in modifiers.

Composition issues:

- **Duplicated logic.** `_creditFee` is implemented twice (`src/DicesHook.sol:731-741`,
  `src/core/InternalSwapPool.sol:287-297`); the three-way distribution is implemented twice
  (`src/DicesHook.sol:478-481`, `src/core/InternalSwapPool.sol:265-277`) and the two copies consult different
  calculators (F-06). `CurrencySettler` exists twice (F-11).
- **Ternaries that defeat tooling.** The three functions Slither failed on all combine a ternary with a tuple
  or a library call: `src/DicesHook.sol:460`, `src/DicesHook.sol:707`, and
  `src/core/InternalSwapPool.sol:244-245`/`:258-262`. The cause of the Slither failure was not determined, but
  rewriting these as `if/else` is cheap and would also make the fee-currency selection easier to read.
- **Pass-through parameters.** `createInternalSwapPool(address, ..., bytes calldata)` and
  `closeInternalSwapPool(address, ..., SwapParams, BalanceDelta, bytes)` ignore four of their parameters
  (`src/core/InternalSwapPool.sol:146`, `:226`).

### 3.2 Inheritance (area 6)

Diagram in 1.2. Depth is at most 3 (`DicesHook -> TrustedRouters -> Ownable -> Context`); width at `DicesHook`
is 4. Linearisation per `slither/printer-entry-points.txt`: "DicesHook is TrustedRouters is Pausable is Ownable is
Context is BaseHook is ImmutableState".

- Diamonds exist only over interfaces and the stateless `Context` (`IHooks`, `IImmutableState`,
  `ITrustedRouters`). No state variable is inherited along two paths.
- Overrides are explicit: `getHookPermissions` overrides `(BaseHook, IDicesHook)` (`src/DicesHook.sol:236`);
  `pause`/`unpause` override the interface (`:843`, `:850`).
- `DicesCoin` does **not** declare `is IDicesCoin` (`src/DicesCoin.sol:18`), yet `LiveCalculator` calls it through
  that interface (`src/calculators/LiveCalculator.sol:371`). Conformance is therefore not compiler-checked. Low
  risk; add the inheritance or a test that compares selectors.
- Inherited and reachable but probably unwanted: `renounceOwnership()` (`slither/printer-entry-points.txt`).
  Renouncing would freeze calculators, routers, recipients and the pause switch permanently. Override it to
  revert, or document it as the intended end state.
- Slither `shadowing-local`: constructor parameter `_owner` shadows `Ownable._owner` (`src/DicesHook.sol:199`).
  Benign.

### 3.3 Events (area 7)

Events emitted today: `PoolCreated`, `HookSwap`, `HookFee`, `PoolStateUpdated` (via `UniswapEvents`, from the
hook's address); `PoolLive`, `PoolLevelUnlocked`; one `*Updated` event per owner setter
(`src/DicesHook.sol:774`, `:785`, `:797`, `:810`, `:823`, `:836`); `TrustedRouterSet`
(`src/core/TrustedRouters.sol:27`); OpenZeppelin `Paused`/`Unpaused`/`OwnershipTransferred`;
`InternalSwapPool.Deposit` (`src/core/InternalSwapPool.sol:137`); `FeeEscrow.Deposited`/`Claimed`
(`src/core/FeeEscrow.sol:72`, `:119`). Every owner-settable parameter emits. Naming is consistent.

**F-14 (LOW). Gaps and hazards.**

1. **No event records who created a coin.** `createCoin` emits only `PoolCreated(poolId, coin, usdc)`
   (`src/DicesHook.sol:604`); the creator, name, symbol, implementation and bankroll are recoverable only by
   reading storage. `PoolCreated`'s token arguments are not indexed (`src/libraries/UniswapEvents.sol:38`).
2. **Fee credits cannot be attributed to a pool from events.** `FeeEscrow.Deposited(beneficiary, currency,
   depositor, amount)` (`src/interfaces/IFeeEscrow.sol:49`) has no pool id, so a creator with two coins, or the
   platform, cannot be reconciled per pool without replaying swaps.
3. **JIT conversion is silent.** Inventory decreases at `src/core/InternalSwapPool.sol:254` with no event;
   `Deposit` reports increases only.
4. **Double-counting hazard.** `HookSwap` repeats the PoolManager's own `Swap` deltas and carries the fee in its
   `hookLPfeeAmount*` fields; `HookFee` repeats the same fee (`src/DicesHook.sol:376-383`). The library comment
   says consumers "must read one or the other, not both" (`src/libraries/UniswapEvents.sol:21-22`). Whether the
   intended indexers follow that rule is not evidenced in the repository (Q10). The fee is not an LP fee.
5. **Declared but never emitted:** `PoolSwap` (no emitter exists), `PoolLiquidityDelta`, `PoolDonation` (emitters
   exist at `src/libraries/UniswapEvents.sol:104`, `:115` and are called only from `test/Libraries.t.sol:36-37`).
   They enlarge the linked library and the ABI that indexers are told to expect (`AGENT.md:168`).
6. The constructor sets `feeRecipient`, `buyAndBurnRecipient`, `internalSwapPool` and `feeEscrow` without events
   (`src/DicesHook.sol:209-218`), unlike the two calculators.

No critical state change is unlogged in a way that blocks incident monitoring; item 1 is the one that monitoring
of launches will need.

### 3.4 Common pitfalls (area 8)

Checked and found sound:

- **Reentrancy.** `FeeEscrow` is `nonReentrant` on all three entry points and updates the ledger before paying
  (`src/core/FeeEscrow.sol:34`, `:80`, `:89`, `:110`). The ISP deletes its JIT state before external calls
  (`src/core/InternalSwapPool.sol:233-234`). Between `createInternalSwapPool` and `closeInternalSwapPool` the only
  external calls are to the PoolManager, the hook's own view callback and a `staticcall` to a trusted router, so
  the single un-keyed state slot cannot be interleaved. `PoolManager.unlock` rejects nesting
  (`lib/v4-hooks-public/lib/v4-core/src/PoolManager.sol:105`), so `createCoin` cannot run inside a swap. Slither's
  `reentrancy-eth` on `_afterSwap` writes `poolLevel` after calls to protocol contracts and USDC only; the write
  is monotonic. Triaged as not exploitable.
- **Access control.** Hook callbacks are `onlyPoolManager` (BaseHook); ISP mutators are `onlyHook`
  (`src/core/InternalSwapPool.sol:127`, `:146`, `:226`); `LiveCalculator.qualify` is `onlyHook` (`:146`); owner
  functions are `onlyOwner`. Third parties cannot initialise a pool on the hook (`src/DicesHook.sol:256-258`) or
  add or remove liquidity (`:291`, `:303`). Position ownership in the PoolManager is keyed by caller, so the ISP's
  remove permission cannot reach the hook's positions (`test/DicesHook.t.sol:386-402`).
- **Arithmetic.** Solidity 0.8 checked arithmetic throughout; no `unchecked`. Down-casts are bounded and
  commented: `src/calculators/LiveCalculator.sol:271`, `:337`, `:400`; `src/DicesCoin.sol:219`. `SafeCast` guards
  the fee conversions (`src/DicesHook.sol:461`, `:472`, `:493`).
- **Oracle manipulation.** The level uses a time-weighted tick over 24 to 25 hours, not spot
  (`src/calculators/LiveCalculator.sol:309-338`). The upper position extends to the usable tick limit so price
  cannot be moved upward without buying (`src/DicesHook.sol:646`, `:653`). The holder count ignores same-block
  joiners by reporting `min(count before this block, count now)` (`src/DicesCoin.sol:168-175`). The residual
  attack is the documented patient buyer (`AGENT.md:260-262`).
- **Timestamp dependence.** Hour granularity only (`src/calculators/LiveCalculator.sol:79`).
- **Uninitialised state.** `coinImplementation` starts at zero but launches then revert (2.3).
- **Token handling.** `SafeERC20` in hook, ISP and escrow; the escrow rejects fee-on-transfer deposits
  (`src/core/FeeEscrow.sol:65-67`).

Findings:

**F-01 (HIGH). Levels 9 and 10 can never unlock.** Confidence: high.

```solidity
uint public constant HOLDER_THRESHOLD = 300_000e18;                              // src/DicesCoin.sol:32
uint internal constant LAUNCH_SUPPLY = 1_000_000_000e18;                         // src/DicesHook.sol:71
return [uint(150), 225, 350, 500, 750, 1_100, 1_700, 2_500, 3_800, 5_800];       // src/calculators/LiveCalculator.sol:252
while (level_ != 0 && holders < floors[level_ - 1]) { --level_; }                // src/calculators/LiveCalculator.sol:373-375
```

The supply is minted once (`src/DicesCoin.sol:137`, called with `LAUNCH_SUPPLY` at `src/DicesHook.sol:554`) and
can only shrink (`burn`, `src/DicesCoin.sol:182`). At most `floor(1e9 / 3e5) = 3,333` addresses can hold the
threshold at once, before subtracting what sits in the PoolManager, the ISP, the hook and the bankroll, none of
which count (`src/DicesCoin.sol:247-249`).

| Level | Holder floor | Coins that must sit in qualifying wallets | Share of supply |
| --- | --- | --- | --- |
| 7 | 1,700 | 510,000,000 | 51% |
| 8 | 2,500 | 750,000,000 | 75% |
| 9 | 3,800 | 1,140,000,000 | 114% (impossible) |
| 10 | 5,800 | 1,740,000,000 | 174% (impossible) |

Level 8 additionally requires three quarters of the entire supply to be spread across wallets of at least
300,000 coins each (worth about $7,700 per wallet at that level's $25.6M target), with part of the supply still
unsold in the upper position; whether that is practically reachable was not determined. The tests do not expose
the problem: calculator tests use a stand-in coin that reports 10,000 holders
(`test/Calculators.t.sol:38-39`, `test/utils/Fixtures.sol:83-99`), and the end-to-end suite stops at level 5
(`test/DicesHookLive.t.sol:135-171`). `AGENT.md:286-289` asks the client to confirm the floors but does not state
the ceiling. Fix: choose between a lower threshold, floors that fit the supply, or a threshold that falls as the
level rises, and add a test that asserts `floors[i] * HOLDER_THRESHOLD <= sellable supply` for every level.

**F-03 (HIGH). Owner powers are unbounded, instant and held by one key.** Confidence: high on mechanism.

```solidity
fee.amount = Math.mulDiv(amount, feeCalculator.getSwapFee(poolLive(key.toId())), FEE_DENOMINATOR);  // src/DicesHook.sol:462
(uint platform, uint creator, uint buyAndBurn) = feeCalculator.getFeeDistribution(fee.amount, poolLive(poolId)); // :478
try liveCalculator.qualify(_poolKey) returns (uint8 level) { ... if (level > unlocked) { poolLevel[_poolId] = level; // :436-439
protocolOwner = cfg.protocolOwner == address(0) ? deployer : cfg.protocolOwner;  // script/deployment/V001.s.sol:306
```

- The fee rate is whatever the calculator returns. A calculator returning `100_000` takes the whole unspecified
  amount; nothing in the hook caps it. Swappers are protected only by their own slippage limit.
- The split is not checked against `fee.amount`. A sum below the fee strands USDC in the hook, which has no
  sweep; a sum above it reverts every such swap because the hook holds no spare USDC
  (`test/DicesHookInvariant.t.sol:90` asserts a zero balance).
- A calculator that reverts in `getSwapFee` blocks every swap in every pool; only the level calculator is
  wrapped in `try`.
- A level calculator may return any `uint8`; the hook records it without comparing against `LEVELS`, and the
  ratchet makes a wrong unlock permanent (`src/DicesHook.sol:438-446`).
- Ownership is single-step `Ownable` (`src/core/TrustedRouters.sol:13`); `V001` transfers it in one call
  (`script/deployment/V001.s.sol:244-246`), so a mistyped `PROTOCOL_OWNER` is unrecoverable.
- On mainnet the script refuses an unset fee recipient, buy-and-burn recipient and bankroll (`:323-325`) but
  **not** an unset owner: the deployer EOA stays owner (`:131`, `:306`, pinned by
  `test/scripts/V001.t.sol:259-267`).

The brief requires a Safe behind a 48-hour timelock and on-chain caps (`AGENT.md:56`); the treasury is listed as
deferred (`AGENT.md:75`). Until it exists the hook is governed by a hot key with the powers above. Fix: cap the
rate in the hook (for example `require(rate <= MAX_FEE)`), require `platform + creator + buyAndBurn == fee.amount`,
require `level <= LEVELS`, use `Ownable2Step`, and make `V001` revert on mainnet without a contract owner.

**F-04 (HIGH, already an open question). The bankroll's 100M coins are unbacked and unrestricted.**
`src/DicesHook.sol:558` pays 10% of supply to an address that can sell at once. `AGENT.md:127-130` and open
question 10 (`AGENT.md:296-299`) describe the consequence, and `test/DicesHookLaunchCurve.t.sol:75` pins it. It is
listed here because it is the largest economic risk in the launch path and must be closed before mainnet, not
because it is new. Two side effects are not in the documents: the bankroll is the only party that can push a
pool into the zero-liquidity region below the sale range, where price moves for free and drags the time-weighted
average down; and it can seed every holder floor at no cost (stated at `AGENT.md:158`).

**F-05 (MEDIUM). `createCoin` accepts `creator == address(0)`, after which most swaps in that pool revert.**
Confidence: high.

```solidity
poolCreators[poolId] = params.creator;                                           // src/DicesHook.sol:574
_creditFee(poolCreators[poolId], Currency.unwrap(fee.currency), creator);        // src/DicesHook.sol:480
if (_beneficiary == address(0)) { revert InvalidBeneficiary(); }                 // src/core/FeeEscrow.sol:36-38
```

`_creditFee` skips only a zero amount (`src/DicesHook.sol:732`). For a pool with a zero creator, every swap whose
USDC fee is 4 units or more (creator share rounds to at least 1) reverts: all exact-input sells, all exact-output
buys, and any buy whose JIT conversion earns 4 or more USDC units (`src/core/InternalSwapPool.sol:274`). The first
exact-input buy succeeds because no inventory is queued yet; later ones succeed only if they do not trade into
the JIT range. Holders can still exit with exact-output sells, whose fee is in the coin, but that is not what a
wallet UI submits by default. Anyone can create such a coin; no test covers a
zero creator. Fix: revert on a zero creator in `createCoin`.

**F-06 (MEDIUM). Two fee calculators: the ISP's is immutable, the hook's is replaceable.** Confidence: high on
mechanism; intent not evidenced.

```solidity
IFeeCalculator public immutable feeCalculator;                                   // src/core/InternalSwapPool.sol:75
(uint platform, uint creator, uint buyAndBurn) = feeCalculator.getFeeDistribution(proceeds, dicesHook.poolLive(poolId)); // :265
function setFeeCalculator(address _calculator) external onlyOwner { ... }        // src/DicesHook.sol:752
```

After `setFeeCalculator`, USDC-denominated fees follow the new split while coin-denominated fees, which are the
fees of the most common trade (exact-input buy), are converted and split by the calculator fixed at ISP
construction. The ISP cannot be replaced (`src/DicesHook.sol:125` has no setter) and the coin implementation
embeds its address (`src/DicesCoin.sol:50`). `test/CalculatorUpdates.t.sol:28` asserts the immutability
("ISP policy is immutable") but no document states the consequence, and `AGENT.md:277` lists the split as an open
client question, which makes a later change likely. Fix: have the ISP read `dicesHook.feeCalculator()`, or return
the proceeds to the hook and distribute in one place.

**F-07 (MEDIUM). The launch-block guard exempts every user of a trusted router.** Confidence: high on mechanism,
medium that it is unintended.

```solidity
// Prevent 0-block buys: Prevents bots from buying in the same block as launch, unless token creator.   // src/DicesHook.sol:328
if (launchBlock[poolId] == block.number && !trustedRouters[sender]) { revert CannotBuyZeroBlock(); }   // :334-336
hook.setTrustedRouter(cfg.universalRouter, true);                                // script/deployment/V001.s.sol:238
```

`sender` is the router. The deployment trusts the public Universal Router, so anyone who routes through it can
buy in the launch block; the creator is not checked. The guard stops only direct or custom-router callers. The
interface describes the implemented behaviour ("An untrusted router tried to swap in the pool's launch block",
`src/interfaces/IDicesHook.sol:161`), the comment describes a different one, and
`test/DicesHookTrading.t.sol:144-152` tests the guard with a bare `vm.expectRevert()`. Trust is also overloaded:
the allowlist exists for sender attribution (`src/interfaces/ITrustedRouters.sol:11`) and is reused as the
launch-block exemption. Fix depends on intent (Q1): either resolve the swapper with `_getSender` and compare it
with the creator, or delete the guard and the comment.

**F-08 (LOW). The `try` around `qualify` does not make the level calculator fail-safe against malformed returns.**
Confidence: high on language semantics, low on likelihood.

`src/DicesHook.sol:436-448` catches a revert inside `qualify`. It does not catch a failure to decode the return
value (fewer than 32 bytes, or a value above 255), which reverts in the hook and therefore reverts the swap.
`_setLiveCalculator` checks code length only (`:833`). An owner who installs a contract with a different
`qualify` signature halts trading in every pool until it is replaced, contrary to `AGENT.md:218-219` ("never blocks
a swap"). A related edge: an out-of-gas inside `qualify` is swallowed and the swap continues with the retained
1/64 of gas, silently dropping an observation; with the measured costs in `AGENT.md:223-229` the retained gas is
too small to finish a swap, so this was judged not practical. Fix: use a low-level `staticcall`-style call with a
length check, or probe the calculator in the setter.

**F-09 (LOW). `buyAndBurnRecipient` is not validated in the constructor.** Confidence: high.

```solidity
buyAndBurnRecipient = _buyAndBurnRecipient;                                      // src/DicesHook.sol:218
if (_buyAndBurnRecipient == address(0)) { revert ZeroAddress(); }                // src/DicesHook.sol:771 (setter only)
```

A zero value makes every USDC fee credit revert (same path as F-05) for every pool until the owner sets it. The
deployment script guards it (`script/deployment/V001.s.sol:324`); the contract does not. Slither and `forge lint`
both report the missing check.

**F-10 (LOW). The `DicesCoin` implementation can be initialised by anyone.** Confidence: high.

```solidity
function initialize(string calldata name_, string calldata symbol_, uint supply, address to) external {
    if (_initialized) { revert AlreadyInitialized(); }                           // src/DicesCoin.sol:123-127
```

The constructor (`:103-113`) does not set `_initialized`. Clones are unaffected (separate storage), and the
implementation cannot be destroyed. The effect is that the address published as "DicesCoin (impl)" in the address
book can be turned into a live token with any name, symbol and supply by a third party. Fix: set
`_initialized = true` in the constructor. `test/DicesCoin.t.sol:40-47` initialises an implementation directly, so
that test would need a clone.

**F-11 (LOW). Production code imports a v4-core test utility, and two different `CurrencySettler` libraries are in use.**
Confidence: high.

```solidity
import {CurrencySettler} from '@uniswap/v4-core/test/utils/CurrencySettler.sol'; // src/core/InternalSwapPool.sol:9
import {CurrencySettler} from './libraries/CurrencySettler.sol';                 // src/DicesHook.sol:34
```

The upstream test helper transfers with `IERC20Minimal(...).transfer(...)` and ignores the return value
(`lib/v4-hooks-public/lib/v4-core/test/utils/CurrencySettler.sol:31`). The only token the ISP settles is a
`DicesCoin`, which reverts on failure, so there is no exploit today. The risk is maintenance: test utilities carry
no stability or audit guarantee, the two libraries have different signatures under one name, and the local copy's
`payer != address(this)` branch (`src/libraries/CurrencySettler.sol:40-41`) is dead in production (its only caller
passes `address(this)`, `src/DicesHook.sol:614`) and is what Slither's `arbitrary-send-erc20` flags.

**F-12 (LOW). Unreachable code, unused state and discarded work.** Confidence: high.

| Item | Reference | Note |
| --- | --- | --- |
| `_beforeInitialize` after its first check | `src/DicesHook.sol:260-279` | The PoolManager skips the callback when the hook is the caller (`lib/v4-hooks-public/lib/v4-core/src/libraries/Hooks.sol:171-182`), so `_sender == address(this)` never arrives. Covered only by impersonating the manager (`test/DicesHook.t.sol:234-257`) |
| `lastSwapBlock` | `src/DicesHook.sol:185`, `:339` | Written every swap, read by nothing in `src/`. The comment refers to a "BuyAndBurn" contract that is not in the repository |
| `_getSender` results | `src/DicesHook.sol:350`, `:373` | Passed to ISP parameters that are unnamed and ignored (`src/core/InternalSwapPool.sol:146`, `:226`) |
| Native-currency paths in the ISP | `src/core/InternalSwapPool.sol:291-292`, `:363-365` | The paired currency is always USDC (`src/DicesHook.sol:201`, `:564`). `receive()` accepts ETH from anyone and nothing can send it out |
| `IFlaunch` | `src/interfaces/IFlaunch.sol:9-16` | Imported nowhere |
| `emitLiquidityDeltaUpdate`, `emitDonationUpdate`, `PoolSwap` | `src/libraries/UniswapEvents.sol:43`, `:104`, `:115` | Test-only or never emitted |
| `setCoinImplementation` error | `src/DicesHook.sol:807-809` | Reverts `ZeroAddress()` for a non-zero address without code |

The 100% coverage figure includes this code, reached through doubles and impersonation. Coverage therefore
overstates how much of the tested behaviour can occur in production.

**F-13 (LOW). `MINIMUM_INTERNAL_SWAP_POOL_SIZE` is effectively zero.** Confidence: high on effect, medium that it
is a mistake.

```solidity
uint constant MINIMUM_INTERNAL_SWAP_POOL_SIZE = 1e6;                             // src/core/InternalSwapPool.sol:90
if (params.zeroForOne != launchedTokenIsCurrency0 && internalSwapPool[launchedToken] >= MINIMUM_INTERNAL_SWAP_POOL_SIZE) { // :155
```

The inventory is in 18-decimal coin units, so the threshold is 1e-12 of a coin. The comment says the check makes
sure "there are fees in the internal swap pool that are worth interacting with" (`:152-153`); the value looks
like one unit of a 6-decimal currency. Any queued fee passes it, so every buy pays for a JIT round trip.

**F-15 (LOW, economic feasibility not determined). JIT inventory is offered at spot with no reference price.**
The JIT range is derived from `slot0` alone (`src/core/InternalSwapPool.sol:168-186`) and holds the entire
inventory. A trader who first sells to depress the price and then buys acquires the inventory at the depressed
price. The trader pays the fee on both legs, and inventory is normally small because each buy consumes it, so
this is likely unprofitable; it becomes relevant if inventory accumulates (for example through exact-output
sells, whose fee is in the coin). Noted for the threat model; no proof of profitability was attempted.

**F-16 (INFORMATIONAL). Every coin grants Permit2 an infinite allowance.** Solady's
`_givePermit2InfiniteAllowance()` returns `true` by default
(`lib/v4-hooks-public/lib/solady/src/tokens/ERC20.sol:667-669`) and `DicesCoin` does not override it. The
interface acknowledges the resulting error (`src/interfaces/IDicesCoin.sol:57-60`). Holders can be moved by any
valid Permit2 signature without a prior approval transaction. This is a deliberate upstream default; it should be
stated in user-facing documentation. `slither/check-erc20-DicesCoin.txt` reports all ERC-20 signature checks as
passing and notes the standard approve race.

**F-17 (LOW). No recovery path for stray assets.** The hook keeps launch rounding dust forever
(`src/DicesHook.sol:613`); coins sent directly to the ISP are not counted as inventory and cannot leave; ETH sent
to the ISP's `receive()` cannot leave; donations to a pool accrue to the hook's positions, which it cannot
collect. None of these loses user funds in normal operation.

**F-19 (LOW). Integration constraints are recorded only in comments.** The PoolManager-balance assumption and the
router `sync` ordering rule in 1.1. A router that syncs and transfers its input before calling `swap` fails with
`CurrencyNotSettled` on any buy that spends JIT inventory. Which third-party routers behave that way was not
determined.

Slither triage summary (95 raw results in `slither/slither-detectors.txt`, per the coordinating reviewer;
`printer-human-summary.txt` counts 12 high and 70 medium issues across all 73 analysed contracts, dependencies
included). In-scope instances only:

| Detector | In-scope instances | Disposition |
| --- | --- | --- |
| `arbitrary-send-erc20` | `CurrencySettler.settle` | Dead branch in production (F-11) |
| `weak-prng` | `LiveCalculator._average` (2) | False positive: modulo for a ring index and a rounding test |
| `reentrancy-eth` / `-benign` / `-events` | `_afterSwap`, `_syncLevel`, `createCoin`, `unlockCallback`, ISP | Callees are protocol contracts and USDC; see above |
| `divide-before-multiply` | `_launchTick`, ISP tick alignment (3) | Intentional tick rounding |
| `incorrect-equality`, `timestamp` | `DicesCoin`, `LiveCalculator` | Benign block/time comparisons |
| `unused-return` | 13 | Reviewed; ignored values are slot0 fields, fee deltas (zero LP fee) and `settle`/`unlock` returns |
| `missing-zero-check` | 7 | One real (F-09); `_owner` is checked by `Ownable`; the rest are constructor wiring checked by the script |
| `dead-code` | `InternalSwapPool._creditFee` | False positive caused by the IR failure on its only caller |
| `unimplemented-functions` | `DicesHook`, `LiveCalculator` | False positive: public mapping getters |
| `immutable-states` | `feeEscrow`, `internalSwapPool` | Valid optimisation (2.1) |

### 3.5 Dependencies (area 9)

| Dependency | Pin | Used for | Assessment |
| --- | --- | --- | --- |
| `lib/v4-hooks-public` | commit `30d3882`, **no tag**, `heads/main` (`foundry.lock`, `.gitmodules:4-6`) | `BaseHook` (`src/DicesHook.sol:16`) and, transitively, everything below | A monorepo of Uniswap hook deployments pulled in for one small abstract base contract and for its nested submodules. It brings 17 nested submodules (slipstream, pancake, fluid, uniswapx, protocol-fees with Optimism, and others) that the project does not use |
| v4-core | nested, `d153b048`, 19 commits past tag `v4.0.0` | Types, `Hooks`, `StateLibrary`, `TickMath`, `Pool`, `SqrtPriceMath`, `FullMath`, PoolManager (tests) | Untagged commit. Whether its `StateLibrary` slot layout matches the PoolManager deployed on Base was not determined; no fork test runs in CI |
| v4-periphery | nested, `07336f21`, untagged | `LiquidityAmounts`, `IMsgSender`, `ImmutableState` | Untagged commit |
| OpenZeppelin Contracts | nested, `package.json` version 5.6.1 | `Ownable`, `Pausable`, `ReentrancyGuard`, `SafeERC20`, `SafeCast`, `Math` | Appropriate. `ReentrancyGuard` here uses a storage slot, not transient storage |
| Solady | nested, v0.1.26 | `ERC20`, `LibClone`, `SafeTransferLib` | Appropriate; note the Permit2 default (F-16) |
| solmate | nested inside v4-core | `CREATE3` in the deploy script only (`script/deployment/V001.s.sol:9`) | Acceptable for a script |
| createx | tag v1.0.0 | Test artifact for the factory | Fine |
| forge-std | tag v1.17.0 | Tests and scripts | Fine |

Observations:

- **Dependency manager.** Git submodules with `foundry.lock`. Reproducible, but the top-level pin is a moving
  branch head rather than a release, and every nested version is chosen by a third-party monorepo, not by this
  project. A bump of `v4-hooks-public` can silently change OpenZeppelin, Solady, v4-core and v4-periphery at once.
- **Remappings.** `remappings.txt` has 71 entries, most unused, including paths into `node_modules`
  (`remappings.txt:1`, `:35`). Two aliases reach the same repository at different roots (`@uniswap/v4-core/` at
  `:13` and `v4-core/` at `:67`); the first is what lets production code import from `test/` (F-11).
- **Copied or adapted code.** `src/libraries/CurrencySettler.sol` is an adapted copy of the v4-core test helper.
  `InternalSwapPool`, `FeeEscrow`, `TrustedRouters`, `UniswapEvents` and the leftover `IFlaunch` interface
  (`src/interfaces/IFlaunch.sol`) indicate code adapted from another launchpad. Its origin, licence and audit
  history are not evidenced in the repository (Q7).
- **External runtime dependencies.** The Uniswap v4 PoolManager (governance can enable a protocol fee on any
  pool), Circle USDC (pausable, blacklisting, upgradeable), the Universal Router, CreateX. These are trust
  assumptions to list in the design reference.
- **CI supply chain.** Actions are pinned by tag, not by commit hash (`.github/workflows/test.yml:17`, `:23`), and
  the Foundry version is whatever `foundry-toolchain@v1` installs. Token permissions are minimal (`:3`, `:14-15`)
  and credentials are not persisted (`:19`), which is good.

### 3.6 Testing and verification (area 10)

Baseline supplied: 127 tests in 14 suites pass; 100% line, statement, branch and function coverage of the nine
executable files in `src/` (`coverage/summary.txt`); `coverage/gaps.json` lists gaps only in the two scripts (37
items each), which the gate does not cover. By grep there are 86 `test_`, 40 `testFuzz_` and 5 `invariant_`
declarations (131); the difference from 127 was not determined.

Strengths:

- A real PoolManager is deployed from its 0.8.26 artifact for hook, trading, level and launch-curve suites
  (`test/DicesHook.t.sol:60`), in both currency orderings.
- Level behaviour is tested end to end with real swaps, real transfers to holders and `vm.warp`
  (`test/DicesHookLive.t.sol`), including the one-second-short boundary (`:43-45`) and the same-block holder
  rule (`:206-227`).
- The coverage gate fails on a missing file as well as on a missed line (`test/check_coverage.py:45`, `:65`).
- The deployment script has its own 19-test suite (`test/scripts/V001.t.sol`).
- Revert assertions are specific: 63 of 66 `vm.expectRevert` calls name a selector or message.

**F-18 (MEDIUM). Gaps.**

1. **Static analysis blind spots.** Slither produced no IR for `DicesHook._swapFee`,
   `DicesHook._addInitialTokenLiquidity` and `InternalSwapPool.closeInternalSwapPool`
   (`slither/slither-detectors.txt`, first lines). These compute the fee, size the locked liquidity and settle
   JIT proceeds. Slither is not in CI at all, and `forge lint` warnings (23 in the baseline) do not fail the build.
2. **The invariant suite is narrow.** One handler, one actor, one pool, coin-as-currency0 only
   (`test/DicesHookInvariant.t.sol:67`), three actions (exact-input buy, exact-input sell, claim; `:36-51`), no
   `vm.warp` or `vm.roll`, 64 runs of depth 32 (`foundry.toml:67-70`). It never exercises exact-output trades,
   level changes, the fee-rate switch at Live, holder-count changes, a second pool sharing the ISP's single
   state slot, bankroll sales, or the coin-as-currency1 ordering. `invariant_onlyTheTraderCanBeAQualifyingHolder`
   (`:97-103`) is true by construction with one actor.
3. **Most "fuzz" tests are two-case parametrisations.** 30 of 40 `testFuzz_` functions take only `bool`
   arguments. Swap amounts are fixed constants in every trading test (`test/DicesHookTrading.t.sol:97`). No test
   fuzzes amount, price limit or sequence against the real PoolManager outside the invariant handler.
4. **No fork tests in CI.** The Universal Router, Permit2, real USDC and the deployed PoolManager are exercised
   only when a developer passes `--fork-url` by hand (`README.md:147`). The `sync` ordering constraint and the
   PoolManager-balance assumption are properties of those real contracts.
5. **Properties that should exist and do not:**
   - Level feasibility: every floor is attainable with the fixed supply (would have caught F-01).
   - Fee conservation across both paths: USDC credited plus coin inventory valued at execution equals
     `rate x unspecified` for every swap, for any calculator the owner can install (F-03, F-06).
   - Oracle model check: after any sequence of swaps and warps, `averageTick` equals a reference time-weighted
     mean computed in the test over the same window (the current tests check hand-picked sequences).
   - Holder count equals a recount over all touched addresses after arbitrary multi-actor trading through the
     pool, not only direct transfers (`test/DicesCoin.t.sol:205-241` covers transfers and burns).
   - `poolLevel` is monotonic and `<= 10` (F-03).
   - No pool can be made untradeable by its creation parameters (would have caught F-05).
6. **Negative tests missing:** zero creator; zero buy-and-burn recipient at construction; calculator returning a
   split that does not sum; calculator returning malformed data; level above 10; implementation initialised by a
   third party.
7. **Formal methods and other tools.** No Echidna, Medusa, Halmos or Semgrep configuration exists (baseline). The
   holder-count transition (`src/DicesCoin.sol:195-224`) and the checkpoint index arithmetic
   (`src/calculators/LiveCalculator.sol:283-287`, `:320-322`) are small, pure and well suited to symbolic
   checking. Mutation testing would measure whether the 100% coverage actually constrains behaviour.
8. **Weak assertions.** Three bare `vm.expectRevert()` calls: `test/DicesHookTrading.t.sol:148` (the only test of
   the launch-block guard), `test/DicesHook.t.sol:396`, `:398`.

### 3.7 Platform-specific guidance: Solidity (area 11)

- **Compiler version.** `pragma solidity ^0.8.38` in every source file (for example `src/DicesHook.sol:2`), with
  `foundry.toml:19` restricting `src/` and `script/` to exactly 0.8.38. Overflow protection is therefore native.
  The guidelines recommend deploying with a release that has had time in production and using the newest release
  only to check for warnings. How long 0.8.38 has been available and whether any bug affecting it has been
  published were not determined (no network access); the choice is recorded at commit `32487ad` without a
  rationale (Q11). The floating `^` in the sources is neutralised by the Foundry restriction but would not be
  for a consumer compiling the sources elsewhere.
- **EVM target.** `osaka` (`foundry.toml:6`). `README.md:54` states that Base Mainnet and Base Sepolia support it;
  that claim was not verified here.
- **Optimiser.** Legacy pipeline, 77,777 runs (`foundry.toml:7-10`). Coverage runs unoptimised
  (`README.md:81`), so the measured code is not the deployed bytecode; the ordinary test run uses the deployment
  settings.
- **Contract size.** `DicesHook` is 23,077 bytes, 1,499 under the EIP-170 limit (baseline). The external library
  exists to stay under it. Any hardening from this report that adds code to the hook must be measured.
- **Compiler and linter warnings.** `forge lint` reports 23 warnings in the baseline (8 `missing-zero-check`,
  9 `reentrancy-events`, 3 `unused-return`, 2 `arbitrary-send-eth`, 1 `unsafe-typecast`). Many sites already
  carry `forge-lint: disable-next-line` annotations with reasons, which is good practice; the remainder are not
  gated in CI.
- **Inline assembly.** None in `src/` (`slither/printer-human-summary.txt`: "Number of assembly lines: 0"; Slither's
  "Assembly" feature flag on `DicesCoin` comes from inherited Solady code). The deploy script has two
  memory-safe blocks that reset the free-memory pointer (`script/deployment/V001.s.sol:421-431`).
- **Low-level calls.** One `staticcall` with length-checked decoding (`src/core/TrustedRouters.sol:44-50`).
- **Mixed compiler versions.** The upstream PoolManager is compiled separately at 0.8.26/Cancun with its own
  profile (`foundry.toml:16`, `:21`) and used through its interface; in production the already-deployed manager
  is used, so this affects tests only.

---

## 4. Prioritised recommendations

### CRITICAL (address immediately)

None. No direct loss-of-funds path, proxy defect or broken upgrade path was identified.

### HIGH (address before deployment)

| # | Recommendation | Finding | Effort |
| --- | --- | --- | --- |
| H1 | Resolve the level table with the client: levels 9 and 10 are unreachable with a 300,000-coin threshold and a 1e9 supply. Add a feasibility test for every level | F-01 | Decision plus under a day |
| H2 | Rewrite `README.md` and `AGENT.md` section 3 from the code: fee-currency table, 40/30/30 split, escrow, ISP, events actually emitted, lock guarantee including the ISP exception, integration constraints. Obtain client sign-off that the brief's 0.50% buy surcharge and reserve are dropped or deferred | F-02 | 1 to 2 days |
| H3 | Bound what the owner can do on chain: cap the fee rate, require the split to sum to the fee, require `level <= LEVELS`; adopt `Ownable2Step`; disable or document `renounceOwnership`; make `V001` refuse a mainnet run without a contract owner; deploy the Safe and timelock the brief requires before mainnet | F-03 | 2 to 3 days, measure hook size |
| H4 | Decide and enforce the bankroll policy (open question 10) | F-04 | Decision plus implementation |
| H5 | Reject `creator == address(0)` in `createCoin` and a zero `buyAndBurnRecipient` in the constructor | F-05, F-09 | Hours |
| H6 | Use one fee calculator: have the ISP read the hook's, or distribute in one place | F-06 | Under a day |
| H7 | Close the verification gaps: get Slither to analyse the three skipped functions (rewrite the ternaries) and run it in CI; widen the invariant handler (multiple actors, both orderings, two pools, exact-output trades, time and block advancement, transfers, bankroll sales); fuzz amounts; add a fork test against the deployed PoolManager, USDC and Universal Router | F-18 | 1 to 2 weeks |

### MEDIUM (address for production quality)

| # | Recommendation | Finding |
| --- | --- | --- |
| M1 | Decide the launch-block policy and make code, comment, interface and test agree; assert the specific error in the test | F-07 |
| M2 | Emit a hook-level creation event with coin, pool id, creator, name, symbol; add pool id to fee credits or emit a per-swap distribution event; emit JIT conversions; delete events that are never emitted; confirm `HookSwap`/`HookFee` semantics with the indexer | F-14 |
| M3 | Depend on v4-core, v4-periphery, OpenZeppelin and Solady directly at tagged releases and vendor `BaseHook`; prune `remappings.txt`; remove the `test/` import from production code and keep one `CurrencySettler`; pin CI actions by commit and the Foundry version explicitly | F-11, 3.5 |
| M4 | Validate replacements on chain: `LiveCalculator.dicesHook() == address(this)`, coin implementation wiring, and a well-formed `qualify` return (or a low-level call with a length check) | F-08, 2.2 |
| M5 | Lock the `DicesCoin` implementation's initialiser | F-10 |
| M6 | Remove dead code and unused state: unreachable `_beforeInitialize` body, `lastSwapBlock`, discarded `_getSender` calls and unused ISP parameters, native-currency paths and `receive()` in the ISP, `IFlaunch`, unused emitters | F-12 |
| M7 | Write and test scripts and a runbook for replacing each calculator and the coin implementation, a read-only post-deployment verification entry point, and an incident-response plan that accepts that swaps cannot be paused | 2.2 |

### LOW (nice to have)

| # | Recommendation | Finding |
| --- | --- | --- |
| L1 | Gas: transient storage for the JIT state, immutables for `internalSwapPool`/`feeEscrow`, one transfer per fee event, a meaningful minimum inventory; commit a gas snapshot and check it in CI | 2.1, F-13 |
| L2 | Fix the NatSpec inaccuracies listed in 1.3; make `DicesCoin` inherit `IDicesCoin` | 1.3, 3.2 |
| L3 | Document the Permit2 default allowance, the USDC and PoolManager trust assumptions, and the router `sync` constraint for integrators | F-16, F-19 |
| L4 | Record the rationale for Solidity 0.8.38 and check it against the published bug list; gate `forge lint` in CI | 3.7 |
| L5 | Refresh or remove the stale Base Sepolia address book | 1.3 |
| L6 | Analyse the economics of JIT placement at spot and decide whether a reference price or a per-swap cap is needed; add a sweep for stray assets if desired | F-15, F-17 |
| L7 | Add symbolic or property tests for the holder-count transition and checkpoint indexing; run mutation testing against the 100% coverage suite | F-18 |

---

## 5. Questions for the team

Each item is "not evidenced in the repository".

- **Q1.** What is the intended launch-block policy: creator only, any user of a trusted router, or no restriction?
  (`src/DicesHook.sol:328-336`)
- **Q2.** Has the client accepted the implemented fee model (single 1.25%/1.00% rate both ways, 40/30/30 to
  platform, creator and buy-and-burn, fees partly in the coin) in place of the brief's base fee plus 0.50% buy
  surcharge to a reserve? What is the buy-and-burn recipient in production?
- **Q3.** For levels 9 and 10, which input changes: the holder floors, the 300,000-coin threshold, or the rule?
- **Q4.** Is the ISP's fixed fee calculator intentional, and if so how will a change of split be rolled out?
- **Q5.** Who owns the hook on mainnet at launch, and which owner operations are the "critical financial
  operations" that the brief says must be capped?
- **Q6.** Bankroll: which address, and is it restricted (open question 10 in `AGENT.md`)?
- **Q7.** What is the origin of `InternalSwapPool`, `FeeEscrow`, `TrustedRouters`, `UniswapEvents` and `IFlaunch`?
  Has the upstream been audited, and under what licence is it used?
- **Q8.** Why is `v4-hooks-public` at `main` the dependency root, and which v4-core release is the Base
  PoolManager built from?
- **Q9.** What is the response plan for a defect in the swap path, given that swaps cannot be paused and
  liquidity cannot be migrated?
- **Q10.** Which indexers consume `HookSwap`, `HookFee` and `PoolStateUpdated`, and do they also read the
  PoolManager's `Swap`? Who is expected to call `syncLevel`, and what monitoring exists for owner actions?
- **Q11.** Why Solidity 0.8.38, and was its bug list reviewed?
- **Q12.** Has Base Sepolia been redeployed since the bankroll and level changes?
- **Q13.** Is `lastSwapBlock` reserved for a later buy-and-burn contract, and is sender attribution
  (`_getSender`) planned for use?
- **Q14.** Which routers will the front end and partners use, and do any of them sync and transfer input before
  calling `swap`?
- **Q15.** Is a zero creator meant to be allowed (for example, to donate the creator share)? If so the credit
  must be redirected rather than reverted.

---

## 6. Not determined

- The release date and published bug status of Solidity 0.8.38, and whether Base supports the Osaka target (no
  network access; `README.md:54` asserts support).
- Why Slither 0.11.5 fails to generate IR for three functions.
- Gas per swap for the full path (no tool was run); `AGENT.md:223-229` covers the level calculator only.
- Why 131 test declarations are found by grep against 127 executed in the baseline.
- Whether the v4-core commit in `lib/` matches the storage layout of the PoolManager deployed on Base.
- Whether level 8 is practically reachable; whether the JIT spot-placement observation (F-15) is profitable
  under any realistic inventory.
- Which third-party routers violate the `sync` ordering constraint.
- Provenance of the adapted contracts (Q7).

---

*Analysis follows Trail of Bits' "Building Secure Contracts" development guidelines as packaged in the
`guidelines-advisor` skill. It is a guidelines review, not an audit: absence of a finding is not evidence of
absence of a defect.*

---

## Reconciliation with the consolidated findings

Added by the lead reviewer after this report was written. The report above was produced from the code alone,
without sight of the other reviews. Its findings were then checked and merged into [`findings.md`](findings.md)
under `DICES-nn` identifiers; severities there take 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 |
| --- | --- | --- |
| F-01 | DICES-02 | Confirmed; run (`testPoC9`) |
| F-02 | DICES-09, DICES-17 | Confirmed |
| F-03 | DICES-03, DICES-04 | Confirmed; run (`testPoC4`, `testPoC10`) |
| F-04 | DICES-21 | Acknowledged design limit |
| F-05, F-09 | DICES-01 | Confirmed; run (`testPoC1`, `testPoC12`) |
| F-06 | DICES-08 | Confirmed; run (`testPoC5`) |
| F-07 | DICES-06 | Confirmed; run (`testPoC2`) |
| F-08 | DICES-07 | Confirmed; run (`testPoC3`) |
| F-10 | DICES-12 | Confirmed; run (`testPoC7`) |
| F-11 | DICES-11 | Confirmed |
| F-12, F-17 | DICES-13, DICES-16 | Confirmed |
| F-13 | DICES-10 | Confirmed |
| F-14 | DICES-18 | Confirmed |
| F-15 | DICES-05 | **Refined by testing, and rated Medium.** This report could not say whether the manoeuvre pays after fees. Measured by two independent sets of tests: a holder ends with more coins but no monetary gain, so the doubt was sound for that version. A caller with no coins at all, using v4 flash accounting, is paid 470 USDC after a 30,000 USDC buy has queued fees (`poc-tests-verify05.md`) |
| F-16, F-19 | DICES-15, DICES-19 | Confirmed; `testPoC11` for the PoolManager-balance assumption |
| F-18 | DICES-20 | Confirmed |

The priority labels in section 4 above (HIGH, MEDIUM, LOW) are this skill's "how soon to act" scale, not the
severity scale used in `findings.md`.
