Talos Launch App

04 · Developers

Gas

What a hook adds to a swap, and how to keep that smaller than the trade.

The pool swap is the expensive part. A hook should add a few storage reads and, only when the rule requires it, one storage write. It should not add a write that the trade did not need.

What every swap already pays

An exact-input ERC-20 swap pays for the pool math, two token transfers, and the router's unlock. That cost is there with or without Talos. Native ETH is not supported, so you do not also pay a WETH wrap inside these contracts. Wrap first, if you must.

What the hub adds

Each module that opted into a callback is one external call. A hook with only beforeSwap is one call. A hook with beforeSwap and afterSwap is two. Eight modules that all use both is sixteen calls. Calls are hundreds of gas each once the contract is warm, plus whatever the module itself writes.

The hub's pull counter and the router's reentrancy guard use transient storage. They last for the transaction and do not cost a permanent storage write on every trade. Clearing them at the end of the call still matters: transient data survives until the transaction ends, so a later call in the same transaction must not see a stale pull lock.

What actually costs

A practical stack

Wave, cohort, and one fee hook is three modules. A first-time buyer pays the cohort's new slot once. Later buys from that wallet update a warm slot. A sell that the cohort ignores does not write the cap. If a trade is so small that even one warm write dominates its value, the trade is dust. Do not design the hook around dust, and do not invite dust with a stack of eight writers.

Measured against the tests

The forge suite checks behavior, not a gas snapshot in these pages. Before a launch, run forge test --gas-report on the stack you will actually register and compare that overhead with the smallest swap you are willing to accept. A report from a different stack is not your number.