Poolfish has been acquired by Metrix Finance. All LP & lending tools now live on Metrix.

How the Uniswap calculator works

The V3 calculators follow the math presented from the Uniswap whitepaper. We designed the estimations to be based on previous volume data and use the same math that the smart contracts of the pools use.

You can see the breakdown of how it works here. 👇

Calculation Breakdown

1. Calculate deposit amount of token0 and token1

  • Refer to Uniswap V3 Whitepaper (Formula: 6.29, 6.30, P.8), we can calculate total amount of each token by using these formulas: (if il <= ic < iu; where il = lowerTickId, ic = currentTickId, iu = upperTickId, Pl = lower price, Pu = upper price)

    • deltaY = deltaL * (sqrt(P) - sqrt(Pl))
    • deltaX = deltaL * (1 / sqrt(P) - 1 / sqrt(Pu))
  • For estimation of the amount of token0 (deltaX) and token1 (deltaY) we need to know deltaL that make:

    • deltaY * priceUSDY + deltaX * priceUSDX = depositAmountUSD
  • So we can write a equation like this:

    • deltaL * (sqrt(P) - sqrt(Pl)) * priceUSDY + deltaL * (1 / sqrt(P) - 1 / sqrt(Pu)) * priceUSDX = depositAmountUSD
    • Then: deltaL = depositAmountUSD / ((sqrt(P) - sqrt(Pl)) * priceUSDY + (1 / sqrt(P) - 1 / sqrt(Pu)) * priceUSDX)
  • After we've calculated deltaL, we can calculate deltaX and deltaY using these formulas mentioned in Uniswap v3 Whitepaper

    • deltaY = deltaL * (sqrt(P) - sqrt(Pl)) (Formula: 6.29, P.8)
    • deltaX = deltaL * (1 / sqrt(P) - 1 / sqrt(Pu)) (Formula: 6.30, P.8)

2. Calculate estimated fee

  • Estimated fee (daily) can be calculated by this equation:

    • fee = feeTier * volume24H * (deltaL / (L + deltaL)) where:

      • volume24H = average of 24h volume from [currentDay - 7, currentDay - 1]

      • L = total liquidity (cumulative of liquidityNet from all ticks that il <= ic)

      • deltaL = delta liquidity, can be calculated from:

        • liquidityAmount0 = amount0 * (sqrt(pu) * sqrt(pl)) / (sqrt(pu) - sqrt(pl))

        • liquidityAmount1 = amount1 / (sqrt(pu) - sqrt(pl))

        • if ic < ildeltaL = liquidityAmount0

        • if ic > iudeltaL = liquidityAmount1

        • if ic >= il && ic <= iudeltaL = min(liquidityAmount0, liquidityAmount1)

Check out this video and blog post to learn more about providing liquidity and how to calculate fees. We even offer a full video course on how to make moeny liquidity providing.

Poolfish was previously called Uniswap.fish and received a couple of grants from the Uniswap Foundation as well as GitCoin.

Let us know if you have any questions! You can always contact us.

Who wrote this

This post is from the Poolfish archive. Noah Bragg bought Uniswap.fish in 2023, rebuilt it into Poolfish, and wrote most of what you just read. Poolfish is now part of Metrix Finance, so the tools have moved, and you can read the announcement or the whole story.

The next build-in-public

$250 and a camera

Noah built Poolfish in public, and the habit did not stop with the sale. He put $250 into a trading account, pointed a camera at it, and publishes the whole thing. Setups, entries, stop-losses, and the trades that go against him. Nothing edited out afterwards to look smarter. The channel is new, so you would be early enough to watch it happen instead of hearing about it later.

@noahtwofifty on YouTube. Trade setups posted to X in real time, win or lose.