Hooks.wtf

Calculators

LiveCalculator.sol

LiveCalculator uses a rolling price average and holder floors to unlock levels. Its primary findings concern unreachable upper levels and the use of launch supply after tokens are burned.

Reviewed source: src/calculators/LiveCalculator.sol at commit bcd45b2.

Findings

IDSeverityFinding
DICES-02MediumGame levels 9 and 10 can never unlock
DICES-14InformationalLevels price the coin on a supply that burning changes

[MEDIUM] DICES-02 · Game levels 9 and 10 can never unlock

Affected modules: DicesHook.sol, DicesCoin.sol, LiveCalculator.sol.

Severity: Medium. Type: specification, arithmetic.

Affected code: src/DicesCoin.sol:32; src/DicesHook.sol:71; src/calculators/LiveCalculator.sol:252, :373-375.

Description

A level needs the coin to have at least its floor of qualifying holders, and a qualifying holder is an address with at least 300,000 coins. The supply is fixed at 1,000,000,000 coins, so no more than 1,000,000,000 ÷ 300,000 = 3,333 addresses can qualify at once, whatever happens.

LevelHolder floorCoins that must sit in qualifying walletsPossible
71,700510MYes
82,500750MOnly if about three quarters of all coins are in qualifying wallets
93,8001,140MNo: more than the supply
105,8001,740MNo: more than the supply

The practical ceiling is lower than 3,333, because the hook, the PoolManager, the swap pool and the bankroll address are not counted (src/DicesCoin.sol:247-249) and the pool always holds some coins. At level 8's market cap about 982M coins can be outside the pool at most.

_levelAt lowers the level until the floor is met (src/calculators/LiveCalculator.sol:373-375), so a coin whose average market cap is above $51M or $102M stays at level 8 or below.

Impact

Two of the ten games in the client's table (9 November update) cannot be reached by any coin. Level 8 is reachable only with an unusually flat distribution. No funds are at risk.

The project's tests do not catch this because the tests that reach level 10 use a stand-in coin whose holder count is set directly (test/utils/Fixtures.sol:83-99).

Evidence

testPoC9_levelsNineAndTenNeedMoreHoldersThanTheSupplyAllows passes: it prints the table above from the deployed constants and asserts that floors 9 and 10 exceed totalSupply() / HOLDER_THRESHOLD().

Recommendation

This needs a decision from the client, since both the floors and the 300,000-coin threshold came out of AGENT.md open question 5:

  • lower the threshold (for 5,800 holders to be possible at all it must be under about 172,000 coins, and much lower to be practical), or
  • lower the floors for the upper levels, or
  • define the floor for upper levels differently, for example as a count of addresses above a smaller balance.

Then add a test that every level's floor × threshold fits within the coins that can be in circulation at that level's market cap.

Reported independently by the token-integration (TI-01) and guidelines (F-01) reviews and by the calculator context review.

Recorded test source and output: poc-tests.md.

Source finding: findings.md, DICES-02.

[INFORMATIONAL] DICES-14 · Levels price the coin on a supply that burning changes

Affected modules: DicesCoin.sol, LiveCalculator.sol.

Severity: Informational.

LiveCalculator multiplies price by a constant SUPPLY = 1e27 (src/calculators/LiveCalculator.sol:94, :208). DicesCoin.burn lowers totalSupply() (src/DicesCoin.sol:182-184), and a buy-and-burn recipient exists to do exactly that. After burns, the "market cap" that levels use is price × launch supply. Recommendation: confirm with the client that level targets are meant as price targets, and say so in AGENT.md, which currently states "supply is fixed".

Source finding: findings.md, DICES-14.

Shared findings

Previous
FeeCalculator.sol