fixed_pow
Raises an 18-decimal fixed-point (WAD) base to a WAD exponent as exp(y * ln(x)), with integer arithmetic only, for example to annualise a growth factor. NULL propagates. 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-16 relative for results of 1e17 or more (fixed_pow(2e18, 1e18) is 1999999999999999998).
Example
Runs locally
API reference
fixed_pow(UINT256, UINT256) #
Raises an 18-decimal fixed-point (WAD) base to a WAD exponent as exp(y * ln(x)), with integer arithmetic only, for example to annualise a growth factor. NULL propagates.
Returns
| Name | Type |
|---|---|
result | UINT256 |
WAD x^y. UINT256 (x / 1e18)^(y / 1e18) * 1e18 = exp(y * ln(x)); 1e18 when y is 0 and 0 when x is 0. NULL for NULL input. y * ln(x) outside [-41e18, 130e18] errors: annualising a large move over a short window (a 45% gain or an 11% loss in one day) leaves it.