I want to be extract the amounts of t0 and t1 from a Uniswap v3 Pool.
I was trying with some method which I found on other post, but I think is not working, or I am doing something wrong.
This is the method tried by me:
function extractAmounts(){
const tick = -282260;
const liquidity = 31494343572914561514 //liquidityNet
const sqrtPriceCurrent = 58884551862568005367467
const sqrtPriceLow = Math.pow(1.0001, -282260);
const sqrtPriceHigh = Math.pow(1.0001, -282250);
const sp = Math.max(Math.min(sqrtPriceCurrent, sqrtPriceHigh), sqrtPriceLow)
const amount0 = liquidity * (sqrtPriceHigh - sp) / (sp * sqrtPriceHigh)
const amount1 = liquidity * (sp - sqrtPriceLow)
console.log(amount0, amount1)
}
extractAmounts();
The values printed in console for the tick(wrote manually by me) are not matching with the chart from Uniswap page (USDC locked value
, in the image):
https://info.uniswap.org/#/polygon/pools/0xa374094527e1673a86de625aa59517c5de346d32 The values from the image is for example, and is not matching the values from code.
Someone can explain to me how to calculate the amounts for a tick(current/specific one)?
A pool example(polygon): https://polygonscan.com/address/0xa374094527e1673a86de625aa59517c5de346d32#readContract