Catalog/cryptocalc-amm-swap-output

Calculators

AMM swap output & price impact calculator API

Compute a constant-product (x·y=k) AMM swap: out = rOut·(in·(1−fee))/(rIn + in·(1−fee)), with the spot price, effective price, and price impact. Deterministic AMM math. Answers 'how much will I get from this swap','price impact of a 10k swap','Uniswap v2 output amount'.

Price$0.01per request
MethodPOST
Route/v1/calc/cryptocalc-amm-swap-output
StatusLive
MIME typeapplication/json
Rate limit120/minute
CacheNo cache
calccryptodefiammswapprice-impactuniswapslippage
API URLhttps://x402.hexl.dev/v1/calc/cryptocalc-amm-swap-output
Integration docs
Example request
{
  "reserveIn": 1000000,
  "reserveOut": 500,
  "amountIn": 10000,
  "fee": 0.003
}
Example response
{
  "formula": "out = rOut·(in·(1−fee)) / (rIn + in·(1−fee))",
  "amountIn": 10000,
  "feePct": 0.3,
  "amountOut": 4.93579017,
  "spotPrice": 0.0005,
  "effectivePrice": 0.000493579,
  "priceImpactPct": 1.2842,
  "newReserveIn": 1010000,
  "newReserveOut": 495.06421,
  "interpretation": "moderate-impact"
}
Input schema
{
  "type": "object",
  "required": [
    "reserveIn",
    "reserveOut",
    "amountIn"
  ],
  "properties": {
    "reserveIn": {
      "type": "number",
      "description": "input-token reserve",
      "examples": [
        1000000
      ]
    },
    "reserveOut": {
      "type": "number",
      "description": "output-token reserve",
      "examples": [
        500
      ]
    },
    "amountIn": {
      "type": "number",
      "examples": [
        10000
      ]
    },
    "fee": {
      "type": "number",
      "description": "decimal swap fee, e.g. 0.003",
      "examples": [
        0.003
      ]
    }
  }
}
Output schema
{
  "type": "object",
  "additionalProperties": true
}