I am using slither and I get the following medium severity error: performs a multiplication on the result of a division

Now this is the equation in question.

uint256 mult = (_type == 1 ? 5 : 2);
uint256 value = (((_amount / 1e18) * (getPrice() / 1e18)) / 10) * mult * 1e18;

I need some help to rewrite this equation to satisfy slither.

That equation is basically doing the following:

  • Gets the price of what they sent (getPrice is the current price of BNB and _amount is what they sent in wei)
  • Get the value of how many times it goes into $10
  • Multiply that value by a multiplier
  • Convert it back to wei
  • Gives answer on how many tokens to give to user

Any help on this would be greatly appreciated. Thanks!

1 Answer 1


Looks like this actually works and is much cleaner.

uint256 value = ((_amount * getPrice() * mult) / 10e18);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.