Price = Total Supply (y = x)is used.
aand a buyer tries to purchase
aup to the
bsupply (the amount of tokens the persons buys =
b - a), the amount of MINT tokens is calculated as below:
totalSupply = price collateralBalance = 1/2 * totalSupply^2
tokensToBeMinted = √ (2 * (amountPaid + collateralBalance)) - oldTokenSupply
amountToRefund = collateralBalance - 1/2 * (oldTokenSupply - sellingTokenAmount)^2