From b5264a7c66758341c42d32e91a747d34f0c18f31 Mon Sep 17 00:00:00 2001 From: emilio Date: Tue, 11 Aug 2020 12:32:34 +0200 Subject: [PATCH] Removed rayPow --- contracts/libraries/WadRayMath.sol | 16 ---------------- test/helpers/utils/math.ts | 15 --------------- 2 files changed, 31 deletions(-) diff --git a/contracts/libraries/WadRayMath.sol b/contracts/libraries/WadRayMath.sol index bf3495b3..0dc29657 100644 --- a/contracts/libraries/WadRayMath.sol +++ b/contracts/libraries/WadRayMath.sol @@ -113,20 +113,4 @@ library WadRayMath { return a.mul(WAD_RAY_RATIO); } - /** - * @dev calculates base^exp. The code uses the ModExp precompile - * @return z base^exp, in ray - */ - //solium-disable-next-line - function rayPow(uint256 x, uint256 n) internal pure returns (uint256 z) { - z = n % 2 != 0 ? x : RAY; - - for (n /= 2; n != 0; n /= 2) { - x = rayMul(x, x); - - if (n % 2 != 0) { - z = rayMul(z, x); - } - } - } } diff --git a/test/helpers/utils/math.ts b/test/helpers/utils/math.ts index a56de5e0..df6165d2 100644 --- a/test/helpers/utils/math.ts +++ b/test/helpers/utils/math.ts @@ -13,7 +13,6 @@ declare module 'bignumber.js' { rayDiv: (a: BigNumber) => BigNumber; rayToWad: () => BigNumber; wadToRay: () => BigNumber; - rayPow: (n: BigNumber) => BigNumber; } } @@ -65,17 +64,3 @@ BigNumber.prototype.rayToWad = function (): BigNumber { BigNumber.prototype.wadToRay = function (): BigNumber { return this.multipliedBy(WAD_RAY_RATIO).decimalPlaces(0, BigNumber.ROUND_DOWN); }; - -BigNumber.prototype.rayPow = function (n: BigNumber): BigNumber { - let z = !n.modulo(2).eq(0) ? this : new BigNumber(RAY); - let x = new BigNumber(this); - - for (n = n.div(2); !n.eq(0); n = n.div(2)) { - x = x.rayMul(x); - - if (!n.modulo(2).eq(0)) { - z = z.rayMul(x); - } - } - return z; -};