> ## Documentation Index
> Fetch the complete documentation index at: https://pulse-hook.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# E2E Flow

> End-to-end flow executed when a swap reaches PFPHook

<Frame>
  *If you somehow find this docs without knowing what Uniswap v4 hook is, check this link.*
</Frame>

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:**

<Steps>
  <Step title="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.
  </Step>

  <Step title="Comparing to the Typical Level">
    The hook compares the current swap's priority fee to Median across latest 15 blocks/
  </Step>

  <Step title="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.
  </Step>

  <Step title="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. 
  </Step>

  <Step title="Swap Executes with Applied Fee ">
    The swap is executed by the pool as normal. The extra fee collected go to liquidity providers as usually.
  </Step>

  <Step title="Checking Post-Swap Price Movement">
    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.
  </Step>

  <Step title="Checking if Swap Tokens are whitelisted" />

  <Step title="Updating the Measurement.">
    "Meaningful Movement Required to Update. The hook only updates its internal "typical priority fee" measurement if the price moved by a meaningful amount AND at least one of the tokens is in the whitelist.
  </Step>
</Steps>

<Frame>
  Steps 6-7 ensures no Dust Swaps can have place to update the Median. It is extremely important cause Median is one for all pools on the chain. Read here why it is built in such way.
</Frame>

**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 your hook here.**
