Skip to main content
The Priority Fee Hook adjusts trading fees based on how aggressively a swap is bidding for fast inclusion, and keeps its internal reference measurement resistant to manipulation. Here you can find End-to-end flow executed when a swap reaches Pulse Hook:
1

Reading the Swap's Priority Fee

When a user submits a swap, the hook first looks at how much extra “priority fee” (tip) that user is paying to get their transaction included quickly.
2

Comparing to the Typical Level

The hook compares the current swap’s priority fee to a smoothed reference value: the average of the last 15 block-level snapshots of the running median.
3

Normal Fee for Normal Behavior

If the swap’s priority fee is reasonably close to the typical level, no extra fee is applied. Basic fee of 0.1% is the only fee to pay.
4

Penalty for Excessive Fee-Bidding

If the swap’s priority fee is significantly higher than typical (for example, several times above average), the hook applies an additional trading fee on top of the baseline. Refer to Penalty Curve  for detailed Math
5

Swap Executes with Applied Fee

The swap is executed by the pool as normal. The extra fee collected goes to liquidity providers as usual. This fee logic applies to every swap on every pool using this hook - it does not depend on whether the pool is whitelisted (see next steps). Whitelisting only affects whether this swap is allowed to influence the reference measurement, not whether the fee itself is charged.
6

Checking if the Pool is Whitelisted

Whether a pool is allowed to feed the shared median at all is decided once, at pool creation - not per swap. When the pool is initialized, the hook checks if either of its two tokens is on the chain-specific whitelist, and stores that result as the pool’s registration status. Only swaps on a registered pool can go on to update the median (see next steps); swaps on a non-registered pool never affect it, no matter how large their priority fee is.
7

Checking Post-Swap Price Movement

For registered pools only, after the swap completes the hook checks how much the pool’s price actually moved as a result of this swap. How much price movement counts as “meaningful” is not fixed - it automatically adjusts based on how much liquidity is currently available in the pool.
8

Updating the Measurement

Meaningful Movement Required to Update. The hook only updates its internal “typical priority fee” measurement if the swap passed both checks (STEP 6 and STEP 7).
The whitelist and tick-movement checks ensure no dust swaps, and no swap on a non-whitelisted pool, can move the Median. It is extremely important because the Median is shared by all pools on the chain.
That’s it! Even if the code structure looks complicated, it does just quite a few things and changes nothing but the swap dynamic fee. So that’s why it is important that pool created also has dynamic fees enabled. Read how to Deploy Hook here.

On-chain events for indexers / frontends

The hook emits three events so downstream tools don’t need to trace or run an archive node:
  • PoolRegistered(id, registered) - emitted once, in afterInitialize, with the pool’s whitelist result described above.
  • FeeApplied(id, fee, priorityFee, referenceMedian) - emitted on every swap (beforeSwap), regardless of whitelist status, letting anyone reconstruct which swaps were penalized and by how much.
  • MedianUpdated(id, newMedian, step, positive) - emitted only when a swap actually updates the running median (i.e. only for registered pools that passed the tick-movement check).
Last modified on August 27, 2026