# False-positive check: verification log

**Skill**: Trail of Bits `fp-check` 1.0.0
**Date**: 2026-11-25, commit `bcd45b2` (`main`)

Every candidate from the review was put through this check before it was allowed into
[`findings.md`](findings.md). Candidates came from six sources that worked separately: my own line-by-line read,
and the guidelines, code-maturity, token-integration, spec-compliance and Uniswap v4 reviews. Those five
reviewers were not told what the others or I had found.

## How to read a record

Each record follows the skill: Step 0 (restate the claim), Phase 1 data flow, Phase 2 exploitability, Phase 3
impact, Phase 4 proof of concept, Phase 5 devil's advocate, the six gates, a verdict.

- The skill's Gate 3 names remote code execution, privilege escalation and information disclosure. For a
  smart contract I read it as: loss or diversion of funds, denial of a core function, or an action the
  documented trust model does not allow.
- **TRUE POSITIVE** means the claim is true as stated and has a real consequence. It says nothing about
  severity; severity is argued in `findings.md`.
- "PoC" names a test in [`poc-tests.md`](poc-tests.md). All of them were run; the output is in that file.
- Bugs #1 and #5 took the skill's deep route (three or more components, or an economic claim with no
  specification to check against). The rest took the standard route. Bug #5 was also verified a second time
  by a separate verifier that did not see my work.
- Informational items are statements of fact about the code rather than attack claims. They are verified in
  short-form records near the end, with the same phases and gates.

## Summary

| | Count |
| --- | --- |
| Candidates checked | 30 |
| TRUE POSITIVE, security-relevant (Bugs #1 to #8) | 8 |
| TRUE POSITIVE, informational (Bugs #9 to #22) | 14 |
| FALSE POSITIVE (R-01 to R-08) | 8 |

Exploit chains were checked after the individual verdicts; see the last section.

---

## BUG #1 (DICES-01): a zero fee beneficiary makes USDC-fee swaps revert

**Step 0.**
- Claim: `createCoin` stores `params.creator` without checking it. If it is `address(0)`, every later swap in
  that pool that credits the creator reverts.
- Root cause: `FeeEscrow.deposit` rejects a zero beneficiary; the hook and the swap pool call it with
  `poolCreators[poolId]` unconditionally when the creator's share is non-zero.
- Trigger: anyone calls `createCoin({name, symbol, creator: address(0)})`.
- Claimed impact: in that pool, exact-input sells, exact-output buys and buys that convert queued fees revert.
  No setter can repair it.
- Threat model: unprivileged caller; affects only the pool that caller creates and whoever buys into it.
- Bug class: logic bug, denial of service. Route: deep (hook → swap pool → escrow).

**Phase 1, data flow.**
- Source: `params.creator`, untrusted calldata → stored at `src/DicesHook.sol:574` with no check.
- Sink A: `_collectSwapFee` → `_creditFee(poolCreators[poolId], …, creator)` (`:480`) →
  `feeEscrow.deposit` (`:739`) → `revert InvalidBeneficiary()` (`src/core/FeeEscrow.sol:36-38`).
- Sink B: `closeInternalSwapPool` → `_creditFee(dicesHook.poolCreators(poolId), …)`
  (`src/core/InternalSwapPool.sol:274`) → same revert.
- Validation between source and sink: only `if (amount == 0) return` (`src/DicesHook.sol:732`,
  `InternalSwapPool.sol:288`). The creator share is 30% (`src/calculators/FeeCalculator.sol:87`), so it is
  non-zero for any fee or proceeds of 4 raw USDC units or more.
- API contract: the escrow's revert is deliberate and documented. Environment: nothing in the PoolManager
  catches a hook revert; it wraps and re-throws (`v4-core/libraries/Hooks.sol:137`).
- Cross-reference: `feeRecipient` and the setter for `buyAndBurnRecipient` are zero-checked
  (`src/DicesHook.sol:794`, `:771`); `creator` and the constructor's `_buyAndBurnRecipient` (`:218`) are not.
  No test launches with a zero creator.
- Four of the separate reviewers reported this from the code without being given the claim.

**Phase 2, exploitability.** Attacker control: full; `creator` is a free parameter of a permissionless
function. Bounds: not a bounds issue. Race: none. Adversarial view: the attacker gains nothing directly; the
effect is a pool that takes buys and refuses ordinary sells.

**Phase 3, impact.** Real: a core function (selling) is denied for that pool, permanently, since
`poolCreators` has no setter. Buyers are not robbed: an exact-output sell still works, because its fee is
charged in the coin. Primary control, not defence in depth: there is no second check.

**Phase 4, PoC.**
- Pseudocode: `createCoin(creator = 0)` → buy exact-in (succeeds, fee queued in coin) → sell exact-in → hook
  takes USDC fee → credits creator `0` → escrow reverts → swap reverts.
- Executable: `testPoC1_zeroCreatorBricksEverySwapThatCreditsTheCreator(bool)`, 256 runs over both currency
  orderings, passes. It asserts the revert data contains `FeeEscrow.InvalidBeneficiary` for the exact-input
  sell, the exact-output buy and a second buy that trades into the conversion range, and that an exact-output
  sell still pays out.
- Negative PoC: `testPoC1_control_nonZeroCreatorTradesNormally(bool)` runs the same sequence with a real
  creator and every swap succeeds.
- Variant: `testPoC12_zeroBuyAndBurnRecipientBlocksUsdcFeeSwapsUntilSet` shows the same failure for a hook
  constructed with a zero buy-and-burn recipient, repairable by the owner.

**Phase 5, devil's advocate.**
1. Other explanations: none; the revert is unconditional.
2. Developer's view: the front end always supplies a creator. True, but the function is callable directly.
3. Missing context: none found; no setter, no fallback beneficiary.
4. Pattern-matching: no, it was executed.
5. Does validation prevent it: the only guard is the zero-amount skip, which does not apply.
6. Attacker control of trusted data: `creator` is caller input, not trusted state.
7. Math proven: 30% of a fee of 4 or more units is at least 1.
8. Practical: one transaction.
9. Defence in depth: no other layer.
10. Environment: none.
11. Hallucination check: reproduced on a real PoolManager.
12. Dismissing too quickly: the opposite risk is overrating it; the attacker has no profit and the damage is
    confined to their own pool.
13. Invented mitigations: re-read `createCoin` after concluding; there is no check.

**Gates.** 1 Process: pass. 2 Reachability: pass (permissionless). 3 Real impact: pass (sell path denied).
4 PoC: pass. 5 Math: pass. 6 Environment: pass.

`BUG #1 TRUE POSITIVE — createCoin accepts a zero creator, after which every swap that credits the creator reverts.`

---

## BUG #2 (DICES-02): levels 9 and 10 can never unlock

**Step 0.** Claim: the holder floors for levels 9 and 10 exceed the largest number of qualifying holders that
can exist. Root cause: fixed supply ÷ fixed threshold. Trigger: none needed; it is a property of the constants.
Impact: two of the ten games can never be unlocked for any coin. Threat model: not an attack. Bug class:
logic, integer. Route: standard.

**Phase 1, data flow.** `HOLDER_THRESHOLD = 300_000e18` (`src/DicesCoin.sol:32`). Supply is minted once,
`LAUNCH_SUPPLY = 1_000_000_000e18` (`src/DicesHook.sol:71`, `:554`), and `DicesCoin` has no mint after
`initialize` (`src/DicesCoin.sol:123-138`). Floors: `[150, 225, 350, 500, 750, 1100, 1700, 2500, 3800, 5800]`
(`src/calculators/LiveCalculator.sol:252`). `_levelAt` lowers the level while `holders < floors[level - 1]`
(`:373-375`).

**Phase 2, exploitability (bounds proof).**
1. Each qualifying holder has a balance ≥ 300,000 coins.
2. Balances sum to at most the supply, 1,000,000,000 coins.
3. So holders ≤ floor(1,000,000,000 ÷ 300,000) = 3,333.
4. Level 9 needs 3,800 > 3,333. Level 10 needs 5,800 > 3,333.
5. Therefore `_levelAt` can never return 9 or 10 with a real `DicesCoin`. Q.E.D.

The real ceiling is lower, because the hook, the PoolManager, the swap pool and the bankroll address are not
counted (`src/DicesCoin.sol:247-249`) and the pool still holds coins. At level 8's $25.6M market cap about
17.7M of the upper position's 200M coins remain in the pool, so at most about 982M coins are outside it even
if the bankroll has paid out everything. Level 8's 2,500 holders need 750M of them in qualifying wallets.

**Phase 3, impact.** A documented product behaviour (ten games) cannot occur. No funds at risk.

**Phase 4, PoC.** Pseudocode: `assert(floors[8] * HOLDER_THRESHOLD > totalSupply)`. Executable:
`testPoC9_levelsNineAndTenNeedMoreHoldersThanTheSupplyAllows` passes and prints 1,140M and 1,740M coins needed
against a supply of 1,000M. Negative PoC: the same test asserts level 8 (750M) is arithmetically possible.
The project's own tests reach level 10 only with a stand-in coin whose holder count is set by hand
(`test/utils/Fixtures.sol:83-99`).

**Phase 5, devil's advocate.**
1. Other explanations: the floors came from the client's table and the threshold from a later design choice;
   nothing suggests the top levels were meant to be unreachable.
2. Developer's view: each constant is reasonable alone. The floors are the client's; a fixed 300,000-coin
   threshold lets the coin count holders in constant time.
3. Missing context: looked for anything that changes supply or threshold per coin. None. A new coin
   implementation could change the threshold for later coins only.
4. Pattern-matching: no; it is arithmetic on three constants.
5. Does validation prevent it: nothing checks the floors against the supply; `_levelAt` only lowers the level.
6. Attacker control of trusted data: no attacker is involved.
7. Math proven: yes, in Phase 2.
8. Practical: it always holds. Any coin whose average passes $51M stays at level 8 or below.
9. Defence in depth: not applicable; this is a functional requirement.
10. Environment: nothing changes the arithmetic.
11. Hallucination check: constants re-read and the comparison executed (`testPoC9`).
12. Dismissing something: could burns or bankroll payouts help? Burning lowers the supply further; bankroll
    payouts count as holders but stay inside the same supply bound.
13. Invented mitigation: none. `DicesCoin` was checked for another mint path; `initialize` is the only one.

**Gates.** 1 Process: pass. 2 Reachability: pass (the condition always holds; no trigger is needed).
3 Real impact: pass (two documented levels cannot occur). 4 PoC: pass. 5 Math: pass (3,800 and 5,800 exceed
3,333). 6 Environment: pass.

`BUG #2 TRUE POSITIVE — holder floors of 3,800 and 5,800 exceed the 3,333 holders the supply and threshold allow.`

---

## BUG #3 (DICES-03): the owner-replaceable calculators are unbounded

**Step 0.** Claim: the hook applies whatever the fee calculator returns, to pools that already exist, with no
cap, no delay and no check that the split adds up; and stores whatever level the Live calculator returns.
Root cause: `_swapFee`, `_collectSwapFee` and `_syncLevel` trust their callees completely; the setters check
only that the address has code. Trigger: owner calls `setFeeCalculator` or `setLiveCalculator`. Impact: the
owner key can take up to the whole unspecified side of every swap in every pool whose liquidity is locked,
strand or block fees, or unlock any level permanently. Threat model: privileged (owner, or whoever holds its
key). Bug class: logic, access control / centralisation. Route: standard.

**Phase 1, data flow.** `setFeeCalculator` (`src/DicesHook.sol:752`) → `_setFeeCalculator` checks
`code.length != 0` (`:820`) → `feeCalculator` → `fee.amount = mulDiv(amount, feeCalculator.getSwapFee(…),
FEE_DENOMINATOR)` (`:462`) → returned as the hook delta and taken (`:472-473`). Split:
`getFeeDistribution` (`:478`) → three credits (`:479-481`), no sum check. Level: `qualify` return stored if
greater (`:438-439`). No validation anywhere on the path. The configuration is global, not snapshotted per
pool.

**Phase 2, exploitability.** Control: the owner chooses the contract. Bounds: with rate `r`, fee =
`amount × r ÷ 100,000`; `r = 100,000` gives fee = amount. A split that sums to less than the fee leaves the
remainder in the hook with no way out; one that sums to more makes the last deposit fail and the swap revert.
Race: not applicable.

**Phase 3, impact.** Under the documented trust model the owner is meant to be a Safe behind a 48-hour
timelock with "all critical financial operations enforced on-chain with caps" (`AGENT.md`, Governance). The
code has no cap and `V001` leaves the deployer as owner by default (Bug #4). Traders are protected only by
their own slippage limit. This is a primary control that is absent, not a failed second layer.

**Phase 4, PoC.** Pseudocode: `setFeeCalculator(rate = 100%)` → victim sells → receives 0 USDC. Executable:
`testPoC4_ownerCanChargeTheWholeOutputOfExistingPools` passes: a sell of 1,000,000 coins on an existing pool
returns no USDC and 14.73 USDC appears as fee credits. `testPoC10_hookStoresAnyLevelTheCalculatorReturns`
passes: the hook stores level 255 and keeps it after the calculator reports 0. Negative PoC: with the shipped
`FeeCalculator` the rate is 1,250 or 1,000 and the split sums exactly (`test/Calculators.t.sol`).

**Phase 5, devil's advocate.**
1. Other explanations: replaceable modules are a deliberate design. The issue is the missing bounds, not the
   replaceability.
2. Developer's view: the owner is meant to be a Safe behind a timelock, and the shipped calculators are
   simple and correct.
3. Missing context: looked for a cap in the hook, the interface and the calculator, and for the per-pool
   snapshot `AGENT.md` describes. Neither exists.
4. Pattern-matching: no; executed (`testPoC4`, `testPoC10`).
5. Does validation prevent it: the only check is that the address has code, which says nothing about values.
6. Attacker control of trusted data: the actor is the owner. That is why this is rated as a centralisation
   finding on owner-key misuse or compromise, not as an external exploit.
7. Math proven: fee = amount × r ÷ 100,000, so r = 100,000 takes the whole amount; shown by test.
8. Practical: one owner transaction. Traders with a slippage limit revert rather than lose, which halts
   trading instead.
9. Defence in depth: the on-chain cap the brief asks for would be the primary control, and it is absent.
10. Environment: `mulDiv` and `SafeCast` stop overflow only.
11. Hallucination check: reproduced on a real PoolManager.
12. Dismissing it because "the owner is trusted": not dismissed. Liquidity is locked, so holders of a pool
    whose fee is raised can only leave by paying it.
13. Invented mitigation: re-read `_swapFee`, `_collectSwapFee` and `_syncLevel` after concluding; no bounds.

**Gates.** 1 Process: pass. 2 Reachability: pass (reachable by the owner; privileged). 3 Real impact: pass
(the whole output of a swap can be taken, or trading halted). 4 PoC: pass. 5 Math: pass. 6 Environment: pass.

`BUG #3 TRUE POSITIVE — fee rate, fee split and level are taken from owner-set contracts with no bound or delay.`

---

## BUG #4 (DICES-04): a mainnet deployment can leave a single EOA as owner

**Step 0.** Claim: `V001` keeps the deploying wallet as owner on any chain when `PROTOCOL_OWNER` is zero;
ownership is one-step and can be renounced. Root cause: `_resolveDestinations` applies the testnet default to
mainnet for the owner only. Trigger: running the script as committed, after filling in the three mainnet
constants it does insist on. Impact: all powers in Bug #3 sit on one hot key. Threat model: operational.
Bug class: insecure default. Route: standard.

**Phase 1, data flow.** `BASE_MAINNET_PROTOCOL_OWNER = address(0)` (`script/deployment/V001.s.sol:131`) →
`protocolOwner = cfg.protocolOwner == address(0) ? deployer : cfg.protocolOwner` (`:306`), outside the
`isTestnet` block → `if (protocolOwner != deployer) hook.transferOwnership(…)` is skipped (`:244-246`) →
`_requireWiring` then asserts `hook.owner() == protocolOwner`, which is the deployer (`:512`). The mainnet
checks at `:323-325` cover fee recipient, buy-and-burn recipient and bankroll, not the owner. Ownership is
OpenZeppelin `Ownable` through `TrustedRouters` (`src/core/TrustedRouters.sol:13`): `transferOwnership` is
one step, `renounceOwnership` is available.

**Phase 2, exploitability.** No attacker needed; it is the default path. The script's own comment says so:
"The deployer stands in for an unset owner on any chain" (`:301`).

**Phase 3, impact.** Raises the likelihood of Bug #3 from "compromised multisig" to "compromised deployer
key". A mistyped address in a one-step transfer, or an accidental renounce, removes all administration
permanently, including the ability to fix a broken calculator.

**Phase 4, PoC.**
- Pseudocode: `cfg = {isTestnet: false, protocolOwner: 0, recipients and bankroll set}; run()` →
  `hook.owner() == deployer`.
- Executable: the project's own test `test_unsetOwnerKeepsTheDeployer` (`test/scripts/V001.t.sol:259-266`)
  does exactly this. Its fixture config has `isTestnet: false` (`:56`), the test sets `protocolOwner` to zero,
  runs the script and asserts `hook.owner() == DEFAULT_SENDER`, the deploying wallet. It passes.
- Negative PoC: `test_deploymentWiresTheHookAndTradesALaunchedCoin` asserts `hook.owner() == owner` when the
  constant is set (`:63`), and `test_mainnetRequiresRecipients` (`:293-310`) shows that the other three
  mainnet constants are refused when unset. Only the owner has no such requirement.
- Verification: I ran those three tests on their own; all pass. The behaviour is therefore intended by the
  script's authors, which the script's comment also says ("zero keeps the deployer", `:158`).

**Phase 5, devil's advocate.**
1. Other explanations: a deliberate convenience, so that a deployment can be handed over later.
2. Developer's view: the Safe and timelock are deferred; the test pins the behaviour on purpose.
3. Missing context: looked for an on-chain constraint on who the owner may be. The hook's constructor accepts
   any non-zero address.
4. Pattern-matching: no; the control flow was read and is executed by the project's own test.
5. Does validation prevent it: `_requireWiring` checks the owner equals the resolved value, which is the
   deployer, so it confirms the outcome rather than preventing it.
6. Attacker control of trusted data: none; it is the team's own configuration. Hence Low.
7. Math proven: not applicable.
8. Practical: it is the default path today. All four mainnet constants are zero; three are refused, the
   owner is not.
9. Defence in depth: ownership is the primary control for every privileged function.
10. Environment: none.
11. Hallucination check: the project's test asserts the behaviour.
12. Dismissing it because it is intended: intent does not remove the risk on mainnet, so it is kept.
13. Invented mitigation: checked the script and its tests for a mainnet owner requirement; there is none.

**Gates.** 1 Process: pass. 2 Reachability: pass. 3 Real impact: pass (precondition for abuse of Bug #3).
4 PoC: pass (executed by the project's own test). 5 Math: not applicable. 6 Environment: pass.

`BUG #4 TRUE POSITIVE — V001 leaves the deployer EOA as hook owner on mainnet unless a constant is changed.`

---

## BUG #5 (DICES-05): queued fees are converted at a spot price any caller can push down first

**Step 0.**
- Claim: coin-denominated fees wait in `InternalSwapPool` and are sold, on the next buy, in a position placed
  from the pool's spot price at that moment. A coin holder can sell first to lower that price, then buy back
  with exactly the USDC received. The buy-back takes the queued coins at the lowered price. The holder ends
  with the same USDC and more coins, and the fee recipients are credited less for the queue than an ordinary
  conversion would have paid.
- Root cause: the conversion price is the instantaneous `slot0` price, with no reference price and no limit
  on how much of the queue one swap may take.
- Trigger: a sell followed by a buy from the same account, when the queue is large relative to pool depth.
- Claimed impact: fee revenue is diverted or lost; bounded by the queue.
- Threat model: unprivileged. As first stated, a coin holder; after independent verification, any caller.
- Bug class: logic bug, economic / transaction ordering. No specification says at what price fees should
  convert. Route: deep.

**Phase 1, data flow.**
- 1.1 Trust boundaries. Source: the pool price, which any trader moves by swapping (untrusted). Path:
  `_beforeSwap` (`src/DicesHook.sol:350`) → `createInternalSwapPool` reads `getSlot0`
  (`src/core/InternalSwapPool.sol:168`) → range chosen from that tick (`:170-186`) → sized from the whole
  queue (`:196`) → `modifyLiquidity` (`:207`) → the swap trades through it → `closeInternalSwapPool` credits
  whatever USDC it earned (`:243-277`). Validation on the path: swap direction and a dust threshold (`:155`),
  non-zero pool liquidity (`:159`), usable tick bounds (`:190`), tick capacity (`:196`). None concerns price.
- 1.2 API contracts. The PoolManager fills a swap across all liquidity in range pro rata; nothing in v4
  protects a just-added position from being bought at spot.
- 1.3 Environment. Both legs of the manoeuvre pay the hook fee: 1.25% in USDC on the exact-input sell and
  1.25% in coin on the exact-input buy (`src/calculators/FeeCalculator.sol:33`). That raises the bar; whether
  it removes the effect is a measurement question (Phase 2).
- 1.4 Cross-references. The guidelines review flagged the same code independently as "offered at spot with no
  reference price" and could not say whether it paid. No project test or document discusses conversion price.

**Phase 2, exploitability.**
- 2.1 Attacker control. Full control of the price inside the transaction. My first reading was that the
  attacker must already hold coins to sell. That was wrong, and the independent verifier corrected it: under
  v4 flash accounting a contract can sell coins it only owes and buy them back inside one `unlock`, so no
  coins, USDC or approvals are needed (see "Independent verification" below).
- 2.2 Bounds. Not an overflow question. The economic bound, for a constant-product range with virtual USDC
  reserve `y`: lowering the price by a fraction `d` needs about `y·d/2` of volume each way, costing about
  `1.25% · y · d` in fees, and buys a queue worth `I` at a discount of about `d`, saving `I · d`. So the coin
  count rises only when `I > 1.25% · y`, that is when the queue is worth more than 1.25% of the pool's virtual
  USDC reserve. A single exact-input buy of size `B` leaves a queue worth about `1.25% · B · (y + B)/y`, so the
  condition is `B > y`: a buy larger than the pool's virtual reserve before it (about 11,700 USDC at launch,
  about 46,700 at the $200k market cap).
- 2.3 Race. None needed; both swaps can be in one transaction.
- 2.4 Adversarial view, measured (`testPoC8c_measuresOfGainAndWhoPays`), after one 30,000 USDC exact-input buy
  that leaves the buyer 663,518,715 coins and a queue of 8,398,971 coins:

  | Measure | Without the manoeuvre | With it (sell 20%, buy back with the proceeds) |
  | --- | --- | --- |
  | Holder's USDC | unchanged | unchanged |
  | Holder's coins | 663,518,715 | 665,301,980 (+1,783,265) |
  | USDC the holder would get by then selling everything | 29,520.31 | 28,844.99 (675.31 less) |
  | Credited to fee recipients for converting the queue | 1,349.46 for 8,030,698 coins, paid by an ordinary 5,000 USDC buyer | 593.18 for about the whole queue, plus 175.36 as the fee on the holder's own sell |

  So the claim holds on coin count and on what recipients receive, and fails on realisable value: a holder
  who exits afterwards is worse off, because the USDC credited to the recipients came out of the pool it
  would sell into.

**Phase 3, impact.**
- 3.1 Real impact: the fee recipients received about 0.000071 USDC per queued coin instead of about 0.000168,
  roughly 42% of the ordinary price. That is a real diversion of protocol, creator and buy-and-burn revenue.
  It is bounded by the queue, which is at most 1.25% of recent exact-input buy volume. No user funds, pool
  liquidity or escrow balance are exposed.
- 3.2 Primary control or defence in depth: there is no control on conversion price at all, so this is the
  design's behaviour rather than a failed check. The holder version has no monetary profit for the actor;
  the zero-capital version found by the independent verifier does, which is why the finding is rated Medium.

**Phase 4, PoC.**
- 4.1 Pseudocode.

  ```
  [large exact-input buy] → fee coins queued in InternalSwapPool
  attacker (holds coins):
      sell s coins            → spot price falls from P0 to P1; attacker receives U USDC
      buy with exactly U USDC → beforeSwap places the whole queue just above P1
                              → attacker's USDC buys queue coins at about P1, then pool coins back up
  result: attacker USDC unchanged, coins up; recipients credited queue × about P1 instead of queue × about P0
  ```
- 4.2 / 4.3 Executable unit tests: `testPoC8_queuedFeeInventoryIsSoldAtAPriceTheBuyerCanPushDown` (sweep of
  5% to 100% sold; coin change is positive up to 60% and peaks at 20%),
  `testPoC8b_aDifferentHolderCapturesAnotherBuyersQueuedFee` (a holder who is not the large buyer gains
  502,501 coins), `testPoC8c_measuresOfGainAndWhoPays` (the table above). All pass.
- 4.4 Negative PoC: `testPoC8_baseline_inventoryValueAtTheUnmanipulatedPrice` shows the ordinary conversion.
  The sweep also shows the precondition from the other side: selling more than about 60% of the holding makes
  the coin change negative, because fees on the larger round trip outweigh the discount.
- 4.5 Verification: the tests assert the holder's USDC is unchanged to the unit, and read coin balances and
  escrow credits directly.

**Phase 5, devil's advocate.**
1. Other explanations: this is how a spot-priced conversion behaves; the queue is exposed to price like any
   coin holding.
2. Developer's view: converting at spot is simple, needs no oracle and never blocks a swap. Reasonable, and
   inherited from the launchpad this design was adapted from.
3. Missing context: none found that sets a floor. The Live calculator's average is not consulted.
4. Pattern-matching: it started as one. It was then measured.
5. Does validation prevent it: the checks on the path do not look at price.
6. Attacker control of trusted data: the price is public market state, not trusted data.
7. Math: the condition `I > 1.25% · y` was derived and the measured sweep agrees with its shape.
8. Practical: only after a buy larger than the pool's virtual reserve. For the holder version, only for
   someone with a large position; the zero-capital version needs no position.
9. Defence in depth: not applicable; no primary control exists.
10. Environment: the two 1.25% fees limit it and do not remove it.
11. Hallucination check: the coin gain is real and reproduced. The first reading of the holder version as
    "profit" was too strong: measured against realisable USDC the holder loses 675 USDC. The finding is
    worded accordingly, and the money profit it reports is the zero-capital version's.
12. Dismissing a real issue: the opposite danger. Recipients do lose more than half the queue's ordinary
    value in the test, whatever the actor's motive, so it is kept as a finding rather than rejected.
13. Invented mitigations: re-read `createInternalSwapPool`; there is no price check.

**Gates.** 1 Process: pass. 2 Reachability: pass (any holder with enough coins, one transaction). 3 Real
impact: pass (fee revenue reduced; bounded). 4 PoC: pass. 5 Math: pass (the condition can be met and was).
6 Environment: pass (fees raise the bar only).

**Independent verification.** This bug was also given to a separate verifier with the claim and the code
locations, and without my tests or figures. It ran the skill's deep route itself and wrote its own eleven
tests ([`poc-tests-verify05.md`](poc-tests-verify05.md)). I re-ran them; all pass. Its result agrees with the
record above on the holder version (same coin gain of 1,783,265; 675.30 USDC less on selling everything) and
goes further in three ways:

1. **No position is needed.** A contract with no coins, no USDC and no approvals sells 436.7M coins it only
   owes and buys them back in one `unlock`, and is paid **470.38 USDC**
   (`test_2_zeroInventoryVariant_paysOutUsdc`). The same result holds with the coin as currency1 (`test_4`)
   and with no extra USDC in the PoolManager (`test_5b`, which also asserts the escrow stays fully funded and
   the swap pool holds exactly its queue).
2. **The threshold is measured.** The caller profits only after one exact-input buy that multiplies the price
   by about 4.5 or more: from launch, 13,000 USDC loses 1.18 and 13,500 gains 1.58 (`test_5c`). The sweep in
   `test_3a` gives +107.46 after a 20,000 buy, +470.38 after 30,000, +2,024.95 after 50,000 and +5,361.49
   after 75,000. After ordinary flow has converted the queue every size loses (`test_3b`). Selling more than
   the coins outstanding converts nothing and loses the fee, because of the zero-liquidity guard (`test_3c`).
3. **Who pays depends on what follows.** If a 5,000 USDC buy follows, the fee recipients end 523.04 USDC
   short and holders are unaffected. If nobody buys, the pool's USDC is 1,296.81 lower and the large buyer
   could realise 1,175.89 less.

Its derivation of the condition matches mine in form: with `X = L/√P` and fee rate `f`, the profit is
positive only when the queue exceeds about `1.13 · f · X`; for one buy that ratio is `√(price multiple) − 1`,
independent of the fee rate. Predicted best case for the 30,000 USDC buy: 37.3% of the queue. Measured: 35.1%.

Its devil's-advocate answers and gate review were made separately from mine and reach the same result: all
six gates pass. Its severity recommendation is Low, rising to Medium if large first-block buys are routine.
`findings.md` rates it Medium and says why.

### Independent verifier's record for Bug #5, in full

What follows is the record the separate verifier returned, kept as it was written apart from layout. It is
included so that this log holds the second verification complete rather than in summary. Where it speaks of
"the reviewer" or "the claim", it means the claim as I first stated it.

**Lead result.** TRUE POSITIVE, with three corrections to the claim:

1. No coin position is needed. A contract holding no coins, no USDC and no approvals can sell coins it only
   owes and buy them back inside one `unlock`. It was paid 470.38 USDC in the test.
2. The holder version is only profitable on coin count. Same USDC and 1,783,265 more coins is real, but
   selling everything afterwards realises 675.30 USDC less than selling without the manoeuvre, and the holding
   marked at spot falls 3,589.95. It only turns positive in dollars if ordinary buying follows (+316.04).
3. It works only above a threshold. The queue must exceed about 1.13 × fee rate × pool depth (L/√P). That
   takes one unconverted exact-input buy that multiplies the price about 4.5 times or more, which from launch
   is at least about 13,500 USDC, or 39% of the sale. Below that, and in all ordinary flow tested, every size
   loses.

Who pays depends on what happens next: if a buyer follows, the fee recipients do; if nobody buys, the
holders' exit liquidity does.

**Step 0.** Claim: coin-denominated fees wait in `InternalSwapPool` and are sold on the next buy at whatever
`slot0` reads then, so pushing the price down first buys the queue cheaply. Root cause: no reference price or
floor on the conversion. Trigger: a sell followed by a buy, in one transaction or two. Impact: USDC leaves the
system to the caller and recipients are credited less. Threat model: any unprivileged address after the
launch block. Bug class: logic / economic (spot-price dependence), no formal specification. Route: deep.

**Phase 1, data flow.**
- 1.1 Path: untrusted swap caller → `_beforeSwap` (`src/DicesHook.sol:325-358`) → `createInternalSwapPool`
  (`src/core/InternalSwapPool.sol:146-214`) → swap → `_afterSwap` (`src/DicesHook.sol:372-386`) →
  `closeInternalSwapPool` (`InternalSwapPool.sol:226-279`) → `FeeEscrow.deposit`. The fee is charged in the
  unspecified currency (`DicesHook.sol:458-463`); a coin fee is queued (`:474-476`,
  `InternalSwapPool.sol:127`). The position is placed from `getSlot0` (`:168`), one spacing wide next to spot
  (`:170-186`), sized to the whole queue (`:196`). Checks on the path: launch-block router check
  (`DicesHook.sol:334`), minimum inventory (`InternalSwapPool.sol:155`), zero-liquidity guard (`:159`),
  usable ticks (`:190`). None constrains price.
- 1.2 API contracts: `slot0` is instantaneous. The pool's LP fee is 0 (`DicesHook.sol:564`), so the hook fee
  is the only friction. v4 flash accounting allows selling coins that are only owed.
- 1.3 Environment: `lastSwapBlock` is written (`DicesHook.sol:339`) but nothing in `src` reads it. The 1.25%
  fee on each leg is the only deterrent.
- 1.4 Cross-reference: existing tests check that conversion happens, not its price
  (`test/DicesHookTrading.t.sol:173`, `test/InternalSwapPool.t.sol:98`, `:183`). The project defends against
  same-block manipulation elsewhere (`src/DicesCoin.sol:163-170`, the 24-hour average in `LiveCalculator`),
  so this is inside its own threat model.

**Phase 2, exploitability.**
- 2.1 Attacker control: full: swap direction, size and ordering. The bot in the test is an untrusted direct
  caller of the PoolManager.
- 2.2 Math: let `X = L/√P`, `f` the fee rate, `Q` the queue, `k` the fraction the square-root price is pushed
  to. Profit ≈ `P₀·[Q(1−k²) − 2fX(1−k)]`, less small terms for the range premium and the queue's own price
  impact. It is positive only if `Q/(fX) > 1`; the best is at `k = fX/Q`, giving about `Q·P₀·(1 − fX/Q)²`.
  For one buy, `Q/(fX) = √(price multiple) − 1`, independent of `f`. Predicted for the 30,000 USDC case:
  37.3% of the queue (499 USDC). Measured: 35.1% (470.38). Predicted break-even ratio 1.0; measured 1.11 to
  1.16.
- 2.3 Timing: no race. It must land before ordinary buys worth about the queue arrive; a 200 USDC buy
  converted only 523,182 of 8,398,971 coins.
- 2.4 Adversarial: a backrunner or the large buyer can do it. The guard at `:159` only stops the price
  leaving liquidity entirely.

**Phase 3, impact.**
- 3.1 Real and financial: USDC is withdrawn by an unprivileged caller. There is no insolvency: the escrow
  stays fully funded and the swap pool holds exactly its queue (asserted in `test_5b`).
- 3.2 This is the primary control being insufficient, not defence in depth. Nothing else protects the
  conversion price.

**Phase 4, PoC.**
- 4.1 Pseudocode and data flow:

  ```
  large exact-input buy ──► coin fee Q queued (deposit :127)
  attacker: unlock {
    swap(sell c coins, exact-in)      // price P0 → P1, USDC fee to recipients
    swap(buy c coins, exact-out)      // beforeSwap: whole Q placed at [P1, P1·1.006] (:168-207)
                                      // afterSwap: Q sold at ~P1, proceeds credited (:239-277)
    coin delta == 0; take(USDC left over)
  }
  ```
- 4.2 / 4.3 Measured. Starting state: one 30,000 USDC exact-input buy, market cap 159,358, queue 8,398,971
  coins (1,338.44 at spot), ratio 2.57. An ordinary 5,000 USDC buy converts the whole queue for 1,349.45.

  | Scenario | Attacker | Queue credited | Recipients in total |
  | --- | --- | --- | --- |
  | Ordinary 5,000 USDC buy | n/a | 1,349.45 | 1,349.45 |
  | Holder sells 132.7M coins (20%), buys back with 13,853.59 | +1,783,265 coins, USDC unchanged | 593.18 | 1,030.81 after a following 5,000 buy (−318.64) |
  | Zero inventory, 436.7M coins sold and rebought | **+470.38 USDC** | 188.58 | 826.41 (−523.04) |

  Do the two fees eat the gain? Not at this ratio: every holder sell size from 5% to 60% gains coins; 65%
  and above lose. The manoeuvre's own fees, separated: holder 175.36 USDC plus 1,702,367 coins re-queued;
  zero-inventory 637.83 USDC. Measures for the holder: coins at constant USDC +1,783,265 (about 284 USDC);
  sell everything now −675.30; marked at spot −3,589.95; with a following 5,000 buy, sell-all +316.04.
  Third-party holder using all 100M of its coins: +1,667,031 coins, but sell-all −265.00. Zero-inventory
  aftermath: pool USDC falls from 30,000 to 28,703.19; if nobody buys afterwards the large buyer's sell-all
  value drops 1,175.89; if a 5,000 buy follows, recipients are down 523.04 and the large buyer is up 48.32.
  Robustness: the same 470.38 with the coin as currency1 and without the extra manager USDC; at a 1.00% rate
  380.65 (35.5% of the queue). An honest sell of the same coins followed by an ordinary buyer also credits
  593.18, so the inventory always carries price risk; the manoeuvre makes it atomic and paid.
- 4.4 Negative PoC:

  | One exact-input buy from launch | Ratio | Best zero-inventory result |
  | --- | --- | --- |
  | 1,000 to 11,000 USDC | 0.09 to 0.94 | −0.53 to −5.74 |
  | 13,000 (price × 4.46) | 1.11 | −1.18 |
  | 13,500 (price × 4.65) | 1.16 | +1.58 |
  | 20,000 | 1.71 | +107.46 (15.8% of queue) |
  | 34,000 | 2.91 | +674.96 (40.6%) |
  | 50,000 / 75,000 (into the upper position) | 5.2 / 8.0 | +2,024.95 (56.8%) / +5,361.49 (67.0%) |

  After one ordinary 5,000 USDC buy the ratio is 0.12: best −54.80, and holder round trips lose 1.3M to
  10.2M coins. After each of five further 500 USDC buys the ratio is 0.01: −62 to −69. Selling 110% of
  outstanding coins: −750.00 with nothing converted (guard at `:159`). A large exact-output buy pays 352.29
  in USDC and queues nothing: best −45.88.
- 4.5 Does the PoC show what it claims? Yes. Conversion proceeds are separated from direct fees by the
  escrow `Deposited` depositor. The bot's coin delta is required to be zero. The payout equals the manager's
  USDC decrease minus the credits. All 11 tests pass.

**Phase 5, devil's advocate.**
1. Other explanation? Selling fees into buys at market is the intended design. True, but it does not explain
   a riskless payout.
2. Developers' justification? Inventory always carries price risk and fees deter round trips. That holds
   only below the threshold.
3. Missing architecture context? Looked for a price reference, cooldown or sender check on this path and
   found none; `sender` is unused.
4. Pattern-matching? No; it is measured, with USDC landing in a separate address.
5. Does existing validation prevent it? The zero-liquidity guard stops only the degenerate case (−750
   measured).
6. Trusted data assumed attacker-controlled? `slot0` is moved by the attacker's own swap. The queue size is
   not attacker-controlled without cost.
7. Math proven? Yes; the algebra and the sweep agree to within 6%.
8. Practical? Yes when the state exists: one transaction, no capital. The state itself is uncommon.
9. Defence in depth confused with primary? No; there is no other control on conversion price.
10. Platform protections? None apply; ordering on the target chain does not stop a backrun.
11. Hallucinated? The reviewer's holder framing was partly overstated, but the underlying extraction is
    reproduced.
12. Dismissing because it is complex? No; the zero-inventory form is simpler and stronger than the claim.
13. Invented mitigations? Re-read `InternalSwapPool.sol:146-279` and `DicesHook.sol:325-386` after
    concluding. `lastSwapBlock` is not enforced anywhere.

**Gate review.**

| Gate | Result | Reason |
| --- | --- | --- |
| 1 Process | PASS | Every phase has code or measured evidence |
| 2 Reachability | PASS | Unprivileged caller, both orderings, one or two transactions |
| 3 Real impact | PASS | 470.38 USDC withdrawn; recipients 523.04 short |
| 4 PoC | PASS | Executable, with negative cases and accounting assertions |
| 5 Math bounds | PASS | Condition is reachable above ratio ≈ 1.13; impossible below |
| 6 Environment | PASS | Nothing blocks it once the precondition holds |

Verifier's verdict: `BUG #5 TRUE POSITIVE — a zero-capital caller can depress spot and buy the queued fee
inventory cheaply, but only after one exact-input buy that moved the price about 4.5× or more; the "holder
ends with more coins" framing is profitable on coin count only.`

Verifier's severity: Low. Not higher because the value at stake is a fraction of one buy's fee inventory
(about 35 to 41% of its spot value within the sale range), no principal is taken, nothing becomes insolvent,
ordinary trading never creates the precondition and an attacker cannot manufacture it at a profit. Not
informational because, once the state exists, it is permissionless, atomic and repeatable. Would be Medium
if large creator buys in the launch block are expected to be routine.

### Lead reviewer's reconciliation of the two records for Bug #5

Gates after the independent result: 1 Process: pass. 2 Reachability: pass, and wider than first recorded
(any caller). 3 Real impact: pass (USDC withdrawn by an unprivileged caller; recipients short). 4 PoC: pass
(two independent sets). 5 Math: pass (reachable above the measured threshold, impossible below it).
6 Environment: pass.

`BUG #5 TRUE POSITIVE — after one large exact-input buy, any caller can push the spot price down inside a single unlock, buy the queued fee coins cheaply and keep the difference in USDC; confirmed by two independent sets of tests.`

---

## BUG #6 (DICES-06): the launch-block guard does not stop users of a trusted router

**Step 0.** Claim: the guard exempts any swap whose router is trusted, and the deployment trusts the public
Universal Router, so anyone can buy in the launch block. Root cause: one allow-list serves two purposes.
Trigger: buy through the Universal Router in the block a coin launches. Impact: the stated protection
("prevents bots from buying in the same block as launch, unless token creator", `src/DicesHook.sol:328`) is
not provided. Threat model: unprivileged. Bug class: logic, access control. Route: standard.

**Phase 1, data flow.** `sender` = router address supplied by the PoolManager → `if (launchBlock[poolId] ==
block.number && !trustedRouters[sender]) revert` (`:334`). `trustedRouters` is set by the owner
(`src/core/TrustedRouters.sol:25`); `V001` sets it for the Universal Router
(`script/deployment/V001.s.sol:238`) and requires it (`:516`). No check involves the creator or the swap
direction. `_getSender`, which would identify the caller, is evaluated only afterwards and its result is
unused (`:350`, `src/core/InternalSwapPool.sol:146`).

**Phase 2, exploitability.** Control: full; the Universal Router is open to everyone.

**Phase 3, impact.** No funds are taken. The effect is fairness at launch: the first buyer in the launch
block gets the lowest price. The guard would only ever cover one block; from the next block anyone can buy.

**Phase 4, PoC.** Pseudocode: `createCoin` → in the same block, sniper calls the trusted router → swap
succeeds. Executable: `testPoC2_anyUserOfATrustedRouterBuysInTheLaunchBlock(bool)`, both orderings, passes: an
account that is neither creator nor deployer buys 72.7M coins for 1,000 USDC in the launch block. Negative
PoC, in the same test: the same buy through an untrusted router reverts with `CannotBuyZeroBlock`.

**Phase 5, devil's advocate.**
1. Other explanations: the exemption may be meant for a dedicated launch router. A second comment says "only
   approved launching routers may swap in the launch block" (`src/DicesHook.sol:332`), and the project's
   activity script relies on it.
2. Developer's view: trusting the Universal Router is needed to read `msgSender()`, and one list is simpler
   than two.
3. Missing context: looked for a creator comparison or a second list. Neither exists, and the `_getSender`
   result is unused.
4. Pattern-matching: no; executed (`testPoC2`).
5. Does validation prevent it: the check exists but is keyed on the router, so it cannot stop that router's
   users.
6. Attacker control of trusted data: the allow-list is owner-set, but the entry in question is written by the
   deployment script itself.
7. Math proven: not applicable.
8. Practical: any Universal Router swap in the launch block.
9. Defence in depth: the guard is itself a secondary fairness measure, which is why this is rated Low.
10. Environment: nothing about block ordering on the target chain prevents a same-block buy.
11. Hallucination check: reproduced.
12. Dismissing it as fairness only: it also creates the state Bug #5 needs. Recorded under exploit chains.
13. Invented mitigation: none found on re-reading `_beforeSwap`.

**Gates.** 1 Process: pass. 2 Reachability: pass (any user of the trusted router). 3 Real impact: pass
(a stated protection is absent; fairness at launch, and a precondition for Bug #5). 4 PoC: pass. 5 Math: not
applicable. 6 Environment: pass.

`BUG #6 TRUE POSITIVE — as deployed, any user of the Universal Router can buy in a coin's launch block.`

---

## BUG #7 (DICES-07): the calculator fail-safe has two holes

**Step 0.** Claim: (a) the `try` around `qualify` does not catch return data that fails to decode, so a
calculator that returns the wrong shape reverts every swap; (b) the hook stores any `uint8`, including values
above 10. Root cause: Solidity decodes `try` return data in the caller; no bound on the level. Trigger: owner
sets a wrong contract as Live calculator. Impact: all swaps in all pools revert until the owner replaces it;
or a pool is stuck at a meaningless level forever. Threat model: owner error. Bug class: logic, DoS. Route:
standard.

**Phase 1, data flow.** `_setLiveCalculator` checks `code.length != 0` only (`src/DicesHook.sol:833`) →
`try liveCalculator.qualify(_poolKey) returns (uint8 level)` (`:436`) → decode in the hook's frame → `catch {}`
(`:448`) covers only a revert inside the callee. `_syncLevel` is reached from every swap (`:382`) and from
`syncLevel`. Language rule: a decoding failure in a `try` statement is an exception in the calling contract
and is not caught.

**Phase 2, exploitability.** Requires the owner to set a contract that answers `qualify`'s selector with fewer
than 32 bytes or with a word above 255, for example any contract with a silent fallback. Bounds: `level >
unlocked` is the only comparison; 255 passes.

**Phase 3, impact.** Total halt of trading across the protocol until corrected. Recoverable by the owner; not
recoverable if ownership was renounced (Bug #4). `AGENT.md` promises "a reverting calculator leaves the level
as it is and never blocks a swap", which integrators would read as "a bad calculator cannot stop trading".

**Phase 4, PoC.** Executable: `testPoC3_calculatorReturningMalformedDataBlocksEverySwap` passes. It first
shows a reverting calculator is tolerated (the control), then that a calculator returning the word 256, and
one returning nothing, each make buys, sells and `syncLevel` revert. `testPoC10_…` covers (b).

**Phase 5, devil's advocate.**
1. Other explanations: `try`/`catch` is the usual idiom, and the decode edge is easy to overlook.
2. Developer's view: calculators are deployed by the team, so a wrong address is an operational mistake.
3. Missing context: looked for an interface or identity check when the calculator is set. There is none.
4. Pattern-matching: no; executed (`testPoC3`, `testPoC10`).
5. Does validation prevent it: the code-length check does not; any contract with a fallback has code.
6. Attacker control of trusted data: none; it needs an owner mistake. Hence Low.
7. Math proven: the only comparison is `level > unlocked`, which 255 passes.
8. Practical: it needs the mistake, and then halts all trading until corrected.
9. Defence in depth: the `try` is the defence, and it is incomplete.
10. Environment: Solidity decoding return data in the caller is the cause, not a protection.
11. Hallucination check: reproduced.
12. Dismissing something: no. If ownership has been renounced the halt is permanent.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass, with a privileged precondition (the owner sets a wrong
contract). 3 Real impact: pass (all trading halts until corrected). 4 PoC: pass. 5 Math: pass (255 passes the
only comparison). 6 Environment: pass.

`BUG #7 TRUE POSITIVE — a calculator that returns malformed data reverts every swap, and any uint8 level is stored.`

---

## BUG #8 (DICES-08): the swap pool keeps its own fee calculator

**Step 0.** Claim: `InternalSwapPool.feeCalculator` is immutable while `DicesHook.feeCalculator` is
replaceable, so after `setFeeCalculator` the split applied to converted coin fees differs from the split
applied to USDC fees. Root cause: two references to what the design treats as one module. Trigger: any
calculator replacement. Impact: recipients are paid by two different rules; a change of split takes effect on
roughly half of fee flow. Threat model: owner action, unintended consequence. Bug class: logic. Route:
standard.

**Phase 1, data flow.** Hook: `feeCalculator.getFeeDistribution` (`src/DicesHook.sol:478`), replaceable
(`:752`). Swap pool: `IFeeCalculator public immutable feeCalculator` (`src/core/InternalSwapPool.sol:75`), set
in the constructor (`:113`), used at `:265`. The hook's `internalSwapPool` has no setter. `_requireWiring` does
not compare the two (`script/deployment/V001.s.sol:510-532`).

**Phase 2, exploitability.** Happens on every replacement; no attacker.

**Phase 3, impact.** Accounting inconsistency between recipients. No theft: every unit is still credited to
one of the three recipients.

**Phase 4, PoC.** Executable: `testPoC5_swapPoolKeepsTheOldSplitAfterTheCalculatorIsReplaced` passes: after
the owner installs a split that gives everything to the protocol, a USDC-fee swap credits the creator nothing,
and the next conversion still credits the creator 0.30 USDC and the buy-and-burn recipient the same. Negative
PoC: before any replacement both paths use the same contract and agree.

**Phase 5, devil's advocate.**
1. Other explanations: the reference is immutable to save a storage read on every swap, as the comment at
   `src/core/InternalSwapPool.sol:52` says.
2. Developer's view: at deployment both point to the same calculator, and a test pins the immutability.
3. Missing context: looked for a way to re-point the swap pool or to have it read the hook's calculator.
   Neither exists.
4. Pattern-matching: no; executed (`testPoC5`).
5. Does validation prevent it: nothing compares the two references, on chain or in `_requireWiring`.
6. Attacker control of trusted data: none; it follows from an owner action.
7. Math proven: not applicable.
8. Practical: it happens on every calculator replacement.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: reproduced.
12. Dismissing something: no funds are lost, but recipients are paid by two rules, so it is kept as Low.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (every calculator replacement). 3 Real impact: pass
(recipients paid by two different splits). 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #8 TRUE POSITIVE — after a calculator replacement, converted fees keep the old split.`

---

## Rejected candidates

Each record has the same phases as the bugs above. "Negative PoC" is the evidence that the path does not
exist; for a rejected candidate it is the main result.

### R-01: a swap can succeed while `qualify` runs out of gas, skipping an observation

**Step 0.** Claim: the caller picks a gas limit such that `liveCalculator.qualify` gets too little gas and
fails inside the `try`, while the 1/64 the hook keeps is enough to finish. The price would then move without
the history recording it, and the average would keep accruing the old tick. Class: logic, gas. Route: deep.

**Phase 1, data flow.** Source: the transaction gas limit, attacker-chosen. Path: router → PoolManager →
`_afterSwap` → `try liveCalculator.qualify(...)` (`src/DicesHook.sol:436`); after the `catch` the hook still
runs `_emitHookSwap` and `UniswapEvents.emitPoolStateUpdate` (`:383-384`) and returns. API contract: EIP-150
forwards at most 63/64 of the gas at each call. Environment: none beyond that rule. Cross-reference: no
project test covers gas starvation.

**Phase 2, exploitability (bounds).** Attacker control: full control of the gas limit. Let `G` be the gas in
the hook at the `try`, `Q` what `qualify` needs and `R` what the hook needs afterwards. Starvation needs
`63G/64 < Q` and `G/64 ≥ R`, so `R < Q/63`. The most expensive `qualify` measured is 206,856 gas (a call after
more than a day of silence, writing all 25 checkpoints), so `R` would have to be under about 3,300 gas. Two
library calls, two `extsload` reads and two events cost more than that. Race: not applicable.

**Phase 3, impact.** If it were possible it would matter: a pump could be recorded and the matching dump
hidden. It would be a primary-control failure of the oracle.

**Phase 4, PoC.** Pseudocode: `for g in gasLimits: ok = router.swap{gas: g}(); if ok and oracle.observedAt !=
now: starvation`. Executable: `testPoC6_gasStarvationCannotSkipAnObservation` sets up the worst case, finds by
binary search the smallest gas limit at which the swap succeeds (571,464), confirms the observation is
recorded at that limit, then scans in steps of 16 gas from 2,000 below to 12,000 above it and in steps of 6,000
up to 1.5M. Negative PoC: that scan is the negative result: zero gas limits where the swap succeeded without
an observation. Verification: the test reads `oracles(poolId).observedAt` after each attempt and reverts state
between attempts.

**Phase 5, devil's advocate.** 1 Other explanations: none needed. 2 Developer's view: the comment says a
calculator fault must not block a swap; gas safety was not claimed, so it needed checking. 3 Missing context:
none. 4 Pattern only: it looked dangerous; measurement says otherwise. 5 Validation: the protection is
arithmetic, the hook's tail costs more than 1/64 of a starved call. 6 Trusted data: none involved. 7 Math:
bound derived and measured. 8 Practical: no. 9 Defence in depth: not applicable. 10 Environment: EIP-150 is
the protection. 11 Hallucination: not a real issue today. 12 False negative: the margin depends on `Q`; a
future calculator costing roughly 500,000 gas or more per call could reopen it. Recorded in DICES-07's
recommendation. 13 Invented mitigation: none; measured.

**Gates.** 1 Process: pass. 2 Reachability: FAIL. 3 Real impact: would pass if reachable. 4 PoC: pass (the
PoC shows the attack does not work). 5 Math: FAIL (the condition cannot be met). 6 Environment: FAIL (EIP-150
arithmetic prevents it).

`R-01 FALSE POSITIVE — the hook's remaining work after the try costs more than 1/64 of any gas amount that starves qualify.`

### R-02: Slither `arbitrary-send-erc20` in `CurrencySettler.settle`

**Step 0.** Claim: anyone can make the library pull tokens from an arbitrary `payer`. Class: access control.
Route: standard.
**Phase 1.** Source: the `payer` argument. The library is `internal`
(`src/libraries/CurrencySettler.sol:29`); its single call site passes `address(this)`
(`src/DicesHook.sol:614`), so line 41 is never executed. API contract and environment: not relevant.
Cross-reference: a search of `src/` for `.settle(` finds that one call.
**Phase 2.** Attacker control of `payer`: none. Bounds and race: not applicable.
**Phase 3.** Real impact: none, the branch is dead code (recorded in DICES-16). Primary control or defence
in depth: neither is in question, because nothing reaches the branch.
**Phase 4.** Pseudocode: there is no external entry that reaches `safeTransferFrom(payer, …)` with a
caller-chosen `payer`. Executable: skipped, because there is no call to construct. Negative PoC: the call
site at `:614`. Verification: search for other callers returned none.
**Phase 5.** 1 Other explanation: a general-purpose settler with a `payer` parameter. 2 Developer's
view: it mirrors Uniswap's settler signature. 3 Missing context: the library is internal with one caller.
4 Pattern-matching: yes, that is all it is. 5 Validation: the caller passes `address(this)`. 6 Attacker
control: none. 7 Math: not applicable. 8 Practical: no path. 9 Defence in depth: not applicable.
10 Environment: not applicable. 11 Hallucination: the detector's, not a real issue. 12 False negative:
searched every use of the library; the only other one is `take` at `src/DicesHook.sol:473`. 13 Invented
mitigation: none.
**Gates.** 1 Process: pass. 2 Reachability: FAIL. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: not applicable. 6 Environment: pass.

`R-02 FALSE POSITIVE — the transferFrom branch is unreachable; the only caller passes address(this).`

### R-03: Slither `reentrancy-eth` in `_afterSwap`

**Step 0.** Claim: an external call in `_afterSwap` re-enters and exploits `poolLevel` being written last.
Class: reentrancy. Route: standard.
**Phase 1.** Callees: the swap pool (immutable code), the PoolManager, USDC, the escrow (`nonReentrant`,
`src/core/FeeEscrow.sol:34`) and the two calculators (owner-set). `hookData` reaches no external call that
executes attacker code. A trusted router is called with `staticcall` only
(`src/core/TrustedRouters.sol:44`). Cross-reference: the Uniswap review traced the same calls and found no
re-entry point.
**Phase 2.** Attacker-controlled callee: none. `poolLevel` only increases (`src/DicesHook.sol:438`), so a
re-entrant read would see a value that is at most stale-low. Bounds and race: not applicable.
**Phase 3.** Real impact: none without a re-entry point. Primary control or defence in depth: the primary
protection is that no callee is attacker-supplied; the escrow's guard is a second layer and is present.
**Phase 4.** Pseudocode: no step exists at which attacker code runs between the calls; the ETH-sending line
(`:736`) is reached only for currency `address(0)`, which a USDC pool fee never is. Executable: skipped, no
attacker-controlled callee to deploy. Negative PoC: the callee list above. Verification:
`invariant_everyUnlockFinishesSettledAndSupplyIsConserved` holds across the handler's swaps.
**Phase 5.** 1 Other explanation: state written after a call is flagged whatever the callee is.
2 Developer's view: the order is deliberate, so that the swap that reaches Live pays the old rate.
3 Missing context: every callee is fixed code or owner-set, and the router is called with `staticcall`.
4 Pattern-matching: yes. 5 Validation: the escrow is `nonReentrant` and the level only ratchets up.
6 Attacker control: none over any callee. 7 Math: not applicable. 8 Practical: no. 9 Defence in depth: not
applicable. 10 Environment: `staticcall` stops a router changing state. 11 Hallucination: the detector's.
12 False negative: considered USDC as a callee (no transfer hooks) and a malicious calculator (that is
Bug #3, not reentrancy). 13 Invented mitigation: the guard on `FeeEscrow.deposit` was read at `:34`.
**Gates.** 1 Process: pass. 2 Reachability: FAIL. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: not applicable. 6 Environment: pass.

`R-03 FALSE POSITIVE — every callee is fixed or owner-set, and the late write is a monotonic ratchet.`

### R-04: Slither `weak-prng` in `LiveCalculator._average`

**Step 0.** Claim: a modulo of a block value is used as randomness. Class: crypto. Route: standard.
**Phase 1.** `src/calculators/LiveCalculator.sol:322` indexes a 25-slot ring by hour number; `:331` tests a
division remainder to round toward negative infinity. Nothing downstream treats either as unpredictable.
**Phase 2.** No attacker benefit from choosing the hour; bounds and race not applicable.
**Phase 3.** Real impact: none; no decision depends on unpredictability. Primary control or defence in
depth: not applicable.
**Phase 4.** Pseudocode: not applicable, there is no random draw to bias. Executable: skipped for that
reason. Negative PoC: the two lines themselves. Verification: `test/Calculators.t.sol` checks the average
against a direct computation.
**Phase 5.** 1 Other explanation: a ring-buffer index and a floor-division correction. 2 Developer's
view: standard arithmetic. 3 Missing context: none. 4 Pattern-matching: yes. 5 Validation: not applicable.
6 Attacker control: none that matters; the hour is public. 7 Math: not applicable. 8 Practical: no.
9 Defence in depth: not applicable. 10 Environment: not applicable. 11 Hallucination: the detector's.
12 False negative: checked that no value derived from either line is used as a choice or a seed.
13 Invented mitigation: none.
**Gates.** 1 Process: pass. 2 Reachability: n/a. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: not applicable. 6 Environment: pass.

`R-04 FALSE POSITIVE — the modulo is an index and a rounding test, not a random number.`

### R-05: the stored position state can be left behind or picked up by another swap

**Step 0.** Claim: `_internalSwapPoolState`, one struct shared by all pools and kept in ordinary storage, can
survive past its swap or be consumed by a different pool's `afterSwap`. Class: logic, state machine. Route:
standard, escalated to deep reasoning because it crosses the hook, the swap pool and the PoolManager.
**Phase 1.** Written at `src/core/InternalSwapPool.sol:212` in `beforeSwap`, read and deleted at `:233-234`
in the same swap's `afterSwap`. Between the two, `PoolManager.swap` runs `Pool.swap`, which makes no external
call. API contract: the PoolManager calls `beforeSwap`, swaps, then calls `afterSwap` in one frame.
Environment: a revert anywhere in that frame undoes the write. Cross-reference: the Uniswap review and the
swap-pool context review reached the same conclusion separately.
**Phase 2.** For another swap to interleave, attacker code would have to run between the callbacks. The only
external calls in that window are the PoolManager's own callbacks to the hook for the swap pool's
`modifyLiquidity`. The hook never swaps, so its callbacks are never skipped for a swap. Bounds and race: not
applicable.
**Phase 3.** Real impact: none, since the sequence cannot occur. If it could, deltas would be attributed to
the wrong pool, so this would be a primary-control failure; that is why it was traced fully.
**Phase 4.** Pseudocode: `beforeSwap(A) → [attacker code] → beforeSwap(B)` has no reachable middle step.
Executable: skipped; there is nothing to call. Negative PoC:
`invariant_everyUnlockFinishesSettledAndSupplyIsConserved` and the trading fuzz tests assert zero residual
deltas after every swap. Verification: read `PoolManager.swap` in `lib/` to confirm the call order.
**Phase 5.** 1 Other explanation: per-swap state kept in storage for simplicity. 2 Developer's view:
the two calls are always paired inside one swap. 3 Missing context: the PoolManager's call order, and that
`unlock` cannot be nested (it reverts when already unlocked). 4 Pattern-matching: it looks fragile.
5 Validation: the `removeJitLiquidity` flag and the delete at `:234`. 6 Attacker control: none inside the
window. 7 Math: not applicable. 8 Practical: no. 9 Defence in depth: not applicable. 10 Environment: a
revert undoes the write. 11 Hallucination: not a real issue. 12 False negative: considered a router that
catches a failed swap and continues, the hook swapping, and two swaps in one unlock (they are sequential,
each with its own pair of callbacks). 13 Invented mitigation: `PoolManager.swap` was read to confirm.
**Gates.** 1 Process: pass. 2 Reachability: FAIL. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: not applicable. 6 Environment: pass.

`R-05 FALSE POSITIVE — nothing untrusted runs between the two callbacks, and a failed swap reverts the write.`

### R-06: the swap pool, or a third party, can remove the hook's launch liquidity

**Step 0.** Claim: allowing `internalSwapPool` through `beforeRemoveLiquidity` opens the lock. Class: access
control. Route: standard.
**Phase 1.** `_beforeRemoveLiquidity` admits only the swap pool (`src/DicesHook.sol:303`). API contract: the
PoolManager keys a position by its caller (`owner: msg.sender` in `modifyLiquidity`), so the swap pool can
only touch positions it created, and it only ever removes the exact liquidity it added in the same swap
(`src/core/InternalSwapPool.sol:239`). The hook's only `modifyLiquidity` call has a positive delta (`:715`).
**Phase 2.** No path; bounds and race not applicable.
**Phase 3.** Real impact: none; the lock holds. Primary control or defence in depth: the PoolManager's
owner-keyed positions are the primary control; the hook's callback check is a second layer for third parties.
**Phase 4.** Pseudocode: `swapPool.modifyLiquidity(hook's ticks, -L, salt 0)` would address a position owned
by the swap pool, which does not exist, and revert. Executable: covered by the project's own test
(`test/DicesHook.t.sol:386-402`). Negative PoC: `invariant_launchPositionsCannotBeRemoved`. Verification:
both pass in the baseline run.
**Phase 5.** 1 Other explanation: the swap pool must be able to remove its own position. 2 Developer's
view: the comment at `src/DicesHook.sol:300` says positions are keyed to the caller. 3 Missing context: the
position key includes the owner. 4 Pattern-matching: yes. 5 Validation: the PoolManager's owner-keyed
positions. 6 Attacker control: none. 7 Math: not applicable. 8 Practical: no. 9 Defence in depth: not
applicable. 10 Environment: enforced by the PoolManager. 11 Hallucination: not a real issue. 12 False
negative: the callback would not stop the hook itself, because the PoolManager skips callbacks for the
hook's own calls; the lock rests on the hook having no removal code. True today; recorded under DICES-16.
13 Invented mitigation: `owner: msg.sender` was read in `PoolManager.modifyLiquidity`.
**Gates.** 1 Process: pass. 2 Reachability: FAIL. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: not applicable. 6 Environment: pass.

`R-06 FALSE POSITIVE — positions are keyed by owner; the swap pool can only remove what it added.`

### R-07: `spent` can exceed the inventory and revert the swap

**Step 0.** Claim: rounding makes the position cost more coins than were queued, so
`internalSwapPool[coin] -= spent` (`src/core/InternalSwapPool.sol:254`) underflows and every buy reverts.
Class: integer. Route: standard.
**Phase 1.** Liquidity comes from `getLiquidityForAmount0/1(inventory)` or, at the cap, from a comparison
`inventory >= maxCost` (`:320-326`). API contract: the PoolManager charges `getAmount0Delta` / `getAmount1Delta`
rounded up for an addition.
**Phase 2 (bounds).** For the coin as currency0, with `A < B` the range bounds, `Q = 2^96`, `a` the inventory:
1. `L = floor(a × floor(A×B/Q) ÷ (B − A)) ≤ a×A×B ÷ (Q×(B − A))`.
2. So `L×Q×(B − A) ÷ B ≤ a×A`, and since `a×A` is an integer, `ceil(L×Q×(B − A) ÷ B) ≤ a×A`.
3. The PoolManager charges `ceil(ceil(L×Q×(B − A) ÷ B) ÷ A) ≤ ceil(a×A ÷ A) = a`.
For currency1: `L = floor(a×Q ÷ (B − A))`, charged `ceil(L×(B − A) ÷ Q) ≤ a`. At the cap, `maxCost` is
computed with the same round-up function the PoolManager uses. Removal returns no more than was added, so
`spent ≤ added ≤ a`. Q.E.D.
**Phase 3.** Real impact: none; were the bound false, every converting buy would revert, which would be a
denial of service. Primary control or defence in depth: the sizing arithmetic is the primary control and it
holds; checked subtraction would turn a violation into a revert rather than corrupted state.
**Phase 4.** Pseudocode: `assert(cost(liquidityFor(a)) <= a)` for all `a`. Executable: skipped in favour of
the proof; the swap-pool context review also evaluated the formulas over 11,246 sampled inputs and found
`spent` of exactly one raw unit for an untouched position. Negative PoC: `invariant_inventoryEqualsHeldTokens`.
Verification: formulas read from `v4-periphery/libraries/LiquidityAmounts.sol` and
`v4-core/libraries/SqrtPriceMath.sol`.
**Phase 5.** 1 Other explanation: rounding directions that look as if they could disagree.
2 Developer's view: the comment at `:248-249` says the clamp needs no separate accounting. 3 Missing
context: the exact library formulas. 4 Pattern-matching: yes. 5 Validation: the sizing comparison at
`:321`. 6 Attacker control: of the price only, which fixes `A` and `B`; the inequality holds for any.
7 Math: proven above. 8 Practical: no. 9 Defence in depth: not applicable. 10 Environment: checked
arithmetic would revert rather than corrupt state. 11 Hallucination: not a real issue. 12 False negative:
considered the edge where the price sits exactly on the lower tick; the amounts are the same.
13 Invented mitigation: none; the formulas were read.
**Gates.** 1 Process: pass. 2 Reachability: pass. 3 Real impact: would pass. 4 PoC: pass (negative). 5 Math: FAIL
(the proof rules it out). 6 Environment: pass.

`R-07 FALSE POSITIVE — the coins a position costs never exceed the inventory it was sized from.`

### R-08: starting the 24-hour clock with `syncLevel` before any trade helps reach a level early

**Step 0.** Claim: calling `syncLevel` at launch starts the history, so Live can come sooner than "24 hours
after the first trade" (`AGENT.md:205`). Class: logic. Route: standard.
**Phase 1.** `qualify` records the first observation on any call
(`src/calculators/LiveCalculator.sol:273-275`), and `syncLevel` is permissionless (`src/DicesHook.sol:408`).
**Phase 2.** True that the clock can start without a trade. But the average is taken over the 24 to 25 hours
before the check (`:320-327`), and the early history is at the launch tick, about 27,700 ticks below the
first target. A level still needs a full window at or above its tick.
**Phase 3.** Real impact: none; the documentation is slightly wrong (recorded in DICES-17). Primary control
or defence in depth: the moving window is the primary control and is unaffected.
**Phase 4.** Pseudocode: `syncLevel at t0; trade at t0 + 3 days; level at t0 + 3 days + 1 hour?` No: the
window then covers three days at the launch tick. Executable: skipped; the window arithmetic is covered by
`test/Calculators.t.sol` and was re-derived against a brute-force integral by the calculator context review.
Negative PoC: `testFuzz_goesLiveOnceTheMarketCapHasAveragedTheTargetForADay`. Verification: baseline run.
**Phase 5.** 1 Other explanation: loose wording in the document. 2 Developer's view: "first trade" is
shorthand for the first observation. 3 Missing context: the window moves with the clock. 4 Pattern-matching:
yes. 5 Validation: the readiness check at `:314` and the window at `:320`. 6 Attacker control: only of when
the clock starts. 7 Math: a mean over the last 24 hours cannot be raised by values before them. 8 Practical:
no. 9 Defence in depth: not applicable. 10 Environment: not applicable. 11 Hallucination: not a real issue.
12 False negative: could an early start bring a pump-and-hold forward by a day? No: the hold must still
last a full window from when the price is reached. 13 Invented mitigation: none.
**Gates.** 1 Process: pass. 2 Reachability: pass. 3 Real impact: FAIL. 4 PoC: pass (negative). 5 Math: FAIL (a
moving average cannot be raised by earlier low values). 6 Environment: pass.

`R-08 FALSE POSITIVE — an early first observation cannot raise a moving 24-hour average.`

---

## Informational items (Bugs #9 to #22)

Each of these is a statement about the code rather than an attack. They get the same phases as the other
bugs. "Reachability" in Gate 2 is read as "the statement is true of reachable code", and an executable PoC is
skipped only where the statement is a direct reading of cited lines or of a search result.

### BUG #9 (DICES-09): the fee model in the code is not the one in the brief as restated

**Phase 1, data flow.**
- 1.1 Source and path: `AGENT.md:45-47` and `README.md:10-13` (documents) against `src/calculators/FeeCalculator.sol:23-38`, `:85-94` and `src/DicesHook.sol:458-483` (code).
- 1.2 API contract: the hook charges whatever the calculator returns, in the swap's unspecified currency (`src/DicesHook.sol:460`).
- 1.3 Environment: nothing in the toolchain relates documents to code.
- 1.4 Cross-reference: the spec-compliance review reached the same result from the documents alone (DIV-01, 02, 05, 08, 09).

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody; it is how the code was written.
- 2.2 Bounds: the rates are constants: 1,250 and 1,000 over 100,000; shares 30,000 / 30,000 / remainder.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: there is no attack. The risk is building later phases on a reserve that is never funded.

**Phase 3, impact.**
- 3.1 Real impact or robustness: a missing or changed product requirement, not an operational weakness. Whether it is a defect depends on what the client agreed.
- 3.2 Primary control or defence in depth: not a control at all; a specification question.

**Phase 4, PoC.**
- 4.1 Pseudocode: `search(src, reserve | racePool | surcharge | 6909 | claimFees | gameCommitment)` returns no code.
- 4.2 / 4.3 Executable: skipped: a search answers it. The fee behaviour itself is asserted by `test/DicesHookTrading.t.sol`.
- 4.4 Negative PoC: the search returns only comments (`src/DicesHook.sol:108` and unrelated uses of the word "reserve").
- 4.5 Verification: I ran the search myself; the spec-compliance review reports the same absence from its own search.

**Phase 5, devil's advocate.**
1. Other explanations: the client may have agreed the change after the brief; the repository does not say.
2. Developer's view: the swap-pool rework replaced the reserve design, and `AGENT.md:102-103` flags part of the documentation as stale.
3. Missing context: the brief itself is not in the repository, only its restatement.
4. Pattern-matching: no; it is a comparison of stated numbers with constants.
5. Does validation prevent it: nothing enforces documents.
6. Attacker control of trusted data: no attacker involved.
7. Math proven: the constants were read; no calculation is needed.
8. Practical: it affects every swap.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: the constants and the document lines were re-read.
12. Dismissing something: rated Undetermined rather than dropped, because a missing reserve would matter to later phases.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: pass (constants read). 6 Environment: pass.

`BUG #9 TRUE POSITIVE — the code has no reserve surcharge and does not charge every fee in USDC.`

---

### BUG #10 (DICES-10): a conversion position is opened on every buy; callback gas is high

**Phase 1, data flow.**
- 1.1 Source and path: `MINIMUM_INTERNAL_SWAP_POOL_SIZE = 1e6` (`src/core/InternalSwapPool.sol:90`) compared with an 18-decimal balance (`:155`); position state in ordinary storage (`:80`, `:212`, `:234`).
- 1.2 API contract: `modifyLiquidity` initialises two ticks and writes a position each time.
- 1.3 Environment: the target chain has low gas prices, which lowers the cost and does not remove it.
- 1.4 Cross-reference: reported separately by the token-integration, Uniswap, guidelines and code-maturity reviews.

**Phase 2, exploitability.**
- 2.1 Who controls it: any buyer, by buying after a fee has been queued.
- 2.2 Bounds: 1e6 raw units is 1e-12 of a coin, so the comparison is true whenever anything is queued.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: could a dust queue make a swap revert? No: zero liquidity returns early (`:200`). Could it be used to grief gas? Only the griefer's own buys pay it.

**Phase 3, impact.**
- 3.1 Real impact or robustness: operational cost, not a security impact.
- 3.2 Primary control or defence in depth: not a control.

**Phase 4, PoC.**
- 4.1 Pseudocode: `trace(swap)`; read gas of `beforeSwap`, `afterSwap` and the two swap-pool calls.
- 4.2 / 4.3 Executable: the trace run of `test/DicesHookTrading.t.sol` and `test/DicesHookLive.t.sol`: `beforeSwap` max 202,036; `afterSwap` max 397,604; `createInternalSwapPool` max 181,617; `closeInternalSwapPool` max 302,291.
- 4.4 Negative PoC: the cheapest `beforeSwap`, with nothing queued, is 6,069 gas.
- 4.5 Verification: figures taken from the trace output; n = 37 and 36 calls.

**Phase 5, devil's advocate.**
1. Other explanations: the constant may be copied from a design with different units, or deliberately zero-like.
2. Developer's view: convert whenever possible so fees reach recipients sooner.
3. Missing context: the intent of the constant is not documented.
4. Pattern-matching: no; measured.
5. Does validation prevent it: the dust check is the validation, and it filters nothing.
6. Attacker control of trusted data: none.
7. Math proven: 1e6 ÷ 1e18 = 1e-12 coin.
8. Practical: every buy after any coin-denominated fee.
9. Defence in depth: not applicable.
10. Environment: cheap gas on the target chain softens it.
11. Hallucination check: measured, not inferred.
12. Dismissing something: kept as informational; it also explains part of DICES-19's sync constraint.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: pass. 6 Environment: pass.

`BUG #10 TRUE POSITIVE — the threshold filters nothing, and the two swap callbacks exceed the Uniswap skill's gas ceilings.`

---

### BUG #11 (DICES-11): production code uses a settler from v4-core's test utilities

**Phase 1, data flow.**
- 1.1 Source and path: `src/core/InternalSwapPool.sol:9` imports `@uniswap/v4-core/test/utils/CurrencySettler.sol`; used at `:258` and `:262`.
- 1.2 API contract: that library calls `IERC20Minimal.transfer` and ignores the returned boolean (`lib/v4-hooks-public/lib/v4-core/test/utils/CurrencySettler.sol:31`).
- 1.3 Environment: solady's `ERC20` reverts on a failed transfer, so the ignored boolean cannot hide a failure for `DicesCoin`.
- 1.4 Cross-reference: the repository's own `src/libraries/CurrencySettler.sol` uses `SafeERC20` and is used by the hook.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody; it is a dependency choice.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: could a token that returns false reach that `transfer`? Only the launched coin is settled there (`:258`), and coins are clones of the project's implementation.

**Phase 3, impact.**
- 3.1 Real impact or robustness: maintenance and audit-surface risk; no current loss path.
- 3.2 Primary control or defence in depth: the reverting token is the primary control today; the unchecked return would matter only if another token were ever settled this way.

**Phase 4, PoC.**
- 4.1 Pseudocode: `read(import at InternalSwapPool.sol:9)`.
- 4.2 / 4.3 Executable: skipped: there is nothing to trigger.
- 4.4 Negative PoC: looked for any other currency passed to that `settle`; there is none.
- 4.5 Verification: both files read.

**Phase 5, devil's advocate.**
1. Other explanations: convenience: the test settler has the `burn` and `claims` flags.
2. Developer's view: it is Uniswap's own code.
3. Missing context: test utilities are outside Uniswap's audited production surface.
4. Pattern-matching: no; an import was read.
5. Does validation prevent it: the token's own revert covers it today.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: no exploit path.
9. Defence in depth: yes in a sense: the missing check is a second layer that is absent, which is why this is informational.
10. Environment: solady reverts on failure.
11. Hallucination check: the import line is there.
12. Dismissing something: nothing.
13. Invented mitigation: the solady revert was confirmed in the library source.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #11 TRUE POSITIVE — the swap pool settles through a test utility with an unchecked transfer.`

---

### BUG #12 (DICES-12): anyone can initialise the coin implementation

**Phase 1, data flow.**
- 1.1 Source and path: `DicesCoin.initialize` has no caller check (`src/DicesCoin.sol:123-138`); the constructor does not set `_initialized` (`:103-113`).
- 1.2 API contract: a minimal clone has its own storage, so the implementation's state does not affect clones.
- 1.3 Environment: none.
- 1.4 Cross-reference: the hook initialises each clone in the creating transaction (`src/DicesHook.sol:551-554`).

**Phase 2, exploitability.**
- 2.1 Who controls it: any caller, once.
- 2.2 Bounds: not applicable.
- 2.3 Race: no race for clones: creation and initialisation are in one transaction.
- 2.4 Adversarial view: can the implementation's state reach a clone? No. Can it be destroyed? There is no `selfdestruct` or `delegatecall` in it.

**Phase 3, impact.**
- 3.1 Real impact or robustness: no funds or pools are affected; the effect is a look-alike token at a published address.
- 3.2 Primary control or defence in depth: defence in depth; clones are protected by being initialised atomically.

**Phase 4, PoC.**
- 4.1 Pseudocode: `implementation.initialize('Dices', 'DICE', 1e27, attacker)`.
- 4.2 / 4.3 Executable: `testPoC7_anyoneCanInitialiseTheCoinImplementation` passes.
- 4.4 Negative PoC: a second `initialize` reverts with `AlreadyInitialized` (covered in `test/DicesCoin.t.sol`).
- 4.5 Verification: the test asserts the stranger's balance and the name.

**Phase 5, devil's advocate.**
1. Other explanations: the implementation is not meant to be used as a token.
2. Developer's view: locking it costs a line and was not thought necessary.
3. Missing context: none.
4. Pattern-matching: no; executed.
5. Does validation prevent it: the one-time flag exists but nobody sets it for the implementation.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: one call by anyone.
9. Defence in depth: yes; this is a missing second layer.
10. Environment: none.
11. Hallucination check: reproduced.
12. Dismissing something: nothing; phishing with a look-alike is the only use found.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #12 TRUE POSITIVE — the implementation address can be turned into a look-alike token by anyone.`

---

### BUG #13 (DICES-13): ETH sent to the swap pool is stuck

**Phase 1, data flow.**
- 1.1 Source and path: `receive()` accepts ETH from anyone (`src/core/InternalSwapPool.sol:363-365`).
- 1.2 API contract: the only code that forwards ETH is the native branch of `_creditFee` (`:291-292`).
- 1.3 Environment: every pool pairs with USDC, enforced by the hook's constructor (`src/DicesHook.sol:201`) and the pool key (`:564`), so that branch is never taken.
- 1.4 Cross-reference: the hook itself has no `receive`.

**Phase 2, exploitability.**
- 2.1 Who controls it: whoever sends the ETH.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: can someone else extract it? No function sends ETH for a USDC pool.

**Phase 3, impact.**
- 3.1 Real impact or robustness: loss is limited to the sender's own mistaken transfer.
- 3.2 Primary control or defence in depth: not a control.

**Phase 4, PoC.**
- 4.1 Pseudocode: `send(swapPool, 1 ether); trade; assert balance unchanged`.
- 4.2 / 4.3 Executable: `testPoC13_ethSentToTheSwapPoolStaysThere` passes.
- 4.4 Negative PoC: the same test trades in both directions, including a conversion, and the balance stays at 1 ether.
- 4.5 Verification: balance asserted before and after.

**Phase 5, devil's advocate.**
1. Other explanations: left over from a design with native-currency pairs.
2. Developer's view: harmless and unreachable.
3. Missing context: none.
4. Pattern-matching: no; executed.
5. Does validation prevent it: nothing rejects the transfer.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: only by mistake.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: reproduced.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #13 TRUE POSITIVE — the swap pool accepts ETH and has no reachable path to send it out.`

---

### BUG #14 (DICES-14): levels price the coin on a supply that burning changes

**Phase 1, data flow.**
- 1.1 Source and path: `SUPPLY = 1e27` (`src/calculators/LiveCalculator.sol:94`) is the only supply the calculator uses (`:208`); the level ticks are constants (`:219-242`).
- 1.2 API contract: `DicesCoin.burn` reduces `totalSupply()` (`src/DicesCoin.sol:182-184`).
- 1.3 Environment: none.
- 1.4 Cross-reference: `AGENT.md:188` says "supply is fixed"; a buy-and-burn recipient exists in the fee split.

**Phase 2, exploitability.**
- 2.1 Who controls it: any holder can burn its own coins.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: can burning gain a level? No: the tick targets do not move, and burning costs the burner.

**Phase 3, impact.**
- 3.1 Real impact or robustness: a definition that differs from the common meaning of market cap; no loss.
- 3.2 Primary control or defence in depth: not a control.

**Phase 4, PoC.**
- 4.1 Pseudocode: `search(LiveCalculator, totalSupply)` returns nothing.
- 4.2 / 4.3 Executable: skipped: a search answers it.
- 4.4 Negative PoC: the search finds only the constant.
- 4.5 Verification: search run; both files read.

**Phase 5, devil's advocate.**
1. Other explanations: fixed ticks are what make the level rule cheap.
2. Developer's view: `AGENT.md` gives that reason.
3. Missing context: none.
4. Pattern-matching: no.
5. Does validation prevent it: nothing links the calculator to the live supply.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: applies after any burn.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: both lines re-read.
12. Dismissing something: kept because the client's table is stated in market cap.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #14 TRUE POSITIVE — "market cap" in the level rule is price times launch supply, whatever has been burned.`

---

### BUG #15 (DICES-15): every holder gives Permit2 an infinite allowance

**Phase 1, data flow.**
- 1.1 Source and path: solady `ERC20.sol:171-173` (allowance), `:186-196` (approve), `:667-669` (default `true`); not overridden in `src/DicesCoin.sol`.
- 1.2 API contract: Permit2 moves tokens only with the owner's signature.
- 1.3 Environment: none.
- 1.4 Cross-reference: the project's activity script notes the behaviour.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody; it applies to every holder automatically.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: an attacker still needs a signed Permit2 message; what is removed is the on-chain approval step and the ability to revoke.

**Phase 3, impact.**
- 3.1 Real impact or robustness: widens the effect of a phished signature; no direct loss path.
- 3.2 Primary control or defence in depth: the signature requirement is the primary control and is intact.

**Phase 4, PoC.**
- 4.1 Pseudocode: `allowance(anyone, PERMIT2) == max; approve(PERMIT2, 0) reverts`.
- 4.2 / 4.3 Executable: `testPoC15_permit2AllowanceIsInfiniteAndFixed` passes.
- 4.4 Negative PoC: the same test shows any other spender starts at zero.
- 4.5 Verification: values asserted.

**Phase 5, devil's advocate.**
1. Other explanations: solady's default, chosen for cheaper Universal Router use.
2. Developer's view: common in new tokens.
3. Missing context: none.
4. Pattern-matching: no; executed.
5. Does validation prevent it: nothing in the coin limits it.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: always in effect.
9. Defence in depth: yes: approval is a second layer; the signature remains.
10. Environment: none.
11. Hallucination check: reproduced.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #15 TRUE POSITIVE — the Permit2 allowance is infinite and cannot be revoked.`

---

### BUG #16 (DICES-16): code that cannot run or has no effect

**Phase 1, data flow.**
- 1.1 Source and path: `_beforeInitialize` after its first check (`src/DicesHook.sol:260-279`); `lastSwapBlock` (`:185`, `:339`); discarded `_getSender` results (`:350`, `:373`); `CurrencySettler` payer branch (`src/libraries/CurrencySettler.sol:40-41`); `IFlaunch.sol`; three events and two emitters in `src/libraries/UniswapEvents.sol:43-53`, `:104-117`; `internalSwapPool` and `feeEscrow` written only in the constructor.
- 1.2 API contract: the PoolManager skips hook callbacks for the hook's own calls (`v4-core/libraries/Hooks.sol:171-175`), which is why `_beforeInitialize` only ever sees third parties.
- 1.3 Environment: none.
- 1.4 Cross-reference: Slither reports the two could-be-immutable variables; the guidelines and Uniswap reviews list the same dead code.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: does any of it hide a reachable path? The unreachable part of `_beforeInitialize` follows an unconditional revert for every caller that can reach it.

**Phase 3, impact.**
- 3.1 Real impact or robustness: gas, bytecode and misleading coverage; no security effect.
- 3.2 Primary control or defence in depth: one item touches a control: `_beforeRemoveLiquidity` would not stop the hook itself, so the lock rests on the hook having no removal code. The primary protection (no such code) holds.

**Phase 4, PoC.**
- 4.1 Pseudocode: `search(readers of lastSwapBlock); search(importers of IFlaunch); search(callers of the unused emitters)`.
- 4.2 / 4.3 Executable: skipped: searches answer it.
- 4.4 Negative PoC: in `src/` and `script/` the searches find no reader of `lastSwapBlock` beyond its declaration and getter, no importer of `IFlaunch`, and no caller of the two emitters. Two tests assert `lastSwapBlock`'s value; no contract uses it.
- 4.5 Verification: searches run over `src/`, `script/` and `test/`.

**Phase 5, devil's advocate.**
1. Other explanations: leftovers from the rework, or state kept for a later phase.
2. Developer's view: `lastSwapBlock` is commented as being for a buy-and-burn contract that is not in the repository.
3. Missing context: later-phase contracts may read some of it.
4. Pattern-matching: no; each item was searched for.
5. Does validation prevent it: not applicable.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: not applicable.
9. Defence in depth: see Phase 3: the lock's primary protection holds.
10. Environment: none.
11. Hallucination check: searches confirm each item.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #16 TRUE POSITIVE — the listed code is unreachable or unused at this commit.`

---

### BUG #17 (DICES-17): documentation and comments promise things the code does not do

**Phase 1, data flow.**
- 1.1 Source and path: the statement-by-statement table under DICES-17 in `findings.md`; each row gives the document line and the code line.
- 1.2 API contract: not applicable.
- 1.3 Environment: none.
- 1.4 Cross-reference: the four context reviews and the spec-compliance review list the same mismatches independently.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: could someone rely on a false guarantee? An integrator reading "`beforeRemoveLiquidity` always reverts" or "a calculator fault never blocks a swap" would.

**Phase 3, impact.**
- 3.1 Real impact or robustness: risk to integrators and later reviewers; each underlying behaviour was verified separately (R-06, R-08, Bugs #6, #7, #14).
- 3.2 Primary control or defence in depth: documentation is a second layer; the code's actual protections were checked directly.

**Phase 4, PoC.**
- 4.1 Pseudocode: for each row: `read(document line); read(code line); compare`.
- 4.2 / 4.3 Executable: skipped: text comparisons. The behaviours behind the three security-relevant rows are exercised by `testPoC2`, `testPoC3` and the project's lock tests.
- 4.4 Negative PoC: `AGENT.md`'s "Live and game levels" section was compared with the calculator and matches apart from the rows listed.
- 4.5 Verification: each quoted line re-read.

**Phase 5, devil's advocate.**
1. Other explanations: the documents predate the rework.
2. Developer's view: `AGENT.md:102-103` already flags part of it.
3. Missing context: none.
4. Pattern-matching: no.
5. Does validation prevent it: not applicable.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: affects anyone building on the documents.
9. Defence in depth: yes; documentation only.
10. Environment: none.
11. Hallucination check: lines quoted.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #17 TRUE POSITIVE — several documented guarantees are stronger than, or different from, the code.`

---

### BUG #18 (DICES-18): events leave gaps for indexers and monitoring

**Phase 1, data flow.**
- 1.1 Source and path: a launch emits only `PoolCreated(poolId, coin, usdc)` (`src/DicesHook.sol:604`); `Deposited` has no pool id (`src/interfaces/IFeeEscrow.sol:49`); a conversion emits nothing of its own (`src/core/InternalSwapPool.sol:226-279`); `HookFee` repeats `HookSwap`'s fee (`src/DicesHook.sol:376-383`).
- 1.2 API contract: not applicable.
- 1.3 Environment: none.
- 1.4 Cross-reference: the guidelines review lists the same gaps.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: could a missing event hide abuse? A change of creator cannot happen; fee diversion (Bug #5) would show only as lower `Deposited` amounts.

**Phase 3, impact.**
- 3.1 Real impact or robustness: monitoring gap; every value is readable from storage.
- 3.2 Primary control or defence in depth: monitoring is a second layer.

**Phase 4, PoC.**
- 4.1 Pseudocode: `list(emit statements in DicesHook and InternalSwapPool)`.
- 4.2 / 4.3 Executable: skipped: the list answers it.
- 4.4 Negative PoC: the list contains no event with a creator, name or symbol; the swap pool's only event is `Deposit`.
- 4.5 Verification: search run; output reviewed line by line.

**Phase 5, devil's advocate.**
1. Other explanations: indexers may read storage instead.
2. Developer's view: not stated in the repository; the event library's own comment says indexers read its events instead of the PoolManager's.
3. Missing context: the indexer's needs are not in the repository.
4. Pattern-matching: no.
5. Does validation prevent it: not applicable.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: affects every launch.
9. Defence in depth: yes.
10. Environment: none.
11. Hallucination check: list checked.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #18 TRUE POSITIVE — launch, fee attribution and conversion are not fully reconstructable from logs.`

---

### BUG #19 (DICES-19): fees are taken from the PoolManager before the swapper pays

**Phase 1, data flow.**
- 1.1 Source and path: `take` at `src/DicesHook.sol:473` and `src/core/InternalSwapPool.sol:262`, both inside `afterSwap`.
- 1.2 API contract: the PoolManager pays a `take` from its own token balance and checks deltas only when the unlock ends.
- 1.3 Environment: on a live chain the PoolManager holds every pool's USDC.
- 1.4 Cross-reference: the project's test router pre-funds exact-output swaps for this reason (`test/utils/MsgSenderSwapRouter.sol:55`); the Uniswap review reports the same assumption.

**Phase 2, exploitability.**
- 2.1 Who controls it: any swapper, by swapping.
- 2.2 Bounds: the take succeeds when the PoolManager's USDC balance ≥ the amount taken.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: can it be turned into a denial of service? Only where the PoolManager's balance is tiny; the swap reverts and nothing is lost.

**Phase 3, impact.**
- 3.1 Real impact or robustness: fails safe (revert); a deployment and integration constraint.
- 3.2 Primary control or defence in depth: not a control.

**Phase 4, PoC.**
- 4.1 Pseudocode: `buy; sell everything; buy again` in a PoolManager that holds only this pool.
- 4.2 / 4.3 Executable: `testPoC11_conversionProceedsAreTakenBeforeTheBuyerPays` passes: the last buy reverts with `ERC20InsufficientBalance`.
- 4.4 Negative PoC: after minting other USDC to the manager, the same buy succeeds (same test).
- 4.5 Verification: revert data asserted to contain the error selector.

**Phase 5, devil's advocate.**
1. Other explanations: normal use of flash accounting.
2. Developer's view: the PoolManager always has ample USDC on mainnet.
3. Missing context: the deployed PoolManager's balance was not queried.
4. Pattern-matching: no; executed.
5. Does validation prevent it: nothing checks the balance first.
6. Attacker control of trusted data: none.
7. Math proven: stated in Phase 2.
8. Practical: on testnets and new chains.
9. Defence in depth: not applicable.
10. Environment: mainnet balances make it moot there.
11. Hallucination check: reproduced.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: pass. 6 Environment: pass.

`BUG #19 TRUE POSITIVE — in-callback takes depend on the PoolManager's existing balance.`

---

### BUG #20 (DICES-20): blind spots in the test suite

**Phase 1, data flow.**
- 1.1 Source and path: invariant settings in `foundry.toml` (64 runs, depth 32); handler at `test/DicesHookInvariant.t.sol:36-51`, `:67`; bare `vm.expectRevert()` at `test/DicesHookTrading.t.sol:148`; stand-in coin at `test/utils/Fixtures.sol:83-99`.
- 1.2 API contract: not applicable.
- 1.3 Environment: CI enforces 100% coverage, which measures lines reached, not inputs explored.
- 1.4 Cross-reference: the Uniswap, guidelines and code-maturity reviews list the same gaps.

**Phase 2, exploitability.**
- 2.1 Who controls it: nobody.
- 2.2 Bounds: not applicable.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: would a deeper campaign have found the confirmed bugs? Bugs #1, #2 and #7 are each one assertion away from the existing harness.

**Phase 3, impact.**
- 3.1 Real impact or robustness: process weakness, not a defect in `src/`.
- 3.2 Primary control or defence in depth: tests are a second layer.

**Phase 4, PoC.**
- 4.1 Pseudocode: `run(PoC for an untested input class) against unmodified code`.
- 4.2 / 4.3 Executable: `testPoC1`, `testPoC3` and `testPoC9` each pass against the unmodified code.
- 4.4 Negative PoC: coverage is 100% and all four swap modes and both orderings are exercised by unit tests.
- 4.5 Verification: handler read; baseline run.

**Phase 5, devil's advocate.**
1. Other explanations: small team and a recent rework.
2. Developer's view: coverage gate was the chosen bar.
3. Missing context: none.
4. Pattern-matching: no.
5. Does validation prevent it: not applicable.
6. Attacker control of trusted data: none.
7. Math proven: not applicable.
8. Practical: not applicable.
9. Defence in depth: yes.
10. Environment: none.
11. Hallucination check: PoCs pass.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #20 TRUE POSITIVE — full line coverage coexists with untested input classes.`

---

### BUG #21 (DICES-21): design limits the team already documents

**Phase 1, data flow.**
- 1.1 Source and path: patient buyer and sybil holders (`AGENT.md`, design decisions); unrestricted bankroll (`AGENT.md` open question 10); free downward movement below the launch tick (`test/DicesHookLaunchCurve.t.sol:75`); USDC blocklist exposure of the hook, swap pool and escrow.
- 1.2 API contract: v4 moves the price for free across ranges with no liquidity.
- 1.3 Environment: USDC's issuer can block addresses; its code is not in the repository.
- 1.4 Cross-reference: the token-integration, Uniswap and code-maturity reviews each describe these as acknowledged.

**Phase 2, exploitability.**
- 2.1 Who controls it: the bankroll, or a holder with capital and patience.
- 2.2 Bounds: one hour at the lowest tick lowers the 24-hour average by about 20,000 ticks.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: is any of them worse than documented? Upward movement is never free (`src/DicesHook.sol:646`, `:653`); a low tick can only delay a level.

**Phase 3, impact.**
- 3.1 Real impact or robustness: acknowledged design trade-offs.
- 3.2 Primary control or defence in depth: the 24-hour average and the same-block holder rule are the primary controls, and they behave as documented.

**Phase 4, PoC.**
- 4.1 Pseudocode: `bankroll sells past the pool's USDC` → price falls with no input consumed.
- 4.2 / 4.3 Executable: the project's own `testFuzz_bankrollSalesCanEmptyThePoolWhileBuyersStillHoldCoins`.
- 4.4 Negative PoC: the upper position reaches the usable tick limit, so there is no free move upward.
- 4.5 Verification: `_addLaunchLiquidity` and `_levelAt` read.

**Phase 5, devil's advocate.**
1. Other explanations: accepted trade-offs.
2. Developer's view: documented in `AGENT.md`.
3. Missing context: the client's answer to open question 10.
4. Pattern-matching: no.
5. Does validation prevent it: as documented.
6. Attacker control of trusted data: the bankroll is a trusted party.
7. Math proven: stated in Phase 2.
8. Practical: only for the bankroll or a patient buyer.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: matches the project's own tests.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: pass. 6 Environment: pass.

`BUG #21 TRUE POSITIVE — the documented limits hold and are no worse than stated.`

---

### BUG #22 (DICES-22): unbounded inputs

**Phase 1, data flow.**
- 1.1 Source and path: `name` and `symbol` stored as given (`src/DicesCoin.sol:133-134`, from `src/DicesHook.sol:554`); `setCreateFee` (`src/DicesHook.sol:783`); `setTrustedRouter` with a zero address (`src/core/TrustedRouters.sol:25`).
- 1.2 API contract: not applicable.
- 1.3 Environment: none.
- 1.4 Cross-reference: the token-integration and Uniswap reviews list the same inputs.

**Phase 2, exploitability.**
- 2.1 Who controls it: any creator for the strings; the owner for the other two.
- 2.2 Bounds: no length limit; cost grows with length for the creator only.
- 2.3 Race: not applicable.
- 2.4 Adversarial view: can a long name block anything on chain? `permit` hashes the name, so a long one costs its users gas; nothing else reads it.

**Phase 3, impact.**
- 3.1 Real impact or robustness: display risk off chain and owner hygiene.
- 3.2 Primary control or defence in depth: not a control.

**Phase 4, PoC.**
- 4.1 Pseudocode: `search(src, length checks on name or symbol)` returns nothing.
- 4.2 / 4.3 Executable: skipped: a search answers it.
- 4.4 Negative PoC: no check found.
- 4.5 Verification: search run.

**Phase 5, devil's advocate.**
1. Other explanations: left to the front end.
2. Developer's view: names are free-form by design.
3. Missing context: none.
4. Pattern-matching: no.
5. Does validation prevent it: nothing validates them.
6. Attacker control of trusted data: the creator is untrusted, so front ends must treat the strings as hostile.
7. Math proven: not applicable.
8. Practical: any launch.
9. Defence in depth: not applicable.
10. Environment: none.
11. Hallucination check: lines read.
12. Dismissing something: nothing.
13. Invented mitigation: none.

**Gates.** 1 Process: pass. 2 Reachability: pass (the statement is true of reachable code). 3 Real impact: pass, limited as stated in Phase 3. 4 PoC: pass. 5 Math: not applicable. 6 Environment: pass.

`BUG #22 TRUE POSITIVE — these inputs are not bounded on chain.`

---

## Exploit chains

After the individual verdicts I looked for combinations, including of rejected items.

- **Bug #4 + Bug #3 + Bug #7.** A compromised deployer key can raise fees or halt trading, then renounce
  ownership so that neither can be undone. This is the worst case in the report and the reason Bugs #3 and #4
  are listed first in the action plan. It needs the owner key.
- **Bug #6 + Bug #5.** Bug #6 lets anyone buy in the launch block through the Universal Router. A large
  first-block buy is exactly the state Bug #5 needs, and the buyer can run Bug #5 on its own queue in the
  same transaction, recovering about a third of its buy fee in the measured case. Fixing either one breaks
  the chain; it is the reason Bug #5 is rated Medium rather than Low.
- **Bug #1 with anything.** No chain: the creator of such a pool gains nothing from it.
- **R-01 with a heavier calculator.** Not a chain today. If a replacement Live calculator ever costs several
  hundred thousand gas per call, R-01 should be re-run.
- No combination was found that lets an unprivileged party take funds from the PoolManager, the escrow, the
  swap pool or another user.
