169 похожих чатов

16 ответов

13 просмотров

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);

Drew Diligence-(*decentralized only) Автор вопроса
twiddles
hmm... maybe. ... this is all the pertinent code: ...

i think u should add the 'using SafeMath for uint256' and then fix ur formula (is definately underflow)

Drew Diligence (*decentralized only)
i think u should add the 'using SafeMath for uint2...

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

Grim (Travelling)
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

Mitashi
I can't believe people still use SafeMath

What’s wrong with safemath? Honest question

Gerald Maximus
What’s wrong with safemath? Honest question

if you are using ^0.8 it handles the overflow and underflow errors

Mitashi
What's it's use in 0.8.0 an up

Oh, it’s no longer needed? Awesome!

Mitashi
Ye

Thank you

Grim (Travelling)
That'll work

I'll give it a go. Thanks!

Похожие вопросы

Обсуждают сегодня

я не магистр хаскеля, но разве не может лейзи тип конвертнуться в не-лейзи запросив вычисление содержимого прям при инициализации?
deadgnom32 λ madao
49
читать файл максимально быстро? странный вопрос))
zamtmn
53
How to create an OS in C? what to study?
Linus
18
Привет, кто может сделать юзербота с апи? Задачи: - создавать группы - создавать каналы - задавать для созданных каналов аватарку или эмоджи, имя группы - добавлять в группы...
Lencore
11
тоесть, указав return eax, сгенерируется никому ненужная инструкция mov eax,eax ?
Aiwan \ (•◡•) / _bot
24
Компания Elif ищет менеджера проектов, который будет заниматься поиском и ведением новых проектов. Прежде чем приступить к работе, вам нужно пройти наш недельный курс, где вы ...
Elif
5
@HemulGM Параметры у AddStream поменялись? Несостыковка какая-то
Катерина Свиридова
12
Подскажите, есть какие-то события создания/уничтожения у TFrame по типу TForm (OnCreate и OnClose/OnDestroy) ? Как отловить создание TFrame и "перед" уничтожением. На Tframe р...
Денис
8
а чем хуже?
Alexey Kulakov
10
Компания Elif ищет менеджера проектов, который будет заниматься поиском и ведением новых проектов. Прежде чем приступить к работе, вам нужно пройти наш недельный курс, где вы ...
Elif
1
Карта сайта