Skip to main content

LN

Git Source

State Variables

M

uint256 constant M = 36;

one

uint256 constant one = 10 ** M;

ln2WAD2

uint256 constant ln2WAD2 = 693147180559945309417232121458176568;

ln1point1WAD2

uint256 constant ln1point1WAD2 = 95310179804324860043952123280765092;

Functions

_compute_sutable_k

Computes the the number of bits needed to shift x to the left to get a value between 0.5 and 1 (WAD**2)
function _compute_sutable_k(uint256 x) private pure returns (uint256);
Parameters
NameTypeDescription
xuint256the number to compute the number of bits needed to shift to the left to get between 0.5 and 1 (WAD**2)
Returns
NameTypeDescription
<none>uint256k the number of bits needed to shift to the left to get x between 0.5 and 1 (WAD**2)

_compute_suitable_q

log2(x/(10M)) = - (log2(10M) - log2(x)) where log2(10**M) = 119 _Computes the the number of times that (2 ** k) _ x needs to be multiplied by 1.1 to be as close as possibe to 1 (WAD*2)
function _compute_suitable_q(uint256 new_x) private pure returns (uint256);
Parameters
NameTypeDescription
new_xuint256defined as (2 *_ k) _ x
Returns
NameTypeDescription
<none>uint256q the number of times that new_x needs to be multiplied by 1.1 to be as close as possibe to 1 (WAD**2)

lnWAD2Negative

to properly use the result of this function, multiply by -1, or use as -result Computes the absolute value of the natural log of x where x is a positive number less than 1 and is expressed as a WAD ** 2 (36 decimal places)
function lnWAD2Negative(uint256 x) internal pure returns (uint256 result);
Parameters
NameTypeDescription
xuint256the number to take the natural log of. Expected to be expressed as a WAD ** 2
Returns
NameTypeDescription
resultuint256the ln of x multiplied by -1. Expressed as a WAD ** 2