The Missing Trillion-Dollar Math
Uniswap has processed nearly $3 trillion in trading volume since its launch. With a 0.3% fee, this translates to roughly $9 billion in cumulative fees for liquidity providers and the protocol.
Figure 1. Uniswap Cumulative Trading Volume Since Inception.
Yet, despite these staggering numbers, nobody has publicly derived the formula behind Uniswap’s fee calculations – until now.
The Mysterious Formula in Uniswap’s White Paper
Uniswap’s whitepaper references the following formula for total fees collected by liquidity providers:
But where does this come from? Surprisingly, there’s zero public derivation – no academic papers, no StackExchange explanations, and not even AI tools (ChatGPT, Grok, DeepSeek) could crack it.
Figure 2. StackExchange Forum Request.
Does Uniswap Actually Use This Formula?
Unlike many “Web2.5” projects that overpromise and underdeliver, Uniswap’s code matches its whitepaper. A deep dive into UniswapV2Pair.sol confirms the formula is implemented as described.
Figure 3. UniswapV2Pair.sol Smart Contract.
The First-Ever Public Derivation of Uniswap’s DEX Fees
Key Insight: Fees = IL(with fees) – IL(no fees)
We start with the assumption that cumulative DEX fees can be derived from the difference between:
- Impermanent Loss (IL) with fees
- IL without fees
Mathematically:
Recap: Impermanent Loss Formulas
From previous articles, we know:
IL with fees:
IL without fees:
Where:
(price change ratio)
(pool constants before/after swap)
Step-by-Step Derivation
Express IL in absolute terms (not %):
Subtract to isolate DEX fees:
Simplify Value(LP)HODL:
Integrating with d:
And plugging in x1y2 into the Value(LP)HODL:
Substitute back:
Revisiting d:
Multiply both sides by y1y2:
Where:
Plugging both k’s:
Solving for d:
Squaring both sides:
Plugging in back into Total DEX Fees:
2y2 is the value of the LP after swap in terms of Token Y:
Express as a % of LP value after swap (2y2):
This matches Uniswap’s formula exactly!
Why This Matters
- First public proof of Uniswap’s fee model.
- Confirms that fees offset Impermanent Loss.
- Enables better LP strategies by quantifying fee impact.
Stay tuned for Part 9, where we apply this in real-world scenarios!
Final Note: This is the first and only complete derivation of Uniswap’s DEX fee formula. Bookmark it – you won’t find this anywhere else. 🚀