# let users swap tokens inside my app

> 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.

## Recommended stack

- **Uniswap** (supporting_protocol) — readiness 94/100, difficulty medium — AMM with the Universal Router for routing swaps, plus SDKs for quoting and building trades.
- **Pyth Network** (oracle_and_price_data) — readiness 82/100, difficulty medium — Reference prices for slippage limits and showing fair quotes to users.
- **Base** (settlement_or_execution) — readiness 82/100, difficulty low — Low-cost L2 execution so swap gas stays affordable for consumer users.

## 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.

## What the agent receives

```json
{
  "intent": "I want to add onchain token swaps to my dapp",
  "matched_intent": "swap-tokens-in-my-app",
  "recommended_stack": [
    {
      "slug": "uniswap",
      "name": "Uniswap",
      "role": "supporting_protocol",
      "readiness_score": 94,
      "integration_difficulty": "medium",
      "reason": "AMM with the Universal Router for routing swaps, plus SDKs for quoting and building trades."
    },
    {
      "slug": "pyth",
      "name": "Pyth Network",
      "role": "oracle_and_price_data",
      "readiness_score": 82,
      "integration_difficulty": "medium",
      "reason": "Reference prices for slippage limits and showing fair quotes to users."
    },
    {
      "slug": "base",
      "name": "Base",
      "role": "settlement_or_execution",
      "readiness_score": 82,
      "integration_difficulty": "low",
      "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."
  ],
  "generated_with": "composewith.eth",
  "registry_version": "2026.06.10-8752c9d"
}
```

---
Canonical: https://composewith.eth/intents/swap-tokens-in-my-app
