Code Monkey home page Code Monkey logo

uniswap.fish's Introduction

๐Ÿฆ„ UniswapCalculator

Uniswap V3 Fee Calculator, Visit: Poolfish, @poolfish_xyz

Disclaimer: please do your own research, this website is intended to be used and must be used for informational purpose only. It is very important to do your own analysis before making any investment based on your personal circumstances.

Report a bug or request a feature

Features

  • Fee calculation: select pair and pool, input deposit amount (USD), and adjust your lower and upper price
  • Liquidity position histogram and correlation chart to help you plan your strategy better
  • It's 100% open source! hope that Uniswap community will bring a lot more ideas and features to this project

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 < il; deltaL = liquidityAmount0
        • if ic > iu; deltaL = liquidityAmount1
        • if ic >= il && ic <= iu; deltaL = min(liquidityAmount0, liquidityAmount1)

See more on how the Uniswap Calculator works.

Crafted with ๐Ÿงก by @noahwbragg. Previously @chunrapeepat.

uniswap.fish's People

Contributors

chunrapeepat avatar kirrya95 avatar normdoow avatar not-reed avatar pepewitch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uniswap.fish's Issues

Persist selected token pair in URL

It would be great if the selected tokens can be added to the url so refreshing the page doesn't force you to select the tokens again.

feat+1: please add L2 support, OE and Arbitrum

Hi - great tool and thx for sharing!
would it be possible to add L2 support for Optimism and Arbitrum?
I tried to replace the graph URL to OE but apparently token addresses have to be retrieved somehow differently too and my coding skills are not good enough to change myself.
Best,
Nikolai

Error loading contract for ENS pair

Reproduces on ETH:ENS pair with 0.3% tier.

To reproduce:

  1. Select ETH
  2. Select ENS (4 ENS's show up, seems the 2nd option is the correct-est one?)
  3. Pick any fee tier (e.g. 0.3%)

Loading throbber throbs forever, console gets an error:

caught (in promise) Error: Unable to find token from contract address "0xc18360217d8f7ab5e7c516566761ea12ce7f9d72"
    at coingecko.ts:39:11
    at c (runtime.js:63:40)
    at Generator._invoke (runtime.js:293:22)
    at Generator.next (runtime.js:118:21)
    at r (asyncToGenerator.js:3:20)
    at u (asyncToGenerator.js:25:9)
    at asyncToGenerator.js:32:7
    at new Promise (<anonymous>)
    at asyncToGenerator.js:21:12
    at coingecko.ts:32:27

Handle "Unable to find token from contract address" Error

When certain tokens are selected, Tokemak (0x2e9d63788249371f1DFC918a52f8d799F4a38C94) for instance, an error is thrown:

Uncaught (in promise) Error: Unable to find token from contract address "0x2e9d63788249371f1dfc918a52f8d799f4a38c94"

When this occurs the app is broken and a refresh is needed to continue. Also there is no information presented to the user to alert them. I was wondering why the loading image was spinning forever so I decided to take a look at app and noticed this error.

Feature Request: liquidity distribution similar to uniswap.info

Amazing calculator! I have been looking for a tool like this since v3 was launched. Thank you very much for making this.

My first impression for the liquidity distribution visual was a little confusion as I am used to the chart on uniswap info.

For example:

Screenshot_20211129-153012_(1)

Vs

Screenshot_20211129-153150_(1)

Would create more continuity between the two graphs if they were presented similarly.

Decimals are wrong?

src/utils/math.ts:115

const amt0 = expandDecimals(amount0, token1Decimal);
const amt1 = expandDecimals(amount1, token0Decimal);

Looks like the decimals are reversed.

feat: Add L2 support

Please add Ethereum L2 fee calculation options. Start with Arbitrum.

So far from all the calculators tho this one is by far the most responsive in terms of performance and interactivity. Thanks!

Feature: guideline for newbies

Add guidelines for some concepts like fee tiers (0.05% or 0.3% vs 1%, fee tiers strategy), price ranges, range order, etc.. so that newcomers know how to plan their strategy

Doubts about installing the calculator

Good evening, I would like to install this impermanent loss calculator that you have on your website on a self-hosted basis, is there a step-by-step guide on how I do this? I'm from infrastructure, so I know how to set up a vm for this, but I wanted a step-by-step guide or a Python script where I enter the same data: Deposit Amount, Min Price, Max Price, Most Active Price Assumption, and then the option to simulate the same price as the Current Price and Future Price impermanent loss calculator and bring the same data, but instead of via the web, it would be via text.

Impermanent loss calculator doesn't factor in increase in value of assets

The calculator assumes a linear-return as the number of days progress towards the calculated Future Price. In reality, as that price is reached, the underlying fees generated have increased in value.

Animation

Take note here:
1 day position = $0.94 return
200 day position = $187.53 ($0.94 * 200)
In reality, the position would be generating MATIC and USDC, where MATIC is increasing in value. So a linear return isn't the ideal calculation here.

When the position of days is increased, I would expect to see the return of MATIC and USDC increase rather than stay the same - that way it could factor in increase in value.

Simpler way to view this problem

It's easier to visualise if you increase the Future price to be something extreme like $500 in future, across a 200 day position:

Take note of 1 day position, $0.94 yield, $1.5 future price

image

Take note of 200 day position, ONLY $187.53 yield, yet $500 future price

image

Clearly this doesn't make any sense. If your earning yield for 200 days generating MATIC and it's future price is $500 per MATIC, the yield wouldn't be only $187.53

Hope that makes sense?

Adjusting Min Value changes Max value.

Hey Chun,

Great app. Possible to make it so the 2 Min/Max fields are independent of each other?

Kind of frustrating when you're typing in a number in Min Price and have to type in the Max Price again, if you've already set it. Easy to do when trying to calculate multiple positions.

Feature request: wide range LP sliding bar/chart visuals

It took me a bit of time to figure out how to analyze wide ranges. I am not familar with the limitations of the visuals/slide bar; but if it would be possible to have the charts work with passive range Liquidity Providing. I would very much appreciate it!

Again great job; this tool should definately get a grant! Best one I have come across.

Polygon USDC/ETH estimated fee calculations

Are the USDC/ETH estimated fee calculations correct? The estimated fees look very high - when you go to select a min and max price they appear to be reversed to start - didn't know if the estimated collection fees were really this high or if there was a bug in the software for the estimation with min/max price. Thank you!!

Pair select issue

hi, seems to be an issue with token selection.
it just gets stuck on loading...
Screenshot 2021-11-14 at 09 58 33
..

marker of charts partially covered

I really like your project. just found some minor UI issues and will report them. I hope you don't mind.

In the correlation chart, the marker which indicates the price at the current cursor position is partially covered, which makes it hard to read the actual price when one want to get a rough feeling for it.

same issue with the liquidity position chart.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.