Routers
Last updated
TL;DR – Why AEGIS DFM Is the Least‑Surprise Dynamic‑Fee Hook for Aggregators
Deterministic pricing. Every fee component is a pure, on‑chain function.
“Never‑higher” guarantee. Your user pays ≤ the fee you simulated 99.75 % of the time …
Edge‑case bounded & predictable. That surge fee hits exactly one follower trade, then linearly decays to zero over the next few hours.
No exotic math. Pool invariant stays constant‑product; keep your usual Uniswap‑V3/V4 price‑impact logic.
Gas‑friendly. The only extra storage write burdening swaps is the oracle observation, similar to Uniswap V3.
File & line: DynamicFeeManager.sol 180‑222
Logic: Clamps between per‑pool min / max using on‑chain volatility (maxTicksPerBlock).
Trigger
If a single block’s tick‑move exceeds maxTicksPerBlock, TruncGeoOracleMulti (150‑169) sets capStart
Cap trade
Pays no surge (fee = base)
First follower trade
Pays base + surge
Subsequent trades
Surge decays linearly to 0 over decaySecs (228‑252)
Returns the exact numbers the next swap will use—no hidden maths.
Permission bitmap excludes beforeModifyPosition; only swap callbacks enabled (Spot.sol 90‑111). Constant‑product forever.
Usual pain‑point
Typical dynamic hooks
AEGIS DFM
Hidden admin fee changes
Upgradeable proxies, opaque owner calls
On‑chain fee logic
Fee can spike after simulation
No public pre‑swap view
getFeeState() = what you will pay (unless rare cap)
Multiple paths to fee inflation
Policy gates, beforeModifyPosition
Single path (cap event) + bounded surge
Complicated invariants
Logistic/TWAMM curves
Same xy = k maths you already implement
Whitelist byte‑code hash (one‑time).
Display live fee to users via the same getFeeState() call.
Last updated
function getFeeState(bytes32 poolId)
external view returns (uint24 base, uint24 surge);