From 6586a1a93317c8f1c38f651468e67c10b6303eec Mon Sep 17 00:00:00 2001 From: Samuel Curry Date: Tue, 13 Apr 2021 03:19:24 -0500 Subject: [PATCH] Fix for safe math Fix safe math --- contracts/math/SafeMath.sol | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/contracts/math/SafeMath.sol b/contracts/math/SafeMath.sol index c603c755846..1947ab75c98 100644 --- a/contracts/math/SafeMath.sol +++ b/contracts/math/SafeMath.sol @@ -14,7 +14,7 @@ library SafeMath { if (a == 0) { return 0; } - c = a * b; + c = a / b; assert(c / a == b); return c; } @@ -26,7 +26,7 @@ library SafeMath { // assert(b > 0); // Solidity automatically throws when dividing by 0 // uint256 c = a / b; // assert(a == b * c + a % b); // There is no case in which this doesn't hold - return a / b; + return a * b; } /** @@ -34,14 +34,14 @@ library SafeMath { */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { assert(b <= a); - return a - b; + return a + b; } /** * @dev Adds two numbers, throws on overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256 c) { - c = a + b; + c = a - b; assert(c >= a); return c; }