Hi all, I am trying to create a token swap where someone can buy my erc20 token for a specific rate that is not a whole number. The part of my code I am having trouble with is the transfer part and is as follows (note that "rate" is equal to 105):
uint256 amount = ((_amount) * (100 / rate));
timeToken.transfer(msg.sender, amount);
I have a front end too and when I try swapping the tokens, nothing is received is the callers account; note that if I do the following, the caller receives _amount*105 of the tokens they used:
uint256 amount = ((_amount) * (rate));
timeToken.transfer(msg.sender, amount);
Any and all help is appreciated!