Why not an exact median
An exact median needs to store (or at least sort) every past observation. On the EVM that runs into three hard problems:- Storage cost. Every new transaction means another
SSTOREinto a growing array. Costs pile up and eventually hit block gas limits. - Recompute cost. Sorting or partial sorting (quickselect and friends) on every update costs O(n log n) or O(n) gas per swap, where n is the whole history. That quickly exceeds the swap itself.
- Unbounded state. An exact median has no built-in way to “forget” old data. Adding a window or eviction logic means even more storage operations.
P² vs Frugal2U
Source for P²: Jain, R., Chlamtac, I. “The P² algorithm for dynamic calculation of quantiles and histograms without storing observations”, Communications of the ACM, 1985. (researchgate.net)
Why Frugal2U was picked
The priority fee is not a stationary signal. It can sit calmly at 1-2 gwei for hours, then jump 10-50x within a couple of blocks (memecoin launch, liquidations, NFT mint) and drop back down just as fast. P² was designed on the assumption that the underlying distribution changes slowly or not at all. Its markers “remember” the whole history in proportion to the number of observations, so when the regime suddenly shifts (fee levels jump by an order of magnitude), P² needs many new observations to outweigh the accumulated history and catch up. For a fast-moving fee market, that means lag at exactly the moment adaptiveness matters most. Frugal2U works the other way. Its accumulating-but-easily-resetstep lets it:
- chase a new level fast when the trend keeps confirming itself, and
- stop just as fast when it turns out to be a one-off spike.
Key takeaway
Frugal2U is picked because it fits both constraints at once:- On-chain feasible. 3 state variables and minimal arithmetic per update, vs. P²’s 10 variables and interpolation formula. That gas gap runs on every swap.
- Right dynamics for priority fees. Adapts quickly to genuine regime shifts and shrugs off isolated outliers, thanks to the growing-then-resetting
step.