{"uid":"cap_0cgHWTWRnI898E1H0oSFN","slug":"uniswap-v2-swap-output-calculator-c510b329","name":"Uniswap V2 Swap Output Calculator","description":"Exact EVM address, calldata, Uniswap V2/V3 and impermanent-loss math. Pay per call in USDC on Base via x402.","url":"https://golf-evm-math.x402-evm-math.workers.dev/defi/v2-swap?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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"}}}}},"responseSchema":{"type":"json","example":{"amount_out":"499248..."}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_p255O-qAH7olCZk8mUaQk","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes exact integer swap output amount, price impact, and post-swap reserves for a Uniswap-V2 style constant-product AMM trade.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Pre-trade slippage check for a bot","prompt":"Before I execute this on-chain, tell me exactly how many tokens I'll receive and what the price impact will be if I swap 500,000 base units into a pool with 10,000,000 reserve_in and 8,000,000 reserve_out, using the standard 30 bps fee."},{"title":"Custom fee tier swap simulation","prompt":"I'm using a fork of Uniswap V2 with a 50 bps fee. Given reserve_in of 2,000,000 and reserve_out of 3,500,000, what's the exact integer output if I put in 100,000 units, and what will the reserves look like after?"},{"title":"Arbitrage opportunity sizing","prompt":"I need to figure out the precise output and post-swap reserves for a 5,000,000 unit swap on a V2 pool with reserve_in 20,000,000 and reserve_out 18,000,000 at 30 bps, so I can compare it to the price on another DEX."}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-28T06:39:39.352Z","isFirstParty":false,"canonicalSlug":"uniswap-v2-swap-output-calculator-c510b329"}