In a liquidity pool, for example one that contains and tokens BUSD and WBNB, a liquidity provider owns a share of the BUSD and WBNB in the pool that is proportional to its number of LP tokens. For instance, if you own 1 BUSD-WBNB LP token out of a total of 100 BUSD-WBNB LP tokens shared among the liquidity providers, you will get and tokens BUSD and WBNB when removing your liquidity from the pool.
However, the ratio between the quantities and may evolve with time, and so the quantities of each token that you obtain when removing your liquidity may be different to the quantities you provided initially! There are two mechanisms that explain the variations of both tokens in the pool:
In the first case, tokens are removed or added exactly in the proportion of the pool. Therefore these operations do not change the relative proportions of each token in the pool and so there is no change in the quantities of tokens a liquidity provider will obtain from removing its liquidity.
In the case of swaps, let us say that before the swap, the BUSD-WBNB pool contains and tokens BUSD and WBNB respectively. After your swap, there will be and such tokens. These quantities are related by the constant product rule:
In other words, the product of the quantities of BUSD and WBNB tokens inside the pool is constant.
For example we see that if the quantity of BUSD in the pool increases then the quantity of WBNB decreases. The exact quantity of WBNB obtained by swapping in this pool also depends on a liquidity provider fee, as we will see next with the swap formula in the article
In particular, we see that after the swap we have . Thus a liquidity provider who redeems its tokens from the pool after the swap will get more BUSD tokens and less WBNB tokens than he initially provided.
There are pools with more sophisticated rules than the constant product rule, which can lead to very different and interesting behaviours. In fact one of the major updates of Uniswap V3 is to introduce pools with a new rule called Concentrated Liquidity, which roughly speaking enables different token prices to coexist inside a single pool.