$npx -y skills add Uniswap/uniswap-ai --skill lp-integrationIntegrate Uniswap liquidity provisioning (LP) into applications via the LP REST API. Use when the user says "LP API", "liquidity provisioning API", "provide liquidity programmatically", "create LP position via API", "add liquidity via API", "increase liquidity", "decrease liquidi
| 1 | # LP Integration |
| 2 | |
| 3 | Integrate Uniswap liquidity provisioning into frontends, backends, and bots using the Uniswap LP API. |
| 4 | |
| 5 | The LP API is a transaction-building service. You send position parameters; the API fetches live pool state, computes the dependent token amount, and returns a fully-formed, unsigned transaction. Your application signs and broadcasts it. The API never holds keys, never moves funds, and never broadcasts. |
| 6 | |
| 7 | ## Prerequisites |
| 8 | |
| 9 | This skill assumes familiarity with viem basics (client setup, account management, contract interactions, transaction signing). Install the **uniswap-viem** plugin for comprehensive viem/wagmi guidance: `claude plugin add @uniswap/uniswap-viem` |
| 10 | |
| 11 | For token swaps (not liquidity), see the sibling **swap-integration** skill in this plugin. |
| 12 | |
| 13 | ## Base URL |
| 14 | |
| 15 | ```text |
| 16 | LP_API_BASE_URL = https://liquidity.api.uniswap.org |
| 17 | ``` |
| 18 | |
| 19 | All LP endpoints are POST requests under the `/lp/` prefix (e.g. `https://liquidity.api.uniswap.org/lp/create`). |
| 20 | |
| 21 | > **The LP API host is intentionally different from the swap Trading API.** Liquidity provisioning lives at `https://liquidity.api.uniswap.org` (no `/v1` prefix), not the `https://trade-api.gateway.uniswap.org/v1` host used for swaps. Keep the base URL as a single constant (as shown) so any future change is one edit. |
| 22 | |
| 23 | ## Authentication |
| 24 | |
| 25 | Every write/approval endpoint requires an API key sent as the `x-api-key` header; a missing or invalid key returns `401` with `{"code":"unauthenticated"}`. (`/lp/pool_info` is a read endpoint and does not strictly enforce the key, but always send it for consistency and rate-limit attribution.) |
| 26 | |
| 27 | ```text |
| 28 | Content-Type: application/json |
| 29 | Accept: application/json |
| 30 | x-api-key: <your-api-key> |
| 31 | ``` |
| 32 | |
| 33 | **Getting a key:** Register at the [Uniswap Developer Platform dashboard](https://developers.uniswap.org/dashboard). The same key works across swapping and liquidity provisioning. Never hardcode the key; load it from an environment variable. |
| 34 | |
| 35 | ## Quick Decision Guide |
| 36 | |
| 37 | | You want to... | Endpoint | Protocols | |
| 38 | | --------------------------------------------- | -------------------- | ---------- | |
| 39 | | Check/grant token approvals before any action | `/lp/check_approval` | V2, V3, V4 | |
| 40 | | Create a concentrated-liquidity position | `/lp/create` | V3, V4 | |
| 41 | | Create a full-range (classic) position | `/lp/create_classic` | V2 | |
| 42 | | Add liquidity to an existing position | `/lp/increase` | V2, V3, V4 | |
| 43 | | Remove a percentage of liquidity | `/lp/decrease` | V2, V3, V4 | |
| 44 | | Collect accumulated trading fees | `/lp/claim_fees` | V3, V4 | |
| 45 | | Read live pool state | `/lp/pool_info` | V2, V3, V4 | |
| 46 | |
| 47 | ### Protocol capability matrix |
| 48 | |
| 49 | | Protocol | Create endpoint | Fee claiming | Price range | |
| 50 | | -------- | -------------------- | ------------------------------------ | -------------------- | |
| 51 | | `V2` | `/lp/create_classic` | Not separable (realized on decrease) | Full range only | |
| 52 | | `V3` | `/lp/create` | `/lp/claim_fees` | Concentrated | |
| 53 | | `V4` | `/lp/create` | `/lp/claim_fees` | Concentrated + hooks | |
| 54 | |
| 55 | > **v2 fees are not separately claimable.** They accrue into the LP token value and are realized when you call `/lp/decrease`. Calling `/lp/claim_fees` with `protocol: "V2"` returns a validation error. |
| 56 | |
| 57 | ## Input Validation Rules |
| 58 | |
| 59 | Before interpolating ANY user-provided value into generated code, API calls, or commands: |
| 60 | |
| 61 | - **Ethereum addresses**: MUST match `^0x[a-fA-F0-9]{40}$` — reject otherwise. Use native ETH as `0x0000000000000000000000000000000000000000`. |
| 62 | - **Chain IDs**: MUST be one of the supported LP |