# AMM Out Given In

> AMM Out Given In is a paid API for AI agents from api.delx.ai, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-13).

Computes the output token amount for a given input in a constant-product (x*y=k) AMM swap using caller-supplied reserves and fee, returning the result as deterministic JSON.

## Facts

- Endpoint: POST https://api.delx.ai/api/v1/x402/amm-out-given-in
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/amm-out-given-in-72230e47
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap__O0VP-Idpw3HgjbH6DOEt

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 amm-out-given-in-72230e47 -d '<json body>'
```

Example prompt: Using the constant-product AMM formula with a 30 bps fee, calculate how many tokens I'd receive if I swap 1000 units into a pool with 500000 reserve_in and 400000 reserve_out.

## When to prefer this

Choose this endpoint when you already have pool reserves and need fast, deterministic, offline AMM output math without requiring an RPC node, live price feed, or API key. Ideal for backtesting, pre-trade simulation, arbitrage sizing, or any scenario where you want pure constant-product (x*y=k) calculations with a fee in basis points at minimal cost ($0.001 USDC). Not suitable when you need live, on-chain reserve data — pair it with a reserve-fetching tool for that case.

## Known failure modes

- Missing required fields (amount_in, reserve_in, reserve_out, fee_bps) result in validation errors
- Zero or negative reserve values may cause division-by-zero or invalid math errors
- Payment failure via x402 protocol prevents the computation from being returned
- Integer overflow if extremely large reserve or amount values are provided
- fee_bps outside valid range (e.g. >= 10000) may return an error or nonsensical result

## How this service works

Constant-product AMM output amount for a given input size. Call when simulating x*y=k swaps offline from reserves you already know. Returns amount out and new reserves as deterministic JSON for $0.001 USDC via x402 on Base. First-party local math only—no RPC, live market feed, API keys, storage, or mediagen. Advisory only; the caller owns capital, risk, and production controls.

## Output

Returns a deterministic JSON object containing the computed output token amount (amount_out) and the updated pool reserves (new_reserve_in, new_reserve_out) after the simulated swap, based purely on local constant-product math with the provided fee.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "fee_bps": {
   "type": "integer",
   "description": "Input field: fee bps."
  },
  "amount_in": {
   "type": "integer",
   "description": "Input field: amount in."
  },
  "reserve_in": {
   "type": "integer",
   "description": "Input field: reserve in."
  },
  "reserve_out": {
   "type": "integer",
   "description": "Input field: reserve out."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "schema": "delx/util-amm-out-given-in/v1",
  "fee_bps": 30,
  "amount_in": 10,
  "amount_out": 9.871580343970614
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/amm-out-given-in-72230e47/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.delx.ai](https://www.zero.xyz/host/api.delx.ai/llms.txt)
