0

I have searched this Stack and read tutorials like this one: https://vomtom.at/how-to-use-uniswap-v2-as-a-developer/, but I'm still not 100% I understand what "liquidity" and "reserves" are.

Let's take an example. I want to track the number of tokens for a pair on a DEX (decentralized exchange), through smart contracts. Let's say I want to track WAVAX/USDT.e on the platform Trader Joe. The pair can be tracked here: https://snowtrace.io/address/0xed8cbd9f0ce3c6986b22002f03c6475ceb7a6256#readContract (NOTE: this page tracks the pair, not the individual tokens). If we go to Contract > Read contract we can actually query the smart contract directly from the page. If we trigger getReserves we get two numbers back:

reserve_contract

reserve0: 812366423471170692437931
reserve1: 69748145940889

AFAIK, reserve1 is the "raw reserve" of USDT.e (since we're looking at the pair WAVAX/USDT.e). We know that USDT.e uses 6 decimals, so the real reserve of USDT.e is: 69,748,145.940889. Correct?

If this process is correct, it means that - when I queried - there was ~69 million USDT.e "on the DEX". Correct?

These 69 million, is that what is called the "liquidity" of the token? Does that mean that the maximum amount of USDT.e I can buy from this DEX is 69 mill?

2 Answers 2

1

Yes, your process is correct.

Additional side-note which kept me busy for some time so someone in the future might see this as helpful:

Reserves refer to the LP pools, and not the token balance in the contract.

I was confused first, when I compared the reserve data with the token balance and it didn't match. And that's correct because of this exact reason I mentioned above.

0

Not really, you can never buy all the reserves. Different DEXs use different equations to calculate how much tokenB you can get for x amount of tokenA.

But let's take UniswapV2's equation, which is the most widely used:

XY = K

, where X represents the reserves of tokenA and Y the reserves of tokenB. Since factor K will always stay fixed, you can theoretically come close to getting all the tokenA from the pool, if you send a large amount of tokenB, but will never reach it.

To answer the second part, usually in a pool you have some protocol token (tokenA) and an underlying token (tokenB) that gives the pool its value. This is usually ETH or a stablecoin like USDT. Liquidity is then measured by how much underlying token there is in the pool. It is used to give an impression on how much the pool is worth and how stable the exchange rate is.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.