> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chance.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Uniswap

> Venue-aware verification for the Uniswap Trading API — quotes and swap transactions judged against your mandate, plus one-call swap preparation from escrow wallets.

Chance understands the Uniswap Trading API natively. Submit the **exact quote request, quote response, or swap transaction** your agent is about to execute and the harness will classify it deterministically, **re-quote the trade against the Trading API itself** (fresh output, enforced minimum, price impact), and judge it against your mandate with Uniswap's own documentation in the loop — returning a signed verdict whose `requestHash` binds to those exact bytes.

## What gets recognized

| Family | Payloads                                                                                                                                                                                                                                                                                    |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `swap` | `/v1/quote` requests (`tokenIn`, `tokenOut`, `amount`, `swapper`, `type`), the quote objects the API returns (`routing`, `input`/`output` with `minimumAmount`, `permitData`), and raw transactions targeting known Uniswap execution contracts (Universal Router, Permit2, the swap proxy) |

For every payload, the classifier decodes amounts out of their raw base units, reads the slippage (a **percent** in this API — `0.5` means 0.5%), surfaces the onchain-enforced `minimumAmount` (the real floor, not the optimistic estimate), and checks whether the output `recipient` redirects proceeds away from the swapper. Quote payloads are re-quoted independently, so a stale or doctored quote never stands as its own evidence. The judge reasons over:

> *UNISWAP SWAP QUOTE: 1 USDC → 0.00055958 WETH (enforced minimum 0.0005568 WETH), on Base (chainId 8453), swapper 0x397E…dd83, routing CLASSIC, slippage 0.5%, est. gas \$0.0021 — Independent re-quote (Uniswap Trading API, just now): 1 USDC → 0.00055912 WETH, enforced minimum 0.00055633 WETH, price impact 0.01%.*

## Swap from an escrow wallet in one call

Escrow wallets get a dedicated `escrow_swap` MCP tool — describe the trade in plain terms and Chance does the rest:

> Swap 1 USDC for WETH on base from my baseliquid wallet.

Under the hood, Chance quotes the trade (`/quote`), asks the API what approval is missing (`/check_approval`), and assembles the exact transaction batch — with a **bounded** approval for just this swap's amount instead of the API's default unlimited grant — then proposes the batch through the standard verification gate: simulated with state carry-over, judged against the wallet's mandate, executed immediately on an autonomous wallet with an ALLOW and a clean simulation, or held behind a one-time approval link. UniswapX routings (signed orders rather than transactions) are refused rather than half-verified.

## Use it from your bot

Wrap the quote you were already going to execute:

```ts theme={null}
const quoteRequest = {
  tokenIn: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",  // USDC on Base
  tokenOut: "0x4200000000000000000000000000000000000006", // WETH on Base
  tokenInChainId: 8453,
  tokenOutChainId: 8453,
  type: "EXACT_INPUT",
  amount: "1000000",              // 1 USDC (6 decimals)
  swapper: "0x397EE1E74FCBE42b76A39B42521E9ef04E16dd83",
  slippageTolerance: 0.5,         // PERCENT — 0.5%
};

const res = await fetch("https://harness.chance.cc/api/v1/intent", {
  method: "POST",
  headers: { "x-api-key": process.env.CHANCE_API_KEY!, "Content-Type": "application/json" },
  body: JSON.stringify({
    intent: "DeFi on Base only. Swaps between USDC/WETH, max $200 per trade, max 1% slippage, proceeds stay in my wallet.",
    venue: "uniswap",
    action: quoteRequest, // the exact payload — the verdict binds to these bytes
  }),
});

const { verdict, reasoning } = await res.json();
if (verdict !== "ALLOW") throw new Error(`Blocked: ${reasoning}`);
// only now call /v1/swap and broadcast the returned transaction
```

You can also pass the full quote object the API returned, or the final swap transaction itself — all three shapes are auto-detected (`venue` is optional).

## Use it from Claude or ChatGPT

Add the hosted connector (`https://harness.chance.cc/api/mcp`, see [Connectors](/connectors)) and give your agent one standing instruction:

> Before executing any Uniswap trade, call `verify_intent` with my rules as the intent and the exact quote or transaction as the action. To trade from my escrow wallet, use `escrow_swap` and relay any approval link to me verbatim.

## How the harness knows Uniswap

The venue ships a versioned knowledge snapshot of the Trading API — endpoints and shapes (`/check_approval`, `/quote`, `/swap`), the Permit2 and proxy-approval flows, routing types (CLASSIC vs UniswapX orders), supported chains, execution-contract addresses, and error semantics — every page content-hashed and cited in the verdict's transcript. Slippage-unit confusion, unlimited-allowance defaults, redirected recipients, and permit-borne spend authority are called out explicitly in the judge's brief.
