# 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).

Canonical HTML: <https://determica.com/docs/functions/fixed_pow>

- Kind: scalar function
- Category: [Fixed-point and AMM math](/docs/category/fixed-point-and-amm-math.md)
- Tags: Fixed Point Math, Deterministic, Offline, Types

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).

## Overload 1: fixed_pow(UINT256, UINT256)

```sql
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.

- Kind: scalar
- Execution context: Offline
- Behavior: Transform
- Execution modes: Offline
- Input shape: Scalar Arguments
- Planning contract: Runtime
- Cardinality: One Per Input
- Determinism: Deterministic
- Return shape: Scalar
- Schema stability: Fixed
- Stability: Stable
- Side effects: None documented

### Inputs

- `x` (UINT256; required; positional) — UINT256 base with 18 decimals, below 2^255.
- `y` (UINT256; required; positional) — UINT256 exponent with 18 decimals, below 2^254 / 1e20.

### Returns

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.

- `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.

### Examples

_Local SQL · Local_

```sql
-- Annualise a 7-day growth factor of 1.003456789012345678: (growth)^(365 / 7) - 1
SELECT format_units(fixed_pow(1003456789012345678::UINT256, muldiv(365::UINT256, 1000000000000000000::UINT256, 7::UINT256)) - 1000000000000000000::UINT256, 18) AS apy;
-- => [{"apy":"0.197140784436020924"}]
```

## Related functions

- [fixed_exp](/docs/functions/fixed_exp.md) — See Also
- [fixed_ln](/docs/functions/fixed_ln.md) — See Also
- [fixed_div](/docs/functions/fixed_div.md) — Usually Before
- [format_units](/docs/functions/format_units.md) — Usually After
