# finmath Uniswap v3 Token Amounts Calculator

> finmath Uniswap v3 Token Amounts Calculator is a paid API for AI agents from finmath.qzqh5rrbkz.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-09-15).

Calculates the token amounts (amount0 and amount1) held in a Uniswap v3 liquidity position given current price, liquidity, and the position's price range.

## Facts

- Endpoint: POST https://finmath.qzqh5rrbkz.workers.dev/v1/uniswap_v3_amounts
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/finmath-uniswap-v3-token-amounts-calculator-928d6c06
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_yHb01PDhIxTHQspG-q4VW

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability finmath-uniswap-v3-token-amounts-calculator-928d6c06 -d '<json body>'
```

Example prompt: What are the actual token amounts in my Uniswap v3 position? The current price is 1800, the liquidity is 5000000, and the position range goes from 1600 to 2000.

## When to prefer this

Use this endpoint when you need exact, deterministic Uniswap v3 token amount calculations — especially when LLM arithmetic is unreliable for concentrated liquidity math. Prefer this over manual computation or general-purpose math tools when dealing with Uniswap v3 positions where precision matters for portfolio tracking, rebalancing decisions, or impermanent loss analysis.

## Known failure modes

- Missing required fields (price, liquidity, lower_price, upper_price) returns a 400-level error
- Non-numeric or negative values for price or liquidity may return a validation error
- If current price is outside or inside the range, only one token amount may be non-zero — this is expected behavior, not an error
- Payment failure (insufficient USDC balance) returns 402 Payment Required

## How this service works

Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.

## Output

Returns a result object containing the computed token amounts (amount0 and amount1) for the given Uniswap v3 liquidity position, along with metadata about the calculation. Amounts reflect how much of each token is held given the current price relative to the position's tick range.

## Example request

```json
{
 "price": 1500.5,
 "liquidity": 1000000,
 "lower_price": 1000,
 "upper_price": 2000
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "price",
  "liquidity",
  "lower_price",
  "upper_price"
 ],
 "properties": {
  "price": {
   "type": "number",
   "description": "price"
  },
  "liquidity": {
   "type": "number",
   "description": "liquidity"
  },
  "lower_price": {
   "type": "number",
   "description": "lower_price"
  },
  "upper_price": {
   "type": "number",
   "description": "upper_price"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "result",
  "meta"
 ],
 "properties": {
  "meta": {
   "type": "object"
  },
  "result": {}
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/finmath-uniswap-v3-token-amounts-calculator-928d6c06/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from finmath.qzqh5rrbkz.workers.dev](https://www.zero.xyz/host/finmath.qzqh5rrbkz.workers.dev/llms.txt)
