Below is an explanation of how dynamic swap fee is determined.
The pool's price before swap is equal to the price before the first swap of the block. Thus, every swap uses this reference price for the pool's price before swap.
Below are a few examples of dynamic swap fee for ETH/USDC pool.