Please create buy struct with similar parameters as sell, namely tokenAmount, afterPriceDecrease. But also have buy.percentOfSellPrice.
If sell.tokenAmount or buy.tokenAmount is 0, then skip selling or buying, respectively.
If afterPriceDecrease is 0, then this would be a constant price at which you buy or sell, in terms of WETH.
If percentOfSellPrice > 0 then this would be used instead of afterPriceDecrease when calculating how much to buy back. See next issue.
Now, sell.tokenAmount is supposed to be directly set in the initialization parameters, so remove sell.eventsTotal. Just make sell.tokenAmount = 1 million by default, while init parameter totalSupply = 1 billion. If there are not enough tokens to sell, or not enough WETH to buy, then don't sell or buy, respectively, just emit a log/event and continue.
Please create
buystruct with similar parameters assell, namelytokenAmount,afterPriceDecrease. But also havebuy.percentOfSellPrice.If
sell.tokenAmountorbuy.tokenAmountis 0, then skip selling or buying, respectively.If
afterPriceDecreaseis 0, then this would be a constant price at which you buy or sell, in terms of WETH.If
percentOfSellPrice > 0then this would be used instead ofafterPriceDecreasewhen calculating how much to buy back. See next issue.Now,
sell.tokenAmountis supposed to be directly set in the initialization parameters, so removesell.eventsTotal. Just makesell.tokenAmount = 1 millionby default, while init parametertotalSupply = 1 billion. If there are not enough tokens to sell, or not enough WETH to buy, then don't sell or buy, respectively, just emit a log/event and continue.