'How to calculate Total Value Locked for a liquidity pool?

I want to calculate Total Value Locked (TVL) for a liquidity pool pair programmatically. I need this value in order to calculate APR, and all other values I've already calculated with MasterChef smart contract, and now I'm missing this. I guess there is a getBalance(poolAddress) function or something like that, but on my Masterchef smart contract there is no one.

The DEX I've been working with is AuroraSwap and Masterchef smart contract address is 0x35CC71888DBb9FfB777337324a4A60fdBAA19DDE

All smart contracts: Factory 0xC5E1DaeC2ad401eBEBdd3E32516d90Ab251A3aA3 Router 0xA1B1742e9c32C7cAa9726d8204bD5715e3419861 Borealis (BRL) 0x12c87331f086c3C926248f964f8702C0842Fd77F Masterchef 0x35CC71888DBb9FfB777337324a4A60fdBAA19DDE

Generally, I don't understand what are these smart contracts used for except Masterchef. There are not many docs on the web, and I'm trying to learn technology on my own.

For now, I didn't even understand how to calculate TVL for any DEX, like Uniswap, so if somebody has knowledge about that, would be awesome to post an answer here, and maybe I'll find some analogy and solve this for Auroraswap.

Regarding programming language anything is fine.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source