I need to get liquidity of tokens. Example, bnb – cake, new token – bnb, new token – busd.
I found 2 options as I can.
First option, It use lp address.
use a decision
// Ratio in % of LP tokens that are staked in the MC, vs the total number in circulation lpTokenRatio = lpTokenBalanceMC * lpTotalSupply // Raw amount of token in the LP, including those not staked tokenAmountTotal = tokenBalanceLP / BIG_TEN.pow(tokenDecimals) anyTokenAmountTotal = anyTokenBalanceLP / BIG_TEN.pow(quoteTokenDecimals) // Amount of quoteToken in the LP that are staked in the MC anyTokenAmountMc = anyTokenAmountTotal * lpTokenRatio // Total staked in LP, in quote token value lpTotalInAnyToken = quoteTokenAmountMc * new BigNumber(2) totalLiqiudity = lpTotalInAnyToken * anyTokenPriceBusd
But, I don’t know how to get new lp address.
Second option, It use https://docs.uniswap.org/sdk/2.0.0/reference/pair#getliquidityvalue, However, I saw
getLiquidityValue( token: Token, totalSupply: TokenAmount, liquidity: TokenAmount, feeOn: boolean = false, kLast?: BigintIsh ): TokenAmount
There is third argument is liquidity, but I think I get a liquidity.
I hope, smb know to get a liquidity.