In its simplest and most traditional form, a DEX liquidity pool consists of a token pair, or two individual tokens. These pools are usually created by a factory contract, which also defines key parameters such as the trading fee percentage or the revenue split.
One of the most accurate methods for obtaining the liquidity of each token within a pool is to use traces and filter them based on the balanceOf function. The first 4 bytes of the input in a trace can serve as the function signature. After filtering, the resulting value represents the unadjusted balance of the token.
This value can then be combined with ERC-20 token metadata or pricing data to calculate the adjusted balances and their USD equivalents.