Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getAmountsForCurrentLiquidity returns wrong numbers #13

Open
npabisz opened this issue Jan 25, 2023 · 2 comments
Open

getAmountsForCurrentLiquidity returns wrong numbers #13

npabisz opened this issue Jan 25, 2023 · 2 comments

Comments

@npabisz
Copy link

npabisz commented Jan 25, 2023

Hi, great lib!

I have hard time getting getAmountsForCurrentLiquidity to return me correct numbers.

POOL: https://etherscan.io/address/0x7b12d855445073987D45ea97B1af3554f05E4ef4

const tickSpacing = await factoryV3.methods.tickSpacing().call();
const slot0 = await factoryV3.methods.slot0().call();
const liquidity = await factoryV3.methods.liquidity().call();

const [token0Reserves, token1Reserves] = univ3prices.getAmountsForCurrentLiquidity(
    [18, 18],
    liquidity, 
    slot0.sqrtPriceX96,
    tickSpacing,
);

At the moment I checked the liquidity the values were as follows:

liquidity = '245601860687069854565223'
slot0.sqrtPriceX96 = '278325983107464703780213223'
tickSpacing = 200

This resulted in:

token0Reserves = '110134.75101'
token1Reserves = '7.23672'

However there was 82.19160422 WETH and 23658181.1760672 WOOL.

Am I missing something?

@sierret
Copy link

sierret commented May 15, 2024

BUMP. Similar issue.

@nnti3n
Copy link

nnti3n commented Aug 27, 2024

So any other ways to calculate token0Reservesand token1Reserves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants