# Uniswap V2 Swap Output Calculator

> Uniswap V2 Swap Output Calculator is a paid API for AI agents from golf-evm-math.x402-evm-math.workers.dev, paid per call via x402, $0.002/call, status unknown (last checked 2026-10-28).

Computes exact integer swap output amount, price impact, and post-swap reserves for a Uniswap-V2 style constant-product AMM trade.

## Facts

- Endpoint: GET https://golf-evm-math.x402-evm-math.workers.dev/defi/v2-swap?utm_source=zero.xyz
- Price: $0.002/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-28
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/uniswap-v2-swap-output-calculator-c510b329
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_0cgHWTWRnI898E1H0oSFN

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 uniswap-v2-swap-output-calculator-c510b329
```

Example prompt: I want to swap 1,000,000 units of token A into token B on a Uniswap V2 pool where reserve_in is 50,000,000 and reserve_out is 80,000,000 — with a standard 30 bps fee. What's the exact output amount and price impact?

## When to prefer this

Choose this endpoint when you need bit-accurate, integer-safe Uniswap V2 swap math without running a local simulation or calling an RPC node. It is ideal for bots, arbitrage engines, and smart-contract pre-flight checks that require exact on-chain-equivalent arithmetic (not floating-point approximations) for V2-style constant-product AMMs.

## Known failure modes

- Missing required parameters (reserve_in, reserve_out, amount_in) returns an error
- Non-integer or float values for reserve/amount fields may cause rejection
- amount_in exceeding reserve_out causes an invalid or zero output
- Very large integers beyond uint256 range may produce overflow errors
- Network or worker timeout returns a 5xx error

## How this service works

Exact EVM address, calldata, Uniswap V2/V3 and impermanent-loss math. Pay per call in USDC on Base via x402.

## Output

Returns an exact integer amount_out (in base units) representing the tokens received, along with the price impact as a percentage and the updated reserve balances after the hypothetical swap — all computed using integer arithmetic consistent with Uniswap V2 smart contract logic.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "properties": {}
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object"
    }
   }
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "amount_out": "499248..."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/uniswap-v2-swap-output-calculator-c510b329/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from golf-evm-math.x402-evm-math.workers.dev](https://www.zero.xyz/host/golf-evm-math.x402-evm-math.workers.dev/llms.txt)
