I'm a little bit confused because the Uniswap v3 Nonfungible Positions Manager has a positions function, that's supposed to return token0Owed and token1Owed, which is (I think in not just my case) is always zero, regardless of how many fees have accumulated already. All the answers on Stackexchange point to now paid 3rd party services to query this info.

Where do those services get their data from?

I really wanna get down to this and query / calculate it directly from the blockchain. Thank you for your help

1 Answer 1


These token0Owed and token1Owed doesn't return the collectables fees. My two cents:

I wrote a function that perform a static call passing the maximum collectable value in other to see how much is pending to be collected.

export const calculatePendingFees = async (
  tokenId: number,
  recipient: string,
  amount0Max: BigNumber,
  amount1Max: BigNumber,
  chainId: number
) => {
  try {
    const params = {
      tokenId: tokenId,
      recipient: recipient,
      amount0Max: amount0Max,
      amount1Max: amount1Max,

    const nonfungible = new ethers.Contract(

    const feesGenerated = await nonfungible.callStatic.collect(params)
    return feesGenerated
  } catch (error) {
    console.log(error.message, "calculate fees error")

For amount0Maxand amount1Maxyou can use this:

const MAX_UINT128 = BigNumber.from(2).pow(128).sub(1)

This function will return to you the uncollected fees :)

  • Thank you a lot. I've come across a similar solution, but I thought this does a transaction, I haven't used callStatic before. Commented Jan 3, 2023 at 15:13

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.