Calculate percentage of token user owns relative to total supply, burn it and distribute another token. I’m running into issues trying to calculate percentage and amount that has to be distributed.
function ratio(address _address, uint256 _amount) public {
uint256 ratio = _amount.div(totalSupply);
_burn(msg.sender, _amount);
uint256 rewards = ERC20(token_address).balanceOf(thiscontract);
uint256 pay = ratio.mul(rewards);
ERC20(token_address).transfer(msg.sender, pay);
}