code-423n4 / 2021-04-vader-findings

1 stars 0 forks source link

Divide before multiply #255

Open code423n4 opened 3 years ago

code423n4 commented 3 years ago

Handle

a_delamo

Vulnerability details

Here you have more information: https://gist.github.com/alexon1234/e5038a9f66136ae210be692f8803d874

strictly-scarce commented 3 years ago

Can't quite understand the assertion that a division is made before a multiply in the code outlined

uint _units = (((P * part1) + part2) / part3);
    return (_units * slipAdjustment) / one;  // Divide by 10**18

_units will be 0 -> 2**256. slipAdjustment will be 0 -> 10**18 one is 10**18

 // returns 0
  return (0 * 10**18) / 10**18;
  return (2**256 * 0) / 10**18;
 return (<10**9 * <10**9) / 10**18;
   // returns  non-zero
  return (>=10**9 * >=10**9) / 10**18;