# Code Maturity Assessment: Dices launchpad (EVM)

| | |
| --- | --- |
| Skill | Trail of Bits `building-secure-contracts` 1.1.1 / `code-maturity-assessor` (Code Maturity Evaluation framework v0.1.0) |
| Commit | `bcd45b2` on `main` ("Merge launch distribution with TWAP game levels") |
| Date | 2026-11-25 |
| Platform | Solidity 0.8.38, EVM `osaka`, Foundry; Uniswap v4 hook (upstream `PoolManager` compiled separately at 0.8.26 / `cancun`) |
| Scope | `src/` (`DicesHook.sol`, `DicesCoin.sol`, `core/InternalSwapPool.sol`, `core/FeeEscrow.sol`, `core/TrustedRouters.sol`, `calculators/LiveCalculator.sol`, `calculators/FeeCalculator.sol`, `libraries/CurrencySettler.sol`, `libraries/UniswapEvents.sol`, `interfaces/*`), `script/deployment/V001.s.sol`, `test/` (testing category), `foundry.toml`, `.github/workflows/test.yml`, `AGENT.md`, `README.md`. `lib/` only where `src/` depends on its behaviour. |
| Method | Manual read of every in-scope contract and library, most interfaces, the deployment script and the main test suites; pre-generated Slither 0.11.5 output and the last local coverage report. Nothing was compiled, tested or executed for this assessment (see section 7 for one accidental exception). |

Rating scale: Missing (0), Weak (1), Moderate (2), Satisfactory (3), Strong (4).

Rating logic, applied as the skill states it: any WEAK criterion met gives Weak; no WEAK criterion and some MODERATE
criterion unmet gives Moderate; all MODERATE criteria and some SATISFACTORY criteria met gives Satisfactory; all
SATISFACTORY criteria plus exceptional practice gives Strong.

Off-chain practice (monitoring, incident response, key management, team process) cannot be seen in a repository. No
credit is given for anything that is not evidenced. Each such criterion is marked "not evidenced in the repository" and
the matching question is listed in section 5, so the rating can be revised when the team answers.

---

## 1. Executive summary

**Project.** Dices is a memecoin launchpad built as a single Uniswap v4 hook. `DicesHook.createCoin` clones a
fixed-supply ERC20, pays 10% of it to a bankroll address, initialises a coin/USDC pool and locks the other 90% in two
hook-owned positions. The hook charges a trading fee in the unspecified swap currency, queues coin-denominated fees in
`InternalSwapPool` for conversion through just-in-time liquidity, credits USDC fees to a pull-payment `FeeEscrow`, and
asks a replaceable `LiveCalculator` (24-hour tick TWAP plus a holder count kept by the coin) which "game level" each
pool has reached. About 1,024 source lines in 17 contracts, libraries and interfaces (Slither `human-summary`).

**Overall maturity: 1.7 / 4.0 (between Weak and Moderate).**

The average understates the engineering quality of the Solidity and overstates the readiness of everything around it.
The two code-centric categories that can be judged from the repository alone (low-level manipulation, testing) rate
Satisfactory. The five Weak ratings come from three root causes, not five independent problems:

1. The prose documentation was not updated after the internal-swap-pool rework, so the written fee and ledger model
   contradicts the code (drives Documentation and, through the "spec doesn't match code" criterion, Arithmetic).
2. Governance is deferred: one single-step `Ownable` owner, by default the deployer EOA, can replace the fee and level
   logic at any time with no cap and no delay, and one unrestricted bankroll address holds 10% of every coin (drives
   Access Controls and Decentralization).
3. The only launch-time ordering protection, the zero-block guard, does not constrain anyone in the shipped
   configuration, and launch MEV is not documented (drives Transaction Ordering).

**Top 3 strengths**

1. **Test discipline.** CI enforces 100% line, statement, branch and function coverage on every executable file under
   `src/` (`.github/workflows/test.yml:37-44`, `test/check_coverage.py:25-73`, `coverage/summary.txt`). Tests run against
   the real v4 `PoolManager` artifact in both currency orderings and all four swap modes
   (`test/DicesHookTrading.t.sol:90-117`), and the deployment script is tested end to end (`test/scripts/V001.t.sol`).
2. **Arithmetic hygiene and a carefully reasoned oracle.** There is no `unchecked` block and no inline assembly in
   `src/`. Every narrowing cast carries a written justification (`src/calculators/LiveCalculator.sol:269-271,324-326,335-337,398-400`;
   `src/DicesCoin.sol:217-219`), rounding direction is explicit where it matters (`LiveCalculator.sol:329-333`,
   `InternalSwapPool.sol:320`), and the TWAP design, its window and its manipulation cost are explained and tested.
3. **Small custody trust surface.** Launch liquidity has no removal path (`src/DicesHook.sol:302-307`,
   `test/DicesHook.t.sol:386-402`); `FeeEscrow` has no administrator and uses checks-effects-interactions behind a
   reentrancy guard (`src/core/FeeEscrow.sol:16,34,80,89,110-117`); launched coins have no owner, mint or blacklist
   (`src/DicesCoin.sol`); contract-to-contract authority is fixed by immutables (`InternalSwapPool.sol:54,352-358`,
   `LiveCalculator.sol:109,406-412`); a failing level calculator cannot block a swap (`DicesHook.sol:436-448`).

**Top 3 gaps**

1. **One key, uncapped module replacement, no delay.** `setFeeCalculator` and `setLiveCalculator` take effect
   immediately (`DicesHook.sol:752-763`), the hook applies whatever rate the calculator returns with no upper bound
   (`DicesHook.sol:462`), ownership is single-step with `renounceOwnership` available, and `V001` keeps the deployer as
   owner whenever `PROTOCOL_OWNER` is unset, on mainnet too (`script/deployment/V001.s.sol:61,131,306`).
2. **Documentation contradicts the code.** `README.md:10-13` and several `AGENT.md` sections describe USDC-only fees,
   a 0.50% reserve surcharge, a race pool, ERC-6909 fee claims, `claimFees()` and a `reserveController`. None of these
   exist in `src/`. The brief's "every buy funds the coin's casino reserve" output is therefore not implemented at this
   commit, and only `AGENT.md:102-103` hints at that.
3. **Launch-path gaps.** The zero-block guard exempts any swap through a trusted router and the deployment trusts the
   public Universal Router (`DicesHook.sol:334`, `V001.s.sol:238`); `createCoin` accepts `creator == address(0)`, which
   makes later USDC-fee swaps on that pool revert in `FeeEscrow.deposit` (`DicesHook.sol:574,480`,
   `FeeEscrow.sol:36-38`); no monitoring or incident-response material is in the repository.

**Priority recommendations**

1. Before any mainnet deployment: put the hook behind a Safe and timelock with two-step ownership, make `V001` refuse a
   mainnet run with an unset owner, and cap the fee rate and level in the hook.
2. Validate `params.creator` in `createCoin`.
3. Rewrite the stale documentation and obtain explicit client sign-off on the fee model that the code implements.
4. Decide what the launch block is meant to allow, make the guard match, and document launch MEV.

---

## 2. Maturity scorecard

| # | Category | Rating | Score | Notes |
| --- | --- | --- | --- | --- |
| 1 | Arithmetic | WEAK | 1/4 | Checked arithmetic, justified casts, explicit rounding and fuzz tests; rated Weak on one criterion: the written fee specification does not match the code. Fee rate and level are unbounded inputs from replaceable modules. |
| 2 | Auditing | MODERATE | 2/4 | Every configuration change emits an event with old and new value; indexer events are documented and tested. No launch event carries the creator. Monitoring and incident response not evidenced. |
| 3 | Authentication / access controls | WEAK | 1/4 | All privileged functions are gated and tested, but every privilege sits on one single-step `Ownable` address that defaults to the deployer EOA, with no timelock, cap or role separation. |
| 4 | Complexity management | MODERATE | 2/4 | No function reaches cyclomatic complexity 11; inheritance is shallow. Vestigial code and small duplications remain from the rework; one input (`creator`) is unvalidated; no naming convention is documented. |
| 5 | Decentralization | WEAK | 1/4 | Liquidity lock, adminless escrow and ownerless coins are strong. The owner can change fee and level logic for existing pools at any time, in the path users need to exit; the bankroll is unrestricted. |
| 6 | Documentation | WEAK | 1/4 | NatSpec is extensive and mostly accurate. `README.md` and `AGENT.md` describe a fee and ledger system that no longer exists, beyond what `AGENT.md` itself flags as stale. No diagrams, glossary or user stories. |
| 7 | Transaction ordering risks | WEAK | 1/4 | The level oracle is a well-argued 24-hour tick TWAP with a same-block holder rule. The launch-block guard is ineffective as deployed, launch sniping and fee-conversion ordering are undocumented, and the oracle records unbacked prices below the launch range. |
| 8 | Low-level manipulation | SATISFACTORY | 3/4 | No assembly or `unchecked` in `src/`; one justified, length-checked `staticcall` tested against every response shape. Implicit `delegatecall` (linked event library, minimal clones) is handled in deployment but not explained in code. |
| 9 | Testing and verification | SATISFACTORY | 3/4 | 127 passing tests, 100% `src/` coverage gate in CI, real `PoolManager` integration, deployment tests. Invariant campaign is shallow, there is no mutation testing, and static analysis is not in CI. |

**Overall: 15 / 36 = 1.7 / 4.0**

---

## 3. Detailed analysis

### 3.1 Arithmetic: WEAK (1/4)

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | No overflow protection without justification | Not triggered | Solidity 0.8.38 checked arithmetic throughout; no `unchecked` in `src/` (search). `SafeCast` on every sign or width change in the hook and swap pool (`DicesHook.sol:461,472,493,718`; `InternalSwapPool.sol:250-251`). |
| WEAK | Unchecked arithmetic not documented | Not triggered | No unchecked arithmetic. The four narrowing casts are commented and lint-suppressed with the reason (`LiveCalculator.sol:269-271,324-326,335-337,398-400`; `DicesCoin.sol:217-219`). |
| WEAK | No arithmetic specification, or spec doesn't match code | **Triggered** | Levels and the launch curve are specified and match (`AGENT.md:178-221`, `LiveCalculator.sol:219-253`, `FeeCalculator.sol:47-63`). The trading-fee specification does not match: `README.md:10-13` and `AGENT.md:42-47,132-143,231-235` specify fees "always `rate x gross USDC moved`", a 0.50% reserve surcharge on buys, a race pool, a transient-storage rate cache and a 50% creator share. The code charges the unspecified currency, coin or USDC (`DicesHook.sol:458-463`), at a flat 1.25% / 1.00% (`FeeCalculator.sol:33,38`), split 40 / 30 / 30 (`FeeCalculator.sol:23,28,85-94`). |
| WEAK | No testing strategy for arithmetic | Not triggered | `test/Calculators.t.sol`, `test/CalculatorUpdates.t.sol`, `test/InternalSwapPool.t.sol`, `test/DicesCoin.t.sol`. |
| WEAK | Critical edge cases not tested | Not triggered | Zero, dust and `type(uint).max` fee splits (`Calculators.t.sol:63-72`); window one second short (`DicesHookLive.t.sol:43-45`); exact holder threshold (`DicesCoin.t.sol:77`); tick rounding for both signs (`CalculatorUpdates.t.sol:103-132`); tick-capacity clamp (`InternalSwapPool.t.sol:142-159`). Untested edges are listed under gaps. |
| MODERATE | Unchecked arithmetic minimal, justified, documented | Met | None present. |
| MODERATE | Overflow and underflow risks documented and tested | Met | `int56` cumulative bound argued at `LiveCalculator.sol:398`; `uint32` timestamp at `:269`; inventory subtraction cannot exceed the position cost (`InternalSwapPool.sol:248-254`, tested at `InternalSwapPool.t.sol:161-172`). |
| MODERATE | Explicit rounding for precision loss | Partly met | TWAP rounds down with explicit handling of negative values (`LiveCalculator.sol:329-333`); level ticks are "the lowest tick at which the supply is worth at least the target" (`:214-215`); position cost rounds up (`InternalSwapPool.sol:320`); the platform takes the split remainder (`FeeCalculator.sol:92-93`). The trading fee itself rounds down with no stated direction (`DicesHook.sol:462`), so swaps moving under 80 raw units pay no fee. |
| MODERATE | Automated testing (fuzzing or formal methods) | Met | Foundry fuzz tests, for example `Calculators.t.sol:56`, `InternalSwapPool.t.sol:161`, `DicesCoin.t.sol:205`, `CalculatorUpdates.t.sol:114`. Many tests named `testFuzz_` vary only a `bool`. |
| MODERATE | Stateless arithmetic functions | Met | `FeeCalculator` holds no state; `_cumulativeAt`, `_spansThreshold`, `_launchTick` are pure. |
| MODERATE | Bounded parameters with explained ranges | **Not met** | The swap fee rate comes from a replaceable calculator and is applied unbounded (`DicesHook.sol:462`). The level returned by `qualify` is stored without checking it is at most `LEVELS` (`DicesHook.sol:436-439`). `MINIMUM_INTERNAL_SWAP_POOL_SIZE = 1e6` is in raw units of an 18-decimal coin, 1e-12 of a coin, so it bounds nothing (`InternalSwapPool.sol:90,155`). |
| SATISFACTORY | Precision loss analysed against ground truth | Partly met | Level ticks and launch prices are checked against recomputed market caps (`Calculators.t.sol:74-82,103-114`); the sale raise is pinned at $35,013 (`DicesHookLaunchCurve.t.sol:31`). No analysis for fee rounding or the geometric-versus-arithmetic mean beyond `AGENT.md:192-196`. |
| SATISFACTORY | All trapping operations identified | Not met | No list. Examples that trap inside a swap: `require(..., 'Invalid JIT delta')` (`InternalSwapPool.sol:246`), `internalSwapPool[launchedToken] -= spent` (`:254`), `SafeCast` reverts, `Pool.tickSpacingToMaxLiquidityPerTick(...) - used` (`:346`). |
| SATISFACTORY | Arithmetic spec matches code one-to-one | Not met | See the triggered WEAK criterion. |
| SATISFACTORY | Automated testing covers all operations in CI | Partly met | CI runs every test with a 100% coverage gate; no arithmetic-focused invariant (for example fee conservation across random swaps of realistic size). |

**Rating.** One WEAK criterion is met, so the category is Weak. Without it the category would be Moderate (bounded
parameters unmet).

**Gaps**

- The written fee model and the implemented fee model are different systems. A reviewer working from the README would
  test for properties the code does not have.
- No cap on the fee rate or the level inside the hook.
- Edge cases without a test: a calculator returning a rate at or above 100%; a pool whose price has fallen below the
  launch range while the TWAP is running; `createCoin` with a zero creator.

**To reach Moderate**

- Replace the stale fee text with the formulas the code uses, including which currency is charged in each of the four
  swap modes and the rounding direction.
- Enforce `rate <= MAX_FEE` and `level <= LEVELS` in the hook; fix or remove the minimum inventory constant.

**To reach Satisfactory**

- One arithmetic specification listing every formula, its rounding direction, its trapping conditions and a
  ground-truth comparison (a reference TWAP model driven by the same fuzz inputs would cover the oracle).

---

### 3.2 Auditing: MODERATE (2/4)

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | No event strategy | Not triggered | Indexer events are centralised in `UniswapEvents` (`src/libraries/UniswapEvents.sol:26-58`) and mirrored for decoding in `IUniswapEvents`; configuration events live in `IDicesHook.sol:39-94`. |
| WEAK | Events missing for critical updates | Not triggered | Every owner setter emits old and new values: `DicesHook.sol:774,785,797,810,823,836`; `TrustedRouters.sol:27`; pause and ownership through OpenZeppelin. Level changes: `DicesHook.sol:443,446`. Escrow credits and payouts: `FeeEscrow.sol:72,119`. Launch: `DicesHook.sol:604,611`. |
| WEAK | No consistent event guidelines | Not triggered | Naming is consistent within each contract (`...Updated(previous, new)` for configuration). Minor drift: `Deposit` in the swap pool against `Deposited` in the escrow. |
| WEAK | Same events reused for different purposes | Not triggered | `PoolStateUpdated` is emitted at launch and after swaps with the same meaning. |
| MODERATE | Events for all critical functions | Partly met | No launch event carries the creator, which is the address that will receive 30% of the pool's fees; `PoolCreated` has only pool, coin and USDC (`UniswapEvents.sol:38`, `DicesHook.sol:604`). `AGENT.md:116` promises a `CoinCreated` event that does not exist. Inventory leaving the swap pool emits nothing from the pool (`InternalSwapPool.sol:254`), while inventory entering does (`:137`). `FeeEscrow.Deposited` does not identify the pool that generated the credit. |
| MODERATE | Off-chain monitoring logs events | Not evidenced in the repository | |
| MODERATE | Monitoring plan documented | Not evidenced in the repository | |
| MODERATE | Event documentation (purpose, usage, assumptions) | Met in code, stale in prose | NatSpec states purpose and caveats, for example "indexers must read one or the other, not both" (`UniswapEvents.sol:21-24`). `AGENT.md:93,166-176` still describes a `PoolSwap` event; the hook emits `HookSwap` and `HookFee` (`DicesHook.sol:506,519`). `PoolSwap`, `PoolLiquidityDelta` and `PoolDonation` are declared but never emitted by the hook. |
| MODERATE | Log review process documented | Not evidenced in the repository | |
| MODERATE | Incident response plan exists | Not evidenced in the repository | |
| SATISFACTORY | Alerts on unexpected behaviour; defined detection roles; plan regularly tested | Not evidenced in the repository | |

**Rating.** No WEAK criterion is met; several MODERATE criteria are unmet or not evidenced. Moderate.

**Gaps**

- The creator, the fee recipient of record for a pool, can only be discovered by calling `poolCreators(poolId)`.
- No evidence of who watches `FeeCalculatorUpdated`, `LiveCalculatorUpdated`, `CoinImplementationUpdated`,
  `TrustedRouterSet`, `OwnershipTransferred` or `Paused`, each of which changes the trust assumptions of every pool.
- The only on-chain emergency control is `pause()`, which stops `createCoin` and nothing else
  (`DicesHook.sol:533,843-852`; `test/DicesHookTrading.t.sol:154-162`). A response plan has to say what is done about a
  fault in the swap path.

**To reach Satisfactory**

- Add a launch event with coin, pool, creator, implementation and bankroll; add a conversion event to the swap pool.
- Write a monitoring plan (events watched, thresholds, owners) and an incident-response runbook, deploy alerting on the
  configuration events and on escrow solvency, and rehearse the runbook.

---

### 3.3 Authentication / access controls: WEAK (1/4)

**Actors found in code**

| Actor | Authority | Evidence |
| --- | --- | --- |
| Hook owner | `setFeeCalculator`, `setLiveCalculator`, `setBuyAndBurnRecipient`, `setCreateFee`, `setFeeRecipient`, `setCoinImplementation`, `pause`, `unpause`, `setTrustedRouter`, `transferOwnership`, `renounceOwnership` | `DicesHook.sol:752-812,843-852`; `TrustedRouters.sol:25`; OpenZeppelin `Ownable` |
| PoolManager | Hook callbacks and `unlockCallback` | `onlyPoolManager` in `BaseHook`; `DicesHook.sol:587` |
| DicesHook (as caller) | `InternalSwapPool.deposit/createInternalSwapPool/closeInternalSwapPool`; `LiveCalculator.qualify` | `InternalSwapPool.sol:127,146,226,352-358`; `LiveCalculator.sol:146,406-412` |
| InternalSwapPool | May add and remove its own liquidity on Dices pools | `DicesHook.sol:291,303` |
| Trusted router | Exempt from the launch-block guard; its `msgSender()` is resolved | `DicesHook.sol:334`; `TrustedRouters.sol:37-52` |
| Bankroll | Receives 10% of every coin; no on-chain restriction | `DicesHook.sol:558`; `DicesCoin.sol:60`; `AGENT.md:121-130` |
| Anyone | `createCoin`, `syncLevel`, `FeeEscrow.deposit/claim/claimBatch`, `DicesCoin.burn` | `DicesHook.sol:408,533`; `FeeEscrow.sol:34,80,89` |

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Access controls unclear or inconsistent | Not triggered | Three modifiers used consistently. One overloaded flag: `trustedRouters` is documented as "trusted for wallet attribution" (`ITrustedRouters.sol:11,16`) but also grants the launch-block exemption (`DicesHook.sol:334`). |
| WEAK | Single address controls system without safeguards | **Triggered** | One `Ownable` owner (`TrustedRouters.sol:13`, `DicesHook.sol:199`). Single-step transfer, `renounceOwnership` not disabled, no timelock, no bound on what a replacement calculator may return (`DicesHook.sol:462,436-439`). `V001` keeps the deployer as owner when `PROTOCOL_OWNER` is zero "on any chain" (`V001.s.sol:61,131,306`; tested at `test/scripts/V001.t.sol:259-267`). The Safe and timelock are deferred (`AGENT.md:75`). The only deployment on record has owner equal to deployer (`deployments/deployment-84532.md`). |
| WEAK | Missing access controls on privileged functions | Not triggered | Every setter is `onlyOwner` (Slither `entry-points`); negative tests for all eight hook setters (`test/DicesHook.t.sol:325-342`) and the router setter (`test/TrustedRouters.t.sol:35-37`). |
| WEAK | No role differentiation | **Triggered** | One human role. Pausing, fee policy, level policy, router trust and coin implementation are not separable. |
| WEAK | All privileges on one address | **Triggered** | As above. |
| MODERATE | All privileged functions have access control | Met | |
| MODERATE | Least privilege | Not met | The pauser can also replace fee logic. |
| MODERATE | Non-overlapping role privileges | Not met | Single role. |
| MODERATE | Clear actor and privilege documentation | Partly met | `README.md:23-27` and `AGENT.md:95-101` describe calculator replacement; there is no single list of actors and privileges, and the bankroll is described only in `AGENT.md:121-130`. |
| MODERATE | Tests cover all privileges | Met | Positive and negative tests for every owner function; `onlyHook` and `onlyPoolManager` paths (`test/InternalSwapPool.t.sol:82-87`, `test/Calculators.t.sol:347`, `test/DicesHook.t.sol:259-275`). |
| MODERATE | Roles can be revoked | Partly met | Routers can be untrusted; ownership can be transferred or renounced. The creator of a pool can never be changed (`DicesHook.sol:574`, no setter). |
| MODERATE | Two-step processes for EOA operations | Not met | `Ownable`, not `Ownable2Step`; `V001.s.sol:245` calls `transferOwnership` directly. |
| SATISFACTORY | Privileged actors not EOAs; key leakage doesn't compromise system; tested against known attack vectors | Not met / not evidenced | See section 5. |

**Rating.** Three WEAK criteria are met. Weak.

**What works well.** The owner is an explicit constructor argument, as CREATE3 requires (`DicesHook.sol:196-199`,
tested at `test/DicesHook.t.sol:372-384`). The swap pool's liquidity permission cannot touch the hook's positions
because the PoolManager keys positions to the caller (`DicesHook.sol:298-307`, `test/DicesHook.t.sol:386-402`).
`LiveCalculator` is bound to one hook by an immutable, so a detached calculator cannot be fed by anyone else.

**Key-compromise scenario (by code reading).** A holder of the owner key can set a fee calculator that returns any
rate, or that reverts. The first takes up to the whole unspecified amount of each swap, limited only by each trader's
own slippage bound; the second blocks every swap on every pool. Followed by `renounceOwnership`, either state is
permanent, and the liquidity is locked by design.

**To reach Moderate**

- `Ownable2Step`; owner is a Safe behind a `TimelockController`; `V001` reverts on mainnet when `PROTOCOL_OWNER` is
  unset or equals the deployer; override `renounceOwnership` to revert, or document why it is wanted.
- A separate guardian role limited to `pause`.
- Hard caps in the hook on what any calculator can return.
- One actors-and-privileges table in the documentation, including the bankroll and trusted routers.

---

### 3.4 Complexity management: MODERATE (2/4)

**Measurements.** Slither `function-summary`: no function in `src/` reaches cyclomatic complexity 11. Highest values:
`DicesHook.createCoin` 7, `FeeEscrow.deposit` 7, `InternalSwapPool.closeInternalSwapPool` 6,
`InternalSwapPool.createInternalSwapPool` 5, `DicesHook._beforeInitialize` 5, `LiveCalculator._observe` 4,
`LiveCalculator._levelAt` 4. Slither could not build IR for `DicesHook._swapFee`,
`DicesHook._addInitialTokenLiquidity` and `InternalSwapPool.closeInternalSwapPool`, so those three figures are less
reliable; by hand, `createInternalSwapPool` has about eight decision points and three levels of nesting
(`InternalSwapPool.sol:155-201`), still under 11. Inheritance: `DicesHook is BaseHook, IDicesHook, Pausable,
TrustedRouters(Ownable)` (`DicesHook.sol:49`), depth three. `DicesHook` runtime size is 23,077 bytes, 1,499 under the
EIP-170 limit (baseline measurement).

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Unnecessary complexity hinders review | Not triggered (borderline) | See "vestigial code" below. It costs reviewer time but the control flow stays readable. |
| WEAK | Functions overuse nested operations | Not triggered | Maximum nesting three. |
| WEAK | Functions have unclear scope | Not triggered | Callbacks delegate to named helpers (`DicesHook.sol:372-386`). |
| WEAK | Unnecessary code duplication | Not triggered (borderline) | Duplication exists but is small: see below. Judged minor in extent; this is a judgement call and is flagged so it can be revised. |
| WEAK | Complex inheritance tree | Not triggered | |
| MODERATE | Complex parts identified, minimised | Met | Contract-level NatSpec explains the oracle and the JIT conversion (`LiveCalculator.sol:15-40`, `InternalSwapPool.sol:216-222`). |
| MODERATE | High complexity (11 or more) justified | Met | None. |
| MODERATE | Critical functions well-scoped | Met | |
| MODERATE | Minimal, justified redundancy | **Not met** | Redundancy is minimal but not justified anywhere. |
| MODERATE | Clear inputs with validation | **Not met** | `params.creator` is stored unchecked (`DicesHook.sol:574`); `_buyAndBurnRecipient` unchecked in the constructor (`:218`) though checked in the setter (`:771`); calculator return values unchecked (`:462,436-439`). |
| MODERATE | Documented naming convention | **Not met** | None documented. Parameter style is mixed inside one contract: `_beforeSwap(address sender, PoolKey calldata key, ...)` at `DicesHook.sol:325` against `_afterSwap(address _sender, PoolKey calldata _poolKey, ...)` at `:372`. |
| MODERATE | Types not misused | Met | `PoolId`, `Currency`, `BalanceDelta` user types are used throughout. |
| SATISFACTORY | Minimal unnecessary complexity; no redundant behaviour | Not met | See below. |

**Vestigial code and duplication**

- `lastSwapBlock` is written on every swap and read by nothing on chain (`DicesHook.sol:185,339`; only tests read it).
  The comment refers to a "BuyAndBurn" contract that is not in the repository.
- `_getSender(sender)` is evaluated in both callbacks and passed to the swap pool, which leaves the parameter unnamed
  and unused (`DicesHook.sol:350,373`; `InternalSwapPool.sol:146,226`). Through a trusted router that is two
  `staticcall`s per swap with no effect.
- The body of `_beforeInitialize` after the sender check cannot run in production: a third-party initialisation
  reverts at `DicesHook.sol:256-258`, and the PoolManager skips the callback when the hook is the caller, as the
  function's own NatSpec says (`:246-247`). Lines `261-279` are reached only by tests that prank the manager
  (`test/DicesHook.t.sol:234-257`).
- Two libraries are both called `CurrencySettler`: the in-repo one with four-argument functions
  (`src/libraries/CurrencySettler.sol`), used by the hook, and Uniswap's test utility with five-argument functions,
  imported into production code by the swap pool (`InternalSwapPool.sol:9,258,262`).
- `_creditFee` is duplicated verbatim (`DicesHook.sol:731-741`, `InternalSwapPool.sol:287-297`). Tick alignment is
  written three times (`DicesHook.sol:673-683`, `InternalSwapPool.sol:173-185`). Events are declared in both the
  library and `IUniswapEvents`.
- Native-currency branches are unreachable because every pool is paired with USDC (`DicesHook.sol:564`):
  `InternalSwapPool.sol:291-292,363-365`, `src/libraries/CurrencySettler.sol:31-34`. The `payer != address(this)` branch
  of `settle` is also unused by the hook (`CurrencySettler.sol:40-41`, sole caller `DicesHook.sol:614`).
- `IFlaunch` is unused. `emitLiquidityDeltaUpdate` and `emitDonationUpdate` are unused.
- `DicesHook.internalSwapPool` and `feeEscrow` have no setter and could be immutable (`DicesHook.sol:125,145`; Slither
  `immutable-states`), saving storage reads on every swap.

**Runtime cost.** Baseline traces put `afterSwap` at a median of 210,011 gas and a maximum of 397,604. A USDC fee is
taken from the PoolManager and then moved to the escrow by three separate approve-and-`transferFrom` deposits, each
with two `balanceOf` calls and a reentrancy guard (`DicesHook.sol:473-481,731-741`; `FeeEscrow.sol:59-67`). A buy that
converts inventory repeats this in the swap pool (`InternalSwapPool.sol:261-278`).

**To reach Satisfactory**

- Remove the items above or justify each in a comment; share one `_creditFee` and one settle library.
- Validate `creator`, the constructor recipient and calculator return values.
- Write down the naming convention and apply it.

---

### 3.5 Decentralization: WEAK (1/4)

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Centralization points not visible to users | Partly triggered | Calculator replacement is stated (`README.md:23-27`). Nothing says the fee rate is uncapped, that changes are immediate, or that the bankroll can sell into buyers' USDC (that last point is only in `AGENT.md:121-130`). No user-facing risk disclosure. |
| WEAK | Critical functions upgradable by single entity without opt-out | **Triggered** | No proxies, but fee and level logic are replaceable modules that apply to existing pools at once (`DicesHook.sol:752-763`; `test/CalculatorUpdates.t.sol:19-29`). The exit path for a holder is a sell, which passes through the same fee calculator. |
| WEAK | Single entity controls user funds | Partly triggered | The owner cannot move pool funds directly. Through an arbitrary fee rate it can redirect swap proceeds to recipients it also sets (`DicesHook.sol:462,478-481,793-799`). The bankroll holds 100M of each coin that nobody paid for and can sell it into the pool; the repository's own test shows more than $13,000 leaving a pool that raised $35,000 (`test/DicesHookLaunchCurve.t.sol:75-100`). |
| WEAK | All decisions by single entity | **Triggered** | Single owner. |
| WEAK | Parameters changeable anytime by single entity | **Triggered** | Fee calculator, live calculator, recipients, creation fee (uncapped, `DicesHook.sol:783-786`), coin implementation, router trust. |
| WEAK | Centralized permission required | Not triggered | Launching, trading, syncing levels and claiming are permissionless. |
| MODERATE | Privileged actors can't unilaterally move or trap funds | Not met | A reverting fee calculator traps every holder (`DicesHook.sol:462` has no fallback, unlike the `try` around the live calculator). |
| MODERATE | User opt-out or exit path documented | Not met | |
| MODERATE | Upgradeability only for non-critical features | Not met | Fees are critical. |
| MODERATE | Centralization risks identified, justified, documented; all privileges documented | Partly met | `AGENT.md` records the bankroll risk and open question 10; owner powers are not analysed. |
| SATISFACTORY | Critical parameters immutable or users can exit; deployment and external-interaction risks documented | Not met | Launch constants are immutable; fee logic is not. USDC-specific risks (blacklisting of the hook, swap pool or escrow would stop fee-bearing swaps) are undocumented. |

**Rating.** Three WEAK criteria are met and two partly met. Weak.

**What is already decentralised**

- Launch liquidity is locked for good: `beforeRemoveLiquidity` rejects everyone but the swap pool, which owns only its
  own temporary positions (`DicesHook.sol:302-307`); an invariant test asserts both launch positions never change
  (`test/DicesHookInvariant.t.sol:105-108`).
- Levels are a ratchet kept by the hook, so a calculator replacement cannot take one away (`DicesHook.sol:437-439`). It
  can grant one: nothing stops a replacement from reporting level 10, or 255, for any pool.
- `FeeEscrow` has no administrator; credits cannot be redirected (`FeeEscrow.sol:16`).
- Coins are immutable clones with fixed supply and no privileged functions; an implementation change affects only later
  launches (`DicesHook.sol:551,806-812`).
- Launch curve constants are compiled in (`DicesHook.sol:71-95`).

**To reach Moderate**

- Timelock every setter that affects existing pools; cap the rate and validate the split in the hook; consider making
  fee logic immutable per pool (snapshot at launch) so that only future launches are affected.
- Give a failing fee calculator a safe fallback, or make the fee rate a bounded hook constant.
- Hold the bankroll in a contract that enforces the answer to open question 10.
- Publish a user-facing statement of owner powers, bankroll powers and the exit path.

---

### 3.6 Documentation: WEAK (1/4)

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Minimal, incomplete or outdated documentation | **Triggered** | See the mismatch table below. |
| WEAK | Only high-level description | Not triggered | NatSpec is detailed: roughly half the lines of each source file are documentation, and the interfaces that were read carry NatSpec on every function, event and error. |
| WEAK | Code comments don't match docs | **Triggered** | See below. |
| WEAK | Not publicly available (for public codebases) | Not applicable | Private repository. |
| WEAK | Unexplained artificial terms | Partly triggered | "Buy and burn" recipient is never explained (what is bought, what is burned, by whom). "Race pool" appears only in stale text. |
| MODERATE | Glossary; architecture diagrams; user stories | Not met | None in the repository. |
| MODERATE | Core components identified; known risks and limitations documented | Partly met | `AGENT.md` sections 4 and 5 (design rationale, ten open questions) are a real strength. |
| SATISFACTORY | Implementation matches spec; invariants clearly defined; docs for end users and developers | Not met | The one invariant in `AGENT.md:149` describes the removed ERC-6909 ledger. The invariants the tests actually check (`test/DicesHookInvariant.t.sol:83-118`) are not written down in the docs. |

**Documentation that contradicts the code**

| Document | Says | Code |
| --- | --- | --- |
| `README.md:10-11` | "Every fee is charged in USDC through hook deltas" plus "0.50% on buys to the coin's reserve ... then 0.25% on buys to the race pool" | Fee is charged in the unspecified currency, which is the coin for exact-input buys and exact-output sells (`DicesHook.sol:458-463`); flat 1.25% / 1.00%; no reserve or race pool exists in `src/`. |
| `README.md:12-13` | "Fees accrue as ERC-6909 USDC claims and are withdrawn with `claimFees()`; reserve and race-pool ledgers are controlled by the `reserveController`" | ERC20 and native credits in `FeeEscrow`, withdrawn with `claim` / `claimBatch` (`FeeEscrow.sol:80-94`). No `claimFees`, no `reserveController`. |
| `README.md:12` | "The base fee is split between the platform and the creator" | Three-way split with a buy-and-burn recipient (`FeeCalculator.sol:23-28,85-94`). |
| `AGENT.md:80-82` | The hook "charges every fee as a USDC hook delta" and "holds fee proceeds as ERC-6909 claims" | As above. |
| `AGENT.md:84-93` | Contracts table omits `InternalSwapPool`, `FeeEscrow`, `TrustedRouters`, `CurrencySettler` | Present in `src/core`, `src/libraries`. |
| `AGENT.md:106,110,116` | `CoinParams{name, symbol, creator, gameCommitment}`; per-pool `PoolConfig` snapshot; emit `CoinCreated` | `CoinParams` has three fields (`IDicesHook.sol:24-37`); no `PoolConfig`; no `CoinCreated`. The "sealed casino game" of the brief has no on-chain representation. |
| `AGENT.md:118` | "`beforeRemoveLiquidity` rejects everyone"; "`beforeAddLiquidity` rejects any sender but the hook" | Both admit `internalSwapPool` (`DicesHook.sol:291,303`). |
| `AGENT.md:132-149` | Fee table, transient rate cache, `PartialFillWithSpecifiedCurrency`, reserve cap, ledgers | None present. |
| `AGENT.md:168` | `PoolSwap(poolId, amount0, amount1, fee0, fee1)` after every swap | `HookSwap` and `HookFee` (`DicesHook.sol:506,519`). |
| `AGENT.md:231-235` | Start tick -398400, 50% sale position, creator share 50% | $12.5k launch, 70 / 20 / 10 split, creator share 30%. |

`AGENT.md:102-103` warns that "the Contracts table, Fees, Ledgers and Configuration subsections" are stale. The Principle
paragraph, Launch steps 1 to 4 and 6, the lock guarantees and the Indexer events section are stale too and are not
covered by that warning. `README.md` carries no warning at all.

**Comments that contradict the code they sit on**

- `DicesHook.sol:328`: "Prevents bots from buying in the same block as launch, unless token creator." The check is on
  the router, not the creator (`:334`).
- `DicesHook.sol:361`: `_afterSwap` is introduced as "The hook's own swaps." The hook never swaps; this callback runs
  for everyone else's.
- `InternalSwapPool.sol:88`: "Minimum size of the internal swap pool" for a value that is 1e-12 of a coin.
- `deployments/deployment-84532.md` has no Bankroll row, so it was written by an earlier version of the script than the
  one at this commit (`V001.s.sol:660`).

**To reach Moderate**

- Rewrite the stale sections from the code; delete what describes deferred features or move it under a clearly marked
  "not implemented" heading; state in the README which brief outputs are not yet delivered.
- Add an architecture diagram (hook, swap pool, escrow, calculators, coin, PoolManager and the calls between them), a
  glossary, user stories for creator, trader, fee claimant and owner, and the list of invariants.
- Add a router integration note covering the sync-ordering constraint that today exists only in NatSpec
  (`InternalSwapPool.sol:219-222`, `CurrencySettler.sol:20-22`).

---

### 3.7 Transaction ordering risks: WEAK (1/4)

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Ordering risks not identified or documented | Partly triggered | Identified and documented: TWAP manipulation cost and why an arithmetic mean and a hold window were rejected (`AGENT.md:192-196,255-262`); borrowed-coin holders inside one `unlock` (`DicesCoin.sol:162-164`, `AGENT.md:159-161`); the crossing swap paying the pre-Live rate (`DicesHook.sol:381`); router sync ordering. Not identified anywhere: launch sniping, sandwiching of ordinary swaps, the price at which queued coin fees are converted, free price moves below the launch range. |
| WEAK | Protocols or assets at risk from unexpected ordering | Partly triggered | See findings T1 to T3 below. |
| WEAK | Relies on unjustified MEV prevention constraints | **Triggered** | The zero-block guard (T1). |
| WEAK | Unproven assumptions about MEV extractors | Not triggered | `AGENT.md:260-262` states plainly that the level rule "does not stop a patient buyer". |
| MODERATE | MEV mitigations in place | Partly met | 24-hour tick TWAP on hourly checkpoints; holders that joined in the current block are not counted; fee tier decided before the level is synced. Slippage and deadlines are left to the router, which is the normal v4 arrangement but is not stated. |
| MODERATE | Testing emphasises ordering risks | Partly met | `Calculators.t.sol:258` (spike), `:279` (only the last tick of a block counts); `DicesHookLive.t.sol:206-227` (same-block holder); `DicesHookTrading.t.sol:144-152` (zero-block guard). No test for launch-block buying through a public trusted router, nor for the oracle while the price is below the launch range. |
| MODERATE | Tamper-resistant oracles | Met with a caveat | The oracle is internal, built only from the hook's own post-swap observations (`LiveCalculator.sol:146-165`). Caveat T2. |
| SATISFACTORY | All ordering risks documented and visible to users; MEV opportunities centralised in documentation | Not met | |

**Rating.** One WEAK criterion is met outright and two in part. Weak. The oracle half of this category would rate
Moderate on its own.

**T1. The zero-block guard does not restrict the launch block as deployed.** `_beforeSwap` reverts in the launch
block unless `trustedRouters[sender]` is true (`DicesHook.sol:334`). `V001` trusts the chain's Universal Router
(`V001.s.sol:238`), and the activity script requires that trust "for launch-block swaps"
(`script/process/GenerateActivity.s.sol:90`). Anyone can route through the Universal Router, so anyone can buy in the
launch block; a contract can also call `createCoin` and the router in one transaction. `createCoin` has no atomic
creator purchase, so a creator who wants the first fill must bundle it themselves. The guard therefore stops only
callers that use a different router.

**T2. The oracle records prices that no liquidity backs.** Both launch positions sit above the launch price, so below
it there is no liquidity and the price moves at no cost; the swap pool's own comment describes this
(`InternalSwapPool.sol:156-158`) and guards against it (`:159-161`). `LiveCalculator.qualify` records whatever tick the
pool is left at, without a floor (`LiveCalculator.sol:150-163`). Two consequences, by code reading and not executed:
before a pool's first buy, a sell of any size with a price limit at the minimum moves the pool to the extreme tick for
gas alone, and the time until the first buy is averaged at that tick; after a pool has been emptied of USDC, which the
repository's test shows the bankroll can do (`test/DicesHookLaunchCurve.t.sol:86-93`), the pool sits at the extreme
tick until the next buy. An hour at the extreme tick lowers a 24-hour average by roughly 20,000 ticks. The effect is
only ever downward, so it delays levels and cannot grant one.

**T3. Queued coin fees are converted at the spot price of whichever buy arrives next**
(`InternalSwapPool.sol:168-186,196`), in a range one tick spacing wide directly above spot. A buyer who first moves the
price down receives the inventory at the lower price and the fee recipients receive less USDC. The attack pays the
trading fee on both legs, so it is only worthwhile when inventory is large relative to depth; the trade-off is not
written down.

**Other ordering observations**

- `syncLevel` is permissionless and idempotent; front-running it has no effect (`DicesHook.sol:408-417`).
- Holder floors are met by balances held across one block boundary. `AGENT.md:158,260-262` and open question 5 record
  that one person can supply all the wallets and that the bankroll can do so at no cost.
- The settle inside `afterSwap` overwrites a caller's earlier `sync`, so a router that syncs before swapping fails with
  `CurrencyNotSettled`, and only on swaps that convert inventory (`InternalSwapPool.sol:219-222,257-259`). The whole
  transaction reverts, so no funds are lost, but the failure is intermittent from an integrator's point of view.

**To reach Moderate**

- Decide the launch-block policy and implement it so that it holds with the Universal Router trusted (creator-only
  through `IMsgSender` attribution, an atomic creator buy inside `createCoin`, or no guard at all with the comment
  removed). Separate "attribution trust" from "launch-block trust".
- Floor the observed tick at the launch tick, or skip observations while `getLiquidity` is zero; add tests for both
  scenarios in T2.
- Write an MEV section: launch sniping, sandwiching and router-side slippage, fee conversion, level timing, holder
  seeding.

---

### 3.8 Low-level manipulation: SATISFACTORY (3/4)

**Search performed** over `src/` for `assembly`, `delegatecall`, `.call(`, `.call{`, `staticcall`, `unchecked`,
`selfdestruct`, `ecrecover`, `abi.encodePacked`. Results: one `staticcall` (`TrustedRouters.sol:44`); the word
`delegatecall` in one comment (`DicesCoin.sol:37`); nothing else. Slither `human-summary` reports zero assembly lines
in source files and one `low-level-calls` result, the same line.

**Low-level behaviour that the search does not show**

- **Linked library.** Every function of `UniswapEvents` is `public` (`UniswapEvents.sol:67-128`), so the hook reaches
  them by `DELEGATECALL` to a separately deployed library. The deployment script deploys the library through CreateX
  and patches the link references in the hook's creation code by hand (`V001.s.sol:213,485-505`); a test checks that
  Forge will not auto-deploy a library (`test/scripts/V001.t.sol:372`). The source does not say why the functions are
  external; the 1,499-byte size margin is the likely reason.
- **Minimal clones.** Each coin is a Solady `LibClone.cloneDeterministic` proxy that delegates to the implementation
  (`DicesHook.sol:551`). `DicesCoin.sol:37-38` documents that immutables are read through that delegatecall. The
  implementation has no `selfdestruct` and no `delegatecall` of its own. `initialize` can be called once on the
  implementation itself by anyone (`DicesCoin.sol:123-138`); this affects only the implementation's own storage.
- **Assembly in dependencies.** Solady `ERC20`, `LibClone` and `SafeTransferLib`, and the v4 libraries, are
  assembly-heavy, established and unmodified. Solady grants Permit2 an infinite allowance by default; the interface
  acknowledges it (`IDicesCoin.sol:58-60`).
- **Script.** `V001.s.sol:421-431` resets the free-memory pointer in a mining loop, with a comment and a test
  (`test/scripts/V001.t.sol:133`). Not production code.

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Unjustified low-level manipulation; low-level code that could be high-level | Not triggered | The `staticcall` exists so that a malformed router reply cannot revert a swap (`TrustedRouters.sol:43`). A high-level `try` would not catch a reply that fails to decode. |
| MODERATE | Assembly use limited and justified | Met | None in `src/`. |
| MODERATE | Inline comments for each operation | Met | `TrustedRouters.sol:38,43`. |
| MODERATE | No re-implementation of established libraries without justification | Met with a note | `src/libraries/CurrencySettler.sol` adapts Uniswap's helper to use `SafeERC20`; the reason is not stated, and the swap pool still imports the original from `v4-core/test/utils` (`InternalSwapPool.sol:9`), whose `settle` ignores the token's return value (`lib/v4-hooks-public/lib/v4-core/test/utils/CurrencySettler.sol:29-31`). That is safe here because `DicesCoin` reverts on failure, but production bytecode should not depend on a test directory. |
| MODERATE | High-level reference for complex assembly | Not applicable | |
| SATISFACTORY | Thorough documentation, justification and testing | Met | Every reply shape is tested: wrong length, zero address, revert with and without data, dirty upper bits, untrusted router (`test/TrustedRouters.t.sol:12-38`). |
| SATISFACTORY | Automated testing against a reference; differential fuzzing | Not applicable | No assembly to compare. |
| SATISFACTORY | Compiler optimisation risks identified | Partly met | `foundry.toml:9-22` records the legacy pipeline for internal sources, the separate IR profile for the upstream manager and pinned compiler versions; `AGENT.md:302-309` repeats it. Nothing discusses the risk of adopting a very recent compiler and EVM version, or that coverage runs without the optimiser while deployment uses 77,777 runs. |

**Rating.** No WEAK criterion; all applicable MODERATE criteria met; some SATISFACTORY criteria met. Satisfactory.

**Remaining gaps**

- The `staticcall` forwards all available gas to the router. Trusted routers are owner-chosen; a gas cap would remove
  the dependency.
- The hand-rolled bytecode linking in the deployment script is the only thing connecting the hook to the correct
  library address; `_requireWiring` (`V001.s.sol:510-532`) does not check it after deployment.

**To reach Strong**

- Use the in-repo settle library everywhere; document the external-library decision; add a post-deployment check that
  the linked library address has the expected code; record a compiler-adoption policy.

---

### 3.9 Testing and verification: SATISFACTORY (3/4)

**Inventory.** 14 test files, 127 passing tests in 14 suites (baseline). Coverage of `src/` in the last local run:
100% of lines, statements, branches and functions in all nine executable files (`coverage/summary.txt`). Deployment
scripts are lower: `V001.s.sol` 69.57% of branches, `GenerateActivity.s.sol` 73.08%. Invariant configuration: 64 runs,
depth 32, `fail_on_revert = true` (`foundry.toml:67-70`). No Echidna, Medusa, Halmos, Certora, Semgrep or mutation
tool is configured.

**Criteria**

| Level | Criterion | Status | Evidence |
| --- | --- | --- | --- |
| WEAK | Only happy paths; common use cases untested; tests fail; cannot run out of the box | Not triggered | Reverts, malformed replies, failing calculators, fee-on-transfer tokens and reentrancy are tested (`FeeEscrow.t.sol:87-123`, `DicesHookLive.t.sol:352`). `forge test` needs only the submodules. |
| MODERATE | Most functions and use cases tested; all tests pass | Met | |
| MODERATE | Coverage reports available | Met | Generated in CI and checked by `test/check_coverage.py`, which also fails if a production file is missing from the report (`:25-28,45,65`). |
| MODERATE | Automated testing for critical components | Met | Fuzz tests and five stateful invariants (`DicesHookInvariant.t.sol:83-118`). |
| MODERATE | Tests in CI/CD | Met | `.github/workflows/test.yml:28-44`: format check, build with sizes, tests, coverage gate. |
| MODERATE | Integration tests | Met | Real `PoolManager` artifact (`DicesHook.t.sol:60`); full deployment then launch and trade (`test/scripts/V001.t.sol:59-110`); a fork-capable activity test (`README.md:146-148`). |
| MODERATE | Test code follows best practices | Met with notes | Shared fixtures, descriptive names, events and selectors asserted. Some bare `vm.expectRevert()` calls accept any failure (`DicesHookTrading.t.sol:148`, `DicesHook.t.sol:396,398`). |
| SATISFACTORY | 100% reachable branch and statement coverage | Met for `src/` | Enforced in CI. |
| SATISFACTORY | End-to-end testing covers all entry points | Mostly met | `createCoin`, four swap modes in two orderings, `syncLevel`, `claim`, `claimBatch`, every owner setter, deployment. |
| SATISFACTORY | Isolated test cases | Met | Each test builds its own state. |
| SATISFACTORY | Mutation testing used | Not met | None configured; not evidenced. |

**Rating.** All MODERATE criteria met and most SATISFACTORY criteria met. Satisfactory. Not Strong, for the reasons below.

**Why the coverage figure should be read with care**

- **The invariant campaign is shallow.** The single handler buys between 1,000 and 1,000,999 raw USDC units, at most
  about one dollar, per call (`DicesHookInvariant.t.sol:36-39`). Thirty-two such calls cannot move the price far beyond
  the first tick spacing of a curve that takes $35,000 to traverse, so position crossings and inventory conversion are
  barely exercised. It uses exact-input swaps only, one currency ordering (`:67`), one actor, no time movement, and a
  stub level calculator (`DicesHook.t.sol:62`), so the oracle and the level ratchet are outside the campaign.
- **Some covered code cannot run in production.** `DicesHook.sol:261-279` is covered by pranking the PoolManager
  (`test/DicesHook.t.sol:234-257`); the native-currency branches are covered through test doubles
  (`test/InternalSwapPool.t.sol:198-206,221-228`).
- **Several isolated tests use a manager double whose deltas are set by hand** (`test/utils/Fixtures.sol:140-200`). For
  example the "untouched position" test asserts zero settlements (`InternalSwapPool.t.sol:110-128`) against a double
  that returns identical add and remove deltas, where the real manager rounds the two in opposite directions.
- **Most `testFuzz_` tests take a single `bool`.** They run both currency orderings, which is valuable, but they are
  not property tests.
- **Untested behaviours found in this review:** `createCoin` with `creator == address(0)`; a fee calculator returning a
  rate of 100% or more; a live calculator returning data that does not decode or a level above 10; launch-block buys
  through a public trusted router; the oracle while the price is below the launch range.
- **Tooling outside CI.** Slither is not run in CI (95 untriaged results in the supplied output; the ones examined here
  are benign or false positives, see section 7). `forge lint` reports 23 warnings that are not gated. CI installs
  `foundry-toolchain@v1` without a pinned Foundry version (`test.yml:22-23`).

**To reach Strong**

- A second invariant handler with trade sizes up to the whole sale, all four swap modes, both orderings, several actors
  and coins, holder transfers, bankroll sells, and `vm.warp` against the real `LiveCalculator`; raise runs and depth.
- Add properties: fee conservation (fee charged equals escrow credits plus inventory added), `poolLevel` never
  decreases and never exceeds `LEVELS`, `qualifiedHolders` equals a recount, the TWAP equals a reference model.
- Introduce mutation testing and track the score; add Slither and `forge lint` to CI with a triaged baseline; pin the
  toolchain.

---

## 4. Improvement roadmap

### CRITICAL (before any mainnet deployment)

| # | Action | Effort | Impact |
| --- | --- | --- | --- |
| 1 | **Governance hardening.** `Ownable2Step`; owner is a Safe behind a `TimelockController`; `V001` reverts on mainnet when `PROTOCOL_OWNER` is unset or equals the deployer; disable `renounceOwnership` or document why it is wanted; separate pause guardian. | 2 to 4 days | Access Controls Weak to Moderate; removes the key-compromise scenario in 3.3. |
| 2 | **Bound the replaceable modules in the hook.** Constant maximum fee rate; check the split sums to the fee; clamp the level to `LEVELS`; make the `qualify` call tolerant of undecodable return data; give a failing fee calculator a defined fallback. Check the 1,499-byte size margin. | 1 to 2 days plus tests | Decentralization and Arithmetic (bounded parameters); delivers the brief's "enforced on-chain with caps". |
| 3 | **Validate `params.creator != address(0)` in `createCoin`** and `_buyAndBurnRecipient` in the constructor; add the tests. | Half a day | Closes candidate finding F1. |
| 4 | **Make the documentation true.** Rewrite `README.md:10-13` and the stale `AGENT.md` sections from the code; list the brief outputs that are not implemented (reserve surcharge, reserve and race ledgers, sealed game commitment); get client sign-off on the implemented fee model. | 1 to 2 days | Documentation and Arithmetic Weak to Moderate. |
| 5 | **Decide and implement the launch-block policy**; split attribution trust from launch-block trust; document launch MEV. | 1 to 3 days | Transaction Ordering Weak to Moderate. |

### HIGH (1 to 2 months)

| # | Action | Effort | Impact |
| --- | --- | --- | --- |
| 6 | **Bankroll custody** (open question 10): a contract that enforces a lock or payout-only rule. | 3 to 5 days | Removes the largest unrestricted balance in the system. |
| 7 | **Monitoring and incident response.** Written monitoring plan, alerts on every configuration event, on escrow solvency and on a pool sitting at an extreme tick; incident runbook covering a faulty calculator, a compromised owner and a USDC blacklist; rehearsal. | 3 to 5 days, then ongoing | Auditing Moderate to Satisfactory. |
| 8 | **Deeper stateful testing and mutation testing** as described in 3.9; Slither and lint in CI; pinned toolchain. | 1 to 2 weeks | Testing Satisfactory to Strong. |
| 9 | **Oracle floor.** Clamp the observed tick to the launch tick or skip observations at zero liquidity; test both scenarios in T2. | 1 to 2 days | Closes candidate finding F5. |
| 10 | **Events.** Launch event with creator; conversion event in the swap pool. | Half a day to 1 day | Auditing criterion "events for all critical functions". |

### MEDIUM (2 to 4 months)

| # | Action | Effort | Impact |
| --- | --- | --- | --- |
| 11 | **Remove vestigial code and duplication** (list in 3.4); use the in-repo settle library in the swap pool; make `internalSwapPool` and `feeEscrow` immutable; correct the minimum inventory unit. | 2 to 3 days | Complexity Moderate to Satisfactory; recovers bytecode margin and gas. |
| 12 | **Documentation completeness.** Architecture diagram, glossary, user stories, invariants, naming convention, router integration guide, user-facing risk disclosure. | 3 to 5 days | Documentation Moderate to Satisfactory. |
| 13 | **Arithmetic specification** with rounding directions, trapping operations and a reference model for the TWAP. | 3 to 4 days | Arithmetic Moderate to Satisfactory. |
| 14 | **Fee routing cost.** One transfer and three ledger writes per fee instead of three transfers; transient storage for the JIT state. | 2 to 3 days | Lowers the 210k median `afterSwap` cost. |
| 15 | **Decentralization path.** Decide which parameters become immutable per pool at launch and publish the plan. | 2 to 3 days design | Decentralization Moderate to Satisfactory. |

---

## 5. Questions for the team

These could not be answered from the repository. Each can change a rating.

**Auditing**
1. Is there off-chain monitoring of the hook, escrow and calculators today? Which events are logged, and where?
2. Is there a written monitoring plan, a log review process and an incident-response plan? Has the plan been rehearsed?
3. Who is responsible for detecting an incident, and what is the response to a fault in the swap path, given that
   `pause()` stops only coin creation?

**Access controls and decentralization**
4. What will `PROTOCOL_OWNER`, `FEE_RECIPIENT`, `BUY_AND_BURN_RECIPIENT` and `BANKROLL` be on mainnet: EOA, Safe (which
   threshold), timelock? When does the deferred Safe and 48-hour timelock arrive relative to mainnet launch?
5. How is the `dices_deployer` keystore key held, and is it retired after ownership is transferred?
6. Is `renounceOwnership` intended to be available?
7. Is the buy-and-burn recipient a contract or a wallet, and what does it do? Is it the future reader of
   `lastSwapBlock`?
8. Is the bankroll intended to be free from the launch block (open question 10)?
9. Is there a user-facing description of owner powers and exit paths outside this repository?

**Arithmetic and documentation**
10. Is the implemented fee model (fee in the unspecified currency, flat 1.25% / 1.00%, split 40 / 30 / 30, no reserve
    surcharge) the agreed one? The brief requires 0.50% of buys to fund the coin's reserve.
11. Which document is authoritative when `README.md`, `AGENT.md` and the code disagree?
12. Is there a naming convention, a glossary or an architecture diagram outside the repository?

**Transaction ordering**
13. Is buying in the launch block through the Universal Router intended for everyone, or only for the creator?
14. Has launch sniping, sandwiching and the fee-conversion price been analysed anywhere?
15. Is the downward-only effect of unbacked prices on the TWAP (T2) accepted?

**Testing**
16. Has any fuzzing campaign, mutation testing or prior audit been run outside this repository?
17. Are the fork tests for `GenerateActivity` run anywhere on a schedule?
18. Who triages Slither and `forge lint` output, and is there a recorded baseline?

**Low-level**
19. Why are the `UniswapEvents` functions external rather than internal? Is the deployed library address verified after
    deployment?
20. What is the policy for adopting new compiler and EVM versions (0.8.38 and Osaka at this commit)?

---

## 6. Candidate findings for independent verification

Everything here was derived by reading code. Nothing was executed. Severity words are deliberately conservative.

| ID | Claim | Location | Consequence | Confidence |
| --- | --- | --- | --- | --- |
| F1 | `createCoin` stores `params.creator` without a zero check, and `FeeEscrow.deposit` reverts for a zero beneficiary. | `src/DicesHook.sol:574,480`; `src/core/InternalSwapPool.sol:274`; `src/core/FeeEscrow.sol:36-38` | On a pool launched with a zero creator, any swap whose fee is in USDC (exact-input sells, exact-output buys) and any buy that converts inventory reverts once the creator share is non-zero. Exact-output sells and small exact-input buys still work. Launching is permissionless, so such a pool can be created deliberately. | High on the code path; no test covers it |
| F2 | The fee rate and split come from an owner-replaceable calculator with no cap, no delay and single-step ownership; the default owner is the deployer. | `src/DicesHook.sol:462,478,752-754,819-825`; `script/deployment/V001.s.sol:61,131,306`; `test/scripts/V001.t.sol:259-267` | The owner key can take up to the whole unspecified amount of each swap (bounded by each trader's slippage limit) or block all trading on all pools; `renounceOwnership` afterwards makes it permanent. | High |
| F3 | The zero-block guard exempts every swap through a trusted router, and the deployment trusts the public Universal Router. | `src/DicesHook.sol:326-336`; `script/deployment/V001.s.sol:238`; `script/process/GenerateActivity.s.sol:90` | Anyone can buy in the launch block; the guard and its comment ("unless token creator") give no sniping protection. | High on the facts; medium that it is unintended |
| F4 | README and AGENT.md specify a fee and ledger system that is not in the code. | `README.md:10-13`; `AGENT.md:80-82,106-118,132-149,168,231-235` against `src/DicesHook.sol:291,303,458-482`, `src/calculators/FeeCalculator.sol:23-38` | The brief's reserve funding on buys is not implemented and the primary README does not say so; integrators and reviewers working from the documents will be wrong. | High |
| F5 | `LiveCalculator` records the pool tick with no floor, and the price moves freely below the launch range. | `src/calculators/LiveCalculator.sol:150-163,266-295`; `src/core/InternalSwapPool.sol:156-161`; `test/DicesHookLaunchCurve.t.sol:86-93` | Time spent at the extreme tick (reachable for gas before the first buy, or after a pool is drained) lowers the 24-hour average by about 20,000 ticks per hour. Delays levels; cannot grant one. | Medium |
| F6 | Production code imports Uniswap's test-only `CurrencySettler`, whose `settle` ignores the ERC20 return value, alongside a same-named in-repo library. | `src/core/InternalSwapPool.sol:9,258,262`; `lib/v4-hooks-public/lib/v4-core/test/utils/CurrencySettler.sol:29-31` | Dependency on code outside the audited v4 sources; safe today only because `DicesCoin` reverts on a failed transfer. | High; low severity |
| F7 | `InternalSwapPool.feeCalculator` is immutable while the hook's is replaceable. | `src/core/InternalSwapPool.sol:75,265`; `src/DicesHook.sol:752`; `test/CalculatorUpdates.t.sol:28` | After `setFeeCalculator`, converted coin fees keep the old split for good. The test shows it is known; no document says so. | High; low severity |
| F8 | `_syncLevel` does not bound `level`, and a `try` does not catch return data that fails to decode. | `src/DicesHook.sol:436-448,832-838` | A replacement live calculator can set any pool to any `uint8` level irreversibly, or block every swap by returning malformed data. Owner-only. | High on language semantics; low severity |
| F9 | `MINIMUM_INTERNAL_SWAP_POOL_SIZE` is 1e6 raw units of an 18-decimal coin. | `src/core/InternalSwapPool.sol:90,155` | No effective dust floor: a temporary position is added and removed on every buy once any inventory exists. Gas only. | High on the fact |
| F10 | The constructor accepts a zero `_buyAndBurnRecipient`. | `src/DicesHook.sol:218` | USDC-fee swaps on every pool would revert until the owner sets a recipient. `V001` guards against it (`V001.s.sol:324`). | High; low severity |
| F11 | `InternalSwapPool.receive()` accepts ETH from anyone and no path returns it. | `src/core/InternalSwapPool.sol:363-365` | ETH sent by mistake is locked. Native paths are unreachable for USDC pools. | High; informational |

---

## 7. Method, tool output and limitations

**Files read in full:** every contract and library under `src/` and the interfaces `IDicesHook`, `IFeeEscrow`,
`IInternalSwapPool`, `ITrustedRouters`, `IFeeCalculator`, `IFlaunch`; `script/deployment/V001.s.sol`, `foundry.toml`,
`.github/workflows/test.yml`, `README.md`, `AGENT.md`, `test/check_coverage.py`, `test/DicesHook.t.sol`,
`test/DicesHookTrading.t.sol`, `test/DicesHookInvariant.t.sol`, `test/DicesHookLaunchCurve.t.sol`,
`test/CalculatorUpdates.t.sol`, `test/InternalSwapPool.t.sol`, `test/TrustedRouters.t.sol`, `test/utils/Fixtures.sol`.
Read in part: `src/interfaces/ILiveCalculator.sol`, `IDicesCoin.sol`, `IUniswapEvents.sol`; `test/Calculators.t.sol`, `test/DicesHookLive.t.sol`, `test/scripts/V001.t.sol`,
`script/process/GenerateActivity.s.sol`, the upstream `CurrencySettler` and `BaseHook`, Solady `ERC20`. Test function
lists were taken for every test file.

**Tool output used, not regenerated:** `audits/2026-11-25-skills-review/slither/slither-detectors.txt`,
`printer-function-summary.txt`, `printer-vars-and-auth.txt`, `printer-entry-points.txt`, `printer-human-summary.txt`,
`check-erc20-DicesCoin.txt`; `coverage/summary.txt`, `coverage/gaps.json`.

**Slither results examined.** `arbitrary-send-erc20` on `CurrencySettler.settle`: the hook always passes itself as
payer (`DicesHook.sol:614`), so the flagged branch is unused. `weak-prng`: modulo on time, false positive.
`reentrancy-eth` in `_afterSwap`: `poolLevel` is written after external calls, but every callee is a protocol contract
or an owner-chosen calculator and the entry point is restricted to the PoolManager. `dead-code` for
`InternalSwapPool._creditFee`: false positive caused by the IR failure on its only caller. `unimplemented-functions`:
false positive (public mapping getters). `immutable-states`: valid (`DicesHook.sol:125,145`). `missing-zero-check`:
seven constructor parameters; one is material (F10). The remaining results were not triaged individually.

**Limitations**

- Nothing was compiled, tested or executed on purpose. Every behavioural claim, including F1, F5 and F8, is from code
  reading and the semantics of Solidity and Uniswap v4.
- **One accidental build.** While collecting line numbers, a shell search pattern contained the text
  `forge build --sizes` in backticks inside double quotes, and the shell executed it once at 14:06 local time. It was
  an incremental no-op: no artifact under `out/` was rewritten, the only file modified was
  `cache/solidity-files-cache.json`, and `git status` shows no tracked change. It is disclosed here because the review
  rules forbade build commands on the shared cache.
- Slither's cyclomatic complexity for three functions is unreliable because IR generation failed for them.
- The coverage report is from the last local run and may be slightly stale.
- The baseline counts 127 tests; a text search finds about 130 `test*` and `invariant*` declarations across the 14
  files. The difference was not reconciled.
- Whether an untouched just-in-time position nets to minus one raw unit against the real PoolManager, and therefore
  settles on every buy, was not determined.
- The Base Sepolia deployment record predates the bankroll change; whether the deployed bytecode matches this commit
  was not checked.
- Off-chain practice is unknown; see section 5.

Assessment produced with the Trail of Bits Building Secure Contracts Code Maturity Evaluation framework v0.1.0.

---

## 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 (section 6) | Consolidated | Status after verification |
| --- | --- | --- |
| F1, F10 | DICES-01 | Confirmed; run (`testPoC1`, `testPoC12`) |
| F2 | DICES-03, DICES-04 | Confirmed; run (`testPoC4`) |
| F3 | DICES-06 | Confirmed; run (`testPoC2`) |
| F4 | DICES-09, DICES-17 | Confirmed |
| F5 | DICES-21 | Confirmed as described: it can delay a level and cannot grant one |
| F6 | DICES-11 | Confirmed |
| F7 | DICES-08 | Confirmed; run (`testPoC5`) |
| F8 | DICES-07, DICES-03 | Confirmed; run (`testPoC3`, `testPoC10`) |
| F9 | DICES-10 | Confirmed |
| F11 | DICES-13 | Confirmed |

Items this report left open, now settled:

- **Untouched conversion position.** A separate line-by-line review computed that it does net to one raw unit,
  so the settle runs on every buy once fees are queued (`context/03-internal-swap-pool-and-escrow.md`;
  DICES-10).
- **Test count.** `forge test` reports 127 tests in 14 suites; fuzz and invariant functions each count once.

Findings in the consolidated list that this report does not contain: DICES-02 (levels 9 and 10 are
unreachable) and DICES-05 (fee conversion at a price any caller can push down, rated Medium). DICES-05
bears on category 7, transaction ordering, which this report already rates Weak.

The ratings above depend in part on off-chain practice that the repository cannot show. The questions in
section 5 are the ones whose answers would change them.
