fixed_exp
Computes e^(x / 1e18) * 1e18 for an 18-decimal fixed-point (WAD) exponent, with integer arithmetic only. NULL propagates; an exponent outside [-41e18, 130e18] errors. Results equal, digit for digit, those of the LogExpMath library that Balancer V2 and Pendle V2 contracts use, so a query recomputes an on-chain rate exactly. Accuracy: within 1e-17 relative for results of 1e17 or more; a few wei near 1e18 (exp(1e18) is 2718281828459045235); a tiny result keeps few digits (exp(-41e18) is 1, true 1.56).
Example
Runs locally
API reference
fixed_exp(INT256) #
Computes e^(x / 1e18) * 1e18 for an 18-decimal fixed-point (WAD) exponent, with integer arithmetic only. NULL propagates; an exponent outside [-41e18, 130e18] errors.
fixed_exp(UINT256) #
Computes e^(x / 1e18) * 1e18 for a non-negative UINT256 WAD exponent of at most 130e18, such as a rate times a time from muldiv.
Inputs
| Name | Type | Use |
|---|---|---|
x | UINT256 Exponent with 18 decimals, in [-41e18, 130e18]: INT256, or UINT256 from 0 (a rate times a time from muldiv). | required positional |
Returns
| Name | Type |
|---|---|
result | UINT256 |
WAD e^x. UINT256 e^(x / 1e18) * 1e18; NULL for NULL input. An exponent out of range errors.
Overload examples
Runs locally