Core contracts
InternalSwapPool.sol
InternalSwapPool converts queued launched-token fees through just-in-time liquidity. The findings cover the price used to sell that inventory and the timing of settlement with PoolManager.
Reviewed source: src/core/InternalSwapPool.sol at commit 38f14ff.
Findings
| ID | Severity | Finding |
|---|---|---|
| B-01 | High | Internal swap pool inventory can be bought for dust |
| B-16 | Medium | Buys can revert when PoolManager cannot fund internal-swap proceeds |
[HIGH] B-01 · Internal swap pool inventory can be bought for dust
B-01 · High
An attacker can move an idle pool to an arbitrary price, add dust liquidity and buy the launched-token fees queued for the whole launch for a few wei.
The internal swap pool collects fees in the launched token and converts them through a just-in-time liquidity position. The position is placed beside the current spot price, using the launch's entire queued token inventory.
The earlier F-02 fix skips this placement when active liquidity is zero. That check does not establish that the price is backed by meaningful liquidity. The hook allows third parties to add liquidity, so an attacker can move spot through an empty range at no cost, add a 1-wei position at the chosen tick, and make the check pass. A dust buy then trades against the protocol's inventory at that price.
The attack needs a pool whose spot is on the empty side of its launch range. An untouched second pool already meets that condition once the launch block has passed. A single-pair launch becomes exposed after its paired reserve has been exhausted. The steps fit in one transaction and can be repeated when more fees arrive.
Earlier review: F-02 remains open under adversarial conditions. The zero-liquidity fix blocks the original example but not this variant.
Impact
Royalty recipients and the treasury lose the value of fees collected in the launched token, including fees from exact-input buys and exact-output sells. A buyer can take those tokens through an idle pool and sell them through another pool with real liquidity. The affected assets are fee revenue; the attack does not withdraw user principal from a pool or escrow.
Affected code
Locations refer to the reviewed commit, 38f14ff.
src/core/InternalSwapPool.sol:142–183— The liquidity guard, spot-derived range and inventory placement.src/hooks/FlaunchPool.sol:113–121— Hook permissions omit a gate on adding liquidity.
From src/core/InternalSwapPool.sol:142–155:
if (params.zeroForOne != launchedTokenIsCurrency0 && internalSwapPool[launchedToken] >= MINIMUM_INTERNAL_SWAP_POOL_SIZE) {
// Every pool launches single-sided, so a sell that exhausts the paired reserve carries the price across the
// empty side of the launch range without consuming input. A spot price that no active liquidity backs would
// place the whole inventory where it is worth dust, so keep it for a swap that trades inside the liquidity.
if (poolManager.getLiquidity(poolId) == 0) {
return;
}
// Get the tick range for the JIT liquidity position
int24 tickLower;
int24 tickUpper;
{
// Get the current slot0 price for the pool
(uint160 sqrtPriceX96, int24 tick,,) = poolManager.getSlot0(poolId);
Proof of concept
- Launch with two pairs and buy through the liquid pair to queue launched-token fees.
- Move the untouched pair's spot through its empty range with a dust swap and a distant price limit.
- Add dust liquidity at that price, then buy through the same pair.
- Remove the dust position and sell the acquired tokens through the liquid pair.
In HookAudit.t.sol::test_poc_multiPairInventorySoldForDustThroughIdlePool, the attacker spends 2 wei, takes about 815,238 of 823,472 queued tokens, and sells them for 0.01186 ETH. That is 97.8% of the inventory's measured value; the launch receives no proceeds for that inventory. The repeated-purchase test extracts 0.0566 ETH from 0.0578 ETH of fee value for 10 wei.
The independently written F02DustLiquidityBypass.t.sol also reproduces the issue in both currency orderings. Its dormant-pool case takes 98.99% of the inventory for 3 wei. Without the added dust liquidity, the zero-liquidity guard correctly leaves the inventory queued.
The test source is poc/HookAudit.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:
FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/HookAudit.t.sol' -vv
Recommended solution
Record each pool's launch price during initialisation and place the internal swap position only when spot is inside the launch position's range, where moving the price requires real funds. Keep the zero-liquidity check and consider a minimum-proceeds bound.
Extend the swap invariants to include third-party liquidity and free spot movement through empty ranges. The regression should show that adding a dust position cannot make an otherwise unsafe price eligible.
[MEDIUM] B-16 · Buys can revert when PoolManager cannot fund internal-swap proceeds
B-16 · Medium
The internal swap pool takes conversion proceeds before a standard router settles its input. Thin PoolManager balances can therefore make otherwise valid buys revert.
When a buy converts queued launched-token fees, closeInternalSwapPool takes the paired-token proceeds from PoolManager during afterSwap. A router that pays its input after the swap has not funded that balance yet. PoolManager must already hold enough of the paired token to cover the take.
The protocol documentation acknowledges this dependency but assumes shared production reserves cover it. The source review's 25 November Base snapshot showed that assumption did not hold for many whitelisted stock tokens: PoolManager held zero RIVNc, BIRDc, AMCc and UNHc, and fewer than 100 whole tokens of 53 more.
Impact
A buy through Universal Router or the direct swap route reverts whenever the converted proceeds exceed PoolManager's existing paired-token balance. For a zero-balance token, every buy that converts queued fees fails, so that reserve cannot build through a swap-then-settle router.
The issue is particularly reachable when an ETH pair queues fees that are later converted through a thin stock pair. Zaps that fund input before the swap are unaffected. Reverting buys do not lose funds. The source review raised this finding from Low to Medium after the reserve checks.
Affected code
Locations refer to the reviewed commit, 38f14ff.
src/core/InternalSwapPool.sol:244–255— Paired proceeds are taken and deposited before the surrounding router settles.
From src/core/InternalSwapPool.sol:249–255:
Currency paired = state.launchedTokenIsCurrency0 ? _key.currency1 : _key.currency0;
if (proceeds != 0) {
paired.take(poolManager, address(this), proceeds);
if (!paired.isAddressZero()) {
IERC20(Currency.unwrap(paired)).forceApprove(address(flaunch), proceeds);
}
flaunch.deposit{value: paired.isAddressZero() ? proceeds : 0}(flaunch.poolTokenId(poolId), Currency.unwrap(paired), proceeds);
Proof of concept
- Launch with ETH and a paired token that PoolManager holds in insufficient quantity.
- Buy through the ETH pair to queue launched-token fees.
- Buy through the thin pair using a router that settles after
swap. - Repeat with the input funded before the swap.
HookAudit.t.sol::test_poc_thinReserveJitTakeRevertsStandardRouterBuy reverts with ERC20InsufficientBalance inside the internal swap pool's take. The same buy succeeds when the input is funded first.
The executable test uses the real hook and internal swap pool with a test token. The stock-token reserve figures are separate read-only observations from the source review, around Base block 62,149,105; they are a dated snapshot, not a current balance guarantee.
The test source is poc/HookAudit.t.sol in the Solidity evidence bundle. Follow the reproduction setup, then run:
FOUNDRY_GAS_LIMIT=1000000000000 forge test --match-path 'test/audit/HookAudit.t.sol' -vv
Recommended solution
Cap the proceeds taken to PoolManager's available balance and leave the remaining inventory queued, or accrue the proceeds as an ERC-6909 claim and redeem them after settlement. Test both fund-before-swap and swap-before-settlement routers with zero and thin reserves.
Shared findings
- B-10 · Medium: An issuer freeze can halt trading in a currency across every launch — Taking and depositing paired-token proceeds during the swap exposes the path to an issuer freeze.