good morning.
yes, my main question is about tokenomics- however, one thing confuse me profusely!
Is buying a token from DEX/CEX the same as transfer? and if so or not so, does buying tokens from DEX/CEX invoke the transfer function?
anyways, if any one is able to provide some clarity with the question above I will appreciate it with much gratitude.
okay, so the main question of this post:
I am trying to add tokenomics to my token (a 10% tax for buying, 20% tax for selling). I have already added taxing to my transfer function (I will paste the code at the end of this post), however, I am not sure how to add this to buying and selling of my token. ( Like when someone buys from pancakeswap )
I've scanned safemoon's code on their GitHub and found no buying/selling function(s) that was using tokenomics- however, I've noticed transfer functions ( which has me confused as to what actually happens 'under-the-hood' when tokens are bought. hint, my question above ).
//Adding Tax To Transfer(s)
function transfer(address recipient, uint256 amount) public override returns(bool){
//conditions
require(recipient != bankerContract, "Cannot Send To Bank");
require(recipient != burnerContract, "Cannot Send To Burner");
address sender = msg.sender;
//Checking if no tax is applied
if (excludedFromTax[msg.sender] == true) {
_transfer(sender, recipient, amount);
}
else{
uint256 bankAmount = amount.mul(taxFee) / 100;
//Sending to bank (tax)
_transfer(_msgSender(), bankerContract, bankAmount);
//Sending To Address
_transfer(_msgSender(), recipient, amount.sub(bankAmount));
}
return true;
}
the token is ERC20, and openzeppelin's library is installed. I am using truffle for developing this token and my text editor is VSC.
I did notice one method- or I think it's a hook of sorts... called _beforetokentransfer . It is an empty function, but do I create the taxing inside this function?
I think there is also an _aftertokentransfer which- I'm guessing- is where I would implement burn functionality if I had something like 'auto burn after every X amount of coins bought'