🛄Initialization of Liquidity Token Supply

When a new liquidity provider deposits tokens into an existing MTVSwap pair, the number of liquidity tokens minted is computed based on the existing quantity of tokens:

However, if they are the first depositor then xstarting is 0, so this formula will not work. Instead, MTVSwap initially mints shares equal to the geometric mean of the amounts Deposited:

This formula ensures that the value of a liquidity pool share at any time is essentially independent of the ratio at which liquidity was initially deposited. For example, suppose that the price of 1 ABC is currently 100 XYZ. If the initial deposit had been 2 ABC and 200 XYZ (a ratio of 1:100), the depositor would have received √(2 · 200) = 20 shares. Those shares should now still be worth 2 ABC and 200 XYZ, plus accumulated fees. If the initial deposit had been 2 ABC and 800 XYZ (a ratio of 1:400), the depositor would have received √( 2 · 800 ) = 40 pool shares.

The above formula ensures that a liquidity pool share will never be worth less than the geometric mean of the reserves in that pool. However, it is possible for the value of a liquidity pool share to grow over time, either by accumulating trading fees or through “donations” to the liquidity pool. In theory, this could result in a situation where the value of the minimum quantity of liquidity pool shares (1e-18 pool shares) is worth so much that it becomes infeasible for small liquidity providers to provide any liquidity.

To mitigate this, MTVSwap burns the first 1e-15 (0.000000000000001) pool shares that are minted (1000 times the minimum quantity of pool shares), sending them to the zero address instead of to the minter. This is a negligible cost for almost any token pair. But it dramatically increases the cost of an attack. In order to raise the value of a liquidity pool share to $100, the attacker would need to donate $100,000 to the pool, which would be permanently locked up as liquidity.

Last updated