Getting the reserves data for a liquidity pool using SaucerSwap's REST API is also a suitable alternative. For more information, see Get liquidity pool reserves (V1). The pool metadata includes the reserve data.
To track updates to liquidity pool reserves in near real-time, see Track LP updates (V1).
Get Pool Reserves via REST API
Fetch all HTS token balances for a pool via Mirror Node's REST API.
import*as ethers from'ethers'; //V6//Set one of Hedera's JSON RPC Relay as the providerconstprovider=newethers.JsonRpcProvider(hederaJsonRelayUrl,'', { batchMaxCount:1,//workaround for V6});//load abi data containing Pair's getReserves() functionconstinterfaces=newethers.Interface(abi);constpoolContract=newethers.Contract(poolAddress,interfaces.fragments, provider);constresult=awaitpoolContract.getReserves();constreserve0=result.reserve0; //in token's smallest unitconstreserve1=result.reserve1; //in token's smallest unitconstblock=result.blockTimestampLast;