Is it possible to calculate all-time global fees, earned by a Uniswap v3 liquidity pool?

Using Uniswap v3 pool contract I can retrieve feeGrowthGlobal0X128 & feeGrowthGlobal1X128, which represent

the fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool

But I don't see how to calculate the total fees earned by the pool.

Also, the feeGrowthGlobal doc comments say: This value can overflow the uint256
Which is confusing too. What happens when it overflows, isn't the information about earned fees lost?

2 Answers 2


Not sure about the first question, but for your second question: Strictly on chain, the information might be lost. But, looking at it from off chain, you can look at the history of the chain and see how many times it overflowed.

Also, the purpose of those variables is to help track the fees earned between tick marks in uniswap v3, which is why they don't care if they overflow. The math for calculating the fees between ticks doesn't have any problems if feeGrowthGlobal overflows.

In order to actually convert the units into token fees rather than like fees per unit of liquidity however, I'm not quite sure.


you do not calculate, it is already in a global state and tracked by the uniswap v3. from the v3 whitepaper

The global state also tracks two numbers: feeGrowthGlobal0 (fg,0 ) and feeGrowthGlobal1 (fg,1 ).

after u initalized the pool contract

pool.feeGrowthGlobal0X128().then((f) => f.toString()),

from UniswapV3Pool.sol,

/// @inheritdoc IUniswapV3PoolState
uint256 public override feeGrowthGlobal0X128;
/// @inheritdoc IUniswapV3PoolState
uint256 public override feeGrowthGlobal1X128;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.