Skip to content

Instantly share code, notes, and snippets.

@bhavya2611
Last active May 23, 2021 09:58
Show Gist options
  • Save bhavya2611/adc08388e2c57912e5908b78137b510b to your computer and use it in GitHub Desktop.
Save bhavya2611/adc08388e2c57912e5908b78137b510b to your computer and use it in GitHub Desktop.
const getLpTokenReserves = async () => {
try {
const LpTokenContract = new web3.eth.Contract(
IUniswapV2Pair,
LP_TOKEN_ADDRESS
);
const totalReserves = await LpTokenContract.methods.getReserves().call();
// For ETH/DOGE Pool totalReserves[0] = ETH Reserve and totalReserves[1] = DOGE Reserve
// For BNB/DOGE Pool totalReserves[0] = BNB Reserve and totalReserves[1] = DOGE Reserve
return [totalReserves[0], totalReserves[1]];
} catch (e) {
console.log(e);
return [0,0];
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment