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 provider
const provider = new ethers.JsonRpcProvider(hederaJsonRelayUrl, '', {
batchMaxCount: 1, //workaround for V6
});
//load abi data containing Pair's getReserves() function
const interfaces = new ethers.Interface(abi);
const poolContract = new ethers.Contract(poolAddress, interfaces.fragments, provider);
const result = await poolContract.getReserves();
const reserve0 = result.reserve0; //in token's smallest unit
const reserve1 = result.reserve1; //in token's smallest unit
const block = result.blockTimestampLast;