I got little confused about buy and sell functions in the example of token contract, where do they get ether/tokens to make this exchanges?
- if this functions get ether and tokens from the contract owner, it would add big vulnerabilities because you can change owner without his approve and stole his money/tokens;
- if this functions get ether and tokens from the contract creator, then owner changing won't change this and you will need to safe creator's private key until you want to be able to get ether/tokens from buying/selling tokens;
- if you need to send both ether and tokens to the contract address to have this functions working then you will have this tokens/ether lost forever, or you need to add your own functions to get this token/ether from the contract (that are not in standard contract template).
I believe it's not the first way, but I'm not sure what way is exactly used and how people cope with the limitations of that way.