So the penalty curve looks like this:

Design questions
Why is the basic fee 0.1%?
2
Why does the penalty start only from 2.7x?
1
Why is the cap 10%?
3
The formula
The curve is computed on-chain with the formula below, using OpenZeppelin’sMath library.
Why frac^1.5 and not a “real” power function
Solidity has no cheap general pow for fractional exponents. But frac^1.5 can be rewritten as:
sqrt is cheap on-chain via Math.sqrt. So the whole curve costs one multiplication and one integer square root, with no fixed-point ln / exp / pow library needed.
Constants
Formula → code mapping
How this looks in the code
All fixed-point math here uses two scales:PRECISION = 1000 for the ratio (so 2700 means “2.7x”), and WAD = 1e18 for the fractional-exponent part.
Notes
M(reference median) is a smoothed value, not the live running median directly — see [link] for how it’s derived.- Edge case: if
referenceMedian <= 0(no data yet),getDynamicFee_returnsBASIC_FEEdirectly, skipping the ratio/penalty calculation to avoid division by zero.
Key takeaway
- Every swap pays a flat 0.1% baseline.
- Nothing extra is charged until the priority fee is 2.7x the reference median.
- Above that, a smooth
frac^1.5curve adds up to 10% more, saturating at 10x. - The whole thing is computed with one multiplication and one
Math.sqrt, cheap enough to run on every swap.
