hmm... maybe. ... this is all the pertinent code: uint256[] memory _amountOutMin = IUniswapV2Router02(UNISWAP_V2_ROUTER).getAmountsOut(_amountIn, path); uint256 amountOut = _amountOutMin[_amountOutMin.length -1]; uint256 beforeBalance = IERC20(_token).balanceOf(address(this)); IUniswapV2Router02(UNISWAP_V2_ROUTER).swapExactTokensForTokensSupportingFeeOnTransferTokens(_amountIn, amountOut.div(2), path, address(this), block.timestamp) uint256 tokensReceived = (IERC20(_token).balanceOf(address(this))).sub(beforeBalance); return result = ((1).sub((tokensReceived).div(amountOut))).mul(100);
i think u should add the 'using SafeMath for uint256' and then fix ur formula (is definately underflow)
oh yea... thats in the contract that line. But i guess you're right, ill try figure out a different fomula... thanks anyway! :)
You cannot apply safemath on integer constants
Interesting. So I need to declare it as variable prior... Eg uint256 one = 1 then use one.sub(.... ?
I can't believe people still use SafeMath
What’s wrong with safemath? Honest question
What's it's use in 0.8.0 an up
if you are using ^0.8 it handles the overflow and underflow errors
Oh, it’s no longer needed? Awesome!
Amazing i didn’t know that
Thank you
I'll give it a go. Thanks!
Обсуждают сегодня