{
  "schema_version": "intent.v1",
  "slug": "swap-tokens-in-my-app",
  "title": "let users swap tokens inside my app",
  "audience": "builder",
  "prompt": "I want to add onchain token swaps to my dapp",
  "maps_to": [
    "dex",
    "swap",
    "amm",
    "defi"
  ],
  "stack": [
    {
      "slug": "uniswap",
      "role": "supporting_protocol",
      "reason": "AMM with the Universal Router for routing swaps, plus SDKs for quoting and building trades."
    },
    {
      "slug": "pyth",
      "role": "oracle_and_price_data",
      "reason": "Reference prices for slippage limits and showing fair quotes to users."
    },
    {
      "slug": "base",
      "role": "settlement_or_execution",
      "reason": "Low-cost L2 execution so swap gas stays affordable for consumer users."
    }
  ],
  "excluded_candidates": [],
  "risks": [
    "Always set an explicit minimum-output / slippage bound; unprotected swaps are an MEV target.",
    "Quote and execution prices can diverge; refresh quotes close to submission."
  ],
  "next_steps": [
    "Integrate the Uniswap SDK to fetch quotes and build swap calldata.",
    "Add slippage protection and a reference price check before submitting.",
    "Test on the chosen L2's testnet, then mainnet with small amounts."
  ],
  "why": "Uniswap supplies the liquidity and routing for in-app swaps, a price oracle like Pyth backs slippage and quote sanity checks, and a low-cost L2 such as Base keeps per-swap gas affordable.",
  "verified_at": "2026-06-02"
}