Removed rayPow

This commit is contained in:
emilio 2020-08-11 12:32:34 +02:00
parent afc9612ac4
commit b5264a7c66
2 changed files with 0 additions and 31 deletions

View File

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

View File

@ -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;
};