mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Removed rayPow
This commit is contained in:
parent
afc9612ac4
commit
b5264a7c66
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user