{"uid":"cap__O0VP-Idpw3HgjbH6DOEt","slug":"amm-out-given-in-72230e47","name":"AMM Out Given In","description":"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.","url":"https://api.delx.ai/api/v1/x402/amm-out-given-in","method":"POST","headers":{},"bodySchema":{"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."}}},"responseSchema":{"type":"json","example":{"schema":"delx/util-amm-out-given-in/v1","fee_bps":30,"amount_in":10,"amount_out":9.871580343970614}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.001","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.001/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.001","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_UQvrseaPkQBNMKQ3N_0Qv","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.001","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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.","exampleUseCases":[{"title":"Pre-trade swap simulation","prompt":"I want to simulate swapping 5000 USDC into a pool that has 2000000 USDC and 1500000 TOKEN in reserves with a 30 bps fee — how many TOKEN tokens would I get out and what would the new reserves be?"},{"title":"Backtesting AMM price impact","prompt":"For my backtesting script, calculate the output amount and updated reserves for a 10000-unit input into a pool with 800000 reserve_in and 600000 reserve_out using a 25 bps fee."},{"title":"Arbitrage opportunity sizing","prompt":"I think there's an arbitrage opportunity. Can you calculate how many tokens come out if I put 50000 units in, with reserve_in at 3000000, reserve_out at 2800000, and a 30 bps fee?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T19:02:48.295Z","isFirstParty":false}