Calculate Pool Liquidity

Calculate the value of pool liquidity in USDC

Step 1: To get the value in USD for a LP token, our exchange abi has method called getLtPrice (contract address'):

{
constant: true,
inputs: [
{
internalType: "uint256",
name: "_assetPrice",
type: "uint256"
},
{
internalType: "uint256",
name: "_stablePrice",
type: "uint256"
}
],
name: "getLtPrice",
outputs: [
{
internalType: "uint256",
name: "",
type: "uint256"
}
],
payable: false,
stateMutability: "view",
type: "function"
},

Step 2: Call the getLtPrice method with the current price of ETH and USDC

const ltPrice = exchangeInstance
.methods
.getLtPrice(
1952232000000000000000n, // $1,942.23
1000000000000000000n // $1
)

Step 3: Retrieve LP tokens from the users wallet balance and multiply it by the current LtPrice: