Each asset in a liquidity pool always accounts for 50% of the total value of the liquidity pool. Let’s assume ETH is swapped for tokens, so tokens are bought. More concrete, ETH is added to the ETH share of the pool, and tokens are removed from the pool. This means that less tokens are now worth more ETH, meaning that the price has increased. In the other case, where tokens are swapped for ETH, so tokens are added to the pool, more tokens are equal to less ETH, meaning the price will drop. Evidently, buying -> price goes up, selling -> price goes down.
The price of the token is therefore solely determined by the amount of tokens and the amount of ETH in the pool. For example:
Imagine a TOKEN/ETH pair. If 1 million tokens and (for the sake of simplicity ETH = $1000) 100 ETH are in the pool, the price of the token will be the dollar value of 100 ETH, so $100 000 divided by 1 000 000, so $0.10 per token. If then, 10 ETH is bought, which means 10 ETH is swapped for 100 000 tokens (10 ETH = 100 000 tokens = $10 000), 10 ETH will be added to the pool, and 100 000 tokens will be removed from the pool. The pool, which was initially 100 ETH / 1 000 000 tokens, will now be 110 ETH / 900 000 tokens. Since more ETH and less tokens are in the pool, the price of the token will now be 110/900000 = $0.12.
That’s basically it for the AMM. To be completely correct, the price is not linearly but quadratically dependent, but you get the idea.
As for the fees:
A trader trading on Uniswap will always pay a 0.3% fee, a so called liquidity provider fee. This amount is added to the corresponding side of the pool. If you swap 1000 tokens for ETH you will pay a fee of 3 tokens. If you swap 1 ETH for tokens, you wil pay a fee of 0.003 ETH. As said, this will be added to the pool as liquidity. The ones benefitting from this are the liquidity providers. Everyone can be a liquidity provider. For that, you will have to add an equal amount of tokens and ETH to the pool. As a reward, since the fees are added to the pool, you ‘receive’ the fees paid by the traders. Received is in ‘’, because you will not see these fees being added to your wallet. They will be added to your share of the pool. So let’s assume we added $10 000 liquidity to a $90 000 pool and own now 10% of the liquidity in the pool. If the 24h trading volume in the pool is for example 1 million dollars, there will be a total of $3000 paid in fees, meaning $3000 is added to the pool, in the respective asset, tokens or ETH.
If the price stays more or less the same and no one else has added liquidity, we can assume that the total liquidity in the pool is now $103 000 ($100 000 initially + $3000 fees). Since we own 10% of that pool, our share in dollar value of the pool is now $10 300. So as a liquidity provider, we earned $300. (Keep in mind that $1 000 000 volume is pretty high for most pairs on Uniswap). We made the assumption that the price stayed the same and no one else added liquidity, only because that would make things unnecessarily complicated for this example.
When providing liquidity to a pool on Uniswap, you are granted with Uni-V2 tokens. These tokens are worthless on their own, but they are proof that you have provided liquidity to the pool. To claim back your liquidity, you will have to burn those Uni-V2 tokens and you will get your 10% share back. To do that, the easiest way, we find, is to navigate to the ‘accounts’ page on the left on Uniswap. If you enter your own address, you will see in which pools you have liquidity, and then just click remove. Then, you will get your $10 300 back. Of course you don’t have to withdraw your total share.
On centralized exchanges, there are orderbooks, which roughly give you an idea of the sell/buy pressure. On a decentralized exchange, like Uniswap, there is no such thing. Every trade is executed at market price. This market price, as explained above, is determined by the amount of each asset in the pool. On the UI of Uniswap, there is no possibility to place limit orders. At Kairon Labs however, we have an internal system that constantly monitors the price, and executes orders at the right times, just like limit orders on a centralized exchange. On top of that we also have an arbitrage system that can execute on price discrepancies between different decentralized and centralized exchanges.