Wow, okay, almost a year passed after I asked this question. During this period I was learning smart contract development and honestly, I'm proud to answer my past self.
- Supply and price
Determining price and adjusting supply in respect of your projections is very straightforward:
Basically (for Uniswap v2 and Pancakeswap V1) price is determined by
To explain what these variables represent, I should first explain what is a decentralized exchange and AMM.
CEX or centralized exchange is a traditional way of trading crypto assets, their order book is used to let people trade their assets, propose their prices, and reach the consensus for optimal one with other traders. Sounds complex but just think this way, it is how we exchange daily assets like money or commodities with each other, Alice sells an apple for 10 bucks, while Bob wants that apple but is willing to pay 8 bucks, their consensus price might be 9 bucks, and trade was successful, but the problem arises, what if Bob doesn't want the apple for 9 bucks, or what if there is no Bob at all, Alice has to wait for someone willing to buy her apple.
This problem was resolved by creating a DEX, a decentralized exchange where an automated market maker is used, instead of an order book.
in the case of AMM, Bob wants to buy an apple, he can go and buy it from a special apple pool created by Alice where Alice put for example 1 Apple and 1 USD, meaning 1 Apple will cost 1 USD But the apple pool is fully automated and secured, so Bob doesn't have to wait for Alice to show up with apples, he can use the automatic pool and price is already determined by how much USD is in the pool with how much Apples.
To wrap up, determining the price is possible with the formula given above where
x is one asset,
y is another asset, and `k is constant.
If someone buys token x with y, then the supply of token x decreases as the supply of y increases causing the price of token x to increase. Then vice-versa.
So, based on that, to determine the good supply and approx price, we can use the following formula
Price = (x * x price in $) / amount of y
Suppose x (the first asset, that will determine price, should be the existing one and recommended to use native coins, for example, ETH for ethereum or BNB for binance smart chain, but you can go for any other coin that is being already traded) is 100 BNB, and we have 1mil supply of our token:
Price = (100 * current BNB price 400) / 1000000
Price = 0.04$
So, 1 your token will cost 0.04$ or 0.00012BNB in the current BNB price.
- Mining ERC20
As I remember, here I thought that ERC20 was just like other coins and it had default POW consensus, transactions, etc.
So to respond to me, no ERC20 is a standard for a token that lives in an already made blockchain, and ERC20 isn't responsible for transactions.
All thought, there is an implementation of mining in ERC20 called
0xbitcoin, but again, it is just simulating POW consensus, mining is not needed in tokens.
- Changing after deployment
No, the main idea of smart contracts is that it's secured and non-mutable by third parties. But there are ways to do so, implementing proxies for example, or making separated contracts that are working together but in case of malfunction, you can replace the broken contract and link it to the main contract with premade function. But this is not a recommended way to go. It would be hard for people to trust you when you have such tremendous power. And it kinda goes against decentralization as well.
To make a conclusion, I'm happy to answer my dumb questions and hope in future i will make more and more progress in this field